From 37dc168e41c78722ca6ed193f7730640a759a744 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 9 Aug 2012 21:56:57 -0530 Subject: [PATCH] [ADD] Se agrega Mayor Analitico --- .../model/account_financial_report.py | 11 + .../balance_full_4_cols_analytic_ledger.rml | 251 ++++++++++++++++++ account_financial_report/report/parser.py | 63 ++++- .../view/account_financial_report_view.xml | 9 +- account_financial_report/view/report.xml | 11 + account_financial_report/view/wizard.xml | 9 +- account_financial_report/wizard/wizard.py | 16 +- 7 files changed, 365 insertions(+), 5 deletions(-) create mode 100644 account_financial_report/report/balance_full_4_cols_analytic_ledger.rml diff --git a/account_financial_report/model/account_financial_report.py b/account_financial_report/model/account_financial_report.py index 62b2c48e..f36899e8 100644 --- a/account_financial_report/model/account_financial_report.py +++ b/account_financial_report/model/account_financial_report.py @@ -46,6 +46,8 @@ class account_financial_report(osv.osv): 'fiscalyear_id': fields.many2one('account.fiscalyear','Fiscal year',help='Fiscal Year for this report',required=True), '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"), + '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), @@ -92,6 +94,15 @@ class account_financial_report(osv.osv): res['value'].update({'period_ids':[]}) return res + def onchange_analytic_ledger(self,cr,uid,ids,company_id,analytic_ledger,context=None): + if context is None: + context = {} + context['company_id']=company_id + res = {'value':{}} + cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id + res['value'].update({'currency_id':cur_id}) + return res + def onchange_company_id(self,cr,uid,ids,company_id,context=None): if context is None: context = {} diff --git a/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml b/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml new file mode 100644 index 00000000..0870db1a --- /dev/null +++ b/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[setLang(user.context_lang)]] + + + + + CODE + + + + ACCOUNT + + + INITIAL + + + DEBIT + + + CREDIT + + + BALANCE + + + + + [[ repeatIn(lines(data['form']), 'a') ]] + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[a['label']==True and a['code'] or '' ]] + + + + + [[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}))) or removeParentNode('font') ]] + [[ a['type']=='view' and a['name'].upper() or a['name'].title() ]] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['debit'], digits=2, grouping=True) or '']] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['credit'], digits=2, grouping=True) or '']] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + + + + + +
+ + [[ (a['type'] <> 'view') or removeParentNode('blockTable') ]] + + + + Date + + + Period + + + + Reference + + + Journal Entry + + + Partner + + + Debit + + + Credit + + + Balance + + + + + [[ repeatIn(a['mayor'], 'm') ]] + [[ set_fecha(m['date']) ]] + + + [[ m['period'] ]] + + + + + [[ m['name'] ]] [[ m['ref'] and (' - Ref %s'%m['ref']) or '' ]] + + + + + [[ m['entry'] ]] + + + [[ m['journal'] ]] + + + + + [[ m['partner'] ]] + + + + + [[ formatLang(m['debit'], digits=2) or '0,00' ]] + + + + + [[ formatLang(m['credit'], digits=2) or '0,00' ]] + + + + + [[ formatLang(m['balance'], digits=2) or '0,00' ]] + + + + +
+ + +
+
diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 84b8580a..98bdde65 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -155,7 +155,55 @@ class account_balance(report_sxw.rml_parse): return [brw.id for brw in rc_obj.browse(self.cr, self.uid, company_id).credit_account_ids] else: return [brw.id for brw in rc_obj.browse(self.cr, self.uid, company_id).debit_account_ids] - + + + def _get_analytic_ledger(self, account, ctx={}): + res = [] + + 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 = str(tuple(ctx['periods'])) + where = """where aml.period_id in %s and aa.id = %s and aml.state <> 'draft'"""%(periods,account['id']) + + sql_detalle = """select aml.id as id, aj.name as diario, aa.name as descripcion, + (select name from res_partner where aml.partner_id = id) as partner, + aa.code as cuenta, aml.name as name, + aml.ref as ref, + case when aml.debit is null then 0.00 else aml.debit end as debit, + case when aml.credit is null then 0.00 else aml.credit end as credit, + (select code from account_analytic_account where aml.analytic_account_id = id) as analitica, + aml.date as fecha, ap.name as periodo, + am.name as asiento + 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 fecha""" + + self.cr.execute(sql_detalle) + resultat = self.cr.dictfetchall() + balance = account['balanceinit'] + #~ print balance + for det in resultat: + balance += det['debit'] - det['credit'] + res.append({ + 'id': det['id'], + 'date': det['fecha'], + 'journal':det['diario'], + 'partner':det['partner'], + 'name':det['name'], + 'entry':det['asiento'], + 'ref': det['ref'], + 'debit': det['debit'], + 'credit': det['credit'], + 'analytic': det['analitica'], + 'period': det['periodo'], + 'balance': balance, + }) + return res + def lines(self, form, level=0): """ Returns all the data needed for the report lines @@ -546,7 +594,12 @@ class account_balance(report_sxw.rml_parse): else: # Include all accounts to_include = True - + + #~ 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) + + if to_include: result_acc.append(res) # @@ -649,6 +702,12 @@ report_sxw.report_sxw('report.afr.4cols', 'account_financial_report/report/balance_full_4_cols.rml', parser=account_balance, header=False) + +report_sxw.report_sxw('report.afr.analytic.ledger', + 'wizard.report', + 'account_financial_report/report/balance_full_4_cols_analytic_ledger.rml', + parser=account_balance, + header=False) report_sxw.report_sxw('report.afr.5cols', 'wizard.report', diff --git a/account_financial_report/view/account_financial_report_view.xml b/account_financial_report/view/account_financial_report_view.xml index 94e87547..34a86965 100644 --- a/account_financial_report/view/account_financial_report_view.xml +++ b/account_financial_report/view/account_financial_report_view.xml @@ -15,12 +15,19 @@ - + + diff --git a/account_financial_report/view/report.xml b/account_financial_report/view/report.xml index d70f2207..3d932a97 100644 --- a/account_financial_report/view/report.xml +++ b/account_financial_report/view/report.xml @@ -34,6 +34,17 @@ string="Balance 4 Columnas" header="False" /> + + - + + diff --git a/account_financial_report/wizard/wizard.py b/account_financial_report/wizard/wizard.py index 47aea220..b447fe95 100644 --- a/account_financial_report/wizard/wizard.py +++ b/account_financial_report/wizard/wizard.py @@ -48,6 +48,8 @@ class wizard_report(osv.osv_memory): 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Fiscal Year for this report',required=True), '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"), + '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), @@ -81,6 +83,15 @@ class wizard_report(osv.osv_memory): res['value'].update({'periods':[]}) return res + def onchange_analytic_ledger(self,cr,uid,ids,company_id,analytic_ledger,context=None): + if context is None: + context = {} + context['company_id']=company_id + res = {'value':{}} + cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id + res['value'].update({'currency_id':cur_id}) + return res + def onchange_company_id(self,cr,uid,ids,company_id,context=None): if context is None: context = {} @@ -191,7 +202,10 @@ class wizard_report(osv.osv_memory): if data['form']['columns'] == 'two': name = 'afr.2cols' if data['form']['columns'] == 'four': - name = 'afr.4cols' + if data['form']['analytic_ledger'] and data['form']['inf_type'] == 'BS': + name = 'afr.analytic.ledger' + else: + name = 'afr.4cols' if data['form']['columns'] == 'five': name = 'afr.5cols' if data['form']['columns'] == 'qtr':