Bug 34159 - Remove plan by AR_CANCELLATION choice in aqplan
Summary: Remove plan by AR_CANCELLATION choice in aqplan
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Phil Ringnalda
QA Contact: Testopia
URL:
Keywords:
: 36448 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-06-29 19:19 UTC by Caroline Cyr La Rose
Modified: 2024-09-16 11:49 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 34159: Budget planning shouldn't add every authorized value starting with A (2.81 KB, patch)
2024-09-13 01:11 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 34159: Budget planning shouldn't add every authorized value starting with A (2.88 KB, patch)
2024-09-13 14:41 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 34159: Budget planning shouldn't add every authorized value starting with A (2.96 KB, patch)
2024-09-16 09:45 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 Caroline Cyr La Rose 2023-06-29 19:19:29 UTC
I'm not sure if this is my data, but I see it on my local master as well as on the bywater and ptfs-e sandboxes... When I go to Plan by X in the Funds administration, there is an option to Plan by AR_CANCELLATION, which is weird and uncecessary (and also doesn't work).

To recreate:
1. Add a budget
   1.1. Go to Administration > Budgets
   1.2. Click 'New budget'
   1.3. Fill in the form (make sure there are a couple of months between the start and end dates), e.g.
        - Start date: 01/01/2023
        - End date: 12/31/2023
        - Description: 2023
        - Total amount: 10000
        - Make budget active: check
        - Lock budget: leave unchecked
   1.4. Click 'Save'

2. Add at least one fund to the budget, make sure not to choose any statistics 1/2
   2.1. Click 'Actions' next to the budget and choose 'Add fund'
   2.2. Fill out the form, e.g.
        - Fund code: PRINT
        - Fund name: Print material
        - Amount: 6000
   2.3. Click 'Submit'

3. View the planning page, e.g. Plan by months
   3.1. Click 'Planning' at the top of the page and choose 'Plan by months'
   3.2. In the Filter box on the left, open the 'Select planning type' drop-down menu
   --> There is one choice called 'Plan by AR_CANCELLATION' 

I checked all my funds and all the funds in the sandboxes and none have AR_CANCELLATION as a statistic 1 or 2.

If you select this option and click 'Submit', it says there is nothing to show.
Comment 1 Jonathan Druart 2024-09-10 07:25:45 UTC
*** Bug 36448 has been marked as a duplicate of this bug. ***
Comment 2 Jonathan Druart 2024-09-10 07:26:44 UTC
From bug 36448:

"""
122 my $sth = $dbh->prepare("select distinct category from authorised_values where category like 'A%' ")

What is that?!

http://localhost:8081/cgi-bin/koha/admin/aqplan.pl?budget_period_id=1&authcat=MONTHS

On the left " Select planning type:" you can see "By AR_CANCELLATION". That does not make any sense!
"""
Comment 3 Phil Ringnalda 2024-09-12 23:33:57 UTC
I really hoped git archaeology would show that the separate parts made sense at different times, but they didn't, they've both been that way since the intial commit. Selecting A% has always been there, and so has the code which refuses to actually do anything for anything that A% finds unless it is also in the fund's "Statistic 1|2 done on" field (and if you use Asort1|2 for that, then you have two entries, because things that will work are added separately from A%).
Comment 4 Phil Ringnalda 2024-09-13 01:11:01 UTC
Created attachment 171433 [details] [review]
Bug 34159: Budget planning shouldn't add every authorized value starting with A

In aqplan.pl there are two different sets of params for things you can plan
by: for the toolbar "Planning" menubutton the script looks up what AVs are
used for "Statistic 1|2 done on" for the budget's fund(s), and passes them to
the template which knows to hardcode the MONTHS, ITEMTYPES, and BRANCHES
choices, but for "Select planning type" in the Filter sidebar box, the
script inserts the harcoded ones itself, adds in the ones used by a fund,
and for no apparent reason adds in every authorized value category that starts
with the letter A and has at least one value. Those things do not actually
work, because for things other than the hardcoded ones the script checks
whether they are in a fund's "Statistic 1|2" and if not refuses to let you
plan by them.

Test plan:
 1. Administration - Budgets
 2. If you don't have a budget, create one and add a fund to it,
    but with the default data click the name Main budget
 3. In the row for Main fund, click Actions->Edit
 4. For Statistic 1 done on choose an authorized value which does not start
    with A, like BOR_NOTES, and Save
 5. In the top toolbar, Planning->Plan by months
 6. In the sidebar Filter box, note that there is an option to plan by
    AR_CANCELLATION even though you didn't select that for Statistic 1
 7. Select the by BOR_NOTE choice and Submit
 8. Note that you now only see Main fund, because that's the only one
    which uses that AV
 9. Select the by months choice and Submit, see that it changes back, then
    select the by AR_CANCELLATION choice and see that nothing is displayed,
    select the by months choice again and Submit, see that the display is
    now completely broken
 9. Apply patch, restart_all, reload the page
