Rounding tester
Check what Business Central's Round() returns before you write the code, and see how the amount, VAT and invoice rounding settings change an invoice total. Uses exact decimal arithmetic, like AL's Decimal.
Every direction at common precisions
Sales lines
Round() rounds to a multiple of Precision. '=' goes to the nearest multiple and an exact half goes away from zero. '>' and '<' work on the size of the number: '>' moves away from zero and '<' towards zero. So for a negative number, '>' gives a smaller value and '<' a larger one, as Microsoft's documentation notes. Precision can be any positive number, such as 0.05 or 0.25, not only a power of ten.
Follows the standard sales posting logic. Line Amount is Round(Quantity × Unit Price) less Round(that × Line Discount %). VAT is calculated on the running total of lines with the same VAT % and rounded with the VAT Rounding Type, so the document's VAT equals Round(sum × VAT %) rather than the sum of rounded line VAT. With Prices Including VAT, the amount excluding VAT is rounded to the nearest, and VAT is the rest. The invoice rounding line is −Round(Total − Round(Total, Inv. Rounding Precision, Type), Amount Rounding Precision), posted to the invoice rounding account. Invoice discounts, VAT base discounts and Max. VAT Difference aren't modelled.