[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5639] trunk/LedgerSMB/X12



Revision: 5639
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5639&view=rev
Author:   einhverfr
Date:     2013-01-31 06:34:32 +0000 (Thu, 31 Jan 2013)
Log Message:
-----------
X12 894 EDI support for 1.4

Modified Paths:
--------------
    trunk/LedgerSMB/X12/EDI850.pm

Added Paths:
-----------
    trunk/LedgerSMB/X12/EDI894.pm

Modified: trunk/LedgerSMB/X12/EDI850.pm
===================================================================
--- trunk/LedgerSMB/X12/EDI850.pm	2013-01-30 09:46:08 UTC (rev 5638)
+++ trunk/LedgerSMB/X12/EDI850.pm	2013-01-31 06:34:32 UTC (rev 5639)
@@ -6,8 +6,7 @@
 =head1 SYNOPSIS
 
  my $edi = LedgerSMB::X12::EDI850->new(message => 'message.edi');
- my $ISA = $edi->ISA;
- my @orders = $edi->orders;
+ my $form = $edi->order;
 
 =cut
 

Added: trunk/LedgerSMB/X12/EDI894.pm
===================================================================
--- trunk/LedgerSMB/X12/EDI894.pm	                        (rev 0)
+++ trunk/LedgerSMB/X12/EDI894.pm	2013-01-31 06:34:32 UTC (rev 5639)
@@ -0,0 +1,76 @@
+=head1 NAME
+
+LedgerSMB::X12::EDI894 - X12 894 support for LedgerSMB
+
+=head1 SYNPOSIS
+
+ my $edi = LedgerSMB::X12::EDI894->new(message => 'message.edi');
+ my $form = $edi->order;
+
+=cut
+
+package LedgerSMB::X12::EDI894;
+use Moose;
+use LedgerSMB::Form;
+use feature 'switch';
+extends 'LedgerSMB::X12';
+
+sub _config {
+    return 'LedgerSMB/X12/cf/894.cf';
+}
+
+=head1 DESCRIPTION
+
+The X12 894 provides for delivery notifications of orders or product returns.
+While it is not yet clear what we want to do with this, this does return the
+data in a $form object.
+
+=head1 PROPERTIES
+
+=over
+
+=item order
+
+This is an order hashref using the same data structures that a form screen
+would submit (flat format).
+
+=cut 
+
+has order => (is => 'ro', isa => 'HashRef[Any]', lazy => 1, 
+          builder => '_order');
+
+sub _order {
+    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 ('G82') { 
+                my ($segment) = $self->parser->get_loop_segments;
+                my @elements = split(/\Q$sep\E/, $segment);
+                $form->{transdate} = $elements[10];
+                $form->{ordnumber} = $elements[9];
+            }
+            when ('G83') {
+                ++$i;
+                $form->{"qty_$i"} = $elements[2];
+                $form->{"unit_$i"} = $elements[3];
+                $form->{"partnumber_$i"} = $elements[5];
+                $form->{"sellprice_$i"} = $elements[9];
+            }
+       }
+    }
+    return $form;
+}
+
+__PACKAGE__->meta->make_immutable;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.