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

SF.net SVN: ledger-smb:[3185] trunk/LedgerSMB/AA.pm



Revision: 3185
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3185&view=rev
Author:   einhverfr
Date:     2011-05-27 03:25:05 +0000 (Fri, 27 May 2011)

Log Message:
-----------
Patch 2969273

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

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2011-05-27 03:19:11 UTC (rev 3184)
+++ trunk/LedgerSMB/AA.pm	2011-05-27 03:25:05 UTC (rev 3185)
@@ -37,7 +37,10 @@
 
 package AA;
 use LedgerSMB::Sysconfig;
+use LedgerSMB::Log;
 
+my $logger = Log::Log4perl->get_logger("AA");
+
 =pod
 
 =head1 post_transaction()
@@ -736,6 +739,7 @@
 				 WHERE trans_id = ?
 				   AND spoolfile IS NOT NULL|;
 
+    $logger->debug("query: $query");
     my $sth = $dbh->prepare($query);
     $sth->execute( $form->{id} ) || $form->dberror($query);
 
@@ -799,7 +803,7 @@
         $paid = qq|
 			SELECT SUM(ac.amount) * -1 * $ml
 			  FROM acc_trans ac
-			  JOIN chart c ON (c.id = ac.chart_id)
+			  JOIN chart c ON (c.id = ac.chart_id AND charttype = 'A')
 			 WHERE ac.trans_id = a.id
 			       AND ($approved OR ac.approved)
 			       AND (c.link LIKE '%${ARAP}_paid%' 
@@ -822,7 +826,8 @@
 
         $acc_trans_join = qq| 
 			     JOIN acc_trans ac ON (a.id = ac.trans_id)
-			     JOIN chart c ON (c.id = ac.chart_id)
+			     JOIN chart c ON (c.id = ac.chart_id 
+                                              AND charttype = 'A')
 			LEFT JOIN invoice i ON (i.id = ac.invoice_id)|;
     }
     my $query;
@@ -851,7 +856,8 @@
 		     JOIN entity_credit_account vc ON (a.entity_credit_account = vc.id)
 		     JOIN acc_trans acs ON (acs.trans_id = a.id)
 		     JOIN entity vce ON (vc.entity_id = vce.id)
-		     JOIN chart c ON (acs.chart_id = c.id)
+		     JOIN chart c ON (acs.chart_id = c.id 
+                                     AND charttype = 'A')
 		LEFT JOIN exchangerate ex ON (ex.curr = a.curr
 		          AND ex.transdate = a.transdate)
 		LEFT JOIN department d ON (a.department_id = d.id)
@@ -1070,7 +1076,7 @@
         $where .= qq|
 			AND a.id IN (SELECT ac.trans_id
 			               FROM acc_trans ac
-			               JOIN chart c ON (c.id = ac.chart_id)
+			               JOIN chart c ON (c.id = ac.chart_id AND charttype = 'A')
 			              WHERE a.id = ac.trans_id
 			                    AND c.accno = $accno)|;
     }
@@ -1315,7 +1321,7 @@
 		SELECT c.accno
 		  FROM chart c
 		  JOIN $form->{vc}tax ct ON (ct.chart_id = c.id)
-		 WHERE ct.$form->{vc}_id = ?|;
+		 WHERE c.charttype = 'A' AND ct.$form->{vc}_id = ?|;
 
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{"$form->{vc}_id"} ) || $form->dberror($query);
@@ -1375,7 +1381,7 @@
 			     FROM chart c
 			     JOIN acc_trans ac ON (ac.chart_id = c.id)
 			     JOIN $arap a ON (a.id = ac.trans_id)
-			    WHERE a.entity_id = ?
+			    WHERE c.charttype = 'A' AND a.entity_id = ?
 			          AND a.id = (SELECT max(id) 
 			                         FROM $arap
 			                        WHERE entity_id = 


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