Merge lp:~elbati/openobject-addons/add-yaml-tests-for-tax-computation into lp:openobject-addons

Proposed by Lorenzo Battistini
Status: Needs review
Proposed branch: lp:~elbati/openobject-addons/add-yaml-tests-for-tax-computation
Merge into: lp:openobject-addons
Diff against target: 844 lines (+785/-0)
7 files modified
account/__openerp__.py (+2/-0)
account/demo/account_tax.xml (+68/-0)
account/test/tax_computation.yml (+543/-0)
purchase/__openerp__.py (+1/-0)
purchase/test/tax_computation.yml (+86/-0)
sale/__openerp__.py (+1/-0)
sale/test/tax_computation.yml (+84/-0)
To merge this branch: bzr merge lp:~elbati/openobject-addons/add-yaml-tests-for-tax-computation
Reviewer Review Type Date Requested Status
Nhomar - Vauxoo (community) Approve
OpenERP Core Team Pending
Review via email: mp+114679@code.launchpad.net

Description of the change

Following the work of Alexis de Lattre and OpenERP guys on tax computation roundings ( lp:~akretion-team/openobject-addons/trunk-add-tax-rounding-option ) I propose to add some YAML tests that confirm the validity of the solution

To post a comment you must log in.
Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Excelent friend.

I test your scenaries, with openerp-venezuela-localization involved and they work great!!

review: Approve

Unmerged revisions

7023. By Lorenzo Battistini

[ADD] tests for sale and purchase orders

7022. By Lorenzo Battistini

