Koha-clms/t/db_dependent/Koha
Martin Renvoize 4ce8081f07
Bug 29923: Prevent overpayment credit when written-off accruing fine is adjusted on check-in
When a staff member writes off an accruing fine and the item is
subsequently checked in (backdated or in fine-free mode), the fine
amount is recalculated downward via adjust(). The previous code
unconditionally created an OVERPAYMENT credit whenever the adjusted
outstanding went negative, regardless of whether the existing credits
were reversible payments or non-reversible writeoffs/discounts.

This caused patrons to receive an erroneous credit equal to the
written-off amount, since writeoffs should simply be absorbed when
the underlying fine shrinks - no refund is due.

The fix calculates the total non-reversible credits (writeoffs,
discounts, cancellations) applied to the debit using the existing
filter_by_non_reversible method, and only generates an OVERPAYMENT
credit for the portion attributable to reversible cash payments that
exceed the recalculated fine amount.

Test plan:
1. Write off an accruing fine in full
2. Check the item in (backdated or fine-free)
3. Confirm no overpayment credit is generated for the patron

Signed-off-by: Benjamin Daeuber <BDaeuber@fargolibrary.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-09 17:06:47 -06:00
..
Account Bug 29923: Prevent overpayment credit when written-off accruing fine is adjusted on check-in 2026-03-09 17:06:47 -06:00
Acquisition Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
Auth Bug 33782: (QA follow-up) Fix qa issues 2026-02-10 10:51:33 -07:00
BackgroundJob Bug 40846: Improve handling of ignored records 2026-01-21 07:44:20 -07:00
BackgroundJobs Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblio Bug 41031: Fix the subtest check_fixed_length in MARC21.t 2025-12-01 12:53:43 -07:00
Cash Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Charges Bug 36506: Adjust existing tests and test builder 2026-02-27 11:38:47 -07:00
Checkouts Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CirculationRules Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Club Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Config Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Database Bug 40777: Add tests for for_biblio 2026-01-21 07:44:18 -07:00
ERM Bug 39438: (follow-up) Remove agreement_id from periods before comparing to result 2026-02-06 07:21:01 -07:00
Edifact Bug 40391: Add unit tests for GIR:LSL support in EDI 2026-01-12 10:53:29 -07:00
File Bug 40811: (follow-up) Fix list context bug and add comprehensive tests 2026-01-21 15:28:17 -07:00
Filter Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ILL Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
Import Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Item Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Items Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Library Bug 28530: Fix tests 2026-02-10 10:51:38 -07:00
Notice Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAI/Server Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Object Bug 32370: (QA follow-up) Add https to license url, use Test::NoWarnings 2026-01-22 10:02:26 -07:00
Objects Bug 35451: Fix test data 2025-11-07 10:54:06 -07:00
Old Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patron Bug 41818: Add unit tests 2026-02-26 09:04:12 -07:00
Patrons Bug 41145: Add unit test coverage for stopping duplicated borrowerslog logging due to extended patron attributes being deleted on import 2025-12-17 13:24:26 -07:00
Plugins Bug 36542: Update unit test 2026-03-05 08:33:41 -07:00
Policy Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Preservation Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
REST Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
SIP2 Bug 37893: Handle SIPconfig.xml not found / unreadable 2025-11-26 10:40:35 -07:00
SMTP Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchEngine Bug 40966: Regression tests 2026-02-06 15:17:17 -07:00
Subscription Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Tags Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Template/Plugin Bug 40095: Add context to intranet_js plugin hook 2026-02-06 15:17:36 -07:00
Ticket Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
UI/Form/Builder Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
XSLT Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Z3950Responder Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Account.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
ActionLogs.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
AdditionalContents.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
AdditionalField.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
ApiKey.t Bug 20638: Improve ApiKey logging to use structured data 2026-01-22 09:26:02 -07:00
ArticleRequest.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ArticleRequests.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Authorities.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Authority.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
BackgroundJob.t Bug 40943: Fix Koha/BackgroundJob.t 2025-11-04 07:15:11 -07:00
BackgroundJobs.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblio.t Bug 41886: Filter checkouts to bookable items in check_booking 2026-02-26 09:04:20 -07:00
BiblioFrameworks.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblios.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Booking.t Bug 41887: Skip clash detection on terminal status transition 2026-02-26 09:04:22 -07:00
Bookings.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Calendar.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Checkout.t Bug 35612: Add unit test for Koha::Checkout->branch_for_fee_context 2026-02-27 11:38:50 -07:00
Checkouts.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
CirculationRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Cities.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSortRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSources.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSplitRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Course.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Courses.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CoverImages.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CsvProfiles.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CurbsidePickups.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Database.t Bug 38384: Refactor plugin loading to use lightweight Koha::Plugins::Loader 2026-02-25 07:36:59 -07:00
Desks.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
EDI.t Bug 40391: Add unit tests for GIR:LSL support in EDI 2026-01-12 10:53:29 -07:00
Encryption.t Bug 40444: Add a test to ensure all Perl test files use Test::NoWarnings 2025-07-28 16:26:36 -06:00
Hold.t Bug 3492: (RM follow-up) Adjust tests 2026-02-09 12:57:58 -07:00
Holds.t Bug 3492: (follow-up) Remove last reservefee references 2026-02-09 12:57:57 -07:00
ImportBatch.t Bug 41036: (QA follow-up) use nowarnings 2026-02-26 09:04:15 -07:00
Installer.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Item.t Bug 40154: prevent deletion of items with holds 2026-02-10 10:52:04 -07:00
ItemTypes.t Bug 39745: Fix wrong system preference 'language' in test suite (mock_preference) 2026-01-26 14:36:44 -07:00
Items.t Bug 36506: Adjust existing tests and test builder 2026-02-27 11:38:47 -07:00
KeyboardShortcuts.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Libraries.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Library.t Bug 39482: (follow-up) Adjust tests 2025-12-29 09:56:17 -07:00
MarcOrder.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
MarcSubfieldStructures.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Notice_Util.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Notices.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAIHarvester.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAIServers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Object.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Objects.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
Old.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patron.t Bug 39014: (follow-up) Refactoring and renaming to can_be_guaranteed_by 2025-12-30 07:49:05 -07:00
Patron_generate_userid.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patrons.t Bug 23260: Unit tests 2026-03-05 08:33:45 -07:00
Pseudonymization.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
PseudonymizedTransaction.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Quotes.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Ratings.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Recall.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Recalls.t Bug 39985: Set items.onloan when recall adjusts checkout due date 2025-12-01 08:34:05 -07:00
RecordSource.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Reports.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Reviews.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SMS_Providers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchField.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchFilters.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Session.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
SharedContent.t Bug 39745: Fix wrong system preference 'language' in test suite (mock_preference) 2026-01-26 14:36:44 -07:00
Statistic.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Statistics.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Subscription.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Suggestion.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Suggestions.t Bug 41695: Unit tests 2026-02-06 15:17:07 -07:00
Tags.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Ticket.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Virtualshelf.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Virtualshelves.t Bug 39145: (follow-up) Tidy files 2025-09-29 14:02:26 -06:00
Z3950Servers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00