improved logic for post payment actions

This commit is contained in:
David Bomba 2024-04-28 13:52:44 +10:00
parent b696bdbb3b
commit e1fe17cc3d
7 changed files with 12 additions and 13 deletions

View File

@ -122,7 +122,7 @@ class ApplyPayment
$this->payment $this->payment
->ledger() ->ledger()
->updatePaymentBalance($this->amount_applied * -1); ->updatePaymentBalance($this->amount_applied * -1, "ApplyPaymentCredit");
$this->payment $this->payment
->client ->client

View File

@ -73,7 +73,7 @@ class ApplyPayment extends AbstractService
$this->payment $this->payment
->ledger() ->ledger()
->updatePaymentBalance($amount_paid); ->updatePaymentBalance($amount_paid, "ApplyPaymentInvoice");
$this->invoice $this->invoice
->client ->client

View File

@ -101,7 +101,7 @@ class ApplyPaymentAmount extends AbstractService
/* Update Invoice balance */ /* Update Invoice balance */
$payment->ledger() $payment->ledger()
->updatePaymentBalance($payment->amount * -1); ->updatePaymentBalance($payment->amount * -1, "ApplyPaymentInvoice-");
$this->invoice->service()->workFlow()->save(); $this->invoice->service()->workFlow()->save();

View File

@ -213,7 +213,7 @@ class AutoBillInvoice extends AbstractService
} }
$payment->ledger() $payment->ledger()
->updatePaymentBalance($amount * -1) ->updatePaymentBalance($amount * -1, "AutoBill")
->save(); ->save();
$this->invoice $this->invoice

View File

@ -107,7 +107,7 @@ class MarkPaid extends AbstractService
->save(); ->save();
$payment->ledger() $payment->ledger()
->updatePaymentBalance($this->payable_balance * -1); ->updatePaymentBalance($this->payable_balance * -1, "Marked Paid Activity");
//06-09-2022 //06-09-2022
$this->invoice $this->invoice

View File

@ -69,7 +69,7 @@ class PaymentService
$this->payment $this->payment
->ledger() ->ledger()
->updatePaymentBalance($this->payment->amount); ->updatePaymentBalance($this->payment->amount, "PaymentService");
$client->service() $client->service()
->updateBalance($this->payment->amount) ->updateBalance($this->payment->amount)

View File

@ -78,19 +78,18 @@ class UpdateInvoicePayment
//caution what if we amount paid was less than partial - we wipe it! //caution what if we amount paid was less than partial - we wipe it!
$invoice->balance -= $paid_amount; $invoice->balance -= $paid_amount;
$invoice->paid_to_date += $paid_amount; $invoice->paid_to_date += $paid_amount;
$invoice->save(); $invoice->saveQuietly();
$invoice_service = $invoice->service() $invoice = $invoice->service()
->clearPartial() ->clearPartial()
->updateStatus() ->updateStatus()
->workFlow(); ->workFlow()
->save();
if ($has_partial) { if ($has_partial) {
$invoice_service->checkReminderStatus(); $invoice->service()->checkReminderStatus()->save();
} }
$invoice = $invoice_service->save();
if ($invoice->is_proforma) { if ($invoice->is_proforma) {
//keep proforma's hidden //keep proforma's hidden
if (property_exists($this->payment_hash->data, 'pre_payment') && $this->payment_hash->data->pre_payment == "1") { if (property_exists($this->payment_hash->data, 'pre_payment') && $this->payment_hash->data->pre_payment == "1") {
@ -145,7 +144,7 @@ class UpdateInvoicePayment
/* Updates the company ledger */ /* Updates the company ledger */
$this->payment $this->payment
->ledger() ->ledger()
->updatePaymentBalance($paid_amount * -1); ->updatePaymentBalance($paid_amount * -1, "UpdateInvoicePayment");
$pivot_invoice = $this->payment->invoices->first(function ($inv) use ($paid_invoice) { $pivot_invoice = $this->payment->invoices->first(function ($inv) use ($paid_invoice) {
return $inv->hashed_id == $paid_invoice->invoice_id; return $inv->hashed_id == $paid_invoice->invoice_id;