Browse Source

[MERGE] [account_financial_report] Journal ledger

pull/7/merge
Humberto Arocha 11 years ago
parent
commit
57b197b79f
  1. 1
      account_financial_report/model/account_financial_report.py
  2. 398
      account_financial_report/report/balance_full_4_cols_journal_ledger.rml
  3. 49
      account_financial_report/report/parser.py
  4. 9
      account_financial_report/view/account_financial_report_view.xml
  5. 13
      account_financial_report/view/report.xml
  6. 3
      account_financial_report/view/wizard.xml
  7. 3
      account_financial_report/wizard/wizard.py

1
account_financial_report/model/account_financial_report.py

@ -48,6 +48,7 @@ class account_financial_report(osv.osv):
'period_ids': fields.many2many('account.period', 'afr_period_rel', 'afr_id', 'period_id', 'Periods', help='All periods in the fiscal year if empty'),
'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'journal_ledger': fields.boolean('journal Ledger', help="Allows to Generate an journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size=128),

398
account_financial_report/report/balance_full_4_cols_journal_ledger.rml

@ -0,0 +1,398 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(27.94cm,21.59cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
<pageTemplate id="first">
<frame id="first" x1="1.0cm" y1="1.0cm" width="26.0cm" height="16.65cm"/>
<pageGraphics>
<setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="17.65cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!--
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
-->
<place x="-3.5cm" y="16.15cm" width="19cm" height="5.0cm">
<blockTable colWidths="9.6cm,9.4cm" style="TITLE">
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER_NAME">
<font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
<font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">(Expressed in [[data['form'] and (' %s'%( exchange_name(data['form']))) or '']])</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
</tr>
</blockTable>
</place>
<drawRightString x="270mm" y="5mm"> Pag.: <pageNumber/></drawRightString>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="BODY_LINE">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="BODY_LINE_FILLED">
<blockBackground colorName="lightgrey" start="0,0" stop="-1,-1"/>
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="TITLE">
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="BODY">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="darkgrey" start="0,0" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="BODY_STRIKE">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,1" stop="-1,-1" thickness='0.5'/>
</blockTableStyle>
<blockTableStyle id="TOP_TABLE">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,-1" stop="0,-1" thickness='0.25'/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle
name="TITLE_LEFT_ALIGN_NEW"
fontName="Courier"
fontSize="7.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TITLES_NEW"
fontName="Courier"
fontSize="7.0"
leading="10"
alignment="LEFT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TITLES_NEW_P"
fontName="Helvetica-Bold"
fontSize="6.0"
leading="10"
alignment="LEFT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TITLES_NEW_RIGHT"
fontName="Courier"
fontSize="7.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle
name="TITLE_LEFT_ALIGN"
fontName="Helvetica-Bold"
fontSize="7.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="7" leftIndent="0.0" alignment="LEFT"/>
<paraStyle
name="TITLES"
fontName="Helvetica-Bold"
fontSize="7.0"
leading="10"
alignment="LEFT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="7" leading="10" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
<paraStyle
name="TITLE"
alignment="CENTER"
fontName="Helvetica"
fontSize="18.0"
leading="20"
spaceBefore="-3.0"
textColor="black"/>
</stylesheet>
<images/>
<story>
<para>[[setLang(user.lang)]]</para>
<blockTable colWidths="2.5cm,13.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="0">
<tr noRowsplits="0">
<td>
<para style="TITLE_LEFT_ALIGN">
<font>CODE</font>
</para>
</td>
<td>
<para style="TITLES">ACCOUNT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">INITIAL</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">DEBIT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">CREDIT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">BALANCE</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="6.0cm,3.0cm,3.0cm,2.5cm,4.0cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE" repeatRows="0">
<!--
[[ (a['type'] &lt;&gt; 'view') or removeParentNode('blockTable') ]]
-->
<tr noRowsplits="1">
<td>
<para style="TITLES_NEW">
<font>DATE</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>PERIOD</font>
</para>
</td>
<td>
<para style="TITLES_NEW">JOURNAL ENTRY</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
</tr>
</blockTable>
<section>
<para>[[ repeatIn([x for x in lines(data['form']) if x['type'] != 'view'], 'a') ]]</para>
<blockTable colWidths="2.5cm,13.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="0">
<tr>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<i>[[a['label']==True and a['code'] or '' ]]</i>
</para>
</td>
<td>
<para style="TITLES">
<font>[[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}))) or removeParentNode('font') ]]</font>
<font>[[ a['type']=='view' and a['name'].upper() or a['name'].title() ]]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['debit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['credit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
</tr>
</blockTable>
<section>
<para>[[ repeatIn(a['journal'], 'j') ]]</para>
<blockTable colWidths="6.0cm,3.0cm,3.0cm,2.5cm,4.0cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE" repeatRows="1">
<!--
[[ (a['type'] &lt;&gt; 'view') or removeParentNode('blockTable') ]]
-->
<tr>
<td>
<para style="TITLES_NEW_P">
<font> [[ formatLang( j['date'], date=True) ]]</font>
</para>
</td>
<td>
<para style="TITLES_NEW_P">
<font>[[ j['period'] ]]</font>
</para>
</td>
<td>
<para style="TITLES_NEW_P">
<font>[[ j['name'] ]] </font>
</para>
</td>
<td>
<para style="TITLES_NEW_">
<font></font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font></font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
</para>
</td>
</tr>
</blockTable>
<section>
<para>[[ repeatIn(j.get('obj').line_id, 'k') ]]</para>
<blockTable colWidths="6.0cm,3.0cm,3.0cm,1.5cm,5.0cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE_FILLED" repeatRows="1">
<tr>
<td>
<para style="TITLES_NEW">
<font> [[ k.account_id.code == a['code'] and k.name or removeParentNode('blockTable') ]]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.ref and k.ref or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.partner_id and k.partner_id.name or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.account_id and k.account_id.code or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.account_id and k.account_id.name or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW_RIGHT">
<font>[[ k.account_id.type&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ k.debit and formatLang(k.debit, digits=2, grouping=True) or '' ]] </font>
</para>
</td>
<td>
<para style="TITLES_NEW_RIGHT">
<font>[[ k.account_id.type&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ k.credit and formatLang(k.credit, digits=2, grouping=True) or '' ]] </font>
</para>
</td>
<td>
<para style="TITLES_NEW_RIGHT">
<font>[[ k.account_id.type&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ k.reconcile_id and k.reconcile_id.name or k.reconcile_partial_id and k.reconcile_partial_id.name or '']]</font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="6.0cm,3.0cm,3.0cm,1.5cm,5.0cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE" repeatRows="1">
<tr>
<td>
<para style="TITLES_NEW">
<font> [[ k.account_id.code != a['code'] and k.name or removeParentNode('blockTable') ]]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.ref and k.ref or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.partner_id and k.partner_id.name or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.account_id and k.account_id.code or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ k.account_id and k.account_id.name or '']]</font>
</para>
</td>
<td>
<para style="TITLES_NEW_RIGHT">
<font>[[ k.account_id.type&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ k.debit and formatLang(k.debit, digits=2, grouping=True) or '' ]] </font>
</para>
</td>
<td>
<para style="TITLES_NEW_RIGHT">
<font>[[ k.account_id.type&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ k.credit and formatLang(k.credit, digits=2, grouping=True) or '' ]] </font>
</para>
</td>
<td>
<para style="TITLES_NEW_RIGHT">
<font>[[ k.account_id.type&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ k.reconcile_id and k.reconcile_id.name or k.reconcile_partial_id and k.reconcile_partial_id.name or '']]</font>
</para>
</td>
</tr>
</blockTable>
</section>
<spacer length="1.5mm"/>
</section>
<spacer length="2.5mm"/>
</section>
</story>
</document>

