From 05b2acc4507a109ac5f7af7fe92b2b03d536ac57 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 18 Feb 2022 14:23:21 +0000 Subject: [PATCH] Bug 30130: Add standard to edi account definition This patch add a 'standard' field to the edifact account configuration area to allow setting the message standard as either 'EDItEUR' or 'BiC'. This just replaces the currently hard coded hash of SAN's in Koha::Edifact::Order to distinguish between the two standards instead of requireing a bug submission per vender san we identify to be a BiC type vendor. --- Koha/Edifact/Order.pm | 20 ++++++------------- Koha/Schema/Result/VendorEdiAccount.pm | 13 ++++++++++-- admin/edi_accounts.pl | 11 ++++++++++ .../data/mysql/atomicupdate/bug_30130.pl | 19 ++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + .../prog/en/modules/admin/edi_accounts.tt | 18 +++++++++++++++++ 6 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_30130.pl diff --git a/Koha/Edifact/Order.pm b/Koha/Edifact/Order.pm index f21a7a8b76..548c62c429 100644 --- a/Koha/Edifact/Order.pm +++ b/Koha/Edifact/Order.pm @@ -263,7 +263,7 @@ sub order_msg_header { push @header, beginning_of_message( $self->{basket}->basketno, - $self->{recipient}->san, + $self->{recipient}->standard, $self->{is_response} ); @@ -297,29 +297,21 @@ sub order_msg_header { sub beginning_of_message { my $basketno = shift; - my $supplier_san = shift; + my $standard = shift; my $response = shift; my $document_message_no = sprintf '%011d', $basketno; - # Peters & Bolinda use the BIC recommendation to use 22V a code not in Edifact - # If the order is in response to a quote - my %bic_sans = ( - '5013546025065' => 'Peters', - '9377779308820' => 'Bolinda', - ); - # my $message_function = 9; # original 7 = retransmission # message_code values - # 220 prder + # 220 order # 224 rush order # 228 sample order :: order for approval / inspection copies # 22C continuation order for volumes in a set etc. # my $message_code = '220'; - if ( exists $bic_sans{$supplier_san} && $response ) { - return "BGM+22V+$document_message_no+9$seg_terminator"; - } - return "BGM+220+$document_message_no+9$seg_terminator"; + # If the order is in response to a quote and we're dealing with a BIC supplier + my $code = ( $response && ( $standard eq 'BIC' ) ) ? '22V' : '220'; + return "BGM+$code+$document_message_no+9$seg_terminator"; } sub name_and_address { diff --git a/Koha/Schema/Result/VendorEdiAccount.pm b/Koha/Schema/Result/VendorEdiAccount.pm index e8e7d810fc..bb463a89b3 100644 --- a/Koha/Schema/Result/VendorEdiAccount.pm +++ b/Koha/Schema/Result/VendorEdiAccount.pm @@ -80,6 +80,13 @@ __PACKAGE__->table("vendor_edi_accounts"); is_nullable: 1 size: 20 +=head2 standard + + data_type: 'varchar' + default_value: 'EUR' + is_nullable: 1 + size: 3 + =head2 id_code_qualifier data_type: 'varchar' @@ -160,6 +167,8 @@ __PACKAGE__->add_columns( { data_type => "mediumtext", is_nullable => 1 }, "san", { data_type => "varchar", is_nullable => 1, size => 20 }, + "standard", + { data_type => "varchar", default_value => "EUR", is_nullable => 1, size => 3 }, "id_code_qualifier", { data_type => "varchar", default_value => 14, is_nullable => 1, size => 3 }, "transport", @@ -250,8 +259,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TtWuTpP4Ac6/+T6OPMSsRA +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-02-18 14:08:05 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yDbPFtwV40n3o+fFoxR99g # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/admin/edi_accounts.pl b/admin/edi_accounts.pl index 293f7ef666..2da002e489 100755 --- a/admin/edi_accounts.pl +++ b/admin/edi_accounts.pl @@ -76,6 +76,7 @@ else { upload_directory => scalar $input->param('upload_directory'), download_directory => scalar $input->param('download_directory'), san => scalar $input->param('san'), + standard => scalar $input->param('standard'), transport => scalar $input->param('transport'), quotes_enabled => $input->param('quotes_enabled') ? 1 : 0, invoices_enabled => $input->param('invoices_enabled') ? 1 : 0, @@ -133,6 +134,16 @@ $template->param( code => '92', description => 'Assigned by buyer', }, + ], + standards => [ + { + code => 'BIC', + description => 'BiC' + }, + { + code => 'EUR', + description => 'EDItEUR' + } ] ); diff --git a/installer/data/mysql/atomicupdate/bug_30130.pl b/installer/data/mysql/atomicupdate/bug_30130.pl new file mode 100644 index 0000000000..58669f6fbd --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_30130.pl @@ -0,0 +1,19 @@ +use Modern::Perl; + +return { + bug_number => "30130", + description => "A standard to edi_account", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + unless ( column_exists('vendor_edi_accounts', 'standard') ) { + $dbh->do(q{ + ALTER TABLE vendor_edi_accounts ADD standard varchar(3) DEFAULT 'EUR' AFTER san + }); + + $dbh->do(q{ + UPDATE vendor_edi_accounts SET standard = 'BIC' WHERE san IN ( '5013546025065', '9377779308820' ) + }); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 4411ae7604..49f4ac8a60 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -5230,6 +5230,7 @@ CREATE TABLE `vendor_edi_accounts` ( `download_directory` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `upload_directory` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `san` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `standard` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT 'EUR', `id_code_qualifier` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT '14', `transport` varchar(6) COLLATE utf8mb4_unicode_ci DEFAULT 'FTP', `quotes_enabled` tinyint(1) NOT NULL DEFAULT 0, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt index 51d8ec0019..ce4669cd86 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt @@ -185,6 +185,22 @@ EDI accounts › Administration › Koha +
  • + + +
  • [% IF account.quotes_enabled %] @@ -284,6 +300,7 @@ EDI accounts › Administration › Koha Upload directory Qualifier SAN + Standard Quotes Orders Invoices @@ -311,6 +328,7 @@ EDI accounts › Administration › Koha ([% account.id_code_qualifier | html %]) [% account.san | html %] + [% account.standard | html %] [% IF account.quotes_enabled %] Yes [% ELSE %] -- 2.20.1