From c4f09c23bab810f4a08d2b7300d906665a25d3b2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 12 Oct 2021 21:48:07 +1100 Subject: [PATCH] Set default payment type if none defined --- app/Services/Invoice/MarkPaid.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index f3c23ab5b07f..654facfbc4f8 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -58,11 +58,17 @@ class MarkPaid extends AbstractService $payment->transaction_reference = ctrans('texts.manual_entry'); $payment->currency_id = $this->invoice->client->getSetting('currency_id'); $payment->is_manual = true; - /* Create a payment relationship to the invoice entity */ + + $payment_type_id = $this->invoice->client->getSetting('payment_type_id'); + + if((int)$payment_type_id > 0) + $payment->type_id = (int)$payment_type_id; + $payment->save(); $this->setExchangeRate($payment); + /* Create a payment relationship to the invoice entity */ $payment->invoices()->attach($this->invoice->id, [ 'amount' => $payment->amount, ]);