[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[5637] trunk
- Subject: SF.net SVN: ledger-smb:[5637] trunk
- From: ..hidden..
- Date: Wed, 30 Jan 2013 09:40:18 +0000
Revision: 5637
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5637&view=rev
Author: einhverfr
Date: 2013-01-30 09:40:17 +0000 (Wed, 30 Jan 2013)
Log Message:
-----------
X12 850 parser ready for testing, also adding EDI-related contact classes
Modified Paths:
--------------
trunk/LedgerSMB/X12/EDI850.pm
trunk/sql/Pg-database.sql
trunk/sql/modules/Fixes.sql
Modified: trunk/LedgerSMB/X12/EDI850.pm
===================================================================
--- trunk/LedgerSMB/X12/EDI850.pm 2013-01-28 07:24:04 UTC (rev 5636)
+++ trunk/LedgerSMB/X12/EDI850.pm 2013-01-30 09:40:17 UTC (rev 5637)
@@ -13,6 +13,8 @@
package LedgerSMB::X12::EDI850;
use Moose;
+use LedgerSMB::Form;
+use feature 'switch';
extends 'LedgerSMB::X12';
sub _config {
@@ -41,10 +43,54 @@
sub _order {
my ($self) = $_;
$self->parse;
- eval {$self->ISA}; # if throws error, ignore
- $self->parse;
+ my $sep = $self->parser->get_element_separator;
+ my $form = new Form;
+ my $sender_idx;
+ my $sender_id;
+
+ my $i = 0;
-
+ while (my $loop = $self->parser->get_next_loop){
+ given ($loop) {
+ when ('ISA'){
+ my ($segment) = $self->parser->get_loop_segments;
+ my @elements = split(/\Q$sep\E/, $segment);
+ $sender_idx = $elements[5]
+ $sender_id = $elements[6]
+ }
+ when ('BEG'){
+ my ($segment) = $self->parser->get_loop_segments;
+ my @elements = split(/\Q$sep\E/, $segment);
+ $form->{ordnumber} = $elements[3];
+ $form->{transdate} = $elements[4];
+ $form->{transdate} =~ s/(\d{4})(\d{2})(\d{2})/$1-$2-$3/;
+ }
+ when ('PO1'){
+ ++$i;
+ 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];
+ }
+ when ('PID'){
+ my ($segment) = $self->parser->get_loop_segments;
+ my @elements = split(/\Q$sep\E/, $segment);
+ $form->{"description_$i"} = $elements[5];
+ }
+ when ('CTT'){
+ # Perform checks and error if does not work.
+ my ($segment) = $self->parser->get_loop_segments;
+ my @elements = split(/\Q$sep\E/, $segment);
+ 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;
+ }
+ }
+ return $form;
+ }
}
Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql 2013-01-28 07:24:04 UTC (rev 5636)
+++ trunk/sql/Pg-database.sql 2013-01-30 09:40:17 UTC (rev 5637)
@@ -796,8 +796,10 @@
INSERT INTO contact_class (id,class) values (15,'Billing Email');
INSERT INTO contact_class (id,class) values (16,'Billing CC');
INSERT INTO contact_class (id,class) values (17,'Billing BCC');
+INSERT INTO contact_class (id,class) values (18,'EDI Interchange ID');
+INSERT INTO contact_class (id,class) values (19,'EDI ID');
-SELECT SETVAL('contact_class_id_seq',17);
+SELECT SETVAL('contact_class_id_seq',19);
CREATE TABLE entity_to_contact (
entity_id integer not null references entity(id) ON DELETE CASCADE,
Modified: trunk/sql/modules/Fixes.sql
===================================================================
--- trunk/sql/modules/Fixes.sql 2013-01-28 07:24:04 UTC (rev 5636)
+++ trunk/sql/modules/Fixes.sql 2013-01-30 09:40:17 UTC (rev 5637)
@@ -154,3 +154,15 @@
COMMIT;
+
+BEGIN;
+
+--- EDI contact fixes
+
+
+INSERT INTO contact_class (id,class) values (18,'EDI Interchange ID');
+INSERT INTO contact_class (id,class) values (19,'EDI ID');
+
+SELECT SETVAL('contact_class_id_seq',19);
+
+COMMIT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.