Bug 28663 - One should not be able to apply a discount to a VOID accountline
Summary: One should not be able to apply a discount to a VOID accountline
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Fines and fees (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Martin Renvoize
QA Contact: Testopia
URL:
Keywords:
Depends on: 27971
Blocks: 13985
  Show dependency treegraph
 
Reported: 2021-07-05 18:29 UTC by Martin Renvoize
Modified: 2022-03-21 00:14 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This removes the display of the 'Apply discount' button for VOID transactions.
Version(s) released in:
22.05.00,21.11.04,21.05.13


Attachments
Bug 28663: Prevent discounts against void lines (2.39 KB, patch)
2021-07-05 18:40 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 28663 - Screenshot (59.27 KB, image/png)
2021-11-10 19:45 UTC, David Nind
Details
Bug 28663: Prevent discounts against void lines (2.42 KB, patch)
2021-11-11 12:18 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 28663: Prevent discounts against void lines (2.47 KB, patch)
2022-02-17 21:40 UTC, Michal Denar
Details | Diff | Splinter Review
Bug 28663: Prevent discounts against void lines (2.53 KB, patch)
2022-02-20 17:19 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize 2021-07-05 18:29:32 UTC
When adding the VOID account line type in bug 27971 I neglected to update the logic for the display of the 'Apply discount' button on the patron transactions page.
Comment 1 Martin Renvoize 2021-07-05 18:40:27 UTC
Created attachment 122588 [details] [review]
Bug 28663: Prevent discounts against void lines

With the introduction of double entry accounting for VOID actions, we
need to add an additional filter to the 'Apply discount' button appearance

Test plan
1/ Add a debt
2/ Pay the debt
3/ Void the payment
4/ Confirm that with the patch applied the 'Apply discount' button does
not appear on the 'Void' accountline.
Comment 2 David Nind 2021-11-10 19:45:23 UTC
Created attachment 127519 [details]
Bug 28663 - Screenshot

For me (see screenshot) there is no apply discount button for the void transaction.

Also, the patch doesn't apply 8-(..

Applying: Bug 28663: Prevent discounts against void lines
Using index info to reconstruct a base tree...
M	koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
error: Failed to merge in the changes.
Patch failed at 0001 Bug 28663: Prevent discounts against void lines
Comment 3 Martin Renvoize 2021-11-11 12:18:11 UTC
Created attachment 127538 [details] [review]
Bug 28663: Prevent discounts against void lines

With the introduction of double entry accounting for VOID actions, we
need to add an additional filter to the 'Apply discount' button appearance

Test plan
1/ Add a debt
2/ Pay the debt
3/ Void the payment
4/ Confirm that with the patch applied the 'Apply discount' button does
not appear on the 'Void' accountline.
Comment 4 Martin Renvoize 2021-11-11 12:21:41 UTC
The logic is currently:

CAN_user_updatecharges_discount && account.is_debit && ( account.amountoutstanding == account.amount ) && !(account.debit_type_code == 'PAYOUT')

But a void is pretty much always applied immediately so the `account.amountoutstanding == account.amount` sohuldn't ever pass..  I have a feeling when I wrote this that there was a particular way to end up with it showing.. like a series of actions that would partially undo the void.. maybe now.

I've rebased anyway.. but maybe leave this one for now.. marking back to minor.
Comment 5 Michal Denar 2022-02-17 21:40:07 UTC
Created attachment 130772 [details] [review]
Bug 28663: Prevent discounts against void lines

With the introduction of double entry accounting for VOID actions, we
need to add an additional filter to the 'Apply discount' button appearance

Test plan
1/ Add a debt
2/ Pay the debt
3/ Void the payment
4/ Confirm that with the patch applied the 'Apply discount' button does
not appear on the 'Void' accountline.

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 6 Jonathan Druart 2022-02-18 15:27:45 UTC
Should this be enforced at lower (Koha:: module) level as well?
Comment 7 Katrin Fischer 2022-02-20 17:19:42 UTC
Created attachment 130927 [details] [review]
Bug 28663: Prevent discounts against void lines

With the introduction of double entry accounting for VOID actions, we
need to add an additional filter to the 'Apply discount' button appearance

Test plan
1/ Add a debt
2/ Pay the debt
3/ Void the payment
4/ Confirm that with the patch applied the 'Apply discount' button does
not appear on the 'Void' accountline.

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Katrin Fischer 2022-02-20 17:23:19 UTC
(In reply to Jonathan Druart from comment #6)
> Should this be enforced at lower (Koha:: module) level as well?

I believe this is a good first fix, but I am with you on that one as well. Keeping APIs etc in mind, we also should have a check on module level. Could/should we move it to a separate bug?
Comment 9 Fridolin Somers 2022-03-02 08:48:33 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 10 Kyle M Hall 2022-03-04 13:07:19 UTC
Pushed to 21.11.x for 21.11.04
Comment 11 Andrew Fuerste-Henry 2022-03-20 14:55:19 UTC
Pushed to 21.05.x for 21.05.13
Comment 12 Victor Grousset/tuxayo 2022-03-21 00:14:46 UTC
Not backported to oldoldstable (20.11.x). Feel free to ask if it's needed.