first commit
This commit is contained in:
2
modules/account_statement_rule/tests/__init__.py
Normal file
2
modules/account_statement_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,87 @@
|
||||
===============================
|
||||
Account Statement Rule Scenario
|
||||
===============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
|
||||
>>> from trytond.modules.company.tests.tools import create_company, get_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'account_statement_rule', create_company, create_chart)
|
||||
|
||||
Get company::
|
||||
|
||||
>>> company = get_company()
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
>>> receivable = accounts['receivable']
|
||||
>>> cash = accounts['cash']
|
||||
>>> tax = accounts['tax']
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create statement rules::
|
||||
|
||||
>>> Rule = Model.get('account.statement.rule')
|
||||
|
||||
>>> rule1 = Rule(name="Rule 1")
|
||||
>>> rule1.company = company
|
||||
>>> rule1.amount_low = Decimal('10')
|
||||
>>> rule1.description = r"Party: *(?P<party>.*)"
|
||||
>>> line1 = rule1.lines.new()
|
||||
>>> line1.amount = "amount * 0.1"
|
||||
>>> line1.account = tax
|
||||
>>> line2 = rule1.lines.new()
|
||||
>>> line2.amount = "pending"
|
||||
>>> line2.account = receivable
|
||||
>>> rule1.save()
|
||||
|
||||
Create a statement with origins::
|
||||
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> StatementJournal = Model.get('account.statement.journal')
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
|
||||
>>> journal_number = StatementJournal(name="Number",
|
||||
... journal=account_journal,
|
||||
... account=cash,
|
||||
... validation='number_of_lines',
|
||||
... )
|
||||
>>> journal_number.save()
|
||||
|
||||
>>> statement = Statement(name="number origins")
|
||||
>>> statement.journal = journal_number
|
||||
>>> statement.number_of_lines = 1
|
||||
>>> origin = statement.origins.new()
|
||||
>>> origin.date = today
|
||||
>>> origin.amount = Decimal('50.00')
|
||||
>>> origin.description = "Party: %s" % customer.code
|
||||
>>> statement.save()
|
||||
>>> len(statement.lines)
|
||||
0
|
||||
|
||||
Apply rules on statement::
|
||||
|
||||
>>> statement.click('apply_rules')
|
||||
>>> len(statement.lines)
|
||||
2
|
||||
>>> sorted([l.amount for l in statement.lines])
|
||||
[Decimal('5.00'), Decimal('45.00')]
|
||||
>>> assertEqual({l.account for l in statement.lines}, {tax, receivable})
|
||||
>>> assertEqual({l.party for l in statement.lines}, {None, customer})
|
||||
@@ -0,0 +1,139 @@
|
||||
====================================================
|
||||
Account Statement Rule Keyword Bank Account Scenario
|
||||
====================================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> 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, get_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['account_statement_rule', 'bank'],
|
||||
... create_company, create_chart)
|
||||
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> Bank = Model.get('bank')
|
||||
>>> BankAccount = Model.get('bank.account')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Rule = Model.get('account.statement.rule')
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> StatementJournal = Model.get('account.statement.journal')
|
||||
|
||||
Get company::
|
||||
|
||||
>>> company = get_company()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=today))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create a party::
|
||||
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create a bank::
|
||||
|
||||
>>> party_bank = Party(name="Bank")
|
||||
>>> party_bank.save()
|
||||
>>> bank = Bank(party=party_bank)
|
||||
>>> bank.save()
|
||||
|
||||
Create statement rules::
|
||||
|
||||
>>> rule = Rule(name="Party Rule")
|
||||
>>> rule.company = company
|
||||
>>> rule.description = r"Account: *(?P<bank_account>.*)"
|
||||
>>> line = rule.lines.new()
|
||||
>>> line.amount = "pending"
|
||||
>>> line.account = accounts['receivable']
|
||||
>>> rule.save()
|
||||
|
||||
Create a statement with non matching rule::
|
||||
|
||||
>>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
|
||||
>>> journal_number = StatementJournal(
|
||||
... name="Number",
|
||||
... journal=account_journal,
|
||||
... account=accounts['cash'],
|
||||
... validation='number_of_lines')
|
||||
>>> journal_number.save()
|
||||
|
||||
>>> statement = Statement(name="Test")
|
||||
>>> statement.journal = journal_number
|
||||
>>> statement.number_of_lines = 1
|
||||
>>> origin = statement.origins.new()
|
||||
>>> origin.date = today
|
||||
>>> origin.amount = Decimal('50.00')
|
||||
>>> origin.description = "Account: 123456"
|
||||
>>> statement.save()
|
||||
>>> len(statement.lines)
|
||||
0
|
||||
|
||||
Apply rules on statement::
|
||||
|
||||
>>> statement.click('apply_rules')
|
||||
>>> len(statement.lines)
|
||||
0
|
||||
|
||||
Create the bank account::
|
||||
|
||||
>>> bank_account = BankAccount(bank=bank)
|
||||
>>> bank_account.owners.append(Party(customer.id))
|
||||
>>> number = bank_account.numbers.new()
|
||||
>>> number.type = 'other'
|
||||
>>> number.number = "123456"
|
||||
>>> bank_account.save()
|
||||
|
||||
Apply rules on statement match::
|
||||
|
||||
>>> statement.click('apply_rules')
|
||||
>>> line, = statement.lines
|
||||
>>> assertEqual(line.party, customer)
|
||||
|
||||
>>> statement.click('validate_statement')
|
||||
>>> statement.click('post')
|
||||
|
||||
Remove the bank account::
|
||||
|
||||
>>> bank_account.delete()
|
||||
|
||||
Create a new statement with same keyword::
|
||||
|
||||
>>> statement = Statement(name="Test")
|
||||
>>> statement.journal = journal_number
|
||||
>>> statement.number_of_lines = 1
|
||||
>>> origin = statement.origins.new()
|
||||
>>> origin.date = today
|
||||
>>> origin.amount = Decimal('50.00')
|
||||
>>> origin.description = "Account: 123456"
|
||||
>>> statement.save()
|
||||
>>> len(statement.lines)
|
||||
0
|
||||
|
||||
Now a party is found::
|
||||
|
||||
>>> statement.click('apply_rules')
|
||||
>>> line, = statement.lines
|
||||
>>> line.amount
|
||||
Decimal('50.00')
|
||||
>>> assertEqual(line.party, customer)
|
||||
>>> assertEqual(line.account, accounts['receivable'])
|
||||
@@ -0,0 +1,93 @@
|
||||
=========================================================
|
||||
Account Statement Rule Keyword Payment Reference Scenario
|
||||
==========================================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> 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
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['account_statement_rule'],
|
||||
... create_company, create_chart)
|
||||
|
||||
>>> AccountConfiguration = Model.get('account.configuration')
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Rule = Model.get('account.statement.rule')
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> StatementJournal = Model.get('account.statement.journal')
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=today))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
>>> account_configuration = AccountConfiguration(1)
|
||||
>>> account_configuration.customer_payment_reference_number = 'invoice'
|
||||
>>> account_configuration.save()
|
||||
|
||||
Create a party::
|
||||
|
||||
>>> customer = Party(name="Customer", code="CUST-001")
|
||||
>>> customer.save()
|
||||
|
||||
Create an invoice::
|
||||
|
||||
>>> invoice = Invoice(party=customer)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('40.0000')
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
|
||||
Create statement rules::
|
||||
|
||||
>>> rule = Rule(name="Payment Reference Rule")
|
||||
>>> rule.description = r"Ref: *(?P<payment_reference>.*)"
|
||||
>>> line = rule.lines.new()
|
||||
>>> line.amount = "pending"
|
||||
>>> rule.save()
|
||||
|
||||
Create a statement::
|
||||
|
||||
>>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
|
||||
>>> journal_number = StatementJournal(
|
||||
... name="Number",
|
||||
... journal=account_journal,
|
||||
... account=accounts['cash'],
|
||||
... validation='number_of_lines')
|
||||
>>> journal_number.save()
|
||||
|
||||
>>> statement = Statement(name="Test")
|
||||
>>> statement.journal = journal_number
|
||||
>>> statement.number_of_lines = 1
|
||||
>>> origin = statement.origins.new()
|
||||
>>> origin.date = today
|
||||
>>> origin.amount = Decimal('50.00')
|
||||
>>> origin.description = "Ref: " + invoice.customer_payment_reference
|
||||
>>> statement.click('apply_rules')
|
||||
>>> line, = statement.lines
|
||||
>>> assertEqual(line.related_to, invoice)
|
||||
>>> assertEqual(line.party, customer)
|
||||
>>> assertEqual(line.account, invoice.account)
|
||||
@@ -0,0 +1,70 @@
|
||||
==================================================================
|
||||
Account Statement Rule Keyword Payment Reference Customer Scenario
|
||||
==================================================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['account_statement_rule'],
|
||||
... create_company, create_chart)
|
||||
|
||||
>>> AccountConfiguration = Model.get('account.configuration')
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Rule = Model.get('account.statement.rule')
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> StatementJournal = Model.get('account.statement.journal')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
>>> account_configuration = AccountConfiguration(1)
|
||||
>>> account_configuration.customer_payment_reference_number = 'party'
|
||||
>>> account_configuration.save()
|
||||
|
||||
Create a party::
|
||||
|
||||
>>> customer = Party(name="Customer", code="CUST-001")
|
||||
>>> customer.save()
|
||||
|
||||
Create statement rules::
|
||||
|
||||
>>> rule = Rule(name="Payment Reference Rule")
|
||||
>>> rule.description = r"Ref: *(?P<payment_reference>.*)"
|
||||
>>> line = rule.lines.new()
|
||||
>>> line.amount = "pending"
|
||||
>>> rule.save()
|
||||
|
||||
Create a statement::
|
||||
|
||||
>>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
|
||||
>>> journal_number = StatementJournal(
|
||||
... name="Number",
|
||||
... journal=account_journal,
|
||||
... account=accounts['cash'],
|
||||
... validation='number_of_lines')
|
||||
>>> journal_number.save()
|
||||
|
||||
>>> statement = Statement(name="Test")
|
||||
>>> statement.journal = journal_number
|
||||
>>> statement.number_of_lines = 1
|
||||
>>> origin = statement.origins.new()
|
||||
>>> origin.date = today
|
||||
>>> origin.amount = Decimal('50.00')
|
||||
>>> origin.description = "Ref: RF92CUST001"
|
||||
>>> statement.click('apply_rules')
|
||||
>>> line, = statement.lines
|
||||
>>> assertEqual(line.party, customer)
|
||||
@@ -0,0 +1,119 @@
|
||||
=======================================
|
||||
Account Statement Rule Keyword Scenario
|
||||
=======================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> 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, get_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'account_statement_rule', create_company, create_chart)
|
||||
|
||||
Get company::
|
||||
|
||||
>>> company = get_company()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=today))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
>>> receivable = accounts['receivable']
|
||||
>>> cash = accounts['cash']
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create statement rules::
|
||||
|
||||
>>> Rule = Model.get('account.statement.rule')
|
||||
|
||||
>>> rule = Rule(name="Party Rule")
|
||||
>>> rule.company = company
|
||||
>>> rule.description = r"Party: *(?P<party>.*)"
|
||||
>>> line = rule.lines.new()
|
||||
>>> line.amount = "pending"
|
||||
>>> line.account = receivable
|
||||
>>> rule.save()
|
||||
|
||||
Create a statement with non matching rule::
|
||||
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> StatementJournal = Model.get('account.statement.journal')
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
|
||||
>>> journal_number = StatementJournal(name="Number",
|
||||
... journal=account_journal,
|
||||
... account=cash,
|
||||
... validation='number_of_lines',
|
||||
... )
|
||||
>>> journal_number.save()
|
||||
|
||||
>>> statement = Statement(name="number origins")
|
||||
>>> statement.journal = journal_number
|
||||
>>> statement.number_of_lines = 1
|
||||
>>> origin = statement.origins.new()
|
||||
>>> origin.date = today
|
||||
>>> origin.amount = Decimal('50.00')
|
||||
>>> origin.description = "Party: %s-%s" % (customer.code, customer.name)
|
||||
>>> statement.save()
|
||||
>>> len(statement.lines)
|
||||
0
|
||||
|
||||
Apply rules on statement::
|
||||
|
||||
>>> statement.click('apply_rules')
|
||||
>>> len(statement.lines)
|
||||
0
|
||||
|
||||
Manually create a line for the origin::
|
||||
|
||||
>>> origin, = statement.origins
|
||||
>>> line = origin.lines.new()
|
||||
>>> line.party = customer
|
||||
>>> origin.save()
|
||||
>>> statement.click('validate_statement')
|
||||
>>> statement.click('post')
|
||||
|
||||
|
||||
Create a new statement with same keyword::
|
||||
|
||||
>>> statement = Statement(name="number origins")
|
||||
>>> statement.journal = journal_number
|
||||
>>> statement.number_of_lines = 1
|
||||
>>> origin = statement.origins.new()
|
||||
>>> origin.date = today
|
||||
>>> origin.amount = Decimal('50.00')
|
||||
>>> origin.description = "Party: %s-%s" % (customer.code, customer.name)
|
||||
>>> statement.save()
|
||||
>>> len(statement.lines)
|
||||
0
|
||||
|
||||
Now a party is found::
|
||||
|
||||
>>> statement.click('apply_rules')
|
||||
>>> line, = statement.lines
|
||||
>>> line.amount
|
||||
Decimal('50.00')
|
||||
>>> assertEqual(line.party, customer)
|
||||
>>> assertEqual(line.account, receivable)
|
||||
13
modules/account_statement_rule/tests/test_module.py
Normal file
13
modules/account_statement_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 AccountStatementRuleTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test Account Statement Rule module'
|
||||
module = 'account_statement_rule'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/account_statement_rule/tests/test_scenario.py
Normal file
8
modules/account_statement_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