[IMP] account: improve edi import of invoice to split in different stuff
[odoo/odoo.git] / addons / account / test / price_accuracy00.yml
1 -   |
2     Tax Scenario:
3     In order to check that the accounting entries and tax engine works
4     efficiently with all kind of price accuracies we run this test scenario.
5 -  
6     Given the price accuracy for the account module is configured with two
7     digits
8 -  
9     !record {model: decimal.precision, id: product.decimal_account}:
10       digits: 2
11 -  
12     And we have a tax defined
13 -  
14     !record {model: account.tax, id: tax196}:
15       name: Tax 19.6%
16       amount: &tax 0.196
17 -  
18     And we define an invoice with one invoice line with a tax of *tax
19 -  
20     !record {model: account.invoice, id: invoice1}: &invoice
21         name: Precision Test
22         type: out_invoice
23         partner_id: base.res_partner_2
24         address_invoice_id: base.res_partner_address_1
25         account_id: account.a_recv
26         date_invoice: !eval time.strftime('%Y-%m-%d')
27         invoice_line:
28             - product_id: product.product_product_pc1
29               quantity: &qty 11.11
30               account_id: account.a_sale
31               uos_id: product.product_uom_unit
32               price_unit: &price 12.34
33               name: test
34               invoice_line_tax_id:
35                   - tax196
36 -  
37     When I press on the CREATE button on the invoice to open it.
38 -  
39     !python {model: account.invoice}: |
40         self.action_move_create(cr, uid, [ref("invoice1")])  
41 -  
42     Then I should see an account entry linked to this invoice.
43 -  
44     !assert {model: account.invoice, id: invoice1}:
45       test:
46         - bool(move_id)
47 -  
48     # This is not working, find a way to do that in YAML, *qty is not
49     # interpreted because it's not a node.
50     And this account entry must have a credit equals to 163.97€ which is
51     equal to *qty x *price x (1 + *tax)
52 -  
53     !assert {model: account.invoice, id: invoice1}:
54         test:
55             - abs(sum(x.credit for x in move_id.line_id) - 163.97) < 0.000001
56 -  
57     And this account entry must have a credit equals to the debit
58 -  
59     !assert {model: account.invoice, id: invoice1}:
60         test:
61             - abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
62 -  
63     Then, I change the precision of numbers to 3 digits.
64 -  
65     !record {model: decimal.precision, id: product.decimal_account}:
66       digits: 3
67 -  
68     And I create another invoice with the same content.
69 -  
70     !record {model: account.invoice, id: invoice2}:
71         *invoice
72 -  
73     When I press on the CREATE button on the invoice to open it.
74 -  
75     !python {model: account.invoice}: |
76         self.action_move_create(cr, uid, [ref("invoice2")])  
77 -    
78     Then this account entry must have a credit equals to the debit
79 -  
80     !assert {model: account.invoice, id: invoice2}:
81         test:
82             - abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
83 -
84     And this account entry must have a credit equals to 163.968€ which is
85     equal to *qty x *price x (1 + *tax)
86 -  
87     !python {model: account.invoice}: |
88         xid = "invoice2"
89         invoice = self.browse(cr, uid, ref(xid))
90         sum_of_credits = sum(x.credit for x in invoice.move_id.line_id)
91         log("The sum of credits for %s is %f", xid, sum_of_credits)
92         expected_value = 163.968
93         assert (sum_of_credits - expected_value) < 0.000001, "Wrong sum of credits: %f <> %f" % (sum_of_credits, expected_value)
94