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.
6 Given the price accuracy for the account module is configured with two
9 !record {model: decimal.precision, id: product.decimal_account}:
12 And we have a tax defined
14 !record {model: account.tax, id: tax196}:
18 And we define an invoice with one invoice line with a tax of *tax
20 !record {model: account.invoice, id: invoice1}: &invoice
23 partner_id: base.res_partner_2
24 account_id: account.a_recv
25 date_invoice: !eval time.strftime('%Y-%m-%d')
27 - product_id: product.product_product_3
29 account_id: account.a_sale
30 uos_id: product.product_uom_unit
31 price_unit: &price 12.34
36 When I press on the CREATE button on the invoice to open it.
38 !python {model: account.invoice}: |
39 self.action_move_create(cr, uid, [ref("invoice1")])
41 Then I should see an account entry linked to this invoice.
43 !assert {model: account.invoice, id: invoice1}:
47 # This is not working, find a way to do that in YAML, *qty is not
48 # interpreted because it's not a node.
49 And this account entry must have a credit equals to 163.97€ which is
50 equal to *qty x *price x (1 + *tax)
52 !assert {model: account.invoice, id: invoice1}:
54 - abs(sum(x.credit for x in move_id.line_id) - 163.97) < 0.000001
56 And this account entry must have a credit equals to the debit
58 !assert {model: account.invoice, id: invoice1}:
60 - abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
62 Then, I change the precision of numbers to 3 digits.
64 !record {model: decimal.precision, id: product.decimal_account}:
67 And I create another invoice with the same content.
69 !record {model: account.invoice, id: invoice2}:
72 When I press on the CREATE button on the invoice to open it.
74 !python {model: account.invoice}: |
75 self.action_move_create(cr, uid, [ref("invoice2")])
77 Then this account entry must have a credit equals to the debit
79 !assert {model: account.invoice, id: invoice2}:
81 - abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
83 And this account entry must have a credit equals to 163.968€ which is
84 equal to *qty x *price x (1 + *tax)
86 !python {model: account.invoice}: |
88 invoice = self.browse(cr, uid, ref(xid))
89 sum_of_credits = sum(x.credit for x in invoice.move_id.line_id)
90 log("The sum of credits for %s is %f", xid, sum_of_credits)
91 expected_value = 163.968
92 assert (sum_of_credits - expected_value) < 0.000001, "Wrong sum of credits: %f <> %f" % (sum_of_credits, expected_value)