Bug 41553 - Add fund code to the fund dropdown list when adding an item to an order (neworderempty.pl)
Summary: Add fund code to the fund dropdown list when adding an item to an order (newo...
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Kyle M Hall (khall)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 13944
  Show dependency treegraph
 
Reported: 2026-01-08 19:08 UTC by Kyle M Hall (khall)
Modified: 2026-02-14 03:46 UTC (History)
3 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement adds a system preference to control how funds are displayed when entering a new order in acquisitions. Using the new system preference OrderLineFundInfo, you can choose to show just the fund name (current behavior), the fund code, or both values. When both values are displayed, the fund code is displayed in parentheses after the fund name.
Version(s) released in:
Circulation function:


Attachments
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl ) (3.66 KB, patch)
2026-01-08 19:28 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl ) (3.10 KB, patch)
2026-01-08 19:30 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl ) (3.13 KB, patch)
2026-02-07 21:54 UTC, David Nind
Details | Diff | Splinter Review
Bug 41553: Add new syspref OrderLineFundInfo (6.88 KB, patch)
2026-02-09 18:24 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41553: Add new syspref OrderLineFundInfo (6.90 KB, patch)
2026-02-09 18:26 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl ) (3.17 KB, patch)
2026-02-13 20:40 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 41553: Add new syspref OrderLineFundInfo (6.93 KB, patch)
2026-02-13 20:40 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall (khall) 2026-01-08 19:08:01 UTC
It's possible to give multiple funds the same name. It would be helpful to have the fund code in the pulldown options to help disambiguate these funds.
Comment 1 Kyle M Hall (khall) 2026-01-08 19:28:16 UTC
Created attachment 191035 [details] [review]
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl )

It's possible to give multiple funds the same name. It would be helpful to have the fund code in the pulldown options to help disambiguate these funds.

In addition, spans with classes have been added to both the fund name and the fund code for ease of styling.

Test Plan:
1) Create 2 funds with the same name and different fund codes
2) Apply this patch
3) Restart all the things!
4) Create a new order, note the fund code is displayed after the fund name
Comment 2 Kyle M Hall (khall) 2026-01-08 19:30:44 UTC
Created attachment 191036 [details] [review]
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl )

It's possible to give multiple funds the same name. It would be helpful to have the fund code in the pulldown options to help disambiguate these funds.

In addition, spans with classes have been added to both the fund name and the fund code for ease of styling.

Test Plan:
1) Create 2 funds with the same name and different fund codes
2) Apply this patch
3) Restart all the things!
4) Create a new order, note the fund code is displayed after the fund name
Comment 3 Katrin Fischer 2026-01-12 17:47:15 UTC
I feel like this change adds some inconsistency to the display, as only the fund menu on creating new orders is changed. Also: I know some libraries already add the fund code to the description if needed, so that would create a doubled up display for them.

Can you explain why updating the description is not an option here? 

Wouldn't it be better to add the budget to the view, as fund code and fund description could still likely be the same across multiple budget years?
Comment 4 Katrin Fischer 2026-01-19 11:11:22 UTC
Maybe a solution along the lines of bug 21098? This would add more consistency and might also solve the use case.
Comment 5 David Cook 2026-01-19 22:13:27 UTC
(In reply to Katrin Fischer from comment #4)
> Maybe a solution along the lines of bug 21098? This would add more
> consistency and might also solve the use case.

Yeah I reckon bug 21098 would be the way to go
Comment 6 Kyle M Hall (khall) 2026-01-28 14:24:47 UTC
(In reply to David Cook from comment #5)
> (In reply to Katrin Fischer from comment #4)
> > Maybe a solution along the lines of bug 21098? This would add more
> > consistency and might also solve the use case.
> 
> Yeah I reckon bug 21098 would be the way to go

Are you saying to implement optgroups to group funds by budget? I don't believe this would actually solve this problem, as one could still have to funds under a single budget with the same name.
Comment 7 Andrew Fuerste-Henry 2026-02-06 16:41:23 UTC
I agree that the changes described in Bug 21098 don't seem to address the issue here.

In discussing this issue with a library today, they expressed their desire to see *only* the fund code when entering a new order. Coupled with Katrin's point about libraries who would find it redundant to see both values, this suggests we need a configuration option asking whether to show the code, the description, or both.

Additionally, it might make sense to apply whatever changes we make here to the fund dropdown in the receiving modal as well. Perhaps that's another bug.
Comment 8 Andrew Fuerste-Henry 2026-02-06 17:17:00 UTC
(In reply to Andrew Fuerste-Henry from comment #7)
> In discussing this issue with a library today, they expressed their desire
> to see *only* the fund code when entering a new order. Coupled with Katrin's
> point about libraries who would find it redundant to see both values, this
> suggests we need a configuration option asking whether to show the code, the
> description, or both.

It's been pointed out to me that Kyle gave the code and description distinct classes, so either can be easily hidden with CSS. To my mind, that sidesteps this issue.
Comment 9 David Nind 2026-02-07 21:54:34 UTC
Created attachment 192683 [details] [review]
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl )

It's possible to give multiple funds the same name. It would be helpful to have the fund code in the pulldown options to help disambiguate these funds.

In addition, spans with classes have been added to both the fund name and the fund code for ease of styling.

Test Plan:
1) Create 2 funds with the same name and different fund codes
2) Apply this patch
3) Restart all the things!
4) Create a new order, note the fund code is displayed after the fund name

