diff --git a/Koha/Edifact/Order.pm b/Koha/Edifact/Order.pm index 9822526a3b..062a2f930a 100644 --- a/Koha/Edifact/Order.pm +++ b/Koha/Edifact/Order.pm @@ -512,7 +512,7 @@ sub imd_segment { } $odd = !$odd; } - if ( @segs && $segs[-1] !~ m/$seg_terminator$/o ) { + if ( @segs && $segs[-1] !~ m/[^?]$seg_terminator$/o ) { $segs[-1] .= $seg_terminator; } return @segs; diff --git a/t/Ediorder.t b/t/Ediorder.t index 50926a9127..ceeb647371 100755 --- a/t/Ediorder.t +++ b/t/Ediorder.t @@ -3,7 +3,7 @@ use strict; use warnings; use FindBin qw( $Bin ); -use Test::More tests => 8; +use Test::More tests => 10; BEGIN { use_ok('Koha::Edifact::Order') } @@ -55,6 +55,17 @@ $data_to_encode .= '??'; cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, 'IMD segment deals with quoted character at end' ); +# special case for text ending in apostrophe e.g. nuthin' +$data_to_encode .= q{?'}; +@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); +cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC???''}, + 'IMD segment deals with quoted apostrophe at end' ); + +$data_to_encode =~s/\?'$//; +@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); +cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, + 'IMD segment deals with apostrophe preceded by quoted ? at end' ); + my $isbn = '3540556753'; my $ean = '9783540556756';