Hi,
I'm trying to add a right parenthesis to a number when it is negative upon returning from a Java function and so far am unable to do it. I can add the left parenthesis no problem but can't find a way to add the right parenthesis. It is much appreciated if anyone can help?
This is the line I'm using to try and include the right parenthesis. I'm thinking the code would interpret the end of the number as a space and translate it to a ')'. I've tried both " " and "" but neither works. An example of the result I currently get is this: (250.00
<xsl:value-of select='translate(translate(format-number(nws:FormatNoDollar4(nws:ReturnTotalUndesignated()),"0.00"),"-","(")," ",")")'/>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:nws="urn:ns"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:nwsexport="urn:nsexport">
.
.
.
<xsl:value-of select="nws:ResetCount()"/>
<xsl:apply-templates select="Details/CurrentAct" mode="totalundesigamt"/>
<table-row font-size='9' font-weight='500'>
<table-cell><block><xsl:value-of select="Details/CurrentAct/Date"/></block></table-cell>
<table-cell><block>Payment</block></table-cell>
<table-cell><block>Credit Applied</block></table-cell>
<table-cell><block text-align='far'>
<xsl:value-of select='translate(translate(format-number(ns:FormatNoDollar4(ns:ReturnTotalUndesignated()),"0.00"),"-","(")," ",")")'/>
</block></table-cell>
</table-row>
<!--Undesignated Template for Balance Processing for payments and adjustments -->
<xsl:template match="Details/CurrentAct" mode="totalundesigamt">
<xsl:if test="substring(CAType,2,11) = 'ndesignated'">
<table-row font-size='9' font-weight='500'>
<xsl:value-of select='ns:AddUndesignated(number(translate(translate(Amount,"(","-"),")","")))'/>
</table-row>
</xsl:if>
</xsl:template>
<!--********************Java Script*************************************** -->
<msxsl:script language="javascript" implements-prefix="nws">
<![CDATA[
var TotalUndesignated=0;
/*For the Undesignated billing data, this function takes the input xml field Amount and totals it.
If the amount = 0.00 the payment amount is used in the returned amount */
function AddUndesignated(inVal)
{
TotalUndesignated=TotalUndesignated+inVal;
var num = new Number(TotalUndesignated);
if(String(num) == '0.00' || num == 0.00)
TotalUndesignated = num+inVal;
}
function ReturnTotalUndesignated()
{
return TotalUndesignated;
}
function ResetCount()
{
TotalUndesignated=0;
}
function FormatNoDollar4(inNumber) {
var NumDigitsAfterDecimal = 2;
var UseParensForNegativeNumbers = true;
var GroupDigits = true;
var num = new Number(inNumber);
if(String(num) == "NaN" || num == 0)
return '0.00';
else
return num;
}
]]>
</msxsl:script>
</xsl:stylesheet>