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

SF.net SVN: ledger-smb:[5707] trunk



Revision: 5707
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5707&view=rev
Author:   einhverfr
Date:     2013-04-06 13:31:54 +0000 (Sat, 06 Apr 2013)
Log Message:
-----------
Parsing errors fixed in X12 support classes

Modified Paths:
--------------
    trunk/LedgerSMB/X12/EDI850.pm
    trunk/LedgerSMB/X12/EDI894.pm
    trunk/LedgerSMB/X12.pm
    trunk/sql/modules/Company.sql

Modified: trunk/LedgerSMB/X12/EDI850.pm
===================================================================
--- trunk/LedgerSMB/X12/EDI850.pm	2013-03-24 14:15:00 UTC (rev 5706)
+++ trunk/LedgerSMB/X12/EDI850.pm	2013-04-06 13:31:54 UTC (rev 5707)
@@ -54,8 +54,8 @@
             when ('ISA'){
                 my ($segment) = $self->parser->get_loop_segments;
                 my @elements = split(/\Q$sep\E/, $segment);
-                $sender_idx = $elements[5]
-                $sender_id = $elements[6]
+                $sender_idx = $elements[5];
+                $sender_id = $elements[6];
             }
             when ('BEG'){
                 my ($segment) = $self->parser->get_loop_segments;
@@ -82,9 +82,9 @@
                 my ($segment) = $self->parser->get_loop_segments;
                 my @elements = split(/\Q$sep\E/, $segment);
                 my $invtotal;
-                $invtotal += ($form->{"qty_$_"} * $form->{"sellprice_$_"} 
+                $invtotal += ($form->{"qty_$_"} * $form->{"sellprice_$_"})
                      for (1 .. $i);
-                die 'Incorrect number of line items' if $i ~= $elements[1];
+                die 'Incorrect number of line items' if $i =~ $elements[1];
                 die 'Incorrect total' if $elements[2] and $elements[2] != $invtotal;
             }
         }