10. Note that the AR_CANCELLATION choice is gone, and all the choices
    you do have work correctly

Sponsored-by: Chetco Community Public Library
Comment 5 Caroline Cyr La Rose 2024-09-13 14:41:40 UTC
Created attachment 171469 [details] [review]
Bug 34159: Budget planning shouldn't add every authorized value starting with A

In aqplan.pl there are two different sets of params for things you can plan
by: for the toolbar "Planning" menubutton the script looks up what AVs are
used for "Statistic 1|2 done on" for the budget's fund(s), and passes them to
the template which knows to hardcode the MONTHS, ITEMTYPES, and BRANCHES
choices, but for "Select planning type" in the Filter sidebar box, the
script inserts the harcoded ones itself, adds in the ones used by a fund,
and for no apparent reason adds in every authorized value category that starts
with the letter A and has at least one value. Those things do not actually
work, because for things other than the hardcoded ones the script checks
whether they are in a fund's "Statistic 1|2" and if not refuses to let you
plan by them.

Test plan:
 1. Administration - Budgets
 2. If you don't have a budget, create one and add a fund to it,
    but with the default data click the name Main budget
 3. In the row for Main fund, click Actions->Edit
 4. For Statistic 1 done on choose an authorized value which does not start
    with A, like BOR_NOTES, and Save
 5. In the top toolbar, Planning->Plan by months
 6. In the sidebar Filter box, note that there is an option to plan by
    AR_CANCELLATION even though you didn't select that for Statistic 1
 7. Select the by BOR_NOTE choice and Submit
 8. Note that you now only see Main fund, because that's the only one
    which uses that AV
 9. Select the by months choice and Submit, see that it changes back, then
    select the by AR_CANCELLATION choice and see that nothing is displayed,
    select the by months choice again and Submit, see that the display is
    now completely broken
 9. Apply patch, restart_all, reload the page
10. Note that the AR_CANCELLATION choice is gone, and all the choices
    you do have work correctly

Sponsored-by: Chetco Community Public Library
Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Comment 6 Caroline Cyr La Rose 2024-09-13 14:42:16 UTC
Thanks Phil!
Comment 7 Jonathan Druart 2024-09-16 09:45:12 UTC
Created attachment 171521 [details] [review]
Bug 34159: Budget planning shouldn't add every authorized value starting with A

In aqplan.pl there are two different sets of params for things you can plan
by: for the toolbar "Planning" menubutton the script looks up what AVs are
used for "Statistic 1|2 done on" for the budget's fund(s), and passes them to
the template which knows to hardcode the MONTHS, ITEMTYPES, and BRANCHES
choices, but for "Select planning type" in the Filter sidebar box, the
script inserts the harcoded ones itself, adds in the ones used by a fund,
and for no apparent reason adds in every authorized value category that starts
with the letter A and has at least one value. Those things do not actually
work, because for things other than the hardcoded ones the script checks
whether they are in a fund's "Statistic 1|2" and if not refuses to let you
plan by them.

Test plan:
 1. Administration - Budgets
 2. If you don't have a budget, create one and add a fund to it,
    but with the default data click the name Main budget
 3. In the row for Main fund, click Actions->Edit
 4. For Statistic 1 done on choose an authorized value which does not start
    with A, like BOR_NOTES, and Save
 5. In the top toolbar, Planning->Plan by months
 6. In the sidebar Filter box, note that there is an option to plan by
    AR_CANCELLATION even though you didn't select that for Statistic 1
 7. Select the by BOR_NOTE choice and Submit
 8. Note that you now only see Main fund, because that's the only one
    which uses that AV
 9. Select the by months choice and Submit, see that it changes back, then
    select the by AR_CANCELLATION choice and see that nothing is displayed,
    select the by months choice again and Submit, see that the display is
    now completely broken
 9. Apply patch, restart_all, reload the page
10. Note that the AR_CANCELLATION choice is gone, and all the choices
    you do have work correctly

Sponsored-by: Chetco Community Public Library
Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Katrin Fischer 2024-09-16 11:49:01 UTC
Pushed for 24.11!

Well done everyone, thank you!