mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for refund payments
This commit is contained in:
parent
cdf8f04457
commit
d30987c203
@ -28,8 +28,6 @@ class ClientService
|
||||
|
||||
public function updateBalance(float $amount)
|
||||
{
|
||||
// $this->client->balance += $amount;
|
||||
|
||||
$this->client->increment('balance', $amount);
|
||||
|
||||
return $this;
|
||||
@ -37,8 +35,6 @@ class ClientService
|
||||
|
||||
public function updatePaidToDate(float $amount)
|
||||
{
|
||||
// $this->client->paid_to_date += $amount;
|
||||
|
||||
$this->client->increment('paid_to_date', $amount);
|
||||
|
||||
return $this;
|
||||
@ -46,8 +42,6 @@ class ClientService
|
||||
|
||||
public function adjustCreditBalance(float $amount)
|
||||
{
|
||||
// $this->client->credit_balance += $amount;
|
||||
|
||||
$this->client->increment('credit_balance', $amount);
|
||||
|
||||
return $this;
|
||||
|
@ -263,6 +263,7 @@ class RefundPayment
|
||||
foreach ($this->refund_data['invoices'] as $refunded_invoice) {
|
||||
$invoice = Invoice::withTrashed()->find($refunded_invoice['invoice_id']);
|
||||
|
||||
if($invoice->trashed())
|
||||
$invoice->restore();
|
||||
|
||||
$invoice->service()->updateBalance($refunded_invoice['amount'])->save();
|
||||
@ -300,6 +301,10 @@ class RefundPayment
|
||||
}
|
||||
|
||||
$client = $this->payment->client->fresh();
|
||||
|
||||
if($client->trashed())
|
||||
$client->restore();
|
||||
|
||||
$client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save();
|
||||
|
||||
|
||||
@ -318,6 +323,10 @@ class RefundPayment
|
||||
//if we are refunding and no payments have been tagged, then we need to decrement the client->paid_to_date by the total refund amount.
|
||||
|
||||
$client = $this->payment->client->fresh();
|
||||
|
||||
if($client->trashed())
|
||||
$client->restore();
|
||||
|
||||
$client->service()->updatePaidToDate(-1 * $this->total_refund)->save();
|
||||
|
||||
$transaction = [
|
||||
|
@ -43,12 +43,19 @@ class UpdateInvoicePayment
|
||||
|
||||
collect($paid_invoices)->each(function ($paid_invoice) use ($invoices) {
|
||||
|
||||
$client = $this->payment->client->fresh();
|
||||
$client = $this->payment->client;
|
||||
|
||||
if($client->trashed())
|
||||
$client->restore();
|
||||
|
||||
$invoice = $invoices->first(function ($inv) use ($paid_invoice) {
|
||||
return $paid_invoice->invoice_id == $inv->hashed_id;
|
||||
});
|
||||
|
||||
|
||||
if($invoice->trashed())
|
||||
$invoice->restore();
|
||||
|
||||
if ($invoice->id == $this->payment_hash->fee_invoice_id) {
|
||||
$paid_amount = $paid_invoice->amount + $this->payment_hash->fee_total;
|
||||
} else {
|
||||
@ -116,7 +123,6 @@ class UpdateInvoicePayment
|
||||
|
||||
$invoices->each(function ($invoice) {
|
||||
|
||||
$invoice = $invoice->fresh();
|
||||
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user