From 73e2f070a99f657e5bdda51f20098f4e8523e4e2 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 15 Apr 2018 13:21:16 +0300 Subject: [PATCH] =?UTF-8?q?Support=20customizing=20=E2=80=98gateway=20fee?= =?UTF-8?q?=E2=80=99=20label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Account.php | 2 ++ app/Ninja/Repositories/InvoiceRepository.php | 17 +++++++++++++++-- resources/lang/en/texts.php | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 4222fde64a..d2b41875e7 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -251,6 +251,8 @@ class Account extends Eloquent 'description', 'discount', 'due_date', + 'gateway_fee_item', + 'gateway_fee_description', 'hours', 'id_number', 'invoice', diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index e44fe739fa..9d405d1c1c 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -1310,10 +1310,23 @@ class InvoiceRepository extends BaseRepository $data = $invoice->toArray(); $fee = $invoice->calcGatewayFee($gatewayTypeId); + $date = $account->getDateTime()->format($account->getCustomDateFormat()); + $feeItemLabel = $account->getLabel('gateway_fee_item') ?: ($fee >= 0 ? trans('texts.surcharge') : trans('texts.discount')); + + if ($feeDescriptionLabel = $account->getLabel('gateway_fee_description')) { + if (strpos($feeDescriptionLabel, '$date') !== false) { + $feeDescriptionLabel = str_replace('$date', $date, $feeDescriptionLabel); + } else { + $feeDescriptionLabel .= ' • ' . $date; + } + } else { + $feeDescriptionLabel = $fee >= 0 ? trans('texts.online_payment_surcharge') : trans('texts.online_payment_discount'); + $feeDescriptionLabel .= ' • ' . $date; + } $item = []; - $item['product_key'] = $fee >= 0 ? trans('texts.surcharge') : trans('texts.discount'); - $item['notes'] = $fee >= 0 ? trans('texts.online_payment_surcharge') : trans('texts.online_payment_discount'); + $item['product_key'] = $feeItemLabel; + $item['notes'] = $feeDescriptionLabel; $item['qty'] = 1; $item['cost'] = $fee; $item['tax_rate1'] = $settings->fee_tax_rate1; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 1f8922fc6e..2e4b45d5ee 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2836,6 +2836,8 @@ $LANG = array( 'proposal_editor' => 'proposal editor', 'background' => 'Background', 'guide' => 'Guide', + 'gateway_fee_item' => 'Gateway Fee Item', + 'gateway_fee_description' => 'Gateway Fee Surcharge', );