From 0c05370686d6fd60950914d9904fe7161c7c3aa1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 5 Aug 2022 08:08:19 +1000 Subject: [PATCH] Move payment numbering into service --- app/Models/Vendor.php | 5 +++++ app/Services/Invoice/MarkPaid.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index d7af8b867c98..f267e9201cfa 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -172,6 +172,11 @@ class Vendor extends BaseModel return $this->company->company_key.'/'.$this->vendor_hash.'/'.$contact_key.'/purchase_orders/'; } + public function locale() + { + return $this->company->locale(); + } + public function country() { return $this->belongsTo(Country::class); diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index f7957b5439de..e0a49b57cd0b 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -55,7 +55,6 @@ class MarkPaid extends AbstractService $payment->amount = $this->invoice->balance; $payment->applied = $this->invoice->balance; - $payment->number = $this->getNextPaymentNumber($this->invoice->client, $payment); $payment->status_id = Payment::STATUS_COMPLETED; $payment->client_id = $this->invoice->client_id; $payment->transaction_reference = ctrans('texts.manual_entry'); @@ -74,6 +73,8 @@ class MarkPaid extends AbstractService $payment->saveQuietly(); + $payment->service()->applyNumber()->save(); + $this->setExchangeRate($payment); /* Create a payment relationship to the invoice entity */