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

Refactor for payment processing

This commit is contained in:
David Bomba 2024-02-17 19:08:20 +11:00
parent 97accc8142
commit 6974841921

View File

@ -279,7 +279,6 @@ class AutoBillInvoice extends AbstractService
$this->is_partial_amount = true;
}
$payment_repo = new PaymentRepository(new CreditRepository());
foreach ($unapplied_payments as $key => $payment) {
@ -296,7 +295,7 @@ class AutoBillInvoice extends AbstractService
$payment_repo->save($payload, $payment);
}
} else {
//more than needed
//more than needed
if ($payment_balance > $this->invoice->balance) {
$payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $this->invoice->balance]]];
@ -312,6 +311,10 @@ class AutoBillInvoice extends AbstractService
}
$this->invoice = $this->invoice->fresh();
if((int)$this->invoice->balance == 0) {
return $this;
}
}
return $this;