If a lost item is stilled owed in full, the fee is reduced to 0 but no corresponding account offset is generated. All changes to accountlines should generate a corresponding account offset.
Just a guess: this could be implemented using Koha::Account::Line->adjust, provided we allowed negative increments and a suitable update type/offset type is defined.
I indeed left the amount in the adjust method open for just this sort of thing. A new offset type seems sensible [U+1F603].
Though actually, thinking more about this I'm not sure I understand why we're editing the amount directly here at all.. surely it's just a case of adding a credit to offset the amount outstanding to zero as per other payments/waivers.. I don't know the history, perhaps someone could enlighten me?
(In reply to Martin Renvoize from comment #3) > Though actually, thinking more about this I'm not sure I understand why > we're editing the amount directly here at all.. surely it's just a case of > adding a credit to offset the amount outstanding to zero as per other > payments/waivers.. I don't know the history, perhaps someone could enlighten > me? I'm suspecting about adjust as well
Kyle, Martin and I agreed this will be implemented by making this add and apply a credit instead of manually setting amount to 0. The use of the changed accounttype is spread in many places and should remain untouched.
Created attachment 83029 [details] [review] Bug 21759: Regression tests This patch tests for a new behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. Only changes to the 'remaining debt' use cases on this tests are expected. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct. Note: some tests order changes are introduced to avoid calling discard_changes twice
Created attachment 83030 [details] [review] Bug 21759: Avoid manually setting amountoutstanding in _FixAccountForLostAndReturned This patch changes the behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. To test: - Apply the regression tests patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct - Apply this patch - Run: k$ prove t/db_dependent/Circulation.t => SUCCESS: Tests now pass! - Sign off :-D
Created attachment 83038 [details] [review] Bug 21759: Regression tests This patch tests for a new behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. Only changes to the 'remaining debt' use cases on this tests are expected. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct. Note: some tests order changes are introduced to avoid calling discard_changes twice Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 83039 [details] [review] Bug 21759: Avoid manually setting amountoutstanding in _FixAccountForLostAndReturned This patch changes the behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. To test: - Apply the regression tests patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct - Apply this patch - Run: k$ prove t/db_dependent/Circulation.t => SUCCESS: Tests now pass! - Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 83040 [details] [review] Bug 21759: Regression tests This patch tests for a new behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. Only changes to the 'remaining debt' use cases on this tests are expected. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct. Note: some tests order changes are introduced to avoid calling discard_changes twice Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 83041 [details] [review] Bug 21759: Avoid manually setting amountoutstanding in _FixAccountForLostAndReturned This patch changes the behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. To test: - Apply the regression tests patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct - Apply this patch - Run: k$ prove t/db_dependent/Circulation.t => SUCCESS: Tests now pass! - Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 83042 [details] [review] Bug 21759: Regression tests This patch tests for a new behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. Only changes to the 'remaining debt' use cases on this tests are expected. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct. Note: some tests order changes are introduced to avoid calling discard_changes twice Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 83043 [details] [review] Bug 21759: Avoid manually setting amountoutstanding in _FixAccountForLostAndReturned This patch changes the behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. To test: - Apply the regression tests patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct - Apply this patch - Run: k$ prove t/db_dependent/Circulation.t => SUCCESS: Tests now pass! - Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Passing QA.. this works as expected and is a marked improvement for auditing.
Awesome work all! Pushed to master for 19.05
Pushed to 18.11.x for 18.11.01
depends on 13098, won't backport to 18.05