mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 03:24:34 -04:00
Performance improvements for payment reponses
This commit is contained in:
parent
0b2a8eac1a
commit
77199fc697
@ -94,7 +94,7 @@ class PaymentController extends Controller
|
|||||||
$gateway = CompanyGateway::findOrFail($request->input('company_gateway_id'));
|
$gateway = CompanyGateway::findOrFail($request->input('company_gateway_id'));
|
||||||
$payment_hash = PaymentHash::where('hash', $request->payment_hash)->first();
|
$payment_hash = PaymentHash::where('hash', $request->payment_hash)->first();
|
||||||
$invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id);
|
$invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id);
|
||||||
$client = $invoice->client->exists() ? $invoice->client : auth()->user()->client;
|
$client = $invoice ? $invoice->client : auth()->user()->client;
|
||||||
|
|
||||||
return $gateway
|
return $gateway
|
||||||
// ->driver(auth()->user()->client)
|
// ->driver(auth()->user()->client)
|
||||||
|
@ -55,6 +55,16 @@ class UpdateInvoicePayment
|
|||||||
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)
|
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)
|
||||||
$paid_amount = $invoice->balance;
|
$paid_amount = $invoice->balance;
|
||||||
|
|
||||||
|
/*Improve performance here - 26-01-2022 - also change the order of events for invoice first*/
|
||||||
|
$invoice->service() //caution what if we amount paid was less than partial - we wipe it!
|
||||||
|
->clearPartial()
|
||||||
|
->updateBalance($paid_amount * -1)
|
||||||
|
->updatePaidToDate($paid_amount)
|
||||||
|
->updateStatus()
|
||||||
|
->touchPdf()
|
||||||
|
->workFlow()
|
||||||
|
->save();
|
||||||
|
|
||||||
/* Updates the company ledger */
|
/* Updates the company ledger */
|
||||||
$this->payment
|
$this->payment
|
||||||
->ledger()
|
->ledger()
|
||||||
@ -77,19 +87,22 @@ class UpdateInvoicePayment
|
|||||||
|
|
||||||
$this->payment->applied += $paid_amount;
|
$this->payment->applied += $paid_amount;
|
||||||
|
|
||||||
$invoice->service() //caution what if we amount paid was less than partial - we wipe it!
|
// $invoice->service() //caution what if we amount paid was less than partial - we wipe it!
|
||||||
->clearPartial()
|
// ->clearPartial()
|
||||||
->updateBalance($paid_amount * -1)
|
// ->updateBalance($paid_amount * -1)
|
||||||
->updatePaidToDate($paid_amount)
|
// ->updatePaidToDate($paid_amount)
|
||||||
->updateStatus()
|
// ->updateStatus()
|
||||||
->save();
|
// ->save();
|
||||||
|
|
||||||
|
// $invoice->refresh();
|
||||||
|
|
||||||
|
// $invoice->service()
|
||||||
|
// ->touchPdf(true)
|
||||||
|
// ->workFlow()
|
||||||
|
// ->save();
|
||||||
|
|
||||||
|
|
||||||
$invoice->refresh();
|
|
||||||
|
|
||||||
$invoice->service()
|
|
||||||
->touchPdf(true)
|
|
||||||
->workFlow()
|
|
||||||
->save();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user