dellermann / springcrm

An open-source CRM.
GNU General Public License v3.0
14 stars 2 forks source link

NaN when V.A.T is zero #97

Open dellermann opened 7 years ago

dellermann commented 7 years ago

When I print an invoice, sales order etc. with all items having zero V.A.T the tax rate rows in the footer of the table contains "NaN".

dellermann commented 7 years ago

A possible solution could be to add handling of NaN values in XSLT template:

<xsl:template match="entry[@key='taxRates']/entry">
  <fo:table-row>
    <fo:table-cell number-columns-spanned="2">
      <fo:block></fo:block>
    </fo:table-cell>
    <fo:table-cell padding="{$table.cell.padding.default}">
      <fo:block>
        <xsl:value-of select="format-number(number(@key), '#.##0,##')"/>
        <xsl:text> % MwSt.</xsl:text>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell><fo:block></fo:block></fo:table-cell>
    <fo:table-cell padding="{$table.cell.padding.default}"
      text-align="right">
      <fo:block>
        <xsl:choose>
          <xsl:when test="string(number()) = 'NaN'">
            <xsl:value-of select="format-number(0, '#.##0,00')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(number(), '#.##0,00')"/>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:text> €</xsl:text>
      </fo:block>
    </fo:table-cell>
  </fo:table-row>
</xsl:template>