mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Checks for partial/deposit greater than amount/balance
This commit is contained in:
parent
4cd83ba27a
commit
218aa6de73
@ -51,7 +51,7 @@ class StoreInvoiceRequest extends Request
|
||||
|
||||
$rules['invitations.*.client_contact_id'] = 'distinct';
|
||||
|
||||
$rules['number'] = ['nullable',Rule::unique('invoices')->where('company_id', auth()->user()->company()->id)];
|
||||
$rules['number'] = ['nullable', Rule::unique('invoices')->where('company_id', auth()->user()->company()->id)];
|
||||
|
||||
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||
|
||||
|
@ -291,6 +291,10 @@ class BaseRepository
|
||||
/* Apply entity number */
|
||||
$model = $model->service()->applyNumber()->save();
|
||||
|
||||
/* Handle attempts where the deposit is greater than the amount/balance of the invoice */
|
||||
if((int)$model->balance != 0 && $model->partial > $model->amount)
|
||||
$model->partial = min($model->amount, $model->balance);
|
||||
|
||||
/* Update product details if necessary */
|
||||
if ($model->company->update_products)
|
||||
UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company);
|
||||
|
Loading…
x
Reference in New Issue
Block a user