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

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



Revision: 2972
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2972&view=rev
Author:   einhverfr
Date:     2010-03-18 17:46:59 +0000 (Thu, 18 Mar 2010)

Log Message:
-----------
Partial fix to AR/AP aging report
Fix for batches not posting
fix for SIC's not saving

Modified Paths:
--------------
    trunk/LedgerSMB/AM.pm
    trunk/LedgerSMB/RP.pm
    trunk/scripts/vouchers.pl

Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm	2010-03-18 00:46:07 UTC (rev 2971)
+++ trunk/LedgerSMB/AM.pm	2010-03-18 17:46:59 UTC (rev 2972)
@@ -911,7 +911,7 @@
 			   SET code = ?,
 			       sictype = ?,
 			       description = ?
-			 WHERE code = ?)|;
+			 WHERE code = ?|;
         push @queryargs, $form->{id};
 
     }

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2010-03-18 00:46:07 UTC (rev 2971)
+++ trunk/LedgerSMB/RP.pm	2010-03-18 17:46:59 UTC (rev 2972)
@@ -1748,7 +1748,7 @@
     # for each company that has some stuff outstanding
     $form->{currencies} ||= ":";
 
-    $where = qq|a.paid != a.amount|;
+    $where = qq|true|;
     
     if ( $form->{"$form->{ct}_id"} ) {
         $where .= qq| AND c.entity_id = | . $dbh->quote( $form->{"$form->{ct}_id"} );
@@ -1776,24 +1776,24 @@
 	               '' as $form->{ct}phone, 
 		       '' as $form->{ct}fax,
 		       '' as $form->{ct}taxnumber,
-	               a.invnumber, a.transdate, a.till, a.ordnumber, 
+	               a.invnumber, a.transdate, a.ordnumber, 
 		       a.ponumber, a.notes, c.language_code, 
 		       CASE WHEN 
-		                 EXTRACT(days FROM age(a.transdate)/30) 
+		                 EXTRACT(days FROM age(?, a.transdate)/30) 
 		                 = 0
-		                 THEN (sum(p.amount)) ELSE 0 END
+		                 THEN (sum(p.due)) ELSE 0 END
 		            as c0, 
-		       CASE WHEN EXTRACT(days FROM age(a.transdate)/30)
+		       CASE WHEN EXTRACT(days FROM age(?, a.transdate)/30)
 		                 = 1
-		                 THEN (sum(p.amount)) ELSE 0 END
+		                 THEN (sum(p.due)) ELSE 0 END
 		            as c30, 
-		       CASE WHEN EXTRACT(days FROM age(a.transdate)/30)
+		       CASE WHEN EXTRACT(days FROM age(?, a.transdate)/30)
 		                 = 2
-		                 THEN (sum(p.amount)) ELSE 0 END
+		                 THEN (sum(p.due)) ELSE 0 END
 		            as c60, 
-		       CASE WHEN EXTRACT(days FROM age(a.transdate)/30)
+		       CASE WHEN EXTRACT(days FROM age(?, a.transdate)/30)
 		                 > 2
-		                 THEN (sum(p.amount)) ELSE 0 END
+		                 THEN (sum(p.due)) ELSE 0 END
 		            as c90, 
 		       a.duedate, a.invoice, a.id, a.curr,
 		       (SELECT $buysell FROM exchangerate e
@@ -1801,25 +1801,31 @@
 		              AND e.transdate = a.transdate) 
 		       AS exchangerate
 		  FROM $form->{arap} a
-		  JOIN (SELECT acc_trans.trans_id, 
+		  JOIN (SELECT acc_trans.trans_id,
 		                 sum(CASE WHEN $aclass = 1 THEN amount
 		                          WHEN $aclass = 2 THEN amount * -1
 		                     END) AS due 
 		            FROM acc_trans 
 		            JOIN account coa ON (coa.id = acc_trans.chart_id)
                             JOIN account_link al ON (al.account_id = coa.id)
-		           WHERE ((al.description = 'AP' AND in_account_class = 1)
-		                 OR (al.description = 'AR' AND in_account_class = 2))
-			   AND approved IS TRUE
+		           WHERE (al.description = |. 
+                                 $dbh->quote(uc($form->{arap})) . qq|)
+                                 AND approved IS TRUE
+                                 AND transdate <= ?
 		        GROUP BY acc_trans.trans_id) p ON (a.id = p.trans_id)
-		  JOIN entity_credit_account c USING (entity_id)
-		  JOIN company e USING (entity_id)
-		  WHERE $where|;
+		  JOIN entity_credit_account c 
+                       ON (a.entity_credit_account = c.id)
+		  JOIN company e ON e.entity_id = c.entity_id
+		 WHERE $where
+              GROUP BY c.entity_id, c.meta_number, e.legal_name, a.invnumber,
+                       a.transdate, a.ordnumber, a.duedate, a.invoice, a.id,
+                       a.curr, a.ponumber, a.notes, c.language_code|;
 
     $query .= qq| ORDER BY ctid, curr, $transdate, invnumber|;
     $sth = $dbh->prepare($query) || $form->dberror($query);
 
-    $sth->execute();
+    $sth->execute($form->{todate}, $form->{todate}, $form->{todate}, 
+                  $form->{todate}, $form->{todate});
 
     while ( $ref = $sth->fetchrow_hashref('NAME_lc') ) {
 		    $form->db_parse_numeric(sth=>$sth, hashref=>$ref);

Modified: trunk/scripts/vouchers.pl
===================================================================
--- trunk/scripts/vouchers.pl	2010-03-18 00:46:07 UTC (rev 2971)
+++ trunk/scripts/vouchers.pl	2010-03-18 17:46:59 UTC (rev 2972)
@@ -412,7 +412,7 @@
 }
 
 sub list_batches_batch_approve {
-    get_batch_batch_approve(@_);
+    batch_approve(@_);
 }
 
 sub get_batch_batch_approve {


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