[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[5709] trunk
- Subject: SF.net SVN: ledger-smb:[5709] trunk
- From: ..hidden..
- Date: Sat, 06 Apr 2013 15:24:56 +0000
Revision: 5709
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5709&view=rev
Author: einhverfr
Date: 2013-04-06 15:24:56 +0000 (Sat, 06 Apr 2013)
Log Message:
-----------
X12 test cases committed
Modified Paths:
--------------
trunk/LedgerSMB/X12/EDI850.pm
Added Paths:
-----------
trunk/t/64-x12.t
Modified: trunk/LedgerSMB/X12/EDI850.pm
===================================================================
--- trunk/LedgerSMB/X12/EDI850.pm 2013-04-06 14:50:02 UTC (rev 5708)
+++ trunk/LedgerSMB/X12/EDI850.pm 2013-04-06 15:24:56 UTC (rev 5709)
@@ -61,7 +61,7 @@
my ($segment) = $self->parser->get_loop_segments;
my @elements = split(/\Q$sep\E/, $segment);
$form->{ordnumber} = $elements[3];
- $form->{transdate} = $elements[4];
+ $form->{transdate} = $elements[5];
$form->{transdate} =~ s/(\d{4})(\d{2})(\d{2})/$1-$2-$3/;
}
when ('PO1'){
@@ -69,8 +69,8 @@
my ($segment) = $self->parser->get_loop_segments;
my @elements = split(/\Q$sep\E/, $segment);
$form->{"qty_$i"} = $elements[2];
- $form->{"sellprice_$i"} = $elements[3];
- $form->{"partnumber_$i"} = $elements[6];
+ $form->{"sellprice_$i"} = $elements[4];
+ $form->{"partnumber_$i"} = $elements[7];
}
when ('PID'){
my ($segment) = $self->parser->get_loop_segments;
@@ -84,12 +84,11 @@
my $invtotal;
$invtotal += ($form->{"qty_$_"} * $form->{"sellprice_$_"})
for (1 .. $i);
- die 'Incorrect number of line items' if $i =~ $elements[1];
- die 'Incorrect total' if $elements[2] and $elements[2] != $invtotal;
+ #die 'Incorrect total: got ' . $elements[2] . " expected $invtotal" if $elements[2] and $elements[2] != $invtotal;
}
}
- return $form;
}
+ return $form;
}
__PACKAGE__->meta->make_immutable;
Added: trunk/t/64-x12.t
===================================================================
--- trunk/t/64-x12.t (rev 0)
+++ trunk/t/64-x12.t 2013-04-06 15:24:56 UTC (rev 5709)
@@ -0,0 +1,28 @@
+# X12 tests for LedgerSMB 1.4
+#
+# This provides a few very basic tests for parsing X12 docs
+# These include parsing the current test files, and creating 997 docs in
+# response.
+#
+use Test::More tests => 5;
+use LedgerSMB::Form;
+use LedgerSMB::X12;
+use LedgerSMB::X12::EDI850;
+use LedgerSMB::X12::EDI894;
+#use Carp::Always;
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+
+
+my $e850t1 = LedgerSMB::X12::EDI850->new(message => 't/data/sample_po.edi');
+#print Dumper($e850t1->order) . "\n";
+is($e850t1->order->{transdate}, '2009-05-08', 'Valid EDI 1, order date 2009-05-08');
+is($e850t1->order->{ordnumber}, '99AKDF9DAL393', 'valid EDI 1, ordnumber 99AKDF9DAL393');
+is($e850t1->order->{qty_1}, 100, 'Valid EDI 1, First line item quantity of 100');
+is($e850t1->order->{sellprice_1}, '100.00', 'Sell price of 100.00 for first line item');
+is($e850t1->order->{description_1}, 'GENERAL PURPOSE', 'Correct EDI description for line item 1');
+
+my $e850t2 = LedgerSMB::X12::EDI850->new(message => 't/data/sample_po1.edi');
+
+#print Dumper($e850t2->order) . "\n";
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.