mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for incorrect fee calculation edge case
This commit is contained in:
parent
0c89f998eb
commit
a66fa1c678
@ -70,7 +70,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
/* Determine $amount */
|
/* Determine $amount */
|
||||||
if ($this->invoice->partial > 0) {
|
if ($this->invoice->partial > 0) {
|
||||||
$is_partial = true;
|
$is_partial = true;
|
||||||
$invoice_total = $this->invoice->amount;
|
$invoice_total = $this->invoice->balance;
|
||||||
$amount = $this->invoice->partial;
|
$amount = $this->invoice->partial;
|
||||||
} elseif ($this->invoice->balance > 0) {
|
} elseif ($this->invoice->balance > 0) {
|
||||||
$amount = $this->invoice->balance;
|
$amount = $this->invoice->balance;
|
||||||
@ -94,10 +94,14 @@ class AutoBillInvoice extends AbstractService
|
|||||||
/* $gateway fee */
|
/* $gateway fee */
|
||||||
$this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save();
|
$this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save();
|
||||||
|
|
||||||
|
//change from $this->invoice->amount to $this->invoice->balance
|
||||||
if($is_partial)
|
if($is_partial)
|
||||||
$fee = $this->invoice->amount - $invoice_total;
|
$fee = $this->invoice->balance - $invoice_total;
|
||||||
else
|
else
|
||||||
$fee = $this->invoice->amount - $amount;
|
$fee = $this->invoice->balance - $amount;
|
||||||
|
|
||||||
|
if($fee > $amount)
|
||||||
|
$fee = 0;
|
||||||
|
|
||||||
/* Build payment hash */
|
/* Build payment hash */
|
||||||
$payment_hash = PaymentHash::create([
|
$payment_hash = PaymentHash::create([
|
||||||
|
Loading…
Reference in New Issue
Block a user