first commit
This commit is contained in:
3
modules/account_fr/tests/FEC-previous.csv
Normal file
3
modules/account_fr/tests/FEC-previous.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
JournalCode JournalLib EcritureNum EcritureDate CompteNum CompteLib CompAuxNum CompAuxLib PieceRef PieceDate EcritureLib Debit Credit EcritureLet DateLet ValidDate Montantdevise Idevise
|
||||
REV Revenue 1 20170101 7011 Produits finis (ou groupe) A - 20170101 - 0,00 5,00 20170101
|
||||
REV Revenue 1 20170101 4111 Clients - Ventes de biens ou de prestations de services 2 Party - 20170101 - 5,00 0,00 20170101
|
||||
|
9
modules/account_fr/tests/FEC.csv
Normal file
9
modules/account_fr/tests/FEC.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
JournalCode JournalLib EcritureNum EcritureDate CompteNum CompteLib CompAuxNum CompAuxLib PieceRef PieceDate EcritureLib Debit Credit EcritureLet DateLet ValidDate Montantdevise Idevise
|
||||
OUV Balance Initiale 0 20180101 4111 Clients - Ventes de biens ou de prestations de services 2 Party - 20180101 - 5,00 0,00 20180101
|
||||
OUV Balance Initiale 0 20180101 7011 Produits finis (ou groupe) A - 20180101 - 0,00 5,00 20180101
|
||||
REV Revenue 1 20180101 7011 Produits finis (ou groupe) A - 20180101 - 0,00 10,00 20180101
|
||||
REV Revenue 1 20180101 4111 Clients - Ventes de biens ou de prestations de services 2 Party - 20180101 - 10,00 0,00 20180101
|
||||
REV Revenue 2 20180101 7011 Produits finis (ou groupe) A - 20180101 - 0,00 42,00 20180101
|
||||
REV Revenue 2 20180101 4111 Clients - Ventes de biens ou de prestations de services 2 Party - 20180101 - 42,00 0,00 1 {current_date} 20180101
|
||||
CASH Cash 3 20180101 5311 Caisse en monnaie nationale - 20180101 - 42,00 0,00 20180101
|
||||
CASH Cash 3 20180101 4111 Clients - Ventes de biens ou de prestations de services 2 Party - 20180101 - 0,00 42,00 1 {current_date} 20180101
|
||||
|
2
modules/account_fr/tests/__init__.py
Normal file
2
modules/account_fr/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.
|
||||
BIN
modules/account_fr/tests/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/account_fr/tests/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/account_fr/tests/__pycache__/test_module.cpython-311.pyc
Normal file
BIN
modules/account_fr/tests/__pycache__/test_module.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
modules/account_fr/tests/__pycache__/tools.cpython-311.pyc
Normal file
BIN
modules/account_fr/tests/__pycache__/tools.cpython-311.pyc
Normal file
Binary file not shown.
205
modules/account_fr/tests/scenario_fec.rst
Normal file
205
modules/account_fr/tests/scenario_fec.rst
Normal file
@@ -0,0 +1,205 @@
|
||||
============
|
||||
FEC Scenario
|
||||
============
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> import io
|
||||
>>> import os
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> from trytond.modules.account.tests.tools import create_fiscalyear
|
||||
>>> from trytond.modules.account_fr.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
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('account_fr', create_company, create_chart)
|
||||
|
||||
Setup company::
|
||||
|
||||
>>> company = get_company()
|
||||
>>> siren = company.party.identifiers.new(type='fr_siren')
|
||||
>>> siren.code = '820043784'
|
||||
>>> company.party.save()
|
||||
|
||||
Create last year fiscal year::
|
||||
|
||||
>>> fiscalyear_previous = create_fiscalyear(
|
||||
... today=(dt.date(2017, 1, 1), dt.date(2017, 12, 31)))
|
||||
>>> fiscalyear_previous.click('create_period')
|
||||
>>> period_previous = fiscalyear_previous.periods[0]
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = create_fiscalyear(
|
||||
... today=(dt.date(2018, 1, 1), dt.date(2018, 12, 31)))
|
||||
>>> fiscalyear.click('create_period')
|
||||
>>> period = fiscalyear.periods[0]
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
>>> receivable = accounts['receivable']
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> expense = accounts['expense']
|
||||
>>> cash = accounts['cash']
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> party = Party(name='Party')
|
||||
>>> party.save()
|
||||
|
||||
Create some moves::
|
||||
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> Move = Model.get('account.move')
|
||||
>>> journal_revenue, = Journal.find([
|
||||
... ('code', '=', 'REV'),
|
||||
... ])
|
||||
>>> journal_cash, = Journal.find([
|
||||
... ('code', '=', 'CASH'),
|
||||
... ])
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period_previous
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period_previous.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = revenue
|
||||
>>> line.credit = Decimal(5)
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable
|
||||
>>> line.debit = Decimal(5)
|
||||
>>> line.party = party
|
||||
>>> move.save()
|
||||
>>> Move.write([move.id], {
|
||||
... 'post_date': period_previous.start_date,
|
||||
... 'number': '1',
|
||||
... }, config.context)
|
||||
>>> move.click('post')
|
||||
|
||||
With an empty line::
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = revenue
|
||||
>>> line.credit = Decimal(10)
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable
|
||||
>>> line.debit = Decimal(10)
|
||||
>>> line.party = party
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = cash
|
||||
>>> line.debit = line.credit = Decimal(0)
|
||||
>>> move.save()
|
||||
>>> Move.write([move.id], {
|
||||
... 'post_date': period.start_date,
|
||||
... 'number': '1',
|
||||
... }, config.context)
|
||||
>>> move.click('post')
|
||||
|
||||
With reconciliation::
|
||||
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_revenue
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = revenue
|
||||
>>> line.credit = Decimal(42)
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable
|
||||
>>> line.debit = Decimal(42)
|
||||
>>> line.party = party
|
||||
>>> move.save()
|
||||
>>> reconcile1, = [l for l in move.lines if l.account == receivable]
|
||||
>>> Move.write([move.id], {
|
||||
... 'post_date': period.start_date,
|
||||
... 'number': '2',
|
||||
... }, config.context)
|
||||
>>> move.click('post')
|
||||
>>> move = Move()
|
||||
>>> move.period = period
|
||||
>>> move.journal = journal_cash
|
||||
>>> move.date = period.start_date
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = cash
|
||||
>>> line.debit = Decimal(42)
|
||||
>>> line = move.lines.new()
|
||||
>>> line.account = receivable
|
||||
>>> line.credit = Decimal(42)
|
||||
>>> line.party = party
|
||||
>>> move.save()
|
||||
>>> Move.write([move.id], {
|
||||
... 'post_date': period.start_date,
|
||||
... 'number': '3',
|
||||
... }, config.context)
|
||||
>>> move.click('post')
|
||||
>>> reconcile2, = [l for l in move.lines if l.account == receivable]
|
||||
>>> reconcile_lines = Wizard('account.move.reconcile_lines',
|
||||
... [reconcile1, reconcile2])
|
||||
>>> reconcile_lines.state
|
||||
'end'
|
||||
>>> reconcile_date = reconcile1.reconciliation.create_date
|
||||
|
||||
Balance non-deferral::
|
||||
|
||||
>>> Period = Model.get('account.period')
|
||||
>>> Account = Model.get('account.account')
|
||||
|
||||
>>> journal_closing = Journal(name="Closing", code="CLO", type='situation')
|
||||
>>> journal_closing.save()
|
||||
|
||||
>>> period_closing = Period(name="Closing")
|
||||
>>> period_closing.fiscalyear = fiscalyear
|
||||
>>> period_closing.start_date = fiscalyear.end_date
|
||||
>>> period_closing.end_date = fiscalyear.end_date
|
||||
>>> period_closing.type = 'adjustment'
|
||||
>>> period_closing.save()
|
||||
|
||||
>>> balance_non_deferral = Wizard('account.fiscalyear.balance_non_deferral')
|
||||
>>> balance_non_deferral.form.fiscalyear = fiscalyear
|
||||
>>> balance_non_deferral.form.journal = journal_closing
|
||||
>>> balance_non_deferral.form.period = period_closing
|
||||
>>> balance_non_deferral.form.credit_account, = Account.find([
|
||||
... ('code', '=', '120'),
|
||||
... ])
|
||||
>>> balance_non_deferral.form.debit_account, = Account.find([
|
||||
... ('code', '=', '129'),
|
||||
... ])
|
||||
>>> balance_non_deferral.execute('balance')
|
||||
>>> move, = balance_non_deferral.actions[0]
|
||||
>>> move.click('post')
|
||||
|
||||
Generate FEC::
|
||||
|
||||
>>> FEC = Wizard('account.fr.fec')
|
||||
>>> FEC.form.fiscalyear = fiscalyear
|
||||
>>> FEC.form.deferral_period = period_closing
|
||||
>>> FEC.execute('generate')
|
||||
>>> FEC.form.filename
|
||||
>>> file = os.path.join(os.path.dirname(__file__), 'FEC.csv')
|
||||
>>> with io.open(file, mode='rb') as fp:
|
||||
... template = fp.read().decode('utf-8')
|
||||
>>> current_date = reconcile_date.strftime('%Y%m%d')
|
||||
>>> template = template.format(
|
||||
... current_date=current_date,
|
||||
... )
|
||||
>>> assertEqual(FEC.form.file.decode('utf-8'), template)
|
||||
|
||||
Generate FEC for previous fiscal year::
|
||||
|
||||
>>> FEC = Wizard('account.fr.fec')
|
||||
>>> FEC.form.fiscalyear = fiscalyear_previous
|
||||
>>> FEC.execute('generate')
|
||||
>>> file = os.path.join(os.path.dirname(__file__), 'FEC-previous.csv')
|
||||
>>> with io.open(file, mode='rb') as fp:
|
||||
... assertEqual(FEC.form.file.decode('utf-8'), fp.read().decode('utf-8'))
|
||||
20
modules/account_fr/tests/test_module.py
Normal file
20
modules/account_fr/tests/test_module.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# 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.account.tests import create_chart
|
||||
from trytond.modules.company.tests import create_company, set_company
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class AccountFRTestCase(ModuleTestCase):
|
||||
'Test Account FR module'
|
||||
module = 'account_fr'
|
||||
|
||||
@with_transaction()
|
||||
def test_create_chart(self):
|
||||
company = create_company()
|
||||
with set_company(company):
|
||||
create_chart(company, chart=self.module + '.root')
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/account_fr/tests/test_scenario.py
Normal file
8
modules/account_fr/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)
|
||||
70
modules/account_fr/tests/tools.py
Normal file
70
modules/account_fr/tests/tools.py
Normal file
@@ -0,0 +1,70 @@
|
||||
# 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 proteus import Model, Wizard
|
||||
from trytond.modules.company.tests.tools import get_company
|
||||
|
||||
__all__ = ['create_chart', 'get_accounts']
|
||||
|
||||
|
||||
def create_chart(company=None, config=None):
|
||||
"Create chart of accounts"
|
||||
AccountTemplate = Model.get('account.account.template', config=config)
|
||||
ModelData = Model.get('ir.model.data', config=config)
|
||||
|
||||
if not company:
|
||||
company = get_company(config=config)
|
||||
chart_id = ModelData.get_id('account_fr', 'root', config.context)
|
||||
|
||||
account_template = AccountTemplate(chart_id)
|
||||
|
||||
create_chart = Wizard('account.create_chart', config=config)
|
||||
create_chart.execute('account')
|
||||
create_chart.form.account_template = account_template
|
||||
create_chart.form.company = company
|
||||
create_chart.execute('create_account')
|
||||
|
||||
accounts = get_accounts(company, config=config)
|
||||
|
||||
create_chart.form.account_receivable = accounts['receivable']
|
||||
create_chart.form.account_payable = accounts['payable']
|
||||
create_chart.execute('create_properties')
|
||||
return create_chart
|
||||
|
||||
|
||||
def get_accounts(company=None, config=None):
|
||||
"Return accounts per kind"
|
||||
Account = Model.get('account.account', config=config)
|
||||
|
||||
if not company:
|
||||
company = get_company(config=config)
|
||||
|
||||
accounts = {}
|
||||
accounts['receivable'], = Account.find([
|
||||
('type.receivable', '=', True),
|
||||
('company', '=', company.id),
|
||||
('code', '=', '4111'),
|
||||
], limit=1)
|
||||
accounts['payable'], = Account.find([
|
||||
('type.payable', '=', True),
|
||||
('company', '=', company.id),
|
||||
('code', '=', '4011'),
|
||||
], limit=1)
|
||||
accounts['revenue'], = Account.find([
|
||||
('type.revenue', '=', True),
|
||||
('company', '=', company.id),
|
||||
('code', '=', '7011'),
|
||||
], limit=1)
|
||||
accounts['expense'], = Account.find([
|
||||
('type.expense', '=', True),
|
||||
('company', '=', company.id),
|
||||
('code', '=', '6071'),
|
||||
], limit=1)
|
||||
accounts['cash'], = Account.find([
|
||||
('company', '=', company.id),
|
||||
('code', '=', '5311'),
|
||||
])
|
||||
accounts['tax'], = Account.find([
|
||||
('company', '=', company.id),
|
||||
('code', '=', '44558'),
|
||||
])
|
||||
return accounts
|
||||
Reference in New Issue
Block a user