Model Invoice : Add missing month on create

This commit is contained in:
Jérémy Munsch 2022-08-31 12:06:30 +02:00
parent 3045a809b3
commit 74801fad1b
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -251,7 +251,7 @@ class Invoice extends Model
static::creating(function (self $model) {
$model->ref = \sprintf(
'%s_%s_%s',
Carbon::now()->isoFormat('YYYY'),
Carbon::now()->isoFormat('YYYY-MM'),
Str::padLeft((Invoice::whereYear('created_at', Carbon::now()->isoFormat('YYYY'))
->whereMonth('created_at', Carbon::now()->isoFormat('MM'))
->count() + 1) ?: 1, 4, '0'),