Koha-clms/t
Martin Renvoize c58d465cfc
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: Laura Escamilla <laura.escamilla@bywatersolutions.com>
(cherry picked from commit 44483cab32)
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
2026-05-27 15:03:29 +00:00
..
Acquisition
…
Biblio
…
Budgets
…
Circulation Bug 37155: Refactor GetAgeRestrictions 2024-07-01 18:55:50 +02:00
External
…
Koha Bug 34164: Redirect to referring URL when doing OIDC/OAuth SSO 2026-01-09 09:42:39 +01:00
Number Bug 37511: Unit tests 2024-10-30 11:57:27 +01:00
SIP Bug 40675: Add unit tests for SIP line ending normalization 2025-10-16 11:52:21 +02:00
Search Bug 34969: Remove unneeded module from buildQuery.t 2023-10-04 09:15:42 -04:00
Serials Bug 32392: Tests for changes in C4::Serials::GetNextSeq 2024-04-29 15:19:30 +02:00
Template Bug 42136: (RMaint follow-up) Fix number of tests 2026-04-27 09:24:16 +02:00
Test Bug 40404: Remove diag from t/Test/Mock/Logger.t 2025-08-01 15:22:48 +02:00
cypress Merge branch '24.11.x-security' into 24.11.x 2026-04-27 09:23:57 +02:00
data Bug 41032: Fix Open Fifth missing in plugin repos config 2025-12-04 14:35:24 +01:00
db_dependent Bug 29923: Prevent overpayment credit when written-off accruing fine is adjusted on check-in 2026-05-27 15:03:29 +00:00
edi_testfiles Bug 38423: Add unit tests 2025-04-17 14:30:35 +02:00
etc
…
lib Bug 40765: Prevent acquisition tests to fail if order.quantity = 0 2025-10-16 07:55:14 +02:00
mock_templates/intranet-tmpl/prog Bug 36640: Remove jEditable 2024-11-14 14:19:37 +01:00
00-check-atomic-updates.t Bug 31479: Option to skip t/00-check-atomic-updates.t when building custom packages 2023-05-10 15:26:20 -03:00
00-load.t
…
00-merge-conflict-markers.t
…
00-testcritic.t Bug 34911: Test files from HEAD instead of 'master' 2023-10-04 09:15:35 -04:00
00-valid-xml.t
…
Auth.t
…
AuthoritiesMarc_MARC21.t Bug 31023: Unit tests 2022-09-07 13:52:35 -07:00
AuthoritiesMarc_UNIMARC.t
…
Barcodes_EAN13.t
…
Barcodes_annual.t
…
Barcodes_hbyymmincr.t
…
Barcodes_incremental.t
…
Biblio.t Bug 37380: Replace uses of GetMarcControlnumber for get_control_number() 2024-09-16 10:41:05 +02:00
Biblio2.t
…
Budgets.t
…
Charset.t
…
Circulation_barcodedecode.t Bug 30409: (QA follow-up) Avoid uninitialized variable warnings 2022-06-14 08:26:58 -03:00
ClassSortRoutine.t
…
ClassSortRoutine_Dewey.t
…
ClassSortRoutine_Generic.t
…
ClassSortRoutine_LCC.t
…
ClassSource.t
…
Context.t Bug 36081: Use multivalue_preference 2025-02-24 20:43:20 +01:00
Contract.t
…
CookieManager.t Bug 31250: (QA follow-up) The future will be easier 2022-09-12 15:34:11 -03:00
Creators.t
…
DateUtils.t Bug 36432: Remove circular dependency from Koha::Object 2024-04-04 15:24:32 +02:00
EdiInvoice.t
…
Edifact.t Bug 35398: Add unit test for extraction of library_rotation_plan 2024-03-07 15:02:46 +01:00
Ediorder.t Bug 31134: Mock EdifactLSQ for t/Edifact.t 2022-07-18 10:20:44 -03:00
Ediordrsp.t
…
Form_MessagingPreferences.t Bug 34776: Add unit tests for sub restore_form_values 2025-07-28 10:22:07 +02:00
HtmlTags.t
…
ImportBatch.t Bug 18772: Remove warnings from t/ImportBatch.t 2025-08-01 15:50:08 +02:00
Installer_PerlModules.t Bug 30731: Unit tests 2022-06-01 16:15:25 -03:00
ItemCirculationAlertPreference.t
…
Koha_MetadataRecord.t Bug 33749: Use TrimFields instead of stripWhitespaceChars 2023-11-03 12:08:06 -03:00
Koha_SearchEngine_Elasticsearch_Browse.t
…
Koha_Template_Plugin_HtmlId.t
…
Koha_Template_Plugin_Koha.t Bug 31401: (QA follow-up) Remove Koha.ArePluginsEnabled, it is no longer needed 2022-09-07 13:55:37 -07:00
Koha_Util_FrameworkPlugin.t
…
Koha_Util_MARC.t
…
Koha_XSLT_HTTPS.t Bug 12758: Introduce Koha::XSLT::HTTPS 2022-11-09 09:52:17 -03:00
Labels.t Bug 40388: Remove warning from t/Labels.t 2025-08-01 14:29:57 +02:00
Labels_split_Regex.t
…
Labels_split_ccn.t Bug 30110: Fix concatenation during assignements 2022-03-24 14:22:10 -10:00
Labels_split_ddcn.t Bug 30110: Fix concatenation during assignements 2022-03-24 14:22:10 -10:00
Labels_split_lccn.t Bug 30110: Fix concatenation during assignements 2022-03-24 14:22:10 -10:00
Languages.t Bug 38630: (QA follow-up) Two typos 2025-09-29 09:34:51 +02:00
Logger.t Bug 35907: Add ability to log all custom report runs with or without query 2024-05-10 16:45:45 +02:00
Makefile.t Bug 40527: Add SECURITY.md to ignored list in MakeFile.t 2026-01-09 09:41:06 +01:00
Members_Messaging.t
…
OpenLibrarySearch.t
…
Output.t Bug 30524: Unit tests 2023-08-07 20:59:59 -03:00
Output_JSONStream.t
…
Patroncards.t
…
Patroncards_Batch.t
…
Patroncards_Lib.t
…
Patroncards_Patroncard.t
…
Patroncards_Profile.t
…
Patroncards_Template.t
…
RecordProcessor.t Bug 40128: Unit tests 2025-07-31 16:18:10 +02:00
Ris.t
…
SMS.t Bug 36307: SMS::Send driver errors are not captured and stored 2024-04-05 17:39:46 +02:00
Scheduler.t
…
Scrubber.t Bug 40079: (follow-up) Improve test coverage and fix undef handling 2025-07-25 16:49:49 +02:00
Search.t Bug 34968: Remove unneeded module from Search.t 2023-10-04 09:32:46 -04:00
Search_PazPar2.t
…
SimpleMARC.t Bug 36515: (QA follow-up) Tidy code 2024-08-02 19:00:05 +02:00
SuggestionEngine.t
…
SuggestionEngine_AuthorityFile.t Bug 34970: Remove most modules from SuggestionEngine_AuthorityFile.t 2023-10-04 09:15:41 -04:00
TmplToken.t
…
Token.t Bug 36367: Fix test t/Token.t 2024-06-14 11:17:19 +01:00
template_filters.t Bug 38872: Add a test 2025-04-22 23:02:08 +02:00
timezones.t
…