mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fix for applied amount when using credits to pay invoices
This commit is contained in:
parent
a669e9342f
commit
a7e05cb3bd
@ -151,14 +151,16 @@ class PaymentRepository extends BaseRepository
|
||||
$invoice_totals -= $credit_totals;
|
||||
|
||||
//$payment->amount = $invoice_totals; //creates problems when setting amount like this.
|
||||
|
||||
if ($invoice_totals == $payment->amount) {
|
||||
if($credit_totals == $payment->amount){
|
||||
$payment->applied += $credit_totals;
|
||||
} elseif ($invoice_totals == $payment->amount) {
|
||||
$payment->applied += $payment->amount;
|
||||
} elseif ($invoice_totals < $payment->amount) {
|
||||
$payment->applied += $invoice_totals;
|
||||
}
|
||||
|
||||
$payment->save();
|
||||
|
||||
return $payment->fresh();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class ApplyPayment extends AbstractService
|
||||
->ledger()
|
||||
->updatePaymentBalance($this->payment_amount*-1);
|
||||
|
||||
info("apply paymenet method - current client balance = {$this->payment->client->balance}");
|
||||
info("apply payment method - current client balance = {$this->payment->client->balance}");
|
||||
|
||||
info("reducing client balance by payment amount {$this->payment_amount}");
|
||||
|
||||
@ -56,7 +56,7 @@ class ApplyPayment extends AbstractService
|
||||
|
||||
$this->invoice->fresh('client');
|
||||
|
||||
info("1 end of apply payment method the client balnace = {$this->invoice->client->balance}");
|
||||
info("1 end of apply payment method the client balance = {$this->invoice->client->balance}");
|
||||
|
||||
if ($this->invoice->hasPartial()) {
|
||||
//is partial and amount is exactly the partial amount
|
||||
|
Loading…
Reference in New Issue
Block a user