From 2f2eb640991b10e6f52e3155e4b421868a7b2776 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 24 Apr 2007 17:22:54 +0000 Subject: [PATCH] New Module: account_report: fiscal statement and reports /+ indicators L10N_BE: demo data for fiscal report: bilan compte des r?\233sultats Indicateurs bzr revid: fp@tinyerp.com-23e471e88a1d7b0e23304ab674652c87e8b737c5 --- addons/account_report/__init__.py | 29 ++++ addons/account_report/__terp__.py | 17 ++ addons/account_report/account.py | 148 ++++++++++++++++++ addons/account_report/account_view.xml | 143 +++++++++++++++++ .../account_tax_include/invoice_tax_incl.py | 1 - addons/l10n_be/__terp__.py | 4 +- addons/l10n_be/account.report.report.csv | 21 +++ 7 files changed, 360 insertions(+), 3 deletions(-) create mode 100644 addons/account_report/__init__.py create mode 100644 addons/account_report/__terp__.py create mode 100644 addons/account_report/account.py create mode 100644 addons/account_report/account_view.xml create mode 100644 addons/l10n_be/account.report.report.csv diff --git a/addons/account_report/__init__.py b/addons/account_report/__init__.py new file mode 100644 index 00000000000..c3fa84c6cfa --- /dev/null +++ b/addons/account_report/__init__.py @@ -0,0 +1,29 @@ +############################################################################## +# +# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Fabien Pinckaers +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import account diff --git a/addons/account_report/__terp__.py b/addons/account_report/__terp__.py new file mode 100644 index 00000000000..d3f999e4bc0 --- /dev/null +++ b/addons/account_report/__terp__.py @@ -0,0 +1,17 @@ +{ + "name" : "Reporting for accounting", + "version" : "1.0", + "depends" : ["account"], + "author" : "Tiny", + "description": """Financial and accounting reporting""", + "website" : "http://tinyerp.com/module_account.html", + "category" : "Generic Modules/Accounting", + "init_xml" : [ ], + "demo_xml" : [ ], + "update_xml" : [ "account_view.xml" ], +# "translations" : { +# "fr": "i18n/french_fr.csv" +# }, + "active": False, + "installable": True +} diff --git a/addons/account_report/account.py b/addons/account_report/account.py new file mode 100644 index 00000000000..7c102700dfe --- /dev/null +++ b/addons/account_report/account.py @@ -0,0 +1,148 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $ +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## +import time +import netsvc +from osv import fields, osv + +from tools.misc import currency + +import mx.DateTime +from mx.DateTime import RelativeDateTime, now, DateTime, localtime + + +class account_report(osv.osv): + _name = "account.report.report" + _description = "Account reporting" + def _amount_get(self, cr, uid, ids, field_name, arg, context={}): + def _calc_credit(*code): + acc = self.pool.get('account.account') + acc_id = acc.search(cr, uid, [('code','in',code)]) + return reduce(lambda y,x=0: x.credit+y, acc.browse(cr, uid, acc_id, context),0) + def _calc_debit(*code): + acc = self.pool.get('account.account') + acc_id = acc.search(cr, uid, [('code','in',code)]) + return reduce(lambda y,x=0: x.debit+y, acc.browse(cr, uid, acc_id, context),0) + def _calc_balance(*code): + acc = self.pool.get('account.account') + acc_id = acc.search(cr, uid, [('code','in',code)]) + return reduce(lambda y,x=0: x.balance+y, acc.browse(cr, uid, acc_id, context),0) + def _calc_report(*code): + acc = self.pool.get('account.report.report') + acc_id = acc.search(cr, uid, [('code','in',code)]) + return reduce(lambda y,x=0: x.amount+y, acc.browse(cr, uid, acc_id, context),0) + result = {} + for rep in self.browse(cr, uid, ids, context): + objdict = { + 'debit': _calc_debit, + 'credit': _calc_credit, + 'balance': _calc_balance, + 'report': _calc_report, + } + if field_name=='status': + fld_name = 'expression_status' + else: + fld_name = 'expression' + try: + val = eval(getattr(rep, fld_name), objdict) + except: + val = 0.0 + if field_name=='status': + if val<-1: + result[rep.id] = 'very bad' + elif val<0: + result[rep.id] = 'bad' + elif val==0: + result[rep.id] = 'normal' + elif val<1: + result[rep.id] = 'good' + else: + result[rep.id] = 'excellent' + else: + result[rep.id] = val + return result + def onchange_parent_id(self, cr, uid, ids, parent_id): + v={} + if parent_id: + acc=self.pool.get('account.report.report').browse(cr,uid,parent_id) + v['type']=acc.type + if int(acc.style)<6: + v['style']=str(int(acc.style)+1) + return {'value':v} + _columns = { + 'name': fields.char('Name', size=64, required=True), + 'active': fields.boolean('Active'), + 'sequence': fields.integer('Sequence'), + 'code': fields.char('Code', size=64, required=True), + 'type': fields.selection([('fiscal', 'Fiscal statement'),('indicator','Indicator'),('other','Others')], 'Type', required=True), + 'expression': fields.char('Expression', size=240, required=True), + 'expression_status': fields.char('Status expression', size=240, required=True), + 'parent_id': fields.many2one('account.report.report', 'Parent'), + 'child_ids': fields.one2many('account.report.report', 'parent_id', 'Childs'), + 'note': fields.text('Note'), + 'amount': fields.function(_amount_get, method=True, string='Value'), + 'status': fields.function(_amount_get, + method=True, + type="selection", + selection=[ + ('very bad', 'Very Bad'), + ('bad', 'Bad'), + ('normal', ''), + ('good', 'Good'), + ('excellent', 'Excellent') + ], + string='Status' + ), + 'style': fields.selection([('1','Header 1'), ('2','Header 2'), ('3','Header 3'), ('4','Header 4'), ('5','Normal'), ('6', 'Small')], 'Style', required=True), + } + _defaults = { + 'style': lambda *args: '5', + 'active': lambda *args: True, + 'type': lambda *args: 'indicator' + } + def name_search(self, cr, user, name, args=[], operator='ilike', context={}): + ids = [] + if name: + ids = self.search(cr, user, [('code','=',name)]+ args) + if not ids: + ids = self.search(cr, user, [('name',operator,name)]+ args) + else: + ids = self.search(cr, user, args) + return self.name_get(cr, user, ids, context=context) + + # + # Put an expression to valid expression and expression_status + # + _constraints = [ + + ] + _sql_constraints = [ + ('code_uniq', 'unique (code)', 'The code of the report entry must be unique !') + ] +account_report() diff --git a/addons/account_report/account_view.xml b/addons/account_report/account_view.xml new file mode 100644 index 00000000000..b66bc8c26e7 --- /dev/null +++ b/addons/account_report/account_view.xml @@ -0,0 +1,143 @@ + + + + + + account.report.report.form + account.report.report + form + +
+ + + + + + + + + + + + + + + + + +
+
+
+ + + account.report.report.form + account.report.report + form + form,tree + + + + account.report.report.tree + account.report.report + tree + + + + + account.report.report.tree + account.report.report + tree + + child_ids + + + + + + + + + + + + account.report.report.tree + account.fiscalyear + tree + + [('parent_id','=',False)] + + + + + + account.report.report.tree + account.fiscalyear + tree + + [('type','=','fiscal'),('parent_id','=',False)] + + + + + account.report.report.tree + account.fiscalyear + tree + + [('type','=','indicator'),('parent_id','=',False)] + + + + + account.report.report.tree + account.fiscalyear + tree + + [('type','=','other'),('parent_id','=',False)] + + + + +
+
diff --git a/addons/account_tax_include/invoice_tax_incl.py b/addons/account_tax_include/invoice_tax_incl.py index 1866dc79e68..e9eb8dda222 100644 --- a/addons/account_tax_include/invoice_tax_incl.py +++ b/addons/account_tax_include/invoice_tax_incl.py @@ -148,7 +148,6 @@ class account_invoice_line(osv.osv): cur_obj = self.pool.get('res.currency') ait_obj = self.pool.get('account.invoice.tax') cur = inv.currency_id - for line in inv.invoice_line: price_unit = line.price_unit if line.product_id: diff --git a/addons/l10n_be/__terp__.py b/addons/l10n_be/__terp__.py index fe15a2246a1..b6d7ca8d8aa 100644 --- a/addons/l10n_be/__terp__.py +++ b/addons/l10n_be/__terp__.py @@ -3,9 +3,9 @@ "version" : "1.0", "author" : "Tiny", "category" : "Localisation/Account charts", - "depends" : ["base", "account"], + "depends" : ["base", "account", "account_report"], "init_xml" : [], - "demo_xml" : ["account_demo.xml"], + "demo_xml" : ["account_demo.xml","account.report.report.csv"], "update_xml" : ["account_pcmn_belgium.xml"], "active": False, "installable": True diff --git a/addons/l10n_be/account.report.report.csv b/addons/l10n_be/account.report.report.csv new file mode 100644 index 00000000000..0ae4993b5de --- /dev/null +++ b/addons/l10n_be/account.report.report.csv @@ -0,0 +1,21 @@ +expression,note,parent_id,sequence,expression_status,style,type,code,name +0,,,,0,1,indicator,BILAN,Bilan +"report('BIMMO','BSTOCK','BREAL','BDISPO')",,BILAN,,0,2,fiscal,Actif,Actif +balance('2'),,Actif,,0,3,indicator,BIMMO,Valeurs immobilisées +balance('3'),,Actif,2,0,3,indicator,BSTOCK,Stocks +balance('4'),,Actif,3,0,3,indicator,BREAL,Réalisable +balance('5'),,Actif,4,0,3,fiscal,BDISPO,Disponible +report('BCAP') + report('BRESNET'),,BILAN,1,0,2,fiscal,PASSIF,Passif +balance('1'),,PASSIF,1,0,5,indicator,BCAP,Capitaux propores +-balance('7')+balance('6'),,PASSIF,,0,3,fiscal,BRESNET,Résultat net +0,,,,0,1,fiscal,CRES,Compte des résultats +"report('CCHAR','CBENEF')",,CRES,,0,2,fiscal,CRESACTIF,Résultat Actif +balance('6'),,CRESACTIF,,0,2,fiscal,CCHAR,Total des charges +report('CRESPROD'),,CRES,,0,2,fiscal,CRESPASSIF,Résultat Passif +-balance('7'),,CRESPASSIF,,0,2,fiscal,CRESPROD,Total des produits +-balance('7')+balance('6'),,CRESACTIF,,0,2,fiscal,CBENEF,Résultat (Bénéfice) +0,,,,0,3,indicator,IIMMO,Immobilisations +"balance('1')/balance(map(str(range(21,29))))","Dans une entreprise normalement équilibrée, les valeurs immobilisées sont couvertes en premier lieu par les capitaux propres et, en second lieu, par tout ou partie du passif à long terme. Idéalement, ce ratio (rapport entre capitaux permanents et les valeurs immobilisées) doit être suppérieur à l'unité.",IIMMO,,"balance('1')/balance(map(str(range(21,29)))) - 1",3,indicator,CIMMO,Couverture des immobilisations +0,,,,0,2,indicator,ITRE,Trésorerie +"balance('3','4','5') / balance('101','13','15','16','17','18')",Détermine si l'entreprise a la possibilité de s'acquitter de ses dettes à court terme dans des conditions normales. Calculé comme suit: (Stocks + Réalisable + Disponible ) / Passif exigible à court terme,ITRE,,"balance('3','4','5') / balance('101','13','15','16','17','18')",3,indicator,IFR,Indice du fond de roulement +"balance('4','5') / balance('101','13','15','16','17','18')",,ITRE,,"balance('4','5') / balance('101','13','15','16','17','18')",5,indicator,RTRE,Ratio de trésorerie