From 4670e2c843dce415a75da16acd2f565dc87c9f20 Mon Sep 17 00:00:00 2001 From: vra Date: Wed, 19 May 2010 16:19:20 +0530 Subject: [PATCH] [ADD] account_report_india : Final Account Reports(Profit & Loss and Balance Sheet Report. bzr revid: vra@tinyerp.com-20100519104920-vu63y67rhsdq35ud --- addons/account_report_india/__init__.py | 3 + addons/account_report_india/__openerp__.py | 48 +++ .../account_report_india/report/__init__.py | 3 + .../report/report_balance_sheet.rml | 245 +++++++++++++++ .../report_balance_sheet_horizontal.rml | 234 ++++++++++++++ .../account_report_india/report/report_bs.py | 202 ++++++++++++ .../account_report_india/report/report_pl.py | 177 +++++++++++ .../report/report_pl_account.rml | 293 ++++++++++++++++++ .../report/report_pl_account_horizontal.rml | 278 +++++++++++++++++ .../account_report_india/report/rml_parse.py | 165 ++++++++++ .../account_report_india/wizard/__init__.py | 23 ++ .../wizard/account_bs_report.py | 158 ++++++++++ .../wizard/account_bs_report_view.xml | 85 +++++ .../wizard/account_pl_report.py | 155 +++++++++ .../wizard/account_pl_report_view.xml | 89 ++++++ 15 files changed, 2158 insertions(+) create mode 100644 addons/account_report_india/__init__.py create mode 100644 addons/account_report_india/__openerp__.py create mode 100755 addons/account_report_india/report/__init__.py create mode 100644 addons/account_report_india/report/report_balance_sheet.rml create mode 100644 addons/account_report_india/report/report_balance_sheet_horizontal.rml create mode 100644 addons/account_report_india/report/report_bs.py create mode 100644 addons/account_report_india/report/report_pl.py create mode 100644 addons/account_report_india/report/report_pl_account.rml create mode 100644 addons/account_report_india/report/report_pl_account_horizontal.rml create mode 100755 addons/account_report_india/report/rml_parse.py create mode 100755 addons/account_report_india/wizard/__init__.py create mode 100644 addons/account_report_india/wizard/account_bs_report.py create mode 100644 addons/account_report_india/wizard/account_bs_report_view.xml create mode 100644 addons/account_report_india/wizard/account_pl_report.py create mode 100644 addons/account_report_india/wizard/account_pl_report_view.xml diff --git a/addons/account_report_india/__init__.py b/addons/account_report_india/__init__.py new file mode 100644 index 00000000000..f8c96cb3c42 --- /dev/null +++ b/addons/account_report_india/__init__.py @@ -0,0 +1,3 @@ + +import report +import wizard diff --git a/addons/account_report_india/__openerp__.py b/addons/account_report_india/__openerp__.py new file mode 100644 index 00000000000..4e0f8339d64 --- /dev/null +++ b/addons/account_report_india/__openerp__.py @@ -0,0 +1,48 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + "name" : "Accounting Reports", + "version" : "1.0", + "depends" : [ + "account", + "account_voucher" + ], + "author" : "Tiny ERP", + "description": """Accounting Reports +Modules gives the 2 most Important Reports for the Accounting +* Profit and Loss Account +* Balance Sheet + """, + "website" : "http://tinyerp.com/module_account.html", + "category" : "Generic Modules/Accounting", + "init_xml" : [ + ], + "demo_xml" : [ + + ], + "update_xml" : [ + "wizard/account_pl_report_view.xml", + "wizard/account_bs_report_view.xml" + ], + "active": False, + "installable": True +} diff --git a/addons/account_report_india/report/__init__.py b/addons/account_report_india/report/__init__.py new file mode 100755 index 00000000000..5bcdacfefaf --- /dev/null +++ b/addons/account_report_india/report/__init__.py @@ -0,0 +1,3 @@ + +import report_bs +import report_pl diff --git a/addons/account_report_india/report/report_balance_sheet.rml b/addons/account_report_india/report/report_balance_sheet.rml new file mode 100644 index 00000000000..95a34c2f063 --- /dev/null +++ b/addons/account_report_india/report/report_balance_sheet.rml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ get_company(data['form']) ]] + + + + + + + Balance Sheet + + + + + + + From : [[ formatLang(data['form']['date_from'],date=True) ]] To: [[ formatLang(data['form']['date_to'], date=True) ]] + + + + + [[ get_data(data['form']) ]] + + + + + + + Code + + + Liabilities + + + Total Amount([[ get_currency(data['form']) ]]) + + + + + [[ repeatIn(get_lines_another('liability'), 'a') ]][[ a['code'] ]][[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]] + + + [[ '. '*(a['level']-1) ]][[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['name'] ]] + + + [[ formatLang(abs(a['balance'])) ]] + + + + + + + Balance:([[ get_currency(data['form']) ]]) + + + [[ formatLang(sum_dr()) ]] + + + + + + + + + + + Code + + + Assets + + + Total Amount([[ get_currency(data['form']) ]]) + + + + + [[ repeatIn(get_lines_another('asset'), 'a') ]][[ a['code'] ]][[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]] + + + [[ a['code'] ]][[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['name'] ]] + + + [[ formatLang(abs(a['balance'])) ]] + + + + + + + Balance:([[ get_currency(data['form']) ]]) + + + [[ formatLang(sum_cr()) ]] + + + + + + + + diff --git a/addons/account_report_india/report/report_balance_sheet_horizontal.rml b/addons/account_report_india/report/report_balance_sheet_horizontal.rml new file mode 100644 index 00000000000..09a2f252f80 --- /dev/null +++ b/addons/account_report_india/report/report_balance_sheet_horizontal.rml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Balance Sheet + + + + + + + From : [[ formatLang(data['form']['date_from'],date=True) ]] To: [[ formatLang(data['form']['date_to'], date=True) ]] + + + + + [[ get_data(data['form']) ]] + + + + + + + Code + + + Liabilities + + + Total Amount([[ get_currency(data['form']) ]]) + + + Code + + + Assets + + + Total Amount([[ get_currency(data['form']) ]]) + + + + + [[ repeatIn(get_lines(), 'a') ]] [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['code'] ]] + + + [[ '. '*(a['level']-1) ]][[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['name'] ]] + + + [[ formatLang(abs(a['balance'])) ]] + + + [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['code1'] ]] + + + [[ '. '*(a['level1']-1) ]][[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['name1'] ]] + + + [[ formatLang(abs(a['balance1'])) ]] + + + + + + + Balance:([[ get_currency(data['form']) ]]) + + + [[ formatLang(abs(sum_dr())) ]] + + + Balance:([[ get_currency(data['form']) ]]) + + + [[ formatLang(abs(sum_cr())) ]] + + + + + + + + + diff --git a/addons/account_report_india/report/report_bs.py b/addons/account_report_india/report/report_bs.py new file mode 100644 index 00000000000..3369ff0e222 --- /dev/null +++ b/addons/account_report_india/report/report_bs.py @@ -0,0 +1,202 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import pooler +import time +import mx.DateTime +import rml_parse +from report import report_sxw +from account_report_india.report import report_pl + +class report_balancesheet_horizontal(rml_parse.rml_parse): + def __init__(self, cr, uid, name, context): + super(report_balancesheet_horizontal, self).__init__(cr, uid, name, context) + self.obj_pl=report_pl.report_pl_account_horizontal(cr, uid, name, context) + self.result_sum_dr=0.0 + self.result_sum_cr=0.0 + self.result = {} + self.res_pl={} + self.result_temp=[] + self.localcontext.update({ + 'time': time, + 'get_lines' : self.get_lines, + 'get_lines_another' : self.get_lines_another, + 'get_company': self.get_company, + 'get_currency': self._get_currency, + 'sum_dr' : self.sum_dr, + 'sum_cr' : self.sum_cr, + 'get_data':self.get_data, + 'get_pl_balance':self.get_pl_balance, + + }) + self.context = context + + def sum_dr(self): + if self.res_pl['type'] == 'Net Profit': + self.result_sum_dr += self.res_pl['balance'] + return self.result_sum_dr or 0.0 + + def sum_cr(self): + if self.res_pl['type'] == 'Net Loss': + self.result_sum_cr += self.res_pl['balance'] + return self.result_sum_cr or 0.0 + + def get_pl_balance(self): + return self.res_pl or 0.0 + + def get_data(self,form): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + #Getting Profit or Loss Balance from profit and Loss report + result_pl=self.obj_pl.get_data(form) + self.res_pl=self.obj_pl.final_result() + + type_pool = db_pool.get('account.account.type') + account_pool = db_pool.get('account.account') + year_pool = db_pool.get('account.fiscalyear') + + types = [ + 'liability', + 'asset' + ] + + ctx = self.context.copy() + ctx['state'] = form['context'].get('state','all') + ctx['fiscalyear'] = form['fiscalyear'] + if form['state']=='byperiod' : + ctx['periods'] = form['periods'] + elif form['state']== 'bydate': + ctx['date_from'] = form['date_from'] + ctx['date_to'] = form['date_to'] + elif form['state'] == 'all' : + ctx['periods'] = form['periods'] + ctx['date_from'] = form['date_from'] + ctx['date_to'] = form['date_to'] + + cal_list={} + pl_dict = {} + account_dict = {} + account_id = [form['Account_list']] + account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx) + accounts = account_pool.browse(cr, uid, account_ids, context=ctx) + + if self.res_pl['type'] == 'Net Profit C.F.B.L.': + self.res_pl['type'] = 'Net Profit' + else: + self.res_pl['type'] = 'Net Loss' + pl_dict = { + 'code' : False, + 'name' : self.res_pl['type'], + 'level': False, + 'balance':self.res_pl['balance'], + } + for typ in types: + accounts_temp = [] + for account in accounts: + if (account.user_type.report_type) and (account.user_type.report_type == typ): + account_dict = { + 'id' : account.id, + 'code' : account.code, + 'name' : account.name, + 'level': account.level, + 'balance':account.balance, + } + if typ == 'liability' and account.type <> 'view' and (account.debit <> account.credit): + self.result_sum_dr += abs(account.debit - account.credit) + if typ == 'asset' and account.type <> 'view' and (account.debit <> account.credit): + self.result_sum_cr += abs(account.debit - account.credit) + if form['display_account'] == 'bal_mouvement': + if account.credit > 0 or account.debit > 0 or account.balance > 0 : + accounts_temp.append(account_dict) + elif form['display_account'] == 'bal_solde': + if account.balance != 0: + accounts_temp.append(account_dict) + else: + accounts_temp.append(account_dict) + if account.id == form['reserve_account_id']: + pl_dict['level'] = account['level'] + 1 + accounts_temp.append(pl_dict) + + self.result[typ] = accounts_temp + cal_list[typ]=self.result[typ] + if cal_list: + temp={} + for i in range(0,max(len(cal_list['liability']),len(cal_list['asset']))): + if i < len(cal_list['liability']) and i < len(cal_list['asset']): + temp={ + 'code' : cal_list['liability'][i]['code'], + 'name' : cal_list['liability'][i]['name'], + 'level': cal_list['liability'][i]['level'], + 'balance':cal_list['liability'][i]['balance'], + 'code1' : cal_list['asset'][i]['code'], + 'name1' : cal_list['asset'][i]['name'], + 'level1': cal_list['asset'][i]['level'], + 'balance1':cal_list['asset'][i]['balance'], + } + self.result_temp.append(temp) + else: + if i < len(cal_list['asset']): + temp={ + 'code' : '', + 'name' : '', + 'level': False, + 'balance':False, + 'code1' : cal_list['asset'][i]['code'], + 'name1' : cal_list['asset'][i]['name'], + 'level1': cal_list['asset'][i]['level'], + 'balance1':cal_list['asset'][i]['balance'], + } + self.result_temp.append(temp) + if i < len(cal_list['liability']): + temp={ + 'code' : cal_list['liability'][i]['code'], + 'name' : cal_list['liability'][i]['name'], + 'level': cal_list['liability'][i]['level'], + 'balance':cal_list['liability'][i]['balance'], + 'code1' : '', + 'name1' : '', + 'level1': False, + 'balance1':False, + } + self.result_temp.append(temp) + return None + + def get_lines(self): + return self.result_temp + + def get_lines_another(self, group): + return self.result.get(group, []) + + def _get_currency(self, form): + return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.code + + def get_company(self,form): + comp_obj=pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr,self.uid,form['company_id']) + return comp_obj.name + +report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account', + 'addons/account_report_india/report/report_balance_sheet_horizontal.rml',parser=report_balancesheet_horizontal, + header=False) + +report_sxw.report_sxw('report.account.balancesheet', 'account.account', + 'addons/account_report_india/report/report_balance_sheet.rml',parser=report_balancesheet_horizontal, + header=False) diff --git a/addons/account_report_india/report/report_pl.py b/addons/account_report_india/report/report_pl.py new file mode 100644 index 00000000000..b8b77e08be9 --- /dev/null +++ b/addons/account_report_india/report/report_pl.py @@ -0,0 +1,177 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import pooler +import time +import mx.DateTime +import rml_parse +from report import report_sxw + +class report_pl_account_horizontal(rml_parse.rml_parse): + def __init__(self, cr, uid, name, context): + super(report_pl_account_horizontal, self).__init__(cr, uid, name, context) + self.result_sum_dr=0.0 + self.result_sum_cr=0.0 + self.res_pl ={} + self.result = {} + self.result_temp=[] + self.localcontext.update( { + 'time': time, + 'get_lines' : self.get_lines, + 'get_lines_another' : self.get_lines_another, + 'get_company': self.get_company, + 'get_currency': self._get_currency, + 'get_data': self.get_data, + 'sum_dr' : self.sum_dr, + 'sum_cr' : self.sum_cr, + 'final_result' : self.final_result, + }) + self.context = context + + def final_result(self): + return self.res_pl + + def sum_dr(self): + if self.res_pl['type'] == 'Net Profit C.F.B.L.': + self.result_sum_dr += self.res_pl['balance'] + return self.result_sum_dr or 0.0 + + def sum_cr(self): + if self.res_pl['type'] == 'Net Loss C.F.B.L.': + self.result_sum_cr += self.res_pl['balance'] + return self.result_sum_cr or 0.0 + + def get_data(self,form): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + type_pool = db_pool.get('account.account.type') + account_pool = db_pool.get('account.account') + year_pool = db_pool.get('account.fiscalyear') + + types = [ + 'expense', + 'income' + ] + + ctx = self.context.copy() + ctx['state'] = form['context'].get('state','all') + ctx['fiscalyear'] = form['fiscalyear'] + if form['state']=='byperiod' : + ctx['periods'] = form['periods'] + elif form['state']== 'bydate': + ctx['date_from'] = form['date_from'] + ctx['date_to'] = form['date_to'] + elif form['state'] == 'all' : + ctx['periods'] = form['periods'] + ctx['date_from'] = form['date_from'] + ctx['date_to'] = form['date_to'] + + cal_list={} + account_id = [form['Account_list']] + account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx) + accounts = account_pool.browse(cr, uid, account_ids, context=ctx) + + for typ in types: + accounts_temp = [] + for account in accounts: + if (account.user_type.report_type) and (account.user_type.report_type == typ): + if typ == 'expense' and account.type <> 'view' and (account.debit <> account.credit): + self.result_sum_dr += abs(account.debit - account.credit) + if typ == 'income' and account.type <> 'view' and (account.debit <> account.credit): + self.result_sum_cr += abs(account.debit - account.credit) + if form['display_account'] == 'bal_mouvement': + if account.credit > 0 or account.debit > 0 or account.balance > 0 : + accounts_temp.append(account) + elif form['display_account'] == 'bal_solde': + if account.balance != 0: + accounts_temp.append(account) + else: + accounts_temp.append(account) + if self.result_sum_dr > self.result_sum_cr: + self.res_pl['type'] = 'Net Loss C.F.B.L.' + self.res_pl['balance'] = (self.result_sum_dr - self.result_sum_cr) + else: + self.res_pl['type'] = 'Net Profit C.F.B.L.' + self.res_pl['balance'] = (self.result_sum_cr - self.result_sum_dr) + self.result[typ] = accounts_temp + cal_list[typ]=self.result[typ] + if cal_list: + temp={} + for i in range(0,max(len(cal_list['expense']),len(cal_list['income']))): + if i < len(cal_list['expense']) and i < len(cal_list['income']): + temp={ + 'code' : cal_list['expense'][i].code, + 'name' : cal_list['expense'][i].name, + 'level': cal_list['expense'][i].level, + 'balance':cal_list['expense'][i].balance, + 'code1' : cal_list['income'][i].code, + 'name1' : cal_list['income'][i].name, + 'level1': cal_list['income'][i].level, + 'balance1':cal_list['income'][i].balance, + } + self.result_temp.append(temp) + else: + if i < len(cal_list['income']): + temp={ + 'code' : '', + 'name' : '', + 'level': False, + 'balance':False, + 'code1' : cal_list['income'][i].code, + 'name1' : cal_list['income'][i].name, + 'level1': cal_list['income'][i].level, + 'balance1':cal_list['income'][i].balance, + } + self.result_temp.append(temp) + if i < len(cal_list['expense']): + temp={ + 'code' : cal_list['expense'][i].code, + 'name' : cal_list['expense'][i].name, + 'level': cal_list['expense'][i].level, + 'balance':cal_list['expense'][i].balance, + 'code1' : '', + 'name1' : '', + 'level1': False, + 'balance1':False, + } + self.result_temp.append(temp) + return None + + def get_lines(self): + return self.result_temp + + def get_lines_another(self, group): + return self.result.get(group, []) + + def _get_currency(self, form): + return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.code + + def get_company(self,form): + comp_obj=pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr,self.uid,form['company_id']) + return comp_obj.name + +report_sxw.report_sxw('report.pl.account.horizontal', 'account.account', + 'addons/account_report_india/report/report_pl_account_horizontal.rml',parser=report_pl_account_horizontal, header=False) + +report_sxw.report_sxw('report.pl.account', 'account.account', + 'addons/account_report_india/report/report_pl_account.rml',parser=report_pl_account_horizontal, header=False) + diff --git a/addons/account_report_india/report/report_pl_account.rml b/addons/account_report_india/report/report_pl_account.rml new file mode 100644 index 00000000000..77f3fa50ad8 --- /dev/null +++ b/addons/account_report_india/report/report_pl_account.rml @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ get_company(data['form']) ]] + + + + + + + Profit And Loss Account + + + + + + + From : [[ formatLang(data['form']['date_from'],date=True) ]] To: [[ formatLang(data['form']['date_to'], date=True) ]] + + + + + [[ get_data(data['form']) ]] + + + + + + + Code + + + Expenses + + + Total Amount([[ get_currency(data['form']) ]]) + + + + + + [[ repeatIn(get_lines_another('expense'),'a' ) ]] [[ a.code ]][[ a.level<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]] + + + + + [[ '. '*(a.level-1) ]][[ a.level<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a.name ]] + + + + [[ formatLang(abs(a.balance)) ]] + + + + + + + + + + [[ final_result()['type'] == 'Net Profit C.F.B.L.' and final_result()['type'] or removeParentNode('blockTable') ]] + + + [[ final_result()['type'] == 'Net Profit C.F.B.L.' and formatLang(abs(final_result()['balance'])) or '' ]] + + + + + + + Total:([[ get_currency(data['form']) ]]) + + + [[ formatLang(abs(sum_dr())) ]] + + + + + + + + + + + Code + + + Incomes + + + Total Amount([[ get_currency(data['form']) ]]) + + + + + + [[ repeatIn(get_lines_another('income'),'a') ]] [[ a.code ]][[ a.level<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]] + + + + + [[ '. '*(a.level-1) ]][[ a.level<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a.name ]] + + + + [[ formatLang(abs(a.balance)) ]] + + + + + + + + + + [[ final_result()['type'] == 'Net Loss C.F.B.L.' and final_result()['type'] or removeParentNode('blockTable') ]] + + + [[ final_result()['type'] == 'Net Loss C.F.B.L.' and formatLang(abs(final_result()['balance'])) or '' ]] + + + + + + + Total:([[ get_currency(data['form']) ]]) + + + [[ formatLang(abs(sum_cr())) ]] + + + + + + + + + + + diff --git a/addons/account_report_india/report/report_pl_account_horizontal.rml b/addons/account_report_india/report/report_pl_account_horizontal.rml new file mode 100644 index 00000000000..0c2be18da0b --- /dev/null +++ b/addons/account_report_india/report/report_pl_account_horizontal.rml @@ -0,0 +1,278 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Profit And Loss Account + + + + + + + From : [[ formatLang(data['form']['date_from'],date=True) ]] To: [[ formatLang(data['form']['date_to'], date=True) ]] + + + + + [[ get_data(data['form']) ]] + + + + + + + Code + + + Perticular + + + Total Amount([[ get_currency(data['form'])]]) + + + Code + + + Perticular + + + Total Amount([[ get_currency(data['form'])]]) + + + + + + [[ repeatIn(get_lines(),'a' ) ]] [[ a['code'] ]][[ a['level']<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]] + + + + + [[ '. '*(a['level']-1) ]][[ a['level']<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['name'] ]] + + + + [[ formatLang(abs(a['balance'])) ]] + + + + [[ a['code1'] ]][[ a['level1']<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]] + + + + + [[ '. '*(a['level1']-1) ]][[ a['level1']<3 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) ]][[ a['name1'] ]] + + + + [[ formatLang(abs(a['balance1'])) ]] + + + + + + + + + + [[ final_result()['type'] == 'Net Profit C.F.B.L.' and final_result()['type'] or '' ]] + + + [[ final_result()['type'] == 'Net Profit C.F.B.L.' and formatLang(abs(final_result()['balance'])) or '' ]] + + + + + + [[ final_result()['type'] == 'Net Loss C.F.B.L.' and final_result()['type'] or '' ]] + + + [[ final_result()['type'] == 'Net Loss C.F.B.L.' and formatLang(abs(final_result()['balance'])) or '' ]] + + + + + + + + Total:([[ get_currency(data['form']) ]]) + + + [[ formatLang(abs(sum_dr())) ]] + + + Total:([[ get_currency(data['form']) ]]) + + + [[ formatLang(abs(sum_cr())) ]] + + + + + + + + + diff --git a/addons/account_report_india/report/rml_parse.py b/addons/account_report_india/report/rml_parse.py new file mode 100755 index 00000000000..2d2c1d5a763 --- /dev/null +++ b/addons/account_report_india/report/rml_parse.py @@ -0,0 +1,165 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from report import report_sxw +import xml.dom.minidom +import os, time +import osv +import re +import tools +import pooler +import re +import sys + + +class rml_parse(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(rml_parse, self).__init__(cr, uid, name, context=None) + self.localcontext.update({ + 'comma_me': self.comma_me, + 'format_date': self._get_and_change_date_format_for_swiss, + 'strip_name' : self._strip_name, + 'explode_name' : self._explode_name, + }) + + def comma_me(self,amount): + #print "#" + str(amount) + "#" + if not amount: + amount = 0.0 + if type(amount) is float : + amount = str('%.2f'%amount) + else : + amount = str(amount) + if (amount == '0'): + return ' ' + orig = amount + new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) + if orig == new: + return new + else: + return self.comma_me(new) + + def _ellipsis(self, string, maxlen=100, ellipsis = '...'): + ellipsis = ellipsis or '' + try: + return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen] + except Exception, e: + return False + + def _strip_name(self, name, maxlen=50): + return self._ellipsis(name, maxlen, '...') + + def _get_and_change_date_format_for_swiss (self,date_to_format): + date_formatted='' + if date_to_format: + date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') + return date_formatted + + def _explode_name(self,chaine,length): + # We will test if the size is less then account + full_string = '' + if (len(str(chaine)) <= length): + return chaine + # + else: + chaine = unicode(chaine,'utf8').encode('iso-8859-1') + rup = 0 + for carac in chaine: + rup = rup + 1 + if rup == length: + full_string = full_string + '\n' + full_string = full_string + carac + rup = 0 + else: + full_string = full_string + carac + + return full_string + + def makeAscii(self,str): + try: + Stringer = str.encode("utf-8") + except UnicodeDecodeError: + try: + Stringer = str.encode("utf-16") + except UnicodeDecodeError: + print "UTF_16 Error" + Stringer = str + else: + return Stringer + else: + return Stringer + return Stringer + + def explode_this(self,chaine,length): + #chaine = self.repair_string(chaine) + chaine = rstrip(chaine) + ast = list(chaine) + i = length + while i <= len(ast): + ast.insert(i,'\n') + i = i + length + chaine = str("".join(ast)) + return chaine + + def repair_string(self,chaine): + ast = list(chaine) + UnicodeAst = [] + _previouslyfound = False + i = 0 + #print str(ast) + while i < len(ast): + elem = ast[i] + try: + Stringer = elem.encode("utf-8") + except UnicodeDecodeError: + to_reencode = elem + ast[i+1] + print str(to_reencode) + Good_char = to_reencode.decode('utf-8') + UnicodeAst.append(Good_char) + i += i +2 + else: + UnicodeAst.append(elem) + i += i + 1 + return "".join(UnicodeAst) + + def ReencodeAscii(self,str): + print sys.stdin.encoding + try: + Stringer = str.decode("ascii") + except UnicodeEncodeError: + print "REENCODING ERROR" + return str.encode("ascii") + except UnicodeDecodeError: + print "DECODING ERROR" + return str.encode("ascii") + else: + print Stringer + return Stringer + + def _add_header(self, node, header=1): + if header==2: + rml_head = self.rml_header2 + else: + rml_head = self.rml_header + rml_head = rml_head.replace('',''' [[company.logo]] ''') + return True + + + diff --git a/addons/account_report_india/wizard/__init__.py b/addons/account_report_india/wizard/__init__.py new file mode 100755 index 00000000000..2a870d96fad --- /dev/null +++ b/addons/account_report_india/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import account_bs_report +import account_pl_report \ No newline at end of file diff --git a/addons/account_report_india/wizard/account_bs_report.py b/addons/account_report_india/wizard/account_bs_report.py new file mode 100644 index 00000000000..27c50b4b880 --- /dev/null +++ b/addons/account_report_india/wizard/account_bs_report.py @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import time + +from osv import osv, fields +from tools.translate import _ + +class account_bs_report(osv.osv_memory): + """ + This wizard will provide the account balance sheet report by periods, between any two dates. + """ + _name = 'account.bs.report' + _description = 'Account Balance Sheet Report' + _columns = { + 'Account_list': fields.many2one('account.account', 'Chart account', + required=True, domain = [('parent_id','=',False)]), + 'company_id': fields.many2one('res.company', 'Company', required=True), + 'display_account': fields.selection([('bal_movement','With movements'), + ('bal_solde','With balance is not equal to 0'), + ('bal_all','All'), + ],'Display accounts'), + 'display_type': fields.boolean("Landscape Mode"), + 'reserve_account_id': fields.many2one('account.account', 'Reserve & Surplus Account',required = True, + help='This Account is used for trasfering Profit/Loss(If It is Profit : Amount will be added, Loss : Amount will be duducted.), Which is calculated from Profilt & Loss Report', domain = [('type','=','payable')]), + 'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'), + 'state': fields.selection([('bydate','By Date'), + ('byperiod','By Period'), + ('all','By Date and Period'), + ('none','No Filter') + ],'Date/Period Filter'), + 'periods': fields.many2many('account.period', 'period_account_balance_rel', + 'report_id', 'period_id', 'Periods', + help='Keep empty for all open fiscal year'), + 'date_from': fields.date('Start date', required=True), + 'date_to': fields.date('End date', required=True), + } + + def _get_company(self, cr, uid, context=None): + user_obj = self.pool.get('res.users') + company_obj = self.pool.get('res.company') + user = user_obj.browse(cr, uid, uid, context=context) + if user.company_id: + return user.company_id.id + else: + return company_obj.search(cr, uid, [('parent_id', '=', False)])[0] + + _defaults={ + 'state' : 'none', + 'date_from' : time.strftime('%Y-01-01'), + 'date_to' : time.strftime('%Y-%m-%d'), + 'company_id' : _get_company, + 'fiscalyear' : False, + 'display_account': 'bal_all', + 'display_type': True, + } + + def next_view(self, cr, uid, ids, context=None): + obj_model = self.pool.get('ir.model.data') + if context is None: + context = {} + data = self.read(cr, uid, ids, [])[0] + context.update({'Account_list': data['Account_list'],'reserve_account_id':data['reserve_account_id']}) + model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_bs_report_view')]) + resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id'] + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'account.bs.report', + 'views': [(resource_id,'form')], + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': context + } + + def check_state(self, cr, uid, ids, context=None): + if context is None: + context = {} + data={} + data['ids'] = context['active_ids'] + data['form'] = self.read(cr, uid, ids, ['date_from', 'company_id', 'state', 'periods', 'date_to', 'display_account', 'display_type', 'fiscalyear'])[0] + data['form']['Account_list'] = context.get('Account_list',[]) + data['form']['reserve_account_id'] = context.get('reserve_account_id',[]) + data['form']['context'] = context + if data['form']['Account_list']: + data['model'] = 'ir.ui.menu' + else: + data['model'] = 'account.account' + + if data['form']['state'] == 'bydate' : + return self._check_date(cr, uid, data, context) + elif data['form']['state'] == 'byperiod': + if not data['form']['periods']: + raise osv.except_osv(_('Warning'),_('Please Enter Periods ! ')) + if data['form']['display_type']: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.balancesheet.horizontal', + 'datas': data, + 'nodestroy':True, + } + else: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.balancesheet', + 'datas': data, + 'nodestroy':True, + } + + def _check_date(self, cr, uid, data, context=None): + if context is None: + context = {} + sql = """ + SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ + cr.execute(sql,(data['form']['date_from'],)) + res = cr.dictfetchall() + if res: + + if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): + raise osv.except_osv(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop'])) + else: + if data['form']['display_type']: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.balancesheet.horizontal', + 'datas': data, + 'nodestroy':True, + } + else: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.balancesheet', + 'datas': data, + 'nodestroy':True, + } + else: + raise osv.except_osv(_('UserError'),_('Date not in a defined fiscal year')) + +account_bs_report() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report_india/wizard/account_bs_report_view.xml b/addons/account_report_india/wizard/account_bs_report_view.xml new file mode 100644 index 00000000000..a07ef94d81c --- /dev/null +++ b/addons/account_report_india/wizard/account_bs_report_view.xml @@ -0,0 +1,85 @@ + + + + + + Select period + account.bs.report + form + +
+ + + + +