Modified: trunk/LedgerSMB/X12/EDI894.pm
===================================================================
--- trunk/LedgerSMB/X12/EDI894.pm	2013-03-24 14:15:00 UTC (rev 5706)
+++ trunk/LedgerSMB/X12/EDI894.pm	2013-04-06 13:31:54 UTC (rev 5707)
@@ -40,6 +40,7 @@
           builder => '_order');
 
 sub _order {
+    my ($self) = @_;
     my $sep = $self->parser->get_element_separator;
     my $form = new Form;
     my $sender_idx;
@@ -52,8 +53,8 @@
             when ('ISA'){
                 my ($segment) = $self->parser->get_loop_segments;
                 my @elements = split(/\Q$sep\E/, $segment);
-                $sender_idx = $elements[5]
-                $sender_id = $elements[6]
+                $sender_idx = $elements[5];
+                $sender_id = $elements[6];
             }
             when ('G82') { 
                 my ($segment) = $self->parser->get_loop_segments;
@@ -63,6 +64,8 @@
             }
             when ('G83') {
                 ++$i;
+                my ($segment) = $self->parser->get_loop_segments;
+                my @elements = split(/\Q$sep\E/, $segment);
                 $form->{"qty_$i"} = $elements[2];
                 $form->{"unit_$i"} = $elements[3];
                 $form->{"partnumber_$i"} = $elements[5];

Modified: trunk/LedgerSMB/X12.pm
===================================================================
--- trunk/LedgerSMB/X12.pm	2013-03-24 14:15:00 UTC (rev 5706)
+++ trunk/LedgerSMB/X12.pm	2013-04-06 13:31:54 UTC (rev 5707)
@@ -91,13 +91,13 @@
 
 has ISA => (is => 'ro', isa => 'HashRef[Any]', lazy => 1, builder => '_ISA');
 
-sub ISA {
+sub _ISA {
     my ($self) = @_;
     my @segments = $self->parser->get_loop_segments;
     @segments = $self->parser->get_loop_segments unless @segments;
     if ($segments[0] != 'ISA'){
         $self->parse;  # re-initialize parser, we don't have an ISA!
-        die 'No ISA';
+        die 'No ISA'; # Trappable error.
     }
 
     my $isa = {};
@@ -107,7 +107,7 @@
     push @keys, sprintf('ISA%02d', $_) for (1 .. 16);
 
     for my $key (@keys){
-       $isa->{$key} = unshift @segments;
+       $isa->{$key} = shift @segments;
     }
     return $isa;
 }
@@ -147,9 +147,13 @@
     my ($self) = @_;
     my $parser = new X12::Parser;
     my $file = $self->message;
+    return $parser;
 }
 
 sub parse {
+    my ($self) = @_;
+    my $file;
+    my $parser = $self->parser;
     if (!$self->is_message_file){
         $file = $LedgerSMB::Sysconfig::tempdir . '/' . $$ . '-' . $self->message;
         open TMPFILE, '>', $file;
@@ -175,7 +179,7 @@
 sub set_segement_sep {
     my ($self, $sep) = @_;
     # ick, ai don't like how this involves messing around with internals.
-    $self->parser->{_SEGMENT_SEPARATOR} = $seg;
+    $self->parser->{_SEGMENT_SEPARATOR} = $sep;
 }
 
 =back

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2013-03-24 14:15:00 UTC (rev 5706)
+++ trunk/sql/modules/Company.sql	2013-04-06 13:31:54 UTC (rev 5707)
@@ -298,49 +298,39 @@
 		LEFT JOIN entity_credit_account ec ON (ec.entity_id = e.id)
 		LEFT JOIN business b ON (ec.business_id = b.id)
 		WHERE coalesce(ec.entity_class,e.entity_class) = in_entity_class
-			AND (c.entity_id IN (select entity_id 
-                                               FROM entity_to_contact
-                                              WHERE contact ILIKE 
-                                                            ANY(t_contact_info))
-				                    OR '' ILIKE 
-                                                          ALL(t_contact_info)
-                                                    OR t_contact_info IS NULL)
+			AND (c.entity_id IN 
+                       (select entity_id 
+                          FROM entity_credit_account leca
+                          JOIN eca_to_contact le2c ON leca.id = le2c.credit_id
+                         WHERE contact ILIKE ANY(t_contact_info))
+                      OR '' ILIKE ALL(t_contact_info)
+                      OR t_contact_info IS NULL)
 			
 			AND ((in_address IS NULL AND in_city IS NULL 
 					AND in_state IS NULL 
 					AND in_country IS NULL)
 				OR (c.entity_id IN 
-				(select entity_id FROM entity_to_location
-				WHERE location_id IN 
-					(SELECT id FROM location
-					WHERE (line_one @@ plainto_tsquery(
-                                                              in_address)
-                                               OR
-					       line_two @@ plainto_tsquery(
-                                                              in_address)
-                                               OR
-					       line_three @@ plainto_tsquery(
-                                                              in_address))
-						AND city ILIKE 
-							'%' || 
-							coalesce(in_city, '') 
-							|| '%'
-						AND state ILIKE
-							'%' || 
-							coalesce(in_state, '') 
-							|| '%'
-						AND mail_code ILIKE
-							'%' || 
-							coalesce(in_mail_code,
-								'')
-							|| '%'
-						AND country_id IN 
-							(SELECT id FROM country
-							WHERE name ilike
-                                                              in_country
-								OR short_name
-								ilike 
-								in_country)))))
+				(select entity_id 
+                                   FROM entity_credit_account leca
+                                   JOIN eca_to_location le2a 
+                                     ON leca.id = le2a.credit_id
+                                   JOIN location ll ON le2a.location_id = ll.id
+			          WHERE (line_one @@ plainto_tsquery(in_address)
+                                        OR
+				        line_two @@ plainto_tsquery(in_address)
+                                        OR
+					line_three @@ plainto_tsquery(in_address))
+					AND city ILIKE 
+                                            '%' || coalesce(in_city, '') || '%'
+					AND state ILIKE
+					    '%' || coalesce(in_state, '') || '%'
+					AND mail_code ILIKE
+		   			    '%' || coalesce(in_mail_code, '') || '%'
+					AND country_id 
+                                            IN (SELECT id FROM country
+						 WHERE name ilike in_country
+						       OR short_name 
+                                                       ilike in_country)))
 			AND (ec.business_id = 
 				coalesce(in_business_id, ec.business_id)
 				OR (ec.business_id IS NULL 
@@ -739,7 +729,8 @@
 	UPDATE entity 
 	SET name = in_legal_name, 
 		entity_class = in_entity_class,
-		control_code = in_control_code
+		control_code = in_control_code,
+                country_id   = in_country_id
 	WHERE id = in_entity_id;
 
 	IF FOUND THEN

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