@@ -, +, @@ --- Koha/EDI.pm | 17 ++++++++++------- Koha/Edifact/Line.pm | 2 +- Koha/Edifact/Order.pm | 12 +++++++----- installer/data/mysql/atomicupdate/bug_30135.pl | 14 ++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/acquisitions.pref | 8 ++++++++ 6 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_30135.pl --- a/Koha/EDI.pm +++ a/Koha/EDI.pm @@ -869,8 +869,6 @@ sub quote_item { my $new_item = { itype => $item->girfield( 'stock_category', $occurrence ), - location => - $item->girfield( 'collection_code', $occurrence ), itemcallnumber => $item->girfield( 'shelfmark', $occurrence ) || $item->girfield( 'classification', $occurrence ) @@ -879,11 +877,15 @@ sub quote_item { $item->girfield( 'branch', $occurrence ), homebranch => $item->girfield( 'branch', $occurrence ), }; + + my $lsq_field = C4::Context->preference('EdifactLSQ'); + $new_item->{$lsq_field} => $item->girfield( 'sequence_code', $occurrence ); + if ( $new_item->{itype} ) { $item_hash->{itype} = $new_item->{itype}; } - if ( $new_item->{location} ) { - $item_hash->{location} = $new_item->{location}; + if ( $new_item->{$lsq_field} ) { + $item_hash->{$lsq_field} = $new_item->{$lsq_field}; } if ( $new_item->{itemcallnumber} ) { $item_hash->{itemcallnumber} = @@ -957,8 +959,6 @@ sub quote_item { replacementprice => $price, itype => $item->girfield( 'stock_category', $occurrence ), - location => - $item->girfield( 'collection_code', $occurrence ), itemcallnumber => $item->girfield( 'shelfmark', $occurrence ) || $item->girfield( 'classification', $occurrence ) @@ -967,6 +967,8 @@ sub quote_item { $item->girfield( 'branch', $occurrence ), homebranch => $item->girfield( 'branch', $occurrence ), }; + my $lsq_field = C4::Context->preference('EdifactLSQ'); + $new_item->{$lsq_field} => $item->girfield( 'sequence_code', $occurrence ); $new_item->{biblionumber} = $bib->{biblionumber}; $new_item->{biblioitemnumber} = $bib->{biblioitemnumber}; my $kitem = Koha::Item->new( $new_item )->store; @@ -1173,7 +1175,8 @@ sub _create_item_from_quote { $item_hash->{booksellerid} = $quote->vendor_id; $item_hash->{price} = $item_hash->{replacementprice} = $item->price; $item_hash->{itype} = $item->girfield('stock_category'); - $item_hash->{location} = $item->girfield('collection_code'); + my $lsq_field = C4::Context->preference('EdifactLSQ'); + $item_hash->{$lsq_field} = $item->girfield('sequence_code'); my $note = {}; --- a/Koha/Edifact/Line.pm +++ a/Koha/Edifact/Line.pm @@ -686,7 +686,7 @@ sub extract_gir { LQT => 'part_order_quantity', LRS => 'record_sublocation', LSM => 'shelfmark', - LSQ => 'collection_code', + LSQ => 'sequence_code', LST => 'stock_category', LSZ => 'size_code', LVC => 'coded_servicing_instruction', --- a/Koha/Edifact/Order.pm +++ a/Koha/Edifact/Order.pm @@ -381,17 +381,18 @@ sub order_line { # DTM Optional date constraints on delivery # we dont currently support this in koha # GIR copy-related data + my $lsq_field = C4::Context->preference('EdifactLSQ'); my @items; if ( $basket->effective_create_items eq 'ordering' ) { - my @linked_itemnumbers = $orderline->aqorders_items; + my @linked_itemnumbers = $orderline->aqorders_items; foreach my $item (@linked_itemnumbers) { my $i_obj = $schema->resultset('Item')->find( $item->itemnumber ); if ( defined $i_obj ) { push @items, { branchcode => $i_obj->get_column('homebranch'), itype => $i_obj->effective_itemtype, - location => $i_obj->location, + $lsq_field => $i_obj->$lsq_field, itemcallnumber => $i_obj->itemcallnumber, }; } @@ -419,7 +420,7 @@ sub order_line { { branchcode => $item->{branchcode}, itype => $item->{itype}, - location => $item->{location}, + $lsq_field => $item->{$lsq_field}, itemcallnumber => $item->{itemcallnumber}, }; } @@ -551,6 +552,7 @@ sub gir_segments { my $budget_code = $orderfields->{budget_code}; my @segments; my $sequence_no = 1; + my $lsq_field = C4::Context->preference('EdifactLSQ'); foreach my $item (@onorderitems) { my $elements_added = 0; my @gir_elements; @@ -566,9 +568,9 @@ sub gir_segments { push @gir_elements, { identity_number => 'LST', data => $item->{itype} }; } - if ( $item->{location} ) { + if ( $item->{$lsq_field} ) { push @gir_elements, - { identity_number => 'LSQ', data => $item->{location} }; + { identity_number => 'LSQ', data => $item->{$lsq_field} }; } if ( $item->{itemcallnumber} ) { push @gir_elements, --- a/installer/data/mysql/atomicupdate/bug_30135.pl +++ a/installer/data/mysql/atomicupdate/bug_30135.pl @@ -0,0 +1,14 @@ +use Modern::Perl; + +return { + bug_number => "30135", + description => "Add EdifactLSQ mapping system preference", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('EdifactLSQ', 'location', 'location|ccode', "Map EDI sequence code (GIR+LSQ) to Koha Item field', 'Choice') + }); + }, +}; --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/installer/data/mysql/mandatory/sysprefs.sql @@ -187,6 +187,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('DumpTemplateVarsOpac', '0', NULL , 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.', 'YesNo'), ('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'), ('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'), +('EdifactLSQ', 'location', 'location|ccode', "Map EDI sequence code (GIR+LSQ) to Koha Item field', 'Choice'), ('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL), ('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL), ('ElasticsearchMARCFormat', 'ISO2709', 'ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -130,3 +130,11 @@ Acquisitions: automatic: "Do" manual: "Don't" - " automatically import EDIFACT invoice message files when they are downloaded." + - + - "Map sequence code (GIR:LSQ) field to Koha item " + - pref: EdifactLSQ + default: location + choices: + location: "location" + ccode: "ccode" + - " field." --