Bugzilla – Attachment 169480 Details for
Bug 35026
Refactor addorderiso2709.pl to use object methods
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35026: Allow multiple records from one marc file
Bug-35026-Allow-multiple-records-from-one-marc-fil.patch (text/plain), 6.19 KB, created by
Nick Clemens (kidclamp)
on 2024-07-24 12:56:28 UTC
(
hide
)
Description:
Bug 35026: Allow multiple records from one marc file
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-07-24 12:56:28 UTC
Size:
6.19 KB
patch
obsolete
>From 0cee3eefdb7047de21414f723e0b213caa3dd433 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Thu, 11 Jan 2024 11:24:38 +0000 >Subject: [PATCH] Bug 35026: Allow multiple records from one marc file > >This patch addresses a bug where only one record would be read from a marc file and other records would be lost. All records are now read from the file and displayed in the UI. > >Test plan as above > >Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/MarcOrder.pm | 73 +++++++++++++++++++++++------------------------ > 1 file changed, 35 insertions(+), 38 deletions(-) > >diff --git a/Koha/MarcOrder.pm b/Koha/MarcOrder.pm >index f11993636af..3c7ed573b39 100644 >--- a/Koha/MarcOrder.pm >+++ b/Koha/MarcOrder.pm >@@ -38,6 +38,8 @@ use C4::ImportBatch qw( > GetImportBatchNoMatchAction > GetImportBatchItemAction > GetImportBatch >+ GetImportBatchRangeDesc >+ GetNumberOfNonZ3950ImportBatches > ); > use C4::Search qw( FindDuplicate ); > use C4::Acquisition qw( NewBasket ); >@@ -168,19 +170,13 @@ sub _get_MarcFieldsToOrder_syspref_data { > > sub _get_MarcItemFieldsToOrder_syspref_data { > my ($record) = @_; >- my $syspref = C4::Context->preference('MarcItemFieldsToOrder'); >- $syspref = "$syspref\n\n"; >- my $yaml = eval { YAML::XS::Load( Encode::encode_utf8($syspref) ); }; >- if ($@) { >- warn "Unable to parse $syspref syspref : $@"; >- return (); >- } >+ my $syspref = C4::Context->yaml_preference('MarcItemFieldsToOrder'); > my @result; > my @tags_list; > > # Check tags in syspref definition >- for my $field_name ( keys %$yaml ) { >- my @fields = split /\|/, $yaml->{$field_name}; >+ for my $field_name ( keys %$syspref ) { >+ my @fields = split /\|/, $syspref->{$field_name}; > for my $field (@fields) { > my ( $f, $sf ) = split /\$/, $field; > next unless $f and $sf; >@@ -207,21 +203,21 @@ sub _get_MarcItemFieldsToOrder_syspref_data { > if ( $tags_count->{count} ) { > for ( my $i = 0 ; $i < $tags_count->{count} ; $i++ ) { > my $r; >- for my $field_name ( keys %$yaml ) { >- my @fields = split /\|/, $yaml->{$field_name}; >+ for my $field_name ( keys %$syspref ) { >+ my @fields = split /\|/, $syspref->{$field_name}; > for my $field (@fields) { > my ( $f, $sf ) = split /\$/, $field; > next unless $f and $sf; > my $v = $fields_hash->{$f}[$i] ? $fields_hash->{$f}[$i]->subfield($sf) : undef; > $r->{$field_name} = $v if ( defined $v ); >- last if $yaml->{$field}; >+ last if $syspref->{$field}; > } > } > push @result, $r; > } > } > >- return $result[0]; >+ return \@result; > } > > =head3 _verify_number_of_fields >@@ -526,7 +522,7 @@ sub import_batches_list { > }; > } > >-=head3 >+=head3 import_biblios_list > > For an import batch, this function reads the files and creates all the relevant data pertaining to that file > It then returns this to the template to be shown in the UI >@@ -626,32 +622,33 @@ sub import_biblios_list { > my @itemlist = (); > my $all_items_quantity = 0; > my $alliteminfos = _get_MarcItemFieldsToOrder_syspref_data($marcrecord); >- if ( !$alliteminfos || %$alliteminfos != -1 ) { >- >- # 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}; >- >- # 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; >- } >+ if ( $alliteminfos != -1 ) { >+ foreach my $iteminfos (@$alliteminfos) { >+ # Quantity is required, default to one if not supplied >+ my $quantity = delete $iteminfos->{quantity} || 1; >+ >+ # Handle incorrectly named original parameters for MarcItemFieldsToOrder >+ $iteminfos->{location} = delete $iteminfos->{loc} if $iteminfos->{loc}; >+ $iteminfos->{copynumber} = delete $iteminfos->{copyno} if $iteminfos->{copyno}; >+ >+ # Convert budget code to a budget id >+ my $item_budget_code = delete $iteminfos->{budget_code}; >+ if ($item_budget_code) { >+ my $item_budget = GetBudgetByCode($item_budget_code); >+ $iteminfos->{budget_id} = $item_budget->{budget_id} || $budget_id; >+ } > >- # 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++; >+ # 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 = {%$iteminfos}; >+ $itemrecord->{item_id} = $item_id++; > >- # Rename price field to match UI >- $itemrecord->{itemprice} = delete $itemrecord->{price} if $itemrecord->{price}; >- $all_items_quantity++; >- push @itemlist, $itemrecord; >+ # Rename price field to match UI >+ $itemrecord->{itemprice} = delete $itemrecord->{price} if $itemrecord->{price}; >+ $all_items_quantity++; >+ push @itemlist, $itemrecord; >+ } > } > > $cellrecord{'iteminfos'} = \@itemlist; >-- >2.39.2
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 35026
:
157050
|
157051
|
157052
|
157056
|
157057
|
157058
|
159305
|
159306
|
159969
|
159970
|
159971
|
159972
|
159973
|
160833
|
160834
|
160835
|
160836
|
160837
|
160838
|
162647
|
162648
|
162649
|
162650
|
162651
|
162652
|
162653
|
162654
|
163787
|
163788
|
163789
|
163790
|
163791
|
163792
|
163793
|
163794
|
163819
|
163820
|
163835
|
163836
|
163838
|
163839
|
163840
|
163841
|
163842
|
163843
|
163844
|
163845
|
164695
|
164937
|
165378
|
165681
|
168123
|
168124
|
168125
|
168126
|
168127
|
168128
|
168129
|
168130
|
168131
|
168132
|
168971
|
168972
|
168973
|
168974
|
168975
|
168976
|
168977
|
168978
|
168979
|
168980
|
168981
|
169475
|
169476
|
169477
|
169478
|
169479
| 169480 |
169481
|
169482
|
169483
|
169484
|
169485
|
170504