Merge branch '90-invoice-filters' into 'develop'
feat: ✨ add awaiting signature/invoicing filters and auto-set...
See merge request ldc-web/projets/support-web!121
This commit is contained in:
commit
c88f3e8d52
3 changed files with 27 additions and 8 deletions
|
|
@ -8,10 +8,12 @@ enum InvoiceStatusEnum: int
|
|||
{
|
||||
use BaseEnum;
|
||||
|
||||
case opened = 1;
|
||||
case refused = 2;
|
||||
case canceled = 3;
|
||||
case archived = 4;
|
||||
case opened = 1;
|
||||
case refused = 2;
|
||||
case canceled = 3;
|
||||
case archived = 4;
|
||||
case awaiting_signature = 5;
|
||||
case awaiting_invoicing = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
|
|
@ -21,5 +23,7 @@ enum InvoiceStatusEnum: int
|
|||
self::refused->name => "Refusé (par le client ou aucune réponse de sa part)",
|
||||
self::canceled->name => "Annulé (supprimé)",
|
||||
self::archived->name => "Archivé (validé et envoyé à la comptabilité)",
|
||||
self::awaiting_signature->name => "En attente de signature",
|
||||
self::awaiting_invoicing->name => "En attente de facturation",
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,21 @@ class InvoiceController extends Controller
|
|||
? Invoice::query()->orderByDesc('created_at')
|
||||
: Invoice::query();
|
||||
|
||||
$status = intval($request->status);
|
||||
$invoiceModels = $invoiceModels->when($status, function ($query) use ($status) {
|
||||
$query->where('status', $status);
|
||||
});
|
||||
$status = intval($request->status);
|
||||
|
||||
switch ($status) {
|
||||
case InvoiceStatusEnum::awaiting_signature->value:
|
||||
$invoiceModels->whereNotNull('sent_client_date')->whereNull('signed_date');
|
||||
break;
|
||||
case InvoiceStatusEnum::awaiting_invoicing->value:
|
||||
$invoiceModels->whereNotNull('sent_client_date')->whereNotNull('signed_date')->whereNull('sent_accounting_date');
|
||||
break;
|
||||
default:
|
||||
if ($status !== 0) {
|
||||
$invoiceModels->where('status', $status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
|
|
|
|||
|
|
@ -111,6 +111,10 @@ class Invoice extends Model
|
|||
->reduce(function ($previous, array $task) {
|
||||
return \floatval($task['amount']) + \floatval($previous);
|
||||
});
|
||||
|
||||
if($model->sent_accounting_date && $model->status !== InvoiceStatusEnum::archived->value) {
|
||||
$model->status = InvoiceStatusEnum::archived;
|
||||
}
|
||||
});
|
||||
static::deleting(function () {
|
||||
throw new \Error('Action impossible');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue