[IMP] hr: onboarding
[odoo/odoo.git] / addons / account_voucher / test / case3_eur_eur.yml
1 -
2   In order to check the Account_voucher module with multi-currency in OpenERP, 
3   I create 2 Invoices in EUR and make 2 Payments in EUR based on the currency rating on that particular date.
4 -
5   I create currency EUR in OpenERP for January of 1.000000 Rate
6 -
7   !record {model: res.currency.rate, id: jan_eur}:
8     currency_id: base.EUR
9     name: !eval "'%s-01-01' %(datetime.now().year)"
10     rate: 1.000000
11 -
12   I modify the debtor account in order to make sure there is no currency_id linked
13 -
14   !python {model: account.account}: |
15     from datetime import datetime
16     ids = self.search(cr, uid, [('name', 'ilike', 'debtor')])
17     self.write(cr, uid, ids, {'currency_id': False})
18 -
19   I create a bank journal with EUR as currency
20 -
21   !record {model: account.journal, id: bank_journal_EUR}:
22     name: Bank Journal(EUR)
23     code: BEUR
24     type: bank
25     analytic_journal_id: analytic.sit
26     sequence_id: account.sequence_bank_journal
27     default_debit_account_id: account.cash
28     default_credit_account_id: account.cash
29     company_id: base.main_company
30 -
31   I create the first invoice on 1st January for 150 EUR
32 -
33   !record {model: account.invoice, id: account_first_invoice_jan_eur}:
34     account_id: account.a_recv
35     company_id: base.main_company
36     currency_id: base.EUR
37     date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
38     period_id: account.period_1
39     invoice_line:
40       - account_id: account.a_sale
41         name: '[PCSC234] PC Assemble SC234'
42         price_unit: 150.0
43         quantity: 1.0
44         product_id: product.product_product_3
45         uos_id: product.product_uom_unit
46     journal_id: account.sales_journal
47     partner_id: base.res_partner_19
48     reference_type: none
49 -
50   I Validate invoice by clicking on Validate button
51 -
52   !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_eur}
53 -
54   I check that first invoice move is correct for debtor account(debit - credit == 150)
55 -
56   !python {model: account.invoice}: |
57     from openerp.tools import float_compare
58     invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
59     assert invoice_id.move_id, "Move not created for open invoice"
60     move_line_obj = self.pool.get('account.move.line')
61     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
62     move_line = move_line_obj.browse(cr, uid, move_lines[0])
63     assert (float_compare(move_line.debit - move_line.credit, 150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
64 -
65   I create the second invoice on 1st February for 80 EUR
66 -
67   !record {model: account.invoice, id: account_second_invoice_feb_eur}:
68     account_id: account.a_recv
69     company_id: base.main_company
70     currency_id: base.EUR
71     date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
72     period_id: account.period_1
73     invoice_line:
74       - account_id: account.a_sale
75         name: '[PCSC234] PC Assemble SC234'
76         price_unit: 80.0
77         quantity: 1.0
78         product_id: product.product_product_3
79         uos_id: product.product_uom_unit
80     journal_id: account.sales_journal
81     partner_id: base.res_partner_19
82     reference_type: none
83 -
84   I Validate invoice by clicking on Validate button
85 -
86   !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_eur}
87 -
88   I check that second invoice move is correct for debtor account (debit - credit == 80)
89 -
90   !python {model: account.invoice}: |
91     from openerp.tools import float_compare
92     invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
93     assert invoice_id.move_id, "Move not created for open invoice"
94     move_line_obj = self.pool.get('account.move.line')
95     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
96     move_line = move_line_obj.browse(cr, uid, move_lines[0])
97     assert (float_compare(move_line.debit - move_line.credit, 80.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
98 -
99   I set the context that will be used for the encoding of all the vouchers of this file
100 -
101   !context
102     'type': 'receipt'
103 -
104   I create the first voucher of payment with values 120 EUR, journal EUR
105 -
106   !record {model: account.voucher, id: account_voucher_1_case3, view: view_vendor_receipt_form}:
107     account_id: account.cash
108     amount: 120.0
109     company_id: base.main_company
110     journal_id: bank_journal_EUR
111     partner_id: base.res_partner_19
112     period_id: account.period_3
113     date: !eval time.strftime("%Y-03-01")
114     payment_option: 'with_writeoff'
115     writeoff_acc_id: account.a_expense
116     comment: 'Write Off'
117     name: 'First payment: Case 3'
118
119 -
120   I fill amounts 100 for the invoice of 150€ and 20 for the invoice of 80€
121 -
122   !python {model: account.voucher}: |
123     from openerp.tools import float_compare
124     vals = {}
125     voucher_id = self.browse(cr, uid, ref('account_voucher_1_case3'))
126     data = []
127     for item in voucher_id.line_cr_ids:
128         if float_compare(item.amount_unreconciled, 150.00, precision_digits=2) == 0:
129             data += [(item.id, 100.0)]
130         else:
131             data += [(item.id, 20.0)]
132     for line_id, amount in data:
133         self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
134     assert (voucher_id.state=='draft'), "Voucher is not in draft state"
135 -
136   I check that writeoff amount computed is 0.00
137 -
138   !python {model: account.voucher}: |
139     from openerp.tools import float_compare
140     voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
141     voucher_id = self.browse(cr, uid, voucher[0])
142     assert (float_compare(voucher_id.writeoff_amount, 0.00, precision_digits=2) == 0), "Writeoff amount is not 0.00"
143 -
144   I confirm the voucher
145 -
146   !python {model: account.voucher}: |
147     voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
148     self.signal_workflow(cr, uid, voucher, 'proforma_voucher')
149 -
150   I check that the move of my first voucher is valid
151 -
152   !python {model: account.voucher}: |
153     voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
154     voucher_id = self.browse(cr, uid, voucher[0])
155     move_line_obj = self.pool.get('account.move.line')
156     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
157     for move_line in move_line_obj.browse(cr, uid, move_lines):
158         assert move_line.state == 'valid', "Voucher move is not valid"
159 -
160   I check that my debtor account is correct
161 -
162   I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 20 and 100 respectively
163 -
164   !python {model: account.voucher}: |
165     from openerp.tools import float_compare
166     voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
167     voucher_id = self.browse(cr, uid, voucher[0])
168     move_line_obj = self.pool.get('account.move.line')
169     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
170     for move_line in move_line_obj.browse(cr, uid, move_lines):
171         if float_compare(move_line.credit, 20.00, precision_digits=2) == 0:
172             assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
173         elif float_compare(move_line.credit, 100.00, precision_digits=2) == 0:
174             assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
175 -
176   I check the residual amount of Invoice1 is 50
177 -
178   !python {model: account.invoice}: |
179     from openerp.tools import float_compare
180     invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
181     move_line_obj = self.pool.get('account.move.line')
182     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
183     move_line = move_line_obj.browse(cr, uid, move_lines[0])
184     assert (float_compare(move_line.amount_residual_currency, 50.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 50.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
185 -
186   I check the residual amuont of Invoice2 is 60
187 -
188    !python {model: account.invoice}: |
189     from openerp.tools import float_compare
190     invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
191     move_line_obj = self.pool.get('account.move.line')
192     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
193     move_line = move_line_obj.browse(cr, uid, move_lines[0])
194     assert (float_compare(move_line.amount_residual_currency, 60.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 60.0, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"
195 -
196   I create the second voucher of payment with values 120€, journal EUR, and check to let open the debtor overpaid amount
197 -
198   !record {model: account.voucher, id: account_voucher_2_case3, view: view_vendor_receipt_form}:
199     account_id: account.cash
200     amount: 120.0
201     company_id: base.main_company
202     journal_id: bank_journal_EUR
203     partner_id: base.res_partner_19
204     period_id: account.period_3
205     date: !eval time.strftime("%Y-04-01")
206     payment_option: 'with_writeoff'
207     writeoff_acc_id: account.a_expense
208     comment: 'Write Off'
209     name: 'Second payment: Case 3'
210
211 -
212   I fill amounts 50 for the invoice of 150€ and 70 for the invoice of 80€
213 -
214   !python {model: account.voucher}: |
215     from openerp.tools import float_compare
216     vals = {}
217     voucher_id = self.browse(cr, uid, ref('account_voucher_2_case3'))
218     data = []
219     for item in voucher_id.line_cr_ids:
220         if float_compare(item.amount_unreconciled, 50.00, precision_digits=2) == 0:
221             data += [(item.id, 50.0)]
222         elif float_compare(item.amount_unreconciled, 60.00, precision_digits=2) == 0:
223             data += [(item.id, 70.00)]
224     for line_id, amount in data:
225         self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
226     assert (voucher_id.state=='draft'), "Voucher is not in draft state"
227 -
228   I check that writeoff amount computed is 0.00
229 -
230   !python {model: account.voucher}: |
231     from openerp.tools import float_compare
232     voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
233     voucher_id = self.browse(cr, uid, voucher[0])
234     assert (float_compare(voucher_id.writeoff_amount, 0.00, precision_digits=2) == 0), "Writeoff amount is not 0"
235 -
236   I confirm the voucher
237 -
238   !python {model: account.voucher}: |
239     voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))])
240     self.signal_workflow(cr, uid, voucher, 'proforma_voucher')
241
242 -
243   I check that the move of my second voucher is valid
244 -
245   !python {model: account.voucher}: |
246     voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))])
247     voucher_id = self.browse(cr, uid, voucher[0])
248     move_line_obj = self.pool.get('account.move.line')
249     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
250     for move_line in move_line_obj.browse(cr, uid, move_lines):
251         assert move_line.state == 'valid', "Voucher move is not valid"
252 -
253   I check that my debtor account is correct
254 -
255   I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 70 and 50
256 -
257   !python {model: account.voucher}: |
258     from openerp.tools import float_compare
259     voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))])
260     voucher_id = self.browse(cr, uid, voucher[0])
261     move_line_obj = self.pool.get('account.move.line')
262     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
263     for move_line in move_line_obj.browse(cr, uid, move_lines):
264         if float_compare(move_line.credit, 70.00, precision_digits=2) == 0:
265             assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
266         elif float_compare(move_line.credit, 50.00, precision_digits=2) == 0:
267             assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
268 -
269   I check the residual amount of Invoice1 is 0
270 -
271   !python {model: account.invoice}: |
272     from openerp.tools import float_compare
273     invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
274     move_line_obj = self.pool.get('account.move.line')
275     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
276     move_line = move_line_obj.browse(cr, uid, move_lines[0])
277     assert (float_compare(move_line.amount_residual_currency, 0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
278 -    
279   I check the residual amuont of Invoice2 is -10
280 -
281    !python {model: account.invoice}: |
282     from openerp.tools import float_compare
283     invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
284     move_line_obj = self.pool.get('account.move.line')
285     move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
286     move_line = move_line_obj.browse(cr, uid, move_lines[0])
287     assert (float_compare(move_line.amount_residual_currency, -10.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, -10.0, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"