Bug 35892 - Fallback to GetMarcPrice in addorderiso2907 no longer works
Summary: Fallback to GetMarcPrice in addorderiso2907 no longer works
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Nick Clemens (kidclamp)
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 34169
Blocks:
  Show dependency treegraph
 
Reported: 2024-01-24 13:36 UTC by Nick Clemens (kidclamp)
Modified: 2024-03-19 19:44 UTC (History)
6 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:
24.05.00,23.11.04,23.05.10


Attachments
Bug 35892: Populate order price using GetMarcPrice if no price specified (3.52 KB, patch)
2024-01-25 20:07 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Test order file (6.28 KB, application/xml)
2024-01-25 20:08 UTC, Nick Clemens (kidclamp)
Details
Bug 35892: Populate order price using GetMarcPrice if no price specified (3.58 KB, patch)
2024-01-25 21:31 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 35892: Populate order price using GetMarcPrice if no price specified (3.68 KB, patch)
2024-03-01 08:22 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 Nick Clemens (kidclamp) 2024-01-24 13:36:15 UTC
Bug 34169 broke a fall back to the GetMarcPrice routine when ordering from a file. Previously if there was no order, the field was blank and evaluated as 'false' and we used the price from the MARC record. Now the field is '0.00' if no price is mapped in MarcFieldsToOrder.

  perl -e 'warn "True" if "0.00"';

IN addorderiso2907.pl:
  my $c_price             = $input->param( 'price_' . $import_record->import_record_id )
      || GetMarcPrice( $marcrecord, C4::Context->preference('marcflavour') );

We could simply add 0 to tthe value to make it a number:
  perl -e 'warn "True" if "0.00"+ 0';

However, this would mean leaving the field at 0.00 when you didn't pay for something would change it to the GetMarcPrice.

I think the solution may be to populate the field using the GetMarcPrice on the initial load.

You can workaround this by adding the fallback to the MarcFieldsToOrder system preference:
price: 947$c|020$c

Which may be a viable solution for updating/editing the default values/documentatoin for that preference
Comment 1 Nick Clemens (kidclamp) 2024-01-25 20:07:35 UTC
Created attachment 161466 [details] [review]
Bug 35892: Populate order price using GetMarcPrice if no price specified

Previously this happened after the fact, automagically, if no price was included in the order record. We should
rather load the Marc price into the order form if we don't have a price form the '...ToOrder' system preferences

To test:

Setup -- Set systempreferences below

MarcFieldsToOrder:
price: 949$g
quantity: 949$k
budget_code: 949$l
discount: 949$m
sort1: 949$n
sort2: 949$q

MarcItemFieldsToOrder:
homebranch: 949$a
holdingbranch: 949$b
itype: 949$y
nonpublic_note: 949$x
public_note: 949$z
loc: 949$c
ccode: 949$8
notforloan: 949$7
uri: 949$u
copyno: 949$t
replacementprice: 949$v
itemcallnumber: 949$o
quantity: 949$k
budget_code: 949$l

Stage the attached bib-303.marcxml file
Add to basket from the staged file
Note that item prices are populated as '6.50' from 949$g
Cancel
Update MarcFieldsToOrder and map price to "020$c"
Add to basket from the staged file
Note the price is not populated, because 020$c contains a dollar sign
Cancel
Apply patch, restart all
Add to basket from the staged file
Note the price is now correctly populated from fallback to GetMarcPrice

Note: GetMarcPrice does some automatic munging, that's why 020$c on it's own doesn't work - this could be done to fields in MarcFieldsToOrder/MarcItemFieldsToOrder but this would be an enhancement.
This bug simply restores the previous behavious, but does it on the front end and is more obvious to the user
Comment 2 Nick Clemens (kidclamp) 2024-01-25 20:08:17 UTC
Created attachment 161467 [details]
Test order file
Comment 3 ByWater Sandboxes 2024-01-25 21:31:53 UTC
Created attachment 161468 [details] [review]
Bug 35892: Populate order price using GetMarcPrice if no price specified

