1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Refactor for payment processing

This commit is contained in:
David Bomba 2024-02-17 19:04:41 +11:00
parent 66fd68cf93
commit 97accc8142

View File

@ -288,24 +288,24 @@ class AutoBillInvoice extends AbstractService
if ($this->is_partial_amount) {
//more than needed
if ($payment_balance > $this->invoice->partial) {
$payload = ['invoices' => [['invoice_id' => $this->invoice->id,'amount' => $this->invoice->partial]]];
$payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $this->invoice->partial]]];
$payment_repo->save($payload, $payment);
break;
} else {
$payload = ['invoices' => [['invoice_id' => $this->invoice->id,'amount' => $payment_balance]]];
$payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $payment_balance]]];
$payment_repo->save($payload, $payment);
}
} else {
//more than needed
if ($payment_balance > $this->invoice->balance) {
$payload = ['invoices' => [['invoice_id' => $this->invoice->id,'amount' => $this->invoice->balance]]];
$payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $this->invoice->balance]]];
$payment_repo->save($payload, $payment);
break;
} else {
$payload = ['invoices' => [['invoice_id' => $this->invoice->id,'amount' => $payment_balance]]];
$payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $payment_balance]]];
$payment_repo->save($payload, $payment);
}