fix: division by zero in asset Depereciation (#18637)
* fix: division by zero in asset Depereciation * fix: requested changes
This commit is contained in:
parent
7ff82fccf3
commit
210317c0b5
@ -255,9 +255,15 @@ class Asset(AccountsController):
|
|||||||
precision = self.precision("gross_purchase_amount")
|
precision = self.precision("gross_purchase_amount")
|
||||||
|
|
||||||
if row.depreciation_method in ("Straight Line", "Manual"):
|
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) -
|
depreciation_amount = (flt(row.value_after_depreciation) -
|
||||||
flt(row.expected_value_after_useful_life)) / (cint(row.total_number_of_depreciations) -
|
flt(row.expected_value_after_useful_life)) / depreciation_left
|
||||||
cint(self.number_of_depreciations_booked))
|
|
||||||
else:
|
else:
|
||||||
depreciation_amount = flt(depreciable_value * (flt(row.rate_of_depreciation) / 100), precision)
|
depreciation_amount = flt(depreciable_value * (flt(row.rate_of_depreciation) / 100), precision)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user