[Bug 43911] New: Cashup payment types should respect PAYMENT_TYPE library limitations
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 Bug ID: 43911 Summary: Cashup payment types should respect PAYMENT_TYPE library limitations Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Point of Sale Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: martin.renvoize@openfifth.co.uk Target Milestone: --- Bug 33501 lets a library choose which PAYMENT_TYPE authorised values take part in cashup reconciliation, using the CashupPaymentTypes system preference. That preference is global, and the cashup code reads the PAYMENT_TYPE values without looking at their library limitations. Elsewhere PAYMENT_TYPE values are limited by library: the payment type drop-downs use AuthorisedValues.GetAuthValueDropbox, which calls search_with_library_limits for the logged-in library, so a type limited to library A is not offered at library B. Koha::Cash::Register->cashup_payment_types and cashup_payment_types_breakdown do not apply the same rule. A register at library B therefore still lists, and asks staff to count, a payment type that library B cannot take. Expected: when reconciling a register's cashup, only the types in CashupPaymentTypes that are available at the register's library are listed in the Complete cashup modal, in "Bankable by payment type" and in the per-type reconciliation. A Quick cashup builds its balanced list from the same set. Open question: takings already recorded against a type that is not available at the register's library must not silently drop out of the cashup, so I suggest keeping a type in the list when the register has outstanding takings of that type. Test plan: 1. Set UseCashRegisters and set CashupPaymentTypes to CASH,CHEQUE. 2. In the PAYMENT_TYPE authorised values, limit CHEQUE to library A only. 3. Create a register at library B and take a CASH payment on it. 4. At library B open the register page, click Record cashup, then Start cashup and Complete cashup. => Before: a CHEQUE row appears in the modal and in Bankable by payment type. => After: only CASH appears. 5. Repeat at library A: both CASH and CHEQUE appear. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk Depends on| |33501 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33501 [Bug 33501] Add optional support for different payment types during cashup reconciliation -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |13985 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13985 [Bug 13985] [Omnibus] Cash Management - Koha as 'Point of Sale' -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208991 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208991&action=edit Bug 43911: Respect PAYMENT_TYPE library limitations in cashup CashupPaymentTypes is a global list of PAYMENT_TYPE authorised value codes, and the cashup code read those values without looking at their library limitations. A register at library B therefore still listed, and asked staff to count, a payment type that is limited to library A and that library B cannot take. The payment type drop-downs elsewhere apply the limitation. Add Koha::Cash::Register->available_cashup_payment_types, which returns the configured types that apply to the register's library: - a type with no authorised value, or with no library limitations, is always kept - a type limited to other libraries is dropped - a dropped type is kept if the register has takings of that type in the current cashup period, so money already taken is never lost from the cashup - if everything would be dropped the full configured list is returned, so a cashup can always be completed cashup_payment_types_breakdown now uses it. That is what the Complete cashup modal, the "Bankable by payment type" summary, the registers list labels and the Quick cashup (balanced_reconciliations) are built from. cashup_payment_types is unchanged and still returns every configured type, which add_cashup validation and the cashup summary of completed cashups rely on, so historical cashups are not affected. To test: 1. Set UseCashRegisters and set CashupPaymentTypes to CASH,CHEQUE 2. In the PAYMENT_TYPE authorised values, limit CHEQUE to library A only 3. Create a register at library B and take a CASH payment on it 4. At library B open the register page, click Record cashup, then Start cashup and Complete cashup => Before: a CHEQUE row appears in the modal => After: only CASH appears, and entering the cash amount completes the cashup 5. Repeat at library A: both CASH and CHEQUE appear 6. prove t/db_dependent/Koha/Cash/Register.t Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com Status|Needs Signoff |Failed QA --- Comment #2 from David Nind <david@davidnind.com> --- Have Failed QA because the tests fail. It is odd, as if I apply the patches (both the dependent bug and this bug, with an updatedatabase, restart_all) - the tests pass. - Note: The library and cash register created by the tests are still in the system. If I reset everything, then work through the test plan and add the transactions, things work as expected (the issue identified is fixed). However, the tests now fail. Test failures: prove t/db_dependent/Koha/Cash/Register.t t/db_dependent/Koha/Cash/Register.t .. 15/18 # Failed test 'One entry per configured payment type, zero when there are no takings' # at t/db_dependent/Koha/Cash/Register.t line 2209. # Structures begin differing at: # $got->[1] = Does not exist # $expected->[1] = ARRAY(0x5572cf09a4b0) # Looks like you failed 1 test of 6. t/db_dependent/Koha/Cash/Register.t .. 16/18 # Failed test 'balanced_reconciliations' # at t/db_dependent/Koha/Cash/Register.t line 2257. t/db_dependent/Koha/Cash/Register.t .. 17/18 # Looks like you failed 1 test of 18. t/db_dependent/Koha/Cash/Register.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/18 subtests Test Summary Report ------------------- t/db_dependent/Koha/Cash/Register.t (Wstat: 256 (exited 1) Tests: 18 Failed: 1) Failed test: 16 Non-zero exit status: 1 Files=1, Tests=18, 91 wallclock secs ( 0.04 usr 0.00 sys + 63.12 cusr 25.20 csys = 88.36 CPU) Result: FAIL Testing notes (using KTD): 1. Libraries used: - Library A = Centerville - Library B = Midway 2. Apply the patches in bug 33501, databaseupdate, yarn build (just in case) and restart_all 3. Add a CHEQUE authorized value to the PAYMENT_TYPE authorized values category (Administration > Basic parameters > Authorized values), and set the "Library limitations" field to Library A (Centerville). 4. Set the UseCashRegisters system preference to "Use". 5. For the new CashupPaymentTypes system preference select "Cheque" payment type. 6. Add two cash registers: - One for Library A (Centerville) - One for Library B (Midway) 7. With the library set to Library A (Centerville): - Create a manual invoice for a patron ([selected patron] > Accounting > Create manual invoice), for Example Mary Burton - Make a payment 8. Go to More > Tools > Cash management > Cash summary for Library A (Centerville) 9. For the register, click Record cashup, then Start cashup and then Complete cashup. ==> Result: Both Cash and Cheque row appears (as expected) 10. Change to Library B (Midway) and repeat steps 7 to 9. ==> Result: Both Cash and Cheque row appears (not as expected, only the Cash row should appear - the Cheque row should only be shown for Library A (Centerville) because of the library limitations set in step 3) 11. Apply the patches for this bug (don't apply the patches for bug 33501, as these are already applied). 12. Go to More > Tools > Cash management > Cash summary for Library B (Midway), and click "Complete cashup": ==> Result: Only the Cash row is shown (as expected) 13. Change to Library A (Centerville) and go to More > Tools > Cash management
Cash summary for Library A (Centerville), and click "Complete cashup": ==> Result: Both the Cash and Cheque rows are shown (as expected) 14. The tests should pass: prove t/db_dependent/Koha/Cash/Register.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208991|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 209110 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209110&action=edit Bug 43911: Respect PAYMENT_TYPE library limitations in cashup CashupPaymentTypes is a global list of PAYMENT_TYPE authorised value codes, and the cashup code read those values without looking at their library limitations. A register at library B therefore still listed, and asked staff to count, a payment type that is limited to library A and that library B cannot take. The payment type drop-downs elsewhere apply the limitation. Add Koha::Cash::Register->available_cashup_payment_types, which returns the configured types that apply to the register's library: - a type with no authorised value, or with no library limitations, is always kept - a type limited to other libraries is dropped - a dropped type is kept if the register has takings of that type in the current cashup period, so money already taken is never lost from the cashup - if everything would be dropped the full configured list is returned, so a cashup can always be completed cashup_payment_types_breakdown now uses it. That is what the Complete cashup modal, the "Bankable by payment type" summary, the registers list labels and the Quick cashup (balanced_reconciliations) are built from. cashup_payment_types is unchanged and still returns every configured type, which add_cashup validation and the cashup summary of completed cashups rely on, so historical cashups are not affected. The tests set up their own CashupPaymentTypes but not the library limitations of the PAYMENT_TYPE authorised values of the system, so they failed on a system where a payment type such as CHEQUE was limited to one library. Remove the limitations inside the tests' transactions. The cashup_payment_types test also created a library and a register outside of a transaction and left them in the database. To test: 1. Set UseCashRegisters and set CashupPaymentTypes to CASH,CHEQUE 2. In the PAYMENT_TYPE authorised values, limit CHEQUE to library A only 3. Create a register at library B and take a CASH payment on it 4. At library B open the register page, click Record cashup, then Start cashup and Complete cashup => Before: a CHEQUE row appears in the modal => After: only CASH appears, and entering the cash amount completes the cashup 5. Repeat at library A: both CASH and CHEQUE appear 6. prove t/db_dependent/Koha/Cash/Register.t It passes also when CHEQUE is limited to a library, and leaves no library or register behind Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Thanks David, very good catch, and thank you for noting what the tests leave behind. The failure was in the tests rather than the fix: balanced_reconciliations (and the other cashup tests) set up CashupPaymentTypes themselves, with CASH and CHEQUE, but not the library limitations of the PAYMENT_TYPE authorised values. On a system where CHEQUE is limited to one library (as after your manual test plan) the test register, which is created in a random library, correctly no longer lists CHEQUE when it has no takings of it, so the test saw one entry instead of two. On a database where CHEQUE has no limitation they pass, which is why they passed for you before the reset. I reproduced it with CHEQUE limited to one library and the new attachment makes the tests remove the limitations inside their transactions. They now pass with and without such a limitation. The library and cash register left behind came from the cashup_payment_types test (from bug 33501) which created a register outside of a transaction; that is fixed in the same patch and I checked the counts of libraries and registers no longer change after a run. Setting back to Needs Signoff. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43911 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org