[IMP] account: Improved general and partner ledger reports for currency
bzr revid: pso@tinyerp.com-20101123071948-v6c42bqfn0wvcj7x
This commit is contained in:
@@ -170,13 +170,20 @@ class general_ledger(report_sxw.rml_parse, common_report_header):
|
||||
else:
|
||||
sql_sort='l.date'
|
||||
sql = """
|
||||
SELECT l.id AS lid, l.date AS ldate, j.code AS lcode, l.currency_id,l.amount_currency,l.ref AS lref, l.name AS lname, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id AS lperiod_id, l.partner_id AS lpartner_id,
|
||||
SELECT l.id AS lid, l.date AS ldate, j.code AS lcode, l.currency_id,
|
||||
case when a.currency_id is not null then
|
||||
l.amount_currency
|
||||
else
|
||||
0.0
|
||||
end as amount_currency,
|
||||
l.ref AS lref, l.name AS lname, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id AS lperiod_id, l.partner_id AS lpartner_id,
|
||||
m.name AS move_name, m.id AS mmove_id,
|
||||
c.symbol AS currency_code,
|
||||
i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number,
|
||||
p.name AS partner_name
|
||||
FROM account_move_line l
|
||||
JOIN account_move m on (l.move_id=m.id)
|
||||
LEFT JOIN account_account a ON (l.account_id=a.id)
|
||||
LEFT JOIN res_currency c on (l.currency_id=c.id)
|
||||
LEFT JOIN res_partner p on (l.partner_id=p.id)
|
||||
LEFT JOIN account_invoice i on (m.id =i.move_id)
|
||||
@@ -189,25 +196,31 @@ class general_ledger(report_sxw.rml_parse, common_report_header):
|
||||
if res_lines and self.init_balance:
|
||||
#FIXME: replace the label of lname with a string translatable
|
||||
sql = """
|
||||
SELECT 0 AS lid, '' AS ldate, '' AS lcode, COALESCE(SUM(l.amount_currency),0.0) AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id,
|
||||
'' AS move_name, '' AS mmove_id,
|
||||
SELECT 0 AS lid, '' AS ldate, '' AS lcode,
|
||||
sum(case when a.currency_id is not null then
|
||||
l.amount_currency
|
||||
else
|
||||
0.0
|
||||
end) as amount_currency,
|
||||
'' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id,
|
||||
'' AS move_name, '' AS mmove_id,
|
||||
c.symbol AS currency_code,
|
||||
'' AS currency_id,
|
||||
l.currency_id AS currency_id,
|
||||
'' AS invoice_id, '' AS invoice_type, '' AS invoice_number,
|
||||
'' AS partner_name
|
||||
FROM account_move_line l
|
||||
LEFT JOIN account_move m on (l.move_id=m.id)
|
||||
LEFT JOIN account_account ac on (l.account_id=ac.id)
|
||||
LEFT JOIN account_account a ON (l.account_id=a.id)
|
||||
LEFT JOIN res_currency c on (l.currency_id=c.id)
|
||||
LEFT JOIN res_partner p on (l.partner_id=p.id)
|
||||
LEFT JOIN account_invoice i on (m.id =i.move_id)
|
||||
JOIN account_journal j on (l.journal_id=j.id)
|
||||
WHERE %s AND m.state IN %s AND l.account_id = %%s
|
||||
group by c.symbol
|
||||
group by c.symbol , l.currency_id
|
||||
""" %(self.init_query, tuple(move_state))
|
||||
self.cr.execute(sql, (account.id,))
|
||||
res_init = self.cr.dictfetchall()
|
||||
res = res_init + res_lines
|
||||
res = res_init + res_lines
|
||||
account_sum = 0.0
|
||||
inv_types = { 'out_invoice': 'CI', 'in_invoice': 'SI', 'out_refund': 'OR', 'in_refund': 'SR', }
|
||||
for l in res:
|
||||
@@ -224,6 +237,8 @@ class general_ledger(report_sxw.rml_parse, common_report_header):
|
||||
l['amount_currency'] = abs(l['amount_currency']) * -1
|
||||
if l['amount_currency'] != None:
|
||||
self.tot_currency = self.tot_currency + l['amount_currency']
|
||||
self.cr.execute("select distinct currency_id from account_invoice")
|
||||
l['cur_id']=self.cr.fetchall()
|
||||
return res
|
||||
|
||||
def _sum_debit_account(self, account):
|
||||
|
||||
@@ -340,7 +340,7 @@
|
||||
<td alignment="right"><para style="P9b"><u>[[formatLang(sum_debit_account(o)) ]]</u></para></td>
|
||||
<td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o)) ]]</u></para></td>
|
||||
<td><para style="P9b"><u>[[formatLang(sum_balance_account(o)) ]] [[ company.currency_id.symbol ]]</u></para></td>
|
||||
<td><para style="P9b"><u><font>[[ (o.currency_id and formatLang(sum_currency_amount_account(o))) or removeParentNode('font') ]] [[ o.currency_id.symbol or '']]</font></u></para></td>
|
||||
<td><para style="P9b"><u>[[ o.currency_id and sum_currency_amount_account(o) +o.currency_id.symbol or '' ]]</u></para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
</td>
|
||||
@@ -362,7 +362,7 @@
|
||||
<td><para style="P4">[[ formatLang(line['debit']) ]]</para></td>
|
||||
<td><para style="P4">[[ formatLang(line['credit']) ]]</para></td>
|
||||
<td><para style="P4">[[ formatLang(line['progress']) ]] [[ company.currency_id.symbol ]]</para></td>
|
||||
<td><para style="P4"><font>[[ (line.has_key('currency_id') and line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'])]] [[ line['currency_code'] or '']]</font></para></td>
|
||||
<td><para style="P4"><font>[[ (len(line['cur_id'])==1 and o.currency_id.id==line['currency_id'] and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']]</font></para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
</section>
|
||||
|
||||
@@ -327,7 +327,8 @@
|
||||
<td><para style="P4_content">[[ formatLang(line['debit'], digits=get_digits(dp='Account')) ]]</para></td>
|
||||
<td><para style="P4_content">[[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]]</para></td>
|
||||
<td><para style="P4_content">[[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]]</para></td>
|
||||
<td><para style="P4_content"><font>[[ (o.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] </font></para></td>
|
||||
<td>
|
||||
<para style="P4_content"><font>[[ (len(line['cur_id'])==1 and o.currency_id.id==line['currency_id'] and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']]</font></para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user