Apply changes when creating invoices for projects.
All checks were successful
Build project image / Build-and-release-image (push) Successful in 3m9s

This commit is contained in:
2025-05-13 16:00:41 +02:00
parent f478b4aed6
commit e1f579c7fd
6 changed files with 22 additions and 28 deletions

View File

@@ -43,25 +43,6 @@ class Invoice extends Model
'localized_state'
];
/**
* Set the project_count variable automatically, if a project is related to this invoice.
*/
public static function boot(): void
{
parent::boot();
self::creating(function (Invoice $invoice) {
if (is_null($invoice->project_id)) {
return true;
}
if ($invoice->type != '326') {
return true;
}
$projectMax = Invoice::where('project_id', '=', $invoice->project_id)->max('project_count') + 1;
$invoice->project_count = $projectMax;
return true;
});
}
/**
* Get the invoice state as translated string.
*/