mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:34:30 -04:00
Fixes for refunds
This commit is contained in:
parent
1ce5b7ad8e
commit
7dbdc292e5
@ -185,9 +185,9 @@ class RefundPayment
|
|||||||
if ($available_credit > $this->total_refund) {
|
if ($available_credit > $this->total_refund) {
|
||||||
$paymentable_credit->pivot->refunded += $this->total_refund;
|
$paymentable_credit->pivot->refunded += $this->total_refund;
|
||||||
$paymentable_credit->pivot->save();
|
$paymentable_credit->pivot->save();
|
||||||
|
|
||||||
$paymentable_credit->balance += $this->total_refund;
|
$paymentable_credit->balance += $this->total_refund;
|
||||||
$paymentable_credit->save();
|
$paymentable_credit->service()->setStatus(Credit::STATUS_SENT)->save();
|
||||||
|
//$paymentable_credit->save();
|
||||||
|
|
||||||
$this->total_refund = 0;
|
$this->total_refund = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -195,7 +195,8 @@ class RefundPayment
|
|||||||
$paymentable_credit->pivot->save();
|
$paymentable_credit->pivot->save();
|
||||||
|
|
||||||
$paymentable_credit->balance += $available_credit;
|
$paymentable_credit->balance += $available_credit;
|
||||||
$paymentable_credit->save();
|
$paymentable_credit->service()->setStatus(Credit::STATUS_SENT)->save();
|
||||||
|
// $paymentable_credit->save();
|
||||||
|
|
||||||
$this->total_refund -= $available_credit;
|
$this->total_refund -= $available_credit;
|
||||||
}
|
}
|
||||||
@ -226,6 +227,7 @@ class RefundPayment
|
|||||||
$invoice = Invoice::find($refunded_invoice['invoice_id']);
|
$invoice = Invoice::find($refunded_invoice['invoice_id']);
|
||||||
|
|
||||||
$invoice->service()->updateBalance($refunded_invoice['amount'])->save();
|
$invoice->service()->updateBalance($refunded_invoice['amount'])->save();
|
||||||
|
$invoice->ledger()->updateInvoiceBalance($refunded_invoice['amount'], "Refund of payment # {$this->payment->number}")->save();
|
||||||
|
|
||||||
if ($invoice->amount == $invoice->balance)
|
if ($invoice->amount == $invoice->balance)
|
||||||
$invoice->service()->setStatus(Invoice::STATUS_SENT);
|
$invoice->service()->setStatus(Invoice::STATUS_SENT);
|
||||||
@ -247,6 +249,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->paid_to_date -= $this->total_refund;
|
$client->paid_to_date -= $this->total_refund;
|
||||||
$client->save();
|
$client->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user