Merge lp:~julie-w/unifield-server/US-4028 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4838
Proposed branch: lp:~julie-w/unifield-server/US-4028
Merge into: lp:unifield-server
Diff against target: 161 lines (+109/-0)
3 files modified
bin/addons/register_accounting/report/liquidity_position_pdf.rml (+12/-0)
bin/addons/register_accounting/report/liquidity_position_xls.mako (+31/-0)
bin/addons/register_accounting/report/report_liquidity_position.py (+66/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-4028
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+341630@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/register_accounting/report/liquidity_position_pdf.rml'
2--- bin/addons/register_accounting/report/liquidity_position_pdf.rml 2016-06-08 10:12:30 +0000
3+++ bin/addons/register_accounting/report/liquidity_position_pdf.rml 2018-03-19 10:53:17 +0000
4@@ -140,6 +140,18 @@
5 <td><para style="right">[[ formatLang(getPendingCheques()['registers'][journal]['amount_func_currency'], digits=2, grouping=True) or '0.00']]</para></td>
6 <td><para style="text">[[ getFuncCurrency() ]]</para></td>
7 </tr>
8+ <!-- REVALUATION LINES -->
9+ <tr>
10+ [[ repeatIn(getRevaluationLines(), 'rev_cur') ]]
11+ <td><para style="text">[[ getRevaluationLines()[rev_cur]['prop_instance'] ]]</para></td>
12+ <td><para style="text">[[ getRevaluationLines()[rev_cur]['journal_code'] ]] - [[ getRevaluationLines()[rev_cur]['journal_name'] ]]</para></td>
13+ <td><para style="text"></para></td>
14+ <td><para style="text"></para></td>
15+ <td><para style="right">[[ formatLang(getRevaluationLines()[rev_cur]['booking_amount'], digits=2, grouping=True) or '0.00']]</para></td>
16+ <td><para style="text">[[ str(rev_cur) ]]</para></td>
17+ <td><para style="right">[[ formatLang(getRevaluationLines()[rev_cur]['functional_amount'], digits=2, grouping=True) or '0.00']]</para></td>
18+ <td><para style="text">[[ getFuncCurrency() ]]</para></td>
19+ </tr>
20 </blockTable>
21
22 <section>
23
24=== modified file 'bin/addons/register_accounting/report/liquidity_position_xls.mako'
25--- bin/addons/register_accounting/report/liquidity_position_xls.mako 2017-03-14 10:03:52 +0000
26+++ bin/addons/register_accounting/report/liquidity_position_xls.mako 2018-03-19 10:53:17 +0000
27@@ -536,6 +536,37 @@
28 </Row>
29 % endfor
30
31+ <!-- REVALUATION LINES -->
32+ % for rev_cur in getRevaluationLines():
33+ <Row ss:AutoFitHeight="0" ss:Height="25.5" ss:StyleID="s35">
34+ <Cell ss:StyleID="s25">
35+ <Data ss:Type="String">${ getRevaluationLines()[rev_cur]['prop_instance']|x }</Data>
36+ </Cell>
37+ <Cell ss:StyleID="s25">
38+ <Data ss:Type="String">${ getRevaluationLines()[rev_cur]['journal_code']|x }</Data>
39+ </Cell>
40+ <Cell ss:StyleID="s25">
41+ <Data ss:Type="String">${ getRevaluationLines()[rev_cur]['journal_name']|x }</Data>
42+ </Cell>
43+ <Cell ss:StyleID="s25"/>
44+ <Cell ss:StyleID="s25"/>
45+ <Cell ss:StyleID="s25"/>
46+ <Cell ss:StyleID="s25"/>
47+ <Cell ss:StyleID="s26">
48+ <Data ss:Type="Number">${ getRevaluationLines()[rev_cur]['booking_amount'] or '0.00' }</Data>
49+ </Cell>
50+ <Cell ss:StyleID="s25">
51+ <Data ss:Type="String">${ str(rev_cur)|x }</Data>
52+ </Cell>
53+ <Cell ss:MergeAcross="1" ss:StyleID="s26">
54+ <Data ss:Type="Number">${ getRevaluationLines()[rev_cur]['functional_amount'] or '0.00' }</Data>
55+ </Cell>
56+ <Cell ss:StyleID="s25">
57+ <Data ss:Type="String">${ getFuncCurrency()|x }</Data>
58+ </Cell>
59+ </Row>
60+ % endfor
61+
62 % for cur in pending_cheques['currency_amounts']:
63 <Row ss:AutoFitHeight="0" ss:Height="25.5" ss:StyleID="s35">
64 <Cell ss:StyleID="s25c"/>
65
66=== modified file 'bin/addons/register_accounting/report/report_liquidity_position.py'
67--- bin/addons/register_accounting/report/report_liquidity_position.py 2017-11-30 10:12:28 +0000
68+++ bin/addons/register_accounting/report/report_liquidity_position.py 2018-03-19 10:53:17 +0000
69@@ -33,6 +33,7 @@
70 self.registers = {}
71 self.func_currency = {}
72 self.pending_cheques = {}
73+ self.revaluation_lines = {}
74 self.func_currency_id = 0
75 self.total_func_calculated_balance = 0
76 self.total_func_register_balance = 0
77@@ -49,6 +50,7 @@
78 'getOpeningBalance': self.getOpeningBalance,
79 'getPendingCheques': self.getPendingCheques,
80 'getGrandTotalRegCurrency': self.getGrandTotalRegCurrency,
81+ 'getRevaluationLines': self.getRevaluationLines,
82 })
83 return
84
85@@ -208,6 +210,69 @@
86 state = _('Not Created')
87 return state
88
89+ def getRevaluationLines(self):
90+ """
91+ Returns a dict with key = currency, and value = dict of the data to display for the revaluation entries in this currency.
92+ Entries taken into account are: booked in the Revaluation journal of the current instance, on the accounts used
93+ for Cheque Registers, with a Posting date in the selected period or before, and not fully reconciled.
94+ """
95+ if not self.revaluation_lines:
96+ pool = pooler.get_pool(self.cr.dbname)
97+ journal_obj = pool.get('account.journal')
98+ aml_obj = pool.get('account.move.line')
99+ journal_ids = journal_obj.search(self.cr, self.uid, [('type', '=', 'revaluation'),
100+ ('is_current_instance', '=', True)], order='NO_ORDER')
101+ aml_domain = [('journal_id', 'in', journal_ids),
102+ ('date', '<=', self.getPeriod().date_stop),
103+ ('reconcile_id', '=', False)]
104+ cheque_journal_ids = journal_obj.search(self.cr, self.uid, [('type', '=', 'cheque'),
105+ ('is_current_instance', '=', True)], limit=1)
106+ if cheque_journal_ids:
107+ cheque_journal = journal_obj.browse(self.cr, self.uid, cheque_journal_ids[0],
108+ fields_to_fetch=['default_debit_account_id', 'default_credit_account_id'])
109+ account_ids = [cheque_journal.default_debit_account_id.id, cheque_journal.default_credit_account_id.id]
110+ aml_domain.append(('account_id', 'in', account_ids))
111+ aml_ids = aml_obj.search(self.cr, self.uid, aml_domain, order='NO_ORDER')
112+ revaluation_lines = {}
113+ fields_list = ['currency_id', 'journal_id', 'debit_currency', 'credit_currency', 'debit', 'credit']
114+ for aml in aml_obj.browse(self.cr, self.uid, aml_ids, fields_to_fetch=fields_list):
115+ curr = aml.currency_id and aml.currency_id.name or ''
116+ if curr not in revaluation_lines:
117+ revaluation_lines[curr] = {}
118+ # initialize amounts
119+ revaluation_lines[curr]['booking_amount'] = 0.0
120+ revaluation_lines[curr]['functional_amount'] = 0.0
121+ # same Prop. instance and journal for all entries
122+ revaluation_lines[curr]['prop_instance'] = aml.journal_id.instance_id.name
123+ revaluation_lines[curr]['journal_code'] = aml.journal_id.code
124+ revaluation_lines[curr]['journal_name'] = aml.journal_id.name
125+ revaluation_lines[curr]['booking_amount'] += (aml.debit_currency or 0.0) - (aml.credit_currency or 0.0)
126+ revaluation_lines[curr]['functional_amount'] += (aml.debit or 0.0) - (aml.credit or 0.0)
127+ self.revaluation_lines = revaluation_lines
128+ return self.revaluation_lines
129+
130+ def _update_totals_with_revaluation_lines(self, pending_cheques):
131+ """
132+ Adds the revaluation lines values to:
133+ - Pending Cheques subtotals per currency
134+ - Total Cheque
135+ - Grand Total Register per currency
136+ """
137+ for rev_cur in self.getRevaluationLines():
138+ rev_fctal = self.getRevaluationLines()[rev_cur]['functional_amount'] or 0.0
139+ rev_booking = self.getRevaluationLines()[rev_cur]['booking_amount'] or 0.0
140+ if rev_cur not in pending_cheques['currency_amounts']:
141+ pending_cheques['currency_amounts'][rev_cur] = {
142+ 'total_amount_reg_currency': 0.0,
143+ 'total_amount_func_currency': 0.0,
144+ }
145+ pending_cheques['currency_amounts'][rev_cur]['total_amount_reg_currency'] += rev_booking
146+ pending_cheques['currency_amounts'][rev_cur]['total_amount_func_currency'] += rev_fctal
147+ pending_cheques['total_cheque'] += rev_fctal
148+ if rev_cur not in self.grand_total_reg_currency:
149+ self.grand_total_reg_currency[rev_cur] = 0.0
150+ self.grand_total_reg_currency[rev_cur] += rev_booking
151+
152 def getPendingCheques(self):
153 '''
154 Get the pending cheques data from the selected period AND the previous ones. Gives:
155@@ -285,6 +350,7 @@
156
157 # Add amount to get the "global" Total for all currencies (in functional currency)
158 pending_cheques['total_cheque'] += amount_func_currency
159+ self._update_totals_with_revaluation_lines(pending_cheques)
160 self.pending_cheques = pending_cheques
161 return pending_cheques
162

Subscribers

People subscribed via source and target branches