Merge lp:~openerp-dev/openobject-addons/trunk-fix_account_tests-pza into lp:openobject-addons
- trunk-fix_account_tests-pza
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~openerp-dev/openobject-addons/trunk-fix_account_tests-pza |
Merge into: | lp:openobject-addons |
Diff against target: |
2315 lines (+518/-330) 31 files modified
account/test/account_fiscalyear_close.yml (+4/-2) account/test/account_supplier_invoice.yml (+4/-2) account/test/test_edi_invoice.yml (+14/-12) account_analytic_analysis/test/account_analytic_analysis.yml (+2/-1) account_anglo_saxon/test/anglo_saxon.yml (+60/-30) account_anglo_saxon/test/anglo_saxon_avg_fifo.yml (+60/-30) account_voucher/test/case1_usd_usd.yml (+48/-36) account_voucher/test/case1_usd_usd_payment_rate.yml (+23/-16) account_voucher/test/case2_suppl_usd_eur.yml (+42/-28) account_voucher/test/case2_usd_eur_debtor_in_eur.yml (+31/-21) account_voucher/test/case2_usd_eur_debtor_in_usd.yml (+36/-25) account_voucher/test/case3_eur_eur.yml (+31/-19) account_voucher/test/case4_cad_chf.yml (+17/-12) account_voucher/test/case5_suppl_usd_usd.yml (+20/-14) account_voucher/test/case_eur_usd.yml (+13/-10) delivery/test/delivery_cost.yml (+4/-2) hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml (+3/-2) hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml (+3/-2) point_of_sale/test/02_order_to_invoice.yml (+4/-2) product/test/product_pricelist.yml (+16/-8) product/test/product_uom.yml (+4/-2) purchase/test/process/edi_purchase_order.yml (+11/-9) purchase/test/process/rfq2order2done.yml (+8/-5) purchase_requisition/test/purchase_requisition.yml (+5/-3) resource/test/resource.yml (+4/-2) sale/test/edi_sale_order.yml (+10/-8) sale/test/sale_order_demo.yml (+15/-10) sale_stock/test/picking_order_policy.yml (+8/-5) sale_stock/test/sale_order_onchange.yml (+6/-4) stock/test/opening_stock.yml (+2/-1) stock/test/shipment.yml (+10/-7) |
To merge this branch: | bzr merge lp:~openerp-dev/openobject-addons/trunk-fix_account_tests-pza |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+199638@code.launchpad.net |
Commit message
Description of the change
Hello,
I have replaced '==' with float_compare() in all YML tests wherever needed as it causes rounding issues.
Regards,
- 9046. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with lp:~openerp-dev/openobject-addons/trunk-float_compare_sale-pza
- 9047. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with lp:~openerp-dev/openobject-addons/trunk-float_compare_purchase-pza
- 9048. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9049. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9050. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9051. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9052. By Pooja Zankhariya(OpenERP)
-
[MERGE]Mergw with Trunk
- 9053. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9054. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9055. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9056. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9057. By Pooja Zankhariya(OpenERP)
-
[MERGE]Sync with Trunk
- 9058. By Pooja Zankhariya(OpenERP)
-
[MERGE]Sync with Trunk
- 9059. By Pooja Zankhariya(OpenERP)
-
[MERGE]Sync with Trunk
- 9060. By Sanjay Gohel (Open ERP)
-
[MERGE]sync with trunk
- 9061. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
Unmerged revisions
- 9061. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9060. By Sanjay Gohel (Open ERP)
-
[MERGE]sync with trunk
- 9059. By Pooja Zankhariya(OpenERP)
-
[MERGE]Sync with Trunk
- 9058. By Pooja Zankhariya(OpenERP)
-
[MERGE]Sync with Trunk
- 9057. By Pooja Zankhariya(OpenERP)
-
[MERGE]Sync with Trunk
- 9056. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9055. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9054. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9053. By Pooja Zankhariya(OpenERP)
-
[MERGE]Merge with Trunk
- 9052. By Pooja Zankhariya(OpenERP)
-
[MERGE]Mergw with Trunk
Preview Diff
1 | === modified file 'account/test/account_fiscalyear_close.yml' |
2 | --- account/test/account_fiscalyear_close.yml 2013-11-27 15:32:57 +0000 |
3 | +++ account/test/account_fiscalyear_close.yml 2014-03-05 10:51:17 +0000 |
4 | @@ -75,5 +75,7 @@ |
5 | - |
6 | I check that the past accounts are taken into account in partner credit |
7 | - |
8 | - !assert {model: res.partner, id: base.res_partner_2, string: Total Receivable does not takes unreconciled moves of previous years}: |
9 | - - credit == 15.0 |
10 | + !python {model: res.partner}: | |
11 | + from openerp.tools import float_compare |
12 | + credit = self.browse(cr, uid, ref('base.res_partner_2')).credit |
13 | + assert float_compare(credit, 15.0, precision_digits=2) == 0, "Total Receivable does not takes unreconciled moves of previous years" |
14 | |
15 | === modified file 'account/test/account_supplier_invoice.yml' |
16 | --- account/test/account_supplier_invoice.yml 2013-10-27 12:31:04 +0000 |
17 | +++ account/test/account_supplier_invoice.yml 2014-03-05 10:51:17 +0000 |
18 | @@ -62,6 +62,7 @@ |
19 | I verify that account move is created |
20 | - |
21 | !python {model: account.invoice}: | |
22 | + from openerp.tools import float_compare |
23 | move_obj = self.pool.get('account.move') |
24 | inv = self.browse(cr, uid, ref('account_invoice_supplier0')) |
25 | move = inv.move_id |
26 | @@ -73,7 +74,7 @@ |
27 | amt_compute = move_obj._amount_compute(cr, uid, list(ids), 'amount', None, {'lang': u'en_US', 'active_model': 'ir.ui.menu', |
28 | 'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')}, where ='') |
29 | move_amount = amt_compute.values() |
30 | - assert(inv.move_id and move.period_id.id == get_period and move_amount[0] == 3100.0), ('Journal Entries has not been created') |
31 | + assert(inv.move_id and move.period_id.id == get_period and float_compare(move_amount[0], 3100.0, precision_digits=2) == 0), ('Journal Entries has not been created') |
32 | - |
33 | I cancel the account move which is in posted state and verifies that it gives warning message |
34 | - |
35 | @@ -92,5 +93,6 @@ |
36 | I verify that 'Period Sum' and 'Year sum' of the tax code are the expected values |
37 | - |
38 | !python {model: account.tax.code}: | |
39 | + from openerp.tools import float_compare |
40 | tax_code = self.browse(cr, uid, ref('tax_case')) |
41 | - assert(tax_code.sum_period == 100.0 and tax_code.sum == 100.0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum) |
42 | + assert(float_compare(tax_code.sum_period, 100.0, precision_digits=2) == 0 and float_compare(tax_code.sum, 100.0, precision_digits=2) == 0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum) |
43 | |
44 | === modified file 'account/test/test_edi_invoice.yml' |
45 | --- account/test/test_edi_invoice.yml 2012-11-29 22:26:45 +0000 |
46 | +++ account/test/test_edi_invoice.yml 2014-03-05 10:51:17 +0000 |
47 | @@ -49,6 +49,7 @@ |
48 | - |
49 | !python {model: account.invoice}: | |
50 | import time |
51 | + from openerp.tools import float_compare |
52 | edi_document = { |
53 | "__id": "account:b33adf8a-decd-11f0-a4de-702a04e25700.random_invoice_763jsms", |
54 | "__module": "account", |
55 | @@ -141,14 +142,14 @@ |
56 | for inv_line in invoice_new.invoice_line: |
57 | if inv_line.name == 'PC Assemble SC234': |
58 | assert inv_line.uos_id.name == "Unit" , "uom is not same" |
59 | - assert inv_line.price_unit == 10 , "price unit is not same" |
60 | - assert inv_line.quantity == 1 , "product qty is not same" |
61 | - assert inv_line.price_subtotal == 10, "price sub total is not same" |
62 | + assert float_compare(inv_line.price_unit, 10, precision_digits=2) == 0, "price unit is not same" |
63 | + assert float_compare(inv_line.quantity, 1, precision_digits=2) == 0, "product qty is not same" |
64 | + assert float_compare(inv_line.price_subtotal, 10, precision_digits=2) == 0, "price sub total is not same" |
65 | elif inv_line.name == 'PC on Demand': |
66 | assert inv_line.uos_id.name == "Unit" , "uom is not same" |
67 | - assert inv_line.price_unit == 100 , "price unit is not same" |
68 | - assert inv_line.quantity == 5 , "product qty is not same" |
69 | - assert inv_line.price_subtotal == 500, "price sub total is not same" |
70 | + assert float_compare(inv_line.price_unit, 100, precision_digits=2) == 0, "price unit is not same" |
71 | + assert float_compare(inv_line.quantity, 5, precision_digits=2) == 0, "product qty is not same" |
72 | + assert float_compare(inv_line.price_subtotal, 500, precision_digits=2) == 0, "price sub total is not same" |
73 | else: |
74 | raise AssertionError('unknown invoice line: %s' % inv_line) |
75 | for inv_tax in invoice_new.tax_line: |
76 | @@ -159,6 +160,7 @@ |
77 | - |
78 | !python {model: account.invoice}: | |
79 | import time |
80 | + from openerp.tools import float_compare |
81 | edi_document = { |
82 | "__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.random_invoice_763jsms", |
83 | "__module": "account", |
84 | @@ -249,14 +251,14 @@ |
85 | for inv_line in invoice_new.invoice_line: |
86 | if inv_line.name == 'Basic PC': |
87 | assert inv_line.uos_id.name == "PCE" , "uom is not same" |
88 | - assert inv_line.price_unit == 10 , "price unit is not same" |
89 | - assert inv_line.quantity == 1 , "product qty is not same" |
90 | - assert inv_line.price_subtotal == 10, "price sub total is not same" |
91 | + assert float_compare(inv_line.price_unit, 10, precision_digits=2) == 0, "price unit is not same" |
92 | + assert float_compare(inv_line.quantity, 1, precision_digits=2) == 0, "product qty is not same" |
93 | + assert float_compare(inv_line.price_subtotal, 10, precision_digits=2) == 0, "price sub total is not same" |
94 | elif inv_line.name == 'Medium PC': |
95 | assert inv_line.uos_id.name == "PCE" , "uom is not same" |
96 | - assert inv_line.price_unit == 100 , "price unit is not same" |
97 | - assert inv_line.quantity == 5 , "product qty is not same" |
98 | - assert inv_line.price_subtotal == 500, "price sub total is not same" |
99 | + assert float_compare(inv_line.price_unit, 100, precision_digits=2) == 0, "price unit is not same" |
100 | + assert float_compare(inv_line.quantity, 5, precision_digits=2) == 0, "product qty is not same" |
101 | + assert float_compare(inv_line.price_subtotal, 500, precision_digits=2) == 0, "price sub total is not same" |
102 | else: |
103 | raise AssertionError('unknown invoice line: %s' % inv_line) |
104 | for inv_tax in invoice_new.tax_line: |
105 | |
106 | === modified file 'account_analytic_analysis/test/account_analytic_analysis.yml' |
107 | --- account_analytic_analysis/test/account_analytic_analysis.yml 2013-03-12 15:45:29 +0000 |
108 | +++ account_analytic_analysis/test/account_analytic_analysis.yml 2014-03-05 10:51:17 +0000 |
109 | @@ -37,8 +37,9 @@ |
110 | I test the generated invoice |
111 | - |
112 | !python {model: account.invoice}: | |
113 | + from openerp.tools import float_compare |
114 | aid = ref('account_analytic_analysis.contract_main') |
115 | ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context) |
116 | assert len(ids)>=1, 'No invoice created for the contract' |
117 | for invoice in self.browse(cr, uid, ids,context=context): |
118 | - assert invoice.amount_untaxed == 150.0, "The invoice total is different than 150!" |
119 | + assert float_compare(invoice.amount_untaxed, 150.0, precision_digits=2) == 0, "The invoice total is different than 150!" |
120 | |
121 | === modified file 'account_anglo_saxon/test/anglo_saxon.yml' |
122 | --- account_anglo_saxon/test/anglo_saxon.yml 2014-01-14 20:18:34 +0000 |
123 | +++ account_anglo_saxon/test/anglo_saxon.yml 2014-03-05 10:51:17 +0000 |
124 | @@ -133,13 +133,17 @@ |
125 | - |
126 | I check the Stock Interim account (Received) is credited successfully. |
127 | - |
128 | - !assert {model: account.account, id : account_anglo_stock_input, string : Stock Interim account (Received) is not credited successfully.}: |
129 | - - credit == 9 |
130 | + !python {model: account.account}: | |
131 | + from openerp.tools import float_compare |
132 | + credit = self.browse(cr, uid, ref('account_anglo_stock_input')).credit |
133 | + float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not credited successfully." |
134 | - |
135 | I check the Stock valuation account is debited sucessfully. |
136 | - |
137 | - !assert {model: account.account, id : account_anglo_stock_valuation, string : Stock valuation account is not debited successfully.}: |
138 | - - debit == 9 |
139 | + !python {model: account.account}: | |
140 | + from openerp.tools import float_compare |
141 | + debit = self.browse(cr, uid, ref('account_anglo_stock_valuation')).debit |
142 | + float_compare(debit, 9, precision_digits=2) == 0, "Stock valuation account is not debited successfully." |
143 | - |
144 | I Validate Invoice of Purchase Order. |
145 | - |
146 | @@ -149,18 +153,24 @@ |
147 | - |
148 | I check the Stock Interim account (Received) is debited sucessfully when Invoice validated. |
149 | - |
150 | - !assert {model: account.account, id : account_anglo_stock_input, string : Stock Interim account (Received) is not debited successfully.}: |
151 | - - debit == 9 |
152 | + !python {model: account.account}: | |
153 | + from openerp.tools import float_compare |
154 | + debit = self.browse(cr, uid, ref('account_anglo_stock_input')).debit |
155 | + float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not debited successfully." |
156 | - |
157 | I check the Price difference creditor Account is debited sucessfully when Invoice validated. |
158 | - |
159 | - !assert {model: account.account, id : account_anglo_price_difference, string : Price difference creditor Account is not debited successfully.}: |
160 | - - debit == 1 |
161 | + !python {model: account.account}: | |
162 | + from openerp.tools import float_compare |
163 | + debit = self.browse(cr, uid, ref('account_anglo_price_difference')).debit |
164 | + float_compare(debit, 1, precision_digits=2) == 0, "Price difference creditor Account is not debited successfully." |
165 | - |
166 | I check Payable(creditor) Account is Credited sucessfully when Invoice validated. |
167 | - |
168 | - !assert {model: account.account, id : account_anglo_payable, string : Payable(creditor) Account is not Credited successfully.}: |
169 | - - credit == 10 |
170 | + !python {model: account.account}: | |
171 | + from openerp.tools import float_compare |
172 | + credit = self.browse(cr, uid, ref('account_anglo_payable')).credit |
173 | + float_compare(credit, 10, precision_digits=2) == 0, "Payable(creditor) Account is not Credited successfully." |
174 | - |
175 | I open the Invoice. |
176 | - |
177 | @@ -180,13 +190,17 @@ |
178 | - |
179 | I check Payable(Creditors) Account is Debited sucessfully after invoice paid. |
180 | - |
181 | - !assert {model: account.account, id : account_anglo_payable, string : Payable(Creditors) Account is not Debited successfully.}: |
182 | - - debit == 10 |
183 | + !python {model: account.account}: | |
184 | + from openerp.tools import float_compare |
185 | + debit = self.browse(cr, uid, ref('account_anglo_payable')).debit |
186 | + assert float_compare(debit, 10, precision_digits=2) == 0, "Payable(Creditors) Account is not Debited successfully." |
187 | - |
188 | I check Bank/Cash account is credited sucessfully after invoice paid. |
189 | - |
190 | - !assert {model: account.account, id : account_anglo_cash, string: Bank/Cash account is not credited successfully.}: |
191 | - - credit == 10 |
192 | + !python {model: account.account}: | |
193 | + from openerp.tools import float_compare |
194 | + credit = self.browse(cr, uid, ref('account_anglo_cash')).credit |
195 | + float_compare(credit, 10, precision_digits=2) == 0, "Bank/Cash account is not credited successfully." |
196 | - |
197 | I create an Outgoing Picking order |
198 | - |
199 | @@ -227,13 +241,17 @@ |
200 | - |
201 | I check Stock Interim account (Delivery) is debited successfully. |
202 | - |
203 | - !assert {model: account.account, id : account_anglo_stock_output, string : Stock Interim account (Delivery) is not debited successfully.}: |
204 | - - debit == 9 |
205 | + !python {model: account.account}: | |
206 | + from openerp.tools import float_compare |
207 | + debit = self.browse(cr, uid, ref('account_anglo_stock_output')).debit |
208 | + float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not debited successfully." |
209 | - |
210 | I check the Stock valuation account is credited sucessfully. |
211 | - |
212 | - !assert {model: account.account, id : account_anglo_stock_valuation, string : Stock valuation account is not credited successfully.}: |
213 | - - credit == 9 |
214 | + !python {model: account.account}: | |
215 | + from openerp.tools import float_compare |
216 | + credit = self.browse(cr, uid, ref('account_anglo_stock_valuation')).credit |
217 | + float_compare(credit, 9, precision_digits=2) == 0, "Stock valuation account is not credited successfully." |
218 | - |
219 | As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order. |
220 | - |
221 | @@ -260,23 +278,31 @@ |
222 | - |
223 | I check Income Account is Credited sucessfully when Invoice validated. |
224 | - |
225 | - !assert {model: account.account, id : account_anglo_income, string : Income Account is not Credited successfully.}: |
226 | - - credit == 20 |
227 | + !python {model: account.account}: | |
228 | + from openerp.tools import float_compare |
229 | + credit = self.browse(cr, uid, ref('account_anglo_income')).credit |
230 | + float_compare(credit, 20, precision_digits=2) == 0, "Income Account is not Credited successfully." |
231 | - |
232 | I check Cost of goods sold account for debit. |
233 | - |
234 | - !assert {model: account.account, id : account_anglo_cogs, string : Cost of goods sale is not Debited successfully.}: |
235 | - - debit == 9 |
236 | + !python {model: account.account}: | |
237 | + from openerp.tools import float_compare |
238 | + debit = self.browse(cr, uid, ref('account_anglo_cogs')).debit |
239 | + float_compare(debit, 9, precision_digits=2) == 0, "Cost of goods sale is not Debited successfully." |
240 | - |
241 | I check Stock Interim account (Delivery) |
242 | - |
243 | - !assert {model: account.account, id : account_anglo_stock_output, string : Stock Interim account (Delivery) is not credited successfully.}: |
244 | - - credit == 9 |
245 | + !python {model: account.account}: | |
246 | + from openerp.tools import float_compare |
247 | + credit = self.browse(cr, uid, ref('account_anglo_stock_output')).credit |
248 | + float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not credited successfully." |
249 | - |
250 | I check Receivable(Debtor) Account for debit. |
251 | - |
252 | - !assert {model: account.account, id : account_anglo_receivable, string : Receivable(Debtors) Account is not Debited successfully.}: |
253 | - - debit == 20 |
254 | + !python {model: account.account}: | |
255 | + from openerp.tools import float_compare |
256 | + debit = self.browse(cr, uid, ref('account_anglo_receivable')).debit |
257 | + float_compare(debit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Debited successfully." |
258 | - |
259 | I pay the invoice. |
260 | - |
261 | @@ -293,10 +319,14 @@ |
262 | - |
263 | I check Receivable(Debtor) Account for credit. |
264 | - |
265 | - !assert {model: account.account, id : account_anglo_receivable, string : Receivable(Debtors) Account is not Credited successfully.}: |
266 | - - credit == 20 |
267 | + !python {model: account.account}: | |
268 | + from openerp.tools import float_compare |
269 | + credit = self.browse(cr, uid, ref('account_anglo_receivable')).credit |
270 | + float_compare(credit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Credited successfully." |
271 | - |
272 | I check Bank/Cash account is debited sucessfully after invoice paid. |
273 | - |
274 | - !assert {model: account.account, id : account_anglo_cash, string: Bank/Cash account is not successfully credited.}: |
275 | - - debit == 20 |
276 | + !python {model: account.account}: | |
277 | + from openerp.tools import float_compare |
278 | + debit = self.browse(cr, uid, ref('account_anglo_cash')).debit |
279 | + float_compare(debit, 20, precision_digits=2) == 0, "Bank/Cash account is not successfully credited." |
280 | |
281 | === modified file 'account_anglo_saxon/test/anglo_saxon_avg_fifo.yml' |
282 | --- account_anglo_saxon/test/anglo_saxon_avg_fifo.yml 2014-01-14 20:18:34 +0000 |
283 | +++ account_anglo_saxon/test/anglo_saxon_avg_fifo.yml 2014-03-05 10:51:17 +0000 |
284 | @@ -141,13 +141,17 @@ |
285 | - |
286 | I check the Stock Interim account (Received) is credit successfully. |
287 | - |
288 | - !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not credited successfully.}: |
289 | - - credit == 9 |
290 | + !python {model: account.account}: | |
291 | + from openerp.tools import float_compare |
292 | + credit = self.browse(cr, uid, ref('account_anglo_stock_input_fifo')).credit |
293 | + assert float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not credited successfully." |
294 | - |
295 | I check the Stock valuation account is debit sucessfully. |
296 | - |
297 | - !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not debited successfully.}: |
298 | - - debit == 9 |
299 | + !python {model: account.account, id}: | |
300 | + from openerp.tools import float_compare |
301 | + debit = self.browse(cr, uid, ref('account_anglo_stock_valuation_fifo')).debit |
302 | + assert float_compare(debit, 9, precision_digits=2) == 0, "Stock valuation account is not debited successfully." |
303 | - |
304 | I Validate Invoice of Purchase Order after having changed the price to 10. |
305 | - |
306 | @@ -159,18 +163,24 @@ |
307 | - |
308 | I check the Stock Interim account (Received) is debited sucessfully when Invoice validated. |
309 | - |
310 | - !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not debited successfully.}: |
311 | - - debit == 9 |
312 | + !python {model: account.account}: | |
313 | + from openerp.tools import float_compare |
314 | + debit = self.browse(cr, uid, ref('account_anglo_stock_input_fifo')).debit |
315 | + assert float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not debited successfully." |
316 | - |
317 | I check the Price difference creditor Account is debited sucessfully when Invoice validated. |
318 | - |
319 | - !assert {model: account.account, id : account_anglo_price_difference_fifo, string : Price difference creditor Account is not debited successfully.}: |
320 | - - debit == 1 |
321 | + !python {model: account.account}: | |
322 | + from openerp.tools import float_compare |
323 | + debit = self.browse(cr, uid, ref('account_anglo_price_difference_fifo')).debit |
324 | + assert float_compare(debit, 1, precision_digits=2) == 0, "Price difference creditor Account is not debited successfully." |
325 | - |
326 | I check Payable(creditor) Account is Credited sucessfully when Invoice validated. |
327 | - |
328 | - !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(creditor) Account is not Credited successfully.}: |
329 | - - credit == 10 |
330 | + !python {model: account.account}: | |
331 | + from openerp.tools import float_compare |
332 | + credit = self.browse(cr, uid, ref('account_anglo_payable_fifo')).credit |
333 | + assert float_compare(credit, 10, precision_digits=2) == 0, "Payable(creditor) Account is not Credited successfully." |
334 | - |
335 | I pay the invoice. |
336 | - |
337 | @@ -183,13 +193,17 @@ |
338 | - |
339 | I check Payable(Creditors) Account is Debited sucessfully after invoice paid. |
340 | - |
341 | - !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(Creditors) Account is not Debited successfully.}: |
342 | - - debit == 10 |
343 | + !python {model: account.account}: | |
344 | + from openerp.tools import float_compare |
345 | + debit = self.browse(cr, uid, ref('account_anglo_payable_fifo')).debit |
346 | + assert float_compare(debit, 10, precision_digits=2) == 0, "Payable(Creditors) Account is not Debited successfully." |
347 | - |
348 | I check Bank/Cash account is credited sucessfully after invoice paid. |
349 | - |
350 | - !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not credited successfully.}: |
351 | - - credit == 10 |
352 | + !python {model: account.account}: | |
353 | + from openerp.tools import float_compare |
354 | + credit = self.browse(cr, uid, ref('account_anglo_cash_fifo')).credit |
355 | + assert float_compare(credit, 10, precision_digits=2) == 0, "Bank/Cash account is not credited successfully." |
356 | - |
357 | I create an Outgoing Picking order |
358 | - |
359 | @@ -229,13 +243,17 @@ |
360 | - |
361 | I check Stock Interim account (Delivery) is debited successfully. |
362 | - |
363 | - !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not debited successfully.}: |
364 | - - debit == 9 |
365 | + !python {model: account.account}: | |
366 | + from openerp.tools import float_compare |
367 | + debit = self.browse(cr, uid, ref('account_anglo_stock_output_fifo')).debit |
368 | + assert float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not debited successfully." |
369 | - |
370 | I check the Stock valuation account is credited sucessfully. |
371 | - |
372 | - !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not credited successfully.}: |
373 | - - credit == 9 |
374 | + !python {model: account.account}: | |
375 | + from openerp.tools import float_compare |
376 | + credit = self.browse(cr, uid, ref('account_anglo_stock_valuation_fifo')).credit |
377 | + assert float_compare(credit, 9, precision_digits=2) == 0, "Stock valuation account is not credited successfully." |
378 | - |
379 | As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order. |
380 | - |
381 | @@ -265,23 +283,31 @@ |
382 | - |
383 | I check Income Account is Credited sucessfully when Invoice validated. |
384 | - |
385 | - !assert {model: account.account, id : account_anglo_income_fifo, string : Income Account is not Credited successfully.}: |
386 | - - credit == 20 |
387 | + !python {model: account.account}: | |
388 | + from openerp.tools import float_compare |
389 | + credit = self.browse(cr, uid, ref('account_anglo_income_fifo')).credit |
390 | + assert float_compare(credit, 20, precision_digits=2) == 0, "Income Account is not Credited successfully." |
391 | - |
392 | I check Cost of goods sold account for debit. |
393 | - |
394 | - !assert {model: account.account, id : account_anglo_cogs_fifo, string : Cost of goods sale is not Debited successfully.}: |
395 | - - debit == 9 |
396 | + !python {model: account.account}: | |
397 | + from openerp.tools import float_compare |
398 | + debit = self.browse(cr, uid, ref('account_anglo_cogs_fifo')).debit |
399 | + assert float_compare(debit, 9, precision_digits=2) == 0, "Cost of goods sale is not Debited successfully." |
400 | - |
401 | I check Stock Interim account (Delivery) |
402 | - |
403 | - !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not credited successfully.}: |
404 | - - credit == 9 |
405 | + !python {model: account.account}: | |
406 | + from openerp.tools import float_compare |
407 | + credit = self.browse(cr, uid, ref('account_anglo_stock_output_fifo')).credit |
408 | + assert float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not credited successfully." |
409 | - |
410 | I check Receivable(Debtor) Account for debit. |
411 | - |
412 | - !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Debited successfully.}: |
413 | - - debit == 20 |
414 | + !python {model: account.account}: | |
415 | + from openerp.tools import float_compare |
416 | + debit = self.browse(cr, uid, ref('account_anglo_receivable_fifo')).debit |
417 | + assert float_compare(debit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Debited successfully." |
418 | - |
419 | I pay the invoice. |
420 | - |
421 | @@ -298,10 +324,14 @@ |
422 | - |
423 | I check Receivable(Debtor) Account for credit. |
424 | - |
425 | - !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Credited successfully.}: |
426 | - - credit == 20 |
427 | + !python {model: account.account}: | |
428 | + from openerp.tools import float_compare |
429 | + credit = self.browse(cr, uid, ref('account_anglo_receivable_fifo')).credit |
430 | + assert float_compare(credit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Credited successfully." |
431 | - |
432 | I check Bank/Cash account is debited sucessfully after invoice paid. |
433 | - |
434 | - !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not successfully credited.}: |
435 | - - debit == 20 |
436 | + !python {model: account.account}: | |
437 | + from openerp.tools import float_compare |
438 | + debit = self.browse(cr, uid, ref('account_anglo_cash_fifo')).debit |
439 | + assert float_compare(debit, 20, precision_digits=2) == 0, "Bank/Cash account is not successfully credited." |
440 | |
441 | === modified file 'account_voucher/test/case1_usd_usd.yml' |
442 | --- account_voucher/test/case1_usd_usd.yml 2013-10-27 12:31:04 +0000 |
443 | +++ account_voucher/test/case1_usd_usd.yml 2014-03-05 10:51:17 +0000 |
444 | @@ -94,12 +94,13 @@ |
445 | I check that first invoice move is correct for debtor account (debit - credit == 150.0) |
446 | - |
447 | !python {model: account.invoice}: | |
448 | + from openerp.tools import float_compare |
449 | invoice_id = self.browse(cr, uid, ref("account_invoice_jan")) |
450 | assert invoice_id.move_id, "Move not created for open invoice" |
451 | move_line_obj = self.pool.get('account.move.line') |
452 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
453 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
454 | - assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account" |
455 | + assert (float_compare(move_line.debit - move_line.credit, 150.0, precision_digits=2) == 0), "Invoice move is not correct for debtors account" |
456 | - |
457 | I create the second invoice on 1st February for 100 USD |
458 | - |
459 | @@ -127,12 +128,13 @@ |
460 | I check that second invoice move is correct for debtor account (debit - credit == 80) |
461 | - |
462 | !python {model: account.invoice}: | |
463 | + from openerp.tools import float_compare |
464 | invoice_id = self.browse(cr, uid, ref("account_invoice_feb")) |
465 | assert invoice_id.move_id, "Move not created for open invoice" |
466 | move_line_obj = self.pool.get('account.move.line') |
467 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
468 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
469 | - assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account" |
470 | + assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is not correct for debtors account" |
471 | |
472 | - |
473 | I set the context that will be used for the encoding of all the vouchers of this file |
474 | @@ -159,11 +161,12 @@ |
475 | I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$> |
476 | - |
477 | !python {model: account.voucher}: | |
478 | + from openerp.tools import float_compare |
479 | vals = {} |
480 | voucher_id = self.browse(cr, uid, ref('account_voucher_1_case1')) |
481 | data = [] |
482 | for item in voucher_id.line_cr_ids: |
483 | - if item.amount_unreconciled == 200.00: |
484 | + if float_compare(item.amount_unreconciled, 200.00, precision_digits=2) == 0: |
485 | data += [(item.id, 180.0)] |
486 | else: |
487 | data += [(item.id, 70.0)] |
488 | @@ -174,9 +177,10 @@ |
489 | I check that writeoff amount computed is -10.0 |
490 | - |
491 | !python {model: account.voucher}: | |
492 | + from openerp.tools import float_compare |
493 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))]) |
494 | voucher_id = self.browse(cr, uid, voucher[0]) |
495 | - assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0" |
496 | + assert (float_compare(voucher_id.writeoff_amount, -10.0, precision_digits=2) == 0), "Writeoff amount is not -10.0" |
497 | - |
498 | I confirm the voucher |
499 | - |
500 | @@ -201,39 +205,42 @@ |
501 | I check that my write-off is correct. 9 debit and 10 amount_currency |
502 | - |
503 | !python {model: account.voucher}: | |
504 | + from openerp.tools import float_compare |
505 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))]) |
506 | voucher_id = self.browse(cr, uid, voucher[0]) |
507 | move_line_obj = self.pool.get('account.move.line') |
508 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
509 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
510 | - if move_line.amount_currency == -180.00: |
511 | - assert move_line.credit == 162.00, "Debtor account has wrong entry." |
512 | - elif move_line.amount_currency == -70.00: |
513 | - assert move_line.credit == 63.00, "Debtor account has wrong entry." |
514 | - elif move_line.amount_currency == 10.00: |
515 | - assert move_line.debit == 9.00, "Writeoff amount is wrong." |
516 | - elif move_line.amount_currency == 240.00: |
517 | - assert move_line.debit == 216.00, "Bank entry is wrong." |
518 | + if float_compare(move_line.amount_currency, -180.00, precision_digits=2) == 0: |
519 | + assert float_compare(move_line.credit, 162.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
520 | + elif float_compare(move_line.amount_currency, -70.00, precision_digits=2) == 0: |
521 | + assert float_compare(move_line.credit, 63.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
522 | + elif float_compare(move_line.amount_currency, 10.00, precision_digits=2) == 0: |
523 | + assert float_compare(move_line.debit, 9.00, precision_digits=2) == 0, "Writeoff amount is wrong." |
524 | + elif float_compare(move_line.amount_currency, 240.00, precision_digits=2) == 0: |
525 | + assert float_compare(move_line.debit, 216.00, precision_digits=2) == 0, "Bank entry is wrong." |
526 | else: |
527 | assert False, "Unrecognized journal entry" |
528 | - |
529 | I check the residual amount of Invoice1, should be 20 in amount_currency |
530 | - |
531 | !python {model: account.invoice}: | |
532 | + from openerp.tools import float_compare |
533 | invoice_id = self.browse(cr, uid, ref("account_invoice_jan")) |
534 | move_line_obj = self.pool.get('account.move.line') |
535 | 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)]) |
536 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
537 | - assert (move_line.amount_residual_currency == 20.0) , "Residual amount is not correct for first Invoice" |
538 | + assert (float_compare(move_line.amount_residual_currency, 20.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice" |
539 | - |
540 | I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual |
541 | - |
542 | !python {model: account.invoice}: | |
543 | + from openerp.tools import float_compare |
544 | invoice_id = self.browse(cr, uid, ref("account_invoice_feb")) |
545 | move_line_obj = self.pool.get('account.move.line') |
546 | 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)]) |
547 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
548 | - assert (move_line.amount_residual_currency == 30.0) , "Residual amount is not correct for first Invoice" |
549 | + assert (float_compare(move_line.amount_residual_currency, 30.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice" |
550 | - |
551 | On the first April, I create the second voucher of payment with values 45 USD, journal USD, |
552 | - |
553 | @@ -253,11 +260,12 @@ |
554 | I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$ |
555 | - |
556 | !python {model: account.voucher}: | |
557 | + from openerp.tools import float_compare |
558 | vals = {} |
559 | voucher_id = self.browse(cr, uid, ref('account_voucher_2_case1')) |
560 | data = [] |
561 | for item in voucher_id.line_cr_ids: |
562 | - if item.amount_unreconciled == 20.00: |
563 | + if float_compare(item.amount_unreconciled, 20.00, precision_digits=2) == 0: |
564 | data += [(item.id, 20.0)] |
565 | else: |
566 | data += [(item.id, 30.0)] |
567 | @@ -268,9 +276,10 @@ |
568 | I check that writeoff amount computed is -5.0 |
569 | - |
570 | !python {model: account.voucher}: | |
571 | + from openerp.tools import float_compare |
572 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))]) |
573 | voucher_id = self.browse(cr, uid, voucher[0]) |
574 | - assert (voucher_id.writeoff_amount == -5.0), "Writeoff amount is not -5.0" |
575 | + assert (float_compare(voucher_id.writeoff_amount, -5.0, precision_digits=2) == 0), "Writeoff amount is not -5.0" |
576 | - |
577 | I confirm the voucher |
578 | - |
579 | @@ -299,52 +308,55 @@ |
580 | I check that my writeoff is correct. 4.75 debit and 5 amount_currency |
581 | - |
582 | !python {model: account.voucher}: | |
583 | + from openerp.tools import float_compare |
584 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))]) |
585 | voucher_id = self.browse(cr, uid, voucher[0]) |
586 | move_line_obj = self.pool.get('account.move.line') |
587 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
588 | reconcile_a = reconcile_b = False |
589 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
590 | - if move_line.amount_currency == -20.00: |
591 | + if float_compare(move_line.amount_currency, -20.00, precision_digits=2) == 0: |
592 | assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled" |
593 | reconcile_b = move_line.reconcile_id.id |
594 | - elif move_line.amount_currency == -30.00: |
595 | + elif float_compare(move_line.amount_currency, -30.00, precision_digits=2) == 0: |
596 | assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled" |
597 | reconcile_a = move_line.reconcile_id.id |
598 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
599 | - if move_line.amount_currency == -20.00: |
600 | - assert move_line.credit == 19.00, "Debtor account has wrong entry." |
601 | - elif move_line.amount_currency == -30.00: |
602 | - assert move_line.credit == 28.50, "Debtor account has wrong entry." |
603 | - elif move_line.amount_currency == 5.00: |
604 | - assert move_line.debit == 4.75, "Writeoff amount is wrong." |
605 | - elif move_line.debit == 11.5 and move_line.account_id.reconcile: |
606 | - assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_a, "Exchange difference entry for the invoice of 100$ is wrong" |
607 | - elif move_line.credit == 11.5: |
608 | - assert move_line.amount_currency == 0.0 |
609 | - elif move_line.debit == 31.0 and move_line.account_id.reconcile: |
610 | - assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_b, "Exchange difference entry for the invoice of 200$ is wrong" |
611 | - elif move_line.credit == 31.0: |
612 | - assert move_line.amount_currency == 0.0 |
613 | - elif move_line.amount_currency == 45.00: |
614 | - assert move_line.debit == 42.75, "Bank entry is wrong." |
615 | + if float_compare(move_line.amount_currency, -20.00, precision_digits=2) == 0: |
616 | + assert float_compare(move_line.credit, 19.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
617 | + elif float_compare(move_line.amount_currency, -30.00, precision_digits=2) == 0: |
618 | + assert float_compare(move_line.credit, 28.50, precision_digits=2) == 0, "Debtor account has wrong entry." |
619 | + elif float_compare(move_line.amount_currency, 5.00, precision_digits=2) == 0: |
620 | + assert float_compare(move_line.debit, 4.75, precision_digits=2) == 0, "Writeoff amount is wrong." |
621 | + elif float_compare(move_line.debit, 11.5, precision_digits=2) == 0 and move_line.account_id.reconcile: |
622 | + assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_a, "Exchange difference entry for the invoice of 100$ is wrong" |
623 | + elif float_compare(move_line.credit, 11.5, precision_digits=2) == 0: |
624 | + assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0 |
625 | + elif float_compare(move_line.debit, 31.0, precision_digits=2) == 0 and move_line.account_id.reconcile: |
626 | + assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_b, "Exchange difference entry for the invoice of 200$ is wrong" |
627 | + elif float_compare(move_line.credit, 31.0, precision_digits=2) == 0: |
628 | + assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0 |
629 | + elif float_compare(move_line.amount_currency, 45.00, precision_digits=2) == 0: |
630 | + assert float_compare(move_line.debit, 42.75, precision_digits=2) == 0, "Bank entry is wrong." |
631 | else: |
632 | assert False, "Unrecognized journal entry" |
633 | - |
634 | I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid |
635 | - |
636 | !python {model: account.invoice}: | |
637 | + from openerp.tools import float_compare |
638 | invoice_id = self.browse(cr, uid, ref("account_invoice_jan")) |
639 | move_line_obj = self.pool.get('account.move.line') |
640 | 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)]) |
641 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
642 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
643 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
644 | - |
645 | I check the residual amuont of Invoice2, should be 0 in residual currency and 0 in amount_residual and paid |
646 | - |
647 | !python {model: account.invoice}: | |
648 | + from openerp.tools import float_compare |
649 | invoice_id = self.browse(cr, uid, ref("account_invoice_feb")) |
650 | move_line_obj = self.pool.get('account.move.line') |
651 | 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)]) |
652 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
653 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
654 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
655 | |
656 | === modified file 'account_voucher/test/case1_usd_usd_payment_rate.yml' |
657 | --- account_voucher/test/case1_usd_usd_payment_rate.yml 2013-05-14 12:03:41 +0000 |
658 | +++ account_voucher/test/case1_usd_usd_payment_rate.yml 2014-03-05 10:51:17 +0000 |
659 | @@ -101,12 +101,13 @@ |
660 | I check that first invoice move is correct for debtor account (debit - credit == 150.0) |
661 | - |
662 | !python {model: account.invoice}: | |
663 | + from openerp.tools import float_compare |
664 | invoice_id = self.browse(cr, uid, ref("account_invoice_jan_payment_rate")) |
665 | assert invoice_id.move_id, "Move not created for open invoice" |
666 | move_line_obj = self.pool.get('account.move.line') |
667 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
668 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
669 | - assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account" |
670 | + assert (float_compare(move_line.debit - move_line.credit, 150.0, precision_digits=2) == 0), "Invoice move is not correct for debtors account" |
671 | - |
672 | I create the second invoice on 1st February for 100 USD |
673 | - |
674 | @@ -134,12 +135,13 @@ |
675 | I check that second invoice move is correct for debtor account (debit - credit == 80) |
676 | - |
677 | !python {model: account.invoice}: | |
678 | + from openerp.tools import float_compare |
679 | invoice_id = self.browse(cr, uid, ref("account_invoice_feb_payment_rate")) |
680 | assert invoice_id.move_id, "Move not created for open invoice" |
681 | move_line_obj = self.pool.get('account.move.line') |
682 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
683 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
684 | - assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account" |
685 | + assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is not correct for debtors account" |
686 | |
687 | - |
688 | I set the context that will be used for the encoding of all the vouchers of this file |
689 | @@ -168,11 +170,12 @@ |
690 | I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$> |
691 | - |
692 | !python {model: account.voucher}: | |
693 | + from openerp.tools import float_compare |
694 | vals = {} |
695 | voucher_id = self.browse(cr, uid, ref('account_voucher_1_case1_payment_rate')) |
696 | data = [] |
697 | for item in voucher_id.line_cr_ids: |
698 | - if item.amount_unreconciled == 200.00: |
699 | + if float_compare(item.amount_unreconciled, 200.00, precision_digits=2) == 0: |
700 | data += [(item.id, 180.0)] |
701 | else: |
702 | data += [(item.id, 70.0)] |
703 | @@ -183,9 +186,10 @@ |
704 | I check that writeoff amount computed is -10.0 |
705 | - |
706 | !python {model: account.voucher}: | |
707 | + from openerp.tools import float_compare |
708 | voucher = ref('account_voucher_1_case1_payment_rate') |
709 | voucher_id = self.browse(cr, uid, voucher) |
710 | - assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0" |
711 | + assert (float_compare(voucher_id.writeoff_amount, -10.0, precision_digits=2) == 0), "Writeoff amount is not -10.0" |
712 | - |
713 | I confirm the voucher |
714 | - |
715 | @@ -210,38 +214,41 @@ |
716 | I check that my write-off is correct. 8 debit and 10 amount_currency |
717 | - |
718 | !python {model: account.voucher}: | |
719 | + from openerp.tools import float_compare |
720 | voucher = ref('account_voucher_1_case1_payment_rate') |
721 | voucher_id = self.browse(cr, uid, voucher) |
722 | move_line_obj = self.pool.get('account.move.line') |
723 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
724 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
725 | - if move_line.amount_currency == -180.00: |
726 | - assert move_line.credit == 144.00, "Debtor account has wrong entry." |
727 | - elif move_line.amount_currency == -70.00: |
728 | - assert move_line.credit == 56.00, "Debtor account has wrong entry." |
729 | - elif move_line.amount_currency == 10.00: |
730 | - assert move_line.debit == 8.00, "Writeoff amount is wrong: Got a debit of %s (expected 8,00€)" % (move_line.debit) |
731 | - elif move_line.amount_currency == 240.00: |
732 | - assert move_line.debit == 192.00, "Bank entry is wrong." |
733 | + if float_compare(move_line.amount_currency, -180.00, precision_digits=2) == 0: |
734 | + assert float_compare(move_line.credit, 144.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
735 | + elif float_compare(move_line.amount_currency, -70.00, precision_digits=2) == 0: |
736 | + assert float_compare(move_line.credit, 56.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
737 | + elif float_compare(move_line.amount_currency, 10.00, precision_digits=2) == 0: |
738 | + assert float_compare(move_line.debit, 8.00, precision_digits=2) == 0, "Writeoff amount is wrong: Got a debit of %s (expected 8,00€)" % (move_line.debit) |
739 | + elif float_compare(move_line.amount_currency, 240.00, precision_digits=2) == 0: |
740 | + assert float_compare(move_line.debit, 192.00, precision_digits=2) == 0, "Bank entry is wrong." |
741 | else: |
742 | assert False, "Unrecognized journal entry" |
743 | - |
744 | I check the residual amount of Invoice1, should be 20 in amount_currency and 6 in amount_residual |
745 | - |
746 | !python {model: account.invoice}: | |
747 | + from openerp.tools import float_compare |
748 | invoice_id = self.browse(cr, uid, ref("account_invoice_jan_payment_rate")) |
749 | move_line_obj = self.pool.get('account.move.line') |
750 | 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)]) |
751 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
752 | - assert (move_line.amount_residual == 6.0) , "Residual amount is not correct for first Invoice" |
753 | - assert (move_line.amount_residual_currency == 20.0) , "Residual amount in currency is not correct for first Invoice" |
754 | + assert (float_compare(move_line.amount_residual, 6.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice" |
755 | + assert (float_compare(move_line.amount_residual_currency, 20.0, precision_digits=2) == 0) , "Residual amount in currency is not correct for first Invoice" |
756 | - |
757 | I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual |
758 | - |
759 | !python {model: account.invoice}: | |
760 | + from openerp.tools import float_compare |
761 | invoice_id = self.browse(cr, uid, ref("account_invoice_feb_payment_rate")) |
762 | move_line_obj = self.pool.get('account.move.line') |
763 | 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)]) |
764 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
765 | - assert (move_line.amount_residual == 24.0) , "Residual amount is not correct for second Invoice" |
766 | - assert (move_line.amount_residual_currency == 30.0) , "Residual amount in currency is not correct for second Invoice" |
767 | + assert (float_compare(move_line.amount_residual, 24.0, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice" |
768 | + assert (float_compare(move_line.amount_residual_currency, 30.0, precision_digits=2) == 0) , "Residual amount in currency is not correct for second Invoice" |
769 | |
770 | === modified file 'account_voucher/test/case2_suppl_usd_eur.yml' |
771 | --- account_voucher/test/case2_suppl_usd_eur.yml 2013-10-27 12:31:04 +0000 |
772 | +++ account_voucher/test/case2_suppl_usd_eur.yml 2014-03-05 10:51:17 +0000 |
773 | @@ -65,12 +65,13 @@ |
774 | I check that first invoice move is correct for debtor account(debit - credit == -150) |
775 | - |
776 | !python {model: account.invoice}: | |
777 | + from openerp.tools import float_compare |
778 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl")) |
779 | assert invoice_id.move_id, "Move not created for open invoice" |
780 | move_line_obj = self.pool.get('account.move.line') |
781 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
782 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
783 | - assert (move_line.debit - move_line.credit == -150.00), "Invoice move is incorrect for debtors account" |
784 | + assert (float_compare(move_line.debit - move_line.credit, -150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
785 | - |
786 | I create the second invoice on 1st February for 100 USD |
787 | - |
788 | @@ -100,12 +101,13 @@ |
789 | I check that second invoice move is correct for debtor account (debit - credit == -80) |
790 | - |
791 | !python {model: account.invoice}: | |
792 | + from openerp.tools import float_compare |
793 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl")) |
794 | assert invoice_id.move_id, "Move not created for open invoice" |
795 | move_line_obj = self.pool.get('account.move.line') |
796 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
797 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
798 | - assert (move_line.debit - move_line.credit == -80), "Invoice move is incorrect for debtors account" |
799 | + assert (float_compare(move_line.debit - move_line.credit, -80, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
800 | - |
801 | I set the context that will be used for the encoding of all the vouchers of this file |
802 | - |
803 | @@ -131,11 +133,12 @@ |
804 | I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$ |
805 | - |
806 | !python {model: account.voucher}: | |
807 | + from openerp.tools import float_compare |
808 | vals = {} |
809 | voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2_suppl')) |
810 | data = [] |
811 | for item in voucher_id.line_cr_ids: |
812 | - if item.amount_unreconciled == 200.00: |
813 | + if float_compare(item.amount_unreconciled, 200.00, precision_digits=2) == 0: |
814 | data += [(item.id, 180.0)] |
815 | else: |
816 | data += [(item.id, 70.0)] |
817 | @@ -146,16 +149,18 @@ |
818 | I check that writeoff amount computed is -15.0 |
819 | - |
820 | !python {model: account.voucher}: | |
821 | + from openerp.tools import float_compare |
822 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
823 | voucher_id = self.browse(cr, uid, voucher[0]) |
824 | - assert (voucher_id.writeoff_amount == -15.0), "Writeoff amount is not -15.0" |
825 | + assert (float_compare(voucher_id.writeoff_amount, -15.0, precision_digits=2) == 0), "Writeoff amount is not -15.0" |
826 | - |
827 | I check that currency rate difference is 34.0 |
828 | - |
829 | !python {model: account.voucher}: | |
830 | + from openerp.tools import float_compare |
831 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
832 | voucher_id = self.browse(cr, uid, voucher[0]) |
833 | - assert (voucher_id.currency_rate_difference == 34.0), "Currency rate difference is not 34.0" |
834 | + assert (float_compare(voucher_id.currency_rate_difference, 34.0, precision_digits=2) == 0), "Currency rate difference is not 34.0" |
835 | - |
836 | I confirm the voucher |
837 | - |
838 | @@ -182,37 +187,40 @@ |
839 | I check that my writeoff is correct. -15 in credit with no amount_currency |
840 | - |
841 | !python {model: account.voucher}: | |
842 | + from openerp.tools import float_compare |
843 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
844 | voucher_id = self.browse(cr, uid, voucher[0]) |
845 | move_line_obj = self.pool.get('account.move.line') |
846 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
847 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
848 | - if move_line.amount_currency == 180.00: |
849 | - assert move_line.debit == 135.00, "Creditor account has wrong entry." |
850 | - elif move_line.amount_currency == 70.00: |
851 | - assert move_line.debit == 56.00, "Debtor account has wrong entry." |
852 | - elif move_line.debit == 34.00: |
853 | - assert move_line.amount_currency == 0.00, "Incorrect Currency Difference." |
854 | - elif move_line.debit == 15.00: |
855 | - assert move_line.amount_currency == 0.00, "Writeoff amount is wrong." |
856 | + if float_compare(move_line.amount_currency, 180.00, precision_digits=2) == 0: |
857 | + assert float_compare(move_line.debit, 135.00, precision_digits=2) == 0, "Creditor account has wrong entry." |
858 | + elif float_compare(move_line.amount_currency, 70.00, precision_digits=2) == 0: |
859 | + assert float_compare(move_line.debit, 56.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
860 | + elif float_compare(move_line.debit, 34.00, precision_digits=2) == 0: |
861 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Incorrect Currency Difference." |
862 | + elif float_compare(move_line.debit, 15.00, precision_digits=2) == 0: |
863 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Writeoff amount is wrong." |
864 | - |
865 | I check the residual amount of Invoice1, should be 20 in residual currency and 15 in amount_residual |
866 | - |
867 | !python {model: account.invoice}: | |
868 | + from openerp.tools import float_compare |
869 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl")) |
870 | move_line_obj = self.pool.get('account.move.line') |
871 | 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)]) |
872 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
873 | - assert (move_line.amount_residual_currency == 20.0 and move_line.amount_residual == 15) , "Residual amount is not correct for first Invoice" |
874 | + assert (float_compare(move_line.amount_residual_currency, 20.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 15, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice" |
875 | - |
876 | I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual |
877 | - |
878 | !python {model: account.invoice}: | |
879 | + from openerp.tools import float_compare |
880 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl")) |
881 | move_line_obj = self.pool.get('account.move.line') |
882 | 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)]) |
883 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
884 | - assert (move_line.amount_residual_currency == 30 and move_line.amount_residual == 24) , "Residual amount is not correct for second Invoice" |
885 | + assert (float_compare(move_line.amount_residual_currency, 30, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 24, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice" |
886 | - |
887 | I create the second voucher of payment with values 45 USD, journal USD, |
888 | - |
889 | @@ -233,11 +241,12 @@ |
890 | I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$> |
891 | - |
892 | !python {model: account.voucher}: | |
893 | + from openerp.tools import float_compare |
894 | vals = {} |
895 | voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2_suppl')) |
896 | data = [] |
897 | for item in voucher_id.line_cr_ids: |
898 | - if item.amount_unreconciled == 20.00: |
899 | + if float_compare(item.amount_unreconciled, 20.00, precision_digits=2) == 0: |
900 | data += [(item.id, 20.0)] |
901 | else: |
902 | data += [(item.id, 30.0)] |
903 | @@ -248,16 +257,18 @@ |
904 | I check that writeoff amount computed is -5.0 |
905 | - |
906 | !python {model: account.voucher}: | |
907 | + from openerp.tools import float_compare |
908 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
909 | voucher_id = self.browse(cr, uid, voucher[0]) |
910 | - assert (voucher_id.writeoff_amount == 5.0), "Writeoff amount is not 5.0" |
911 | + assert (float_compare(voucher_id.writeoff_amount, 5.0, precision_digits=2) == 0), "Writeoff amount is not 5.0" |
912 | - |
913 | I check that currency rate difference is 8.50 |
914 | - |
915 | !python {model: account.voucher}: | |
916 | + from openerp.tools import float_compare |
917 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
918 | voucher_id = self.browse(cr, uid, voucher[0]) |
919 | - assert (voucher_id.currency_rate_difference == 8.50), "Currency rate difference is not 8.50" |
920 | + assert (float_compare(voucher_id.currency_rate_difference, 8.50, precision_digits=2) == 0), "Currency rate difference is not 8.50" |
921 | - |
922 | I confirm the voucher |
923 | - |
924 | @@ -281,34 +292,37 @@ |
925 | I check that my writeoff is correct. 4.75 in credit and 5 in amount_currency |
926 | - |
927 | !python {model: account.voucher}: | |
928 | + from openerp.tools import float_compare |
929 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
930 | voucher_id = self.browse(cr, uid, voucher[0]) |
931 | move_line_obj = self.pool.get('account.move.line') |
932 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
933 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
934 | - if move_line.amount_currency == 20.00: |
935 | - assert move_line.debit == 15.00, "Debtor account has wrong entry." |
936 | - elif move_line.amount_currency == 30.00: |
937 | - assert move_line.debit == 24.00, "Debtor account has wrong entry." |
938 | - elif move_line.debit == 8.50: |
939 | - assert move_line.amount_currency == 0.00, "Incorrect Currency Difference." |
940 | - elif move_line.amount_currency == -5.00: |
941 | - assert move_line.credit == 4.75, "Writeoff amount is wrong." |
942 | + if float_compare(move_line.amount_currency, 20.00, precision_digits=2) == 0: |
943 | + assert float_compare(move_line.debit, 15.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
944 | + elif float_compare(move_line.amount_currency, 30.00, precision_digits=2) == 0: |
945 | + assert float_compare(move_line.debit, 24.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
946 | + elif float_compare(move_line.debit, 8.50, precision_digits=2) == 0: |
947 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Incorrect Currency Difference." |
948 | + elif float_compare(move_line.amount_currency, -5.00, precision_digits=2) == 0: |
949 | + assert float_compare(move_line.credit, 4.75, precision_digits=2) == 0, "Writeoff amount is wrong." |
950 | - |
951 | I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid |
952 | - |
953 | !python {model: account.invoice}: | |
954 | + from openerp.tools import float_compare |
955 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl")) |
956 | move_line_obj = self.pool.get('account.move.line') |
957 | 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)]) |
958 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
959 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
960 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
961 | - |
962 | I check the residual amount of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid |
963 | - |
964 | !python {model: account.invoice}: | |
965 | + from openerp.tools import float_compare |
966 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl")) |
967 | move_line_obj = self.pool.get('account.move.line') |
968 | 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)]) |
969 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
970 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
971 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
972 | |
973 | === modified file 'account_voucher/test/case2_usd_eur_debtor_in_eur.yml' |
974 | --- account_voucher/test/case2_usd_eur_debtor_in_eur.yml 2013-10-27 12:31:04 +0000 |
975 | +++ account_voucher/test/case2_usd_eur_debtor_in_eur.yml 2014-03-05 10:51:17 +0000 |
976 | @@ -99,12 +99,13 @@ |
977 | I check that first invoice move is correct for debtor account(debit - credit == 150) |
978 | - |
979 | !python {model: account.invoice}: | |
980 | + from openerp.tools import float_compare |
981 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan")) |
982 | assert invoice_id.move_id, "Move not created for open invoice" |
983 | move_line_obj = self.pool.get('account.move.line') |
984 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
985 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
986 | - assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account" |
987 | + assert (float_compare(move_line.debit - move_line.credit, 150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
988 | - |
989 | I create the second invoice on 1st February for 100 USD |
990 | - |
991 | @@ -132,12 +133,13 @@ |
992 | I check that second invoice move is correct for debtor account (debit - credit == 80) |
993 | - |
994 | !python {model: account.invoice}: | |
995 | + from openerp.tools import float_compare |
996 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb")) |
997 | assert invoice_id.move_id, "Move not created for open invoice" |
998 | move_line_obj = self.pool.get('account.move.line') |
999 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
1000 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1001 | - assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account" |
1002 | + assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
1003 | - |
1004 | I set the context that will be used for the encoding of all the vouchers of this file |
1005 | - |
1006 | @@ -163,13 +165,14 @@ |
1007 | I fill amounts 130 for the invoice of 200$ and 70 for the invoice of 100$ |
1008 | - |
1009 | !python {model: account.voucher}: | |
1010 | + from openerp.tools import float_compare |
1011 | import time |
1012 | from openerp import netsvc |
1013 | vals = {} |
1014 | voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2a')) |
1015 | data = [] |
1016 | for item in voucher_id.line_cr_ids: |
1017 | - if item.amount_unreconciled == 150.00: |
1018 | + if float_compare(item.amount_unreconciled, 150.00, precision_digits=2) == 0: |
1019 | data += [(item.id, 130.0)] |
1020 | else: |
1021 | data += [(item.id, 70.0)] |
1022 | @@ -197,20 +200,22 @@ |
1023 | I check the residual amount of Invoice1, should be 55.56 in residual currency and 20 in amount_residual |
1024 | - |
1025 | !python {model: account.invoice}: | |
1026 | + from openerp.tools import float_compare |
1027 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan")) |
1028 | move_line_obj = self.pool.get('account.move.line') |
1029 | 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)]) |
1030 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1031 | - assert (move_line.amount_residual_currency == 55.56 and move_line.amount_residual == 20) , "Residual amount is not correct for first Invoice. Got %s USD (%s EUR)" %(move_line.amount_residual_currency, move_line.amount_residual) |
1032 | + assert (float_compare(move_line.amount_residual_currency, 55.56, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 20, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice. Got %s USD (%s EUR)" %(move_line.amount_residual_currency, move_line.amount_residual) |
1033 | - |
1034 | I check the residual amuont of Invoice2, should be 22.22 in residual currency and 10 in amount_residual |
1035 | - |
1036 | !python {model: account.invoice}: | |
1037 | + from openerp.tools import float_compare |
1038 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb")) |
1039 | move_line_obj = self.pool.get('account.move.line') |
1040 | 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)]) |
1041 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1042 | - assert (move_line.amount_residual_currency == 22.22 and move_line.amount_residual == 10) , "Residual amount is not correct for second Invoice" |
1043 | + assert (float_compare(move_line.amount_residual_currency, 22.22, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 10, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice" |
1044 | - |
1045 | I create the second voucher of payment with values 80 USD, journal USD |
1046 | - |
1047 | @@ -233,11 +238,12 @@ |
1048 | !python {model: account.voucher}: | |
1049 | import time |
1050 | from openerp import netsvc |
1051 | + from openerp.tools import float_compare |
1052 | vals = {} |
1053 | voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2a')) |
1054 | data = [] |
1055 | for item in voucher_id.line_cr_ids: |
1056 | - if item.amount_unreconciled == 55.56: |
1057 | + if float_compare(item.amount_unreconciled, 55.56, precision_digits=2) == 0: |
1058 | data += [(item.id, 55.56)] |
1059 | else: |
1060 | data += [(item.id, 22.22)] |
1061 | @@ -248,9 +254,10 @@ |
1062 | I check that writeoff amount computed is 2.22 |
1063 | - |
1064 | !python {model: account.voucher}: | |
1065 | + from openerp.tools import float_compare |
1066 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1067 | voucher_id = self.browse(cr, uid, voucher[0]) |
1068 | - assert (round(voucher_id.writeoff_amount, 2) == 2.22), "Writeoff amount is not 2.22$" |
1069 | + assert (float_compare(round(voucher_id.writeoff_amount, 2), 2.22, precision_digits=2) == 0), "Writeoff amount is not 2.22$" |
1070 | - |
1071 | I confirm the voucher |
1072 | - |
1073 | @@ -275,44 +282,47 @@ |
1074 | I check that my writeoff is correct. 2.11 in credit and 2.22 in amount_currency |
1075 | - |
1076 | !python {model: account.voucher}: | |
1077 | + from openerp.tools import float_compare |
1078 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1079 | voucher_id = self.browse(cr, uid, voucher[0]) |
1080 | move_line_obj = self.pool.get('account.move.line') |
1081 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
1082 | reconcile_a = reconcile_b = False |
1083 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1084 | - if move_line.amount_currency == -22.22: |
1085 | + if float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0: |
1086 | assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled" |
1087 | reconcile_b = move_line.reconcile_id.id |
1088 | - elif move_line.amount_currency == -55.56: |
1089 | + elif float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0: |
1090 | assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled" |
1091 | reconcile_a = move_line.reconcile_id.id |
1092 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1093 | - if move_line.amount_currency == -55.56: |
1094 | - assert move_line.credit == 52.78, "Debtor account has wrong entry." |
1095 | - elif move_line.amount_currency == -22.22: |
1096 | - assert move_line.credit == 21.11, "Debtor account has wrong entry." |
1097 | - elif move_line.credit == 11.11 and move_line.account_id.reconcile: |
1098 | - assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference." |
1099 | - elif move_line.credit == 32.78 and move_line.account_id.reconcile: |
1100 | - assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference." |
1101 | - elif move_line.amount_currency == 2.22: |
1102 | - assert move_line.credit == 2.11, "Writeoff amount is wrong." |
1103 | + if float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0: |
1104 | + assert float_compare(move_line.credit, 52.78, precision_digits=2) == 0, "Debtor account has wrong entry." |
1105 | + elif float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0: |
1106 | + assert float_compare(move_line.credit, 21.11, precision_digits=2) == 0, "Debtor account has wrong entry." |
1107 | + elif float_compare(move_line.credit, 11.11, precision_digits=2) == 0 and move_line.account_id.reconcile: |
1108 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference." |
1109 | + elif float_compare(move_line.credit, 32.78, precision_digits=2) == 0 and move_line.account_id.reconcile: |
1110 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference." |
1111 | + elif float_compare(move_line.amount_currency, 2.22, precision_digits=2) == 0: |
1112 | + assert float_compare(move_line.credit, 2.11, precision_digits=2) == 0, "Writeoff amount is wrong." |
1113 | - |
1114 | I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid |
1115 | - |
1116 | !python {model: account.invoice}: | |
1117 | + from openerp.tools import float_compare |
1118 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan")) |
1119 | move_line_obj = self.pool.get('account.move.line') |
1120 | 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)]) |
1121 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1122 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
1123 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
1124 | - |
1125 | I check the residual amuont of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid |
1126 | - |
1127 | !python {model: account.invoice}: | |
1128 | + from openerp.tools import float_compare |
1129 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb")) |
1130 | move_line_obj = self.pool.get('account.move.line') |
1131 | 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)]) |
1132 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1133 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
1134 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
1135 | |
1136 | === modified file 'account_voucher/test/case2_usd_eur_debtor_in_usd.yml' |
1137 | --- account_voucher/test/case2_usd_eur_debtor_in_usd.yml 2013-10-27 12:31:04 +0000 |
1138 | +++ account_voucher/test/case2_usd_eur_debtor_in_usd.yml 2014-03-05 10:51:17 +0000 |
1139 | @@ -99,12 +99,13 @@ |
1140 | I check that first invoice move is correct for debtor account(debit - credit == 150) |
1141 | - |
1142 | !python {model: account.invoice}: | |
1143 | + from openerp.tools import float_compare |
1144 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal")) |
1145 | assert invoice_id.move_id, "Move not created for open invoice" |
1146 | move_line_obj = self.pool.get('account.move.line') |
1147 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
1148 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1149 | - assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account" |
1150 | + assert (float_compare(move_line.debit - move_line.credit, 150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
1151 | - |
1152 | I create the second invoice on 1st February for 100 USD |
1153 | - |
1154 | @@ -132,12 +133,13 @@ |
1155 | I check that second invoice move is correct for debtor account (debit - credit == 80) |
1156 | - |
1157 | !python {model: account.invoice}: | |
1158 | + from openerp.tools import float_compare |
1159 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal")) |
1160 | assert invoice_id.move_id, "Move not created for open invoice" |
1161 | move_line_obj = self.pool.get('account.move.line') |
1162 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
1163 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1164 | - assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account" |
1165 | + assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
1166 | - |
1167 | I set the context that will be used for the encoding of all the vouchers of this file |
1168 | - |
1169 | @@ -163,11 +165,12 @@ |
1170 | I fill amounts 130 for the invoice of 200$ and 70 for the invoice of 100$> |
1171 | - |
1172 | !python {model: account.voucher}: | |
1173 | + from openerp.tools import float_compare |
1174 | vals = {} |
1175 | voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2b')) |
1176 | data = [] |
1177 | for item in voucher_id.line_cr_ids: |
1178 | - if item.amount_unreconciled == 150.00: |
1179 | + if float_compare(item.amount_unreconciled, 150.00, precision_digits=2) == 0: |
1180 | data += [(item.id, 130.0)] |
1181 | else: |
1182 | data += [(item.id, 70.0)] |
1183 | @@ -196,33 +199,36 @@ |
1184 | I check that the debtor account has 2 new lines with 144.44 and 77.78 in amount_currency columns and their credit columns are 130 and 70 |
1185 | - |
1186 | !python {model: account.voucher}: | |
1187 | + from openerp.tools import float_compare |
1188 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1189 | voucher_id = self.browse(cr, uid, voucher[0]) |
1190 | move_line_obj = self.pool.get('account.move.line') |
1191 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
1192 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1193 | - if move_line.credit == 70.0: |
1194 | - assert move_line.amount_currency == -77.78, "Wrong debtor entry" |
1195 | - if move_line.credit == 130.0: |
1196 | - assert move_line.amount_currency == -144.44, "Wrong debtor entry" |
1197 | + if float_compare(move_line.credit, 70.0, precision_digits=2) == 0: |
1198 | + assert float_compare(move_line.amount_currency, -77.78, precision_digits=2) == 0, "Wrong debtor entry" |
1199 | + if float_compare(move_line.credit, 130.0, precision_digits=2) == 0: |
1200 | + assert float_compare(move_line.amount_currency, -144.44, precision_digits=2) == 0, "Wrong debtor entry" |
1201 | - |
1202 | I check the residual amount of Invoice1, should be 55.56 in residual currency and 20 in amount_residual |
1203 | - |
1204 | !python {model: account.invoice}: | |
1205 | + from openerp.tools import float_compare |
1206 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal")) |
1207 | move_line_obj = self.pool.get('account.move.line') |
1208 | 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)]) |
1209 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1210 | - assert (move_line.amount_residual_currency == 55.56 and move_line.amount_residual == 20) , "Residual amount is not correct for first Invoice" |
1211 | + assert (float_compare(move_line.amount_residual_currency, 55.56, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 20, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice" |
1212 | - |
1213 | I check the residual amount of Invoice2, should be 22.22 in residual currency and 10 in amount_residual |
1214 | - |
1215 | !python {model: account.invoice}: | |
1216 | + from openerp.tools import float_compare |
1217 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal")) |
1218 | move_line_obj = self.pool.get('account.move.line') |
1219 | 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)]) |
1220 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1221 | - assert (move_line.amount_residual_currency == 22.22 and move_line.amount_residual == 10) , "Residual amount is not correct for second Invoice" |
1222 | + assert (float_compare(move_line.amount_residual_currency, 22.22, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 10, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice" |
1223 | - |
1224 | I create the second voucher of payment with values 80 USD, journal USD |
1225 | - |
1226 | @@ -243,11 +249,12 @@ |
1227 | and I fully reconcil the 2 previous invoices |
1228 | - |
1229 | !python {model: account.voucher}: | |
1230 | + from openerp.tools import float_compare |
1231 | vals = {} |
1232 | voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2b')) |
1233 | data = [] |
1234 | for item in voucher_id.line_cr_ids: |
1235 | - if item.amount_unreconciled == 55.56: |
1236 | + if float_compare(item.amount_unreconciled, 55.56, precision_digits=2) == 0: |
1237 | data += [(item.id, 55.56)] |
1238 | else: |
1239 | data += [(item.id, 22.22)] |
1240 | @@ -258,9 +265,10 @@ |
1241 | I check that writeoff amount computed is 2.22 |
1242 | - |
1243 | !python {model: account.voucher}: | |
1244 | + from openerp.tools import float_compare |
1245 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1246 | voucher_id = self.browse(cr, uid, voucher[0]) |
1247 | - assert (round(voucher_id.writeoff_amount, 2) == 2.22), "Writeoff amount is not 2.22$" |
1248 | + assert (float_compare(round(voucher_id.writeoff_amount, 2), 2.22, precision_digits=2) == 0), "Writeoff amount is not 2.22$" |
1249 | - |
1250 | I confirm the voucher |
1251 | - |
1252 | @@ -284,44 +292,47 @@ |
1253 | I check that my writeoff is correct. 2.11 in credit and 2.22 in amount_currency |
1254 | - |
1255 | !python {model: account.voucher}: | |
1256 | + from openerp.tools import float_compare |
1257 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1258 | voucher_id = self.browse(cr, uid, voucher[0]) |
1259 | move_line_obj = self.pool.get('account.move.line') |
1260 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
1261 | reconcile_a = reconcile_b = False |
1262 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1263 | - if move_line.amount_currency == -22.22: |
1264 | + if float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0: |
1265 | assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled" |
1266 | reconcile_b = move_line.reconcile_id.id |
1267 | - elif move_line.amount_currency == -55.56: |
1268 | + elif float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0: |
1269 | assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled" |
1270 | reconcile_a = move_line.reconcile_id.id |
1271 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1272 | - if move_line.amount_currency == -55.56: |
1273 | - assert move_line.credit == 52.78, "Debtor account has wrong entry." |
1274 | - elif move_line.amount_currency == -22.22: |
1275 | - assert move_line.credit == 21.11, "Debtor account has wrong entry." |
1276 | - elif move_line.credit == 11.11 and move_line.account_id.reconcile: |
1277 | - assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference." |
1278 | - elif move_line.credit == 32.78 and move_line.account_id.reconcile: |
1279 | - assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference." |
1280 | - elif move_line.amount_currency == 2.22: |
1281 | - assert move_line.credit == 2.11, "Writeoff amount is wrong." |
1282 | + if float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0: |
1283 | + assert float_compare(move_line.credit, 52.78, precision_digits=2) == 0, "Debtor account has wrong entry." |
1284 | + elif float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0: |
1285 | + assert float_compare(move_line.credit, 21.11, precision_digits=2) == 0, "Debtor account has wrong entry." |
1286 | + elif float_compare(move_line.credit, 11.11, precision_digits=2) == 0 and move_line.account_id.reconcile: |
1287 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference." |
1288 | + elif float_compare(move_line.credit, 32.78, precision_digits=2) == 0 and move_line.account_id.reconcile: |
1289 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference." |
1290 | + elif float_compare(move_line.amount_currency, 2.22, precision_digits=2) == 0: |
1291 | + assert float_compare(move_line.credit, 2.11, precision_digits=2) == 0, "Writeoff amount is wrong." |
1292 | - |
1293 | I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid |
1294 | - |
1295 | !python {model: account.invoice}: | |
1296 | + from openerp.tools import float_compare |
1297 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal")) |
1298 | move_line_obj = self.pool.get('account.move.line') |
1299 | 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)]) |
1300 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1301 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
1302 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
1303 | - |
1304 | I check the residual amount of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid |
1305 | - |
1306 | !python {model: account.invoice}: | |
1307 | + from openerp.tools import float_compare |
1308 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal")) |
1309 | move_line_obj = self.pool.get('account.move.line') |
1310 | 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)]) |
1311 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1312 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
1313 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" |
1314 | |
1315 | === modified file 'account_voucher/test/case3_eur_eur.yml' |
1316 | --- account_voucher/test/case3_eur_eur.yml 2013-10-27 12:31:04 +0000 |
1317 | +++ account_voucher/test/case3_eur_eur.yml 2014-03-05 10:51:17 +0000 |
1318 | @@ -54,12 +54,13 @@ |
1319 | I check that first invoice move is correct for debtor account(debit - credit == 150) |
1320 | - |
1321 | !python {model: account.invoice}: | |
1322 | + from openerp.tools import float_compare |
1323 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur")) |
1324 | assert invoice_id.move_id, "Move not created for open invoice" |
1325 | move_line_obj = self.pool.get('account.move.line') |
1326 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
1327 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1328 | - assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account" |
1329 | + assert (float_compare(move_line.debit - move_line.credit, 150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
1330 | - |
1331 | I create the second invoice on 1st February for 80 EUR |
1332 | - |
1333 | @@ -87,12 +88,13 @@ |
1334 | I check that second invoice move is correct for debtor account (debit - credit == 80) |
1335 | - |
1336 | !python {model: account.invoice}: | |
1337 | + from openerp.tools import float_compare |
1338 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur")) |
1339 | assert invoice_id.move_id, "Move not created for open invoice" |
1340 | move_line_obj = self.pool.get('account.move.line') |
1341 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
1342 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1343 | - assert (move_line.debit - move_line.credit == 80.00), "Invoice move is incorrect for debtors account" |
1344 | + assert (float_compare(move_line.debit - move_line.credit, 80.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
1345 | - |
1346 | I set the context that will be used for the encoding of all the vouchers of this file |
1347 | - |
1348 | @@ -118,11 +120,12 @@ |
1349 | I fill amounts 100 for the invoice of 150€ and 20 for the invoice of 80€ |
1350 | - |
1351 | !python {model: account.voucher}: | |
1352 | + from openerp.tools import float_compare |
1353 | vals = {} |
1354 | voucher_id = self.browse(cr, uid, ref('account_voucher_1_case3')) |
1355 | data = [] |
1356 | for item in voucher_id.line_cr_ids: |
1357 | - if item.amount_unreconciled == 150.00: |
1358 | + if float_compare(item.amount_unreconciled, 150.00, precision_digits=2) == 0: |
1359 | data += [(item.id, 100.0)] |
1360 | else: |
1361 | data += [(item.id, 20.0)] |
1362 | @@ -133,9 +136,10 @@ |
1363 | I check that writeoff amount computed is 0.00 |
1364 | - |
1365 | !python {model: account.voucher}: | |
1366 | + from openerp.tools import float_compare |
1367 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))]) |
1368 | voucher_id = self.browse(cr, uid, voucher[0]) |
1369 | - assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0.00" |
1370 | + assert (float_compare(voucher_id.writeoff_amount, 0.00, precision_digits=2) == 0), "Writeoff amount is not 0.00" |
1371 | - |
1372 | I confirm the voucher |
1373 | - |
1374 | @@ -158,33 +162,36 @@ |
1375 | 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 |
1376 | - |
1377 | !python {model: account.voucher}: | |
1378 | + from openerp.tools import float_compare |
1379 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))]) |
1380 | voucher_id = self.browse(cr, uid, voucher[0]) |
1381 | move_line_obj = self.pool.get('account.move.line') |
1382 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
1383 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1384 | - if move_line.credit == 20.00: |
1385 | - assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." |
1386 | - elif move_line.credit == 100.00: |
1387 | - assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." |
1388 | + if float_compare(move_line.credit, 20.00, precision_digits=2) == 0: |
1389 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
1390 | + elif float_compare(move_line.credit, 100.00, precision_digits=2) == 0: |
1391 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
1392 | - |
1393 | I check the residual amount of Invoice1 is 50 |
1394 | - |
1395 | !python {model: account.invoice}: | |
1396 | + from openerp.tools import float_compare |
1397 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur")) |
1398 | move_line_obj = self.pool.get('account.move.line') |
1399 | 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)]) |
1400 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1401 | - assert (move_line.amount_residual_currency == 50.0 and move_line.amount_residual == 50.0) , "Residual amount is not correct for first Invoice" |
1402 | + 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" |
1403 | - |
1404 | I check the residual amuont of Invoice2 is 60 |
1405 | - |
1406 | !python {model: account.invoice}: | |
1407 | + from openerp.tools import float_compare |
1408 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur")) |
1409 | move_line_obj = self.pool.get('account.move.line') |
1410 | 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)]) |
1411 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1412 | - assert (move_line.amount_residual_currency == 60.0 and move_line.amount_residual == 60.0) , "Residual amount is not correct for second Invoice" |
1413 | + 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" |
1414 | - |
1415 | I create the second voucher of payment with values 120€, journal EUR, and check to let open the debtor overpaid amount |
1416 | - |
1417 | @@ -205,13 +212,14 @@ |
1418 | I fill amounts 50 for the invoice of 150€ and 70 for the invoice of 80€ |
1419 | - |
1420 | !python {model: account.voucher}: | |
1421 | + from openerp.tools import float_compare |
1422 | vals = {} |
1423 | voucher_id = self.browse(cr, uid, ref('account_voucher_2_case3')) |
1424 | data = [] |
1425 | for item in voucher_id.line_cr_ids: |
1426 | - if item.amount_unreconciled == 50.00: |
1427 | + if float_compare(item.amount_unreconciled, 50.00, precision_digits=2) == 0: |
1428 | data += [(item.id, 50.0)] |
1429 | - elif item.amount_unreconciled == 60.00: |
1430 | + elif float_compare(item.amount_unreconciled, 60.00, precision_digits=2) == 0: |
1431 | data += [(item.id, 70.00)] |
1432 | for line_id, amount in data: |
1433 | self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount}) |
1434 | @@ -220,9 +228,10 @@ |
1435 | I check that writeoff amount computed is 0.00 |
1436 | - |
1437 | !python {model: account.voucher}: | |
1438 | + from openerp.tools import float_compare |
1439 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))]) |
1440 | voucher_id = self.browse(cr, uid, voucher[0]) |
1441 | - assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0" |
1442 | + assert (float_compare(voucher_id.writeoff_amount, 0.00, precision_digits=2) == 0), "Writeoff amount is not 0" |
1443 | - |
1444 | I confirm the voucher |
1445 | - |
1446 | @@ -245,30 +254,33 @@ |
1447 | 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 |
1448 | - |
1449 | !python {model: account.voucher}: | |
1450 | + from openerp.tools import float_compare |
1451 | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1452 | voucher_id = self.browse(cr, uid, voucher[0]) |
1453 | move_line_obj = self.pool.get('account.move.line') |
1454 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
1455 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1456 | - if move_line.credit == 70.00: |
1457 | - assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." |
1458 | - elif move_line.credit == 50.00: |
1459 | - assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." |
1460 | + if float_compare(move_line.credit, 70.00, precision_digits=2) == 0: |
1461 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
1462 | + elif float_compare(move_line.credit, 50.00, precision_digits=2) == 0: |
1463 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry." |
1464 | - |
1465 | I check the residual amount of Invoice1 is 0 |
1466 | - |
1467 | !python {model: account.invoice}: | |
1468 | + from openerp.tools import float_compare |
1469 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur")) |
1470 | move_line_obj = self.pool.get('account.move.line') |
1471 | 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)]) |
1472 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1473 | - assert (move_line.amount_residual_currency == 0 and move_line.amount_residual == 0) , "Residual amount is not correct for first Invoice" |
1474 | + 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" |
1475 | - |
1476 | I check the residual amuont of Invoice2 is -10 |
1477 | - |
1478 | !python {model: account.invoice}: | |
1479 | + from openerp.tools import float_compare |
1480 | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur")) |
1481 | move_line_obj = self.pool.get('account.move.line') |
1482 | 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)]) |
1483 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1484 | - assert (move_line.amount_residual_currency == -10.0 and move_line.amount_residual == -10.0) , "Residual amount is not correct for second Invoice" |
1485 | + 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" |
1486 | |
1487 | === modified file 'account_voucher/test/case4_cad_chf.yml' |
1488 | --- account_voucher/test/case4_cad_chf.yml 2013-10-27 12:31:04 +0000 |
1489 | +++ account_voucher/test/case4_cad_chf.yml 2014-03-05 10:51:17 +0000 |
1490 | @@ -88,12 +88,13 @@ |
1491 | I check that first invoice move is correct for debtor account (debit - credit == 149.39) |
1492 | - |
1493 | !python {model: account.invoice}: | |
1494 | + from openerp.tools import float_compare |
1495 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad")) |
1496 | assert invoice_id.move_id, "Move not created for open invoice" |
1497 | move_line_obj = self.pool.get('account.move.line') |
1498 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
1499 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1500 | - assert (move_line.debit - move_line.credit == 149.39), "Invoice move is incorrect for debtors account" |
1501 | + assert (float_compare(move_line.debit - move_line.credit, 149.39, precision_digits=2) == 0), "Invoice move is incorrect for debtors account" |
1502 | - |
1503 | I set the context that will be used for the encoding of all the vouchers of this file |
1504 | - |
1505 | @@ -120,11 +121,12 @@ |
1506 | !python {model: account.voucher}: | |
1507 | import time |
1508 | from openerp import netsvc |
1509 | + from openerp.tools import float_compare |
1510 | vals = {} |
1511 | voucher_id = self.browse(cr, uid, ref('account_voucher_1_case4')) |
1512 | data = [] |
1513 | for item in voucher_id.line_cr_ids: |
1514 | - if item.amount_unreconciled == 186.74: |
1515 | + if float_compare(item.amount_unreconciled, 186.74, precision_digits=2) == 0: |
1516 | data += [(item.id, 186.74)] |
1517 | else: |
1518 | data += [(item.id, 0.0)] |
1519 | @@ -135,9 +137,10 @@ |
1520 | I check that writeoff amount computed is 13.26 |
1521 | - |
1522 | !python {model: account.voucher}: | |
1523 | + from openerp.tools import float_compare |
1524 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1525 | voucher_id = self.browse(cr, uid, voucher[0]) |
1526 | - assert (round(voucher_id.writeoff_amount,2) == 13.26), "Writeoff amount is not 13.26 CHF" |
1527 | + assert (float_compare(round(voucher_id.writeoff_amount,2), 13.26, precision_digits=2) == 0), "Writeoff amount is not 13.26 CHF" |
1528 | - |
1529 | I confirm the voucher |
1530 | - |
1531 | @@ -166,28 +169,30 @@ |
1532 | I check that my writeoff is correct. 11.05 credit and -13.26 amount_currency |
1533 | - |
1534 | !python {model: account.voucher}: | |
1535 | + from openerp.tools import float_compare |
1536 | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))]) |
1537 | voucher_id = self.browse(cr, uid, voucher[0]) |
1538 | move_line_obj = self.pool.get('account.move.line') |
1539 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)]) |
1540 | for move_line in move_line_obj.browse(cr, uid, move_lines): |
1541 | - if move_line.amount_currency == 200: |
1542 | - assert move_line.debit == 160.00, "Bank account has wrong entry." |
1543 | - elif move_line.amount_currency == -298.78: |
1544 | - assert move_line.credit == 149.39, "Debtor account has wrong entry." |
1545 | - elif move_line.debit == 0.00 and move_line.credit == 0.00: |
1546 | - assert move_line.amount_currency == 98.78, "Incorrect Currency Difference, got %s as amount_currency (expected 98.78)." % (move_line.amount_currency) |
1547 | + if float_compare(move_line.amount_currency, 200, precision_digits=2) == 0: |
1548 | + assert float_compare(move_line.debit, 160.00, precision_digits=2) == 0, "Bank account has wrong entry." |
1549 | + elif float_compare(move_line.amount_currency, -298.78, precision_digits=2) == 0 : |
1550 | + assert float_compare(move_line.credit, 149.39, precision_digits=2) == 0, "Debtor account has wrong entry." |
1551 | + elif float_compare(move_line.debit, 0.00, precision_digits=2) == 0 and float_compare(move_line.credit, 0.00, precision_digits=2) == 0: |
1552 | + assert float_compare(move_line.amount_currency, 98.78, precision_digits=2) == 0, "Incorrect Currency Difference, got %s as amount_currency (expected 98.78)." % (move_line.amount_currency) |
1553 | assert move_line.currency_id.id == ref('base.CAD'), "Incorrect Currency Difference, got %s (expected 'CAD')" % (move_line.currency_id.name) |
1554 | - elif move_line.credit == 10.61: |
1555 | - assert move_line.amount_currency == -13.26, "Writeoff amount is wrong." |
1556 | + elif float_compare(move_line.credit, 10.61, precision_digits=2) == 0: |
1557 | + assert float_compare(move_line.amount_currency, -13.26, precision_digits=2) == 0, "Writeoff amount is wrong." |
1558 | else: |
1559 | assert False, "Wrong entry" |
1560 | - |
1561 | I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid |
1562 | - |
1563 | !python {model: account.invoice}: | |
1564 | + from openerp.tools import float_compare |
1565 | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad")) |
1566 | move_line_obj = self.pool.get('account.move.line') |
1567 | 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)]) |
1568 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1569 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
1570 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" |
1571 | |
1572 | === modified file 'account_voucher/test/case5_suppl_usd_usd.yml' |
1573 | --- account_voucher/test/case5_suppl_usd_usd.yml 2013-10-27 12:31:04 +0000 |
1574 | +++ account_voucher/test/case5_suppl_usd_usd.yml 2014-03-05 10:51:17 +0000 |
1575 | @@ -92,13 +92,14 @@ |
1576 | I check that first invoice move is correct for creditor account(debit - credit == -555.56) |
1577 | - |
1578 | !python {model: account.invoice}: | |
1579 | + from openerp.tools import float_compare |
1580 | invoice_id = self.browse(cr, uid, ref("account_supplier_invoice_november")) |
1581 | assert invoice_id.move_id, "Move not created for open invoice" |
1582 | move_line_obj = self.pool.get('account.move.line') |
1583 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)]) |
1584 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1585 | - assert (move_line.debit - move_line.credit == -555.56), "Invoice move is incorrect for creditor account" |
1586 | - assert (move_line.amount_currency == -1000), "Amount currency is incorrect for creditor account" |
1587 | + assert (float_compare(move_line.debit - move_line.credit, -555.56, precision_digits=2) == 0), "Invoice move is incorrect for creditor account" |
1588 | + assert (float_compare(move_line.amount_currency, -1000, precision_digits=2) == 0), "Amount currency is incorrect for creditor account" |
1589 | - |
1590 | I set the context that will be used for the encoding of all the vouchers of this file |
1591 | - |
1592 | @@ -125,17 +126,20 @@ |
1593 | - |
1594 | !python {model: account.voucher}: | |
1595 | import time |
1596 | + from openerp.tools import float_compare |
1597 | vals = {} |
1598 | voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow')) |
1599 | for item in voucher_id.line_dr_ids: |
1600 | - if item.amount_unreconciled == 1000.00: |
1601 | + if float_compare(item.amount_unreconciled, 1000.00, precision_digits=2) == 0: |
1602 | self.pool.get('account.voucher.line').write(cr, uid, [item.id], {'amount': 1000}) |
1603 | assert (voucher_id.state=='draft'), "Voucher is not in draft state" |
1604 | - |
1605 | I check that writeoff amount computed is -50.0 |
1606 | - |
1607 | - !assert {model: account.voucher, id: account_voucher_case_5_supplier_flow}: |
1608 | - - writeoff_amount == -50.0 |
1609 | + !python {model: account.voucher}: | |
1610 | + from openerp.tools import float_compare |
1611 | + writeoff_amount = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow')).writeoff_amount |
1612 | + assert float_compare(writeoff_amount, -50.0, precision_digits=2) == 0 |
1613 | - |
1614 | I confirm the voucher |
1615 | - |
1616 | @@ -160,24 +164,26 @@ |
1617 | I check that my writeoff is correct. 33.34€ in credit with -$50 as amount currency |
1618 | - |
1619 | !python {model: account.voucher}: | |
1620 | + from openerp.tools import float_compare |
1621 | voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow')) |
1622 | for move_line in voucher_id.move_id.line_id: |
1623 | - if move_line.amount_currency == -950.00: |
1624 | - assert move_line.credit == 633.33, "Wrong bank entry." |
1625 | - elif move_line.credit == 111.11 or move_line.debit == 111.11: |
1626 | - assert move_line.amount_currency == 0.00, "Incorrect Currency Difference." |
1627 | - elif move_line.credit == 33.34: |
1628 | - assert move_line.amount_currency == -50.0, "Writeoff amount is wrong." |
1629 | - elif move_line.debit == 666.67: |
1630 | - assert move_line.amount_currency == 1000.0, "Wrong supplier entry." |
1631 | + if float_compare(move_line.amount_currency, -950.00, precision_digits=2) == 0: |
1632 | + assert float_compare(move_line.credit, 633.33, precision_digits=2) == 0, "Wrong bank entry." |
1633 | + elif float_compare(move_line.credit, 111.11, precision_digits=2) == 0 or float_compare(move_line.debit, 111.11, precision_digits=2) == 0: |
1634 | + assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Incorrect Currency Difference." |
1635 | + elif float_compare(move_line.credit, 33.34, precision_digits=2) == 0: |
1636 | + assert float_compare(move_line.amount_currency, -50.0, precision_digits=2) == 0, "Writeoff amount is wrong." |
1637 | + elif float_compare(move_line.debit, 666.67, precision_digits=2) == 0: |
1638 | + assert float_compare(move_line.amount_currency, 1000.0, precision_digits=2) == 0, "Wrong supplier entry." |
1639 | else: |
1640 | assert False, "Wrong entry. Unrecognized account move line" |
1641 | - |
1642 | I check the residual amount of invoice, it should be 0 in residual currency and 0 in amount_residual and paid |
1643 | - |
1644 | !python {model: account.invoice}: | |
1645 | + from openerp.tools import float_compare |
1646 | invoice_id = self.browse(cr, uid, ref("account_supplier_invoice_november")) |
1647 | move_line_obj = self.pool.get('account.move.line') |
1648 | 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)]) |
1649 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1650 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for supplier invoice" |
1651 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for supplier invoice" |
1652 | |
1653 | === modified file 'account_voucher/test/case_eur_usd.yml' |
1654 | --- account_voucher/test/case_eur_usd.yml 2013-10-27 12:31:04 +0000 |
1655 | +++ account_voucher/test/case_eur_usd.yml 2014-03-05 10:51:17 +0000 |
1656 | @@ -102,10 +102,11 @@ |
1657 | I fill amount 1400 for the invoice of 1400$ |
1658 | - |
1659 | !python {model: account.voucher}: | |
1660 | + from openerp.tools import float_compare |
1661 | data = [] |
1662 | voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case')) |
1663 | for item in voucher.line_cr_ids: |
1664 | - if item.amount_unreconciled == 1400: |
1665 | + if float_compare(item.amount_unreconciled, 1400, precision_digits=2) == 0: |
1666 | data += [(item.id, 1400)] |
1667 | for line_id, amount in data: |
1668 | self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount}) |
1669 | @@ -114,8 +115,9 @@ |
1670 | I check that writeoff amount computed is -50.0 |
1671 | - |
1672 | !python {model: account.voucher}: | |
1673 | + from openerp.tools import float_compare |
1674 | voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case')) |
1675 | - assert (voucher.writeoff_amount == -50.0), "Writeoff amount is not -50.0" |
1676 | + assert (float_compare(voucher.writeoff_amount, -50.0, precision_digits=2) == 0), "Writeoff amount is not -50.0" |
1677 | - |
1678 | I confirm the voucher |
1679 | - |
1680 | @@ -147,14 +149,15 @@ |
1681 | I check that my bank account is correct. 964.29 debit and 1350 amount_currency |
1682 | - |
1683 | !python {model: account.voucher}: | |
1684 | + from openerp.tools import float_compare |
1685 | voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case')) |
1686 | for move_line in voucher.move_ids: |
1687 | - if move_line.amount_currency == 1350: |
1688 | - assert move_line.debit == 964.29,"debtor account is not correct" |
1689 | - if move_line.amount_currency == 50: |
1690 | - assert move_line.debit == 35.71,"write off bank account is not correct" |
1691 | - if move_line.amount_currency == 0.0: |
1692 | - assert move_line.credit == 1000,"total reconcile is not correct of invoice" |
1693 | + if float_compare(move_line.amount_currency, 1350, precision_digits=2) == 0: |
1694 | + assert float_compare(move_line.debit, 964.29, precision_digits=2) == 0,"debtor account is not correct" |
1695 | + if float_compare(move_line.amount_currency, 50, precision_digits=2) == 0: |
1696 | + assert float_compare(move_line.debit, 35.71, precision_digits=2) == 0,"write off bank account is not correct" |
1697 | + if float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0: |
1698 | + assert float_compare(move_line.credit, 1000, precision_digits=2) == 0,"total reconcile is not correct of invoice" |
1699 | - |
1700 | I check that the move of payment in invoice is valid |
1701 | - |
1702 | @@ -166,9 +169,9 @@ |
1703 | I check the residual amount of invoice should be 0 in residual currency and 0 in amount_residual and paid |
1704 | - |
1705 | !python {model: account.invoice}: | |
1706 | + from openerp.tools import float_compare |
1707 | invoice_id = self.browse(cr, uid, ref("account_invoice_eur_usd")) |
1708 | move_line_obj = self.pool.get('account.move.line') |
1709 | 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)]) |
1710 | move_line = move_line_obj.browse(cr, uid, move_lines[0]) |
1711 | - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for Invoice" |
1712 | - |
1713 | + assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for Invoice" |
1714 | |
1715 | === modified file 'delivery/test/delivery_cost.yml' |
1716 | --- delivery/test/delivery_cost.yml 2013-10-27 12:31:04 +0000 |
1717 | +++ delivery/test/delivery_cost.yml 2014-03-05 10:51:17 +0000 |
1718 | @@ -9,10 +9,11 @@ |
1719 | I check sale order after added delivery cost. |
1720 | - |
1721 | !python {model: sale.order.line}: | |
1722 | + from openerp.tools import float_compare |
1723 | line_ids = self.search(cr, uid, [('order_id','=', ref('sale.sale_order_6')), ('product_id','=', ref('product_product_delivery'))]) |
1724 | assert len(line_ids), "Delivery cost is not Added" |
1725 | line_data = self.browse(cr ,uid ,line_ids[0] ,context) |
1726 | - assert line_data.price_subtotal == 10, "Delivey cost is not correspond." |
1727 | + assert float_compare(line_data.price_subtotal, 10, precision_digits=2) == 0, "Delivey cost is not correspond." |
1728 | - |
1729 | I confirm the sale order. |
1730 | - |
1731 | @@ -49,10 +50,11 @@ |
1732 | I check sale order after added delivery cost. |
1733 | - |
1734 | !python {model: sale.order.line}: | |
1735 | + from openerp.tools import float_compare |
1736 | line_ids = self.search(cr, uid, [('order_id','=', ref('sale.sale_order_2')), ('product_id','=', ref('product_product_delivery'))]) |
1737 | assert len(line_ids), "Delivery cost is not Added" |
1738 | line_data = self.browse(cr ,uid ,line_ids[0] ,context) |
1739 | - assert line_data.price_subtotal == 0, "Delivey cost is not correspond." |
1740 | + assert float_compare(line_data.price_subtotal, 0, precision_digits=2) == 0, "Delivey cost is not correspond." |
1741 | |
1742 | - |
1743 | I set default delivery policy. |
1744 | |
1745 | === modified file 'hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml' |
1746 | --- hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml 2013-10-27 12:31:04 +0000 |
1747 | +++ hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml 2014-03-05 10:51:17 +0000 |
1748 | @@ -92,6 +92,7 @@ |
1749 | I check that Invoice is created for this timesheet. |
1750 | - |
1751 | !python {model: account.analytic.line}: | |
1752 | + from openerp.tools import float_compare |
1753 | aline = self.browse(cr, uid, ref('account_analytic_line_developyamlforhrmodule0')) |
1754 | analytic_account_obj = self.pool.get('account.analytic.account') |
1755 | data = self.pool.get('hr.timesheet.invoice.create').read(cr, uid, [ref("hr_timesheet_invoice_create_0")], [], context)[0] |
1756 | @@ -111,5 +112,5 @@ |
1757 | assert product == product_exp |
1758 | assert aline.invoice_id, "Invoice created, but analytic line wasn't updated." |
1759 | assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line" |
1760 | - assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed |
1761 | - assert invoice_id.amount_tax == 50, "Invoice tax mismatch: %s" % invoice_id.amount_tax |
1762 | + assert float_compare(invoice_id.amount_untaxed, 187.5, precision_digits=2) == 0, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed |
1763 | + assert float_compare(invoice_id.amount_tax, 50, precision_digits=2) == 0, "Invoice tax mismatch: %s" % invoice_id.amount_tax |
1764 | |
1765 | === modified file 'hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml' |
1766 | --- hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml 2013-10-27 12:31:04 +0000 |
1767 | +++ hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml 2014-03-05 10:51:17 +0000 |
1768 | @@ -90,6 +90,7 @@ |
1769 | I check that Invoice is created for this timesheet. |
1770 | - |
1771 | !python {model: account.analytic.line}: | |
1772 | + from openerp.tools import float_compare |
1773 | aline = self.browse(cr, uid, ref('account_analytic_line_developyamlforhrmodule1')) |
1774 | analytic_account_obj = self.pool.get('account.analytic.account') |
1775 | data = self.pool.get('hr.timesheet.invoice.create').read(cr, uid, [ref("hr_timesheet_invoice_create_0")], [], context)[0] |
1776 | @@ -110,5 +111,5 @@ |
1777 | assert product == product_exp |
1778 | assert aline.invoice_id, "Invoice created, but analytic line wasn't updated." |
1779 | assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line" |
1780 | - assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed |
1781 | - assert invoice_id.amount_tax == 40, "Invoice tax mismatch: %s" % invoice_id.amount_tax |
1782 | + assert float_compare(invoice_id.amount_untaxed, 187.5, precision_digits=2) == 0, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed |
1783 | + assert float_compare(invoice_id.amount_tax, 40, precision_digits=2) == 0, "Invoice tax mismatch: %s" % invoice_id.amount_tax |
1784 | |
1785 | === modified file 'point_of_sale/test/02_order_to_invoice.yml' |
1786 | --- point_of_sale/test/02_order_to_invoice.yml 2014-01-15 09:42:20 +0000 |
1787 | +++ point_of_sale/test/02_order_to_invoice.yml 2014-03-05 10:51:17 +0000 |
1788 | @@ -42,5 +42,7 @@ |
1789 | - |
1790 | I test that the total of the attached invoice is correct |
1791 | - |
1792 | - !assert {model: pos.order, id: pos_order_pos1, string: Invoice not correct}: |
1793 | - - amount_total == (450*2 + 300*3*1.05)*0.95 |
1794 | + !python {model: pos.order}: | |
1795 | + from openerp.tools import float_compare |
1796 | + amount_total = self.browse(cr, uid, ref('pos_order_pos1')).amount_total |
1797 | + assert float_compare(amount_total, (450*2 + 300*3*1.05)*0.95, precision_digits=2) == 0, "Invoice not correct" |
1798 | |
1799 | === modified file 'product/test/product_pricelist.yml' |
1800 | --- product/test/product_pricelist.yml 2013-12-06 22:18:09 +0000 |
1801 | +++ product/test/product_pricelist.yml 2014-03-05 10:51:17 +0000 |
1802 | @@ -4,59 +4,67 @@ |
1803 | I check sale price of Assemble Computer |
1804 | - |
1805 | !python {model: product.product}: | |
1806 | + from openerp.tools import float_compare |
1807 | context.update({'pricelist': ref("customer_pricelist"), 'quantity':1}) |
1808 | product = self.browse(cr, uid, ref("product_product_4"), context=context) |
1809 | - assert product.price == (product.lst_price-product.lst_price*(0.10)), "Wrong sale price." |
1810 | + assert float_compare(product.price, (product.lst_price-product.lst_price*(0.10)), precision_digits=2) == 0, "Wrong sale price." |
1811 | - |
1812 | I check sale price of Laptop. |
1813 | - |
1814 | !python {model: product.product}: | |
1815 | + from openerp.tools import float_compare |
1816 | product = self.browse(cr, uid, ref("product_product_25"), context=context) |
1817 | - assert product.price == product.lst_price + 1, "Wrong sale price." |
1818 | + assert float_compare(product.price, product.lst_price + 1, precision_digits=2) == 0, "Wrong sale price." |
1819 | - |
1820 | I check sale price of IT component. |
1821 | - |
1822 | !python {model: product.product}: | |
1823 | + from openerp.tools import float_compare |
1824 | product = self.browse(cr, uid, ref("product_product_7"), context=context) |
1825 | - assert product.price == product.lst_price, "Wrong sale price." |
1826 | + assert float_compare(product.price, product.lst_price, precision_digits=2) == 0, "Wrong sale price." |
1827 | |
1828 | - |
1829 | I check sale price of IT component if more than 3 Unit. |
1830 | - |
1831 | !python {model: product.product}: | |
1832 | + from openerp.tools import float_compare |
1833 | context.update({'quantity':5}) |
1834 | product = self.browse(cr, uid, ref("product_product_26"), context=context) |
1835 | - assert product.price == product.lst_price-product.lst_price*(0.05), "Wrong sale price." |
1836 | + assert float_compare(product.price, product.lst_price-product.lst_price*(0.05), precision_digits=2) == 0, "Wrong sale price." |
1837 | - |
1838 | I check sale price of LCD Monitor. |
1839 | - |
1840 | !python {model: product.product}: | |
1841 | + from openerp.tools import float_compare |
1842 | context.update({'quantity':1}) |
1843 | product = self.browse(cr, uid, ref("product_product_6"), context=context) |
1844 | - assert product.price == product.lst_price, "Wrong sale price." |
1845 | + assert float_compare(product.price, product.lst_price, precision_digits=2) == 0, "Wrong sale price." |
1846 | |
1847 | - |
1848 | I check sale price of LCD Monitor on end of year. |
1849 | - |
1850 | !python {model: product.product}: | |
1851 | + from openerp.tools import float_compare |
1852 | context.update({'quantity':1, 'date': '2011-12-31'}) |
1853 | product = self.browse(cr, uid, ref("product_product_6"), context=context) |
1854 | - assert product.price == product.lst_price-product.lst_price*(0.30), "Wrong sale price." |
1855 | + assert float_compare(product.price, product.lst_price-product.lst_price*(0.30), precision_digits=2) == 0, "Wrong sale price." |
1856 | |
1857 | - |
1858 | I check cost price of LCD Monitor. |
1859 | - |
1860 | !python {model: product.product}: | |
1861 | + from openerp.tools import float_compare |
1862 | context.update({'quantity':1, 'date': False, 'partner': ref('base.res_partner_4'), 'pricelist': ref("supplier_pricelist")}) |
1863 | product = self.browse(cr, uid, ref("product_product_6"), context=context) |
1864 | - assert product.price == 792, "wrong cost price." |
1865 | + assert float_compare(product.price, 792, precision_digits=2) == 0, "Wrong cost price." |
1866 | - |
1867 | I check cost price of LCD Monitor if more than 3 Unit. |
1868 | - |
1869 | !python {model: product.product}: | |
1870 | + from openerp.tools import float_compare |
1871 | context.update({'quantity':3}) |
1872 | product = self.browse(cr, uid, ref("product_product_6"), context=context) |
1873 | - assert product.price == 787, "wrong cost price." |
1874 | + assert float_compare(product.price, 787, precision_digits=2) == 0, "wrong cost price." |
1875 | |
1876 | - |
1877 | I print the sale prices report. |
1878 | |
1879 | === modified file 'product/test/product_uom.yml' |
1880 | --- product/test/product_uom.yml 2014-02-07 15:13:20 +0000 |
1881 | +++ product/test/product_uom.yml 2014-03-05 10:51:17 +0000 |
1882 | @@ -4,14 +4,16 @@ |
1883 | I convert Grams into TON with price. |
1884 | - |
1885 | !python {model: product.uom}: | |
1886 | + from openerp.tools import float_compare |
1887 | from_uom_id = ref("product_uom_gram") |
1888 | to_uom_id = ref("product_uom_ton") |
1889 | price = 2 |
1890 | qty = 1020000 |
1891 | price = self._compute_price(cr, uid, from_uom_id, price, to_uom_id) |
1892 | qty = self._compute_qty(cr, uid, from_uom_id, qty, to_uom_id) |
1893 | - assert qty == 1.02, "Qty is not correspond." |
1894 | - assert price == 2000000.0, "Price is not correspond." |
1895 | + assert float_compare(qty, 1.02, precision_digits=2) == 0, "Qty is not correspond." |
1896 | + assert float_compare(price, 2000000.0, precision_digits=2) == 0, "Price is not correspond." |
1897 | + |
1898 | - |
1899 | I convert Liters into Gallons with price. |
1900 | - |
1901 | |
1902 | === modified file 'purchase/test/process/edi_purchase_order.yml' |
1903 | --- purchase/test/process/edi_purchase_order.yml 2012-11-29 22:26:45 +0000 |
1904 | +++ purchase/test/process/edi_purchase_order.yml 2014-03-05 10:51:17 +0000 |
1905 | @@ -37,6 +37,7 @@ |
1906 | Then I import a sample EDI document of a sale order (v7.0) |
1907 | - |
1908 | !python {model: edi.edi}: | |
1909 | + from openerp.tools import float_compare |
1910 | purchase_order_pool = self.pool.get('purchase.order') |
1911 | edi_document = { |
1912 | "__id": "sale:724f9v70-dv70-1v70-8v70-701a04e25v70.sale_order_test", |
1913 | @@ -120,17 +121,17 @@ |
1914 | assert bank_info.acc_number == "Guys bank: 123477777-156113", 'Expected "Guys bank: 123477777-156113", got %s' % bank_info.acc_number |
1915 | |
1916 | assert order_new.pricelist_id.name == 'Default Purchase Pricelist' , "Default Purchase Pricelist was not automatically assigned" |
1917 | - assert order_new.amount_total == 350, "Amount total is not same" |
1918 | - assert order_new.amount_untaxed == 350, "untaxed amount is not same" |
1919 | + assert float_compare(order_new.amount_total, 350, precision_digits=2) == 0, "Amount total is not same" |
1920 | + assert float_compare(order_new.amount_untaxed, 350, precision_digits=2) == 0, "untaxed amount is not same" |
1921 | assert len(order_new.order_line) == 2, "Purchase order lines number mismatch" |
1922 | for purchase_line in order_new.order_line: |
1923 | if purchase_line.name == 'PC Assemble SC234': |
1924 | assert purchase_line.product_uom.name == "Unit" , "uom is not same" |
1925 | - assert purchase_line.price_unit == 150 , "unit price is not same, got %s, expected 150"%(purchase_line.price_unit,) |
1926 | + assert float_compare(purchase_line.price_unit, 150 , precision_digits=2) == 0, "unit price is not same, got %s, expected 150"%(purchase_line.price_unit,) |
1927 | assert purchase_line.product_qty == 1 , "product qty is not same" |
1928 | elif purchase_line.name == 'PC on Demand': |
1929 | assert purchase_line.product_uom.name == "Unit" , "uom is not same" |
1930 | - assert purchase_line.price_unit == 20 , "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,) |
1931 | + assert float_compare(purchase_line.price_unit, 20 , precision_digits=2) == 0, "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,) |
1932 | assert purchase_line.product_qty == 10 , "product qty is not same" |
1933 | else: |
1934 | raise AssertionError('unknown order line: %s' % purchase_line) |
1935 | @@ -138,6 +139,7 @@ |
1936 | "Then I import a sample EDI document of a sale order (v6.1 - to test backwards compatibility)" |
1937 | - |
1938 | !python {model: edi.edi}: | |
1939 | + from openerp.tools import float_compare |
1940 | purchase_order_pool = self.pool.get('purchase.order') |
1941 | edi_document = { |
1942 | "__id": "sale:724f93ec-ddd0-11e0-88ec-701a04e25543.sale_order_test", |
1943 | @@ -221,17 +223,17 @@ |
1944 | assert bank_info.acc_number == "Another bank: 123477700-156113", 'Expected "Another bank: 123477700-156113", got %s' % bank_info.acc_number |
1945 | |
1946 | assert order_new.pricelist_id.name == 'Default Purchase Pricelist' , "Default Purchase Pricelist was not automatically assigned" |
1947 | - assert order_new.amount_total == 350, "Amount total is not same" |
1948 | - assert order_new.amount_untaxed == 350, "untaxed amount is not same" |
1949 | + assert float_compare(order_new.amount_total, 350, precision_digits=2) == 0, "Amount total is not same" |
1950 | + assert float_compare(order_new.amount_untaxed, 350, precision_digits=2) == 0, "untaxed amount is not same" |
1951 | assert len(order_new.order_line) == 2, "Purchase order lines number mismatch" |
1952 | for purchase_line in order_new.order_line: |
1953 | if purchase_line.name == 'Basic PC': |
1954 | assert purchase_line.product_uom.name == "PCE" , "uom is not same" |
1955 | - assert purchase_line.price_unit == 150 , "unit price is not same, got %s, expected 150"%(purchase_line.price_unit,) |
1956 | + assert float_compare(purchase_line.price_unit, 150 , precision_digits=2) == 0, "unit price is not same, got %s, expected 150"%(purchase_line.price_unit,) |
1957 | assert purchase_line.product_qty == 1 , "product qty is not same" |
1958 | elif purchase_line.name == 'Medium PC': |
1959 | assert purchase_line.product_uom.name == "PCE" , "uom is not same" |
1960 | - assert purchase_line.price_unit == 20 , "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,) |
1961 | + assert float_compare(purchase_line.price_unit, 20 , precision_digits=2) == 0, "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,) |
1962 | assert purchase_line.product_qty == 10 , "product qty is not same" |
1963 | else: |
1964 | - raise AssertionError('unknown order line: %s' % purchase_line) |
1965 | \ No newline at end of file |
1966 | + raise AssertionError('unknown order line: %s' % purchase_line) |
1967 | |
1968 | === modified file 'purchase/test/process/rfq2order2done.yml' |
1969 | --- purchase/test/process/rfq2order2done.yml 2013-10-27 12:31:04 +0000 |
1970 | +++ purchase/test/process/rfq2order2done.yml 2014-03-05 10:51:17 +0000 |
1971 | @@ -3,8 +3,10 @@ |
1972 | - |
1973 | I check the total untaxed amount of the RFQ is correctly computed |
1974 | - |
1975 | - !assert {model: purchase.order, id: purchase_order_1, string: The amount of RFQ is not correctly computed}: |
1976 | - - round(sum([l.price_subtotal for l in order_line]), 2) == round(amount_untaxed, 2) |
1977 | + !python {model: purchase.order}: | |
1978 | + from openerp.tools import float_compare |
1979 | + po = self.browse(cr, uid, ref('purchase_order_1')) |
1980 | + assert float_compare(sum([l.price_subtotal for l in po.order_line]), po.amount_untaxed, precision_digits=2) == 0, "The amount of RFQ is not correctly computed" |
1981 | - |
1982 | I confirm the RFQ. |
1983 | - |
1984 | @@ -18,6 +20,7 @@ |
1985 | I check that the invoice details which is generated after confirmed RFQ. |
1986 | - |
1987 | !python {model: purchase.order}: | |
1988 | + from openerp.tools import float_compare |
1989 | purchase_order = self.browse(cr, uid, ref("purchase_order_1")) |
1990 | assert len(purchase_order.invoice_ids) >= 1, "Invoice is not generated more or less than one" |
1991 | for invoice in purchase_order.invoice_ids: |
1992 | @@ -28,9 +31,9 @@ |
1993 | assert invoice.currency_id.id == purchase_order.pricelist_id.currency_id.id ,"Invoice currency is not correspond with purchase order" |
1994 | assert invoice.origin == purchase_order.name,"Invoice origin is not correspond with purchase order" |
1995 | assert invoice.company_id.id == purchase_order.company_id.id ,"Invoice company is not correspond with purchase order" |
1996 | - assert invoice.amount_untaxed == purchase_order.amount_untaxed, "Invoice untaxed amount is not correspond with purchase order" |
1997 | - assert invoice.amount_tax == purchase_order.amount_tax, "Invoice tax amount is not correspond with purchase order" |
1998 | - assert invoice.amount_total == purchase_order.amount_total, "Invoice total amount is not correspond with purchase order" |
1999 | + assert float_compare(invoice.amount_untaxed, purchase_order.amount_untaxed, precision_digits=2) == 0, "Invoice untaxed amount is not correspond with purchase order" |
2000 | + assert float_compare(invoice.amount_tax, purchase_order.amount_tax, precision_digits=2) == 0, "Invoice tax amount is not correspond with purchase order" |
2001 | + assert float_compare(invoice.amount_total, purchase_order.amount_total, precision_digits=2) == 0, "Invoice total amount is not correspond with purchase order" |
2002 | assert len(invoice.invoice_line) == len(purchase_order.order_line), "Lines of Invoice and Purchase Order are not correspond" |
2003 | - |
2004 | I check that Reception details after confirmed RFQ. |
2005 | |
2006 | === modified file 'purchase_requisition/test/purchase_requisition.yml' |
2007 | --- purchase_requisition/test/purchase_requisition.yml 2014-02-14 16:55:50 +0000 |
2008 | +++ purchase_requisition/test/purchase_requisition.yml 2014-03-05 10:51:17 +0000 |
2009 | @@ -21,6 +21,7 @@ |
2010 | I check requisition details which created after run procurement. |
2011 | - |
2012 | !python {model: procurement.order}: | |
2013 | + from openerp.tools import float_compare |
2014 | procurement_ids = self.search(cr, uid, [('requisition_id','!=', False)]) |
2015 | for procurement in self.browse(cr, uid, procurement_ids, context=context): |
2016 | requisition = procurement.requisition_id |
2017 | @@ -29,7 +30,7 @@ |
2018 | line = requisition.line_ids[0] |
2019 | assert line.product_id.id == procurement.product_id.id, "Product is not correspond." |
2020 | assert line.product_uom_id.id == procurement.product_uom.id, "UOM is not correspond." |
2021 | - assert line.product_qty == procurement.product_qty, "Quantity is not correspond." |
2022 | + assert float_compare(line.product_qty, procurement.product_qty, precision_digits=2) == 0, "Quantity is not correspond." |
2023 | - |
2024 | Give access rights of Purchase Requisition User to open requisition |
2025 | - |
2026 | @@ -56,6 +57,7 @@ |
2027 | I check that the RFQ details which created for supplier. |
2028 | - |
2029 | !python {model: purchase.order}: | |
2030 | + from openerp.tools import float_compare |
2031 | purchase_requisition = self.pool.get("purchase.requisition") |
2032 | purchase_ids = self.search(cr, uid, [('requisition_id','=',ref("requisition1"))]) |
2033 | assert purchase_ids, "RFQ is not created." |
2034 | @@ -68,9 +70,9 @@ |
2035 | for line in requisition.line_ids: |
2036 | if rfq_line.product_id.id == line.product_id.id: |
2037 | seller_price, qty, default_uom_po_id, date_planned = purchase_requisition._seller_details(cr, uid, line, supplier, context=context) |
2038 | - assert rfq_line.product_qty == qty, "Quantity is not correspond." |
2039 | + assert float_compare(rfq_line.product_qty, qty, precision_digits=2) == 0, "Quantity is not correspond." |
2040 | assert rfq_line.product_uom.id == default_uom_po_id, "UOM is not correspond." |
2041 | - assert rfq_line.price_unit == seller_price, "Unit Price is not correspond." |
2042 | + assert float_compare(rfq_line.price_unit, seller_price, precision_digits=2) == 0, "Unit Price is not correspond." |
2043 | - |
2044 | I confirmed RFQ which has best price. |
2045 | - |
2046 | |
2047 | === modified file 'resource/test/resource.yml' |
2048 | --- resource/test/resource.yml 2013-12-10 09:33:07 +0000 |
2049 | +++ resource/test/resource.yml 2014-03-05 10:51:17 +0000 |
2050 | @@ -12,13 +12,15 @@ |
2051 | First, I generate the resource detail and check the resource Efficiency assigned. |
2052 | - |
2053 | !python {model: resource.resource}: | |
2054 | + from openerp.tools import float_compare |
2055 | resources = self.generate_resources(cr, uid, [ref('base.user_root'),ref('base.user_demo')], ref('timesheet_group1'), context) |
2056 | for resource in resources.values(): |
2057 | - assert resource.get('efficiency', 0.0) == 1.0, 'Invalid resource generated.' |
2058 | + assert float_compare(resource.get('efficiency', 0.0), 1.0, precision_digits=2) == 0, 'Invalid resource generated.' |
2059 | - |
2060 | I check per day work hour availability of the Resource based on Working Calendar Assigned to each resource, for first day of the week. |
2061 | - |
2062 | !python {model: resource.resource}: | |
2063 | + from openerp.tools import float_compare |
2064 | calendar_pool = self.pool.get('resource.calendar') |
2065 | resources = self.browse(cr, uid, [ref('resource_analyst'), ref('resource_designer'), ref('resource_developer')], context) |
2066 | from datetime import datetime, timedelta |
2067 | @@ -26,7 +28,7 @@ |
2068 | dt = now - timedelta(days=now.weekday()) |
2069 | for resource in resources: |
2070 | result = calendar_pool.working_hours_on_day(cr, uid, resource.calendar_id, dt, context) |
2071 | - assert result == 9.0, 'Wrong calculation of day work hour availability of the Resource (found %d).' % result |
2072 | + assert float_compare(result, 9.0, precision_digits=2) == 0, 'Wrong calculation of day work hour availability of the Resource (found %d).' % result |
2073 | - |
2074 | Now, resource "Developer" drafted leave on Thursday in this week. |
2075 | - |
2076 | |
2077 | === modified file 'sale/test/edi_sale_order.yml' |
2078 | --- sale/test/edi_sale_order.yml 2013-10-31 18:56:33 +0000 |
2079 | +++ sale/test/edi_sale_order.yml 2014-03-05 10:51:17 +0000 |
2080 | @@ -35,6 +35,7 @@ |
2081 | "Then I import a sample EDI document of a purchase order (v7.0)" |
2082 | - |
2083 | !python {model: edi.edi}: | |
2084 | + from openerp.tools import float_compare |
2085 | sale_order_pool = self.pool.get('sale.order') |
2086 | edi_document = { |
2087 | "__id": "purchase:5af12v70-dv70-1v70-bv70-701a04e25v70.purchase_order_test", |
2088 | @@ -103,17 +104,17 @@ |
2089 | assert bank_info.acc_number == "Another bank: 032465700-156700", 'Expected "Another bank: 032465700-156700", got %s' % bank_info.acc_number |
2090 | |
2091 | assert order_new.pricelist_id.name == 'Public Pricelist' , "Public Price list was not automatically assigned" |
2092 | - assert order_new.amount_total == 350, "Amount total is wrong" |
2093 | - assert order_new.amount_untaxed == 350, "Untaxed amount is wrong" |
2094 | + assert float_compare(order_new.amount_total, 350, precision_digits=2) == 0, "Amount total is wrong" |
2095 | + assert float_compare(order_new.amount_untaxed, 350, precision_digits=2) == 0, "Untaxed amount is wrong" |
2096 | assert len(order_new.order_line) == 2, "Sale order lines mismatch" |
2097 | for sale_line in order_new.order_line: |
2098 | if sale_line.name == 'PC Assemble SC234': |
2099 | assert sale_line.product_uom.name == "Unit" , "uom is not same" |
2100 | - assert sale_line.price_unit == 150 , "unit price is not same, got %s, expected 150"%(sale_line.price_unit,) |
2101 | + assert float_compare(sale_line.price_unit, 150 , precision_digits=2) == 0, "unit price is not same, got %s, expected 150"%(sale_line.price_unit,) |
2102 | assert sale_line.product_uom_qty == 1 , "product qty is not same" |
2103 | elif sale_line.name == 'PC on Demand': |
2104 | assert sale_line.product_uom.name == "Unit" , "uom is not same" |
2105 | - assert sale_line.price_unit == 100 , "unit price is not same, got %s, expected 100"%(sale_line.price_unit,) |
2106 | + assert float_compare(sale_line.price_unit, 100, precision_digits=2) == 0, "unit price is not same, got %s, expected 100"%(sale_line.price_unit,) |
2107 | assert sale_line.product_uom_qty == 2 , "product qty is not same" |
2108 | else: |
2109 | raise AssertionError('unknown order line: %s' % sale_line) |
2110 | @@ -121,6 +122,7 @@ |
2111 | "Then I import a sample EDI document of a purchase order (v6.1 - to test backwards compatibility)" |
2112 | - |
2113 | !python {model: edi.edi}: | |
2114 | + from openerp.tools import float_compare |
2115 | sale_order_pool = self.pool.get('sale.order') |
2116 | edi_document = { |
2117 | "__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_test", |
2118 | @@ -199,17 +201,17 @@ |
2119 | assert bank_info.acc_number == "Ladies bank: 032465789-156113", 'Expected "Ladies bank: 032465789-156113", got %s' % bank_info.acc_number |
2120 | |
2121 | assert order_new.pricelist_id.name == 'Public Pricelist' , "Public Price list was not automatically assigned" |
2122 | - assert order_new.amount_total == 350, "Amount total is wrong" |
2123 | - assert order_new.amount_untaxed == 350, "Untaxed amount is wrong" |
2124 | + assert float_compare(order_new.amount_total, 350, precision_digits=2) == 0, "Amount total is wrong" |
2125 | + assert float_compare(order_new.amount_untaxed, 350, precision_digits=2) == 0, "Untaxed amount is wrong" |
2126 | assert len(order_new.order_line) == 2, "Sale order lines mismatch" |
2127 | for sale_line in order_new.order_line: |
2128 | if sale_line.name == 'Basic PC': |
2129 | assert sale_line.product_uom.name == "PCE" , "uom is not same" |
2130 | - assert sale_line.price_unit == 150 , "unit price is not same, got %s, expected 150"%(sale_line.price_unit,) |
2131 | + assert float_compare(sale_line.price_unit, 150, precision_digits=2) == 0, "unit price is not same, got %s, expected 150"%(sale_line.price_unit,) |
2132 | assert sale_line.product_uom_qty == 1 , "product qty is not same" |
2133 | elif sale_line.name == 'Medium PC': |
2134 | assert sale_line.product_uom.name == "PCE" , "uom is not same" |
2135 | - assert sale_line.price_unit == 100 , "unit price is not same, got %s, expected 100"%(sale_line.price_unit,) |
2136 | + assert float_compare(sale_line.price_unit, 100 , precision_digits=2) == 0, "unit price is not same, got %s, expected 100"%(sale_line.price_unit,) |
2137 | assert sale_line.product_uom_qty == 2 , "product qty is not same" |
2138 | else: |
2139 | raise AssertionError('unknown order line: %s' % sale_line) |
2140 | |
2141 | === modified file 'sale/test/sale_order_demo.yml' |
2142 | --- sale/test/sale_order_demo.yml 2013-11-21 12:23:11 +0000 |
2143 | +++ sale/test/sale_order_demo.yml 2014-03-05 10:51:17 +0000 |
2144 | @@ -16,11 +16,13 @@ |
2145 | - |
2146 | I verify that the onchange was correctly triggered |
2147 | - |
2148 | - !assert {model: sale.order, id: sale.sale_order_test1, string: The onchange function of product was not correctly triggered}: |
2149 | - - order_line[0].name == u'[A8767] Apple In-Ear Headphones' |
2150 | - - order_line[0].price_unit == 79.0 |
2151 | - - order_line[0].product_uom_qty == 8 |
2152 | - - order_line[0].product_uom.id == ref('product.product_uom_unit') |
2153 | + !python {model: sale.order}: | |
2154 | + from openerp.tools import float_compare |
2155 | + order_line = self.browse(cr, uid, ref('sale.sale_order_test1')).order_line |
2156 | + assert order_line[0].name == u'[A8767] Apple In-Ear Headphones', "The onchange function of product was not correctly triggered" |
2157 | + assert float_compare(order_line[0].price_unit, 79.0, precision_digits=2) == 0, "The onchange function of product was not correctly triggered" |
2158 | + assert order_line[0].product_uom_qty == 8, "The onchange function of product was not correctly triggered" |
2159 | + assert order_line[0].product_uom.id == ref('product.product_uom_unit'), "The onchange function of product was not correctly triggered" |
2160 | |
2161 | - |
2162 | I create another sale order |
2163 | @@ -34,8 +36,11 @@ |
2164 | - |
2165 | I verify that the onchange was correctly triggered |
2166 | - |
2167 | - !assert {model: sale.order, id: sale.sale_order_test2, string: The onchange function of product was not correctly triggered}: |
2168 | - - order_line[0].name == u'[A8767] Apple In-Ear Headphones' |
2169 | - - order_line[0].price_unit == 79.0 * 12 |
2170 | - - order_line[0].product_uom.id == ref('product.product_uom_dozen') |
2171 | - - order_line[0].product_uom_qty == 16 |
2172 | \ No newline at end of file |
2173 | + !python {model: sale.order}: | |
2174 | + from openerp.tools import float_compare |
2175 | + order_line = self.browse(cr, uid, ref('sale.sale_order_test2')).order_line |
2176 | + assert order_line[0].name == u'[A8767] Apple In-Ear Headphones', "The onchange function of product was not correctly triggered" |
2177 | + assert float_compare(order_line[0].price_unit, 79.0 * 12, precision_digits=2) == 0, "The onchange function of product was not correctly triggered" |
2178 | + assert order_line[0].product_uom.id == ref('product.product_uom_dozen'), "The onchange function of product was not correctly triggered" |
2179 | + assert order_line[0].product_uom_qty == 16, "The onchange function of product was not correctly triggered" |
2180 | + |
2181 | |
2182 | === modified file 'sale_stock/test/picking_order_policy.yml' |
2183 | --- sale_stock/test/picking_order_policy.yml 2014-02-12 22:12:54 +0000 |
2184 | +++ sale_stock/test/picking_order_policy.yml 2014-03-05 10:51:17 +0000 |
2185 | @@ -16,8 +16,10 @@ |
2186 | - |
2187 | First I check the total amount of the Quotation before Approved. |
2188 | - |
2189 | - !assert {model: sale.order, id: sale.sale_order_6, string: The amount of the Quotation is not correctly computed}: |
2190 | - - sum([l.price_subtotal for l in order_line]) == amount_untaxed |
2191 | + !python {model: sale.order}: | |
2192 | + from openerp.tools import float_compare |
2193 | + so = self.browse(cr, uid, ref('sale.sale_order_6')) |
2194 | + float_compare(sum([l.price_subtotal for l in so.order_line]), so.amount_untaxed, precision_digits=2) == 0, "The amount of the Quotation is not correctly computed" |
2195 | - |
2196 | I set an explicit invoicing partner that is different from the main SO Customer |
2197 | - |
2198 | @@ -74,7 +76,7 @@ |
2199 | !python {model: sale.order}: | |
2200 | from datetime import datetime, timedelta |
2201 | from dateutil.relativedelta import relativedelta |
2202 | - from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT |
2203 | + from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, float_compare |
2204 | sale_order = self.browse(cr, uid, ref("sale.sale_order_6")) |
2205 | assert sale_order.picking_ids, "Delivery order is not created." |
2206 | for picking in sale_order.picking_ids: |
2207 | @@ -103,7 +105,7 @@ |
2208 | assert move.partner_id.id == order_line.address_allotment_id.id or sale_order.partner_shipping_id.id,"Address is not correspond" |
2209 | #assert move.location_id.id == location_id,"Source Location is not correspond." |
2210 | #assert move.location_dest_id == output_id,"Destination Location is not correspond." |
2211 | - assert move.price_unit == order_line.product_id.standard_price or 0.0,"Price Unit is not correspond" |
2212 | + assert float_compare(move.price_unit, order_line.product_id.standard_price or 0.0, precision_digits=2) == 0, "Price Unit is not correspond" |
2213 | - |
2214 | Now, I dispatch delivery order. |
2215 | - |
2216 | @@ -137,6 +139,7 @@ |
2217 | I check the invoice details after dispatched delivery. |
2218 | - |
2219 | !python {model: sale.order}: | |
2220 | + from openerp.tools import float_compare |
2221 | order = self.browse(cr, uid, ref("sale.sale_order_6")) |
2222 | assert order.invoice_ids, "Invoice is not created." |
2223 | ac = order.partner_invoice_id.property_account_receivable.id |
2224 | @@ -156,7 +159,7 @@ |
2225 | assert inv_line.product_id.id == so_line.product_id.id or False,"Product is not correspond" |
2226 | assert inv_line.account_id.id == ac,"Account of Invoice line is not corresponding." |
2227 | assert inv_line.uos_id.id == (so_line.product_uos and so_line.product_uos.id) or so_line.product_uom.id, "Product UOS is not correspond." |
2228 | - assert inv_line.price_unit == so_line.price_unit , "Price Unit is not correspond." |
2229 | + assert float_compare(inv_line.price_unit, so_line.price_unit , precision_digits=2) == 0, "Price Unit is not correspond." |
2230 | assert inv_line.quantity == (so_line.product_uos and so_line.product_uos_qty) or so_line.product_uom_qty , "Product qty is not correspond." |
2231 | assert inv_line.price_subtotal == so_line.price_subtotal, "Price sub total is not correspond." |
2232 | - |
2233 | |
2234 | === modified file 'sale_stock/test/sale_order_onchange.yml' |
2235 | --- sale_stock/test/sale_order_onchange.yml 2013-10-27 12:31:04 +0000 |
2236 | +++ sale_stock/test/sale_order_onchange.yml 2014-03-05 10:51:17 +0000 |
2237 | @@ -26,7 +26,9 @@ |
2238 | - |
2239 | I verify that the onchange of product on sale order line was correctly triggered |
2240 | - |
2241 | - !assert {model: sale.order, id: sale_order_onchange1, string: The onchange function of product was not correctly triggered}: |
2242 | - - order_line[0].name == u'Devil Worship Book' |
2243 | - - order_line[0].price_unit == 66.6 |
2244 | - - order_line[0].type == 'make_to_order' |
2245 | + !python {model: sale.order}: | |
2246 | + from openerp.tools import float_compare |
2247 | + order_line = self.browse(cr, uid, ref('sale_order_onchange1')).order_line |
2248 | + assert order_line[0].name == u'Devil Worship Book', "The onchange function of product was not correctly triggered" |
2249 | + assert float_compare(order_line[0].price_unit, 66.6, precision_digits=2) == 0, "The onchange function of product was not correctly triggered" |
2250 | + assert order_line[0].type == 'make_to_order', "The onchange function of product was not correctly triggered" |
2251 | |
2252 | === modified file 'stock/test/opening_stock.yml' |
2253 | --- stock/test/opening_stock.yml 2013-10-27 12:31:04 +0000 |
2254 | +++ stock/test/opening_stock.yml 2014-03-05 10:51:17 +0000 |
2255 | @@ -18,8 +18,9 @@ |
2256 | I check price of 15” LCD Monitor after update price. |
2257 | - |
2258 | !python {model: product.product}: | |
2259 | + from openerp.tools import float_compare |
2260 | product = self.browse(cr, uid, ref('product_product_6'), context=context) |
2261 | - assert product.standard_price == 1500, "Price is not updated." |
2262 | + assert float_compare(product.standard_price, 1500, precision_digits=2) == 0, "Price is not updated." |
2263 | - |
2264 | I update the current stock of the 15” LCD Monitor with 10 unit in stock location shop1 in lot0. |
2265 | - |
2266 | |
2267 | === modified file 'stock/test/shipment.yml' |
2268 | --- stock/test/shipment.yml 2013-12-09 11:15:50 +0000 |
2269 | +++ stock/test/shipment.yml 2014-03-05 10:51:17 +0000 |
2270 | @@ -168,6 +168,7 @@ |
2271 | I check the stock valuation account entries. |
2272 | - |
2273 | !python {model: account.move}: | |
2274 | + from openerp.tools import float_compare |
2275 | incomming_shipment = self.pool.get('stock.picking').browse(cr, uid, ref('incomming_shipment'), context=context) |
2276 | account_move_ids = self.search(cr, uid, [('ref','=',incomming_shipment.name)]) |
2277 | assert len(account_move_ids), "account move should be created." |
2278 | @@ -176,11 +177,11 @@ |
2279 | for account_move_line in account_move.line_id: |
2280 | for stock_move in incomming_shipment.move_lines: |
2281 | if account_move_line.account_id.id == stock_move.product_id.property_stock_account_input.id: |
2282 | - assert account_move_line.credit == 14000.0, "Credit amount does not correspond." |
2283 | - assert account_move_line.debit == 0.0, "Debit amount does not correspond." |
2284 | + assert float_compare(account_move_line.credit, 14000.0, precision_digits=2) == 0, "Credit amount does not correspond." |
2285 | + assert float_compare(account_move_line.debit, 0.0, precision_digits=2) == 0, "Debit amount does not correspond." |
2286 | else: |
2287 | - assert account_move_line.credit == 0.0, "Credit amount does not correspond." |
2288 | - assert account_move_line.debit == 14000.0, "Debit amount does not correspond." |
2289 | + assert float_compare(account_move_line.credit, 0.0, precision_digits=2) == 0, "Credit amount does not correspond." |
2290 | + assert float_compare(account_move_line.debit, 14000.0, precision_digits=2) == 0, "Debit amount does not correspond." |
2291 | - |
2292 | I trace all incoming lots. |
2293 | - |
2294 | @@ -229,9 +230,10 @@ |
2295 | I check available stock after consumed and scraped move. |
2296 | - |
2297 | !python {model: product.product}: | |
2298 | + from openerp.tools import float_compare |
2299 | product = self.browse(cr, uid, ref('product_product_6'), context=context) |
2300 | assert product.qty_available == 132.0, "Stock does not correspond." |
2301 | - assert round(product.virtual_available, 2) == -4.00, "Virtual stock does not correspond." |
2302 | + assert float_compare(product.virtual_available, -4.00, precision_digits=2) == 0, "Virtual stock does not correspond." |
2303 | - |
2304 | I deliver 5 Unit 15” LCD Monitor to customer partially. |
2305 | - |
2306 | @@ -287,6 +289,7 @@ |
2307 | I check available stock after delivery. |
2308 | - |
2309 | !python {model: product.product}: | |
2310 | + from openerp.tools import float_compare |
2311 | product = self.browse(cr, uid, ref('product_product_6'), context=context) |
2312 | - assert round(product.qty_available, 2) == 6, "Stock does not correspond." |
2313 | - assert round(product.virtual_available, 2) == -4.00, "Virtual stock does not correspond." |
2314 | + assert float_compare(product.qty_available, 6, precision_digits=2) == 0, "Stock does not correspond." |
2315 | + assert float_compare(product.virtual_available, -4.00, precision_digits=2) == 0, "Virtual stock does not correspond." |