You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.9 KiB

9 years ago
  1. #from openerp.addons.account.tests.account_test_users import AccountTestUsers
  2. from openerp.tests.common import TransactionCase
  3. from openerp.tools import float_compare
  4. class TestAccountTaxBalance(TransactionCase):
  5. def setUp(self):
  6. super(TestAccountTaxBalance, self).setUp()
  7. self.fixed_tax = self.tax_model.create({
  8. 'name': "Fixed tax",
  9. 'amount_type': 'fixed',
  10. 'amount': 10.0,
  11. 'sequence': 1,
  12. })
  13. self.fixed_tax_bis = self.tax_model.create({
  14. 'name': "Fixed tax bis",
  15. 'amount_type': 'fixed',
  16. 'amount': 15,
  17. 'sequence': 2,
  18. })
  19. self.percent_tax = self.tax_model.create({
  20. 'name': "Percent tax",
  21. 'amount_type': 'percent',
  22. 'amount': 10.0,
  23. 'sequence': 3,
  24. })
  25. self.bank_journal = self.env['account.journal'].search([('type', '=', 'bank'), ('company_id', '=', self.account_manager.company_id.id)])[0]
  26. self.bank_account = self.bank_journal.default_debit_account_id
  27. self.expense_account = self.env['account.account'].search([('user_type_id.type', '=', 'payable')], limit=1) #Should be done by onchange later
  28. def test_tax_balance(self):
  29. company_id = self.env['res.users'].browse(self.env.uid).company_id.id
  30. tax = self.env['account.tax'].create({
  31. 'name': 'Tax 10.0',
  32. 'amount': 10.0,
  33. 'amount_type': 'fixed',
  34. })
  35. analytic_account = self.env['account.analytic.account'].create({
  36. 'name': 'test account',
  37. })
  38. invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id
  39. invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id
  40. invoice = self.env['account.invoice'].create({
  41. 'partner_id': self.env.ref('base.res_partner_2').id,
  42. 'account_id': invoice_account,
  43. 'type': 'in_invoice',
  44. })
  45. self.env['account.invoice.line'].create({
  46. 'product_id': self.env.ref('product.product_product_4').id,
  47. 'quantity': 1.0,
  48. 'price_unit': 100.0,
  49. 'invoice_id': invoice.id,
  50. 'name': 'product that cost 100',
  51. 'account_id': invoice_line_account,
  52. 'invoice_line_tax_ids': [(6, 0, [tax.id])],
  53. 'account_analytic_id': analytic_account.id,
  54. })
  55. # : check that Initially supplier bill state is "Draft"
  56. self.assertTrue((invoice.state == 'draft'), "Initially vendor bill state is Draft")
  57. #change the state of invoice to open by clicking Validate button
  58. invoice.signal_workflow('invoice_open')
  59. self.assertEquals(tax.base_balance, 100)
  60. self.assertEquals(tax.balance, 10)