From 0791e6fbc56cf20ba20ebfd8cbf700a41615da11 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 17 Mar 2017 15:10:33 +0200 Subject: [PATCH] Working on gateway fees --- app/Ninja/Repositories/InvoiceRepository.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index cb5ca20d3d..46c0fa60ef 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -1019,15 +1019,15 @@ class InvoiceRepository extends BaseRepository return false; } + if (! $invoice->relationLoaded('invoice_items')) { + $invoice->load('invoice_items'); + } + // once an invoice with fee surcharge has been paid don't clear it if (($location == FEE_LOCATION_CHARGE1 || $location == FEE_LOCATION_CHARGE2) && $invoice->amount != $invoice->balance) { return false; } - if (! $invoice->relationLoaded('invoice_items')) { - $invoice->load('invoice_items'); - } - if ($location == FEE_LOCATION_ITEM) { $data = $invoice->toArray(); foreach ($data['invoice_items'] as $key => $item) { @@ -1066,7 +1066,7 @@ class InvoiceRepository extends BaseRepository $data = $invoice->toArray(); if ($location == FEE_LOCATION_ITEM) { - $fee = $invoice->calcGatewayFee($gatewayTypeId, false); + $fee = $invoice->calcGatewayFee($gatewayTypeId); $item = []; $item['product_key'] = trans('texts.surcharge');