From 0211e4fa869b5c0e1f2ba0dd8f31a760fe2e54bb Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 28 Jan 2019 10:44:25 +0200 Subject: [PATCH] email template currency decimal places --- application/Espo/Services/EmailTemplate.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/application/Espo/Services/EmailTemplate.php b/application/Espo/Services/EmailTemplate.php index d5227bc2d1..03e582db9b 100644 --- a/application/Espo/Services/EmailTemplate.php +++ b/application/Espo/Services/EmailTemplate.php @@ -219,8 +219,8 @@ class EmailTemplate extends Record $value = implode(', ', $valueList); $value = $this->getLanguage()->translateOption($value, $attribute, $entity->getEntityType()); } else { - if (!isset($entity->fields[$attribute]['type'])) continue; - $attributeType = $entity->fields[$attribute]['type']; + $attributeType = $entity->getAttributeType($attribute); + if (!$attributeType) continue; if ($attributeType == 'date') { $value = $this->getDateTime()->convertSystemDate($value); @@ -233,7 +233,11 @@ class EmailTemplate extends Record $value = nl2br($value); } else if ($attributeType == 'float') { if (is_float($value)) { - $value = $this->getNumber()->format($value, 2); + $decimalPlaces = 2; + if ($fieldType === 'currency') { + $decimalPlaces = $this->getConfig()->get('currencyDecimalPlaces'); + } + $value = $this->getNumber()->format($value, $decimalPlaces); } } else if ($attributeType == 'int') { if (is_int($value)) { @@ -242,7 +246,6 @@ class EmailTemplate extends Record } } - if (is_string($value) || $value === null || is_scalar($value) || is_callable([$value, '__toString'])) { $variableName = $attribute; if (!is_null($prefixLink)) {