Permalink
Browse files

[FIX] account_asset: use the last day of fiscal year for depreciation…

… date

The depreciation was hardcoded as starting the first of January.
If a user changed the configuration to set a different value than 31/12 it had
no impact.

In saas-11.3, this was improved to allow to configure the behaviour at 805f3a6

opw-1878927
  • Loading branch information...
mart-e committed Sep 7, 2018
1 parent 9511cb2 commit a307d4fc80f7cf2090c03292bc86f6f063e695c0
Showing with 8 additions and 1 deletion.
  1. +8 −1 addons/account_asset/models/account_asset.py
@@ -217,7 +217,14 @@ def compute_depreciation_board(self):
# depreciation_date = 1st of January of purchase year if annual valuation, 1st of
# purchase month in other cases
if self.method_period >= 12:
asset_date = datetime.strptime(self.date[:4] + '-01-01', DF).date()
if self.company_id.fiscalyear_last_month:
asset_date = date(year=int(self.date[:4]),
month=self.company_id.fiscalyear_last_month,
day=self.company_id.fiscalyear_last_day) + \
relativedelta(days=1) + \
relativedelta(year=int(self.date[:4])) # e.g. 2018-12-31 +1 -> 2019
else:
asset_date = datetime.strptime(self.date[:4] + '-01-01', DF).date()
else:
asset_date = datetime.strptime(self.date[:7] + '-01', DF).date()
# if we already have some previous validated entries, starting date isn't 1st January but last entry + method period

0 comments on commit a307d4f

Please sign in to comment.