Rounding
From LaneWiki
L’âne has a powerful and flexible rounding system.
Contents |
System-wide Rounding
In rounding situations where the portion of the calculated value less than the smallest base currency unit, the remainder is discarded.
Configuration
@@@@FIXME
Sales Line Items
When calculating the price of a sales line item, the value stored and used for further calculations is rounded using the system-wide rounding method, per line. Thus, the value stored in Sale.items.amt is rounded(qty * unit price).
Taxes
When calculating the individual tax lines of a sale, the value stored and used for further calculations is rounded using the system-wide rounding method after totaling all of the items taxable by the given tax. Thus, the value is rounded(sum(all items taxable by this tax rate)).
Saved Rounding
These rounding situations save any remainder larger than the smallest base currency unit, but after the #System-wide Rounding was applied. They are useful in cases where one wants to constrain a tender to some multiple of the base currency unit. For example, some countries no longer mint 0.01 coins, so cash transactions must be rounded to the nearest 0.05 amount.
Sale Total
After the #System-wide Rounding, the system will apply an additional "#Saved Rounding" to the sale, if configured to do so. The remainder from this saved rounding is stored as Sale.round and can thus be reported on. Reporting maybe useful, as some taxing jurisdictions allow businesses to report this value as a business expense. This value does not include the total of any #Sales Tenders Total values!
Configuration
@@@@FIXME
Sale Tenders Total
At tendering, but after the #System-wide Rounding, the system will apply an additional "#Saved Rounding" to the individual tender, if configured to do so. This option allows some tenders to use the saved rounding (cash) while other tenders do not use it (electronic transfers, like credit cards). The remainder is saved in Sale.tenders.round.
Configuration
This option is configured in Tender, per tender.
- Tender.roundBaseUnit
- The smallest unit value, after rounding. In the previous example, this value would be 0.05.
- Tender.roundUpPoint
- The point where a value should be rounded up. Typically, this value is
roundBaseUnit / 2.
- Tender.roundDirection
- The direction the tender should round.
Value Description away-from-zero Round away from zero: Negative values become smaller ("more negative") and positive values become larger towards-zero Round towards zero: Negative values become larger ("less negative") and positive values become smaller towards-infinity Round up: Negative and positive values become larger (Negative values are "less negative") towards-negative-infinity Round down: Negative and positive values become smaller (Negative values are "more negative") to-even Not implemented Round towards the even base unit. to-odd Not implemented Round towards the odd base unit.

