From ac763b3a0a728eb11cd458fd58e3ece5f443d850 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 29 Aug 2021 21:17:27 +1000 Subject: [PATCH] Small fix for edge case where invoice may appear to be paid --- app/Services/Invoice/InvoiceService.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index f6df31475ca2..7023afd562ce 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -192,6 +192,8 @@ class InvoiceService public function handleCancellation() { + $this->removeUnpaidGatewayFees(); + $this->invoice = (new HandleCancellation($this->invoice))->run(); return $this; @@ -199,6 +201,8 @@ class InvoiceService public function markDeleted() { + $this->removeUnpaidGatewayFees(); + $this->invoice = (new MarkInvoiceDeleted($this->invoice))->run(); return $this; @@ -213,6 +217,8 @@ class InvoiceService public function reverseCancellation() { + $this->removeUnpaidGatewayFees(); + $this->invoice = (new HandleCancellation($this->invoice))->reverse(); return $this; @@ -278,11 +284,14 @@ class InvoiceService public function updateStatus() { - if ((int)$this->invoice->balance == 0) { + if($this->invoice->status_id == Invoice::STATUS_DRAFT) + return $this; + + // if ((int)$this->invoice->balance == 0) { - $this->setStatus(Invoice::STATUS_PAID)->workFlow(); - // InvoiceWorkflowSettings::dispatchNow($this->invoice); - } + // $this->setStatus(Invoice::STATUS_PAID)->workFlow(); + + // } if ($this->invoice->balance > 0 && $this->invoice->balance < $this->invoice->amount) { $this->setStatus(Invoice::STATUS_PARTIAL);