Bug 24081 - Add a 'discount' process to accounts
Summary: Add a 'discount' process to accounts
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: Fines and fees (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Martin Renvoize
QA Contact: Testopia
URL:
Keywords:
Depends on: 23442
Blocks: 24812 24821 24822 24849 26541
  Show dependency treegraph
 
Reported: 2019-11-21 11:17 UTC by Martin Renvoize
Modified: 2020-09-28 13:14 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Allows to specify and apply a discount on a patron's charges. Staff will require the new permission 'discount' to use this new functionality.
Version(s) released in:
20.05.00


Attachments
Bug 24081: Add credit_types, offset_types and permissions (3.56 KB, patch)
2020-01-09 14:22 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add DISCOUNT to the allowed 'reduce' types (1.35 KB, patch)
2020-01-09 14:22 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add credit_types, offset_types and permissions (3.59 KB, patch)
2020-03-03 19:24 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add DISCOUNT to the allowed 'reduce' types (1.35 KB, patch)
2020-03-03 19:24 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add discount action to boraccount (8.32 KB, patch)
2020-03-03 19:24 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add credit_types, offset_types and permissions (3.66 KB, patch)
2020-03-03 20:32 UTC, Michal Denar
Details | Diff | Splinter Review
Bug 24081: Add DISCOUNT to the allowed 'reduce' types (1.39 KB, patch)
2020-03-03 20:32 UTC, Michal Denar
Details | Diff | Splinter Review
Bug 24081: Add discount action to boraccount (8.37 KB, patch)
2020-03-03 20:32 UTC, Michal Denar
Details | Diff | Splinter Review
Bug 24081: Add credit_types, offset_types and permissions (3.64 KB, patch)
2020-03-04 08:36 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add DISCOUNT to the allowed 'reduce' types (1.39 KB, patch)
2020-03-04 08:36 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add discount action to boraccount (8.94 KB, patch)
2020-03-04 08:36 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add credit_types, offset_types and permissions (3.64 KB, patch)
2020-03-04 08:49 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add DISCOUNT to the allowed 'reduce' types (1.54 KB, patch)
2020-03-04 08:49 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add discount action to boraccount (8.94 KB, patch)
2020-03-04 08:49 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24081: Add credit_types, offset_types and permissions (3.69 KB, patch)
2020-03-04 13:40 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24081: Add DISCOUNT to the allowed 'reduce' types (1.59 KB, patch)
2020-03-04 13:40 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24081: Add discount action to boraccount (9.00 KB, patch)
2020-03-04 13:40 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24081: (QA follow-up) Fix small typo (793 bytes, patch)
2020-03-04 13:41 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize 2019-11-21 11:17:56 UTC
There are times when a staff member wishes to record and apply to a fine on a patrons account. We should add a formal method/workflow for this requirement.
Comment 1 Martin Renvoize 2020-01-09 14:22:39 UTC
Created attachment 97090 [details] [review]
Bug 24081: Add credit_types, offset_types and permissions

This patch adds the credit_type, offset_type and permissions required
for the addition of a discounting workflow in the accounts system.
Comment 2 Martin Renvoize 2020-01-09 14:22:43 UTC
Created attachment 97091 [details] [review]
Bug 24081: Add DISCOUNT to the allowed 'reduce' types

This patch adds the DISCOUNT type to the handled types list in the
reduce method introduced in bug 23442
Comment 3 Martin Renvoize 2020-03-03 19:24:29 UTC
Created attachment 100044 [details] [review]
Bug 24081: Add credit_types, offset_types and permissions

This patch adds the credit_type, offset_type and permissions required
for the addition of a discounting workflow in the accounts system.
Comment 4 Martin Renvoize 2020-03-03 19:24:32 UTC
Created attachment 100045 [details] [review]
Bug 24081: Add DISCOUNT to the allowed 'reduce' types

This patch adds the DISCOUNT type to the handled types list in the
reduce method introduced in bug 23442
Comment 5 Martin Renvoize 2020-03-03 19:24:35 UTC
Created attachment 100046 [details] [review]
Bug 24081: Add discount action to boraccount

This patch adds the ability to apply discounts to existing patron
charges from the boraccount page.

Test plan
Comment 6 Michal Denar 2020-03-03 20:09:28 UTC
Hi Martin,
test plan? :-)
Comment 7 Michal Denar 2020-03-03 20:30:53 UTC
Test plan:

