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

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



Revision: 3296
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3296&view=rev
Author:   einhverfr
Date:     2011-06-20 07:38:55 +0000 (Mon, 20 Jun 2011)

Log Message:
-----------
John Locke's patches to aging reports, payments, trial balance, and printing

Modified Paths:
--------------
    trunk/LedgerSMB/IS.pm
    trunk/LedgerSMB/RP.pm
    trunk/LedgerSMB/User.pm
    trunk/UI/payments/payments_detail.html

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2011-06-20 07:34:14 UTC (rev 3295)
+++ trunk/LedgerSMB/IS.pm	2011-06-20 07:38:55 UTC (rev 3296)
@@ -848,18 +848,19 @@
     my $query = qq|
 		SELECT c.customernumber, e.name, l.line_one as address1, 
 		       l.line_two as address2, l.city AS city,
-		       '' as state, l.mail_code AS zipcode, 
+		       l.state as state, l.mail_code AS zipcode, 
 		       country.name as country,
 		       '' as contact, '' as customerphone, '' as customerfax,
 		       '' AS customertaxnumber, sic_code AS sic, iban, 
-		       bic,startdate,enddate
+ 		       bic,eca.startdate,eca.enddate
 		  FROM customer c
 		  JOIN company cm ON c.entity_id = cm.entity_id
 		  JOIN entity e ON (c.entity_id = e.id)
-		  JOIN company_to_location cl ON cm.id = cl.company_id
-		  JOIN location l ON cl.location_id = l.id
-		  JOIN country ON l.country_id = country.id
-		 WHERE e.id = ? limit 1|;
+                    JOIN entity_credit_account eca ON e.id = eca.entity_id
+		  LEFT JOIN eca_to_location el ON eca.id = el.credit_id
+		  LEFT JOIN location l ON el.location_id = l.id
+		  LEFT JOIN country ON l.country_id = country.id
+		 WHERE eca.id = ? limit 1|;
 
 
     my $sth = $dbh->prepare($query);

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2011-06-20 07:34:14 UTC (rev 3295)
+++ trunk/LedgerSMB/RP.pm	2011-06-20 07:38:55 UTC (rev 3296)
@@ -1362,7 +1362,7 @@
 				         SUM(ac.amount::$amount_cast) AS amount,
 				         g.description, c.contra
 				    FROM acc_trans ac
