Merge branch 'addMissingInvoiceMonthOnCreate' into 'develop'

Add missing invoice month on create

See merge request service-web-lab/support-web!3
This commit is contained in:
Vincent BRIDIER 2022-08-31 10:28:14 +00:00
commit 0298fd82d2
2 changed files with 4 additions and 2 deletions

View file

@ -29,4 +29,6 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=noreply-sw@ldc.fr
MAIL_FROM_NAME="${APP_NAME}"
MAIL_LIST_SERVICEWEB=equipe.web@ldc.fr
MAIL_ADMIN=equipe.web@ldc.fr
MAIL_ADMIN=equipe.web@ldc.fr
LDC_STATUS_CHECKER_API_KEY=

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'),