Bug 18786

Summary: Add ability to create custom payment types
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: CirculationAssignee: Kyle M Hall (khall) <kyle>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: amitddng135, black23, costalc, gmcharlt, jonathan.druart, josef.moravec, kohapatch, kyle.m.hall, martin.renvoize, mfuerst, tomascohen, veron
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12001
Change sponsored?: --- Patch complexity: Medium patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 14826    
Bug Blocks: 21791, 22872, 18790, 22610    
Attachments: Bug 18786 - Update database
Bug 18786 - Update schema
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Update database
Bug 18786 - Update schema
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Update database
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Update database
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Update database
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Update database
Bug 18786 - Add ability to create custom payment types
Bug 18786 - Update database
Bug 18786 - Add ability to create custom payment types
Bug 18786: Remove use of Koha::Patron::Images
Bug 18786: Remove use of Koha::Patron::Images
Bug 18786: Update database
Bug 18786: Add ability to create custom payment types
Bug 18786: Remove use of Koha::Patron::Images
Bug 18786: Add PAYMENT_TYPE to the AV categories
Bug 18786: Remove duplicate block with bad IF
Bug 18786: Add PAYMENT_TYPE to the installer file

Description Kyle M Hall (khall) 2017-06-12 12:30:46 UTC
Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.
Comment 1 Kyle M Hall (khall) 2017-06-12 14:30:41 UTC
Created attachment 64202 [details] [review]
Bug 18786 - Update database
Comment 2 Kyle M Hall (khall) 2017-06-12 14:30:49 UTC
Created attachment 64203 [details] [review]
Bug 18786 - Update schema
Comment 3 Kyle M Hall (khall) 2017-06-12 14:30:52 UTC
Created attachment 64204 [details] [review]
Bug 18786 - Add ability to create custom payment types
Comment 4 Marc Véron 2017-06-14 12:44:30 UTC
Test plan was missing.

I tested with following steps:
Following test is OK:

- Apply patches
- Update database
- Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
- Go to the fines section of a patron who has several fines
- Tab 'Fines'
- Click on 'Pay' for an individual fine
- Verified that in form  'Pay an individual fine' a dropdown appears with
  paxment types
- Selected a payment type, confirm payment
- Verify that payment type appears in "Description of charges" in tab 'Account'


Following is missing:
- Go to 'Fines' tab
- Use 'Pay amount' or 'Pay selected' for payment
Fail: There is no dropdown list with payment types
Comment 5 Kyle M Hall (khall) 2017-06-14 15:02:12 UTC
Ack! Thanks for the test plan! I'll get the patch set fixed up asap!

