first commit
This commit is contained in:
2
modules/account_asset/tests/__init__.py
Normal file
2
modules/account_asset/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_asset/tests/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/account_asset/tests/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
modules/account_asset/tests/__pycache__/tools.cpython-311.pyc
Normal file
BIN
modules/account_asset/tests/__pycache__/tools.cpython-311.pyc
Normal file
Binary file not shown.
275
modules/account_asset/tests/scenario_account_asset.rst
Normal file
275
modules/account_asset/tests/scenario_account_asset.rst
Normal file
@@ -0,0 +1,275 @@
|
||||
======================
|
||||
Account Asset Scenario
|
||||
======================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from dateutil.relativedelta import relativedelta
|
||||
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_asset.tests.tools import add_asset_accounts
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... create_payment_term, set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('account_asset', create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_asset_accounts(get_accounts())
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> asset_account = accounts['asset']
|
||||
>>> expense = accounts['expense']
|
||||
>>> depreciation_account = accounts['depreciation']
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.account_asset = asset_account
|
||||
>>> account_category.account_depreciation = depreciation_account
|
||||
>>> account_category.save()
|
||||
|
||||
Create an asset::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> asset_product = Product()
|
||||
>>> asset_template = ProductTemplate()
|
||||
>>> asset_template.name = 'Asset'
|
||||
>>> asset_template.type = 'assets'
|
||||
>>> asset_template.default_uom = unit
|
||||
>>> asset_template.list_price = Decimal('1000')
|
||||
>>> asset_template.account_category = account_category
|
||||
>>> asset_template.depreciable = True
|
||||
>>> asset_template.depreciation_duration = 24
|
||||
>>> asset_template.save()
|
||||
>>> asset_product, = asset_template.products
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.save()
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create payment term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Buy an asset::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> InvoiceLine = Model.get('account.invoice.line')
|
||||
>>> supplier_invoice = Invoice(type='in')
|
||||
>>> supplier_invoice.party = supplier
|
||||
>>> invoice_line = InvoiceLine()
|
||||
>>> supplier_invoice.lines.append(invoice_line)
|
||||
>>> invoice_line.product = asset_product
|
||||
>>> invoice_line.quantity = 1
|
||||
>>> invoice_line.unit_price = Decimal('1000')
|
||||
>>> assertEqual(invoice_line.account, asset_account)
|
||||
>>> supplier_invoice.invoice_date = fiscalyear.start_date
|
||||
>>> supplier_invoice.click('post')
|
||||
>>> supplier_invoice.state
|
||||
'posted'
|
||||
>>> invoice_line, = supplier_invoice.lines
|
||||
>>> (asset_account.debit, asset_account.credit)
|
||||
(Decimal('1000.00'), Decimal('0.00'))
|
||||
|
||||
Depreciate the asset::
|
||||
|
||||
>>> Asset = Model.get('account.asset')
|
||||
>>> asset = Asset()
|
||||
>>> asset.product = asset_product
|
||||
>>> asset.supplier_invoice_line = invoice_line
|
||||
>>> asset.value
|
||||
Decimal('1000.00')
|
||||
>>> assertEqual(asset.start_date, supplier_invoice.invoice_date)
|
||||
>>> assertEqual(asset.end_date,
|
||||
... (supplier_invoice.invoice_date + relativedelta(years=2, days=-1)))
|
||||
>>> asset.quantity
|
||||
1.0
|
||||
>>> assertEqual(asset.unit, unit)
|
||||
>>> asset.residual_value = Decimal('100')
|
||||
>>> asset.click('create_lines')
|
||||
>>> len(asset.lines)
|
||||
24
|
||||
>>> {l.depreciation for l in asset.lines}
|
||||
{Decimal('37.50')}
|
||||
>>> asset.lines[0].actual_value
|
||||
Decimal('962.50')
|
||||
>>> asset.lines[0].accumulated_depreciation
|
||||
Decimal('37.50')
|
||||
>>> asset.lines[11].actual_value
|
||||
Decimal('550.00')
|
||||
>>> asset.lines[11].accumulated_depreciation
|
||||
Decimal('450.00')
|
||||
>>> asset.lines[-1].actual_value
|
||||
Decimal('100.00')
|
||||
>>> asset.lines[-1].accumulated_depreciation
|
||||
Decimal('900.00')
|
||||
>>> asset.click('run')
|
||||
|
||||
Trying to close the period to check error::
|
||||
|
||||
>>> period = supplier_invoice.move.period
|
||||
>>> period.click('close')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AccessError: ...
|
||||
|
||||
Create Moves for 3 months::
|
||||
|
||||
>>> create_moves = Wizard('account.asset.create_moves')
|
||||
>>> create_moves.form.date = (supplier_invoice.invoice_date
|
||||
... + relativedelta(months=3))
|
||||
>>> create_moves.execute('create_moves')
|
||||
>>> depreciation_account.debit
|
||||
Decimal('0.00')
|
||||
>>> depreciation_account.credit
|
||||
Decimal('112.50')
|
||||
>>> expense.debit
|
||||
Decimal('112.50')
|
||||
>>> expense.credit
|
||||
Decimal('0.00')
|
||||
|
||||
Update the asset::
|
||||
|
||||
>>> update = Wizard('account.asset.update', [asset])
|
||||
>>> update.form.value = Decimal('1100.00')
|
||||
>>> update.execute('update_asset')
|
||||
>>> update.form.amount
|
||||
Decimal('100.00')
|
||||
>>> update.form.date = (supplier_invoice.invoice_date
|
||||
... + relativedelta(months=2))
|
||||
>>> assertEqual(update.form.latest_move_date, (supplier_invoice.invoice_date
|
||||
... + relativedelta(months=3, days=-1)))
|
||||
>>> assertEqual(update.form.next_depreciation_date, (supplier_invoice.invoice_date
|
||||
... + relativedelta(months=4, days=-1)))
|
||||
>>> update.execute('create_move')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValueError: ...
|
||||
|
||||
>>> update.form.date = (supplier_invoice.invoice_date
|
||||
... + relativedelta(months=3))
|
||||
>>> update.execute('create_move')
|
||||
>>> asset.reload()
|
||||
>>> asset.value
|
||||
Decimal('1100.00')
|
||||
>>> revision, = asset.revisions
|
||||
>>> revision.value
|
||||
Decimal('1100.00')
|
||||
>>> len(asset.lines)
|
||||
24
|
||||
>>> {l.depreciation for l in asset.lines[:3]}
|
||||
{Decimal('37.50')}
|
||||
>>> {l.depreciation for l in asset.lines[3:-1]}
|
||||
{Decimal('42.26')}
|
||||
>>> asset.lines[-1].depreciation
|
||||
Decimal('42.30')
|
||||
>>> depreciation_account.reload()
|
||||
>>> depreciation_account.debit
|
||||
Decimal('0.00')
|
||||
>>> depreciation_account.credit
|
||||
Decimal('112.50')
|
||||
>>> asset_account.reload()
|
||||
>>> asset_account.debit
|
||||
Decimal('1100.00')
|
||||
>>> asset_account.credit
|
||||
Decimal('0.00')
|
||||
>>> revenue.reload()
|
||||
>>> revenue.debit
|
||||
Decimal('0.00')
|
||||
>>> revenue.credit
|
||||
Decimal('100.00')
|
||||
>>> expense.reload()
|
||||
>>> expense.debit
|
||||
Decimal('112.50')
|
||||
>>> expense.credit
|
||||
Decimal('0.00')
|
||||
|
||||
Create Moves for 3 other months::
|
||||
|
||||
>>> create_moves = Wizard('account.asset.create_moves')
|
||||
>>> create_moves.form.date = (supplier_invoice.invoice_date
|
||||
... + relativedelta(months=6))
|
||||
>>> create_moves.execute('create_moves')
|
||||
>>> asset_account.reload()
|
||||
>>> asset_account.debit
|
||||
Decimal('1100.00')
|
||||
>>> asset_account.credit
|
||||
Decimal('0.00')
|
||||
>>> depreciation_account.reload()
|
||||
>>> depreciation_account.debit
|
||||
Decimal('0.00')
|
||||
>>> depreciation_account.credit
|
||||
Decimal('239.28')
|
||||
>>> expense.reload()
|
||||
>>> expense.debit
|
||||
Decimal('239.28')
|
||||
>>> expense.credit
|
||||
Decimal('0.00')
|
||||
|
||||
Sale the asset::
|
||||
|
||||
>>> customer_invoice = Invoice(type='out')
|
||||
>>> customer_invoice.party = customer
|
||||
>>> invoice_line = InvoiceLine()
|
||||
>>> customer_invoice.lines.append(invoice_line)
|
||||
>>> invoice_line.product = asset_product
|
||||
>>> invoice_line.asset = asset
|
||||
>>> invoice_line.quantity = 1
|
||||
>>> invoice_line.unit_price = Decimal('600')
|
||||
>>> assertEqual(invoice_line.account, revenue)
|
||||
>>> customer_invoice.click('post')
|
||||
>>> customer_invoice.state
|
||||
'posted'
|
||||
>>> asset.reload()
|
||||
>>> assertEqual(asset.customer_invoice_line, customer_invoice.lines[0])
|
||||
>>> revenue.reload()
|
||||
>>> revenue.debit
|
||||
Decimal('860.72')
|
||||
>>> revenue.credit
|
||||
Decimal('700.00')
|
||||
>>> asset_account.reload()
|
||||
>>> asset_account.debit
|
||||
Decimal('1100.00')
|
||||
>>> asset_account.credit
|
||||
Decimal('1100.00')
|
||||
>>> depreciation_account.reload()
|
||||
>>> depreciation_account.debit
|
||||
Decimal('239.28')
|
||||
>>> depreciation_account.credit
|
||||
Decimal('239.28')
|
||||
|
||||
Generate the asset report::
|
||||
|
||||
>>> print_depreciation_table = Wizard(
|
||||
... 'account.asset.print_depreciation_table')
|
||||
>>> print_depreciation_table.execute('print_')
|
||||
|
||||
Close periods::
|
||||
|
||||
>>> period.click('close')
|
||||
@@ -0,0 +1,140 @@
|
||||
==================================
|
||||
Account Asset Depreciated Scenario
|
||||
==================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from dateutil.relativedelta import relativedelta
|
||||
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_asset.tests.tools import add_asset_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
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('account_asset', create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_asset_accounts(get_accounts())
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> asset_account = accounts['asset']
|
||||
>>> expense = accounts['expense']
|
||||
>>> depreciation_account = accounts['depreciation']
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.account_asset = asset_account
|
||||
>>> account_category.account_depreciation = depreciation_account
|
||||
>>> account_category.save()
|
||||
|
||||
Create an asset::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> asset_template = ProductTemplate()
|
||||
>>> asset_template.name = 'Asset'
|
||||
>>> asset_template.type = 'assets'
|
||||
>>> asset_template.default_uom = unit
|
||||
>>> asset_template.list_price = Decimal('1000')
|
||||
>>> asset_template.account_category = account_category
|
||||
>>> asset_template.depreciable = True
|
||||
>>> asset_template.depreciation_duration = 24
|
||||
>>> asset_template.save()
|
||||
>>> asset_product, = asset_template.products
|
||||
|
||||
Depreciate the asset::
|
||||
|
||||
>>> Asset = Model.get('account.asset')
|
||||
>>> asset = Asset()
|
||||
>>> asset.product = asset_product
|
||||
>>> asset.value = Decimal('1500.00')
|
||||
>>> asset.depreciated_amount = Decimal('500.00')
|
||||
>>> asset.start_date = fiscalyear.start_date
|
||||
>>> asset.purchase_date = asset.start_date
|
||||
>>> asset.end_date = (asset.start_date
|
||||
... + relativedelta(years=2, days=-1))
|
||||
>>> asset.quantity = 1
|
||||
>>> asset.residual_value = Decimal('100')
|
||||
>>> asset.click('create_lines')
|
||||
>>> len(asset.lines)
|
||||
24
|
||||
>>> {l.depreciation for l in asset.lines}
|
||||
{Decimal('37.50')}
|
||||
>>> {l.acquired_value for l in asset.lines}
|
||||
{Decimal('1500.00')}
|
||||
>>> {l.depreciable_basis for l in asset.lines}
|
||||
{Decimal('900.00')}
|
||||
>>> asset.lines[0].actual_value
|
||||
Decimal('962.50')
|
||||
>>> asset.lines[0].accumulated_depreciation
|
||||
Decimal('537.50')
|
||||
>>> asset.lines[11].actual_value
|
||||
Decimal('550.00')
|
||||
>>> asset.lines[11].accumulated_depreciation
|
||||
Decimal('950.00')
|
||||
>>> asset.lines[-1].actual_value
|
||||
Decimal('100.00')
|
||||
>>> asset.lines[-1].accumulated_depreciation
|
||||
Decimal('1400.00')
|
||||
>>> asset.click('run')
|
||||
|
||||
Create Moves for 3 months::
|
||||
|
||||
>>> create_moves = Wizard('account.asset.create_moves')
|
||||
>>> create_moves.form.date = (asset.start_date
|
||||
... + relativedelta(months=3))
|
||||
>>> create_moves.execute('create_moves')
|
||||
>>> depreciation_account.reload()
|
||||
>>> depreciation_account.debit
|
||||
Decimal('0.00')
|
||||
>>> depreciation_account.credit
|
||||
Decimal('112.50')
|
||||
>>> expense.reload()
|
||||
>>> expense.debit
|
||||
Decimal('112.50')
|
||||
>>> expense.credit
|
||||
Decimal('0.00')
|
||||
|
||||
Close the asset::
|
||||
|
||||
>>> asset.click('close')
|
||||
>>> asset_account.reload()
|
||||
>>> asset_account.debit
|
||||
Decimal('0.00')
|
||||
>>> asset_account.credit
|
||||
Decimal('1500.00')
|
||||
>>> depreciation_account.reload()
|
||||
>>> depreciation_account.debit
|
||||
Decimal('612.50')
|
||||
>>> depreciation_account.credit
|
||||
Decimal('112.50')
|
||||
>>> expense.reload()
|
||||
>>> expense.debit
|
||||
Decimal('1000.00')
|
||||
>>> expense.credit
|
||||
Decimal('0.00')
|
||||
>>> revenue.reload()
|
||||
>>> revenue.debit
|
||||
Decimal('0.00')
|
||||
>>> revenue.credit
|
||||
Decimal('0.00')
|
||||
100
modules/account_asset/tests/scenario_purchase_asset.rst
Normal file
100
modules/account_asset/tests/scenario_purchase_asset.rst
Normal file
@@ -0,0 +1,100 @@
|
||||
=======================
|
||||
Purchase Asset Scenario
|
||||
=======================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> 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_asset.tests.tools import add_asset_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
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['account_asset', 'purchase'], create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_asset_accounts(get_accounts())
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> asset_account = accounts['asset']
|
||||
>>> expense = accounts['expense']
|
||||
>>> depreciation_account = accounts['depreciation']
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.account_asset = asset_account
|
||||
>>> account_category.account_depreciation = depreciation_account
|
||||
>>> account_category.save()
|
||||
|
||||
Create products::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> asset_template = ProductTemplate()
|
||||
>>> asset_template.name = 'Asset'
|
||||
>>> asset_template.type = 'assets'
|
||||
>>> asset_template.default_uom = unit
|
||||
>>> asset_template.list_price = Decimal('1000')
|
||||
>>> asset_template.depreciable = True
|
||||
>>> asset_template.purchasable = True
|
||||
>>> asset_template.account_category = account_category
|
||||
>>> asset_template.depreciation_duration = 24
|
||||
>>> asset_template.save()
|
||||
>>> service_product, = asset_template.products
|
||||
>>> asset_product, = asset_template.products
|
||||
>>> service_template = ProductTemplate()
|
||||
>>> service_template.name = 'Service'
|
||||
>>> service_template.type = 'service'
|
||||
>>> service_template.default_uom = unit
|
||||
>>> service_template.list_price = Decimal('10')
|
||||
>>> service_template.purchasable = True
|
||||
>>> service_template.account_category = account_category
|
||||
>>> service_template.save()
|
||||
>>> service_product, = service_template.products
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.save()
|
||||
|
||||
Purchase an asset mixed with services::
|
||||
|
||||
>>> Purchase = Model.get('purchase.purchase')
|
||||
>>> purchase = Purchase()
|
||||
>>> purchase.party = supplier
|
||||
>>> line = purchase.lines.new()
|
||||
>>> line.product = asset_product
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('500.0000')
|
||||
>>> line = purchase.lines.new()
|
||||
>>> line.product = service_product
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('5.0000')
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.click('process')
|
||||
>>> invoice, = purchase.invoices
|
||||
>>> asset_line, service_line = invoice.lines
|
||||
>>> assertEqual(asset_line.account, asset_account)
|
||||
>>> assertEqual(service_line.account, expense)
|
||||
50
modules/account_asset/tests/test_module.py
Normal file
50
modules/account_asset/tests/test_module.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import datetime as dt
|
||||
|
||||
from trytond.modules.account_asset.asset import normalized_delta
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AccountAssetTestCase(ModuleTestCase):
|
||||
'Test AccountAsset module'
|
||||
module = 'account_asset'
|
||||
extras = ['purchase']
|
||||
|
||||
def test_normalized_delta(self):
|
||||
"Test normalized delta"
|
||||
for start, end, delta in [
|
||||
(dt.date(2019, 1, 1), dt.date(2019, 12, 31),
|
||||
dt.timedelta(days=364)),
|
||||
(dt.date(2019, 1, 1), dt.date(2020, 1, 1),
|
||||
dt.timedelta(days=365)),
|
||||
(dt.date(2019, 1, 1), dt.date(2019, 3, 1),
|
||||
dt.timedelta(days=31 + 28)),
|
||||
(dt.date(2019, 2, 28), dt.date(2019, 3, 31),
|
||||
dt.timedelta(days=31)),
|
||||
(dt.date(2024, 1, 1), dt.date(2024, 2, 1),
|
||||
dt.timedelta(days=31)),
|
||||
(dt.date(2024, 1, 1), dt.date(2024, 3, 1),
|
||||
dt.timedelta(days=31 + 28)),
|
||||
(dt.date(2024, 2, 27), dt.date(2024, 3, 31),
|
||||
dt.timedelta(days=32)),
|
||||
(dt.date(2024, 2, 28), dt.date(2024, 3, 31),
|
||||
dt.timedelta(days=31)),
|
||||
(dt.date(2024, 2, 29), dt.date(2024, 3, 31),
|
||||
dt.timedelta(days=31)),
|
||||
(dt.date(2024, 3, 1), dt.date(2024, 4, 1),
|
||||
dt.timedelta(days=31)),
|
||||
(dt.date(2024, 1, 1), dt.date(2025, 1, 1),
|
||||
dt.timedelta(days=365)),
|
||||
(dt.date(2023, 1, 1), dt.date(2025, 1, 1),
|
||||
dt.timedelta(days=365 * 2)),
|
||||
(dt.date(2000, 1, 1), dt.date(2020, 1, 1),
|
||||
dt.timedelta(days=365 * 20)),
|
||||
]:
|
||||
with self.subTest(start=start, end=end):
|
||||
self.assertEqual(
|
||||
normalized_delta(start, end), delta)
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/account_asset/tests/test_scenario.py
Normal file
8
modules/account_asset/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)
|
||||
22
modules/account_asset/tests/tools.py
Normal file
22
modules/account_asset/tests/tools.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# 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
|
||||
from trytond.modules.company.tests.tools import get_company
|
||||
|
||||
|
||||
def add_asset_accounts(accounts, company=None, config=None):
|
||||
"Add asset kind to accounts"
|
||||
Account = Model.get('account.account', config=config)
|
||||
|
||||
if not company:
|
||||
company = get_company(config=config)
|
||||
|
||||
accounts['asset'], = Account.find([
|
||||
('company', '=', company.id),
|
||||
('code', '=', '1.5.3'),
|
||||
], limit=1)
|
||||
accounts['depreciation'], = Account.find([
|
||||
('company', '=', company.id),
|
||||
('code', '=', '1.4.1'),
|
||||
], limit=1)
|
||||
return accounts
|
||||
Reference in New Issue
Block a user