mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-31 02:40:43 +02:00
fix: asset field precision check
(cherry picked from commit 92b8768ae2)
This commit is contained in:
@@ -308,12 +308,14 @@ class Asset(AccountsController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def validate_precision(self):
|
def validate_precision(self):
|
||||||
float_precision = cint(frappe.db.get_default("float_precision")) or 2
|
|
||||||
if self.gross_purchase_amount:
|
if self.gross_purchase_amount:
|
||||||
self.gross_purchase_amount = flt(self.gross_purchase_amount, float_precision)
|
self.gross_purchase_amount = flt(
|
||||||
|
self.gross_purchase_amount, self.precision("gross_purchase_amount")
|
||||||
|
)
|
||||||
|
|
||||||
if self.opening_accumulated_depreciation:
|
if self.opening_accumulated_depreciation:
|
||||||
self.opening_accumulated_depreciation = flt(
|
self.opening_accumulated_depreciation = flt(
|
||||||
self.opening_accumulated_depreciation, float_precision
|
self.opening_accumulated_depreciation, self.precision("opening_accumulated_depreciation")
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_asset_values(self):
|
def validate_asset_values(self):
|
||||||
@@ -487,11 +489,7 @@ class Asset(AccountsController):
|
|||||||
|
|
||||||
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"):
|
||||||
row.expected_value_after_useful_life = flt(
|
|
||||||
row.expected_value_after_useful_life, self.precision("gross_purchase_amount")
|
|
||||||
)
|
|
||||||
depr_schedule = get_depr_schedule(self.name, "Draft", row.finance_book)
|
depr_schedule = get_depr_schedule(self.name, "Draft", row.finance_book)
|
||||||
|
|
||||||
if not depr_schedule:
|
if not depr_schedule:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ class AssetDepreciationSchedule(Document):
|
|||||||
|
|
||||||
if not depreciation_amount:
|
if not depreciation_amount:
|
||||||
continue
|
continue
|
||||||
|
depreciation_amount = flt(depreciation_amount, asset_doc.precision("gross_purchase_amount"))
|
||||||
value_after_depreciation = flt(
|
value_after_depreciation = flt(
|
||||||
value_after_depreciation - flt(depreciation_amount),
|
value_after_depreciation - flt(depreciation_amount),
|
||||||
asset_doc.precision("gross_purchase_amount"),
|
asset_doc.precision("gross_purchase_amount"),
|
||||||
@@ -443,6 +444,7 @@ class AssetDepreciationSchedule(Document):
|
|||||||
depreciation_amount += flt(value_after_depreciation) - flt(
|
depreciation_amount += flt(value_after_depreciation) - flt(
|
||||||
row.expected_value_after_useful_life
|
row.expected_value_after_useful_life
|
||||||
)
|
)
|
||||||
|
depreciation_amount = flt(depreciation_amount, asset_doc.precision("gross_purchase_amount"))
|
||||||
skip_row = True
|
skip_row = True
|
||||||
|
|
||||||
if flt(depreciation_amount, asset_doc.precision("gross_purchase_amount")) > 0:
|
if flt(depreciation_amount, asset_doc.precision("gross_purchase_amount")) > 0:
|
||||||
@@ -517,10 +519,13 @@ class AssetDepreciationSchedule(Document):
|
|||||||
i - 1
|
i - 1
|
||||||
].accumulated_depreciation_amount
|
].accumulated_depreciation_amount
|
||||||
else:
|
else:
|
||||||
accumulated_depreciation = flt(self.opening_accumulated_depreciation)
|
accumulated_depreciation = flt(
|
||||||
|
self.opening_accumulated_depreciation,
|
||||||
|
asset_doc.precision("opening_accumulated_depreciation"),
|
||||||
|
)
|
||||||
|
|
||||||
depreciation_amount = flt(d.depreciation_amount, d.precision("depreciation_amount"))
|
value_after_depreciation -= flt(d.depreciation_amount)
|
||||||
value_after_depreciation -= flt(depreciation_amount)
|
value_after_depreciation = flt(value_after_depreciation, d.precision("depreciation_amount"))
|
||||||
|
|
||||||
# for the last row, if depreciation method = Straight Line
|
# for the last row, if depreciation method = Straight Line
|
||||||
if (
|
if (
|
||||||
@@ -530,12 +535,11 @@ class AssetDepreciationSchedule(Document):
|
|||||||
and not date_of_return
|
and not date_of_return
|
||||||
and not row.shift_based
|
and not row.shift_based
|
||||||
):
|
):
|
||||||
depreciation_amount += flt(
|
d.depreciation_amount += flt(
|
||||||
value_after_depreciation - flt(row.expected_value_after_useful_life),
|
value_after_depreciation - flt(row.expected_value_after_useful_life),
|
||||||
d.precision("depreciation_amount"),
|
d.precision("depreciation_amount"),
|
||||||
)
|
)
|
||||||
|
|
||||||
d.depreciation_amount = depreciation_amount
|
|
||||||
accumulated_depreciation += d.depreciation_amount
|
accumulated_depreciation += d.depreciation_amount
|
||||||
d.accumulated_depreciation_amount = flt(
|
d.accumulated_depreciation_amount = flt(
|
||||||
accumulated_depreciation, d.precision("accumulated_depreciation_amount")
|
accumulated_depreciation, d.precision("accumulated_depreciation_amount")
|
||||||
|
|||||||
Reference in New Issue
Block a user