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

Proposed by jftempo
Status: Merged
Merged at revision: 4753
Proposed branch: lp:~julie-w/unifield-server/US-3182
Merge into: lp:unifield-server
Diff against target: 123 lines (+63/-6)
2 files modified
bin/addons/account/report/account_liquidity_balance.py (+58/-2)
bin/addons/vertical_integration/report/hq_report_ocb.py (+5/-4)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-3182
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+340169@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/account/report/account_liquidity_balance.py'
2--- bin/addons/account/report/account_liquidity_balance.py 2017-05-26 15:28:23 +0000
3+++ bin/addons/account/report/account_liquidity_balance.py 2018-03-01 09:44:19 +0000
4@@ -41,13 +41,69 @@
5 def _get_register_data(self):
6 """
7 Returns a list of dicts, each containing the data of the liquidity registers for the selected period and instances
8+ For Cash & Bank registers the calculation is the one used in OCB VI.
9+ For Cheque Registers:
10+ - opening: balance at end of N-1 of entries which are not reconciled within period N-1 or before
11+ - calculated: always 0.00
12+ - closing: balance at end of N of entries which are not reconciled within period N or before
13 """
14+ res = []
15 period = self.pool.get('account.period').browse(self.cr, self.uid, self.period_id, context=self.context,
16 fields_to_fetch=['date_start', 'date_stop'])
17 period_yyyymm = "{0}{1}".format(self.year, self.month)
18- params = (tuple([period_yyyymm]), period.date_start, period.id, period.date_stop, tuple(self.instance_ids))
19+ # Cash and Bank registers
20+ reg_types = ('cash', 'bank')
21+ params = (tuple([period_yyyymm]), reg_types, period.date_start, reg_types, period.id, reg_types,
22+ period.date_stop, tuple(self.instance_ids))
23 self.cr.execute(self.liquidity_sql, params)
24- return self.cr.dictfetchall()
25+ cash_bank_res = self.cr.dictfetchall()
26+ res.extend(cash_bank_res)
27+ # Cheque registers
28+ cheque_sql = """
29+ SELECT i.code AS instance, j.code, j.name, %s AS period, req.opening, req.calculated, req.closing,
30+ c.name AS currency
31+ FROM res_currency c,
32+ (
33+ SELECT journal_id, account_id, SUM(col1) AS opening, SUM(col2) AS calculated, SUM(col3) AS closing
34+ FROM (
35+ (
36+ SELECT aml.journal_id AS journal_id, aml.account_id AS account_id,
37+ ROUND(SUM(amount_currency), 2) as col1, 0.00 as col2, 0.00 as col3
38+ FROM account_move_line AS aml
39+ LEFT JOIN account_journal j ON aml.journal_id = j.id
40+ WHERE j.type = 'cheque'
41+ AND aml.date < %s
42+ AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
43+ AND ((reconcile_id IS NULL AND reconcile_partial_id IS NULL) OR reconcile_date >= %s)
44+ GROUP BY aml.journal_id, aml.account_id
45+ )
46+ UNION
47+ (
48+ SELECT aml.journal_id AS journal_id, aml.account_id AS account_id, 0.00 as col1,
49+ 0.00 as col2, ROUND(SUM(amount_currency), 2) as col3
50+ FROM account_move_line AS aml
51+ LEFT JOIN account_journal j ON aml.journal_id = j.id
52+ WHERE j.type = 'cheque'
53+ AND aml.date <= %s
54+ AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
55+ AND ((reconcile_id IS NULL AND reconcile_partial_id IS NULL) OR reconcile_date > %s)
56+ GROUP BY aml.journal_id, aml.account_id
57+ )
58+ ) AS ssreq
59+ GROUP BY journal_id, account_id
60+ ORDER BY journal_id, account_id
61+ ) AS req, account_journal j, msf_instance i
62+ WHERE req.journal_id = j.id
63+ AND j.instance_id = i.id
64+ AND j.currency = c.id
65+ AND j.instance_id IN %s;
66+ """
67+ cheque_params = (tuple([period_yyyymm]), period.date_start, period.date_start, period.date_stop,
68+ period.date_stop, tuple(self.instance_ids))
69+ self.cr.execute(cheque_sql, cheque_params)
70+ cheque_res = self.cr.dictfetchall()
71+ res.extend(cheque_res)
72+ return res
73
74 def set_context(self, objects, data, ids, report_type=None):
75 # get the selection made by the user
76
77=== modified file 'bin/addons/vertical_integration/report/hq_report_ocb.py'
78--- bin/addons/vertical_integration/report/hq_report_ocb.py 2017-05-26 10:19:33 +0000
79+++ bin/addons/vertical_integration/report/hq_report_ocb.py 2018-03-01 09:44:19 +0000
80@@ -260,7 +260,7 @@
81 FROM account_move_line AS aml
82 LEFT JOIN account_journal j
83 ON aml.journal_id = j.id
84- WHERE j.type IN ('cash', 'bank', 'cheque')
85+ WHERE j.type IN %s
86 AND aml.date < %s
87 AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
88 GROUP BY aml.journal_id, aml.account_id
89@@ -271,7 +271,7 @@
90 FROM account_move_line AS aml
91 LEFT JOIN account_journal j
92 ON aml.journal_id = j.id
93- WHERE j.type IN ('cash', 'bank', 'cheque')
94+ WHERE j.type IN %s
95 AND aml.period_id = %s
96 AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
97 GROUP BY aml.journal_id, aml.account_id
98@@ -282,7 +282,7 @@
99 FROM account_move_line AS aml
100 LEFT JOIN account_journal j
101 ON aml.journal_id = j.id
102- WHERE j.type IN ('cash', 'bank', 'cheque')
103+ WHERE j.type IN %s
104 AND aml.date <= %s
105 AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
106 GROUP BY aml.journal_id, aml.account_id
107@@ -606,6 +606,7 @@
108 # + More than 1 request in 1 file: just use same filename for each request you want to be in the same file.
109 # + If you cannot do a SQL request to create the content of the file, do a simple request (with key) and add a postprocess function that returns the result you want
110 instance_name = 'OCB' # since US-949
111+ reg_types = ('cash', 'bank', 'cheque')
112 processrequests = [
113 {
114 'headers': ['XML_ID', 'Name', 'Reference', 'Partner type', 'Active/inactive'],
115@@ -646,7 +647,7 @@
116 'headers': ['Instance', 'Code', 'Name', 'Period', 'Opening balance', 'Calculated balance', 'Closing balance', 'Currency'],
117 'filename': instance_name + '_' + year + month + '_Liquidity Balances.csv',
118 'key': 'liquidity',
119- 'query_params': (tuple([period_yyyymm]), first_day_of_period, period.id, last_day_of_period, tuple(instance_ids)),
120+ 'query_params': (tuple([period_yyyymm]), reg_types, first_day_of_period, reg_types, period.id, reg_types, last_day_of_period, tuple(instance_ids)),
121 },
122 {
123 'headers': ['Name', 'Code', 'Donor code', 'Grant amount', 'Reporting CCY', 'State'],

Subscribers

People subscribed via source and target branches