first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,150 @@
=========================
Account Tax Cash Scenario
=========================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, create_tax, create_tax_code, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('account_tax_cash', create_company, create_chart)
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Get accounts::
>>> accounts = get_accounts()
>>> receivable = accounts['receivable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> account_tax = accounts['tax']
>>> account_cash = accounts['cash']
Set Cash journal::
>>> Journal = Model.get('account.journal')
>>> PaymentMethod = Model.get('account.invoice.payment.method')
>>> journal_cash, = Journal.find([('type', '=', 'cash')])
>>> payment_method = PaymentMethod()
>>> payment_method.name = 'Cash'
>>> payment_method.journal = journal_cash
>>> payment_method.credit_account = account_cash
>>> payment_method.debit_account = account_cash
>>> payment_method.save()
Create taxes::
>>> Tax = Model.get('account.tax')
>>> TaxGroup = Model.get('account.tax.group')
>>> TaxCode = Model.get('account.tax.code')
>>> group_cash_basis = TaxGroup(name="Cash Basis", code="CASH")
>>> group_cash_basis.save()
>>> tax_cash_basis = create_tax(Decimal('.10'))
>>> tax_cash_basis.group = group_cash_basis
>>> tax_cash_basis.save()
>>> code_base_cash_basis = create_tax_code(tax_cash_basis, 'base', 'invoice')
>>> code_base_cash_basis.save()
>>> code_tax_cash_basis = create_tax_code(tax_cash_basis, 'tax', 'invoice')
>>> code_tax_cash_basis.save()
>>> fiscalyear.tax_group_on_cash_basis.append(TaxGroup(group_cash_basis.id))
>>> fiscalyear.save()
>>> group_no_cash_basis = TaxGroup(name="No Cash Basis", code="NOCASH")
>>> group_no_cash_basis.save()
>>> tax_no_cash_basis = create_tax(Decimal('.05'))
>>> tax_no_cash_basis.group = group_no_cash_basis
>>> tax_no_cash_basis.save()
>>> code_base_no_cash_basis = create_tax_code(tax_no_cash_basis, 'base', 'invoice')
>>> code_base_no_cash_basis.save()
>>> code_tax_no_cash_basis = create_tax_code(tax_no_cash_basis, 'tax', 'invoice')
>>> code_tax_no_cash_basis.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.quantity = 1
>>> line.unit_price = Decimal('100')
>>> line.account = revenue
>>> line.taxes.extend([Tax(tax_cash_basis.id), Tax(tax_no_cash_basis.id)])
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('115.00')
>>> invoice.move.state
'posted'
Check tax lines::
>>> TaxLine = Model.get('account.tax.line')
>>> lines = TaxLine.find([])
>>> len(lines)
4
>>> any(l.on_cash_basis for l in lines if l.tax == tax_no_cash_basis)
False
>>> all(l.on_cash_basis for l in lines if l.tax == tax_cash_basis)
True
Check tax codes::
>>> with config.set_context(periods=[period.id]):
... TaxCode(code_base_cash_basis.id).amount
... TaxCode(code_tax_cash_basis.id).amount
Decimal('0.00')
Decimal('0.00')
>>> with config.set_context(periods=[period.id]):
... TaxCode(code_base_no_cash_basis.id).amount
... TaxCode(code_tax_no_cash_basis.id).amount
Decimal('100.00')
Decimal('5.00')
Pay partially the invoice::
>>> pay = Wizard('account.invoice.pay', [invoice],
... context={'payment_date': period.start_date})
>>> pay.form.amount = Decimal('60')
>>> pay.form.payment_method = payment_method
>>> pay.form.date = period.start_date
>>> pay.execute('choice')
>>> pay.form.type = 'partial'
>>> pay.execute('pay')
Check tax codes::
>>> with config.set_context(periods=[period.id]):
... TaxCode(code_base_cash_basis.id).amount
... TaxCode(code_tax_cash_basis.id).amount
Decimal('52.17')
Decimal('5.22')
>>> with config.set_context(periods=[period.id]):
... TaxCode(code_base_no_cash_basis.id).amount
... TaxCode(code_tax_no_cash_basis.id).amount
Decimal('100.00')
Decimal('5.00')

View File

@@ -0,0 +1,110 @@
===============================
Account Tax Cash Closing Period
===============================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('account_tax_cash', create_company, create_chart)
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Get accounts::
>>> accounts = get_accounts()
>>> receivable = accounts['receivable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> account_cash = accounts['cash']
Set tax cash basis::
>>> Tax = Model.get('account.tax')
>>> TaxGroup = Model.get('account.tax.group')
>>> TaxCode = Model.get('account.tax.code')
>>> group_cash_basis = TaxGroup(name="Cash Basis", code="CASH")
>>> group_cash_basis.save()
>>> fiscalyear.tax_group_on_cash_basis.append(TaxGroup(group_cash_basis.id))
>>> fiscalyear.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create revenue::
>>> Move = Model.get('account.move')
>>> Journal = Model.get('account.journal')
>>> journal_revenue, = Journal.find([('type', '=', 'revenue')])
>>> move = Move()
>>> move.period = period
>>> move.date = period.start_date
>>> move.journal = journal_revenue
>>> line = move.lines.new()
>>> line.account = revenue
>>> line.credit = Decimal('10')
>>> line = move.lines.new()
>>> line.account = receivable
>>> line.party = party
>>> line.debit = Decimal('10')
>>> move.click('post')
Can close the period::
>>> period.click('close')
>>> period.click('reopen')
Receive cash::
>>> journal_cash, = Journal.find([('type', '=', 'cash')])
>>> move = Move()
>>> move.period = period
>>> move.date = period.start_date
>>> move.journal = journal_cash
>>> line = move.lines.new()
>>> line.account = account_cash
>>> line.debit = Decimal('10')
>>> line = move.lines.new()
>>> line.account = receivable
>>> line.party = party
>>> line.credit = Decimal('10')
>>> move.click('post')
Can not close the period::
>>> period.click('close')
Traceback (most recent call last):
...
ClosePeriodWarning: ...
Reconcile lines::
>>> Line = Model.get('account.move.line')
>>> lines = Line.find([('account', '=', receivable.id)])
>>> reconcile_lines = Wizard('account.move.reconcile_lines', lines)
>>> reconcile_lines.state
'end'
Can close the period::
>>> period.click('close')

View File

@@ -0,0 +1,138 @@
=======================================
Account Tax Cash Reconsilition Scenario
=======================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, create_tax, create_tax_code, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('account_tax_cash', create_company, create_chart)
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Get accounts::
>>> accounts = get_accounts()
>>> receivable = accounts['receivable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> account_tax = accounts['tax']
>>> account_cash = accounts['cash']
Create taxes::
>>> Tax = Model.get('account.tax')
>>> TaxGroup = Model.get('account.tax.group')
>>> TaxCode = Model.get('account.tax.code')
>>> group_cash_basis = TaxGroup(name="Cash Basis", code="CASH")
>>> group_cash_basis.save()
>>> tax_cash_basis = create_tax(Decimal('.10'))
>>> tax_cash_basis.group = group_cash_basis
>>> tax_cash_basis.save()
>>> code_base_cash_basis = create_tax_code(tax_cash_basis, 'base', 'invoice')
>>> code_base_cash_basis.save()
>>> code_tax_cash_basis = create_tax_code(tax_cash_basis, 'tax', 'invoice')
>>> code_tax_cash_basis.save()
>>> fiscalyear.tax_group_on_cash_basis.append(TaxGroup(group_cash_basis.id))
>>> fiscalyear.save()
Create payment term::
>>> PaymentTerm = Model.get('account.invoice.payment_term')
>>> payment_term = PaymentTerm(name="2x")
>>> line = payment_term.lines.new(type='percent', ratio=Decimal('0.5'))
>>> line = payment_term.lines.new(type='remainder')
>>> payment_term.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.payment_term = payment_term
>>> line = invoice.lines.new()
>>> line.quantity = 1
>>> line.unit_price = Decimal('100')
>>> line.account = revenue
>>> line.taxes.extend([Tax(tax_cash_basis.id)])
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('110.00')
>>> invoice.move.state
'posted'
Check tax lines::
>>> TaxLine = Model.get('account.tax.line')
>>> lines = TaxLine.find([])
>>> len(lines)
2
>>> all(l.on_cash_basis for l in lines if l.tax == tax_cash_basis)
True
Check tax codes::
>>> with config.set_context(periods=[period.id]):
... TaxCode(code_base_cash_basis.id).amount
... TaxCode(code_tax_cash_basis.id).amount
Decimal('0.00')
Decimal('0.00')
Pay 1 term of the invoice::
>>> Journal = Model.get('account.journal')
>>> Move = Model.get('account.move')
>>> journal_cash, = Journal.find([('type', '=', 'cash')])
>>> move = Move()
>>> move.date = period.start_date
>>> move.journal = journal_cash
>>> line = move.lines.new()
>>> line.account = revenue
>>> line.debit = Decimal('55')
>>> line = move.lines.new()
>>> line.account = receivable
>>> line.party = party
>>> line.credit = Decimal('55')
>>> move.save()
>>> payment_line, = [l for l in move.lines if l.account == receivable]
>>> term1 = [l for l in invoice.move.lines if l.account == receivable][0]
>>> reconcile_lines = Wizard('account.move.reconcile_lines',
... [payment_line, term1],
... context={'payment_date': period.start_date})
>>> reconcile_lines.state
'end'
Check tax codes::
>>> with config.set_context(periods=[period.id]):
... TaxCode(code_base_cash_basis.id).amount
... TaxCode(code_tax_cash_basis.id).amount
Decimal('50.00')
Decimal('5.00')

View File

@@ -0,0 +1,83 @@
==================================
Account Tax Cash Supplier Scenario
==================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, create_tax, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('account_tax_cash', create_company, create_chart)
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Get accounts::
>>> accounts = get_accounts()
>>> receivable = accounts['receivable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> account_tax = accounts['tax']
>>> account_cash = accounts['cash']
Create tax::
>>> Tax = Model.get('account.tax')
>>> TaxGroup = Model.get('account.tax.group')
>>> TaxCode = Model.get('account.tax.code')
>>> tax_group = TaxGroup(name="Supplier", code="SUP")
>>> tax_group.save()
>>> tax = create_tax(Decimal('.10'))
>>> tax.group = tax_group
>>> tax.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.supplier_tax_group_on_cash_basis.append(TaxGroup(tax_group.id))
>>> party.save()
Create invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = party
>>> len(invoice.tax_group_on_cash_basis)
1
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.quantity = 1
>>> line.unit_price = Decimal('100')
>>> line.account = expense
>>> line.taxes.extend([Tax(tax.id)])
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('110.00')
>>> invoice.move.state
'posted'
Check tax lines::
>>> TaxLine = Model.get('account.tax.line')
>>> lines = TaxLine.find([])
>>> len(lines)
2
>>> all(l.on_cash_basis for l in lines)
True

View File

@@ -0,0 +1,12 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import ModuleTestCase
class AccountTaxCashTestCase(ModuleTestCase):
'Test Account Tax Cash module'
module = 'account_tax_cash'
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)