Bug 21759: Avoid manually setting amountoutstanding in _FixAccountForLostAndReturned
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 10 Dec 2018 19:45:00 +0000 (16:45 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 12 Dec 2018 11:01:40 +0000 (11:01 +0000)
commit3a719dd8229f9907a5dfe59485f7165e48725ecb
tree835da52f35a4d478af3b28e734d66421628e3090
parenta4b7e02dc99851e86213ae6f356364ab17edf1d6
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>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit e75c869785d09e6a2b1eb8dbe47cca868fb86105)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
C4/Circulation.pm