Bug 38457 - Add additional fields support to debit types
Summary: Add additional fields support to debit types
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Fines and fees (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Laura Escamilla
URL:
Keywords:
Depends on: 13985 38663
Blocks: 39177
  Show dependency treegraph
 
Reported: 2024-11-15 14:24 UTC by Hannah Dunne-Howrie
Modified: 2025-05-26 15:09 UTC (History)
10 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
**Summary:** Debit types were previously limited in customization, restricting the ability to store extra metadata. **Enhancement:** Additional fields can now be configured for debit types, allowing storage of custom financial codes or reporting data. **Impact:** Improves flexibility for libraries with advanced accounting or reporting requirements.
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 38457: DBIC Add AdditionalFields to AccountDebitType (1.29 KB, patch)
2024-12-17 16:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit types (6.24 KB, patch)
2024-12-17 16:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit display (3.84 KB, patch)
2024-12-17 17:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: DBIC Add AdditionalFields to AccountDebitType (1.34 KB, patch)
2025-01-20 11:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit types (6.29 KB, patch)
2025-01-20 11:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit display (3.90 KB, patch)
2025-01-20 11:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: DBIC Add AdditionalFields to AccountDebitType (1.54 KB, patch)
2025-02-20 12:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit types (48.75 KB, patch)
2025-02-20 12:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit display (33.32 KB, patch)
2025-02-20 12:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Update record_id to VARCHAR(80) (1.91 KB, patch)
2025-02-20 12:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: DBIC Schema (1.48 KB, patch)
2025-02-20 12:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: DBIC Add AdditionalFields to AccountDebitType (1.54 KB, patch)
2025-04-03 12:13 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit types (34.59 KB, patch)
2025-04-03 12:13 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit display (31.92 KB, patch)
2025-04-03 12:13 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Update record_id to VARCHAR(80) (1.91 KB, patch)
2025-04-03 12:13 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: DBIC Schema (1.05 KB, patch)
2025-04-03 12:13 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: DBIC Add AdditionalFields to AccountDebitType (1.61 KB, patch)
2025-04-03 13:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit types (34.65 KB, patch)
2025-04-03 13:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit display (31.98 KB, patch)
2025-04-03 13:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 38457: Update record_id to VARCHAR(80) (1.97 KB, patch)
2025-04-03 13:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 38457: DBIC Schema (1.11 KB, patch)
2025-04-03 13:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 38457: DBIC Add AdditionalFields to AccountDebitType (1.54 KB, patch)
2025-05-13 16:06 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit types (6.70 KB, patch)
2025-05-13 16:06 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Add additional fields to debit display (3.80 KB, patch)
2025-05-13 16:06 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: Update record_id to VARCHAR(80) (2.06 KB, patch)
2025-05-13 16:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: DBIC Schema (1.25 KB, patch)
2025-05-13 16:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38457: (follow-up) Update record_id to VARCHAR(80) (1.04 KB, patch)
2025-05-19 07:34 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Hannah Dunne-Howrie 2024-11-15 14:24:39 UTC
Problem - 
Any external finance systems have separate codes that may not align 1:1 with debit type lines. For example, a library might have a retail offer with 50 item lines but these products may align to 10 finance codes. This means it is time consuming/impossible for staff during finance reporting to match up finance codes with item lines from Koha reports. 

Proposed solution - 
An additional field within debit types would allow us to add in these finance codes and create reports based on takings by these codes (as opposed to each individual debit type line.
Comment 1 Martin Renvoize (ashimema) 2024-11-20 12:35:55 UTC
We're going to take this on within PTFS Europe, it's on my list to assign it out to the team today and schedule it very early in the next community cycle (i.e. coding to take place before xmas)
Comment 2 Martin Renvoize (ashimema) 2024-12-17 16:43:07 UTC Comment hidden (obsolete)
Comment 3 Martin Renvoize (ashimema) 2024-12-17 16:43:09 UTC
Created attachment 175631 [details] [review]
Bug 38457: Add additional fields to debit types

Test plan, k-t-d:
1) Before defining any additional fields for account_debit_types,
   confirm that the 'Additional fields' section does not appear when
   attempting to add a new or edit an existing debit type.
2) Add a new additional field to 'account_debit_types':
   <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=account_debit_types
3) Click 'New field'. Add a name. Click Save.
4) Repeat step 2 but repeatable. Repeat again for 2 more of AV category
   (one repeatable, one not repeatable)
5) Edit an account debit type:
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL
6) Input various values in the different additional fields. Click
   'Submit'
