~neobis/neobis-addons/6.1

« back to all changes in this revision

Viewing changes to reports_accounting_aeroo_nl/report/report_nl_balance.py

  • Committer: Elias Hermoso Illera
  • Date: 2012-08-20 09:47:46 UTC
  • Revision ID: elias@neobis.nl-20120820094746-sounm5o8ylu2sdox
[IMP] - Initial Version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###################################################################################
 
3
#
 
4
#    Dutch accounting module to generate reports.
 
5
#    Copyright (C) 2010-2012 Neobis ICT Dienstverlening BV (<http://www.neobis.nl>)
 
6
#
 
7
#    This program is free software: you can redistribute it and/or
 
8
#    modify it under the terms of the GNU Affero General Public
 
9
#    License as published by the Free Software Foundation, either
 
10
#    version 3 of the License, or (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
#    Affero General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU Affero General Public
 
18
#    License along with this program.  If not, see
 
19
#    <http://www.gnu.org/licenses/>.
 
20
#
 
21
###################################################################################
 
22
from report import report_sxw
 
23
 
 
24
 
 
25
class report_nl_balance(report_sxw.rml_parse):
 
26
 
 
27
    def __init__(self, cr, uid, name, context):
 
28
        super(report_nl_balance, self).__init__(cr, uid, name, context)
 
29
        self.selection_periods = []
 
30
        self.cr = cr
 
31
        self.uid = uid
 
32
        self.acc_nl = self.pool.get('nl.accounts')
 
33
        self.localcontext.update(
 
34
            {
 
35
                'assemble_data': self.assemble_data,
 
36
                'get_date_from': self.get_date_from,
 
37
                'get_date_to': self.get_date_to,
 
38
                'sum_credit_func': self.sum_credit_func,
 
39
                'sum_debit_func': self.sum_debit_func,
 
40
                'get_acclines': self.get_acclines,
 
41
                'get_difference': self.get_difference,
 
42
                'get_period_names': self.get_period_names,
 
43
            }
 
44
        )
 
45
        self.context = context
 
46
 
 
47
    def get_period_names(self):
 
48
        if not self.acc_nl.selection_periods:
 
49
            return "Unknown!?"
 
50
 
 
51
        period_obj = self.pool.get('account.period')
 
52
        periods = period_obj.browse(self.cr, self.uid, self.selection_periods)
 
53
        period_names = '%s t/m %s' % (periods[0].name, periods[-1].name)
 
54
        return period_names
 
55
 
 
56
 
 
57
    def assemble_data(self, data):
 
58
        self.acc_nl.assemble_data(self.cr, self.uid, data)
 
59
 
 
60
    def get_acclines(self):
 
61
        return self.acc_nl.get_acclines()
 
62
 
 
63
    def get_date_from(self):
 
64
        return self.date_from
 
65
 
 
66
    def get_date_to(self):
 
67
        return self.date_to
 
68
 
 
69
    def sum_credit_func(self):
 
70
        return self.acc_nl.sum_credit
 
71
 
 
72
    def sum_debit_func(self):
 
73
        return self.acc_nl.sum_debit
 
74
 
 
75
    def get_difference(self):
 
76
        return abs(self.acc_nl.sum_credit - self.acc_nl.sum_debit)
 
77
 
 
78
report_sxw.report_sxw(
 
79
    'report.nl.balance',
 
80
    'nl.accounts',
 
81
    'addons/nl_accounts/report/report_nl_balance.rml',
 
82
    parser = report_nl_balance,
 
83
    header = 2
 
84
)
 
85