49
account_financial_report/report/parser.py

@ -239,6 +239,46 @@ class account_balance(report_sxw.rml_parse):
})
return res
def _get_journal_ledger(self, account, ctx={}):
res = []
am_obj = self.pool.get('account.move')
print 'AM OBJ ', am_obj
if account['type'] in ('other', 'liquidity', 'receivable', 'payable'):
#~ TODO: CUANDO EL PERIODO ESTE VACIO LLENARLO CON LOS PERIODOS DEL EJERCICIO
#~ FISCAL, SIN LOS PERIODOS ESPECIALES
periods = ', '.join([str(i) for i in ctx['periods']])
#~ periods = str(tuple(ctx['periods']))
where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % (
periods, account['id'])
if ctx.get('state','posted')=='posted':
where += "AND am.state = 'posted'"
sql_detalle = """SELECT
DISTINCT am.id as am_id,
aj.name as diario,
am.name as name,
am.date as date,
ap.name as periodo
from account_move_line aml
inner join account_journal aj on aj.id = aml.journal_id
inner join account_account aa on aa.id = aml.account_id
inner join account_period ap on ap.id = aml.period_id
inner join account_move am on am.id = aml.move_id """ + where +\
""" order by date, am.name"""
self.cr.execute(sql_detalle)
resultat = self.cr.dictfetchall()
for det in resultat:
res.append({
'am_id': det['am_id'],
'journal': det['diario'],
'name': det['name'],
'date': det['date'],
'period': det['periodo'],
'obj': am_obj.browse(self.cr,self.uid,det['am_id'])
})
print 'ACCOUNT NAME', am_obj.browse(self.cr,self.uid,det['am_id']).name
return res
def lines(self, form, level=0):
"""
Returns all the data needed for the report lines
@ -786,6 +826,8 @@ class account_balance(report_sxw.rml_parse):
#~ ANALYTIC LEDGER
if to_include and form['analytic_ledger'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'):
res['mayor'] = self._get_analytic_ledger(res, ctx=ctx_end)
elif to_include and form['journal_ledger'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'):
res['journal'] = self._get_journal_ledger(res, ctx=ctx_end)
else:
res['mayor'] = []
@ -895,6 +937,12 @@ report_sxw.report_sxw('report.afr.analytic.ledger',
'account_financial_report/report/balance_full_4_cols_analytic_ledger.rml',
parser=account_balance,
header=False)
report_sxw.report_sxw('report.afr.journal.ledger',
'wizard.report',
'account_financial_report/report/balance_full_4_cols_journal_ledger.rml',
parser=account_balance,
header=False)
report_sxw.report_sxw('report.afr.5cols',
'wizard.report',
@ -913,3 +961,4 @@ report_sxw.report_sxw('report.afr.13cols',
'account_financial_report/report/balance_full_13_cols.rml',
parser=account_balance,
header=False)

9
account_financial_report/view/account_financial_report_view.xml

@ -25,6 +25,15 @@
attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
on_change='onchange_analytic_ledger(company_id,analytic_ledger)' />
</group>
<group string="Report Info" >
<field
name="inf_type"
on_change='onchange_inf_type(inf_type)' />
<field name="columns" on_change='onchange_columns(columns,fiscalyear_id,period_ids)' />
<field name="journal_ledger"
attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
on_change='(company_id,journal_ledger)' />
</group>
</group>
<group>
<group string="Accounts Info" >

13
account_financial_report/view/report.xml

@ -45,6 +45,17 @@
string="Analytic Ledger"
header="False"
/>
<report
auto="False"
id="journal_ledger_report"
menu="True"
model="wizard.report"
name="afr.journal.ledger"
rml="account_financial_report/report/balance_full_4_cols_journal_ledger.rml"
string="journal Ledger"
header="False"
/>
<report
auto="False"
@ -78,5 +89,7 @@
string="Balance 13 Columnas"
header="False"
/>
</data>
</openerp>

3
account_financial_report/view/wizard.xml

@ -41,6 +41,9 @@
attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
on_change='onchange_analytic_ledger(company_id,analytic_ledger)'
/>
<field name="journal_ledger"
attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
/>
</group>
</group>
<group>

3
account_financial_report/wizard/wizard.py

@ -50,6 +50,7 @@ class wizard_report(osv.osv_memory):
'periods': fields.many2many('account.period', 'rel_wizard_period', 'wizard_id', 'period_id', 'Periods', help='All periods in the fiscal year if empty'),
'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'journal_ledger': fields.boolean('Journal Ledger', help="Allows to Generate an Journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size=128),
@ -273,6 +274,8 @@ class wizard_report(osv.osv_memory):
if data['form']['columns'] == 'four':
if data['form']['analytic_ledger'] and data['form']['inf_type'] == 'BS':
name = 'afr.analytic.ledger'
elif data['form']['journal_ledger'] and data['form']['inf_type'] == 'BS':
name = 'afr.journal.ledger'
else:
name = 'afr.4cols'
if data['form']['columns'] == 'five':

Loading…
Cancel
Save