Bugzilla – Attachment 157100 Details for
Bug 34355
Automated MARC record ordering process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34355: Rebase changes made in bug 33170
Bug-34355-Rebase-changes-made-in-bug-33170.patch (text/plain), 10.49 KB, created by
Matt Blenkinsop
on 2023-10-13 13:51:35 UTC
(
hide
)
Description:
Bug 34355: Rebase changes made in bug 33170
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2023-10-13 13:51:35 UTC
Size:
10.49 KB
patch
obsolete
>From 11f40e73fd738c19779b42803243dab8d3da227a Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Fri, 13 Oct 2023 13:29:30 +0000 >Subject: [PATCH] Bug 34355: Rebase changes made in bug 33170 > >--- > Koha/MarcOrder.pm | 108 ++++++++++++++++------------------------------ > 1 file changed, 38 insertions(+), 70 deletions(-) > >diff --git a/Koha/MarcOrder.pm b/Koha/MarcOrder.pm >index fc7574c6d3..af7865fdbf 100644 >--- a/Koha/MarcOrder.pm >+++ b/Koha/MarcOrder.pm >@@ -35,6 +35,10 @@ use C4::ImportBatch qw( > SetImportBatchNoMatchAction > SetImportBatchItemAction > SetImportBatchStatus >+ GetImportBatchOverlayAction >+ GetImportBatchNoMatchAction >+ GetImportBatchItemAction >+ GetImportBatch > ); > use C4::Search qw( FindDuplicate ); > use C4::Acquisition qw( NewBasket ); >@@ -329,15 +333,15 @@ sub _stage_file { > > =head3 _get_MarcFieldsToOrder_syspref_data > >- my $marc_fields_to_order = _get_MarcFieldsToOrder_syspref_data('MarcFieldsToOrder', $marcrecord, $fields); >+ my $marc_fields_to_order = _get_MarcFieldsToOrder_syspref_data( $marcrecord ); > > Fetches data from a marc record based on the mappings in the syspref MarcFieldsToOrder using the fields selected in $fields (array). > > =cut > > sub _get_MarcFieldsToOrder_syspref_data { >- my ($syspref_name, $record, $field_list) = @_; >- my $syspref = C4::Context->preference($syspref_name); >+ my ( $record ) = @_; >+ my $syspref = C4::Context->preference('MarcFieldsToOrder'); > $syspref = "$syspref\n\n"; > my $yaml = eval { > YAML::XS::Load(Encode::encode_utf8($syspref)); >@@ -347,7 +351,7 @@ sub _get_MarcFieldsToOrder_syspref_data { > return (); > } > my $r; >- for my $field_name ( @$field_list ) { >+ for my $field_name ( keys %$yaml ) { > next unless exists $yaml->{$field_name}; > my @fields = split /\|/, $yaml->{$field_name}; > for my $field ( @fields ) { >@@ -364,15 +368,15 @@ sub _get_MarcFieldsToOrder_syspref_data { > > =head3 _get_MarcItemFieldsToOrder_syspref_data > >- my $marc_item_fields_to_order = _get_MarcItemFieldsToOrder_syspref_data('MarcItemFieldsToOrder', $marcrecord, $fields); >+ my $marc_item_fields_to_order = _get_MarcItemFieldsToOrder_syspref_data( $marcrecord ); > > Fetches data from a marc record based on the mappings in the syspref MarcItemFieldsToOrder using the fields selected in $fields (array). > > =cut > > sub _get_MarcItemFieldsToOrder_syspref_data { >- my ($syspref_name, $record, $field_list) = @_; >- my $syspref = C4::Context->preference($syspref_name); >+ my ( $record ) = @_; >+ my $syspref = C4::Context->preference('MarcItemFieldsToOrder'); > $syspref = "$syspref\n\n"; > my $yaml = eval { > YAML::XS::Load(Encode::encode_utf8($syspref)); >@@ -385,7 +389,7 @@ sub _get_MarcItemFieldsToOrder_syspref_data { > my @tags_list; > > # Check tags in syspref definition >- for my $field_name ( @$field_list ) { >+ for my $field_name ( keys %$yaml ) { > next unless exists $yaml->{$field_name}; > my @fields = split /\|/, $yaml->{$field_name}; > for my $field ( @fields ) { >@@ -413,7 +417,7 @@ sub _get_MarcItemFieldsToOrder_syspref_data { > if($tags_count->{count}){ > for (my $i = 0; $i < $tags_count->{count}; $i++) { > my $r; >- for my $field_name ( @$field_list ) { >+ for my $field_name ( keys %$yaml ) { > next unless exists $yaml->{$field_name}; > my @fields = split /\|/, $yaml->{$field_name}; > for my $field ( @fields ) { >@@ -576,7 +580,7 @@ sub add_items_from_import_record { > my @order_line_details; > > if($agent eq 'cron') { >- my $marc_fields_to_order = _get_MarcFieldsToOrder_syspref_data('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2']); >+ my $marc_fields_to_order = _get_MarcFieldsToOrder_syspref_data( $marcrecord ); > my $quantity = $marc_fields_to_order->{quantity}; > my $budget_code = $marc_fields_to_order->{budget_code} || $budget_id; # Use fallback from ordering profile if not mapped > my $price = $marc_fields_to_order->{price}; >@@ -593,7 +597,7 @@ sub add_items_from_import_record { > } > } > >- my $marc_item_fields_to_order = _get_MarcItemFieldsToOrder_syspref_data('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']); >+ my $marc_item_fields_to_order = _get_MarcItemFieldsToOrder_syspref_data( $marcrecord ); > my $item_homebranch = $marc_item_fields_to_order->{homebranch}; > my $item_holdingbranch = $marc_item_fields_to_order->{holdingbranch}; > my $item_itype = $marc_item_fields_to_order->{itype}; >@@ -1020,10 +1024,7 @@ sub import_biblios_list { > ); > my $marcrecord = $import_record->get_marc_record || die "couldn't translate marc information"; > >- my $infos = _get_MarcFieldsToOrder_syspref_data( >- 'MarcFieldsToOrder', $marcrecord, >- [ 'price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2', 'replacementprice' ] >- ); >+ my $infos = _get_MarcFieldsToOrder_syspref_data( $marcrecord ); > my $price = $infos->{price}; > my $replacementprice = $infos->{replacementprice}; > my $quantity = $infos->{quantity}; >@@ -1043,63 +1044,30 @@ sub import_biblios_list { > # Items > my @itemlist = (); > my $all_items_quantity = 0; >- my $alliteminfos = _get_MarcItemFieldsToOrder_syspref_data( >- 'MarcItemFieldsToOrder', >- $marcrecord, >- [ >- 'homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', >- 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code' >- ] >- ); >+ my $alliteminfos = _get_MarcItemFieldsToOrder_syspref_data( $marcrecord ); > if ( !$alliteminfos || %$alliteminfos != -1 ) { >- my $item_homebranch = $alliteminfos->{homebranch}; >- my $item_holdingbranch = $alliteminfos->{holdingbranch}; >- my $item_itype = $alliteminfos->{itype}; >- my $item_nonpublic_note = $alliteminfos->{nonpublic_note}; >- my $item_public_note = $alliteminfos->{public_note}; >- my $item_loc = $alliteminfos->{loc}; >- my $item_ccode = $alliteminfos->{ccode}; >- my $item_notforloan = $alliteminfos->{notforloan}; >- my $item_uri = $alliteminfos->{uri}; >- my $item_copyno = $alliteminfos->{copyno}; >- my $item_quantity = $alliteminfos->{quantity} || 1; >- my $item_budget_code = $alliteminfos->{budget_code}; >- my $item_budget_id; >- >- if ( $alliteminfos->{budget_code} ) { >- my $item_budget = GetBudgetByCode( $alliteminfos->{budget_code} ); >- if ($item_budget) { >- $item_budget_id = $item_budget->{budget_id}; >- } >+ # Quantity is required, default to one if not supplied >+ my $quantity = delete $alliteminfos->{quantity} || 1; >+ >+ # Handle incorrectly named original parameters for MarcItemFieldsToOrder >+ $alliteminfos->{location} = delete $alliteminfos->{loc} if $alliteminfos->{loc}; >+ $alliteminfos->{copynumber} = delete $alliteminfos->{copyno} if $alliteminfos->{copyno}; >+ $alliteminfos->{itemprice} = delete $alliteminfos->{price} if $alliteminfos->{price}; >+ >+ # Convert budget code to a budget id >+ my $item_budget_code = delete $alliteminfos->{budget_code}; >+ if ($item_budget_code) { >+ my $item_budget = GetBudgetByCode($item_budget_code); >+ $alliteminfos->{budget_id} = $item_budget->{budget_id} || $budget_id; > } >- my $item_price = $alliteminfos->{price}; >- my $item_replacement_price = $alliteminfos->{replacementprice}; >- my $item_callnumber = $alliteminfos->{itemcallnumber}; >- >- for ( my $i = 0 ; $i < $item_quantity ; $i++ ) { >- >- my %itemrecord = ( >- 'item_id' => $item_id++, >- 'biblio_count' => $biblio_count, >- 'homebranch' => $item_homebranch, >- 'holdingbranch' => $item_holdingbranch, >- 'itype' => $item_itype, >- 'nonpublic_note' => $item_nonpublic_note, >- 'public_note' => $item_public_note, >- 'loc' => $item_loc, >- 'ccode' => $item_ccode, >- 'notforloan' => $item_notforloan, >- 'uri' => $item_uri, >- 'copyno' => $item_copyno, >- 'quantity' => $item_quantity, >- 'budget_id' => $item_budget_id || $budget_id, >- 'itemprice' => $item_price || $price, >- 'replacementprice' => $item_replacement_price || $replacementprice, >- 'itemcallnumber' => $item_callnumber, >- ); >+ >+ # Clone the item data for the needed quantity >+ # Add the incremented item id for each item in that quantity >+ for ( my $i = 0 ; $i < $quantity ; $i++ ) { >+ my $itemrecord = {%$alliteminfos}; >+ $itemrecord->{item_id} = $item_id++; > $all_items_quantity++; >- push @itemlist, \%itemrecord; >- >+ push @itemlist, $itemrecord; > } > > $cellrecord{'iteminfos'} = \@itemlist; >@@ -1109,7 +1077,7 @@ sub import_biblios_list { > push @list, \%cellrecord; > > # If MarcItemFieldsToOrder is not set, we use MarcFieldsToOrder to populate the order form. >- if ( $alliteminfos || %$alliteminfos == -1 ) { >+ if ( !$alliteminfos || %$alliteminfos == -1 ) { > $cellrecord{price} = $price || ''; > $cellrecord{replacementprice} = $replacementprice || ''; > $cellrecord{quantity} = $quantity || ''; >-- >2.37.1 (Apple Git-137.1)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34355
:
154705
|
154706
|
154707
|
154708
|
154709
|
154710
|
157092
|
157093
|
157094
|
157095
|
157096
|
157097
|
157098
|
157099
|
157100
|
160858
|
160859
|
160860
|
160861
|
160862
|
160863
|
160864
|
160865
|
160866
|
160867
|
160868
|
160869
|
160870
|
160871
|
160872
|
160873
|
160874
|
160875
|
169896
|
169897
|
169898
|
169899
|
169900
|
169901
|
169902
|
169903
|
169904
|
170395
|
170401
|
170402
|
170403
|
170404
|
170405
|
170406
|
170407
|
170408
|
170409
|
173054
|
173055
|
173056
|
173057
|
173058
|
173059
|
173060
|
173061
|
173062
|
173063
|
173064
|
173065
|
173066
|
173709
|
173805
|
173806
|
173809
|
173824
|
173825
|
173993
|
173994
|
173995
|
173996
|
173997
|
173998
|
173999
|
174000
|
174001
|
174002
|
174003
|
174004
|
174005
|
174006
|
174007
|
174008
|
174009
|
174010
|
174362
|
174363
|
174364
|
174365
|
174366
|
174367
|
174368
|
174369
|
174370
|
174371
|
174372
|
174373
|
174374
|
174375
|
174376
|
174377
|
174378
|
174379
|
174380
|
174382
|
174383