fix: split and set value after depreciation

This commit is contained in:
khushi8112
2025-07-15 12:22:50 +05:30
parent c20c9031f4
commit 3488ba05eb

View File

@@ -1215,6 +1215,10 @@ def update_existing_asset(asset, remaining_qty, new_asset_name):
opening_accumulated_depreciation = flt( opening_accumulated_depreciation = flt(
(asset.opening_accumulated_depreciation * remaining_qty) / asset.asset_quantity (asset.opening_accumulated_depreciation * remaining_qty) / asset.asset_quantity
) )
value_after_depreciation = flt(
(asset.value_after_depreciation * remaining_qty) / asset.asset_quantity,
asset.precision("gross_purchase_amount"),
)
frappe.db.set_value( frappe.db.set_value(
"Asset", "Asset",
@@ -1222,6 +1226,7 @@ def update_existing_asset(asset, remaining_qty, new_asset_name):
{ {
"opening_accumulated_depreciation": opening_accumulated_depreciation, "opening_accumulated_depreciation": opening_accumulated_depreciation,
"gross_purchase_amount": remaining_gross_purchase_amount, "gross_purchase_amount": remaining_gross_purchase_amount,
"value_after_depreciation": value_after_depreciation,
"asset_quantity": remaining_qty, "asset_quantity": remaining_qty,
}, },
) )
@@ -1283,6 +1288,9 @@ def create_new_asset_after_split(asset, split_qty):
new_asset.opening_accumulated_depreciation = opening_accumulated_depreciation new_asset.opening_accumulated_depreciation = opening_accumulated_depreciation
new_asset.asset_quantity = split_qty new_asset.asset_quantity = split_qty
new_asset.split_from = asset.name new_asset.split_from = asset.name
new_asset.value_after_depreciation = flt(
(asset.value_after_depreciation * split_qty) / asset.asset_quantity, asset.precision("gross_purchase_amount")
)
for row in new_asset.get("finance_books"): for row in new_asset.get("finance_books"):
row.value_after_depreciation = flt((row.value_after_depreciation * split_qty) / asset.asset_quantity) row.value_after_depreciation = flt((row.value_after_depreciation * split_qty) / asset.asset_quantity)