85 lines
2.3 KiB
ReStructuredText
85 lines
2.3 KiB
ReStructuredText
====================================
|
|
Account Reconcile Automatic Scenario
|
|
====================================
|
|
|
|
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.company.tests.tools import create_company
|
|
>>> from trytond.tests.tools import activate_modules
|
|
|
|
Activate modules::
|
|
|
|
>>> config = activate_modules('account', create_company, create_chart)
|
|
|
|
>>> Journal = Model.get('account.journal')
|
|
>>> Line = Model.get('account.move.line')
|
|
>>> Move = Model.get('account.move')
|
|
>>> Party = Model.get('party.party')
|
|
|
|
Create fiscal year::
|
|
|
|
>>> fiscalyear = create_fiscalyear()
|
|
>>> fiscalyear.click('create_period')
|
|
>>> period = fiscalyear.periods[0]
|
|
|
|
Get accounts::
|
|
|
|
>>> accounts = get_accounts()
|
|
|
|
Create parties::
|
|
|
|
>>> customer = Party(name="Customer")
|
|
>>> customer.save()
|
|
|
|
Create Moves to reconcile::
|
|
|
|
>>> journal_revenue, = Journal.find([
|
|
... ('code', '=', 'REV'),
|
|
... ])
|
|
>>> journal_cash, = Journal.find([
|
|
... ('code', '=', 'CASH'),
|
|
... ])
|
|
|
|
>>> 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(42)
|
|
>>> line = move.lines.new()
|
|
>>> line.account = accounts['receivable']
|
|
>>> line.debit = Decimal(42)
|
|
>>> line.party = customer
|
|
>>> move.save()
|
|
|
|
>>> 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(42)
|
|
>>> line = move.lines.new()
|
|
>>> line.account = accounts['receivable']
|
|
>>> line.credit = Decimal(42)
|
|
>>> line.party = customer
|
|
>>> move.save()
|
|
|
|
Run Reconcile wizard::
|
|
|
|
>>> reconcile = Wizard('account.reconcile')
|
|
>>> reconcile.form.automatic = True
|
|
>>> reconcile.execute('setup')
|
|
|
|
>>> lines = Line.find([('account', '=', accounts['receivable'].id)])
|
|
>>> len(lines)
|
|
2
|
|
>>> all(l.reconciliation for l in lines)
|
|
True
|