|Posted: 2017-09-05 11:25|
If you are creating your own custom Credit Note PDF Template, you will need to make sure that you are pulling through the correct line item fields, else your PDF will show negative amounts.
Below is some example XML from a Credit Note. Highlighted are some of the Line Item amount fields that you can pull through onto the PDF. Notice that the amounts are all negative.
Highlighted in green are those fields that display as positive amounts in the UI - these fields will also display as positive on your PDF without any conversion. Those highlighted in red display as negative in the UI, and will also display as negative on your PDF if you do not first convert them to a positive number in your XSL.
Below you can see that the fields will pull through onto the PDF the same as they show in the UI, irrespective of whether they are negative or positive values in the XML. Use this to ensure you are using the correct field label in the <xsl:value-of select="...."/>
The rest of the fields that you can see in the XML are those that are used to calculate the correct Net Amount depending on whether you have the 'Discount applied before totalling' (found in Database Settings) set to true or false. In general you would not display these fields on a PDF, and would instead use 'Unit Price' and 'Net Value' from above.
You may want to use 'Unit Price After Discount' or 'Net Amount (before discount)' for comparison though- these will pull through as positive values (make sure you pick the correct one dependent on how you have the setting). if any of the other fields are required, they will need to be converted to ensure that they pull through onto your PDF as positive. You can do this by multiplying the amount by -1, but you will therefore have to split the field into the currency symbol and the amount, as follows:
<xsl:value-of select="/hash/document_currency_currency_symbol"/> <xsl:value-of select="format-number(field/@amount * -1, '#,###.00')"/>
Discount applied before totalling = true
Discount applied before totalling = false