Checks for partial/deposit greater than amount/balance

This commit is contained in:
David Bomba 2021-04-15 08:09:36 +10:00
parent 4cd83ba27a
commit 218aa6de73
2 changed files with 5 additions and 1 deletions

View File

@ -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);