From 2e6c42f7ba51c3e37178ead933ed6f2202e51260 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Fri, 1 Feb 2019 17:12:54 +0300 Subject: [PATCH] close #690 Fixed: Add new Item to Paid Invoice should mark Invoice Status as Partial --- app/Jobs/Expense/UpdateBill.php | 8 ++++++++ app/Jobs/Income/UpdateInvoice.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/app/Jobs/Expense/UpdateBill.php b/app/Jobs/Expense/UpdateBill.php index 7abf8d362..02355eb19 100644 --- a/app/Jobs/Expense/UpdateBill.php +++ b/app/Jobs/Expense/UpdateBill.php @@ -107,6 +107,14 @@ class UpdateBill $this->request['amount'] = money($amount, $this->request['currency_code'])->getAmount(); + $bill_paid = $this->bill->paid; + + if ($this->request['amount'] > $bill_paid) { + $this->request['bill_status_code'] = 'partial'; + + unset($this->bill->reconciled); + } + $this->bill->update($this->request->input()); // Delete previous bill totals diff --git a/app/Jobs/Income/UpdateInvoice.php b/app/Jobs/Income/UpdateInvoice.php index f2995ff4a..6d2fa0efc 100644 --- a/app/Jobs/Income/UpdateInvoice.php +++ b/app/Jobs/Income/UpdateInvoice.php @@ -108,6 +108,14 @@ class UpdateInvoice $this->request['amount'] = money($amount, $this->request['currency_code'])->getAmount(); + $invoice_paid = $this->invoice->paid; + + if ($this->request['amount'] > $invoice_paid) { + $this->request['invoice_status_code'] = 'partial'; + + unset($this->invoice->reconciled); + } + $this->invoice->update($this->request->input()); // Delete previous invoice totals