Bug 21268 - Can't add to basket from staged file if base-level allocated is zero
Summary: Can't add to basket from staged file if base-level allocated is zero
Status: Pushed to stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low normal with 1 vote (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
: 26029 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-08-24 14:27 UTC by Ray Delahunty
Modified: 2020-08-07 02:04 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:
20.11.00, 20.05.03


Attachments
Bug 21268: Don't remove 0 allocated funds from fund list (5.25 KB, patch)
2020-07-28 07:31 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21268: Don't remove 0 allocated funds from fund list (5.32 KB, patch)
2020-07-28 13:13 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 21268: Don't remove 0 allocated funds from fund list (5.47 KB, patch)
2020-07-29 12:32 UTC, Joonas Kylmälä
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Ray Delahunty 2018-08-24 14:27:49 UTC
We recently carried out fiscal period close, and as we are not permitted to move remaining unspent funds we ended up with negative amounts in Total Available (due to open orders rolling forward into the new fiscal period, of course). 
We did not get around to adding any amounts so all Base-level allocated amounts remained zero. Since the fiscal period close we have been able to add to baskets using options OTHER than from a staged file. Selecting this option sees the Fund dropdown box (in the Default Accounting Details tab) not effective. We cannot see any of the funds. 
Once base-level allocated amounts are increased from zero this problem vanishes- funds are visible and selectable in the Fund pull-down. This is not a major problem, but it is a puzzle that this problem only appears with the stage file option.
Comment 1 Jonathan Druart 2018-08-29 21:04:17 UTC
(In reply to Ray Delahunty from comment #0)
> Since the fiscal period close we have been able to
> add to baskets using options OTHER than from a staged file.

Sure about that? It is not what I see:

acqui/addorderiso2709.pl:    if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
acqui/basket.pl:        if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
acqui/booksellers.pl:    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
acqui/neworderbiblio.pl:    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
acqui/neworderempty.pl:    if (!defined $r->{budget_amount} || $r->{budget_amount} <0) {
acqui/orderreceive.pl:        if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
acqui/parcels.pl:    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {


It's '== 0' vs '< 0'

So we we should fix neworderempty and replace '<0' with '== 0'
Comment 2 Katrin Fischer 2019-02-09 23:51:02 UTC
We have seen the issue for normal ordering as well after migrations where the amounts hadn't been set yet or for funds that are set up purely for handling donations or 'exchanged' items.
Comment 3 Katrin Fischer 2019-02-10 00:01:23 UTC
I tested a bit on master: the funds = 0 now show when adding a new order, but are for example not in the fund pull down on receiving the order.

> acqui/addorderiso2709.pl:    if ( !defined $r->{budget_amount} ||
> $r->{budget_amount} == 0 ) {
> acqui/basket.pl:        if (!defined $r->{budget_amount} ||
> $r->{budget_amount} == 0) {
> acqui/booksellers.pl:    if (!defined $r->{budget_amount} ||
> $r->{budget_amount} == 0) {
> acqui/neworderbiblio.pl:    if (!defined $r->{budget_amount} ||
> $r->{budget_amount} == 0) {
> acqui/neworderempty.pl:    if (!defined $r->{budget_amount} ||
> $r->{budget_amount} <0) {
> acqui/orderreceive.pl:        if ( !defined $r->{budget_amount} ||
> $r->{budget_amount} == 0 ) {
> acqui/parcels.pl:    if (!defined $r->{budget_amount} || $r->{budget_amount}
> == 0) {
> 
> 
> It's '== 0' vs '< 0'
> 
> So we we should fix neworderempty and replace '<0' with '== 0'

I am not sure what would be the right behaviour here. I think having to add 0.01 just to make a fund you want to use for handling 'free' orders is a bit clumsy right now. I wonder if the cleaner solution would be to just check if the fund exists and omit testing for the amount in all places. Or: Only test for negative with <0 everywhere.
Comment 4 Andrew Fuerste-Henry 2020-06-29 14:59:39 UTC
I'm seeing this error when adding to a basket via a staged file on 19.11.
We do have libraries using funds with $0 allocated to track donations and other situations where there is not an expected amount for the year. I'm in favor of Katrin's suggestion to simply check whether a fund exists and is active, rather then checking for an amount allocated.
Comment 5 Donna 2020-07-14 16:32:14 UTC
This is still an issue in 20.05 and is blocking workflows for libraries.  The base fund allocation of 0.00 is becoming more common for libraries, so I expect this will be brought up more and more.  

If I can add an item directly into a basket using a 0.00 fund then that same behavior should be permitted using staged or new files. 

I think that expected behavior is just look to see if there is an active fund. Increasing the importance level as it blocks workflows.
Comment 6 Jonathan Druart 2020-07-28 07:31:49 UTC
Created attachment 107455 [details] [review]
Bug 21268: Don't remove 0 allocated funds from fund list

If a fund is created with a amount of 0, it will not appear in the fund
list (when a new order is created for instance).
0 allocated funds can be used to track donations and other situations
where there is not an expected amount for the year.

Test plan:
0. Do not apply the patch
1. Create 1 active and 1 inactive budgets
2. Create some funds for each budgets, with amount > 0 and amount == 0
3. Add orders to basket
=> Note that the funds with amount == 0 are not displayed
4. Apply the patch
5. Add orders to basket (using the different possible ways we have)
=> Note that the funds with amount == 0 are displayed

This change is applied to the different views of the acquisition module.
Comment 7 Andrew Fuerste-Henry 2020-07-28 13:10:58 UTC
Without this patch, I can select a $0 fund for all methods of adding to a basket except:
- duplicating an order (duplicate_orders.pl)
- from a new file (addorderiso2709.pl)
- from a staged file (also addorderiso2709.pl)

Additionally, if I try to set my $0 fund via a budget code in the field set by MARCItemFieldstoOrder, it is not selected.
Comment 8 Andrew Fuerste-Henry 2020-07-28 13:13:04 UTC
Created attachment 107466 [details] [review]
Bug 21268: Don't remove 0 allocated funds from fund list

If a fund is created with a amount of 0, it will not appear in the fund
list (when a new order is created for instance).
0 allocated funds can be used to track donations and other situations
where there is not an expected amount for the year.

Test plan:
0. Do not apply the patch
1. Create 1 active and 1 inactive budgets
2. Create some funds for each budgets, with amount > 0 and amount == 0
3. Add orders to basket
=> Note that the funds with amount == 0 are not displayed
4. Apply the patch
5. Add orders to basket (using the different possible ways we have)
=> Note that the funds with amount == 0 are displayed

This change is applied to the different views of the acquisition module.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 9 Joonas Kylmälä 2020-07-29 12:32:46 UTC
Created attachment 107491 [details] [review]
Bug 21268: Don't remove 0 allocated funds from fund list

If a fund is created with a amount of 0, it will not appear in the fund
list (when a new order is created for instance).
0 allocated funds can be used to track donations and other situations
where there is not an expected amount for the year.

Test plan:
0. Do not apply the patch
1. Create 1 active and 1 inactive budgets
2. Create some funds for each budgets, with amount > 0 and amount == 0
3. Add orders to basket
=> Note that the funds with amount == 0 are not displayed
4. Apply the patch
5. Add orders to basket (using the different possible ways we have)
=> Note that the funds with amount == 0 are displayed

This change is applied to the different views of the acquisition module.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Comment 10 Jonathan Druart 2020-07-29 14:37:29 UTC
*** Bug 26029 has been marked as a duplicate of this bug. ***
Comment 11 Jonathan Druart 2020-07-30 15:46:21 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 12 Lucas Gass 2020-08-06 20:08:06 UTC
backported to 20.05.x for 20.05.03
Comment 13 Aleisha Amohia 2020-08-07 02:04:18 UTC
I cannot recreate the bug in 19.11.x, all funds show in the fund list. Not backported.