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

SF.net SVN: ledger-smb:[3591] trunk/LedgerSMB/RP.pm



Revision: 3591
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3591&view=rev
Author:   einhverfr
Date:     2011-07-29 19:38:45 +0000 (Fri, 29 Jul 2011)

Log Message:
-----------
Removing further dependencies on customer/vendor reports, and correcting conditional bug in tax report

Modified Paths:
--------------
    trunk/LedgerSMB/RP.pm

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2011-07-29 19:06:02 UTC (rev 3590)
+++ trunk/LedgerSMB/RP.pm	2011-07-29 19:38:45 UTC (rev 3591)
@@ -1774,6 +1774,7 @@
         $aclass = 1;
     } else {
         $aclass = 2;
+        $form->{arap} = 'ap';
     }
         $query .= qq|
 		SELECT c.entity_id AS ctid, 
@@ -1871,12 +1872,19 @@
     my $dbh = $form->{dbh};
 
     my $query = qq|
-		SELECT name, email, cc, bcc FROM $form->{ct} ct
-		 WHERE ct.entity_id = ?|;
+		SELECT e.name, c.contact, cc.class 
+                  FROM entity_credit_account eca
+                  JOIN entity USING (entity_id)
+                  JOIN eca_to_contact c ON (eca.credit_id = eca.id)
+                  JOIN contact_class cc ON (c.contact_class_id = cc.id)
+		 WHERE eca.id = ?
+                       AND cc.id BETWEEN 12 AND 17|;
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{"$form->{ct}_id"} );
-    ( $form->{ $form->{ct} }, $form->{email}, $form->{cc}, $form->{bcc} ) =
-      $sth->fetchrow_array();
+    while (my $ref = $sth->fetchrow_hashref('NAME_lc')){
+        $form->{ $form->{ct} } = $ref->{name};
+        $form->{ lc($ref->{class}) } = $ref->{contact};
+    }
 
     $dbh->commit;
 
@@ -2030,10 +2038,10 @@
         $table = 'customer';
         $account_class = 2;
         $ml    = -1;
-    }
-    if ( $form->{db} eq 'ap' ) {
+    } else {
         $table = 'vendor';
         $account_class = 1;
+        $form->{db} = 'ap';
     }
 
     my $query;


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