[ADD] YAML tests for different tax computation methods

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/__openerp__.py'
2--- account/__openerp__.py 2012-05-18 05:26:05 +0000
3+++ account/__openerp__.py 2012-07-12 16:30:21 +0000
4@@ -134,6 +134,7 @@
5 'project/analytic_account_demo.xml',
6 'demo/account_minimal.xml',
7 'demo/account_invoice_demo.xml',
8+ 'demo/account_tax.xml',
9 # 'account_unit_test.xml',
10 ],
11 'test': [
12@@ -150,6 +151,7 @@
13 'test/test_edi_invoice.yml',
14 'test/account_report.yml',
15 'test/account_fiscalyear_close_state.yml', #last test, as it will definitively close the demo fiscalyear
16+ 'test/tax_computation.yml',
17 ],
18 'installable': True,
19 'auto_install': False,
20
21=== added file 'account/demo/account_tax.xml'
22--- account/demo/account_tax.xml 1970-01-01 00:00:00 +0000
23+++ account/demo/account_tax.xml 2012-07-12 16:30:21 +0000
24@@ -0,0 +1,68 @@
25+<?xml version="1.0" encoding="utf-8"?>
26+<openerp>
27+ <data noupdate="1">
28+
29+ <!-- Tax codes -->
30+
31+ <record id="account_tax_code_10" model="account.tax.code">
32+ <field name="name">10 %</field>
33+ </record>
34+ <record id="account_tax_code_10_imp" model="account.tax.code">
35+ <field name="name">10 % IMP</field>
36+ </record>
37+
38+ <record id="account_tax_code_21" model="account.tax.code">
39+ <field name="name">21 %</field>
40+ </record>
41+ <record id="account_tax_code_21_imp" model="account.tax.code">
42+ <field name="name">21 % IMP</field>
43+ </record>
44+
45+ <record id="account_tax_code_21_inc" model="account.tax.code">
46+ <field name="name">21 % INC</field>
47+ </record>
48+ <record id="account_tax_code_21_inc_imp" model="account.tax.code">
49+ <field name="name">21 % INC IMP</field>
50+ </record>
51+
52+ <record id="account_tax_code_20_inc" model="account.tax.code">
53+ <field name="name">20 % INC</field>
54+ </record>
55+ <record id="account_tax_code_20_inc_imp" model="account.tax.code">
56+ <field name="name">20 % INC IMP</field>
57+ </record>
58+
59+ <!-- taxes -->
60+
61+ <record id="account_tax_10" model="account.tax">
62+ <field name="name">10 %</field>
63+ <field name="amount">0.1</field>
64+ <field name="tax_code_id" ref="account_tax_code_10"></field>
65+ <field name="base_code_id" ref="account_tax_code_10_imp"></field>
66+ </record>
67+
68+ <record id="account_tax_21" model="account.tax">
69+ <field name="name">21 %</field>
70+ <field name="amount">0.21</field>
71+ <field name="tax_code_id" ref="account_tax_code_21"></field>
72+ <field name="base_code_id" ref="account_tax_code_21_imp"></field>
73+ </record>
74+
75+ <record id="account_tax_21_inc" model="account.tax">
76+ <field name="name">21 % INC</field>
77+ <field name="amount">0.21</field>
78+ <field name="price_include">1</field>
79+ <field name="tax_code_id" ref="account_tax_code_21_inc"></field>
80+ <field name="base_code_id" ref="account_tax_code_21_inc_imp"></field>
81+ </record>
82+
83+ <record id="account_tax_20_inc" model="account.tax">
84+ <field name="name">20 % INC</field>
85+ <field name="amount">0.2</field>
86+ <field name="price_include">1</field>
87+ <field name="tax_code_id" ref="account_tax_code_20_inc"></field>
88+ <field name="base_code_id" ref="account_tax_code_20_inc_imp"></field>
89+ </record>
90+
91+ </data>
92+</openerp>
93
94=== added file 'account/test/tax_computation.yml'
95--- account/test/tax_computation.yml 1970-01-01 00:00:00 +0000
96+++ account/test/tax_computation.yml 2012-07-12 16:30:21 +0000
97@@ -0,0 +1,543 @@
98+
99+#-
100+ #First invoice. 2 lines
101+ #price_unit = 23.83, tax = 0.21
102+ #price_unit = 7.44, tax = 0.21
103+#-
104+-
105+ Set the company to 'Round per line'.
106+-
107+
108+ !record {model: res.company, id: base.main_company}:
109+ tax_calculation_rounding_method: 'round_per_line'
110+
111+-
112+ Computation by line
113+-
114+
115+ !record {model: account.invoice, id: invoice_1_computation_by_line}:
116+ account_id: a_recv
117+ company_id: base.main_company
118+ currency_id: base.EUR
119+ date_invoice: !eval time.strftime('%Y-%m-%d')
120+ invoice_line:
121+ - account_id: a_sale
122+ name: '23.83'
123+ price_unit: 23.83
124+ quantity: 1.0
125+ invoice_line_tax_id:
126+ - account_tax_21
127+ - account_id: a_sale
128+ name: '7.44'
129+ price_unit: 7.44
130+ quantity: 1.0
131+ invoice_line_tax_id:
132+ - account_tax_21
133+ journal_id: sales_journal
134+ partner_id: base.res_partner_3
135+
136+-
137+ Compute the total tax.
138+-
139+ !python {model: account.invoice}: |
140+ self.button_compute(cr, uid, [ref("invoice_1_computation_by_line")])
141+-
142+ Then I verify the amount (computation by line).
143+ 23.83 × 0.21 = 5.0043 = 5
144+ 7.44 × 0.21 = 1.5624 = 1.56
145+ 5 + 1.56 = 6.56
146+-
147+ !assert {model: account.invoice, id: invoice_1_computation_by_line}:
148+ - amount_tax == 6.56
149+
150+-
151+ Set the company to 'Round globally'.
152+-
153+
154+ !record {model: res.company, id: base.main_company}:
155+ tax_calculation_rounding_method: 'round_globally'
156+
157+-
158+ Computation by column
159+-
160+ !record {model: account.invoice, id: invoice_1_computation_by_column}:
161+ account_id: a_recv
162+ company_id: base.main_company
163+ currency_id: base.EUR
164+ date_invoice: !eval time.strftime('%Y-%m-%d')
165+ invoice_line:
166+ - account_id: a_sale
167+ name: '23.83'
168+ price_unit: 23.83
169+ quantity: 1.0
170+ invoice_line_tax_id:
171+ - account_tax_21
172+ - account_id: a_sale
173+ name: '7.44'
174+ price_unit: 7.44
175+ quantity: 1.0
176+ invoice_line_tax_id:
177+ - account_tax_21
178+ journal_id: sales_journal
179+ partner_id: base.res_partner_3
180+
181+-
182+ Compute the total tax.
183+-
184+ !python {model: account.invoice}: |
185+ self.button_compute(cr, uid, [ref("invoice_1_computation_by_column")])
186+-
187+ Then I verify the amount (computation by column).
188+ 23.83 + 7.44 = 31.27
189+ 31.27 × 0.21 = 6.5667 = 6.57
190+-
191+ !assert {model: account.invoice, id: invoice_1_computation_by_column}:
192+ - amount_tax == 6.57
193+
194+
195+#-
196+ #Second invoice. 2 lines
197+ #price_unit = 24.92, tax = 0.21
198+ #price_unit = 7.44, tax = 0.21
199+#-
200+-
201+ Set the company to 'Round per line'.
202+-
203+
204+ !record {model: res.company, id: base.main_company}:
205+ tax_calculation_rounding_method: 'round_per_line'
206+
207+-
208+ Computation by line
209+-
210+ !record {model: account.invoice, id: invoice_2_computation_by_line}:
211+ account_id: a_recv
212+ company_id: base.main_company
213+ currency_id: base.EUR
214+ date_invoice: !eval time.strftime('%Y-%m-%d')
215+ invoice_line:
216+ - account_id: a_sale
217+ name: '24.92'
218+ price_unit: 24.92
219+ quantity: 1.0
220+ invoice_line_tax_id:
221+ - account_tax_21
222+ - account_id: a_sale
223+ name: '7.44'
224+ price_unit: 7.44
225+ quantity: 1.0
226+ invoice_line_tax_id:
227+ - account_tax_21
228+ journal_id: sales_journal
229+ partner_id: base.res_partner_3
230+
231+-
232+ Compute the total tax.
233+-
234+ !python {model: account.invoice}: |
235+ self.button_compute(cr, uid, [ref("invoice_2_computation_by_line")])
236+-
237+ Then I verify the amount (computation by line).
238+ 24.92 × 0.21 = 5.2332 = 5.23
239+ 7.44 × 0.21 = 1.5624 = 1.56
240+ 5.23 + 1.56 = 6.79
241+-
242+ !assert {model: account.invoice, id: invoice_2_computation_by_line}:
243+ - amount_tax == 6.79
244+
245+-
246+ Set the company to 'Round globally'.
247+-
248+
249+ !record {model: res.company, id: base.main_company}:
250+ tax_calculation_rounding_method: 'round_globally'
251+
252+-
253+ Computation by column
254+-
255+ !record {model: account.invoice, id: invoice_2_computation_by_column}:
256+ account_id: a_recv
257+ company_id: base.main_company
258+ currency_id: base.EUR
259+ date_invoice: !eval time.strftime('%Y-%m-%d')
260+ invoice_line:
261+ - account_id: a_sale
262+ name: '24.92'
263+ price_unit: 24.92
264+ quantity: 1.0
265+ invoice_line_tax_id:
266+ - account_tax_21
267+ - account_id: a_sale
268+ name: '7.44'
269+ price_unit: 7.44
270+ quantity: 1.0
271+ invoice_line_tax_id:
272+ - account_tax_21
273+ journal_id: sales_journal
274+ partner_id: base.res_partner_3
275+
276+-
277+ Compute the total tax.
278+-
279+ !python {model: account.invoice}: |
280+ self.button_compute(cr, uid, [ref("invoice_2_computation_by_column")])
281+-
282+ Then I verify the amount (computation by column).
283+ 24.92 + 7.44 = 32.36
284+ 32.36 × 0.21 = 6.7956 = 6.8
285+-
286+ !assert {model: account.invoice, id: invoice_2_computation_by_column}:
287+ - amount_tax == 6.8
288+
289+
290+#-
291+ #Third invoice. 6 lines
292+ #price_unit = 1.99, tax = 0.1
293+ #price_unit = 0.38, tax = 0.1
294+ #price_unit = 5.68, tax = 0.1
295+ #price_unit = 0.45, tax = 0.1
296+ #price_unit = 1.05, tax = 0.1
297+ #price_unit = 2.87, tax = 0.1
298+#-
299+-
300+ Set the company to 'Round per line'.
301+-
302+
303+ !record {model: res.company, id: base.main_company}:
304+ tax_calculation_rounding_method: 'round_per_line'
305+
306+-
307+ Computation by line
308+-
309+ !record {model: account.invoice, id: invoice_3_computation_by_line}:
310+ account_id: a_recv
311+ company_id: base.main_company
312+ currency_id: base.EUR
313+ date_invoice: !eval time.strftime('%Y-%m-%d')
314+ invoice_line:
315+ - account_id: a_sale
316+ name: '1.99'
317+ price_unit: 1.99
318+ quantity: 1.0
319+ invoice_line_tax_id:
320+ - account_tax_10
321+ - account_id: a_sale
322+ name: '0.38'
323+ price_unit: 0.38
324+ quantity: 1.0
325+ invoice_line_tax_id:
326+ - account_tax_10
327+ - account_id: a_sale
328+ name: '5.68'
329+ price_unit: 5.68
330+ quantity: 1.0
331+ invoice_line_tax_id:
332+ - account_tax_10
333+ - account_id: a_sale
334+ name: '0.45'
335+ price_unit: 0.45
336+ quantity: 1.0
337+ invoice_line_tax_id:
338+ - account_tax_10
339+ - account_id: a_sale
340+ name: '1.05'
341+ price_unit: 1.05
342+ quantity: 1.0
343+ invoice_line_tax_id:
344+ - account_tax_10
345+ - account_id: a_sale
346+ name: '2.87'
347+ price_unit: 2.87
348+ quantity: 1.0
349+ invoice_line_tax_id:
350+ - account_tax_10
351+ journal_id: sales_journal
352+ partner_id: base.res_partner_3
353+
354+-
355+ Compute the total tax.
356+-
357+ !python {model: account.invoice}: |
358+ self.button_compute(cr, uid, [ref("invoice_3_computation_by_line")])
359+-
360+ Then I verify the amount (computation by line).
361+ 1.99 × 0.1 = 0.199 = 0.2
362+ 0.38 × 0.1 = 0.038 = 0.04
363+ 5.68 × 0.1 = 0.568 = 0.57
364+ 0.45 × 0.1 = 0.045 = 0.05
365+ 1.05 × 0.1 = 0.105 = 0.11
366+ 2.87 × 0.1 = 0.287 = 0.29
367+ 0.2 + 0.04 + 0.57 + 0.05 + 0.11 + 0.29 = 1.26
368+-
369+ !assert {model: account.invoice, id: invoice_3_computation_by_line}:
370+ - amount_tax == 1.26
371+
372+-
373+ Set the company to 'Round globally'.
374+-
375+
376+ !record {model: res.company, id: base.main_company}:
377+ tax_calculation_rounding_method: 'round_globally'
378+
379+-
380+ Computation by column
381+-
382+ !record {model: account.invoice, id: invoice_3_computation_by_column}:
383+ account_id: a_recv
384+ company_id: base.main_company
385+ currency_id: base.EUR
386+ date_invoice: !eval time.strftime('%Y-%m-%d')
387+ invoice_line:
388+ - account_id: a_sale
389+ name: '1.99'
390+ price_unit: 1.99
391+ quantity: 1.0
392+ invoice_line_tax_id:
393+ - account_tax_10
394+ - account_id: a_sale
395+ name: '0.38'
396+ price_unit: 0.38
397+ quantity: 1.0
398+ invoice_line_tax_id:
399+ - account_tax_10
400+ - account_id: a_sale
401+ name: '5.68'
402+ price_unit: 5.68
403+ quantity: 1.0
404+ invoice_line_tax_id:
405+ - account_tax_10
406+ - account_id: a_sale
407+ name: '0.45'
408+ price_unit: 0.45
409+ quantity: 1.0
410+ invoice_line_tax_id:
411+ - account_tax_10
412+ - account_id: a_sale
413+ name: '1.05'
414+ price_unit: 1.05
415+ quantity: 1.0
416+ invoice_line_tax_id:
417+ - account_tax_10
418+ - account_id: a_sale
419+ name: '2.87'
420+ price_unit: 2.87
421+ quantity: 1.0
422+ invoice_line_tax_id:
423+ - account_tax_10
424+ journal_id: sales_journal
425+ partner_id: base.res_partner_3
426+
427+-
428+ Compute the total tax.
429+-
430+ !python {model: account.invoice}: |
431+ self.button_compute(cr, uid, [ref("invoice_3_computation_by_column")])
432+-
433+ Then I verify the amount (computation by column).
434+ 1.99 + 0.38 + 5.68 + 0.45 + 1.05 + 2.87 = 12.42
435+ 12.42 * 0.1 = 1.242 = 1.24
436+-
437+ !assert {model: account.invoice, id: invoice_3_computation_by_column}:
438+ - amount_tax == 1.24
439+
440+
441+#-
442+ #Fourth invoice. 2 lines
443+ #price_unit = 465, tax = 0.21 included in price
444+ #price_unit = 9, tax = 0.21 included in price
445+#-
446+-
447+ Set the company to 'Round per line'.
448+-
449+
450+ !record {model: res.company, id: base.main_company}:
451+ tax_calculation_rounding_method: 'round_per_line'
452+
453+-
454+ Computation by line
455+-
456+ !record {model: account.invoice, id: invoice_4_computation_by_line}:
457+ account_id: a_recv
458+ company_id: base.main_company
459+ currency_id: base.EUR
460+ date_invoice: !eval time.strftime('%Y-%m-%d')
461+ invoice_line:
462+ - account_id: a_sale
463+ name: '465'
464+ price_unit: 465
465+ quantity: 1.0
466+ invoice_line_tax_id:
467+ - account_tax_21_inc
468+ - account_id: a_sale
469+ name: '9'
470+ price_unit: 9
471+ quantity: 1.0
472+ invoice_line_tax_id:
473+ - account_tax_21_inc
474+ journal_id: sales_journal
475+ partner_id: base.res_partner_3
476+
477+-
478+ Compute the total tax.
479+-
480+ !python {model: account.invoice}: |
481+ self.button_compute(cr, uid, [ref("invoice_4_computation_by_line")])
482+-
483+ Then I verify the amount (computation by line).
484+ 465 ÷ 1.21 = 384.297520661 = 384.3
485+ 9 ÷ 1.21 = 7.438016529 = 7.44
486+ 465 + 9 = 474
487+ 384.3 + 7.44 = 391.74
488+ 474 − 391.74 = 82.26
489+-
490+ !assert {model: account.invoice, id: invoice_4_computation_by_line}:
491+ - amount_tax == 82.26
492+
493+-
494+ Set the company to 'Round globally'.
495+-
496+
497+ !record {model: res.company, id: base.main_company}:
498+ tax_calculation_rounding_method: 'round_globally'
499+
500+-
501+ Computation by column
502+-
503+ !record {model: account.invoice, id: invoice_4_computation_by_column}:
504+ account_id: a_recv
505+ company_id: base.main_company
506+ currency_id: base.EUR
507+ date_invoice: !eval time.strftime('%Y-%m-%d')
508+ invoice_line:
509+ - account_id: a_sale
510+ name: '465'
511+ price_unit: 465
512+ quantity: 1.0
513+ invoice_line_tax_id:
514+ - account_tax_21_inc
515+ - account_id: a_sale
516+ name: '9'
517+ price_unit: 9
518+ quantity: 1.0
519+ invoice_line_tax_id:
520+ - account_tax_21_inc
521+ journal_id: sales_journal
522+ partner_id: base.res_partner_3
523+
524+-
525+ Compute the total tax.
526+-
527+ !python {model: account.invoice}: |
528+ self.button_compute(cr, uid, [ref("invoice_4_computation_by_column")])
529+-
530+ Then I verify the amount (computation by column).
531+ 465 + 9 = 474
532+ 474 ÷ 1.21 = 391.73553719 = 391.74
533+ 474 − 391.74 = 82.26
534+-
535+ !assert {model: account.invoice, id: invoice_4_computation_by_column}:
536+ - amount_tax == 82.26
537+
538+
539+#-
540+ #Fifth invoice. 2 lines
541+ #price_unit = 148.28, tax = 0.2 included in price
542+ #price_unit = 148.28, tax = 0.2 included in price
543+#-
544+-
545+ Set the company to 'Round per line'.
546+-
547+
548+ !record {model: res.company, id: base.main_company}:
549+ tax_calculation_rounding_method: 'round_per_line'
550+
551+-
552+ Computation by line
553+-
554+ !record {model: account.invoice, id: invoice_5_computation_by_line}:
555+ account_id: a_recv
556+ company_id: base.main_company
557+ currency_id: base.EUR
558+ date_invoice: !eval time.strftime('%Y-%m-%d')
559+ invoice_line:
560+ - account_id: a_sale
561+ name: '148.28'
562+ price_unit: 148.28
563+ quantity: 1.0
564+ invoice_line_tax_id:
565+ - account_tax_20_inc
566+ - account_id: a_sale
567+ name: '148.28'
568+ price_unit: 148.28
569+ quantity: 1.0
570+ invoice_line_tax_id:
571+ - account_tax_20_inc
572+ journal_id: sales_journal
573+ partner_id: base.res_partner_3
574+
575+-
576+ Compute the total tax.
577+-
578+ !python {model: account.invoice}: |
579+ self.button_compute(cr, uid, [ref("invoice_5_computation_by_line")])
580+-
581+ Then I verify the amount (computation by line).
582+ 148.28 + 148.28 = 296.56
583+ 148.28 ÷ 1.2 = 123.566666667 = 123.57
584+ 123.57 × 2 = 247.14
585+ 296.56 - 247.14 = 49.42
586+-
587+ !assert {model: account.invoice, id: invoice_5_computation_by_line}:
588+ - amount_tax == 49.42
589+
590+-
591+ Set the company to 'Round globally'.
592+-
593+
594+ !record {model: res.company, id: base.main_company}:
595+ tax_calculation_rounding_method: 'round_globally'
596+
597+-
598+ Computation by column
599+-
600+ !record {model: account.invoice, id: invoice_5_computation_by_column}:
601+ account_id: a_recv
602+ company_id: base.main_company
603+ currency_id: base.EUR
604+ date_invoice: !eval time.strftime('%Y-%m-%d')
605+ invoice_line:
606+ - account_id: a_sale
607+ name: '148.28'
608+ price_unit: 148.28
609+ quantity: 1.0
610+ invoice_line_tax_id:
611+ - account_tax_20_inc
612+ - account_id: a_sale
613+ name: '148.28'
614+ price_unit: 148.28
615+ quantity: 1.0
616+ invoice_line_tax_id:
617+ - account_tax_20_inc
618+ journal_id: sales_journal
619+ partner_id: base.res_partner_3
620+
621+-
622+ Compute the total tax.
623+-
624+ !python {model: account.invoice}: |
625+ self.button_compute(cr, uid, [ref("invoice_5_computation_by_column")])
626+-
627+ Then I verify the amount (computation by column).
628+ 148.28 + 148.28 = 296.56
629+ 296.56 ÷ 1.2 = 247.133333333 = 247.13
630+ 296.56 - 247.13 = 49.43
631+-
632+ !assert {model: account.invoice, id: invoice_5_computation_by_column}:
633+ - amount_tax == 49.43
634+
635+-
636+ Set the company to 'Round per line'.
637+-
638+
639+ !record {model: res.company, id: base.main_company}:
640+ tax_calculation_rounding_method: 'round_per_line'
641
642=== modified file 'purchase/__openerp__.py'
643--- purchase/__openerp__.py 2012-05-18 05:26:05 +0000
644+++ purchase/__openerp__.py 2012-07-12 16:30:21 +0000
645@@ -71,6 +71,7 @@
646 'test/ui/print_report.yml',
647 'test/ui/duplicate_order.yml',
648 'test/ui/delete_order.yml',
649+ 'test/tax_computation.yml',
650 ],
651 'demo': [
652 'purchase_order_demo.yml',
653
654=== added file 'purchase/test/tax_computation.yml'
655--- purchase/test/tax_computation.yml 1970-01-01 00:00:00 +0000
656+++ purchase/test/tax_computation.yml 2012-07-12 16:30:21 +0000
657@@ -0,0 +1,86 @@
658+#-
659+ #First order. 2 lines
660+ #price_unit = 23.83, tax = 0.21
661+ #price_unit = 7.44, tax = 0.21
662+#-
663+-
664+ Set the company to 'Round per line'.
665+-
666+
667+ !record {model: res.company, id: base.main_company}:
668+ tax_calculation_rounding_method: 'round_per_line'
669+
670+-
671+ Computation by line
672+-
673+ !record {model: purchase.order, id: order_1_computation_by_line}:
674+ partner_id: base.res_partner_agrolait
675+ location_id: stock.stock_location_3
676+ pricelist_id: 1
677+ order_line:
678+ - product_qty: 1.0
679+ product_uom: 1
680+ price_unit: 23.83
681+ name: '23.83'
682+ taxes_id:
683+ - account.account_tax_21
684+ date_planned: '2012-05-06'
685+ - product_qty: 1.0
686+ product_uom: 1
687+ price_unit: 7.44
688+ name: '7.44'
689+ taxes_id:
690+ - account.account_tax_21
691+ date_planned: '2012-05-06'
692+-
693+ Then I verify the amount (computation by line).
694+ 23.83 × 0.21 = 5.0043 = 5
695+ 7.44 × 0.21 = 1.5624 = 1.56
696+ 5 + 1.56 = 6.56
697+-
698+ !assert {model: purchase.order, id: order_1_computation_by_line}:
699+ - amount_tax == 6.56
700+
701+-
702+ Set the company to 'Round globally'.
703+-
704+
705+ !record {model: res.company, id: base.main_company}:
706+ tax_calculation_rounding_method: 'round_globally'
707+
708+-
709+ Computation by column
710+-
711+ !record {model: purchase.order, id: order_1_computation_by_column}:
712+ partner_id: base.res_partner_agrolait
713+ location_id: stock.stock_location_3
714+ pricelist_id: 1
715+ order_line:
716+ - product_qty: 1.0
717+ product_uom: 1
718+ price_unit: 23.83
719+ name: '23.83'
720+ taxes_id:
721+ - account.account_tax_21
722+ date_planned: '2012-05-06'
723+ - product_qty: 1.0
724+ product_uom: 1
725+ price_unit: 7.44
726+ name: '7.44'
727+ taxes_id:
728+ - account.account_tax_21
729+ date_planned: '2012-05-06'
730+-
731+ Then I verify the amount (computation by column).
732+ 23.83 + 7.44 = 31.27
733+ 31.27 × 0.21 = 6.5667 = 6.57
734+-
735+ !assert {model: purchase.order, id: order_1_computation_by_column}:
736+ - amount_tax == 6.57
737+
738+-
739+ Set the company to 'Round per line'.
740+-
741+
742+ !record {model: res.company, id: base.main_company}:
743+ tax_calculation_rounding_method: 'round_per_line'
744
745=== modified file 'sale/__openerp__.py'
746--- sale/__openerp__.py 2012-05-29 06:49:42 +0000
747+++ sale/__openerp__.py 2012-07-12 16:30:21 +0000
748@@ -96,6 +96,7 @@
749 'test/cancel_order.yml',
750 'test/delete_order.yml',
751 'test/edi_sale_order.yml',
752+ 'test/tax_computation.yml',
753 ],
754 'installable': True,
755 'auto_install': False,
756
757=== added file 'sale/test/tax_computation.yml'
758--- sale/test/tax_computation.yml 1970-01-01 00:00:00 +0000
759+++ sale/test/tax_computation.yml 2012-07-12 16:30:21 +0000
760@@ -0,0 +1,84 @@
761+#-
762+ #First order. 2 lines
763+ #price_unit = 23.83, tax = 0.21
764+ #price_unit = 7.44, tax = 0.21
765+#-
766+-
767+ Set the company to 'Round per line'.
768+-
769+
770+ !record {model: res.company, id: base.main_company}:
771+ tax_calculation_rounding_method: 'round_per_line'
772+
773+-
774+ Computation by line
775+-
776+ !record {model: sale.order, id: order_1_computation_by_line}:
777+ partner_id: base.res_partner_agrolait
778+ partner_invoice_id: base.res_partner_address_8invoice
779+ partner_shipping_id: base.res_partner_address_8invoice
780+ pricelist_id: 1
781+ order_line:
782+ - product_uom_qty: 1.0
783+ product_uom: 1
784+ price_unit: 23.83
785+ name: '23.83'
786+ tax_id:
787+ - account.account_tax_21
788+ - product_uom_qty: 1.0
789+ product_uom: 1
790+ price_unit: 7.44
791+ name: '7.44'
792+ tax_id:
793+ - account.account_tax_21
794+-
795+ Then I verify the amount (computation by line).
796+ 23.83 × 0.21 = 5.0043 = 5
797+ 7.44 × 0.21 = 1.5624 = 1.56
798+ 5 + 1.56 = 6.56
799+-
800+ !assert {model: sale.order, id: order_1_computation_by_line}:
801+ - amount_tax == 6.56
802+
803+-
804+ Set the company to 'Round globally'.
805+-
806+
807+ !record {model: res.company, id: base.main_company}:
808+ tax_calculation_rounding_method: 'round_globally'
809+
810+-
811+ Computation by column
812+-
813+ !record {model: sale.order, id: order_1_computation_by_column}:
814+ partner_id: base.res_partner_agrolait
815+ partner_invoice_id: base.res_partner_address_8invoice
816+ partner_shipping_id: base.res_partner_address_8invoice
817+ pricelist_id: 1
818+ order_line:
819+ - product_uom_qty: 1.0
820+ product_uom: 1
821+ price_unit: 23.83
822+ name: '23.83'
823+ tax_id:
824+ - account.account_tax_21
825+ - product_uom_qty: 1.0
826+ product_uom: 1
827+ price_unit: 7.44
828+ name: '7.44'
829+ tax_id:
830+ - account.account_tax_21
831+-
832+ Then I verify the amount (computation by column).
833+ 23.83 + 7.44 = 31.27
834+ 31.27 × 0.21 = 6.5667 = 6.57
835+-
836+ !assert {model: sale.order, id: order_1_computation_by_column}:
837+ - amount_tax == 6.57
838+
839+-
840+ Set the company to 'Round per line'.
841+-
842+
843+ !record {model: res.company, id: base.main_company}:
844+ tax_calculation_rounding_method: 'round_per_line'

Subscribers

People subscribed via source and target branches

to all changes: