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.analytic.account, id: test_destination}:
15
name: "Test Destination"
21
!record {model: account.account, id: test_expense}:
24
user_type: account_account_type_expense0
29
...a destination link, ...
31
!record {model: account.destination.link, id: test_destination_link}:
32
account_id: test_expense
33
destination_id: test_destination
37
!record {model: account.analytic.account, id: analytic_account_OC1}:
44
!record {model: account.analytic.account, id: analytic_account_OC2}:
51
!record {model: account.analytic.account, id: analytic_account_FP1}:
56
- analytic_account_OC2
57
tuple_destination_account_ids:
58
- test_destination_link
62
!record {model: account.analytic.account, id: analytic_account_FP2}:
67
- analytic_account_OC1
68
- analytic_account_OC2
69
tuple_destination_account_ids:
70
- test_destination_link
72
I set the company currency's rate to 1 for the move
74
!record {model: res.currency.rate, id: currency_rate_test_3}:
75
name: !eval "'%s-01-01' %(datetime.now().year+1)"
79
I set another currency's rate to 100 for the move
81
!record {model: res.currency.rate, id: currency_rate_test_4}:
82
name: !eval "'%s-01-01' %(datetime.now().year+1)"
86
...an analytical journal, ...
88
!record {model: account.analytic.journal, id: analytic_journal_1}:
90
name: Cash Analytic Journal
93
I create a cash account type
95
!record {model: account.account.type, id: account_account_type_cash_0}:
103
I create a X11003 Cash Account.
105
!record {model: account.account, id: account_account_cash0}:
107
company_id: base.main_company
108
currency_mode: current
112
user_type : account_account_type_cash_0
113
activation_date: !eval time.strftime('%Y-01-01')
117
!record {model: account.journal, id: account_journal_1}:
122
analytic_journal_id: analytic_journal_1
123
default_debit_account_id: account_account_cash0
124
default_credit_account_id: account_account_cash0
126
...a fiscal year, ...
128
!record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}:
129
code: !eval "'FY%s'% (datetime.now().year+1)"
130
company_id: base.main_company
131
date_start: !eval "'%s-01-01' %(datetime.now().year+1)"
132
date_stop: !eval "'%s-12-31' %(datetime.now().year+1)"
133
name: !eval "'Fiscal Year %s' %(datetime.now().year+1)"
137
!record {model: account.period, id: account_period_mar0}:
138
company_id: base.main_company
139
date_start: !eval "'%s-03-01' %(datetime.now().year+1)"
140
date_stop: !eval "'%s-03-31' %(datetime.now().year+1)"
141
fiscalyear_id: account_fiscalyear_fiscalyear0
142
name: !eval "'Mar %s' %(datetime.now().year+1)"
147
... and a distribution.
149
!record {model: analytic.distribution, id: distribution_test}:
151
- analytic_id: analytic_distribution.analytic_account_msf_private_funds
152
cost_center_id: analytic_account_OC1
153
destination_id: test_destination
155
currency_id: base.CHF
156
date: !eval "'%s-03-12' %(datetime.now().year+1)"
157
- analytic_id: analytic_account_FP1
158
cost_center_id: analytic_account_OC2
159
destination_id: test_destination
161
currency_id: base.CHF
162
date: !eval "'%s-03-12' %(datetime.now().year+1)"
164
... and another distribution.
166
!record {model: analytic.distribution, id: distribution_test_2}:
168
- analytic_id: analytic_account_FP1
169
cost_center_id: analytic_account_OC2
170
destination_id: test_destination
172
currency_id: base.CHF
173
date: !eval "'%s-03-12' %(datetime.now().year+1)"
174
- analytic_id: analytic_account_FP2
175
cost_center_id: analytic_account_OC2
176
destination_id: test_destination
178
currency_id: base.CHF
179
date: !eval "'%s-03-12' %(datetime.now().year+1)"
180
- analytic_id: analytic_account_FP2
181
cost_center_id: analytic_account_OC1
182
destination_id: test_destination
184
currency_id: base.CHF
185
date: !eval "'%s-03-12' %(datetime.now().year+1)"
187
I create an account move line with all of this.
189
!record {model: account.move.line, id: move_line_test}:
191
journal_id: account_journal_1
192
period_id: account_period_mar0
193
account_id: test_expense
194
currency_id: base.CHF
195
date: !eval "'%s-03-12' %(datetime.now().year+1)"
196
document_date: !eval "'%s-03-12' %(datetime.now().year+1)"
197
debit_currency: 4242.0
198
analytic_distribution_id: distribution_test
200
I create an account move line with all of this.
202
!record {model: account.move.line, id: move_line_test_2}:
204
journal_id: account_journal_1
205
period_id: account_period_mar0
206
account_id: test_expense
207
currency_id: base.CHF
208
date: !eval "'%s-03-12' %(datetime.now().year+1)"
209
document_date: !eval "'%s-03-12' %(datetime.now().year+1)"
210
debit_currency: 12500.0
211
analytic_distribution_id: distribution_test_2
213
Analytic lines are created from it
215
!python {model: account.move.line}: |
216
self.create_analytic_lines(cr, uid, [ref("move_line_test"), ref("move_line_test_2")], context={})
218
Create a donor (almost empty)
220
!record {model: financing.contract.donor, id: donor1}:
226
!record {model: financing.contract.contract, id: contract1}:
230
instance_id: !ref {search: "[]", model: msf.instance}
231
grant_amount: 100000.0
232
eligibility_from_date: !eval "'%s-01-01' %(datetime.now().year+1)"
233
eligibility_to_date: !eval "'%s-12-31' %(datetime.now().year+1)"
234
reporting_currency: base.CHF
236
- funding_pool_id: analytic_account_FP1
238
- funding_pool_id: analytic_account_FP2
241
- analytic_account_OC2
245
account_destination_ids:
246
- test_destination_link
248
Assert that total retrieved for funded is 7121 CHF, and project is 12121 CHF
250
!python {model: financing.contract.contract}: |
251
context = {"reporting_currency": ref("base.CHF"),
252
"reporting_type": "all",
253
"currency_table_id": None}
254
contract = self.pool.get('financing.contract.contract').browse(cr, uid, ref("contract1"), context=context)
255
#assert len(contract.actual_line_ids) == 1, ("No reporting line!")
256
# assert contract.actual_line_ids[0].allocated_real == 2121, ("Allocation is not what is expected! %s" % contract.actual_line_ids[0].allocated_real)
257
#assert contract.actual_line_ids[0].allocated_real == 7121, ("Allocation is not what is expected!")
258
#assert contract.actual_line_ids[0].project_real == 12121, ("Project is not what is expected!")
260
Assert that total retrieved for funded is 712100 EUR
262
!python {model: financing.contract.contract}: |
263
context = {"reporting_currency": ref("base.EUR"),
264
"reporting_type": "all",
265
"currency_table_id": None}
266
contract = self.pool.get('financing.contract.contract').browse(cr, uid, ref("contract1"), context=context)
267
#assert len(contract.actual_line_ids) == 1, ("No reporting line!")
268
# assert contract.actual_line_ids[0].allocated_real == 212100, ("Allocation is not what is expected! %s" % contract.actual_line_ids[0].allocated_real)
269
#assert contract.actual_line_ids[0].allocated_real == 712100, ("Allocation is not what is expected!")
270
#assert contract.actual_line_ids[0].project_real == 1212100, ("Project is not what is expected!")
272
Create a currency table
274
!record {model: res.currency.table, id: test_table}:
278
Import table currency rates
280
!python {model: import.table.currencies}: |
283
import_file = '"Currency Code","Rate"\n"EUR","10.0"\n"CHF","1.0"'
284
wizard = self.create(cr, uid, {'rate_date': "%s-03-01" %(datetime.datetime.now().year+1),
285
'import_file': base64.encodestring(import_file)}, context={})
286
self.import_table_rates(cr, uid, [wizard], context={'active_id': ref("test_table")})
288
Assert that total retrieved for funded with currency table is 71210 EUR
290
!python {model: financing.contract.contract}: |
291
context = {"reporting_currency": ref("base.EUR"),
292
"reporting_type": "all",
293
"currency_table_id": ref("test_table")}
294
contract = self.pool.get('financing.contract.contract').browse(cr, uid, ref("contract1"), context=context)
295
#assert len(contract.actual_line_ids) == 1, ("No reporting line!")
296
# assert contract.actual_line_ids[0].allocated_real == 21210, ("Allocation is not what is expected! %s" % contract.actual_line_ids[0].allocated_real)
297
#assert contract.actual_line_ids[0].allocated_real == 71210, ("Allocation is not what is expected!")
298
#assert contract.actual_line_ids[0].project_real == 121210, ("Project is not what is expected!")