e2e9916348
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>
75 lines
2.3 KiB
Perl
Executable file
75 lines
2.3 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
use strict;
|
|
use warnings;
|
|
use FindBin qw( $Bin );
|
|
|
|
use Test::More tests => 19;
|
|
|
|
BEGIN { use_ok('Koha::Edifact') }
|
|
|
|
my $invoice_file = "$Bin/edi_testfiles/BLSINV337023.CEI";
|
|
|
|
my $invoice = Koha::Edifact->new( { filename => $invoice_file, } );
|
|
|
|
isa_ok( $invoice, 'Koha::Edifact' );
|
|
my $x = $invoice->interchange_header('sender');
|
|
my $control_reference = '337023';
|
|
is( $x, '5013546025078', "sender returned" );
|
|
|
|
$x = $invoice->interchange_header('recipient');
|
|
is( $x, '5013546121974', "recipient returned" );
|
|
$x = $invoice->interchange_header('datetime');
|
|
is( $x->[0], '140729', "datetime returned" );
|
|
$x = $invoice->interchange_header('interchange_control_reference');
|
|
is( $x, $control_reference, "interchange_control_reference returned" );
|
|
|
|
$x = $invoice->interchange_header('application_reference');
|
|
is( $x, 'INVOIC', "application_reference returned" );
|
|
$x = $invoice->interchange_trailer('interchange_control_count');
|
|
is( $x, 6, "interchange_control_count returned" );
|
|
|
|
my $messages = $invoice->message_array();
|
|
|
|
# check inv number from BGM
|
|
|
|
my $msg_count = @{$messages};
|
|
is( $msg_count, 6, 'correct message count returned' );
|
|
|
|
is( $messages->[0]->message_type, 'INVOIC', 'Message shows correct type' );
|
|
|
|
my $expected_date = '20140729';
|
|
is( $messages->[0]->message_date,
|
|
$expected_date, 'Message date correctly returned' );
|
|
is( $messages->[0]->tax_point_date,
|
|
$expected_date, 'Tax point date correctly returned' );
|
|
|
|
my $expected_invoicenumber = '01975490';
|
|
|
|
my $invoicenumber = $messages->[1]->docmsg_number();
|
|
|
|
is( $messages->[0]->buyer_ean, '5013546121974', 'Buyer ean correct' );
|
|
is( $messages->[0]->supplier_ean, '5013546025078', 'Supplier ean correct' );
|
|
|
|
is( $invoicenumber, $expected_invoicenumber,
|
|
'correct invoicenumber extracted' );
|
|
|
|
my $lines = $messages->[1]->lineitems();
|
|
|
|
my $num_lines = @{$lines};
|
|
|
|
is( $num_lines, 8, "Correct number of lineitems returned" );
|
|
|
|
# sample invoice was from an early version where order was formatted basketno/ordernumber
|
|
my $expected_ordernumber = '2818/74593';
|
|
|
|
my $ordernumber = $lines->[7]->ordernumber;
|
|
|
|
is( $ordernumber, $expected_ordernumber, 'correct ordernumber returned' );
|
|
|
|
my $lineprice = $lines->[7]->price_net;
|
|
|
|
is( $lineprice, 4.55, 'correct net line price returned' );
|
|
|
|
my $tax = $lines->[7]->tax;
|
|
|
|
is( $tax, 0, 'correct tax amount returned' );
|