Previously this happened after the fact, automagically, if no price was included in the order record. We should
rather load the Marc price into the order form if we don't have a price form the '...ToOrder' system preferences

To test:

Setup -- Set systempreferences below

MarcFieldsToOrder:
price: 949$g
quantity: 949$k
budget_code: 949$l
discount: 949$m
sort1: 949$n
sort2: 949$q

MarcItemFieldsToOrder:
homebranch: 949$a
holdingbranch: 949$b
itype: 949$y
nonpublic_note: 949$x
public_note: 949$z
loc: 949$c
ccode: 949$8
notforloan: 949$7
uri: 949$u
copyno: 949$t
replacementprice: 949$v
itemcallnumber: 949$o
quantity: 949$k
budget_code: 949$l

Stage the attached bib-303.marcxml file
Add to basket from the staged file
Note that item prices are populated as '6.50' from 949$g
Cancel
Update MarcFieldsToOrder and map price to "020$c"
Add to basket from the staged file
Note the price is not populated, because 020$c contains a dollar sign
Cancel
Apply patch, restart all
Add to basket from the staged file
Note the price is now correctly populated from fallback to GetMarcPrice

Note: GetMarcPrice does some automatic munging, that's why 020$c on it's own doesn't work - this could be done to fields in MarcFieldsToOrder/MarcItemFieldsToOrder but this would be an enhancement.
This bug simply restores the previous behavious, but does it on the front end and is more obvious to the user

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 4 Marcel de Rooy 2024-01-26 07:55:52 UTC
Depends on a NSO ? Blocked
Comment 5 Nick Clemens (kidclamp) 2024-02-08 18:39:41 UTC
Removing dependencies on 35912 and 35913 - they are useful for testing, so that all order prices populate correctly, however, this is present from 23.05 and forward and others are not
Comment 6 Marcel de Rooy 2024-03-01 08:22:51 UTC
Created attachment 162643 [details] [review]
Bug 35892: Populate order price using GetMarcPrice if no price specified

Previously this happened after the fact, automagically, if no price was included in the order record. We should
rather load the Marc price into the order form if we don't have a price form the '...ToOrder' system preferences

To test:

Setup -- Set systempreferences below

MarcFieldsToOrder:
price: 949$g
quantity: 949$k
budget_code: 949$l
discount: 949$m
sort1: 949$n
sort2: 949$q

MarcItemFieldsToOrder:
homebranch: 949$a
holdingbranch: 949$b
itype: 949$y
nonpublic_note: 949$x
public_note: 949$z
loc: 949$c
ccode: 949$8
notforloan: 949$7
uri: 949$u
copyno: 949$t
replacementprice: 949$v
itemcallnumber: 949$o
quantity: 949$k
budget_code: 949$l

Stage the attached bib-303.marcxml file
Add to basket from the staged file
Note that item prices are populated as '6.50' from 949$g
Cancel
Update MarcFieldsToOrder and map price to "020$c"
Add to basket from the staged file
Note the price is not populated, because 020$c contains a dollar sign
Cancel
Apply patch, restart all
Add to basket from the staged file
Note the price is now correctly populated from fallback to GetMarcPrice

Note: GetMarcPrice does some automatic munging, that's why 020$c on it's own doesn't work - this could be done to fields in MarcFieldsToOrder/MarcItemFieldsToOrder but this would be an enhancement.
This bug simply restores the previous behavious, but does it on the front end and is more obvious to the user

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Katrin Fischer 2024-03-07 15:37:53 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 8 Fridolin Somers 2024-03-11 10:06:10 UTC
Pushed to 23.11.x for 23.11.04
Comment 9 Lucas Gass 2024-03-19 19:44:58 UTC
Backported to 23.05.x for upcoming 23.05.10