(In reply to Marc Véron from comment #4)
> Test plan was missing.
> 
> I tested with following steps:
> Following test is OK:
> 
> - Apply patches
> - Update database
> - Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit
> card'
> - Go to the fines section of a patron who has several fines
> - Tab 'Fines'
> - Click on 'Pay' for an individual fine
> - Verified that in form  'Pay an individual fine' a dropdown appears with
>   paxment types
> - Selected a payment type, confirm payment
> - Verify that payment type appears in "Description of charges" in tab
> 'Account'
> 
> 
> Following is missing:
> - Go to 'Fines' tab
> - Use 'Pay amount' or 'Pay selected' for payment
> Fail: There is no dropdown list with payment types
Comment 6 Kyle M Hall (khall) 2017-06-14 15:05:26 UTC
Created attachment 64288 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'
Comment 7 Marc Véron 2017-06-14 20:27:34 UTC
Created attachment 64300 [details] [review]
Bug 18786 - Update database

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 8 Marc Véron 2017-06-14 20:28:20 UTC
Created attachment 64301 [details] [review]
Bug 18786 - Update schema

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 9 Marc Véron 2017-06-14 20:29:37 UTC
Created attachment 64302 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 10 Martha Fuerst 2017-08-22 16:33:18 UTC
Got the following error when trying to pay a lost item charge, but fine is gone from the account. No indication of payment on Account page or in account_offsets table.

Software error:

{UNKNOWN}: Can't call method "unblessed" on an undefined value at /var/lib/koha/hcpl/kohaclone/C4/Circulation.pm line 2178. at /var/lib/koha/hcpl/kohaclone/C4/Circulation.pm line 2198
For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error.

Everything else works fine.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types - YES (also appears with all "Pay")
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'
Comment 11 Tomás Cohen Arazi (tcohen) 2017-09-29 14:12:05 UTC
Please rebase.
Comment 12 Kyle M Hall (khall) 2017-09-29 15:25:58 UTC
Created attachment 67476 [details] [review]
Bug 18786 - Update database

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 13 Kyle M Hall (khall) 2017-09-29 15:26:05 UTC
Created attachment 67477 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 14 Kyle M Hall (khall) 2017-11-15 14:12:30 UTC
Created attachment 69155 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 15 Kyle M Hall (khall) 2017-11-15 14:12:55 UTC
Created attachment 69156 [details] [review]
Bug 18786 - Update database

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 16 Kyle M Hall (khall) 2017-11-15 14:13:06 UTC
Created attachment 69157 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 17 Katrin Fischer 2017-11-15 20:00:06 UTC
I think this is a duplicate of the older bug 5630 which is also signed off at the moment.

There was some discussion about using an authorised value there and because we already have a list of payment types used by SIP and translatability some hardcoded values were added. Maybe we could make it so that the list can be extended by an authorised value? (... and make authorised values translatable for display one day...)

Can we pick one implementation?
Comment 18 Josef Moravec 2017-12-08 07:32:29 UTC
(In reply to Katrin Fischer from comment #17)
> I think this is a duplicate of the older bug 5630 which is also signed off
> at the moment.

Katrin, which bug did you have in mind? This bug number is not related to account either.


> There was some discussion about using an authorised value there and because
> we already have a list of payment types used by SIP and translatability some
> hardcoded values were added. Maybe we could make it so that the list can be
> extended by an authorised value? (... and make authorised values
> translatable for display one day...)
> 
> Can we pick one implementation?

+1 ;)
Comment 19 Katrin Fischer 2017-12-08 09:31:39 UTC
Found it - it was bug 5620!
Comment 20 Kyle M Hall (khall) 2018-01-16 19:48:19 UTC
(In reply to Katrin Fischer from comment #19)
> Found it - it was bug 5620!

That bug doesn't do what this one does. That one is specifically about SIP payment types. Moreover, I see some issues with it since it hardcodes a bunch of payment type values that aren't specified by the SIP2 protocol : \

If this one gets pushed I'd be willing to assist in fixing up 5620.
Comment 21 Josef Moravec 2018-01-29 11:57:58 UTC
Created attachment 71020 [details] [review]
Bug 18786 - Update database

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 22 Josef Moravec 2018-01-29 11:58:03 UTC
Created attachment 71021 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 23 Josef Moravec 2018-01-29 12:02:03 UTC
I agree with you Kyle, better to not have more hardcoded values in Koha...

Passed QA, note for RM: on boraccount.pl, the payment type is not shown now, but should be fixed by bug 12001 I think, with GetMemberAccountRecords refactoring
Comment 24 Katrin Fischer 2018-01-29 17:16:04 UTC
What I am not sure about is the relation to the already existing SIP payment types - will both work together nicely for reports etc?
Comment 25 Kyle M Hall (khall) 2018-01-30 13:47:10 UTC
(In reply to Katrin Fischer from comment #24)
> What I am not sure about is the relation to the already existing SIP payment
> types - will both work together nicely for reports etc?

Yes they will!
Comment 26 Kyle M Hall (khall) 2018-02-21 11:22:55 UTC
Created attachment 72015 [details] [review]
Bug 18786 - Update database

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 27 Kyle M Hall (khall) 2018-02-21 11:23:02 UTC
Created attachment 72016 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 28 Kyle M Hall (khall) 2018-02-23 12:26:38 UTC
Created attachment 72114 [details] [review]
Bug 18786 - Update database

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 29 Kyle M Hall (khall) 2018-02-23 12:26:46 UTC
Created attachment 72115 [details] [review]
Bug 18786 - Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 30 Jonathan Druart 2018-02-27 17:21:56 UTC
We are going to add yet another AV that cannot be translatable.
Moreover this patch set does not create some default ones for existing or new installations.

I'd like to get more QA pov on that.
Comment 31 Jonathan Druart 2018-02-27 17:27:53 UTC
Cannot we try to be exhaustive and list all (or at least several to start) payment types in a separate table? We could have a FK at DB level and make them translatable.
Comment 32 Kyle M Hall (khall) 2018-02-27 17:53:42 UTC
(In reply to Jonathan Druart from comment #31)
> Cannot we try to be exhaustive and list all (or at least several to start)
> payment types in a separate table? We could have a FK at DB level and make
> them translatable.

These are not hard coded payment types, they are meant to be added by the librarians, just as we already use a AV category for librarian defined fee types.

Really, what we need is for authorised values to be translatable, but that's a bit outside the scope of this bug ; )

If you would like me to add an example payment type to the sample data, I'd be happy to do so!
Comment 33 Katrin Fischer 2018-02-27 18:40:35 UTC
As the payment types are ok as key value pairs and you wouldn't need more, I think having them as an authorised value is ok. But we should start to make AV translatable one by one (or all at once - wouldn't mind that!). It is the next logical step, especially for values exposed in the OPAC like location and collection.
Comment 34 Kyle M Hall (khall) 2018-02-27 19:05:10 UTC
Created attachment 72282 [details] [review]
Bug 18786: Remove use of Koha::Patron::Images
Comment 35 Josef Moravec 2018-04-04 12:45:23 UTC
Why did you added the cleaning of the code in C4/SIP/ILS.pm? 

It looks OK, but I think it's not related to this report.
Comment 36 Kyle M Hall (khall) 2018-04-04 13:47:38 UTC
Created attachment 73628 [details] [review]
Bug 18786: Remove use of Koha::Patron::Images
Comment 37 Kyle M Hall (khall) 2018-04-04 13:48:14 UTC
(In reply to Josef Moravec from comment #35)
> Why did you added the cleaning of the code in C4/SIP/ILS.pm? 
> 
> It looks OK, but I think it's not related to this report.

No idea how the snuck in. This new version of the followup should have that fixed!
Comment 38 Katrin Fischer 2018-04-10 06:26:37 UTC
Josef, do you have time to finish here?
Comment 39 Josef Moravec 2018-04-13 09:31:55 UTC
(In reply to Katrin Fischer from comment #38)
> Josef, do you have time to finish here?

Sorry, I missed this somehow, I'll take a look on this
Comment 40 Josef Moravec 2018-04-13 09:50:33 UTC
Created attachment 74147 [details] [review]
Bug 18786: Update database

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 41 Josef Moravec 2018-04-13 09:50:37 UTC
Created attachment 74148 [details] [review]
Bug 18786: Add ability to create custom payment types

Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE.

Test Plan:
1) Apply patches
2) Update database
3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card'
4) Go to the fines section of a patron who has several fines
5) Tab 'Fines'
6) Click on 'Pay' for an individual fine
7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types
8) Select a payment type, confirm payment
9) Verify that payment type appears in "Description of charges" in tab 'Account'

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 42 Josef Moravec 2018-04-13 09:50:41 UTC
Created attachment 74149 [details] [review]
Bug 18786: Remove use of Koha::Patron::Images

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 43 Jonathan Druart 2018-04-13 16:14:48 UTC
Hum, PQA, sure?

