From 967a9b73dc3796720a67aa510d4625853750ff46 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Tue, 31 Jan 2023 15:00:19 -0800 Subject: [PATCH 1/2] Make the add funds limit exception more specific The other message wasn't really great for the end user and it gave no indication as to what the problem is, so now we specify why it's an invalid amount --- src/modules/Invoice/Service.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/modules/Invoice/Service.php b/src/modules/Invoice/Service.php index 042280731..66f61b1af 100644 --- a/src/modules/Invoice/Service.php +++ b/src/modules/Invoice/Service.php @@ -1128,15 +1128,15 @@ class Service implements InjectionAwareInterface $systemService = $this->di['mod_service']('system'); - $min_amount = $systemService->getParamValue('funds_min_amount', null); - $max_amount = $systemService->getParamValue('funds_max_amount', null); + $min_amount = $systemService->getParamValue('minimum_funds_limit', null); + $max_amount = $systemService->getParamValue('maximum_funds_limit', null); if ($min_amount && $amount < $min_amount) { - throw new \Box_Exception('Amount is not valid', null, 981); + throw new \Box_Exception('Amount must be at least :min_amount', [':min_amount' => $min_amount], 981); } if ($max_amount && $amount > $max_amount) { - throw new \Box_Exception('Amount is not valid', null, 982); + throw new \Box_Exception('Amount cannot exceed :max_amount', [':max_amount' => $max_amount], 982); } $proforma = $this->di['db']->dispense('Invoice'); @@ -1243,16 +1243,16 @@ class Service implements InjectionAwareInterface $CustomCSSPath = __DIR__ . DIRECTORY_SEPARATOR . 'pdf_template' . DIRECTORY_SEPARATOR . 'custom-pdf.css'; $DefaultCSSPath = __DIR__ . DIRECTORY_SEPARATOR . 'pdf_template' . DIRECTORY_SEPARATOR . 'default-pdf.css'; - - if(file_exists($CustomCSSPath)){ - $CSS = file_get_contents($CustomCSSPath); + + if (file_exists($CustomCSSPath)) { + $CSS = file_get_contents($CustomCSSPath); } else { - $CSS = file_get_contents($DefaultCSSPath); + $CSS = file_get_contents($DefaultCSSPath); } if (empty($CSS)) { - $CSS = file_get_contents($DefaultCSSPath); - } + $CSS = file_get_contents($DefaultCSSPath); + } $pdf = new Dompdf(); $options = $pdf->getOptions(); @@ -1312,7 +1312,7 @@ class Service implements InjectionAwareInterface $data = trim($data); if (!empty($data)) { $html .= "

$label: $data

"; - $sellerLines ++; + $sellerLines++; } } $html .= ''; @@ -1329,12 +1329,12 @@ class Service implements InjectionAwareInterface $data = trim($data); if (!empty($data)) { $html .= "

$label: $data

"; - $buyerLines ++; + $buyerLines++; } } $top = ($buyerLines >= $sellerLines) ? (325 + (25 * $buyerLines)) : (325 + (25 * $sellerLines)); $html .= ''; - $html .= '
+ $html .= '
@@ -1503,7 +1503,8 @@ class Service implements InjectionAwareInterface $params = [ ':id' => sprintf('%05s', $proforma['nr']), ':serie' => $proforma['serie'], - ':title' => $first_title, ]; + ':title' => $first_title, + ]; if ($first_title) { $title = __trans('Payment for invoice :serie:id [:title]', $params); } else { From eaec06de7cdf752457b7f8b3884faf687a4c6728 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Tue, 31 Jan 2023 15:12:41 -0800 Subject: [PATCH 2/2] You saw nothing --- src/modules/Invoice/Service.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/Invoice/Service.php b/src/modules/Invoice/Service.php index 66f61b1af..ef91e05b0 100644 --- a/src/modules/Invoice/Service.php +++ b/src/modules/Invoice/Service.php @@ -1128,8 +1128,8 @@ class Service implements InjectionAwareInterface $systemService = $this->di['mod_service']('system'); - $min_amount = $systemService->getParamValue('minimum_funds_limit', null); - $max_amount = $systemService->getParamValue('maximum_funds_limit', null); + $min_amount = $systemService->getParamValue('funds_min_amount', null); + $max_amount = $systemService->getParamValue('funds_max_amount', null); if ($min_amount && $amount < $min_amount) { throw new \Box_Exception('Amount must be at least :min_amount', [':min_amount' => $min_amount], 981);
#