diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index f76ec3ae1dc2..036e88ad394c 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -103,19 +103,21 @@ class PaymentController extends Controller foreach($payable_invoices as $key => $payable_invoice) { - $payable_invoice[$key]['amount'] = Number::parseFloat($payable_invoice[$key]['amount']); + + $payable_invoice[$key]['amount'] = Number::parseFloat($payable_invoice['amount']); + $payable_invoice['amount'] = $payable_invoice[$key]['amount']; $invoice = $invoices->first(function ($inv) use($payable_invoice) { - return $payable_invoice[$key]['invoice_id'] == $inv->hashed_id; + return $payable_invoice['invoice_id'] == $inv->hashed_id; }); if($invoice) - $invoice->service()->addGatewayFee($gateway, $payable_invoice[$key]['amount'])->save(); + $invoice->service()->addGatewayFee($gateway, $payable_invoice['amount'])->save(); /*Update the payable amount to include the fee*/ - $gateway_fee = $gateway->calcGatewayFee($payable_invoice[$key]['amount']); + $gateway_fee = $gateway->calcGatewayFee($payable_invoice['amount']); - $payable_invoice[$key]['amount_with_fee'] += $gateway_fee; + $payable_invoice[$key]['amount_with_fee'] = $payable_invoice['amount'] + $gateway_fee; $payable_invoice[$key]['fee'] = $gateway_fee; $payable_invoice[$key]['due_date'] = $this->formatDate($invoice->due_date, $invoice->client->date_format()); $payable_invoice[$key]['invoice_number'] = $invoice->number; diff --git a/tests/Unit/NumberTest.php b/tests/Unit/NumberTest.php index c2c67fd78bb9..3997864da191 100644 --- a/tests/Unit/NumberTest.php +++ b/tests/Unit/NumberTest.php @@ -42,14 +42,8 @@ class NumberTest extends TestCase $formatted_amount = Number::formatValue($amount, $currency); - info($formatted_amount); - $float_amount = Number::parseFloat($formatted_amount); - info($float_amount); - info($currency->id); - info($currency->code); - if($currency->precision == 0){ $this->assertEquals(123456789, $float_amount); }