Koha/t/Ediorder.t
Colin Campbell e2e9916348 Bug 7736: Support Ordering via Edifact EDI messages
Add support for processing incoming Edifact Quotes, Invoices
and order responses and generating and transmission of
Edifact Orders.
Basic workflow is that an incoming quote generates an aquisition
basket in Koha, with each line corresponding to an order record

The user can then generate an edifact order from this (or another)
basket, which is transferred to the vendor's site

The supplier generates an invoice on despatch and this will
result in corresponding invoices being generated in Koha
The orderlines on the invoice are receipted automatically.

We also support order response messages. This may include
simple order acknowledgements, supplier reports/amendments
on availability. Cancellation messages cause the koha order
to be cancelled, other messages are recorded against the order

Which messages are to be supported/processed is specifiable on a
vendor by vendor basis via the admin screens

You can also specify auto order i.e. to generate orders from quotes
without user intervention - This reflects existing
workflows where most work is done on the suppliers website
then generating a dummy quote

Received messages are stored in the edifact_messages table
and the original can be viewed via the online

Database changes are in installer/data/mysql/atomicchanges/edifact.sql
Note new perl dependencies:
    Net::SFTP:Foreign
    Text::Unidecode

Signed-off-by: Paul Johnson <p.johnson@staffs.ac.uk>

Signed-off-by: Sally Healey <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
2016-04-01 20:03:17 +00:00

56 lines
1.5 KiB
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw( $Bin );
use Test::More tests => 6;
BEGIN { use_ok('Koha::Edifact::Order') }
# The following tests are for internal methods but they could
# error spectacularly so yest
# Check that quoting is done correctly
#
my $processed_text =
Koha::Edifact::Order::encode_text(q{string containing ?,',:,+});
cmp_ok(
$processed_text, 'eq',
q{string containing ??,?',?:,?+},
'Outgoing text correctly quoted'
);
# extend above test to test chunking in imd_segment
#
my $code = '010';
my $data_to_encode = $processed_text;
my @segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode );
my $testseg = "IMD+L+010+:::$processed_text";
$testseg .= q{'}; # add segment terminator
cmp_ok( $segs[0], 'eq', $testseg, 'IMD segment correctly formed' );
$data_to_encode = 'A' x 35;
$data_to_encode .= 'B' x 35;
$data_to_encode .= 'C' x 10;
@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode );
cmp_ok(
$segs[0],
'eq',
q{IMD+L+010+:::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'},
'IMD segment correctly chunked'
);
cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC'},
'IMD segment correctly split across segments' );
$data_to_encode .= '??';
# this used to cause an infinite loop
@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 character at end' );