Fixes for paid to date when refund is applied

This commit is contained in:
David Bomba 2020-10-23 12:57:54 +11:00
parent 73b3c11d80
commit 3139539f46
2 changed files with 4 additions and 2 deletions

View File

@ -56,7 +56,7 @@ class AutoBillInvoice extends AbstractService
//if the credits cover the payments, we stop here, build the payment with credits and exit early //if the credits cover the payments, we stop here, build the payment with credits and exit early
if($this->invoice->company->use_credits_payment == 'always' || $this->invoice->company->use_credits_payment == 'option') if($this->invoice->company->use_credits_payment != 'off')
$this->applyCreditPayment(); $this->applyCreditPayment();
info("partial = {$this->invoice->partial}"); info("partial = {$this->invoice->partial}");

View File

@ -241,6 +241,7 @@ class RefundPayment
$adjustment_amount += $refunded_invoice['amount']; $adjustment_amount += $refunded_invoice['amount'];
$client->balance += $refunded_invoice['amount']; $client->balance += $refunded_invoice['amount'];
//$client->paid_to_date -= $refunded_invoice['amount'];//todo refund balancing
$client->save(); $client->save();
//todo adjust ledger balance here? or after and reference the credit and its total //todo adjust ledger balance here? or after and reference the credit and its total
@ -251,7 +252,8 @@ class RefundPayment
// $this->credit_note->ledger()->updateCreditBalance($adjustment_amount, $ledger_string); // $this->credit_note->ledger()->updateCreditBalance($adjustment_amount, $ledger_string);
$client = $this->payment->client->fresh(); $client = $this->payment->client->fresh();
$client->service()->updatePaidToDate(-1 * $this->total_refund)->save(); //$client->service()->updatePaidToDate(-1 * $this->total_refund)->save();
$client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save();
} }
return $this; return $this;