feat: total_asset_cost field (#38879)
This commit is contained in:
parent
a6ab53236e
commit
d370c60a6c
@ -35,6 +35,7 @@
|
|||||||
"purchase_receipt",
|
"purchase_receipt",
|
||||||
"purchase_invoice",
|
"purchase_invoice",
|
||||||
"available_for_use_date",
|
"available_for_use_date",
|
||||||
|
"total_asset_cost",
|
||||||
"column_break_23",
|
"column_break_23",
|
||||||
"gross_purchase_amount",
|
"gross_purchase_amount",
|
||||||
"asset_quantity",
|
"asset_quantity",
|
||||||
@ -529,6 +530,14 @@
|
|||||||
"label": "Capitalized In",
|
"label": "Capitalized In",
|
||||||
"options": "Asset Capitalization",
|
"options": "Asset Capitalization",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.docstatus > 0",
|
||||||
|
"fieldname": "total_asset_cost",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total Asset Cost",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 72,
|
"idx": 72,
|
||||||
@ -572,7 +581,7 @@
|
|||||||
"link_fieldname": "target_asset"
|
"link_fieldname": "target_asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2023-11-20 20:57:37.010467",
|
"modified": "2023-12-20 16:50:21.128595",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
|||||||
@ -111,6 +111,7 @@ class Asset(AccountsController):
|
|||||||
"Decapitalized",
|
"Decapitalized",
|
||||||
]
|
]
|
||||||
supplier: DF.Link | None
|
supplier: DF.Link | None
|
||||||
|
total_asset_cost: DF.Currency
|
||||||
total_number_of_depreciations: DF.Int
|
total_number_of_depreciations: DF.Int
|
||||||
value_after_depreciation: DF.Currency
|
value_after_depreciation: DF.Currency
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|||||||
@ -93,6 +93,9 @@ class AssetRepair(AccountsController):
|
|||||||
|
|
||||||
self.increase_asset_value()
|
self.increase_asset_value()
|
||||||
|
|
||||||
|
if self.capitalize_repair_cost:
|
||||||
|
self.asset_doc.total_asset_cost += self.repair_cost
|
||||||
|
|
||||||
if self.get("stock_consumption"):
|
if self.get("stock_consumption"):
|
||||||
self.check_for_stock_items_and_warehouse()
|
self.check_for_stock_items_and_warehouse()
|
||||||
self.decrease_stock_quantity()
|
self.decrease_stock_quantity()
|
||||||
@ -128,6 +131,9 @@ class AssetRepair(AccountsController):
|
|||||||
|
|
||||||
self.decrease_asset_value()
|
self.decrease_asset_value()
|
||||||
|
|
||||||
|
if self.capitalize_repair_cost:
|
||||||
|
self.asset_doc.total_asset_cost -= self.repair_cost
|
||||||
|
|
||||||
if self.get("stock_consumption"):
|
if self.get("stock_consumption"):
|
||||||
self.increase_stock_quantity()
|
self.increase_stock_quantity()
|
||||||
if self.get("capitalize_repair_cost"):
|
if self.get("capitalize_repair_cost"):
|
||||||
|
|||||||
@ -352,6 +352,7 @@ erpnext.patches.v14_0.create_accounting_dimensions_in_supplier_quotation
|
|||||||
erpnext.patches.v14_0.update_zero_asset_quantity_field
|
erpnext.patches.v14_0.update_zero_asset_quantity_field
|
||||||
execute:frappe.db.set_single_value("Buying Settings", "project_update_frequency", "Each Transaction")
|
execute:frappe.db.set_single_value("Buying Settings", "project_update_frequency", "Each Transaction")
|
||||||
execute:frappe.db.set_default("date_format", frappe.db.get_single_value("System Settings", "date_format"))
|
execute:frappe.db.set_default("date_format", frappe.db.get_single_value("System Settings", "date_format"))
|
||||||
|
erpnext.patches.v14_0.update_total_asset_cost_field
|
||||||
# below migration patch should always run last
|
# below migration patch should always run last
|
||||||
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
||||||
erpnext.stock.doctype.delivery_note.patches.drop_unused_return_against_index
|
erpnext.stock.doctype.delivery_note.patches.drop_unused_return_against_index
|
||||||
|
|||||||
17
erpnext/patches/v14_0/update_total_asset_cost_field.py
Normal file
17
erpnext/patches/v14_0/update_total_asset_cost_field.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
asset = frappe.qb.DocType("Asset")
|
||||||
|
frappe.qb.update(asset).set(asset.total_asset_cost, asset.gross_purchase_amount).run()
|
||||||
|
|
||||||
|
asset_repair_list = frappe.db.get_all(
|
||||||
|
"Asset Repair",
|
||||||
|
filters={"docstatus": 1, "repair_status": "Completed", "capitalize_repair_cost": 1},
|
||||||
|
fields=["asset", "repair_cost"],
|
||||||
|
)
|
||||||
|
|
||||||
|
for asset_repair in asset_repair_list:
|
||||||
|
frappe.qb.update(asset).set(
|
||||||
|
asset.total_asset_cost, asset.total_asset_cost + asset_repair.repair_cost
|
||||||
|
).where(asset.name == asset_repair.asset).run()
|
||||||
Loading…
x
Reference in New Issue
Block a user