7) Edit the same debit type again and note the additional fields added
   in the previous step are visible
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL
Comment 4 Martin Renvoize (ashimema) 2024-12-17 17:07:21 UTC Comment hidden (obsolete)
Comment 5 Martin Renvoize (ashimema) 2024-12-19 16:08:56 UTC
Add additional fields to
Comment 6 Martin Renvoize (ashimema) 2025-01-20 11:31:45 UTC Comment hidden (obsolete)
Comment 7 Martin Renvoize (ashimema) 2025-01-20 11:31:47 UTC Comment hidden (obsolete)
Comment 8 Martin Renvoize (ashimema) 2025-01-20 11:31:50 UTC Comment hidden (obsolete)
Comment 9 Martin Renvoize (ashimema) 2025-01-20 11:33:44 UTC
Added sponsorship lines and this is about to get pushed to a site we're implementing right now so should be signed off soon.
Comment 10 Martin Renvoize (ashimema) 2025-02-20 12:07:23 UTC Comment hidden (obsolete)
Comment 11 Martin Renvoize (ashimema) 2025-02-20 12:07:26 UTC Comment hidden (obsolete)
Comment 12 Martin Renvoize (ashimema) 2025-02-20 12:07:29 UTC Comment hidden (obsolete)
Comment 13 Martin Renvoize (ashimema) 2025-02-20 12:07:32 UTC Comment hidden (obsolete)
Comment 14 Martin Renvoize (ashimema) 2025-02-20 12:07:34 UTC Comment hidden (obsolete)
Comment 15 Anneli Österman 2025-02-28 12:55:26 UTC
I tried to test this on PTFS Europe's sandbox but account_debit_types table does not come visible in Additional fields page and if I use the direct address <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=account_debit_types you can add a field but it does not show in Debit types page.

Is it possible to test this on sandbox?
Comment 16 Martin Renvoize (ashimema) 2025-03-04 17:30:14 UTC
Hmm.. I would think this is testable via sandboxes.. I'm just confirming that now myself.

We have deployed this, backported to 24.11.x, to a customer site who are going live in the next month and it's working well there currently.

I'll report back
Comment 17 Martin Renvoize (ashimema) 2025-03-04 17:38:22 UTC
OK.. for me at least it looks like sha1 application issues.. i.e the patches never actually applied to the sandbox.  That's good in so much as it doesn't point to an issue with the patchset here but it does show one of the challenges with the sandboxes output.. they don't report failures to apply patches properly unless you know what to look for in the logs.
Comment 18 Laura Escamilla 2025-04-01 12:33:53 UTC
patch isn't applying cleanly in k-t-d either

Applying: Bug 38457: Add additional fields to debit types
error: sha1 information is lacking or useless (koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt).
error: could not build fake ancestor
Patch failed at 0001 Bug 38457: Add additional fields to debit types
Comment 19 Martin Renvoize (ashimema) 2025-04-03 12:13:04 UTC
Created attachment 180494 [details] [review]
Bug 38457: DBIC Add AdditionalFields to AccountDebitType

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Comment 20 Martin Renvoize (ashimema) 2025-04-03 12:13:07 UTC
Created attachment 180495 [details] [review]
Bug 38457: Add additional fields to debit types

Test plan, k-t-d:
1) Before defining any additional fields for account_debit_types,
   confirm that the 'Additional fields' section does not appear when
   attempting to add a new or edit an existing debit type.
2) Add a new additional field to 'account_debit_types':
   <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=account_debit_types
3) Click 'New field'. Add a name. Click Save.
4) Repeat step 2 but repeatable. Repeat again for 2 more of AV category
   (one repeatable, one not repeatable)
5) Edit an account debit type:
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL
6) Input various values in the different additional fields. Click
   'Submit'
7) Edit the same debit type again and note the additional fields added
   in the previous step are visible
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Comment 21 Martin Renvoize (ashimema) 2025-04-03 12:13:11 UTC
Created attachment 180496 [details] [review]
Bug 38457: Add additional fields to debit display

This patch adds the previously added additional fields to the display
in the debit types management page table

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Comment 22 Martin Renvoize (ashimema) 2025-04-03 12:13:14 UTC
Created attachment 180497 [details] [review]
Bug 38457: Update record_id to VARCHAR(80)

This is required to allow for long primary keys from the
account_debit_types table.
Comment 23 Martin Renvoize (ashimema) 2025-04-03 12:13:18 UTC
Created attachment 180498 [details] [review]
Bug 38457: DBIC Schema
Comment 24 Laura Escamilla 2025-04-03 13:12:07 UTC
Created attachment 180519 [details] [review]
Bug 38457: DBIC Add AdditionalFields to AccountDebitType

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 25 Laura Escamilla 2025-04-03 13:12:13 UTC
Created attachment 180520 [details] [review]
Bug 38457: Add additional fields to debit types

Test plan, k-t-d:
1) Before defining any additional fields for account_debit_types,
   confirm that the 'Additional fields' section does not appear when
   attempting to add a new or edit an existing debit type.
2) Add a new additional field to 'account_debit_types':
   <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=account_debit_types
