refactor: 견적 산출 서비스 DB 기반으로 재작성
- Quote 수식 모델 추가 (mng 패턴 적용) - QuoteFormula: 수식 정의 (input/calculation/range/mapping) - QuoteFormulaCategory: 카테고리 정의 - QuoteFormulaItem: 품목 출력 정의 - QuoteFormulaRange: 범위별 값 정의 - QuoteFormulaMapping: 매핑 값 정의 - FormulaEvaluatorService 확장 - executeAll(): 카테고리별 수식 실행 - evaluateRangeFormula/evaluateMappingFormula: QuoteFormula 기반 평가 - getItemPrice(): prices 테이블 연동 - QuoteCalculationService DB 기반으로 재작성 - 하드코딩된 품목 코드/로직 제거 - quote_formulas 테이블 기반 동적 계산 - getInputSchema(): DB 기반 입력 스키마 생성 - Price 모델 수정 - items 테이블 연동 (products/materials 대체) - ITEM_TYPE 상수 업데이트 (FG/PT/RM/SM/CS)
This commit is contained in:
70
app/Models/Quote/QuoteFormulaItem.php
Normal file
70
app/Models/Quote/QuoteFormulaItem.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Quote;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 수식 품목 출력 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $formula_id
|
||||
* @property string $item_code
|
||||
* @property string $item_name
|
||||
* @property string|null $specification
|
||||
* @property string $unit
|
||||
* @property string $quantity_formula
|
||||
* @property string|null $unit_price_formula
|
||||
* @property int $sort_order
|
||||
*/
|
||||
class QuoteFormulaItem extends Model
|
||||
{
|
||||
protected $table = 'quote_formula_items';
|
||||
|
||||
protected $fillable = [
|
||||
'formula_id',
|
||||
'item_code',
|
||||
'item_name',
|
||||
'specification',
|
||||
'unit',
|
||||
'quantity_formula',
|
||||
'unit_price_formula',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'sort_order' => 0,
|
||||
];
|
||||
|
||||
// =========================================================================
|
||||
// Relationships
|
||||
// =========================================================================
|
||||
|
||||
public function formula(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(QuoteFormula::class, 'formula_id');
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Helper Methods
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 품목 표시 문자열
|
||||
*/
|
||||
public function getDisplayNameAttribute(): string
|
||||
{
|
||||
$name = "[{$this->item_code}] {$this->item_name}";
|
||||
|
||||
if ($this->specification) {
|
||||
$name .= " ({$this->specification})";
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user