Receipt amount and discount rules: Difference between revisions
David Ashton (talk | contribs) (Created page with "This is how the register calculates amounts: There are two functions, applyAmountRule(amount) and applyDiscountAmountRule(discountAmount). The amount rule function does this: Convert the amount to pennies by multiplying by 100.0 If the fractional part is less than 0.001 then take the floor amount else take the ceiling amount. This amount is multiplied by 0.01 and returned. The discount amount rule does this: Convert the amount to pennies by multiplying by 100.0...") |
David Ashton (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
There are two functions, applyAmountRule(amount) and applyDiscountAmountRule(discountAmount). | There are two functions, applyAmountRule(amount) and applyDiscountAmountRule(discountAmount). | ||
The amount rule function does this: | '''The amount rule function does this:''' | ||
Convert the amount to pennies by multiplying by 100.0 | Convert the amount to pennies by multiplying by 100.0 | ||
Line 12: | Line 12: | ||
The discount amount rule does this: | |||
'''The discount amount rule does this:''' | |||
Convert the amount to pennies by multiplying by 100.0 | Convert the amount to pennies by multiplying by 100.0 | ||
Line 36: | Line 37: | ||
There is one exception to these rules. If the menu has tax included in the price then the discount rule is used in all calculations. This is so items for example set to $7.00 don't end up being $7.01 | There is one exception to these rules. If the menu has tax included in the price then the discount rule is used in all calculations. This is so items for example set to $7.00 don't end up being $7.01 | ||
==Cash Discounting Fee== | |||
Credit card fee from a given amount | |||
:fee = ( amount / ( 1.0 - percentage ) ) - amount | |||
:fee = applyAmountRule(fee) |
Revision as of 11:03, 29 August 2024
This is how the register calculates amounts:
There are two functions, applyAmountRule(amount) and applyDiscountAmountRule(discountAmount).
The amount rule function does this:
Convert the amount to pennies by multiplying by 100.0
If the fractional part is less than 0.001 then take the floor amount else take the ceiling amount.
This amount is multiplied by 0.01 and returned.
The discount amount rule does this:
Convert the amount to pennies by multiplying by 100.0
If the fractional part is greater than 0.999 then take the ceiling amount else take the floor amount.
This amount is multiplied by 0.01 and returned.
So the amount rule always goes up unless it is within 0.001 of a penny.
The discount rule always go down unless it is within 0.999 of a penny.
Discounts are calculated with fractional amounts during the calculation of modifier amounts, line amounts and the subtotal.
The amount rule is applied to each modifier, each line in the receipt, the full price of the receipt, the subtotal, the tax, the alcohol tax, the credit card fee, and the service fee. All of these amounts go up unless they are within 0.001 of a penny.
The full amount does not have any discounts and the subtotal does have discounts applied.
The final discount is calculated as the full amount - subtotal and then the discount rule is applied to this result. The discounts always go down unless they are within 0.999 of a penny.
There is one exception to these rules. If the menu has tax included in the price then the discount rule is used in all calculations. This is so items for example set to $7.00 don't end up being $7.01
Cash Discounting Fee
Credit card fee from a given amount
- fee = ( amount / ( 1.0 - percentage ) ) - amount
- fee = applyAmountRule(fee)