93 lines
3.1 KiB
YAML
93 lines
3.1 KiB
YAML
|
- |
|
||
|
Tax Scenario:
|
||
|
In order to check that the accounting entries and tax engine works
|
||
|
efficiently with all kind of price accuracies we run this test scenario.
|
||
|
-
|
||
|
Given the price accuracy for the account module is configured with two
|
||
|
digits
|
||
|
-
|
||
|
!record {model: decimal.precision, id: product.decimal_account}:
|
||
|
digits: 2
|
||
|
-
|
||
|
And we have a tax defined
|
||
|
-
|
||
|
!record {model: account.tax, id: tax196}:
|
||
|
name: Tax 19.6%
|
||
|
amount: &tax 0.196
|
||
|
account_collected_id: account.a_recv
|
||
|
account_paid_id: account.a_recv
|
||
|
-
|
||
|
And we define an invoice with one invoice line with a tax of *tax
|
||
|
-
|
||
|
!record {model: account.invoice, id: invoice1}: &invoice
|
||
|
name: Precision Test
|
||
|
type: out_invoice
|
||
|
partner_id: base.res_partner_2
|
||
|
address_invoice_id: base.res_partner_address_1
|
||
|
account_id: account.a_recv
|
||
|
date_invoice: !eval time.strftime('%Y-%m-%d')
|
||
|
invoice_line:
|
||
|
- product_id: product.product_product_pc1
|
||
|
quantity: &qty 11.11
|
||
|
account_id: account.a_sale
|
||
|
uos_id: product.product_uom_unit
|
||
|
price_unit: &price 12.34
|
||
|
name: test
|
||
|
invoice_line_tax_id:
|
||
|
- tax196
|
||
|
-
|
||
|
When I press on the CREATE button on the invoice to open it.
|
||
|
-
|
||
|
!python {model: account.invoice}: |
|
||
|
self.action_move_create(cr, uid, [ref("invoice1")])
|
||
|
-
|
||
|
Then I should see an account entry linked to this invoice.
|
||
|
-
|
||
|
!assert {model: account.invoice, id: invoice1}:
|
||
|
test:
|
||
|
- bool(move_id)
|
||
|
-
|
||
|
# This is not working, find a way to do that in YAML, *qty is not
|
||
|
# interpreted because it's not a node.
|
||
|
And this account entry must have a credit equals to 163.70€ which is
|
||
|
equal to *qty x *price x (1 + *tax)
|
||
|
-
|
||
|
!assert {model: account.invoice, id: invoice1}:
|
||
|
test:
|
||
|
- abs(sum(x.credit for x in move_id.line_id) - 163.97) < 0.000001
|
||
|
-
|
||
|
And this account entry must have a credit equals to the debit
|
||
|
-
|
||
|
!assert {model: account.invoice, id: invoice1}:
|
||
|
test:
|
||
|
- abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
|
||
|
-
|
||
|
Then, I change the precision of numbers to 3 digits.
|
||
|
-
|
||
|
!record {model: decimal.precision, id: product.decimal_account}:
|
||
|
digits: 3
|
||
|
-
|
||
|
And I create another invoice with the same content.
|
||
|
-
|
||
|
!record {model: account.invoice, id: invoice2}:
|
||
|
*invoice
|
||
|
-
|
||
|
When I press on the CREATE button on the invoice to open it.
|
||
|
-
|
||
|
!python {model: account.invoice}: |
|
||
|
self.action_move_create(cr, uid, [ref("invoice2")])
|
||
|
-
|
||
|
!python {model: account.invoice}: |
|
||
|
invoice = self.browse(cr, uid, ref("invoice2"))
|
||
|
log(sum(x.credit for x in invoice.move_id.line_id))
|
||
|
assert (sum(x.credit for x in invoice.move_id.line_id) - 163.968) < 0.000001, "Pas bon !!!"
|
||
|
-
|
||
|
!assert {model: account.invoice, id: invoice2}:
|
||
|
test:
|
||
|
- abs(sum(x.credit for x in move_id.line_id) - 163.968) < 0.000001
|
||
|
-
|
||
|
!assert {model: account.invoice, id: invoice2}:
|
||
|
test:
|
||
|
- abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
|
||
|
|