From 236aec74aff4d9992a739e6776bf871eca652816 Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Tue, 9 Mar 2010 10:41:32 +0100 Subject: [PATCH] [IMP] Completed tests. bzr revid: jth@openerp.com-20100309094132-x4ycbziga4kqflyj --- addons/account/test/price_accuracy00.yaml | 64 ---------------- addons/account/test/price_accuracy00.yml | 92 +++++++++++++++++++++++ 2 files changed, 92 insertions(+), 64 deletions(-) delete mode 100644 addons/account/test/price_accuracy00.yaml create mode 100644 addons/account/test/price_accuracy00.yml diff --git a/addons/account/test/price_accuracy00.yaml b/addons/account/test/price_accuracy00.yaml deleted file mode 100644 index a825700e4b7..00000000000 --- a/addons/account/test/price_accuracy00.yaml +++ /dev/null @@ -1,64 +0,0 @@ -- | - 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 -- - 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.xxx - address_contact_id: - address_invoice_id: - account_id: - invoice_lines: - - product_qty: &qty 11.11 - product_uom: product.product_unit - price_unit: &price 12.34 -- - When I press on the CREATE button on the invoice to open it. -- - # to be completed -- - Then I should see an account entry linked to this invoice. -- - !record {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) -- - !record {model: account.invoice, id: invoice1}: - test: abs(move_id.credit - 163.70) < 0.000001 -- - And this account entry must have a credit equals to the debit -- - !record {model: account.invoice, id: invoice1}: - test: abs(move_id.debit - move_id.credit) < 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 -- - to be completed, etc. diff --git a/addons/account/test/price_accuracy00.yml b/addons/account/test/price_accuracy00.yml new file mode 100644 index 00000000000..48b5ceca35b --- /dev/null +++ b/addons/account/test/price_accuracy00.yml @@ -0,0 +1,92 @@ +- | + 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 +