Hoan thien core finance v2

This commit is contained in:
2026-04-25 04:04:14 +00:00
parent 86216ef872
commit 002c9a8b99
39 changed files with 1308 additions and 89 deletions

View File

@@ -33,6 +33,11 @@ class Contract extends Model
return $this->belongsTo(Product::class);
}
public function paymentTemplate()
{
return $this->belongsTo(PaymentTemplate::class);
}
public function customers()
{
return $this->belongsToMany(Customer::class, 'contract_customers')
@@ -73,6 +78,19 @@ class Contract extends Model
return $this->hasMany(PaymentFine::class);
}
/**
* Giá trị sau chiết khấu.
*/
public function getFinalValueAttribute(): float
{
$result = \App\Services\DiscountEngine::calculate(
(float) $this->total_value,
$this->discount_details
);
return $result['final_value'];
}
protected static function booted()
{
static::saving(function ($contract) {