Signed-off-by: David Nind <david@davidnind.com>
Comment 10 David Nind 2026-02-07 21:59:33 UTC
I've signed ff.

However, I'm not sure if all the issues raised in the comments need addressing, or are resolved.
Comment 11 Andrew Fuerste-Henry 2026-02-09 13:13:33 UTC
(In reply to Andrew Fuerste-Henry from comment #8)
> It's been pointed out to me that Kyle gave the code and description distinct
> classes, so either can be easily hidden with CSS. To my mind, that sidesteps
> this issue.

I posted this based on the code, without looking at the actual interface. Turns out the use of select2 strips the html out of the menu options so these don't have distinct classes after all. For that reason, I'm kicking this to FQA. This needs at least a way to preserve current behavior of showing only the fund name, if not also a way to show only the code.

Preliminary googling suggests that select2 templating can allow html within the options list, allowing the fund and code to have classes and be hidden/shown via CSS.

A note on Kyle's existing code here, he's got the fund code in parentheses, with the parentheses also within the .budget_code class. That'd mean if one hid the .budget_name the resulting list would be all codes in parens, which is not ideal. We should avoid that.
Comment 12 Kyle M Hall (khall) 2026-02-09 13:29:52 UTC
(In reply to Andrew Fuerste-Henry from comment #11)
> (In reply to Andrew Fuerste-Henry from comment #8)
> > It's been pointed out to me that Kyle gave the code and description distinct
> > classes, so either can be easily hidden with CSS. To my mind, that sidesteps
> > this issue.
> 
> I posted this based on the code, without looking at the actual interface.
> Turns out the use of select2 strips the html out of the menu options so
> these don't have distinct classes after all. For that reason, I'm kicking
> this to FQA. This needs at least a way to preserve current behavior of
> showing only the fund name, if not also a way to show only the code.
> 
> Preliminary googling suggests that select2 templating can allow html within
> the options list, allowing the fund and code to have classes and be
> hidden/shown via CSS.
> 
> A note on Kyle's existing code here, he's got the fund code in parentheses,
> with the parentheses also within the .budget_code class. That'd mean if one
> hid the .budget_name the resulting list would be all codes in parens, which
> is not ideal. We should avoid that.

Based on this, I think the correct answer is indeed to add a syspref as you wrote previously. Do you agree?
Comment 13 Katrin Fischer 2026-02-09 13:34:24 UTC
Thanks Andrew for having second look and testing the behavior, much appreciated!
Comment 14 Andrew Fuerste-Henry 2026-02-09 13:42:47 UTC
(In reply to Kyle M Hall (khall) from comment #12)
> Based on this, I think the correct answer is indeed to add a syspref as you
> wrote previously. Do you agree?

A syspref would work and might be the simpler option in the end.

Alternatively, we could use custom templating to insert the desired html into the options in the select2 dropdown.
https://forums.select2.org/t/add-html-into-select-options/193
https://stackoverflow.com/questions/36360783/how-to-render-html-in-select2-options

We could construct it to show something like:

Some fund: CODE123

With markup of
<span class="budget_name">Some fund</span><span class="budget_separator">: </span><span class="budget_code">Code123</span>
Comment 15 Kyle M Hall (khall) 2026-02-09 18:24:03 UTC
Created attachment 192832 [details] [review]
Bug 41553: Add new syspref OrderLineFundInfo

Patch from commit e03755a
Comment 16 Kyle M Hall (khall) 2026-02-09 18:26:13 UTC
Created attachment 192833 [details] [review]
Bug 41553: Add new syspref OrderLineFundInfo

Patch from commit 67104d2
Comment 17 Andrew Fuerste-Henry 2026-02-10 16:34:57 UTC
Updated test plan:

1 - create one or more funds for which the fund code is not the same as the fund name (default funds in KTD all have codes that match their names, which makes testing here difficult)
2 - add a new order to a basket, confirm that the Fund dropdown on the New Order page only shows fund names

3 - apply patch, updatedatabase, restart_all

4 - confirm you now have the OrderLineFundInfo system preference and it is set to "fund name" at update
5 - add a new order to a basket, confirm that the Fund dropdown on the New Order page only shows fund names
6 - Set OrderLineFundInfo to "fund code"
7 - add a new order to a basket, confirm that the Fund dropdown on the New Order page only shows fund codes
8 - Set OrderLineFundInfo to "fund code and name"
9 - add a new order to a basket, confirm that the Fund dropdown on the New Order page only shows both fund codes and fund names
Comment 18 Andrew Fuerste-Henry 2026-02-11 20:44:56 UTC
Apologies for mucking with release notes. I set my test site up confusingly and confused myself.
Comment 19 Andrew Fuerste-Henry 2026-02-13 20:40:33 UTC
Created attachment 193154 [details] [review]
Bug 41553: Add fund code to fund pulldown for order editor ( neworderempty.pl )

It's possible to give multiple funds the same name. It would be helpful to have the fund code in the pulldown options to help disambiguate these funds.

In addition, spans with classes have been added to both the fund name and the fund code for ease of styling.

Test Plan:
1) Create 2 funds with the same name and different fund codes
2) Apply this patch
3) Restart all the things!
4) Create a new order, note the fund code is displayed after the fund name

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Amy Peck <apeck@fplct.org>
Comment 20 Andrew Fuerste-Henry 2026-02-13 20:40:36 UTC
Created attachment 193155 [details] [review]
Bug 41553: Add new syspref OrderLineFundInfo

Signed-off-by: Amy Peck <apeck@fplct.org>