Bug 20262 - Add ability to refund lost item fees without creating credits
Summary: Add ability to refund lost item fees without creating credits
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement with 34 votes (vote)
Assignee: Kyle M Hall
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-21 16:03 UTC by Kyle M Hall
Modified: 2022-05-08 20:45 UTC (History)
15 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Medium patch
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 20262: Add ability to refund lost item fees without creating credits (12.30 KB, patch)
2018-02-21 16:14 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (12.88 KB, patch)
2018-02-21 16:17 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (14.09 KB, patch)
2018-05-22 14:21 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (15.35 KB, patch)
2018-05-23 14:32 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (15.45 KB, patch)
2018-05-24 10:14 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (14.78 KB, patch)
2019-10-14 13:56 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (11.80 KB, patch)
2021-10-27 15:58 UTC, David Gustafsson
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (20.64 KB, patch)
2021-11-03 18:51 UTC, David Gustafsson
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (20.37 KB, patch)
2021-11-03 18:54 UTC, David Gustafsson
Details | Diff | Splinter Review
Bug 20262: Add ability to refund lost item fees without creating credits (20.43 KB, patch)
2022-05-03 16:24 UTC, ByWater Sandboxes
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2018-02-21 16:03:54 UTC
Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.
Comment 1 Kyle M Hall 2018-02-21 16:14:05 UTC
Created attachment 72029 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
Comment 2 Kyle M Hall 2018-02-21 16:17:20 UTC
Created attachment 72030 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
Comment 3 Martha Fuerst 2018-05-21 14:45:30 UTC
Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.

Notes:
4) If the patron has other fines, the lost item refund pays those first, as opposed to just paying the lost item charge. This could be confusing for staff, but IIRC, there's another bug related to how credits get applied?
8) Marked an item lost that created a 9.99 charge on patron's account. Paid 5.00 of it. Returned item. Patron's account was credited 9.99, creating a 5.00 credit.
9) Fully paid for item - credit still applied, resulting in a credit on the account.
Comment 4 Kyle M Hall 2018-05-22 14:21:11 UTC
Created attachment 75470 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
Comment 5 Kyle M Hall 2018-05-22 14:23:55 UTC
(In reply to Martha Fuerst from comment #3)
> Test Plan:
> Notes:
> 4) If the patron has other fines, the lost item refund pays those first, as
> opposed to just paying the lost item charge. This could be confusing for
> staff, but IIRC, there's another bug related to how credits get applied?
> 8) Marked an item lost that created a 9.99 charge on patron's account. Paid
> 5.00 of it. Returned item. Patron's account was credited 9.99, creating a
> 5.00 credit.
> 9) Fully paid for item - credit still applied, resulting in a credit on the
> account.

Martha, it sounds like perhaps the circ rule with "Only if unpaid" did not get selected. Did you set *all* your rules to "Only if unpaid" to ensure you didn't accidentally change the wrong rule? The unit tests prove the functionality works so that's my best guess at what's happening for you. I've also added some more unit tests to prove partially paid lost fees don't cause a credit when the rule is applied.
Comment 6 Martha Fuerst 2018-05-22 14:36:16 UTC
(In reply to Kyle M Hall from comment #5)
> (In reply to Martha Fuerst from comment #3)
> > Test Plan:
> > Notes:
> > 4) If the patron has other fines, the lost item refund pays those first, as
> > opposed to just paying the lost item charge. This could be confusing for
> > staff, but IIRC, there's another bug related to how credits get applied?
> > 8) Marked an item lost that created a 9.99 charge on patron's account. Paid
> > 5.00 of it. Returned item. Patron's account was credited 9.99, creating a
> > 5.00 credit.
> > 9) Fully paid for item - credit still applied, resulting in a credit on the
> > account.
> 
> Martha, it sounds like perhaps the circ rule with "Only if unpaid" did not
> get selected. Did you set *all* your rules to "Only if unpaid" to ensure you
> didn't accidentally change the wrong rule? The unit tests prove the
> functionality works so that's my best guess at what's happening for you.
> I've also added some more unit tests to prove partially paid lost fees don't
> cause a credit when the rule is applied.

I have it set as the default rule in our bug-squashing sandbox's Circ Rules table, with no other library-specific rules set.

Is there something in sysprefs that might be fouling it up? 

