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.
5 I create currency EUR in OpenERP for January of 1.000000 Rate
7 !record {model: res.currency.rate, id: jan_eur}:
9 name: !eval "'%s-01-01' %(datetime.now().year)"
12 I modify the debtor account in order to make sure there is no currency_id linked
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})
19 I create a bank journal with EUR as currency
21 !record {model: account.journal, id: bank_journal_EUR}:
22 name: Bank Journal(EUR)
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
31 I create the first invoice on 1st January for 150 EUR
33 !record {model: account.invoice, id: account_first_invoice_jan_eur}:
34 account_id: account.a_recv
35 company_id: base.main_company
37 date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
38 period_id: account.period_1
40 - account_id: account.a_sale
41 name: '[PCSC234] PC Assemble SC234'
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
50 I Validate invoice by clicking on Validate button
52 !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_eur}
54 I check that first invoice move is correct for debtor account(debit - credit == 150)
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"
65 I create the second invoice on 1st February for 80 EUR
67 !record {model: account.invoice, id: account_second_invoice_feb_eur}:
68 account_id: account.a_recv
69 company_id: base.main_company
71 date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
72 period_id: account.period_1
74 - account_id: account.a_sale
75 name: '[PCSC234] PC Assemble SC234'
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
84 I Validate invoice by clicking on Validate button
86 !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_eur}
88 I check that second invoice move is correct for debtor account (debit - credit == 80)
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"
99 I set the context that will be used for the encoding of all the vouchers of this file
104 I create the first voucher of payment with values 120 EUR, journal EUR
106 !record {model: account.voucher, id: account_voucher_1_case3, view: view_vendor_receipt_form}:
107 account_id: account.cash
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
117 name: 'First payment: Case 3'
120 I fill amounts 100 for the invoice of 150€ and 20 for the invoice of 80€
122 !python {model: account.voucher}: |
123 from openerp.tools import float_compare
125 voucher_id = self.browse(cr, uid, ref('account_voucher_1_case3'))
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)]
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"
136 I check that writeoff amount computed is 0.00
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"
144 I confirm the voucher
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')
150 I check that the move of my first voucher is valid
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"
160 I check that my debtor account is correct
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
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."
176 I check the residual amount of Invoice1 is 50
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"
186 I check the residual amuont of Invoice2 is 60
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"
196 I create the second voucher of payment with values 120€, journal EUR, and check to let open the debtor overpaid amount
198 !record {model: account.voucher, id: account_voucher_2_case3, view: view_vendor_receipt_form}:
199 account_id: account.cash
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
209 name: 'Second payment: Case 3'
212 I fill amounts 50 for the invoice of 150€ and 70 for the invoice of 80€
214 !python {model: account.voucher}: |
215 from openerp.tools import float_compare
217 voucher_id = self.browse(cr, uid, ref('account_voucher_2_case3'))
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"
228 I check that writeoff amount computed is 0.00
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"
236 I confirm the voucher
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')
243 I check that the move of my second voucher is valid
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"
253 I check that my debtor account is correct
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
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."
269 I check the residual amount of Invoice1 is 0
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"
279 I check the residual amuont of Invoice2 is -10
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"