Bug 20014: Preselect item budget based on id not code
authorNick Clemens <nick@bywatersolutions.com>
Wed, 17 Jan 2018 19:50:31 +0000 (19:50 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Mon, 24 Sep 2018 12:51:16 +0000 (14:51 +0200)
To test:
1 - Have the same fund code in two budgets
2 - Have budget code defined in MarcItemFieldsToOrder
3 - Stage a file with some order items as defined above
4 - Inspect the fuinds drop down in the item, notice two lines are
marked selected
5 - Apply patch
6 - Repeat
7 - Only one field should be selected, with a preference for active
budget

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit d1890533c8796873149338831c5de13d5b19cb9e)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 41b67901d2a6f46452d590916a0cb57f29a69496)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit bff9e80adfa7692963a564c5c35c507d81e1f34b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

acqui/addorderiso2709.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt

index 22f35bd..7acff42 100755 (executable)
@@ -544,6 +544,13 @@ sub import_biblios_list {
                 my $item_copyno = $iteminfos->{copyno};
                 my $item_quantity = $iteminfos->{quantity} || 1;
                 my $item_budget_code = $iteminfos->{budget_code};
+                my $item_budget_id;
+                if ( $iteminfos->{budget_code} ) {
+                    my $item_budget = GetBudgetByCode( $iteminfos->{budget_code} );
+                    if ( $item_budget ) {
+                        $item_budget_id = $item_budget->{budget_id};
+                    }
+                }
                 my $item_price = $iteminfos->{price};
                 my $item_replacement_price = $iteminfos->{replacementprice};
                 my $item_callnumber = $iteminfos->{itemcallnumber};
@@ -564,7 +571,7 @@ sub import_biblios_list {
                         'uri' => $item_uri,
                         'copyno' => $item_copyno,
                         'quantity' => $item_quantity,
-                        'budget_code' => $item_budget_code || $budget_code,
+                        'budget_id' => $item_budget_id || $budget_id,
                         'itemprice' => $item_price || $price,
                         'replacementprice' => $item_replacement_price,
                         'itemcallnumber' => $item_callnumber,
index fe420c4..107b408 100644 (file)
                         <li><label for="budget_code_item_[% item.item_id %]">budget_code</label><select id="budget_code_item_[% item.item_id %]" name="budget_code_[% item.biblio_count %]">
                         <option value="">Select a fund</option>
                         [% FOREACH budget_loo IN budget_loop %]
-                            [% IF ( budget_loo.b_code ) == ( item.budget_code ) %]<option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
+                            [% IF ( budget_loo.b_id ) == ( item.budget_id ) %]<option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
                             [% ELSE %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
                             [% END %]
                         [% END %]