From 59688c0ce8b16d80b356b9dcf13a1a241efaf876 Mon Sep 17 00:00:00 2001 From: Jens Hardings Date: Tue, 12 Sep 2023 18:22:57 -0300 Subject: [PATCH] Currency (#217) * Add currency-hide-symbol attribute as a comlement to currency-unit-field, displaying the value without the currency symbol * Update AUTHORS file --- AUTHORS | 4 ++-- template/screen-macro/DefaultScreenMacros.csv.ftl | 12 ++++++++++-- template/screen-macro/DefaultScreenMacros.html.ftl | 12 ++++++++++-- template/screen-macro/DefaultScreenMacros.qvt.ftl | 13 +++++++++++-- template/screen-macro/DefaultScreenMacros.text.ftl | 12 ++++++++++-- template/screen-macro/DefaultScreenMacros.vuet.ftl | 13 +++++++++++-- template/screen-macro/DefaultScreenMacros.xml.ftl | 12 ++++++++++-- .../screen-macro/DefaultScreenMacros.xsl-fo.ftl | 12 ++++++++++-- 8 files changed, 74 insertions(+), 16 deletions(-) diff --git a/AUTHORS b/AUTHORS index 88f33f1b9..9258dd711 100644 --- a/AUTHORS +++ b/AUTHORS @@ -46,7 +46,7 @@ Written in 2015-2016 by Sam Hamilton - samhamilton Written in 2015 by Leonardo Carvalho - CarvalhoLeonardo Written in 2015 by Swapnil M Mane - swapnilmmane Written in 2015 by Anton Akhiar - akhiar -Writter in 2015-2016 by Jens Hardings - jenshp +Writter in 2015-2023 by Jens Hardings - jenshp Written in 2016 by Mark Haney - mphaney Written in 2018 by Nirendra Singh Panwar - nirendra10695 Written in 2018 by Zhang Wei - zhangwei1979 @@ -86,7 +86,7 @@ Written in 2015 by Jimmy Shen - shendepu Written in 2015 by Sam Hamilton - samhamilton Written in 2015 by Leonardo Carvalho - CarvalhoLeonardo Written in 2015 by Anton Akhiar - akhiar -Writter in 2015-2016 by Jens Hardings - jenshp +Writter in 2015-2023 by Jens Hardings - jenshp Written in 2016 by Mark Haney - mphaney Written in 2018 by Nirendra Singh Panwar - nirendra10695 Written in 2018 by Zhang Wei - zhangwei1979 diff --git a/template/screen-macro/DefaultScreenMacros.csv.ftl b/template/screen-macro/DefaultScreenMacros.csv.ftl index 035905a6a..f784c4c30 100644 --- a/template/screen-macro/DefaultScreenMacros.csv.ftl +++ b/template/screen-macro/DefaultScreenMacros.csv.ftl @@ -192,10 +192,18 @@ on the same screen to increase reusability of those screens --> <#assign fieldValue = ec.getResource().expand(.node["@text"], "")> <#if .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#elseif .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> <#assign fieldValue = sri.getFieldValueString(.node)> diff --git a/template/screen-macro/DefaultScreenMacros.html.ftl b/template/screen-macro/DefaultScreenMacros.html.ftl index 9e68d56da..37c86281e 100644 --- a/template/screen-macro/DefaultScreenMacros.html.ftl +++ b/template/screen-macro/DefaultScreenMacros.html.ftl @@ -1941,10 +1941,18 @@ a => A, d => D, y => Y <#assign fieldValue = ec.getResource().expand(.node["@text"], "")> <#if .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#elseif .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> <#assign fieldValue = sri.getFieldValueString(.node)> diff --git a/template/screen-macro/DefaultScreenMacros.qvt.ftl b/template/screen-macro/DefaultScreenMacros.qvt.ftl index 834ce2be0..71abbc09d 100644 --- a/template/screen-macro/DefaultScreenMacros.qvt.ftl +++ b/template/screen-macro/DefaultScreenMacros.qvt.ftl @@ -1755,9 +1755,18 @@ a => A, d => D, y => Y <#if textMap?has_content><#assign fieldValue = ec.getResource().expand(.node["@text"], "", textMap)> <#else><#assign fieldValue = ec.getResource().expand(.node["@text"], "")> <#if .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + + <#elseif .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> <#assign fieldValue = sri.getFieldValueString(.node)> diff --git a/template/screen-macro/DefaultScreenMacros.text.ftl b/template/screen-macro/DefaultScreenMacros.text.ftl index 783890b9d..629b1ee3f 100644 --- a/template/screen-macro/DefaultScreenMacros.text.ftl +++ b/template/screen-macro/DefaultScreenMacros.text.ftl @@ -281,10 +281,18 @@ along with this software (see the LICENSE.md file). If not, see <#assign fieldValue = ec.getResource().expand(.node["@text"], "")> <#if .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#elseif .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> <#assign fieldValue = sri.getFieldValueString(.node)> diff --git a/template/screen-macro/DefaultScreenMacros.vuet.ftl b/template/screen-macro/DefaultScreenMacros.vuet.ftl index e25470efc..67a4a5c32 100644 --- a/template/screen-macro/DefaultScreenMacros.vuet.ftl +++ b/template/screen-macro/DefaultScreenMacros.vuet.ftl @@ -1667,9 +1667,18 @@ a => A, d => D, y => Y <#if textMap?has_content><#assign fieldValue = ec.getResource().expand(.node["@text"], "", textMap)> <#else><#assign fieldValue = ec.getResource().expand(.node["@text"], "")> <#if .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(fieldValue, ec.getResource().expression(.node["@currency-unit-field"], ""))> + + <#elseif .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.getL10n().formatCurrencyNoSymbol(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.getL10n().formatCurrency(sri.getFieldValue(dispFieldNode, ""), ec.getResource().expression(.node["@currency-unit-field"], ""))> + <#else> <#assign fieldValue = sri.getFieldValueString(.node)> diff --git a/template/screen-macro/DefaultScreenMacros.xml.ftl b/template/screen-macro/DefaultScreenMacros.xml.ftl index 3be23827c..255ce3c81 100644 --- a/template/screen-macro/DefaultScreenMacros.xml.ftl +++ b/template/screen-macro/DefaultScreenMacros.xml.ftl @@ -132,10 +132,18 @@ along with this software (see the LICENSE.md file). If not, see <#if .node["@text"]?has_content> <#assign fieldValue = ec.resource.expand(.node["@text"], "")> <#if .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.l10n.formatCurrency(fieldValue, ec.resource.expression(.node["@currency-unit-field"], ""), 2)> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.l10n.formatCurrencyNoSymbol(fieldValue, ec.resource.expression(.node["@currency-unit-field"], ""), 2)> + <#else> + <#assign fieldValue = ec.l10n.formatCurrency(fieldValue, ec.resource.expression(.node["@currency-unit-field"], ""), 2)> + <#elseif .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.l10n.formatCurrency(sri.getFieldValue(.node?parent?parent, ""), ec.resource.expression(.node["@currency-unit-field"], ""), 2)> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.l10n.formatCurrencyNoSymbol(sri.getFieldValue(.node?parent?parent, ""), ec.resource.expression(.node["@currency-unit-field"], ""), 2)> + <#else> + <#assign fieldValue = ec.l10n.formatCurrency(sri.getFieldValue(.node?parent?parent, ""), ec.resource.expression(.node["@currency-unit-field"], ""), 2)> + <#else> <#assign fieldValue = sri.getFieldValueString(.node)> diff --git a/template/screen-macro/DefaultScreenMacros.xsl-fo.ftl b/template/screen-macro/DefaultScreenMacros.xsl-fo.ftl index c09d3bb31..05f2840a0 100644 --- a/template/screen-macro/DefaultScreenMacros.xsl-fo.ftl +++ b/template/screen-macro/DefaultScreenMacros.xsl-fo.ftl @@ -385,10 +385,18 @@ along with this software (see the LICENSE.md file). If not, see <#if .node["@text"]?has_content> <#assign fieldValue = ec.resource.expand(.node["@text"], "")> <#if .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.l10n.formatCurrency(fieldValue, ec.resource.expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.l10n.formatCurrencyNoSymbol(fieldValue, ec.resource.expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.l10n.formatCurrency(fieldValue, ec.resource.expression(.node["@currency-unit-field"], ""))> + <#elseif .node["@currency-unit-field"]?has_content> - <#assign fieldValue = ec.l10n.formatCurrency(sri.getFieldValue(.node?parent?parent, ""), ec.resource.expression(.node["@currency-unit-field"], ""))> + <#if .node["@currency-hide-symbol"]! == "true"> + <#assign fieldValue = ec.l10n.formatCurrencyNoSymbol(sri.getFieldValue(.node?parent?parent, ""), ec.resource.expression(.node["@currency-unit-field"], ""))> + <#else> + <#assign fieldValue = ec.l10n.formatCurrency(sri.getFieldValue(.node?parent?parent, ""), ec.resource.expression(.node["@currency-unit-field"], ""))> + <#else> <#assign fieldValue = sri.getFieldValueString(.node)>