first commit
This commit is contained in:
61
modules/account_statement_ofx/tests/OFX.txt
Normal file
61
modules/account_statement_ofx/tests/OFX.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
OFXHEADER:100
|
||||
DATA:OFXSGML
|
||||
VERSION:102
|
||||
SECURITY:NONE
|
||||
ENCODING:USASCII
|
||||
CHARSET:1252
|
||||
COMPRESSION:NONE
|
||||
OLDFILEUID:NONE
|
||||
NEWFILEUID:NONE
|
||||
<OFX>
|
||||
<SIGNONMSGSRSV1>
|
||||
<SONRS>
|
||||
<STATUS>
|
||||
<CODE>0
|
||||
<SEVERITY>INFO
|
||||
</STATUS>
|
||||
<DTSERVER>20180222052809
|
||||
<LANGUAGE>FRA
|
||||
<DTPROFUP>20180222052809
|
||||
<DTACCTUP>20180222052809
|
||||
</SONRS>
|
||||
</SIGNONMSGSRSV1>
|
||||
<BANKMSGSRSV1>
|
||||
<STMTTRNRS>
|
||||
<TRNUID>01234567890
|
||||
<STATUS>
|
||||
<CODE>0
|
||||
<SEVERITY>INFO
|
||||
</STATUS>
|
||||
<STMTRS>
|
||||
<CURDEF>EUR
|
||||
<BANKACCTFROM>
|
||||
<BANKID>12345</BANKID>
|
||||
<BRANCHID>00000</BRANCHID>
|
||||
<ACCTID>01234567890</ACCTID>
|
||||
<ACCTTYPE>CHECKING</ACCTTYPE>
|
||||
</BANKACCTFROM>
|
||||
<BANKTRANLIST>
|
||||
<DTSTART>20180212
|
||||
<DTEND>20180222
|
||||
<STMTTRN>
|
||||
<TRNTYPE>CREDIT
|
||||
<DTPOSTED>20180221
|
||||
<TRNAMT>+100.00
|
||||
<FITID>0001
|
||||
<NAME>MICHAEL SCOTT PAPER COMPANY
|
||||
<MEMO>COMMUNICATION
|
||||
</STMTTRN>
|
||||
</BANKTRANLIST>
|
||||
<LEDGERBAL>
|
||||
<BALAMT>500.00
|
||||
<DTASOF>20180222
|
||||
</LEDGERBAL>
|
||||
<AVAILBAL>
|
||||
<BALAMT>500.00
|
||||
<DTASOF>20180222
|
||||
</AVAILBAL>
|
||||
</STMTRS>
|
||||
</STMTTRNRS>
|
||||
</BANKMSGSRSV1>
|
||||
</OFX>
|
||||
2
modules/account_statement_ofx/tests/__init__.py
Normal file
2
modules/account_statement_ofx/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,107 @@
|
||||
==============================
|
||||
Account Statement OFX 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, assertEqual
|
||||
>>> from trytond.tools import file_open
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'account_statement_ofx',
|
||||
... 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')
|
||||
>>> michael_scott_paper = Party(name="Michael Scott Paper Company")
|
||||
>>> michael_scott_paper.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 = 'other'
|
||||
>>> bank_account_number.number = '01234567890'
|
||||
>>> 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,
|
||||
... validation='amount',
|
||||
... )
|
||||
>>> journal.save()
|
||||
|
||||
Import OFX file::
|
||||
|
||||
>>> statement_import = Wizard('account.statement.import')
|
||||
>>> with file_open('account_statement_ofx/tests/OFX.txt', mode='rb') as fp:
|
||||
... ofx = fp.read()
|
||||
>>> statement_import.form.file_ = ofx
|
||||
>>> statement_import.form.file_format = 'ofx'
|
||||
>>> statement_import.execute('import_')
|
||||
|
||||
Check Statement::
|
||||
|
||||
>>> Statement = Model.get('account.statement')
|
||||
>>> statement, = Statement.find([])
|
||||
>>> statement.name
|
||||
'01234567890'
|
||||
>>> statement.date
|
||||
datetime.date(2018, 2, 22)
|
||||
>>> statement.total_amount
|
||||
Decimal('100.00')
|
||||
>>> statement.number_of_lines
|
||||
1
|
||||
>>> statement.start_balance
|
||||
Decimal('400.00')
|
||||
>>> statement.end_balance
|
||||
Decimal('500.00')
|
||||
>>> len(statement.origins)
|
||||
1
|
||||
>>> origin, = statement.origins
|
||||
>>> origin.number
|
||||
'0001'
|
||||
>>> origin.date
|
||||
datetime.date(2018, 2, 21)
|
||||
>>> origin.amount
|
||||
Decimal('100.00')
|
||||
>>> assertEqual(origin.party, michael_scott_paper)
|
||||
>>> origin.description
|
||||
'COMMUNICATION'
|
||||
>>> origin.information['ofx_type']
|
||||
'credit'
|
||||
12
modules/account_statement_ofx/tests/test_module.py
Normal file
12
modules/account_statement_ofx/tests/test_module.py
Normal 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 AccountStatementOFXTestCase(ModuleTestCase):
|
||||
'Test Account Statement OFX module'
|
||||
module = 'account_statement_ofx'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/account_statement_ofx/tests/test_scenario.py
Normal file
8
modules/account_statement_ofx/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