Ok. This is the last one of the set from yesterday... Couple bug fixes
to get the right account, as well as a change to the behavior of Cash ->
Vouchers -> [Payments|Receipts] to default to unchecked instead of
checked...

Would be nice to have a javascript "check all"/"Uncheck all" function
added to these tables with checkboxes... haven't gotten there yet!

I did take out a bunch of pattern changes related to num2text, a commit
from December that I reverted because it broke generating correct text
for numbers in check printing. I think these may be related to the GMP
processing, though, so I'm holding off on submitting until I determine
whether it's still an issue...

Cheers
John Locke
http://freelock.com
diff --git LedgerSMB/IS.pm LedgerSMB/IS.pm
index 4f9f7f5..2e859d6 100644
--- LedgerSMB/IS.pm
+++ LedgerSMB/IS.pm
@@ -848,18 +848,19 @@ sub customer_details {
     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);
diff --git LedgerSMB/RP.pm LedgerSMB/RP.pm
index 70e24b8..f1e5b1e 100644
--- LedgerSMB/RP.pm
+++ LedgerSMB/RP.pm
@@ -1362,7 +1362,7 @@ sub trial_balance {
                                         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 @@ sub trial_balance {
                                         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 @@ sub trial_balance {
                                         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 @@ sub trial_balance {
                          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 @@ sub trial_balance {
                          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 @@ sub trial_balance {
                                 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 @@ sub trial_balance {
             $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 @@ sub trial_balance {
                
                       (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 @@ sub aging {
                       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 @@ sub aging {
                 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);
diff --git LedgerSMB/User.pm LedgerSMB/User.pm
index 8dc1ef2..9fcda82 100644
--- LedgerSMB/User.pm
+++ LedgerSMB/User.pm
@@ -184,6 +184,10 @@ sub fetch_config {
     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;
 }
 
diff --git UI/payments/payments_detail.html UI/payments/payments_detail.html
index edba943..096b1e9 100644
--- UI/payments/payments_detail.html
+++ UI/payments/payments_detail.html
@@ -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 ?> -- 

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Ledger-smb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel

Reply via email to