Skip to content

Commit

Permalink
Merge pull request #8 from acsone/7.0-fix-asset-management-test-suite…
Browse files Browse the repository at this point in the history
…-2015-sbi

7.0 make asset management test suite FY independent
  • Loading branch information
luc-demeyer committed Jan 12, 2015
2 parents e03d342 + a93efea commit 23de62a
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions account_asset_management/tests/test_account_asset_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
##############################################################################

from datetime import datetime

import openerp.tests.common as common

import time
Expand All @@ -33,9 +35,8 @@ def setUp(self):
self.asset_model = self.registry('account.asset.asset')
self.dl_model = self.registry('account.asset.depreciation.line')

def test_1(self):
""" Compute depreciation boards and post assets for first year,
verify the depreciation values and values in parent assets. """
def test_1_hierarchy(self):
"""Test computations across the asset hierarchy."""
#
# first load demo assets and do some sanity checks
#
Expand Down Expand Up @@ -70,7 +71,7 @@ def test_1(self):
self.assertEquals(fa.asset_value, 11500)

#
# compute depreciation boards
# I compute the depreciation boards
#
self.asset_model.compute_depreciation_board(
self.cr, self.uid, [ict0.id, vehicle0.id])
Expand All @@ -82,7 +83,7 @@ def test_1(self):
self.assertEquals(vehicle0.depreciation_line_ids[1].amount, 2000)

#
# post first depreciation line
# I post the first depreciation line
#
ict0.validate()
ict0.depreciation_line_ids[1].create_move()
Expand All @@ -107,7 +108,7 @@ def test_1(self):
self.assertEquals(fa.value_residual, 9000)

#
# change parent and check values
# I change the parent and check values
#
ict0.write({'parent_id': vehicle.id})
ict.refresh()
Expand All @@ -120,8 +121,8 @@ def test_1(self):
self.assertEquals(fa.value_depreciated, 2500)
self.assertEquals(fa.value_residual, 9000)

def test_2(self):
""" prorata temporis depreciation """
def test_2_prorata_basic(self):
"""Prorata temporis depreciation basic test."""
asset_id = self.asset_model.create(self.cr, self.uid, {
'name': 'test asset',
'category_id': self.ref('account_asset_management.'
Expand All @@ -145,24 +146,25 @@ def test_2(self):
self.assertEquals(asset.depreciation_line_ids[6].amount, 55.55)
self.assertEquals(asset.depreciation_line_ids[-1].amount, 8.22)

def test_3(self):
""" prorata temporis depreciation with initial value in
previous year """
def test_3_proprata_init_prev_year(self):
"""Prorata temporis depreciation with init value in prev year."""
# I create an asset in current year
asset_id = self.asset_model.create(self.cr, self.uid, {
'name': 'test asset',
'category_id': self.ref('account_asset_management.'
'account_asset_category_car_5Y'),
'purchase_value': 3333,
'salvage_value': 0,
'date_start': time.strftime('2013-07-07'),
'date_start': '%d-07-07' % (datetime.now().year - 1,),
'method_number': 5,
'method_period': 'month',
'prorata': True,
})
# I create a initial depreciation line in previous year
self.dl_model.create(self.cr, self.uid, {
'asset_id': asset_id,
'amount': 325.08,
'line_date': time.strftime('2013-12-31'),
'line_date': '%d-12-31' % (datetime.now().year - 1,),
'type': 'depreciate',
'init_entry': True,
})
Expand All @@ -171,14 +173,15 @@ def test_3(self):
self.asset_model.compute_depreciation_board(
self.cr, self.uid, [asset.id])
asset.refresh()
# I check the depreciated value is the initial value
self.assertEquals(asset.value_depreciated, 325.08)
# I check computed values in the depreciation board
self.assertEquals(asset.depreciation_line_ids[2].amount, 55.55)
self.assertEquals(asset.depreciation_line_ids[3].amount, 55.55)
self.assertEquals(asset.depreciation_line_ids[-1].amount, 8.22)

def test_4(self):
""" prorata temporis depreciation with initial value in
curent year """
def test_4_prorata_init_cur_year(self):
"""Prorata temporis depreciation with init value in curent year."""
asset_id = self.asset_model.create(self.cr, self.uid, {
'name': 'test asset',
'category_id': self.ref('account_asset_management.'
Expand All @@ -202,7 +205,9 @@ def test_4(self):
self.asset_model.compute_depreciation_board(
self.cr, self.uid, [asset.id])
asset.refresh()
# I check the depreciated value is the initial value
self.assertEquals(asset.value_depreciated, 279.44)
# I check computed values in the depreciation board
self.assertEquals(asset.depreciation_line_ids[2].amount, 45.64)
self.assertEquals(asset.depreciation_line_ids[3].amount, 55.55)
self.assertEquals(asset.depreciation_line_ids[-1].amount, 8.22)

0 comments on commit 23de62a

Please sign in to comment.