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

@@ -36,6 +36,7 @@ class Project extends Model
'end',
'customer_email',
'customer_name',
'next_invoice_count',
];
@@ -56,6 +57,14 @@ class Project extends Model
return (is_null($this->start_date)) ? '' : Carbon::createFromFormat('Y-m-d', $this->start_date)->format('d.m.Y');
}
/**
* Get the next invoice number for this project.
*/
public function getNextInvoiceCountAttribute(): int
{
return $this->invoices()->max('project_count') + 1 ?? 1;
}
/**
* Get the end_date attribute in local format.
*/
@@ -72,6 +81,9 @@ class Project extends Model
return $this->belongsTo(Customer::class)->withTrashed();
}
/**
* Get the invoices for this project.
*/
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);