Bug 21417: EDI ordering fails when basket and EAN libraries do not match

When clicking Create EDIFACT Order on /acqui/basket.pl, an EDIFACT message will not be generated if aqbasket.branch does not match edifact_ean.branchcode. This failure does not generate any sort of error message, it just fails to produce a message.

We should allow ean's to not require a branch to be set, then if we don't find a branch specific each, we can look for the default version of the ean.

Test Plan:
1) Apply this patch set
2) Run updatedatabase
3) Verify you can create a Library EAN without setting a branchcode for it
4) Verify you can use this EAN to send an EDI order where the basket has a branchcode set

Signed-off-by: Colin Campbell <colin.campbell@ptfs-europe.com>
Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 18674cfde3)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit c2537558e0)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Kyle M Hall 2018-09-27 06:51:27 -04:00 committed by Fridolin Somers
parent 68c83c4c86
commit c8efbde5ed
5 changed files with 21 additions and 3 deletions

View File

@ -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\'',

View File

@ -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'),

View File

@ -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";
}

View File

@ -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 )

View File

@ -68,6 +68,7 @@
<li>
<label for="branchcode">Library: </label>
<select name="branchcode" id="branchcode">
<option value="">All libraries</option>
[% FOREACH branch IN branches %]
[% IF branch.branchcode == ean.branch.branchcode %]
<option value="[% branch.branchcode %]" selected="selected">[% branch.branchname %]</option>