mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-28 17:34:47 +00:00
fix(Asset): Fix depreciation_amount calculation
This commit is contained in:
@@ -205,8 +205,7 @@ class Asset(AccountsController):
|
|||||||
# If depreciation is already completed (for double declining balance)
|
# If depreciation is already completed (for double declining balance)
|
||||||
if skip_row: continue
|
if skip_row: continue
|
||||||
|
|
||||||
depreciation_amount = self.get_depreciation_amount(value_after_depreciation,
|
depreciation_amount = get_depreciation_amount(self, value_after_depreciation, d)
|
||||||
d.total_number_of_depreciations, d)
|
|
||||||
|
|
||||||
if not has_pro_rata or n < cint(number_of_pending_depreciations) - 1:
|
if not has_pro_rata or n < cint(number_of_pending_depreciations) - 1:
|
||||||
schedule_date = add_months(d.depreciation_start_date,
|
schedule_date = add_months(d.depreciation_start_date,
|
||||||
@@ -377,24 +376,6 @@ class Asset(AccountsController):
|
|||||||
def get_value_after_depreciation(self, idx):
|
def get_value_after_depreciation(self, idx):
|
||||||
return flt(self.get('finance_books')[cint(idx)-1].value_after_depreciation)
|
return flt(self.get('finance_books')[cint(idx)-1].value_after_depreciation)
|
||||||
|
|
||||||
def get_depreciation_amount(self, depreciable_value, total_number_of_depreciations, row):
|
|
||||||
precision = self.precision("gross_purchase_amount")
|
|
||||||
|
|
||||||
if row.depreciation_method in ("Straight Line", "Manual"):
|
|
||||||
depreciation_left = (cint(row.total_number_of_depreciations) - cint(self.number_of_depreciations_booked))
|
|
||||||
|
|
||||||
if not depreciation_left:
|
|
||||||
frappe.msgprint(_("All the depreciations has been booked"))
|
|
||||||
depreciation_amount = flt(row.expected_value_after_useful_life)
|
|
||||||
return depreciation_amount
|
|
||||||
|
|
||||||
depreciation_amount = (flt(row.value_after_depreciation) -
|
|
||||||
flt(row.expected_value_after_useful_life)) / depreciation_left
|
|
||||||
else:
|
|
||||||
depreciation_amount = flt(depreciable_value * (flt(row.rate_of_depreciation) / 100), precision)
|
|
||||||
|
|
||||||
return depreciation_amount
|
|
||||||
|
|
||||||
def validate_expected_value_after_useful_life(self):
|
def validate_expected_value_after_useful_life(self):
|
||||||
for row in self.get('finance_books'):
|
for row in self.get('finance_books'):
|
||||||
accumulated_depreciation_after_full_schedule = [d.accumulated_depreciation_amount
|
accumulated_depreciation_after_full_schedule = [d.accumulated_depreciation_amount
|
||||||
@@ -791,3 +772,19 @@ def get_total_days(date, frequency):
|
|||||||
cint(frequency) * -1)
|
cint(frequency) * -1)
|
||||||
|
|
||||||
return date_diff(date, period_start_date)
|
return date_diff(date, period_start_date)
|
||||||
|
|
||||||
|
@erpnext.allow_regional
|
||||||
|
def get_depreciation_amount(asset, depreciable_value, row):
|
||||||
|
depreciation_left = flt(row.total_number_of_depreciations) - flt(asset.number_of_depreciations_booked)
|
||||||
|
|
||||||
|
if row.depreciation_method in ("Straight Line", "Manual"):
|
||||||
|
if not asset.to_date:
|
||||||
|
depreciation_amount = (flt(row.value_after_depreciation) -
|
||||||
|
flt(row.expected_value_after_useful_life)) / depreciation_left
|
||||||
|
else:
|
||||||
|
depreciation_amount = (flt(row.value_after_depreciation) -
|
||||||
|
flt(row.expected_value_after_useful_life)) / (date_diff(asset.to_date, asset.available_for_use_date) / 365)
|
||||||
|
else:
|
||||||
|
depreciation_amount = flt(depreciable_value * (flt(row.rate_of_depreciation) / 100))
|
||||||
|
|
||||||
|
return depreciation_amount
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ class AssetRepair(Document):
|
|||||||
extra_months = self.increase_in_asset_life % row.frequency_of_depreciation
|
extra_months = self.increase_in_asset_life % row.frequency_of_depreciation
|
||||||
if extra_months != 0:
|
if extra_months != 0:
|
||||||
self.calculate_last_schedule_date(asset, row, extra_months)
|
self.calculate_last_schedule_date(asset, row, extra_months)
|
||||||
# fix depreciation amount
|
|
||||||
|
|
||||||
asset.prepare_depreciation_data()
|
asset.prepare_depreciation_data()
|
||||||
asset.save()
|
asset.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user