BlockReturnofLostItems: Don't block
RetundLostOnReturnControl: check-in library
WhenLostChargeReplacementFee: Charge
WhenLostForgiveFine: Don't forgive
Comment 7 Kyle M Hall 2018-05-22 15:27:20 UTC
(In reply to Martha Fuerst from comment #6)
> Is there something in sysprefs that might be fouling it up? 

That looks pretty good, are you sure you are triggering the rule by utilizing the branch chosen from RetundLostOnReturnControl?

Basically, if the other refund lost item fee rule options work, then you can switch those rules to "only if unpaid" and it should work. If they do not work it is an issue with your test data.
Comment 8 Kyle M Hall 2018-05-23 14:32:02 UTC
Created attachment 75503 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
Comment 9 Martha Fuerst 2018-05-23 17:30:40 UTC
(In reply to Kyle M Hall from comment #7)
> (In reply to Martha Fuerst from comment #6)
> > Is there something in sysprefs that might be fouling it up? 
> 
> That looks pretty good, are you sure you are triggering the rule by
> utilizing the branch chosen from RetundLostOnReturnControl?
> 
> Basically, if the other refund lost item fee rule options work, then you can
> switch those rules to "only if unpaid" and it should work. If they do not
> work it is an issue with your test data.

Gotcha.

Tested again after you took a look at my settings (thanks Kyle!) -

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.

Everything worked as it should - signing off!
Comment 10 Kyle M Hall 2018-05-24 10:14:14 UTC
Created attachment 75532 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Martha Fuerst <mfuerst@hmcpl.org>
Comment 11 Katrin Fischer 2018-08-10 12:09:32 UTC
Hi Kyle,
code looks sensible, but I am having problems with the unit tests. Can you have a look please? Tested on a clean db (reset_all), passes on master, fails with the patch applied:

# Subtest: _FixAccountForLostAndReturned
    1..11
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`accountlines`, CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE) [for Statement "INSERT INTO `accountlines` ( `accounttype`, `amount`, `amountoutstanding`, `itemnumber`) VALUES ( ?, ?, ?, ? )" with ParamValues: 0='F', 1=10, 2=10, 3='1041'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.
    # No tests run!
not ok 113 - No tests run for subtest "_FixAccountForLostAndReturned"
Comment 12 Martha Fuerst 2018-12-12 20:14:04 UTC
This would really help us out with the lost item credits issues we are having at our library. Can we look into this again?

Thanks!

-Marti
Comment 13 Rhonda Kuiper 2018-12-12 21:27:16 UTC
This fix would be SUPER helpful for our library as well. At our library we do not give any refunds because of the way our money goes through the city.
Rhonda Kuiper.
Comment 14 Chris Slone 2019-01-03 15:54:23 UTC
Just to add to the interest and need expressed by Martha and Rhonda: This is more than ever a necessity for us, as the recent changes to how Koha handles credits have made apparent how often refunds have been automatically generated for something already resolved without anyone catching it. Hoping this is in a release soon.
Comment 15 Tomás Cohen Arazi 2019-01-09 09:53:42 UTC
Kyle, unfortunately a lot of the code changed in the meantime so this doesn't apply. I suggest you take a look at the PQA stuffs because there's still lots of moving pieces here (Koha::Account->add_debit, Koha::Account::Lin->adjust bugs specifically)
Comment 16 Christopher Brannon 2019-04-18 20:14:39 UTC
Please add me to the list of squeaky wheels about this.  We want to see this added ASAP.
Comment 17 Cab Vinton 2019-05-16 21:17:08 UTC
We would also be happy to see this bug applied as soon as possible.
Comment 18 Martha Fuerst 2019-05-17 13:22:12 UTC
We are also still very interested!
Comment 19 Caroline Cyr La Rose 2019-10-04 13:43:04 UTC
Hi! A lot of our libraries would love to see this added as the refunds for lost items create many headaches.
Comment 20 Jonathan Druart 2019-10-14 13:56:38 UTC
Created attachment 94099 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Martha Fuerst <mfuerst@hmcpl.org>
Comment 21 Jonathan Druart 2019-10-14 13:57:25 UTC
Kyle, I have tried to rebase the patch but I lost myself in the tests. Could you have a look?
Comment 22 Martha Fuerst 2021-02-05 16:16:11 UTC
We're still interested in this!

-Marti Fuerst
Huntsville-Madison County Public Library
Comment 23 Christopher Brannon 2021-02-05 18:05:02 UTC
Still interested - disparately wanting.
Comment 24 Rhonda Kuiper 2021-02-05 19:12:52 UTC
Still interested - eagerly anticipating.
Comment 25 Chris Slone 2021-02-05 19:43:44 UTC
Still interested - anxiously awaiting.
Comment 26 Christopher Brannon 2021-08-26 17:47:53 UTC
Unexpectedly misspelling!
Comment 27 David Gustafsson 2021-10-27 15:58:57 UTC
Created attachment 127018 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should ocurr
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
Comment 28 David Gustafsson 2021-10-27 16:07:15 UTC
Working on this, tests are in progress though since the tests in t/db_dependent/Circulation.t are crashing and failing with or without the patch, so need to work out those issues first before being able to properly run the tests, which has to be rewritten since so much has been refactored with regard to how lost item fees are handled.
Comment 29 David Gustafsson 2021-11-03 18:51:38 UTC
Created attachment 127285 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should occur
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
11) Run tests in t/db_dependent/Circulation.t
Comment 30 David Gustafsson 2021-11-03 18:52:11 UTC
Now added tests.
Comment 31 David Gustafsson 2021-11-03 18:54:12 UTC
Created attachment 127286 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should occur
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
11) Run tests in t/db_dependent/Circulation.t
Comment 32 ByWater Sandboxes 2022-05-03 16:24:44 UTC
Created attachment 134555 [details] [review]
Bug 20262: Add ability to refund lost item fees without creating credits

Some libraries handle refunding of paid lost fees at a financial office and not within Koha. To facilitate this, it would be good for Koha to have the option to not generate lost returned credits by skipping fully paid lost items, and only refunding the outstanding balance on partially paid lost fees.

Test Plan:
1) Apply this patch
2) Set your lost item refund on return policies to 'Only if unpaid'
3) Mark an item lost, charging the lost fee
4) Return the item, a full refund should occur
5) Mark another item lost, charging the lost fee
6) Make a partial payment on this lost fee
7) Return the item
8) The remaining balance of that fee should be 0, but the patron should
   not recieve a credit for the already paid balance
8) Mark another item lost, charging the lost fee
9) Fully pay the lost fee
10) Return the item. The paid lost fee should be unaffected.
11) Run tests in t/db_dependent/Circulation.t

Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com>
Comment 33 Lisette Scheer 2022-05-03 16:26:14 UTC
Works as expected. 
I also tried with partial and full write offs and it worked as expected there as well. 

I was not able to do step 11 as I was on the sandbox. 

I'm really looking forward to this! 
Lisette