Koha/t/Ediordrsp.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

59 lines
1.5 KiB
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw( $Bin );
use Test::More tests => 16;
BEGIN { use_ok('Koha::Edifact') }
my $filedir = "$Bin/edi_testfiles";
my @files = map { "$filedir/$_" }
( 'ordrsp1.CEA', 'ordrsp2.CEA', 'ordrsp3.CEA', 'ordrsp4.CEA' );
my @responses;
for my $filename (@files) {
my $order_response = Koha::Edifact->new( { filename => $filename, } );
isa_ok( $order_response, 'Koha::Edifact' );
push @responses, $order_response;
}
# tests on file 1
# Order accepted with amendments
my $order_response = $responses[0];
my $msg = $order_response->message_array();
my $no_of_msg = @{$msg};
is( $no_of_msg, 1, "Correct number of messages returned" );
isa_ok( $msg->[0], 'Koha::Edifact::Message' );
my $lines = $msg->[0]->lineitems();
my $no_of_lines = @{$lines};
is( $no_of_lines, 3, "Correct number of orderlines returned" );
#
is( $lines->[0]->ordernumber(), 'P28837', 'Line 1 correct ordernumber' );
is(
$lines->[0]->coded_orderline_text(),
'Not yet published',
'NP returned and translated'
);
is( $lines->[1]->ordernumber(), 'P28838', 'Line 2 correct ordernumber' );
is( $lines->[1]->action_notification(),
'cancelled', 'Cancelled action returned' );
is( $lines->[1]->coded_orderline_text(),
'Out of print', 'OP returned and translated' );
is( $lines->[2]->ordernumber(), 'P28846', 'Line 3 correct ordernumber' );
is( $lines->[2]->action_notification(),
'recorded', 'Accepted with change action returned' );
is( $lines->[0]->availability_date(), '19971120',
'Availability date returned' );