1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Performance improvements for payment reponses

This commit is contained in:
David Bomba 2022-01-26 23:01:54 +11:00
parent 0b2a8eac1a
commit 77199fc697
2 changed files with 25 additions and 12 deletions

View File

@ -94,7 +94,7 @@ class PaymentController extends Controller
$gateway = CompanyGateway::findOrFail($request->input('company_gateway_id'));
$payment_hash = PaymentHash::where('hash', $request->payment_hash)->first();
$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
// ->driver(auth()->user()->client)

View File

@ -55,6 +55,16 @@ class UpdateInvoicePayment
if($paid_amount > $invoice->partial && $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 */
$this->payment
->ledger()
@ -77,19 +87,22 @@ class UpdateInvoicePayment
$this->payment->applied += $paid_amount;
$invoice->service() //caution what if we amount paid was less than partial - we wipe it!
->clearPartial()
->updateBalance($paid_amount * -1)
->updatePaidToDate($paid_amount)
->updateStatus()
->save();
// $invoice->service() //caution what if we amount paid was less than partial - we wipe it!
// ->clearPartial()
// ->updateBalance($paid_amount * -1)
// ->updatePaidToDate($paid_amount)
// ->updateStatus()
// ->save();
// $invoice->refresh();
// $invoice->service()
// ->touchPdf(true)
// ->workFlow()
// ->save();
$invoice->refresh();
$invoice->service()
->touchPdf(true)
->workFlow()
->save();
});