2
In order to test the financing contract,
4
I create, in order, a account type, ...
6
!record {model: account.account.type, id: account_account_type_expense0}:
14
!record {model: account.account, id: test_expense}:
17
user_type: account_account_type_expense0
22
!record {model: account.analytic.account, id: analytic_account_OC1}:
29
!record {model: account.analytic.account, id: analytic_account_OC2}:
36
!record {model: account.analytic.account, id: analytic_account_FP1}:
41
- analytic_account_OC2
47
!record {model: account.analytic.account, id: analytic_account_FP2}:
52
- analytic_account_OC1
53
- analytic_account_OC2
57
I set the company currency's rate to 1 for the move
59
!record {model: res.currency.rate, id: currency_rate_test_3}:
60
name: !eval "'%s-01-01' %(datetime.now().year+1)"
64
I set another currency's rate to 100 for the move
66
!record {model: res.currency.rate, id: currency_rate_test_4}:
67
name: !eval "'%s-01-01' %(datetime.now().year+1)"
71
...an analytical journal, ...
73
!record {model: account.analytic.journal, id: analytic_journal_1}:
75
name: Cash Analytic Journal
80
!record {model: account.journal, id: account_journal_1}:
85
analytic_journal_id: analytic_journal_1
89
!record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}:
90
code: !eval "'FY%s'% (datetime.now().year+1)"
91
company_id: base.main_company
92
date_start: !eval "'%s-01-01' %(datetime.now().year+1)"
93
date_stop: !eval "'%s-12-31' %(datetime.now().year+1)"
94
name: !eval "'Fiscal Year %s' %(datetime.now().year+1)"
98
!record {model: account.period, id: account_period_mar0}:
99
company_id: base.main_company
100
date_start: !eval "'%s-03-01' %(datetime.now().year+1)"
101
date_stop: !eval "'%s-03-31' %(datetime.now().year+1)"
102
fiscalyear_id: account_fiscalyear_fiscalyear0
103
name: !eval "'Mar %s' %(datetime.now().year+1)"
107
... and a distribution.
109
!record {model: analytic.distribution, id: distribution_test}:
111
- analytic_id: analytic_account_OC1
113
currency_id: base.CHF
114
date: !eval "'%s-03-12' %(datetime.now().year+1)"
116
- analytic_id: funding_pool.analytic_account_msf_private_funds
117
cost_center_id: analytic_account_OC1
119
currency_id: base.CHF
120
date: !eval "'%s-03-12' %(datetime.now().year+1)"
121
- analytic_id: analytic_account_FP1
122
cost_center_id: analytic_account_OC1
124
currency_id: base.CHF
125
date: !eval "'%s-03-12' %(datetime.now().year+1)"
127
... and another distribution.
129
!record {model: analytic.distribution, id: distribution_test_2}:
131
- analytic_id: analytic_account_OC1
133
currency_id: base.CHF
134
date: !eval "'%s-03-12' %(datetime.now().year+1)"
135
- analytic_id: analytic_account_OC2
137
currency_id: base.CHF
138
date: !eval "'%s-03-12' %(datetime.now().year+1)"
140
- analytic_id: analytic_account_FP2
141
cost_center_id: analytic_account_OC1
143
currency_id: base.CHF
144
date: !eval "'%s-03-12' %(datetime.now().year+1)"
145
- analytic_id: analytic_account_FP2
146
cost_center_id: analytic_account_OC2
148
currency_id: base.CHF
149
date: !eval "'%s-03-12' %(datetime.now().year+1)"
151
I create an account move line with all of this.
153
!record {model: account.move.line, id: move_line_test}:
155
journal_id: account_journal_1
156
period_id: account_period_mar0
157
account_id: test_expense
158
currency_id: base.CHF
159
date: !eval "'%s-03-12' %(datetime.now().year+1)"
160
debit_currency: 4242.0
161
analytic_distribution_id: distribution_test
163
I create an account move line with all of this.
165
!record {model: account.move.line, id: move_line_test_2}:
167
journal_id: account_journal_1
168
period_id: account_period_mar0
169
account_id: test_expense
170
currency_id: base.CHF
171
date: !eval "'%s-03-12' %(datetime.now().year+1)"
172
debit_currency: 12345.0
173
analytic_distribution_id: distribution_test_2
176
Analytic lines are created from it
178
!python {model: account.move.line}: |
179
self.create_analytic_lines(cr, uid, [ref("move_line_test"), ref("move_line_test_2")], context={})
182
Create a donor (almost empty)
184
!record {model: financing.contract.donor, id: donor1}:
190
!record {model: financing.contract.contract, id: contract1}:
194
grant_name: "Grant Name"
195
grant_amount: 100000.0
196
eligibility_from_date: !eval "'%s-01-01' %(datetime.now().year+1)"
197
eligibility_to_date: !eval "'%s-12-31' %(datetime.now().year+1)"
198
reporting_currency: base.CHF
200
- funding_pool_id: analytic_account_FP1
202
- funding_pool_id: analytic_account_FP2
205
- analytic_account_OC1
212
Assert that total retrieved for funded is 2121 CHF, and project is 12121 CHF
214
!python {model: financing.contract.contract}: |
215
context = {"reporting_currency": ref("base.CHF"),
216
"reporting_type": "all",
217
"currency_table_id": None}
218
contract = self.pool.get('financing.contract.contract').browse(cr, uid, ref("contract1"), context=context)
219
assert len(contract.actual_line_ids) == 1, ("No reporting line!")
220
assert contract.actual_line_ids[0].allocated_real == 2121, ("Allocation is not what is expected!")
221
assert contract.actual_line_ids[0].project_real == 12121, ("Project is not what is expected!")
223
Assert that total retrieved for funded is 212100 EUR
225
!python {model: financing.contract.contract}: |
226
context = {"reporting_currency": ref("base.EUR"),
227
"reporting_type": "all",
228
"currency_table_id": None}
229
contract = self.pool.get('financing.contract.contract').browse(cr, uid, ref("contract1"), context=context)
230
assert len(contract.actual_line_ids) == 1, ("No reporting line!")
231
assert contract.actual_line_ids[0].allocated_real == 212100, ("Allocation is not what is expected!")
232
assert contract.actual_line_ids[0].project_real == 1212100, ("Project is not what is expected!")
234
Create a currency table
236
!record {model: res.currency.table, id: test_table}:
240
Change test currency's rate for this table
242
!python {model: res.currency.rate}: |
244
rate_ids = self.pool.get("res.currency").search(cr, uid, [("reference_currency_id", "=", ref("base.EUR")),
245
("currency_table_id", "=", ref("test_table"))])
247
assert len(rate_ids) == 1, "Something wrong with the currency table creation"
248
self.create(cr, uid, {"name": "%s-03-01" %(datetime.datetime.now().year+1),
250
"currency_id": rate_ids[0]})
252
Assert that total retrieved for funded with currency table is 21210 EUR
254
!python {model: financing.contract.contract}: |
255
context = {"reporting_currency": ref("base.EUR"),
256
"reporting_type": "all",
257
"currency_table_id": ref("test_table")}
258
contract = self.pool.get('financing.contract.contract').browse(cr, uid, ref("contract1"), context=context)
259
assert len(contract.actual_line_ids) == 1, ("No reporting line!")
260
assert contract.actual_line_ids[0].allocated_real == 21210, ("Allocation is not what is expected!")
261
assert contract.actual_line_ids[0].project_real == 121210, ("Project is not what is expected!")
b'\\ No newline at end of file'