changeset ee1920cb7d12 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=ee1920cb7d12
description:
Add Account Tax Code Scenario
issue9743
review328531002
diffstat:
tests/scenario_tax_code.rst | 92 +++++++++++++++++++++++++++++++++++++++++++++
tests/test_account.py | 5 ++
2 files changed, 97 insertions(+), 0 deletions(-)
diffs (109 lines):
diff -r 75da9fcb8533 -r ee1920cb7d12 tests/scenario_tax_code.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/scenario_tax_code.rst Wed Oct 28 23:54:20 2020 +0100
@@ -0,0 +1,92 @@
+=========================
+Account Tax Code Scenario
+=========================
+
+Imports::
+
+ >>> from decimal import Decimal
+ >>> from proteus import Model, Wizard
+ >>> from trytond.tests.tools import activate_modules
+ >>> from trytond.modules.company.tests.tools import create_company, \
+ ... get_company
+ >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
+ ... create_chart, get_accounts, create_tax, create_tax_code
+
+Activate modules::
+
+ >>> config = activate_modules('account')
+
+Create company::
+
+ >>> _ = create_company()
+ >>> company = get_company()
+
+Create fiscal year::
+
+ >>> fiscalyear = create_fiscalyear(company)
+ >>> fiscalyear.click('create_period')
+ >>> period = fiscalyear.periods[0]
+
+Create chart of accounts::
+
+ >>> _ = create_chart(company)
+ >>> accounts = get_accounts(company)
+
+Create tax code::
+
+ >>> TaxCode = Model.get('account.tax.code')
+ >>> tax = create_tax(Decimal('0.1'))
+ >>> tax.save()
+ >>> base_code = create_tax_code(tax, amount='base')
+ >>> base_code.save()
+ >>> tax_code_invoice = create_tax_code(tax)
+ >>> tax_code_invoice.save()
+ >>> tax_code_credit = create_tax_code(tax, type='credit')
+ >>> tax_code_credit.save()
+
+Create parties::
+
+ >>> Party = Model.get('party.party')
+ >>> party = Party(name='Party')
+ >>> party.save()
+
+Create some moves::
+
+ >>> Journal = Model.get('account.journal')
+ >>> Move = Model.get('account.move')
+ >>> journal, = Journal.find([
+ ... ('code', '=', 'EXP'),
+ ... ])
+
+ >>> move = Move(period=period, journal=journal)
+ >>> move.date = period.start_date
+ >>> line = move.lines.new()
+ >>> line.account = accounts['expense']
+ >>> line.credit = Decimal(10)
+ >>> line = move.lines.new()
+ >>> line.account = accounts['payable']
+ >>> line.debit = Decimal(11)
+ >>> line.party = party
+ >>> line = move.lines.new()
+ >>> line.account = accounts['tax']
+ >>> line.credit = Decimal(1)
+ >>> tax_line = line.tax_lines.new()
+ >>> tax_line.amount = line.credit
+ >>> tax_line.type = 'tax'
+ >>> tax_line.tax = tax
+ >>> move.save()
+
+ >>> _ = move.duplicate()
+
+ >>> cancel_move = Wizard('account.move.cancel', [move])
+ >>> cancel_move.execute('cancel')
+
+Check tax code::
+
+ >>> TaxCode = Model.get('account.tax.code')
+
+ >>> with config.set_context(periods=[period.id]):
+ ... tax_code_invoice = TaxCode(tax_code_invoice.id)
+ ... tax_code_credit = TaxCode(tax_code_credit.id)
+ >>> tax_code_invoice.amount, tax_code_credit.amount
+ (Decimal('1.00'), Decimal('0.00'))
diff -r 75da9fcb8533 -r ee1920cb7d12 tests/test_account.py
--- a/tests/test_account.py Wed Oct 28 23:53:53 2020 +0100
+++ b/tests/test_account.py Wed Oct 28 23:54:20 2020 +0100
@@ -1679,4 +1679,9 @@
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+ suite.addTests(doctest.DocFileSuite(
+ 'scenario_tax_code.rst',
+ tearDown=doctest_teardown, encoding='utf-8',
+ checker=doctest_checker,
+ optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite