1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 03:02:34 +01:00

Working on applying credits to payments prior to billing via gateway

This commit is contained in:
David Bomba 2020-10-07 22:06:00 +11:00
parent 50b24c55d9
commit ee77993006

View File

@ -117,6 +117,10 @@ class AutoBillInvoice extends AbstractService
$available_credits->each(function($credit) use($is_partial_amount){ $available_credits->each(function($credit) use($is_partial_amount){
//todo need to iterate until the partial or balance is completely consumed
//by the credit, any remaining balance is then dealt with by
//the gateway
//each time a credit is applied SAVE the invoice
// if($credit->balance >= $amount){ // if($credit->balance >= $amount){
// //current credit covers the total amount // //current credit covers the total amount
@ -141,6 +145,10 @@ class AutoBillInvoice extends AbstractService
$credit->id => ['amount' => $amount] $credit->id => ['amount' => $amount]
]); ]);
$this->payment->invoice()->attach([
$this->invoice->id => ['amount' => $amount]
]);
$this->applyPaymentToCredit($credit, $amount); $this->applyPaymentToCredit($credit, $amount);
} }
} }