[FIX] account_asset: compute_depreciation_board
The last depreciation date must be take from the last posted depreciation line. opw:679212
This commit is contained in:
@@ -168,8 +168,8 @@ class AccountAssetAsset(models.Model):
|
||||
# depreciation_date = 1st of January of purchase year
|
||||
asset_date = datetime.strptime(self.date[:4] + '-01-01', DF).date()
|
||||
# if we already have some previous validated entries, starting date isn't 1st January but last entry + method period
|
||||
if posted_depreciation_line_ids and posted_depreciation_line_ids[0].depreciation_date:
|
||||
last_depreciation_date = datetime.strptime(posted_depreciation_line_ids[0].depreciation_date, DF).date()
|
||||
if posted_depreciation_line_ids and posted_depreciation_line_ids[-1].depreciation_date:
|
||||
last_depreciation_date = datetime.strptime(posted_depreciation_line_ids[-1].depreciation_date, DF).date()
|
||||
depreciation_date = last_depreciation_date + relativedelta(months=+self.method_period)
|
||||
else:
|
||||
depreciation_date = asset_date
|
||||
@@ -179,6 +179,7 @@ class AccountAssetAsset(models.Model):
|
||||
total_days = (year % 4) and 365 or 366
|
||||
|
||||
undone_dotation_number = self._compute_board_undone_dotation_nb(depreciation_date, total_days)
|
||||
|
||||
for x in range(len(posted_depreciation_line_ids), undone_dotation_number):
|
||||
sequence = x + 1
|
||||
amount = self._compute_board_amount(sequence, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date)
|
||||
|
||||
Reference in New Issue
Block a user