-create manual invoice
- go to Transaction a here is new button Appla discount, click
- in modal, set discount and confirm
- check if amount to pay is lower (minus discount)
- pay amount
Comment 8 Michal Denar 2020-03-03 20:32:08 UTC
Created attachment 100074 [details] [review]
Bug 24081: Add credit_types, offset_types and permissions

This patch adds the credit_type, offset_type and permissions required
for the addition of a discounting workflow in the accounts system.

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 9 Michal Denar 2020-03-03 20:32:11 UTC
Created attachment 100075 [details] [review]
Bug 24081: Add DISCOUNT to the allowed 'reduce' types

This patch adds the DISCOUNT type to the handled types list in the
reduce method introduced in bug 23442

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 10 Michal Denar 2020-03-03 20:32:15 UTC
Created attachment 100076 [details] [review]
Bug 24081: Add discount action to boraccount

This patch adds the ability to apply discounts to existing patron
charges from the boraccount page.

Test plan

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 11 Michal Denar 2020-03-03 20:38:23 UTC
Hi,
I really like this feature. It's works. But itsn't "user friendly". I prefer to apply discout directly at "Pay an amount toward all fines" or "Pay an individual fine" window. 

Thank you for opinions.
Comment 12 Martin Renvoize 2020-03-04 07:49:54 UTC
(In reply to Michal Denar from comment #11)
> Hi,
> I really like this feature. It's works. But itsn't "user friendly". I prefer
> to apply discout directly at "Pay an amount toward all fines" or "Pay an
> individual fine" window. 
> 
> Thank you for opinions.

Thanks for the quick testing, and my apologies for the lack of test plan.. seems I forgot to paste it into the commit message after drafting it.. oops.

As for the feedback, that's great. I wanted to get the foundation in with this bug and then build on top of them.  I'll open some further bugs with your idea's as their foundation, as I have done for Tomas when he QA'd the parallel 'Refund' bug requesting similar options.

I also intend to migrate some of the existing automated discounting functionality to using this model of record for auditability which has been sorely missed in the past.

Thanks again,
Comment 13 Martin Renvoize 2020-03-04 08:36:14 UTC
Created attachment 100084 [details] [review]
Bug 24081: Add credit_types, offset_types and permissions

This patch adds the credit_type, offset_type and permissions required
for the addition of a discounting workflow in the accounts system.

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 14 Martin Renvoize 2020-03-04 08:36:17 UTC
Created attachment 100085 [details] [review]
Bug 24081: Add DISCOUNT to the allowed 'reduce' types

This patch adds the DISCOUNT type to the handled types list in the
reduce method introduced in bug 23442

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 15 Martin Renvoize 2020-03-04 08:36:20 UTC
Created attachment 100086 [details] [review]
Bug 24081: Add discount action to boraccount

This patch adds the ability to apply discounts to existing patron
charges from the boraccount page.

Test plan
1/ Carry out some accounting actions that end up with debts on the
patron record. (Add a manual invoice for example)
2/ Note a new 'Apply discount' action button on the unpaid debt
3/ Paid debts do not display the action button
4/ Click the button
5/ Enter an amount into the resulting modal and click confirm
6/ Confirm that the outstanding debt has been reduced by the amount you
specified.
7/ Confirm that a new 'Discount' line appears on the patrons account
8/ Confirm that in the 'details' view of the debt that the discount line
was used against the debt to create the reduction.
9/ Signoff

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 16 Martin Renvoize 2020-03-04 08:49:26 UTC
Created attachment 100087 [details] [review]
Bug 24081: Add credit_types, offset_types and permissions

This patch adds the credit_type, offset_type and permissions required
for the addition of a discounting workflow in the accounts system.

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 17 Martin Renvoize 2020-03-04 08:49:29 UTC
Created attachment 100088 [details] [review]
Bug 24081: Add DISCOUNT to the allowed 'reduce' types

This patch adds the DISCOUNT type to the handled types list in the
reduce method introduced in bug 23442

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 18 Martin Renvoize 2020-03-04 08:49:32 UTC
Created attachment 100089 [details] [review]
Bug 24081: Add discount action to boraccount

This patch adds the ability to apply discounts to existing patron
charges from the boraccount page.

Test plan
1/ Carry out some accounting actions that end up with debts on the
patron record. (Add a manual invoice for example)
2/ Note a new 'Apply discount' action button on the unpaid debt
3/ Paid debts do not display the action button
4/ Click the button
5/ Enter an amount into the resulting modal and click confirm
6/ Confirm that the outstanding debt has been reduced by the amount you
specified.
7/ Confirm that a new 'Discount' line appears on the patrons account
8/ Confirm that in the 'details' view of the debt that the discount line
was used against the debt to create the reduction.
9/ Signoff

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 19 Tomás Cohen Arazi 2020-03-04 13:39:11 UTC
(In reply to Michal Denar from comment #11)
> Hi,
> I really like this feature. It's works. But itsn't "user friendly". I prefer
> to apply discout directly at "Pay an amount toward all fines" or "Pay an
> individual fine" window. 
> 
> Thank you for opinions.

I agree with you! I tried testing it without reading the test plan (following my intuition) as I saw your comment. And it felt like:
- Discount could be a percentage as well
- It should be cool to have it (also) on the Make payment flow

Anyway, good job and really clean implementation. I'm happy where the accounts code is now.
Comment 20 Tomás Cohen Arazi 2020-03-04 13:40:50 UTC
Created attachment 100111 [details] [review]
Bug 24081: Add credit_types, offset_types and permissions

This patch adds the credit_type, offset_type and permissions required
for the addition of a discounting workflow in the accounts system.

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 21 Tomás Cohen Arazi 2020-03-04 13:40:55 UTC
Created attachment 100112 [details] [review]
Bug 24081: Add DISCOUNT to the allowed 'reduce' types

This patch adds the DISCOUNT type to the handled types list in the
reduce method introduced in bug 23442

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 22 Tomás Cohen Arazi 2020-03-04 13:40:59 UTC
Created attachment 100113 [details] [review]
Bug 24081: Add discount action to boraccount

This patch adds the ability to apply discounts to existing patron
charges from the boraccount page.

Test plan
1/ Carry out some accounting actions that end up with debts on the
patron record. (Add a manual invoice for example)
2/ Note a new 'Apply discount' action button on the unpaid debt
3/ Paid debts do not display the action button
4/ Click the button
5/ Enter an amount into the resulting modal and click confirm
6/ Confirm that the outstanding debt has been reduced by the amount you
specified.
7/ Confirm that a new 'Discount' line appears on the patrons account
8/ Confirm that in the 'details' view of the debt that the discount line
was used against the debt to create the reduction.
9/ Signoff

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 23 Tomás Cohen Arazi 2020-03-04 13:41:03 UTC
Created attachment 100114 [details] [review]
Bug 24081: (QA follow-up) Fix small typo

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 24 Martin Renvoize 2020-03-04 14:54:28 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 25 Jonathan Druart 2020-03-10 13:04:11 UTC
% git grep updatecharges|grep discount
koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt:        [% IF CAN_user_updatecharges_discount && account.is_debit && ( account.amountoutstanding == account.amount ) && !(account.debit_type_code == 'PAYOUT') %]


There is no check on the discount subperm, only hide/show a button.
Without a test in the controller that can be forced.
Comment 26 Joy Nelson 2020-04-01 21:15:55 UTC
not pushed to 19.11.x due to dependencies