diff --git a/Koha/EDI.pm b/Koha/EDI.pm index 1a15507171..ba1057b06b 100644 --- a/Koha/EDI.pm +++ b/Koha/EDI.pm @@ -80,6 +80,16 @@ sub create_edi_order { my $ean_obj = $schema->resultset('EdifactEan')->search($ean_search_keys)->single; + # If no branch specific each can be found, look for a default ean + unless ($ean_obj) { + $ean_obj = $schema->resultset('EdifactEan')->search( + { + ean => $ean, + branchcode => undef, + } + )->single; + } + my $dbh = C4::Context->dbh; my $arr_ref = $dbh->selectcol_arrayref( 'select id from edifact_messages where basketno = ? and message_type = \'QUOTE\'', diff --git a/admin/edi_ean_accounts.pl b/admin/edi_ean_accounts.pl index d6e8d953c2..2bceac578a 100755 --- a/admin/edi_ean_accounts.pl +++ b/admin/edi_ean_accounts.pl @@ -69,7 +69,7 @@ else { if ($change) { $schema->resultset('EdifactEan')->find($id)->update( { - branchcode => scalar $input->param('branchcode'), + branchcode => scalar $input->param('branchcode') || undef, description => scalar $input->param('description'), ean => scalar $input->param('ean'), id_code_qualifier => scalar $input->param('id_code_qualifier'), @@ -79,7 +79,7 @@ else { else { my $new_ean = $schema->resultset('EdifactEan')->new( { - branchcode => scalar $input->param('branchcode'), + branchcode => scalar $input->param('branchcode') || undef, description => scalar $input->param('description'), ean => scalar $input->param('ean'), id_code_qualifier => scalar $input->param('id_code_qualifier'), diff --git a/installer/data/mysql/atomicupdate/bug_21417.perl b/installer/data/mysql/atomicupdate/bug_21417.perl new file mode 100644 index 0000000000..952e5b6bd3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_21417.perl @@ -0,0 +1,7 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "ALTER TABLE edifact_ean MODIFY branchcode VARCHAR(10) NULL DEFAULT NULL" ); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 8844a8f71d..7331493963 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3741,7 +3741,7 @@ DROP TABLE IF EXISTS edifact_ean; CREATE TABLE IF NOT EXISTS edifact_ean ( ee_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, description VARCHAR(128) NULL DEFAULT NULL, - branchcode VARCHAR(10) NOT NULL REFERENCES branches (branchcode), + branchcode VARCHAR(10) NULL DEFAULT NULL REFERENCES branches (branchcode), ean VARCHAR(15) NOT NULL, id_code_qualifier VARCHAR(3) NOT NULL DEFAULT '14', CONSTRAINT efk_branchcode FOREIGN KEY ( branchcode ) REFERENCES branches ( branchcode ) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_ean_accounts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_ean_accounts.tt index 2620bf0ed0..675f7e3e99 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_ean_accounts.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_ean_accounts.tt @@ -68,6 +68,7 @@