mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01: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'));
|
||||
$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)
|
||||
|
@ -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();
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user