-				    JOIN chart c ON (ac.chart_id = c.id)
+				    JOIN chart c ON (ac.chart_id = c.id AND c.charttype = 'A')
 				    JOIN gifi g ON (c.gifi_accno = g.accno)
 				         $dpt_join
 				    JOIN (SELECT id, approved FROM gl UNION
@@ -1384,7 +1384,7 @@
 				         SUM(ac.amount::$amount_cast) AS amount,
 				         c.description, c.contra
 				    FROM acc_trans ac
-				    JOIN chart c ON (ac.chart_id = c.id)
+				    JOIN chart c ON (ac.chart_id = c.id AND c.charttype = 'A')
 				         $dpt_join
 				    JOIN (SELECT id, approved FROM gl UNION
 				          SELECT id, approved FROM ar UNION
@@ -1496,7 +1496,7 @@
                                         UNION ALL
                                         select id, approved FROM ar) g
                                         ON (g.id = ac.trans_id)
-                                JOIN chart c ON (c.id = ac.chart_id)
+                                JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
 				LEFT JOIN yearend y ON (ac.trans_id = y.trans_id)
                                 WHERE (ac.transdate <= $dateto OR $dateto IS NULL)
                                         AND ac.approved AND g.approved
@@ -1546,7 +1546,7 @@
 			  SELECT g.accno, g.description, c.category,
 			         SUM(ac.amount::$amount_cast) AS amount, c.contra
 			    FROM acc_trans ac
-			    JOIN chart c ON (c.id = ac.chart_id)
+			    JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
 			    JOIN gifi g ON (c.gifi_accno = g.accno)
 			         $dpt_join
 			    JOIN (SELECT id, approved FROM gl UNION
@@ -1566,7 +1566,7 @@
 			  SELECT c.accno, c.description, c.category,
 			         SUM(ac.amount::$amount_cast) AS amount, c.contra
 			    FROM acc_trans ac
-			    JOIN chart c ON (c.id = ac.chart_id)
+			    JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
 			         $dpt_join
 			    JOIN (SELECT id, approved FROM gl UNION
 			          SELECT id, approved FROM ar UNION
@@ -1597,7 +1597,7 @@
 			         AND ($approved OR gl.approved)
 		                 AND c.accno = ?) AS debit,
 		       (SELECT SUM(ac.amount::$amount_cast) FROM acc_trans ac
-		          JOIN chart c ON (c.id = ac.chart_id)
+		          JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
 		               $dpt_join
 			  JOIN (SELECT id, approved FROM gl UNION
 			        SELECT id, approved FROM ar UNION
@@ -1613,7 +1613,7 @@
             $query = qq|
 		SELECT (SELECT SUM(ac.amount::$amount_cast) * -1
 		          FROM acc_trans ac
-		          JOIN chart c ON (c.id = ac.chart_id)
+		          JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
 		               $dpt_join
 		         WHERE $where $dpt_where $project AND ac.amount < 0
 				         AND ($approved OR ac.approved)
@@ -1621,7 +1621,7 @@
 		
 		       (SELECT SUM(ac.amount::$amount_cast)
 		          FROM acc_trans ac
-		          JOIN chart c ON (c.id = ac.chart_id)
+		          JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
 		               $dpt_join
 		         WHERE $where $dpt_where $project AND ac.amount > 0
 				         AND ($approved OR ac.approved)
@@ -1790,19 +1790,19 @@
 		       CASE WHEN 
 		                 EXTRACT(days FROM age(?, a.transdate)/30) 
 		                 = 0
-		                 THEN (sum(p.due)) ELSE 0 END
+		                 THEN (sum(p.due) * -1) ELSE 0 END
 		            as c0, 
 		       CASE WHEN EXTRACT(days FROM age(?, a.transdate)/30)
 		                 = 1
-		                 THEN (sum(p.due)) ELSE 0 END
+		                 THEN (sum(p.due) * -1) ELSE 0 END
 		            as c30, 
 		       CASE WHEN EXTRACT(days FROM age(?, a.transdate)/30)
 		                 = 2
-		                 THEN (sum(p.due)) ELSE 0 END
+		                 THEN (sum(p.due) * -1) ELSE 0 END
 		            as c60, 
 		       CASE WHEN EXTRACT(days FROM age(?, a.transdate)/30)
 		                 > 2
-		                 THEN (sum(p.due)) ELSE 0 END
+		                 THEN (sum(p.due) * -1) ELSE 0 END
 		            as c90, 
 		       a.duedate, a.invoice, a.id, a.curr,
 		       (SELECT $buysell FROM exchangerate e
@@ -1828,7 +1828,8 @@
 		 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|;
+                       a.curr, a.ponumber, a.notes, c.language_code
+		HAVING sum(p.due) <> 0|;
 
     $query .= qq| ORDER BY ctid, curr, $transdate, invnumber|;
     $sth = $dbh->prepare($query) || $form->dberror($query);

Modified: trunk/LedgerSMB/User.pm
===================================================================
--- trunk/LedgerSMB/User.pm	2011-06-20 07:34:14 UTC (rev 3295)
+++ trunk/LedgerSMB/User.pm	2011-06-20 07:38:55 UTC (rev 3296)
@@ -184,6 +184,10 @@
     my $sth = $dbh->prepare($query);
     $sth->execute($lsmb->{login});
     $myconfig = $sth->fetchrow_hashref(NAME_lc);
+    $sth = $dbh->prepare("SELECT value FROM defaults WHERE setting_key = 'templates'");
+    $sth->execute();
+    ($templates) = $sth->fetchrow_array() || 'demo';
+    $myconfig->{templates} = "templates/$templates";
     return $myconfig;
 }
 

Modified: trunk/UI/payments/payments_detail.html
===================================================================
--- trunk/UI/payments/payments_detail.html	2011-06-20 07:34:14 UTC (rev 3295)
+++ trunk/UI/payments/payments_detail.html	2011-06-20 07:38:55 UTC (rev 3296)
@@ -208,15 +208,15 @@
 			value = r.contact_id
 		} ?>
 		<?lsmb IF action == "update_payments" -?>
-			<?lsmb IF !${"id_$r.contact_id"} -?>
-				<?lsmb r.unselected = 1 -?>
+			<?lsmb IF ${"id_$r.contact_id"} -?>
+				<?lsmb r.selected = 1 -?>
 			<?lsmb END # IF !${"id_$r.contact_id"} -?>
 		<?lsmb END # IF action ... -?>
 		<?lsmb INCLUDE input element_data = {
 			type = "checkbox"
 			name = "id_$r.contact_id"
 			value = r.contact_id
-			checked = (r.unselected) ? undef : "checked" 
+			checked = (r.selected) ? "checked" : undef 
 			
 		} ?>
 		<?lsmb r.econtrol_code ?> -- 


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