From 2f18ab1eebb9b5a36c279728998008d2a4f56c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:12:43 +0100 Subject: [PATCH 1/9] htmlengine: refactor formatCustomFieldValue --- app/Utils/HtmlEngine.php | 53 ++++++++++++---------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 955e41936fc4..aff4b42f7602 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -41,6 +41,8 @@ class HtmlEngine public $entity_string; + private $helpers; + public function __construct($invitation) { $this->invitation = $invitation; @@ -58,6 +60,8 @@ class HtmlEngine $this->settings = $this->client->getMergedSettings(); $this->entity_calc = $this->entity->calc(); + + $this->helpers = new Helpers(); } @@ -179,10 +183,10 @@ class HtmlEngine $data['$taxes'] = ['value' => Number::formatMoney($this->entity_calc->getItemTotalTaxes(), $this->client) ?: ' ', 'label' => ctrans('texts.taxes')]; $data['$invoice.taxes'] = &$data['$taxes']; - $data['$invoice.custom1'] = ['value' => $this->formatCustomFieldValue('invoice1', $this->entity->custom_value1) ?: ' ', 'label' => $this->makeCustomField('invoice1')]; - $data['$invoice.custom2'] = ['value' => $this->formatCustomFieldValue('invoice2', $this->entity->custom_value2) ?: ' ', 'label' => $this->makeCustomField('invoice2')]; - $data['$invoice.custom3'] = ['value' => $this->formatCustomFieldValue('invoice3', $this->entity->custom_value3) ?: ' ', 'label' => $this->makeCustomField('invoice3')]; - $data['$invoice.custom4'] = ['value' => $this->formatCustomFieldValue('invoice4', $this->entity->custom_value4) ?: ' ', 'label' => $this->makeCustomField('invoice4')]; + $data['$invoice.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice1')]; + $data['$invoice.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice2')]; + $data['$invoice.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice3')]; + $data['$invoice.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice4')]; $data['$invoice.public_notes'] = ['value' => nl2br($this->entity->public_notes) ?: ' ', 'label' => ctrans('texts.public_notes')]; $data['$entity.public_notes'] = &$data['$invoice.public_notes']; @@ -214,10 +218,10 @@ class HtmlEngine // $data['$details'] = ; $data['$invoice_no'] = &$data['$number']; $data['$invoice.invoice_no'] = &$data['$number']; - $data['$client1'] = ['value' => $this->formatCustomFieldValue('client1', $this->client->custom_value1) ?: ' ', 'label' => $this->makeCustomField('client1')]; - $data['$client2'] = ['value' => $this->formatCustomFieldValue('client2', $this->client->custom_value2) ?: ' ', 'label' => $this->makeCustomField('client2')]; - $data['$client3'] = ['value' => $this->formatCustomFieldValue('client3', $this->client->custom_value3) ?: ' ', 'label' => $this->makeCustomField('client3')]; - $data['$client4'] = ['value' => $this->formatCustomFieldValue('client4', $this->client->custom_value4) ?: ' ', 'label' => $this->makeCustomField('client4')]; + $data['$client1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client1', $this->client->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('client1')]; + $data['$client2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client2', $this->client->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('client2')]; + $data['$client3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client3', $this->client->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('client3')]; + $data['$client4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client4', $this->client->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('client4')]; $data['$address1'] = ['value' => $this->client->address1 ?: ' ', 'label' => ctrans('texts.address1')]; $data['$address2'] = ['value' => $this->client->address2 ?: ' ', 'label' => ctrans('texts.address2')]; $data['$id_number'] = ['value' => $this->client->id_number ?: ' ', 'label' => ctrans('texts.id_number')]; @@ -284,10 +288,10 @@ class HtmlEngine $data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')]; $data['$company_logo'] = &$data['$company.logo']; - $data['$company1'] = ['value' => $this->formatCustomFieldValue('company1', $this->settings->custom_value1) ?: ' ', 'label' => $this->makeCustomField('company1')]; - $data['$company2'] = ['value' => $this->formatCustomFieldValue('company2', $this->settings->custom_value2) ?: ' ', 'label' => $this->makeCustomField('company2')]; - $data['$company3'] = ['value' => $this->formatCustomFieldValue('company3', $this->settings->custom_value3) ?: ' ', 'label' => $this->makeCustomField('company3')]; - $data['$company4'] = ['value' => $this->formatCustomFieldValue('company4', $this->settings->custom_value4) ?: ' ', 'label' => $this->makeCustomField('company4')]; + $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('company1')]; + $data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('company2')]; + $data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('company3')]; + $data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('company4')]; $data['$custom_surcharge1'] = ['value' => $this->entity->custom_surcharge1 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge1')]; $data['$custom_surcharge2'] = ['value' => $this->entity->custom_surcharge2 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge2')]; @@ -532,31 +536,6 @@ class HtmlEngine return ''; } - private function formatCustomFieldValue($field, $value) :string - { - $custom_fields = $this->company->custom_fields; - $custom_field = ''; - - if ($custom_fields && property_exists($custom_fields, $field)) { - $custom_field = $custom_fields->{$field}; - $custom_field_parts = explode('|', $custom_field); - - if (count($custom_field_parts) >= 2) { - $custom_field = $custom_field_parts[1]; - } - } - - switch ($custom_field) { - case 'date': - return $this->formatDate($value, $this->client->date_format()); - break; - - default: - return is_null($value) ? '' : $value; - break; - } - } - private function makeTotalTaxes() :string { $data = ''; From 710c08cdef9b36479d7b64b753d6de14f16b5046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:12:56 +0100 Subject: [PATCH 2/9] update formatCustomField value to accept nullable client --- app/Utils/Helpers.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index 889d75e29f3f..b9947fedc9b2 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -41,15 +41,15 @@ class Helpers /** * A centralised way to format the custom fields content. - * - * @param mixed $custom_fields - * @param mixed $field - * @param mixed $value - * @param null|\App\Models\Client $client - * - * @return null|string + * + * @param mixed $custom_fields + * @param mixed $field + * @param mixed $value + * @param \App\Models\Client|null $client + * + * @return null|string */ - public function formatCustomFieldValue($custom_fields, $field, $value, ?Client $client): ?string + public function formatCustomFieldValue($custom_fields, $field, $value, Client $client = null): ?string { $custom_field = ''; @@ -64,7 +64,7 @@ class Helpers switch ($custom_field) { case 'date': - return $this->formatDate($value, $client->date_format()); + return is_null($client) ? $value : $this->formatDate($value, $client->date_format()); break; case 'switch': From 85a27941f28083fb987fb94532cba9f2dbe0b5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:13:26 +0100 Subject: [PATCH 3/9] paymentemailengine: refactor formatCustomFieldValue --- app/Mail/Engine/PaymentEmailEngine.php | 53 ++++++++------------------ 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index f76c395adb50..15512511ef23 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -12,6 +12,7 @@ namespace App\Mail\Engine; use App\DataMapper\EmailTemplateDefaults; +use App\Utils\Helpers; use App\Utils\Number; use App\Utils\Traits\MakesDates; @@ -30,6 +31,8 @@ class PaymentEmailEngine extends BaseEmailEngine public $company; public $contact; + + private $helpers; public function __construct($payment, $contact, $template_data = null) { @@ -39,6 +42,7 @@ class PaymentEmailEngine extends BaseEmailEngine $this->contact = $contact ?: $this->client->primary_contact()->first(); $this->settings = $this->client->getMergedSettings(); $this->template_data = $template_data; + $this->helpers = new Helpers(); } public function build() @@ -106,16 +110,16 @@ class PaymentEmailEngine extends BaseEmailEngine $data['$transaction_reference'] = ['value' => $this->payment->transaction_reference, 'label' => ctrans('texts.transaction_reference')]; $data['$public_notes'] = ['value' => $this->payment->public_notes, 'label' => ctrans('texts.notes')]; - $data['$payment1'] = ['value' => $this->formatCustomFieldValue('payment1', $this->payment->custom_value1) ?: ' ', 'label' => $this->makeCustomField('payment1')]; - $data['$payment2'] = ['value' => $this->formatCustomFieldValue('payment2', $this->payment->custom_value2) ?: ' ', 'label' => $this->makeCustomField('payment2')]; - $data['$payment3'] = ['value' => $this->formatCustomFieldValue('payment3', $this->payment->custom_value3) ?: ' ', 'label' => $this->makeCustomField('payment3')]; - $data['$payment4'] = ['value' => $this->formatCustomFieldValue('payment4', $this->payment->custom_value4) ?: ' ', 'label' => $this->makeCustomField('payment4')]; + $data['$payment1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment1', $this->payment->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment1')]; + $data['$payment2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment2', $this->payment->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment2')]; + $data['$payment3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment3', $this->payment->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment3')]; + $data['$payment4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment4', $this->payment->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment4')]; // $data['$type'] = ['value' => $this->payment->type->name ?: '', 'label' => ctrans('texts.payment_type')]; - $data['$client1'] = ['value' => $this->formatCustomFieldValue('client1', $this->client->custom_value1) ?: ' ', 'label' => $this->makeCustomField('client1')]; - $data['$client2'] = ['value' => $this->formatCustomFieldValue('client2', $this->client->custom_value2) ?: ' ', 'label' => $this->makeCustomField('client2')]; - $data['$client3'] = ['value' => $this->formatCustomFieldValue('client3', $this->client->custom_value3) ?: ' ', 'label' => $this->makeCustomField('client3')]; - $data['$client4'] = ['value' => $this->formatCustomFieldValue('client4', $this->client->custom_value4) ?: ' ', 'label' => $this->makeCustomField('client4')]; + $data['$client1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client1', $this->client->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('client1')]; + $data['$client2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client2', $this->client->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('client2')]; + $data['$client3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client3', $this->client->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('client3')]; + $data['$client4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client4', $this->client->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('client4')]; $data['$address1'] = ['value' => $this->client->address1 ?: ' ', 'label' => ctrans('texts.address1')]; $data['$address2'] = ['value' => $this->client->address2 ?: ' ', 'label' => ctrans('texts.address2')]; $data['$id_number'] = ['value' => $this->client->id_number ?: ' ', 'label' => ctrans('texts.id_number')]; @@ -178,10 +182,10 @@ class PaymentEmailEngine extends BaseEmailEngine $data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')]; $data['$company_logo'] = &$data['$company.logo']; - $data['$company1'] = ['value' => $this->formatCustomFieldValue('company1', $this->settings->custom_value1) ?: ' ', 'label' => $this->makeCustomField('company1')]; - $data['$company2'] = ['value' => $this->formatCustomFieldValue('company2', $this->settings->custom_value2) ?: ' ', 'label' => $this->makeCustomField('company2')]; - $data['$company3'] = ['value' => $this->formatCustomFieldValue('company3', $this->settings->custom_value3) ?: ' ', 'label' => $this->makeCustomField('company3')]; - $data['$company4'] = ['value' => $this->formatCustomFieldValue('company4', $this->settings->custom_value4) ?: ' ', 'label' => $this->makeCustomField('company4')]; + $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('company1')]; + $data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('company2')]; + $data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('company3')]; + $data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('company4')]; $data['$view_link'] = ['value' => ''.ctrans('texts.view_payment').'', 'label' => ctrans('texts.view_payment')]; $data['$view_url'] = ['value' => $this->payment->getLink(), 'label' => ctrans('texts.view_payment')]; @@ -217,31 +221,6 @@ class PaymentEmailEngine extends BaseEmailEngine return ''; } - private function formatCustomFieldValue($field, $value) :string - { - $custom_fields = $this->company->custom_fields; - $custom_field = ''; - - if ($custom_fields && property_exists($custom_fields, $field)) { - $custom_field = $custom_fields->{$field}; - $custom_field_parts = explode('|', $custom_field); - - if (count($custom_field_parts) >= 2) { - $custom_field = $custom_field_parts[1]; - } - } - - switch ($custom_field) { - case 'date': - return $this->formatDate($value, $this->client->date_format()); - break; - - default: - return is_null($value) ? '' : $value; - break; - } - } - public function makeValues() :array { $data = []; From 83ec60cf704376a32b9b676b7c125d8db0dac0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:25:28 +0100 Subject: [PATCH 4/9] Remove unused makeCustomFieldKeyValuePair() method --- app/Utils/Traits/MakesInvoiceValues.php | 30 +------------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index 08356c076822..6d78e614c40a 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -74,6 +74,7 @@ trait MakesInvoiceValues if ($custom_fields && property_exists($custom_fields, $field)) { $custom_field = $custom_fields->{$field}; + $custom_field_parts = explode('|', $custom_field); return $custom_field_parts[0]; @@ -96,35 +97,6 @@ trait MakesInvoiceValues return ''; } - /** - * This method produces the key /value pairs for - * custom fields. - * - * We need to explode the field name and search for the | - * we split on the pipe, the first value is the field name - * and the second is the field _type_ - * - * We transform the $value depending the $field type - * - * @param string $field The full field name - * @param string $value The custom value - * @return array The key value pair - */ - private function makeCustomFieldKeyValuePair($field, $value) - { - if ($this->findCustomType($field) == 'date') { - $value = $this->formatDate($value, $this->client->date_format()); - } elseif ($this->findCustomType($field) == 'switch') { - $value = ctrans('texts.'.$value); - } - - if (! $value) { - $value = ''; - } - - return ['value' => $value, 'field' => $this->makeCustomField($field)]; - } - public function makeLabels($contact = null) :array { $data = []; From ebfbfb6e10834af379817151bf46cc7c6cf9e7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:27:23 +0100 Subject: [PATCH 5/9] htmlengine: refactor makeCustomField to helpers --- app/Utils/HtmlEngine.php | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index aff4b42f7602..c14ff69ab6b0 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -183,10 +183,10 @@ class HtmlEngine $data['$taxes'] = ['value' => Number::formatMoney($this->entity_calc->getItemTotalTaxes(), $this->client) ?: ' ', 'label' => ctrans('texts.taxes')]; $data['$invoice.taxes'] = &$data['$taxes']; - $data['$invoice.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice1')]; - $data['$invoice.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice2')]; - $data['$invoice.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice3')]; - $data['$invoice.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('invoice4')]; + $data['$invoice.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice1')]; + $data['$invoice.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice2')]; + $data['$invoice.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice3')]; + $data['$invoice.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice4')]; $data['$invoice.public_notes'] = ['value' => nl2br($this->entity->public_notes) ?: ' ', 'label' => ctrans('texts.public_notes')]; $data['$entity.public_notes'] = &$data['$invoice.public_notes']; @@ -218,10 +218,10 @@ class HtmlEngine // $data['$details'] = ; $data['$invoice_no'] = &$data['$number']; $data['$invoice.invoice_no'] = &$data['$number']; - $data['$client1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client1', $this->client->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('client1')]; - $data['$client2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client2', $this->client->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('client2')]; - $data['$client3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client3', $this->client->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('client3')]; - $data['$client4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client4', $this->client->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('client4')]; + $data['$client1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client1', $this->client->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client1')]; + $data['$client2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client2', $this->client->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client2')]; + $data['$client3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client3', $this->client->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client3')]; + $data['$client4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client4', $this->client->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client4')]; $data['$address1'] = ['value' => $this->client->address1 ?: ' ', 'label' => ctrans('texts.address1')]; $data['$address2'] = ['value' => $this->client->address2 ?: ' ', 'label' => ctrans('texts.address2')]; $data['$id_number'] = ['value' => $this->client->id_number ?: ' ', 'label' => ctrans('texts.id_number')]; @@ -263,10 +263,10 @@ class HtmlEngine $data['$contact.last_name'] = ['value' => isset($this->contact) ? $this->contact->last_name : '', 'label' => ctrans('texts.last_name')]; - $data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->makeCustomField('contact1')]; - $data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->makeCustomField('contact2')]; - $data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->makeCustomField('contact3')]; - $data['$contact.custom4'] = ['value' => isset($this->contact) ? $this->contact->custom_value4 : ' ', 'label' => $this->makeCustomField('contact4')]; + $data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact1')]; + $data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact2')]; + $data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact3')]; + $data['$contact.custom4'] = ['value' => isset($this->contact) ? $this->contact->custom_value4 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact4')]; $data['$company.city_state_postal'] = ['value' => $this->company->present()->cityStateZip($this->settings->city, $this->settings->state, $this->settings->postal_code, false) ?: ' ', 'label' => ctrans('texts.city_state_postal')]; $data['$company.postal_city_state'] = ['value' => $this->company->present()->cityStateZip($this->settings->city, $this->settings->state, $this->settings->postal_code, true) ?: ' ', 'label' => ctrans('texts.postal_city_state')]; @@ -288,15 +288,15 @@ class HtmlEngine $data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')]; $data['$company_logo'] = &$data['$company.logo']; - $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('company1')]; - $data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('company2')]; - $data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('company3')]; - $data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('company4')]; + $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')]; + $data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company2')]; + $data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company3')]; + $data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company4')]; - $data['$custom_surcharge1'] = ['value' => $this->entity->custom_surcharge1 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge1')]; - $data['$custom_surcharge2'] = ['value' => $this->entity->custom_surcharge2 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge2')]; - $data['$custom_surcharge3'] = ['value' => $this->entity->custom_surcharge3 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge3')]; - $data['$custom_surcharge4'] = ['value' => $this->entity->custom_surcharge4 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge4')]; + $data['$custom_surcharge1'] = ['value' => $this->entity->custom_surcharge1 ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'custom_surcharge1')]; + $data['$custom_surcharge2'] = ['value' => $this->entity->custom_surcharge2 ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'custom_surcharge2')]; + $data['$custom_surcharge3'] = ['value' => $this->entity->custom_surcharge3 ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'custom_surcharge3')]; + $data['$custom_surcharge4'] = ['value' => $this->entity->custom_surcharge4 ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'custom_surcharge4')]; $data['$product.item'] = ['value' => '', 'label' => ctrans('texts.item')]; $data['$product.date'] = ['value' => '', 'label' => ctrans('texts.date')]; @@ -312,10 +312,10 @@ class HtmlEngine $data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')]; $data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')]; $data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')]; - $data['$product.product1'] = ['value' => '', 'label' => $this->makeCustomField('product1')]; - $data['$product.product2'] = ['value' => '', 'label' => $this->makeCustomField('product2')]; - $data['$product.product3'] = ['value' => '', 'label' => $this->makeCustomField('product3')]; - $data['$product.product4'] = ['value' => '', 'label' => $this->makeCustomField('product4')]; + $data['$product.product1'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product1')]; + $data['$product.product2'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product2')]; + $data['$product.product3'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product3')]; + $data['$product.product4'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product4')]; $data['$task.date'] = ['value' => '', 'label' => ctrans('texts.date')]; $data['$task.discount'] = ['value' => '', 'label' => ctrans('texts.discount')]; From 491d080ab4df682b46b7f2d35a4dd304c502816c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:27:37 +0100 Subject: [PATCH 6/9] add new makeCustomField (centralised refactor) --- app/Utils/Helpers.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index b9947fedc9b2..f2fa72b30fe7 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -40,16 +40,16 @@ class Helpers } /** - * A centralised way to format the custom fields content. + * A centralised method to format the custom fields content. * - * @param mixed $custom_fields + * @param mixed|null $custom_fields * @param mixed $field * @param mixed $value * @param \App\Models\Client|null $client * * @return null|string */ - public function formatCustomFieldValue($custom_fields, $field, $value, Client $client = null): ?string + public function formatCustomFieldValue($custom_fields = null, $field, $value, Client $client = null): ?string { $custom_field = ''; @@ -76,4 +76,24 @@ class Helpers break; } } + + /** + * A centralised method to make custom field. + * @param mixed|null $custom_fields + * @param mixed $field + * + * @return string + */ + public function makeCustomField($custom_fields = null, $field): string + { + if ($custom_fields && property_exists($custom_fields, $field)) { + $custom_field = $custom_fields->{$field}; + + $custom_field_parts = explode('|', $custom_field); + + return $custom_field_parts[0]; + } + + return ''; + } } From 3198ef335201bcbbc5124ed4f215685525cca1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:29:13 +0100 Subject: [PATCH 7/9] paymentemailengine: refactor to makeCustomField --- app/Mail/Engine/PaymentEmailEngine.php | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index 15512511ef23..9e84837c54b2 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -110,16 +110,16 @@ class PaymentEmailEngine extends BaseEmailEngine $data['$transaction_reference'] = ['value' => $this->payment->transaction_reference, 'label' => ctrans('texts.transaction_reference')]; $data['$public_notes'] = ['value' => $this->payment->public_notes, 'label' => ctrans('texts.notes')]; - $data['$payment1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment1', $this->payment->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment1')]; - $data['$payment2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment2', $this->payment->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment2')]; - $data['$payment3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment3', $this->payment->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment3')]; - $data['$payment4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment4', $this->payment->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('payment4')]; + $data['$payment1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment1', $this->payment->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment1')]; + $data['$payment2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment2', $this->payment->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment2')]; + $data['$payment3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment3', $this->payment->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment3')]; + $data['$payment4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment4', $this->payment->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment4')]; // $data['$type'] = ['value' => $this->payment->type->name ?: '', 'label' => ctrans('texts.payment_type')]; - $data['$client1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client1', $this->client->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('client1')]; - $data['$client2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client2', $this->client->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('client2')]; - $data['$client3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client3', $this->client->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('client3')]; - $data['$client4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client4', $this->client->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('client4')]; + $data['$client1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client1', $this->client->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client1')]; + $data['$client2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client2', $this->client->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client2')]; + $data['$client3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client3', $this->client->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client3')]; + $data['$client4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client4', $this->client->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client4')]; $data['$address1'] = ['value' => $this->client->address1 ?: ' ', 'label' => ctrans('texts.address1')]; $data['$address2'] = ['value' => $this->client->address2 ?: ' ', 'label' => ctrans('texts.address2')]; $data['$id_number'] = ['value' => $this->client->id_number ?: ' ', 'label' => ctrans('texts.id_number')]; @@ -157,10 +157,10 @@ class PaymentEmailEngine extends BaseEmailEngine $data['$contact.name'] = ['value' => isset($this->contact) ? $this->contact->present()->name() : 'no contact name on record', 'label' => ctrans('texts.contact_name')]; $data['$contact.first_name'] = ['value' => isset($this->contact) ? $this->contact->first_name : '', 'label' => ctrans('texts.first_name')]; $data['$contact.last_name'] = ['value' => isset($this->contact) ? $this->contact->last_name : '', 'label' => ctrans('texts.last_name')]; - $data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->makeCustomField('contact1')]; - $data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->makeCustomField('contact1')]; - $data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->makeCustomField('contact1')]; - $data['$contact.custom4'] = ['value' => isset($this->contact) ? $this->contact->custom_value4 : ' ', 'label' => $this->makeCustomField('contact1')]; + $data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact1')]; + $data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact1')]; + $data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact1')]; + $data['$contact.custom4'] = ['value' => isset($this->contact) ? $this->contact->custom_value4 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact1')]; $data['$company.city_state_postal'] = ['value' => $this->company->present()->cityStateZip($this->settings->city, $this->settings->state, $this->settings->postal_code, false) ?: ' ', 'label' => ctrans('texts.city_state_postal')]; $data['$company.postal_city_state'] = ['value' => $this->company->present()->cityStateZip($this->settings->city, $this->settings->state, $this->settings->postal_code, true) ?: ' ', 'label' => ctrans('texts.postal_city_state')]; @@ -182,10 +182,10 @@ class PaymentEmailEngine extends BaseEmailEngine $data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')]; $data['$company_logo'] = &$data['$company.logo']; - $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->makeCustomField('company1')]; - $data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->makeCustomField('company2')]; - $data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->makeCustomField('company3')]; - $data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->makeCustomField('company4')]; + $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')]; + $data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company2')]; + $data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company3')]; + $data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company4')]; $data['$view_link'] = ['value' => ''.ctrans('texts.view_payment').'', 'label' => ctrans('texts.view_payment')]; $data['$view_url'] = ['value' => $this->payment->getLink(), 'label' => ctrans('texts.view_payment')]; From 0bbd9104902b6c2c816a7a3b54da27d685d46fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:29:42 +0100 Subject: [PATCH 8/9] apply php-cs-fixer --- app/Helpers/Generic.php | 8 ++++---- app/Utils/Helpers.php | 20 ++++++++++---------- config/logging.php | 2 +- tests/Feature/Import/ImportCsvTest.php | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/Helpers/Generic.php b/app/Helpers/Generic.php index ef29f83a1195..ecec44c2da15 100644 --- a/app/Helpers/Generic.php +++ b/app/Helpers/Generic.php @@ -13,11 +13,11 @@ /** * Simple helper function that will log into "invoiceninja.log" file * only when extended logging is enabled. - * - * @param mixed $output - * @param array $context * - * @return void + * @param mixed $output + * @param array $context + * + * @return void */ function nlog($output, $context = []): void { diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index f2fa72b30fe7..ae82fca7903d 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -41,13 +41,13 @@ class Helpers /** * A centralised method to format the custom fields content. - * + * * @param mixed|null $custom_fields - * @param mixed $field - * @param mixed $value - * @param \App\Models\Client|null $client - * - * @return null|string + * @param mixed $field + * @param mixed $value + * @param \App\Models\Client|null $client + * + * @return null|string */ public function formatCustomFieldValue($custom_fields = null, $field, $value, Client $client = null): ?string { @@ -79,10 +79,10 @@ class Helpers /** * A centralised method to make custom field. - * @param mixed|null $custom_fields - * @param mixed $field - * - * @return string + * @param mixed|null $custom_fields + * @param mixed $field + * + * @return string */ public function makeCustomField($custom_fields = null, $field): string { diff --git a/config/logging.php b/config/logging.php index ffc7bebb68c4..fc8e2966252f 100644 --- a/config/logging.php +++ b/config/logging.php @@ -102,7 +102,7 @@ return [ 'invoiceninja' => [ 'driver' => 'single', - 'path' => storage_path('logs/invoiceninja.log'), + 'path' => storage_path('logs/invoiceninja.log'), ], ], diff --git a/tests/Feature/Import/ImportCsvTest.php b/tests/Feature/Import/ImportCsvTest.php index c2804bc8607c..d024bb54f169 100644 --- a/tests/Feature/Import/ImportCsvTest.php +++ b/tests/Feature/Import/ImportCsvTest.php @@ -56,7 +56,7 @@ class ImportCsvTest extends TestCase public function testInvoiceCsvImport() { - $this->markTestSkipped(); + $this->markTestSkipped(); $csv = file_get_contents(base_path().'/tests/Feature/Import/invoice.csv'); $hash = Str::random(32); @@ -132,7 +132,7 @@ class ImportCsvTest extends TestCase public function testProductCsvImport() { - $this->markTestSkipped(); + $this->markTestSkipped(); $csv = file_get_contents(base_path().'/tests/Feature/Import/products.csv'); From f3f76e9644fd59d73aa8f9b1ad7459ac4536411f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 25 Dec 2020 12:30:40 +0100 Subject: [PATCH 9/9] remove duplicate methods --- app/Mail/Engine/PaymentEmailEngine.php | 15 --------------- app/Utils/HtmlEngine.php | 15 --------------- app/Utils/Traits/MakesInvoiceValues.php | 15 --------------- 3 files changed, 45 deletions(-) diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index 9e84837c54b2..37c5d0e24eb9 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -206,21 +206,6 @@ class PaymentEmailEngine extends BaseEmailEngine return $invoice_list; } - private function makeCustomField($field) :string - { - $custom_fields = $this->company->custom_fields; - - if ($custom_fields && property_exists($custom_fields, $field)) { - $custom_field = $custom_fields->{$field}; - - $custom_field_parts = explode('|', $custom_field); - - return $custom_field_parts[0]; - } - - return ''; - } - public function makeValues() :array { $data = []; diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index c14ff69ab6b0..feae2eacc0ba 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -521,21 +521,6 @@ class HtmlEngine return $data; } - private function makeCustomField($field) :string - { - $custom_fields = $this->company->custom_fields; - - if ($custom_fields && property_exists($custom_fields, $field)) { - $custom_field = $custom_fields->{$field}; - - $custom_field_parts = explode('|', $custom_field); - - return $custom_field_parts[0]; - } - - return ''; - } - private function makeTotalTaxes() :string { $data = ''; diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index 6d78e614c40a..c4d085b63888 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -68,21 +68,6 @@ trait MakesInvoiceValues 'company4', ]; - public function makeCustomField($field) :string - { - $custom_fields = $this->company->custom_fields; - - if ($custom_fields && property_exists($custom_fields, $field)) { - $custom_field = $custom_fields->{$field}; - - $custom_field_parts = explode('|', $custom_field); - - return $custom_field_parts[0]; - } - - return ''; - } - private function findCustomType($field) { $custom_fields = $this->company->custom_fields;