From b831658da413376d89101ef9902acebbe78a8f04 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 30 Nov 2022 15:36:30 +1100 Subject: [PATCH] Do not allow restoration of a invoice with a deleted payment --- app/Services/Invoice/HandleRestore.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Services/Invoice/HandleRestore.php b/app/Services/Invoice/HandleRestore.php index f0e7a4e89425..0d46f8717e40 100644 --- a/app/Services/Invoice/HandleRestore.php +++ b/app/Services/Invoice/HandleRestore.php @@ -44,11 +44,12 @@ class HandleRestore extends AbstractService return $this->invoice; } - //determine whether we need to un-delete payments OR just modify the payment amount /applied balances. - + //cannot restore an invoice with a deleted payment foreach ($this->invoice->payments as $payment) { - //restore the payment record - $this->invoice->restore(); + + if(($this->invoice->paid_to_date == 0) && $payment->is_deleted) + return $this->invoice; + } //adjust ledger balance