3) Click 'New field'. Add a name. Click Save.
4) Repeat step 2 but repeatable. Repeat again for 2 more of AV category
   (one repeatable, one not repeatable)
5) Edit an account debit type:
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL
6) Input various values in the different additional fields. Click
   'Submit'
7) Edit the same debit type again and note the additional fields added
   in the previous step are visible
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 26 Laura Escamilla 2025-04-03 13:12:17 UTC
Created attachment 180521 [details] [review]
Bug 38457: Add additional fields to debit display

This patch adds the previously added additional fields to the display
in the debit types management page table

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 27 Laura Escamilla 2025-04-03 13:12:20 UTC
Created attachment 180522 [details] [review]
Bug 38457: Update record_id to VARCHAR(80)

This is required to allow for long primary keys from the
account_debit_types table.

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 28 Laura Escamilla 2025-04-03 13:12:23 UTC
Created attachment 180523 [details] [review]
Bug 38457: DBIC Schema

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 29 Anneli Österman 2025-04-04 10:41:11 UTC
I'm not sure if this was testable in sandbox but I tested this in a Bywater's sandbox. Some notes:

* A new additional field can be added on that page.

* If I try to edit a existing debit type I get an error: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'me.record_id' in 'on clause' at /kohadevbox/koha/Koha/Objects.pm line 319
 at /usr/share/perl5/DBIx/Class/Exception.pm line 77

* If I add a new debit type, the newly added additional field is visible and can be added/selected but when I save the debit type I get an error message"An error occurred when saving this debit type. Check the logs for details.." The debit type is still added.

* If I try to edit the new debit type, I get the same error as with editing existing debit type:
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'me.record_id' in 'on clause' at /kohadevbox/koha/Koha/Objects.pm line 319
 at /usr/share/perl5/DBIx/Class/Exception.pm line 77
Comment 30 Lucas Gass (lukeg) 2025-04-29 15:52:23 UTC
Looks like there are a couple small rebases needed here.
Comment 31 Martin Renvoize (ashimema) 2025-05-13 16:06:50 UTC
Created attachment 182384 [details] [review]
Bug 38457: DBIC Add AdditionalFields to AccountDebitType

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 32 Martin Renvoize (ashimema) 2025-05-13 16:06:54 UTC
Created attachment 182385 [details] [review]
Bug 38457: Add additional fields to debit types

Test plan, k-t-d:
1) Before defining any additional fields for account_debit_types,
   confirm that the 'Additional fields' section does not appear when
   attempting to add a new or edit an existing debit type.
2) Add a new additional field to 'account_debit_types':
   <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=account_debit_types
3) Click 'New field'. Add a name. Click Save.
4) Repeat step 2 but repeatable. Repeat again for 2 more of AV category
   (one repeatable, one not repeatable)
5) Edit an account debit type:
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL
6) Input various values in the different additional fields. Click
   'Submit'
7) Edit the same debit type again and note the additional fields added
   in the previous step are visible
   <staff_url>/cgi-bin/koha/admin/debit_types.pl?op=add_form&code=MANUAL

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 33 Martin Renvoize (ashimema) 2025-05-13 16:06:58 UTC
Created attachment 182386 [details] [review]
Bug 38457: Add additional fields to debit display

This patch adds the previously added additional fields to the display
in the debit types management page table

Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 34 Martin Renvoize (ashimema) 2025-05-13 16:07:03 UTC
Created attachment 182387 [details] [review]
Bug 38457: Update record_id to VARCHAR(80)

This is required to allow for long primary keys from the
account_debit_types table.

Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 35 Martin Renvoize (ashimema) 2025-05-13 16:07:07 UTC
Created attachment 182388 [details] [review]
Bug 38457: DBIC Schema

Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 36 Martin Renvoize (ashimema) 2025-05-13 16:08:07 UTC
That was an interesting rebase.. the auto tidy stuff had royally screwed up the intermediary patches

Anywho.. rebased now and restoring status of the bug to PQA as it's had Hannah signoff and Laura QA
Comment 37 Katrin Fischer 2025-05-15 07:02:25 UTC
Please use "say_success" :)
+        say $out "Converted record_id to VARCHAR(80)";

This appears pretty contained to the configuration page for now. I'd be interested in some use cases/best practice for documentation and when demoing this.
Comment 38 Katrin Fischer 2025-05-15 07:21:35 UTC
Pushed for 25.05!

Well done everyone, thank you!
Comment 39 Katrin Fischer 2025-05-15 08:01:56 UTC
Hm, something is not quite right here, but I am not spotting it right now, can you please take a look?

https://jenkins.koha-community.org/job/Koha_Main_MariaDB_update/155/console
Comment 40 Jonathan Druart 2025-05-19 07:34:22 UTC
Created attachment 182575 [details] [review]
Bug 38457: (follow-up) Update record_id to VARCHAR(80)