Happy Business Starts Here

How to fix incorrect invoice MERGEFIELD calculations?

Highlighted
Support SME

How to fix incorrect invoice MERGEFIELD calculations?

Question:

 

What to do when IF conditional Merge Fields' calculation seems to be off on generated invoice documents?

 

Just for the sake of providing an example, we can calculate List Price by dividing the charge amount with the quantity (we should not do this though, as ListPrice is available as a separate field):

 

{ IF { MERGEFIELD InvoiceItem.ChargeType \* MERGEFORMAT }="Recurring" { =({MERGEFIELD InvoiceItem.AmountWithoutTax \# # }) / { MERGEFIELD InvoiceItem.ListPrice \# #} / { MERGEFIELD InvoiceItem.Quantity \# #} } } 1 }

However, in some scenarios the numbers just won't add up.



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Support SME

Re: How to fix incorrect invoice MERGEFIELD calculations?

Answer:

 

We can observe the numbers are only off if not all the numbers are whole numbers in the calculation, as the Merge Field's formatting does not account for fractions, and rounds the values up.

 

If you want to account for fractions as well, you'll need to use the following format:

 

{ IF { MERGEFIELD InvoiceItem.ChargeType \* MERGEFORMAT }="Recurring" { =({MERGEFIELD InvoiceItem.AmountWithoutTax \# #.00 }) / { MERGEFIELD InvoiceItem.ListPrice \# #.00} / { MERGEFIELD InvoiceItem.Quantity \# #.00} } } 1 }



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

View solution in original post

1 REPLY 1
Highlighted
Support SME

Re: How to fix incorrect invoice MERGEFIELD calculations?

Answer:

 

We can observe the numbers are only off if not all the numbers are whole numbers in the calculation, as the Merge Field's formatting does not account for fractions, and rounds the values up.

 

If you want to account for fractions as well, you'll need to use the following format:

 

{ IF { MERGEFIELD InvoiceItem.ChargeType \* MERGEFORMAT }="Recurring" { =({MERGEFIELD InvoiceItem.AmountWithoutTax \# #.00 }) / { MERGEFIELD InvoiceItem.ListPrice \# #.00} / { MERGEFIELD InvoiceItem.Quantity \# #.00} } } 1 }



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

View solution in original post