first commit
This commit is contained in:
2
modules/account_receivable_rule/tests/__init__.py
Normal file
2
modules/account_receivable_rule/tests/__init__.py
Normal 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.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,151 @@
|
||||
================================
|
||||
Account Receivable Rule Scenario
|
||||
================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'account_receivable_rule', create_company, create_chart)
|
||||
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Move = Model.get('account.move')
|
||||
>>> ReceivableRule = Model.get('account.account.receivable.rule')
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = create_fiscalyear()
|
||||
>>> fiscalyear.click('create_period')
|
||||
>>> period = fiscalyear.periods[0]
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create multiple receivable::
|
||||
|
||||
>>> receivable1, = accounts['receivable'].duplicate()
|
||||
>>> receivable2, = accounts['receivable'].duplicate()
|
||||
|
||||
Setup journals::
|
||||
|
||||
>>> journal_general = Journal(name="General", type='general')
|
||||
>>> journal_general.save()
|
||||
>>> journal_revenue, = Journal.find([('code', '=', "REV")])
|
||||
>>> journal_cash, = Journal.find([('code', '=', "CASH")])
|
||||
|
||||
Create a receivable rule::
|
||||
|
||||
>>> receivable_rule = ReceivableRule()
|
||||
>>> receivable_rule.account = accounts['receivable']
|
||||
>>> receivable_rule.journal = journal_general
|
||||
>>> receivable_rule.priorities = 'maturity_date|account'
|
||||
>>> account_rule1 = receivable_rule.accounts.new()
|
||||
>>> account_rule1.account = receivable1
|
||||
>>> account_rule2 = receivable_rule.accounts.new()
|
||||
>>> account_rule2.account = receivable2
|
||||
>>> account_rule2.only_reconcile = False
|
||||
>>> receivable_rule.save()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create receivable lines for 100::
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.credit = Decimal('50.00')
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable1
|
||||
>>> line.party = customer
|
||||
>>> line.debit = Decimal('50.00')
|
||||
>>> line.maturity_date = period.start_date
|
||||
>>> move.click('post')
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.credit = Decimal('20.00')
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable2
|
||||
>>> line.party = customer
|
||||
>>> line.debit = Decimal('20.00')
|
||||
>>> line.maturity_date = period.start_date
|
||||
>>> move.click('post')
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.credit = Decimal('30.00')
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable2
|
||||
>>> line.party = customer
|
||||
>>> line.debit = Decimal('30.00')
|
||||
>>> line.maturity_date = period.end_date
|
||||
>>> move.click('post')
|
||||
|
||||
Receive 80::
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_cash
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['cash']
|
||||
>>> line.debit = Decimal('80.00')
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['receivable']
|
||||
>>> line.party = customer
|
||||
>>> line.credit = Decimal('80.00')
|
||||
>>> move.click('post')
|
||||
|
||||
Check balance of accounts::
|
||||
|
||||
>>> accounts['receivable'].reload()
|
||||
>>> accounts['receivable'].balance
|
||||
Decimal('-80.00')
|
||||
>>> receivable1.reload()
|
||||
>>> receivable1.balance
|
||||
Decimal('50.00')
|
||||
>>> receivable2.reload()
|
||||
>>> receivable2.balance
|
||||
Decimal('50.00')
|
||||
|
||||
|
||||
Apply receivable rule::
|
||||
|
||||
>>> receivable_rule.click('apply')
|
||||
|
||||
Check balance of accounts::
|
||||
|
||||
>>> accounts['receivable'].reload()
|
||||
>>> accounts['receivable'].balance
|
||||
Decimal('0.00')
|
||||
>>> receivable1.reload()
|
||||
>>> receivable1.balance
|
||||
Decimal('0.00')
|
||||
>>> receivable2.reload()
|
||||
>>> receivable2.balance
|
||||
Decimal('20.00')
|
||||
@@ -0,0 +1,120 @@
|
||||
=========================================
|
||||
Account Receivable Rule Overflow Scenario
|
||||
=========================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'account_receivable_rule', create_company, create_chart)
|
||||
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Move = Model.get('account.move')
|
||||
>>> ReceivableRule = Model.get('account.account.receivable.rule')
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = create_fiscalyear()
|
||||
>>> fiscalyear.click('create_period')
|
||||
>>> period = fiscalyear.periods[0]
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create multiple receivable::
|
||||
|
||||
>>> receivable1, = accounts['receivable'].duplicate()
|
||||
>>> receivable2, = accounts['receivable'].duplicate()
|
||||
|
||||
Setup journals::
|
||||
|
||||
>>> journal_general = Journal(name="General", type='general')
|
||||
>>> journal_general.save()
|
||||
>>> journal_revenue, = Journal.find([('code', '=', "REV")])
|
||||
>>> journal_cash, = Journal.find([('code', '=', "CASH")])
|
||||
|
||||
Create a receivable rule::
|
||||
|
||||
>>> receivable_rule = ReceivableRule()
|
||||
>>> receivable_rule.account = accounts['receivable']
|
||||
>>> receivable_rule.journal = journal_general
|
||||
>>> receivable_rule.priorities = 'maturity_date|account'
|
||||
>>> receivable_rule.overflow_account = receivable2
|
||||
>>> account_rule1 = receivable_rule.accounts.new()
|
||||
>>> account_rule1.account = receivable1
|
||||
>>> receivable_rule.save()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create receivable lines for 50::
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.credit = Decimal('50.00')
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable1
|
||||
>>> line.party = customer
|
||||
>>> line.debit = Decimal('50.00')
|
||||
>>> line.maturity_date = period.start_date
|
||||
>>> move.click('post')
|
||||
|
||||
Receive 100::
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_cash
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['cash']
|
||||
>>> line.debit = Decimal('100.00')
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['receivable']
|
||||
>>> line.party = customer
|
||||
>>> line.credit = Decimal('100.00')
|
||||
>>> move.click('post')
|
||||
|
||||
Check balance of accounts::
|
||||
|
||||
>>> accounts['receivable'].reload()
|
||||
>>> accounts['receivable'].balance
|
||||
Decimal('-100.00')
|
||||
>>> receivable1.reload()
|
||||
>>> receivable1.balance
|
||||
Decimal('50.00')
|
||||
>>> receivable2.reload()
|
||||
>>> receivable2.balance
|
||||
Decimal('0.00')
|
||||
|
||||
Apply receivable rule::
|
||||
|
||||
>>> receivable_rule.click('apply')
|
||||
|
||||
Check balance of accounts::
|
||||
|
||||
>>> accounts['receivable'].reload()
|
||||
>>> accounts['receivable'].balance
|
||||
Decimal('0.00')
|
||||
>>> receivable1.reload()
|
||||
>>> receivable1.balance
|
||||
Decimal('0.00')
|
||||
>>> receivable2.reload()
|
||||
>>> receivable2.balance
|
||||
Decimal('-50.00')
|
||||
@@ -0,0 +1,126 @@
|
||||
==========================================
|
||||
Account Receivable Rule Statement Scenario
|
||||
==========================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> 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, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['account_receivable_rule', 'account_statement'],
|
||||
... create_company, create_chart)
|
||||
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> Move = Model.get('account.move')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ReceivableRule = Model.get('account.account.receivable.rule')
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> StatementJournal = Model.get('account.statement.journal')
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
>>> period = fiscalyear.periods[0]
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create multiple receivable::
|
||||
|
||||
>>> receivable_bis, = accounts['receivable'].duplicate()
|
||||
|
||||
Setup journals::
|
||||
|
||||
>>> journal_general = Journal(name="General", type='general')
|
||||
>>> journal_general.save()
|
||||
>>> journal_revenue, = Journal.find([('code', '=', "REV")])
|
||||
>>> journal_cash, = Journal.find([('code', '=', "CASH")])
|
||||
|
||||
Create a receivable rule::
|
||||
|
||||
>>> receivable_rule = ReceivableRule()
|
||||
>>> receivable_rule.account = accounts['receivable']
|
||||
>>> receivable_rule.journal = journal_general
|
||||
>>> receivable_rule.priorities = 'maturity_date|account'
|
||||
>>> account_rule = receivable_rule.accounts.new()
|
||||
>>> account_rule.account = receivable_bis
|
||||
>>> receivable_rule.save()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create receivable bis of 50::
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.credit = Decimal('50.00')
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable_bis
|
||||
>>> line.party = customer
|
||||
>>> line.debit = Decimal('50.00')
|
||||
>>> line.maturity_date = period.start_date
|
||||
>>> move.click('post')
|
||||
|
||||
Create statement receiving 50 from customer on receivable::
|
||||
|
||||
>>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
|
||||
>>> statement_journal = StatementJournal(
|
||||
... name="Journal",
|
||||
... journal=account_journal,
|
||||
... account=accounts['cash'],
|
||||
... validation='balance',
|
||||
... )
|
||||
>>> statement_journal.save()
|
||||
|
||||
>>> statement = Statement(
|
||||
... name="Statement",
|
||||
... journal=statement_journal,
|
||||
... start_balance=Decimal('0.00'),
|
||||
... end_balance=Decimal('50.00'),
|
||||
... )
|
||||
>>> statement_line = statement.lines.new()
|
||||
>>> statement_line.number = '0001'
|
||||
>>> statement_line.description = "Description"
|
||||
>>> statement_line.date = period.start_date
|
||||
>>> statement_line.amount = Decimal('50.00')
|
||||
>>> statement_line.party = customer
|
||||
>>> assertEqual(statement_line.account, accounts['receivable'])
|
||||
>>> statement_line.amount
|
||||
Decimal('50.00')
|
||||
|
||||
Validate and Post statement::
|
||||
|
||||
>>> statement.click('validate_statement')
|
||||
>>> statement.state
|
||||
'validated'
|
||||
>>> statement.click('post')
|
||||
>>> statement.state
|
||||
'posted'
|
||||
|
||||
Check receivable bis has been credited::
|
||||
|
||||
>>> accounts['receivable'].reload()
|
||||
>>> accounts['receivable'].balance
|
||||
Decimal('0.00')
|
||||
>>> receivable_bis.reload()
|
||||
>>> receivable_bis.balance
|
||||
Decimal('0.00')
|
||||
13
modules/account_receivable_rule/tests/test_module.py
Normal file
13
modules/account_receivable_rule/tests/test_module.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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.modules.company.tests import CompanyTestMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AccountReceivableRuleTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test Account Receivable Rule module'
|
||||
module = 'account_receivable_rule'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/account_receivable_rule/tests/test_scenario.py
Normal file
8
modules/account_receivable_rule/tests/test_scenario.py
Normal 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)
|
||||
Reference in New Issue
Block a user