Fieldpine Logo Documentation Home   DESIGN NOTES

This information is a technical design note. Use extreme caution if relying on this information, it may be outdated or incomplete

Design Note: Discount PosCommand


Source Code: PosDiscount.cpp See also discount() PosCommand

Execution

Source Ref: PosDiscount::Go()

  1. Verify a sale has been passed in. Abort if not.
  2. Create FlowDataBase "PosDiscount", and record the command.
  3. Extract the name of the discount, selecting all characters until a delimiter (space is a delimiter and not permitted in disc_name field)
  4. If the name is "select" call discountSelect screen. If the result of this is to remove discounts, issue the corresponding "cleardiscount" PosCommand and exit
  5. Query the database using discounts.disc_name. If the name is not found in database log flow error 1219170628 and exit
  6. Verify the line syntax is correct and log flow error 1219170608 if something is wrong, but continue processing anyway
  7. Uniform discounts:
    1. Verify the requested amount is not 0. Exit if 0.
    2. If the setting DiscountMaxUniform is present, exit if the requested amount is greater than this.
    3. If the setting DiscountMinUniform is present, exit if the requested amount is less than this.
  8. Percentage discounts:
    1. If the setting DiscountInteger is set (default=yes) then Fetch "long1". If this is 0, then convert the param field to the percentage then divide by "long2" (0 is treated as 1)
    2. Otherwise fetch "long1" as a double, if 0 converting param field to the percentage and then divide by "long2" (0 is treated as 1) using floating point operations. Set the processing mode to float-mode.
    3. If the percentage rate is greater than the setting DiscountMaxPercentage (default 100.00), the exit and do not apply
    4. If the percentage rate is less than the setting DiscountMinPercentage (default 0.01), the exit and do not apply
  9. Other types of discounts, preload various values. If the discount type is unknown, log flow error 1220170628 and exit.
  10. Store any "if" conditions present on the discount into the call arguments. They are only stored at this time, not evaluated.
  11. Transfer control to Sale-Add-Discount to apply the decoded discount

Sale-Add-Discount

Source Ref: Sale::AddDiscount()

  1. Log flow point 804160728
  2. If the requested line is "0" (sale wide discount) and the setting SaleDiscAutoAllLine is defined, the line is changed to -2
  3. If the was 0 the setting SaleDiscNoSale is set, exit without applying