first commit
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
===============================
|
||||
Account Statement Coda Scenario
|
||||
===============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from functools import partial
|
||||
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> 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
|
||||
>>> from trytond.tools import file_open
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'account_statement_coda',
|
||||
... partial(create_company, currency='EUR'), create_chart)
|
||||
|
||||
Get company::
|
||||
|
||||
>>> company = get_company()
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
>>> cash = accounts['cash']
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
>>> bank_party = Party(name="Bank")
|
||||
>>> bank_party.save()
|
||||
|
||||
Create Bank Account::
|
||||
|
||||
>>> Bank = Model.get('bank')
|
||||
>>> BankAccount = Model.get('bank.account')
|
||||
|
||||
>>> bank = Bank()
|
||||
>>> bank.party = bank_party
|
||||
>>> bank.save()
|
||||
>>> bank_account = BankAccount()
|
||||
>>> bank_account.bank = bank
|
||||
>>> bank_account.owners.append(Party(company.party.id))
|
||||
>>> bank_account.currency = company.currency
|
||||
>>> bank_account_number = bank_account.numbers.new()
|
||||
>>> bank_account_number.type = 'iban'
|
||||
>>> bank_account_number.number = 'BE47435000000080'
|
||||
>>> bank_account.save()
|
||||
|
||||
Create Statement Journal::
|
||||
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> StatementJournal = Model.get('account.statement.journal')
|
||||
|
||||
>>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
|
||||
>>> journal = StatementJournal(name="Bank",
|
||||
... journal=account_journal,
|
||||
... account=cash,
|
||||
... bank_account=bank_account,
|
||||
... )
|
||||
>>> journal.save()
|
||||
|
||||
Import CODA file::
|
||||
|
||||
>>> statement_import = Wizard('account.statement.import')
|
||||
>>> with file_open('account_statement_coda/tests/CODA.txt', mode='rb') as fp:
|
||||
... coda = fp.read()
|
||||
>>> statement_import.form.file_ = coda
|
||||
>>> statement_import.form.file_format = 'coda'
|
||||
>>> statement_import.execute('import_')
|
||||
|
||||
Check Statement::
|
||||
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> statement, = Statement.find([])
|
||||
>>> statement.name
|
||||
'001'
|
||||
>>> statement.date
|
||||
datetime.date(2017, 8, 1)
|
||||
>>> statement.start_balance
|
||||
Decimal('0')
|
||||
>>> statement.end_balance
|
||||
Decimal('100')
|
||||
>>> statement.total_amount
|
||||
Decimal('100')
|
||||
>>> statement.number_of_lines
|
||||
1
|
||||
>>> len(statement.origins)
|
||||
1
|
||||
>>> origin, = statement.origins
|
||||
>>> origin.number
|
||||
'0001'
|
||||
>>> origin.date
|
||||
datetime.date(2017, 7, 19)
|
||||
>>> origin.amount
|
||||
Decimal('100')
|
||||
>>> origin.description
|
||||
'COMMUNICATION'
|
||||
>>> origin.information['coda_bank_reference']
|
||||
'REF BANK '
|
||||
Reference in New Issue
Block a user