Bug 34445 - Default budget is not selected in addorderiso2709.pl
Summary: Default budget is not selected in addorderiso2709.pl
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial (vote)
Assignee: Matt Blenkinsop
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-31 09:47 UTC by Matt Blenkinsop
Modified: 2023-12-28 20:47 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.04,22.11.10


Attachments
Test file with mapped fields (25.13 KB, application/xml)
2023-07-31 09:51 UTC, Matt Blenkinsop
Details
Bug 34445: Set default budget in addorderiso2709.pl (1.30 KB, patch)
2023-07-31 09:51 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 34445: Set default budget in addorderiso2709.pl (1.34 KB, patch)
2023-08-14 16:59 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 34445: (QA follow-up) Tidy file (1.19 KB, patch)
2023-08-25 09:52 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 34445: Set default budget in addorderiso2709.pl (2.91 KB, patch)
2023-08-25 10:24 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 34445: Set default budget in addorderiso2709.pl (3.10 KB, patch)
2023-08-28 08:56 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Blenkinsop 2023-07-31 09:47:15 UTC
When adding order lines to a basket from a staged marc file using the mappings in MarcItemFieldsToOrder a default budget should be selected when adding order lines if no budget is selected in the UI. Currently this does not happen and the order line creation fails.

To replicate:
1) Add the following to the syspref MarcItemFieldsToOrder

homebranch: 975$a
holdingbranch: 975$b
itype: 975$y
nonpublic_note: 975$x
public_note: 975$z
loc: 975$c
ccode: 975$8
notforloan: 975$7
uri: 975$u
copyno: 975$n
quantity: 975$q
budget_code: 975$h
price: 975$p
replacementprice: 975$v

2) Save the file attached ready to stage
3) Navigate to Acquisitions, choose a vendor and then create/choose a basket
4) Click Add to basket and then From a new file
5) Choose the file you just saved
6) Change the Record matching rule to ISBN and the Action if matching record found to Ignore incoming record. Click stage for import
7) When the job progress is complete, click the Add staged files to basket button
8) Click on the Item information tab and in field y - Koha item type select Books
9) Click Select all on the table
10) Observe that under Item record 1, the budget_code field says "Select a fund...". Do not change this field, this is just to show that no budget has been selected
11) At the bottom of the form, click Save
12) You should be back on the basket page - observe that no order lines have been added
Comment 1 Matt Blenkinsop 2023-07-31 09:51:18 UTC
Created attachment 154084 [details]
Test file with mapped fields
Comment 2 Matt Blenkinsop 2023-07-31 09:51:58 UTC
Created attachment 154085 [details] [review]
Bug 34445: Set default budget in addorderiso2709.pl

This patch allows the default budget to be used as a fallback if no budget is selected. Currently the default budget is set using lines 129-133 but then is never used.

Test plan:
1) Apply patch
2) restart_all
3) Follow the steps from the bug description
4) Order lines should be added properly
Comment 3 Lucas Gass 2023-08-14 16:59:04 UTC
Created attachment 154413 [details] [review]
Bug 34445: Set default budget in addorderiso2709.pl

This patch allows the default budget to be used as a fallback if no budget is selected. Currently the default budget is set using lines 129-133 but then is never used.

Test plan:
1) Apply patch
2) restart_all
3) Follow the steps from the bug description
4) Order lines should be added properly

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Marcel de Rooy 2023-08-25 09:44:55 UTC
   WARN   tidiness
                The file is less tidy than before (bad/messy lines before: 307, now: 308)

Please correct. This is a oneliner patch. Should be possible to tidy :)
Comment 5 Matt Blenkinsop 2023-08-25 09:52:25 UTC
Created attachment 154791 [details] [review]
Bug 34445: (QA follow-up) Tidy file

perl tidy for patch
Comment 6 Marcel de Rooy 2023-08-25 10:01:07 UTC
Please squash. Note that perltidy does not like

             for (my $i = 0; $i < $count; $i++) {
+                # Use default budget if no budget selected in the UI
+                $budget_codes[$i] = $budget_id
+                  if !$budget_codes[$i];

It seems to insert an empty line before the new comment line..
Sorry about that, i think it is nonsense..

Another question:
You are putting an id in a field called budget_code.
Are you really sure that this is correct?? It does not look good.
Comment 7 Matt Blenkinsop 2023-08-25 10:18:57 UTC
The terminology is confusing, I think budget_codes needs changing to budget_ids because the values in the array are the integer values from the budget_id fields in aqbudgets. I'll change it and re-upload
Comment 8 Matt Blenkinsop 2023-08-25 10:24:31 UTC
Created attachment 154795 [details] [review]
Bug 34445: Set default budget in addorderiso2709.pl

This patch allows the default budget to be used as a fallback if no budget is selected. Currently the default budget is set using lines 129-133 but then is never used.

QA follow-up:
- perl tidied
- budget_codes changed to budget_ids for consistency

Test plan:
1) Apply patch
2) restart_all
3) Follow the steps from the bug description
4) Order lines should be added properly
Comment 9 Marcel de Rooy 2023-08-28 08:56:30 UTC
Created attachment 154874 [details] [review]
Bug 34445: Set default budget in addorderiso2709.pl

This patch allows the default budget to be used as a fallback if no budget is selected. Currently the default budget is set using lines 129-133 but then is never used.

QA follow-up:
- perl tidied
- budget_codes changed to budget_ids for consistency

Test plan:
1) Apply patch
2) restart_all
3) Follow the steps from the bug description
4) Order lines should be added properly

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
[EDIT] Rearranged comments
Comment 10 Tomás Cohen Arazi 2023-08-30 13:06:40 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 11 Fridolin Somers 2023-08-30 20:15:29 UTC
Pushed to 23.05.x for 23.05.04
Comment 12 Matt Blenkinsop 2023-08-31 10:47:09 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x