Fixes for credit reversals
This commit is contained in:
parent
12981de1ca
commit
d754d2f79a
|
|
@ -214,9 +214,14 @@ class CreditController extends BaseController
|
||||||
if ($credit->invoice_id) {
|
if ($credit->invoice_id) {
|
||||||
$credit = $credit->service()->markSent()->save();
|
$credit = $credit->service()->markSent()->save();
|
||||||
$credit->client->service()->updatePaidToDate(-1 * $credit->balance)->save(); // If we mutate the paid to date, we need to reverse the status of the invoice, this will allow the credit note that has been created to be used and double paid to dates prevented.
|
$credit->client->service()->updatePaidToDate(-1 * $credit->balance)->save(); // If we mutate the paid to date, we need to reverse the status of the invoice, this will allow the credit note that has been created to be used and double paid to dates prevented.
|
||||||
$invoice = $credit->invoice;
|
// $invoice = $credit->invoice;
|
||||||
$invoice->status_id = \App\Models\Invoice::STATUS_REVERSED;
|
|
||||||
$invoice->save();
|
$invoice = \App\Models\Invoice::withTrashed()->find($credit->invoice_id);
|
||||||
|
if ($invoice) {
|
||||||
|
$invoice->status_id = Invoice::STATUS_REVERSED;
|
||||||
|
$invoice->save();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars($user->id)));
|
event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars($user->id)));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue