mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 22:34:37 -04: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;
|
$invoice_totals -= $credit_totals;
|
||||||
|
|
||||||
//$payment->amount = $invoice_totals; //creates problems when setting amount like this.
|
//$payment->amount = $invoice_totals; //creates problems when setting amount like this.
|
||||||
|
if($credit_totals == $payment->amount){
|
||||||
if ($invoice_totals == $payment->amount) {
|
$payment->applied += $credit_totals;
|
||||||
|
} elseif ($invoice_totals == $payment->amount) {
|
||||||
$payment->applied += $payment->amount;
|
$payment->applied += $payment->amount;
|
||||||
} elseif ($invoice_totals < $payment->amount) {
|
} elseif ($invoice_totals < $payment->amount) {
|
||||||
$payment->applied += $invoice_totals;
|
$payment->applied += $invoice_totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
|
||||||
return $payment->fresh();
|
return $payment->fresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class ApplyPayment extends AbstractService
|
|||||||
->ledger()
|
->ledger()
|
||||||
->updatePaymentBalance($this->payment_amount*-1);
|
->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}");
|
info("reducing client balance by payment amount {$this->payment_amount}");
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class ApplyPayment extends AbstractService
|
|||||||
|
|
||||||
$this->invoice->fresh('client');
|
$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()) {
|
if ($this->invoice->hasPartial()) {
|
||||||
//is partial and amount is exactly the partial amount
|
//is partial and amount is exactly the partial amount
|
||||||
|
Loading…
x
Reference in New Issue
Block a user