Template process failed: undef error - The method count is not covered by tests! at /home/vagrant/kohaclone/C4/Templates.pm line 122.
Comment 44 Jonathan Druart 2018-04-13 16:16:15 UTC
Created attachment 74172 [details] [review]
Bug 18786: Add PAYMENT_TYPE to the AV categories
Comment 45 Kyle M Hall (khall) 2018-04-13 17:17:28 UTC
(In reply to Jonathan Druart from comment #43)
> Hum, PQA, sure?
> 
> Template process failed: undef error - The method count is not covered by
> tests! at /home/vagrant/kohaclone/C4/Templates.pm line 122.

Why is this failed qa now? From this error? How do you generate it?
Comment 46 Jonathan Druart 2018-04-13 18:49:27 UTC
Just try to pay a fine.
Comment 47 Kyle M Hall (khall) 2018-04-13 19:05:51 UTC
(In reply to Jonathan Druart from comment #46)
> Just try to pay a fine.

Thanks! Probably due to a recent change to master.
Comment 48 Kyle M Hall (khall) 2018-04-18 12:12:54 UTC
(In reply to Jonathan Druart from comment #46)
> Just try to pay a fine.

I am completely unable to reproduce your error. Can you try again?
Comment 49 Jonathan Druart 2018-04-18 13:05:40 UTC
Did you create AVs for PAYMENT_TYPE?
Comment 50 Kyle M Hall (khall) 2018-04-18 13:32:50 UTC
(In reply to Jonathan Druart from comment #49)
> Did you create AVs for PAYMENT_TYPE?

Yes, I tested every payment option with and without PAYMENT_TYPEs. In both cases the av category itself existed.
Comment 51 Jonathan Druart 2018-04-18 14:07:14 UTC
Take a look at the patch, the problem is obvious: the [% IF payment_types %] is duplicated. One has a call to ->count, the others not.
Comment 52 Kyle M Hall (khall) 2018-04-18 14:24:33 UTC
(In reply to Jonathan Druart from comment #51)
> Take a look at the patch, the problem is obvious: the [% IF payment_types %]
> is duplicated. One has a call to ->count, the others not.

Ah, I *still* don't get an error, but that is clearly a duplicate block. I'll get that taken care of!
Comment 53 Kyle M Hall (khall) 2018-04-18 14:25:37 UTC
Created attachment 74436 [details] [review]
Bug 18786: Remove duplicate block with bad IF
Comment 54 Jonathan Druart 2018-04-19 15:42:26 UTC
Pushed to master for 18.05, thanks to everybody involved!
Comment 55 Jonathan Druart 2018-05-17 16:17:20 UTC
Created attachment 75401 [details] [review]
Bug 18786: Add PAYMENT_TYPE to the installer file
Comment 56 Jonathan Druart 2018-05-17 16:44:20 UTC
(In reply to Jonathan Druart from comment #55)
> Created attachment 75401 [details] [review] [review]
> Bug 18786: Add PAYMENT_TYPE to the installer file

Pushed to master for 18.05
Comment 57 Martin Renvoize (ashimema) 2019-03-29 16:35:20 UTC
*** Bug 5620 has been marked as a duplicate of this bug. ***