https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43959

            Bug ID: 43959
           Summary: Cash-up reports false surplus or deficit when amounts
                    contain fractions of a penny
   Initiative type: ---
        Sponsorship ---
            status:
           Product: Koha
           Version: Main
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: Point of Sale
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
        Depends on: 33501, 43956, 43957, 43958
            Blocks: 23728
  Target Milestone: ---

Cash-up reports a false surplus or deficit, and makes the reconciliation reason
mandatory, when stored account line amounts contain fractions of a penny. Part
of the currency rounding work collected on bug 23728.

Reproduction: a POS card sale was stored in accountlines.amount as -0.825000
(quantity x price, unrounded). At cash-up the counted card total (0.83) did not
match the expected total (0.825); the reconciliation note became mandatory and
a CASHUP_SURPLUS line of -0.005000 was created, displayed as GBP 0.01.

Causes:
- Koha::Cash::Register::cashup_payment_types_breakdown returns the raw
SUM(amount) * -1.
- Koha::Cash::Register::add_cashup computes difference = actual - expected in
floating point and tests difference == 0.
- cashup_modals.js recalculate() does the same on the client.
- The client also disagrees with itself: (0.825).toFixed(2) is "0.82" but (0.83
- 0.825).toFixed(2) is "0.01".

Fix: compare integer minor units (using the currency decimal_digits and the
shared rounding engine) on both server and client; present expected totals at
currency precision; compute the difference in minor units.

Tests: an expected total ending in a half-penny does not trigger a discrepancy,
note requirement, or surplus/deficit line; a genuine 1p difference is still
detected.

Existing sub-penny lines need no data fix for cash-up to work.


Referenced Bugs:

https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23728
[Bug 23728] Rounding code should be moved to a Koha module so code can be
centralised
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33501
[Bug 33501] Add optional support for different payment types during cashup
reconciliation
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43956
[Bug 43956] Koha::Number::Price::round returns wrong or inconsistent results
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43957
[Bug 43957] Add per-currency decimal digits and configurable rounding policy
preferences
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43958
[Bug 43958] Replace toFixed-based price formatting with a currency-aware
minor-unit helper
-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to