From 688431641738e5c5d6f8fa17f3a1e0e969aab3aa Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Wed, 8 Jan 2025 20:44:12 +0530 Subject: [PATCH 1/2] chore: removal of decapitalization feature (#45162) * chore: removal of decapitalization feature * fix: rearrangement of asset capitalization doctype fields (cherry picked from commit 7ea73d826501d062a65544f81a8b38773ab2cdff) # Conflicts: # erpnext/assets/doctype/asset_capitalization/asset_capitalization.json --- .../doctype/sales_invoice/sales_invoice.py | 2 +- erpnext/assets/doctype/asset/asset.json | 2 +- erpnext/assets/doctype/asset/asset.py | 1 - erpnext/assets/doctype/asset/asset_list.js | 4 +- erpnext/assets/doctype/asset/depreciation.py | 2 +- .../asset_capitalization.js | 8 +- .../asset_capitalization.json | 85 ++++--------- .../asset_capitalization.py | 106 +++------------- .../test_asset_capitalization.py | 114 ------------------ .../fixed_asset_register.py | 8 +- 10 files changed, 52 insertions(+), 280 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index cb501c1ffbca..279cee195019 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -367,7 +367,7 @@ def validate_fixed_asset(self): if self.update_stock: frappe.throw(_("'Update Stock' cannot be checked for fixed asset sale")) - elif asset.status in ("Scrapped", "Cancelled", "Capitalized", "Decapitalized") or ( + elif asset.status in ("Scrapped", "Cancelled", "Capitalized") or ( asset.status == "Sold" and not self.is_return ): frappe.throw( diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index fca0cf7877a8..e28eab9ed137 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -378,7 +378,7 @@ "in_standard_filter": 1, "label": "Status", "no_copy": 1, - "options": "Draft\nSubmitted\nPartially Depreciated\nFully Depreciated\nSold\nScrapped\nIn Maintenance\nOut of Order\nIssue\nReceipt\nCapitalized\nDecapitalized\nWork In Progress", + "options": "Draft\nSubmitted\nPartially Depreciated\nFully Depreciated\nSold\nScrapped\nIn Maintenance\nOut of Order\nIssue\nReceipt\nCapitalized\nWork In Progress", "read_only": 1 }, { diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 8aa8c0ba6ac2..994f36ae1f26 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -111,7 +111,6 @@ class Asset(AccountsController): "Issue", "Receipt", "Capitalized", - "Decapitalized", "Work In Progress", ] supplier: DF.Link | None diff --git a/erpnext/assets/doctype/asset/asset_list.js b/erpnext/assets/doctype/asset/asset_list.js index 0086333a96b3..8b0d289dab09 100644 --- a/erpnext/assets/doctype/asset/asset_list.js +++ b/erpnext/assets/doctype/asset/asset_list.js @@ -10,8 +10,8 @@ frappe.listview_settings["Asset"] = { return [__("Sold"), "green", "status,=,Sold"]; } else if (doc.status === "Work In Progress") { return [__("Work In Progress"), "orange", "status,=,Work In Progress"]; - } else if (["Capitalized", "Decapitalized"].includes(doc.status)) { - return [__(doc.status), "grey", "status,=," + doc.status]; + } else if (doc.status === "Capitalized") { + return [__("Capitalized"), "grey", "status,=,Capitalized"]; } else if (doc.status === "Scrapped") { return [__("Scrapped"), "grey", "status,=,Scrapped"]; } else if (doc.status === "In Maintenance") { diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index cc8defc5fe6d..6ad0631135ab 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -436,7 +436,7 @@ def scrap_asset(asset_name): if asset.docstatus != 1: frappe.throw(_("Asset {0} must be submitted").format(asset.name)) - elif asset.status in ("Cancelled", "Sold", "Scrapped", "Capitalized", "Decapitalized"): + elif asset.status in ("Cancelled", "Sold", "Scrapped", "Capitalized"): frappe.throw(_("Asset {0} cannot be scrapped, as it is already {1}").format(asset.name, asset.status)) date = today() diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js index d9f2231b3132..28a8b81f3adb 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js @@ -36,11 +36,7 @@ erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.s me.setup_warehouse_query(); me.frm.set_query("target_item_code", function () { - if (me.frm.doc.entry_type == "Capitalization") { - return erpnext.queries.item({ is_stock_item: 0, is_fixed_asset: 1 }); - } else { - return erpnext.queries.item({ is_stock_item: 1, is_fixed_asset: 0 }); - } + return erpnext.queries.item({ is_stock_item: 0, is_fixed_asset: 1 }); }); me.frm.set_query("target_asset", function () { @@ -51,7 +47,7 @@ erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.s me.frm.set_query("asset", "asset_items", function () { var filters = { - status: ["not in", ["Draft", "Scrapped", "Sold", "Capitalized", "Decapitalized"]], + status: ["not in", ["Draft", "Scrapped", "Sold", "Capitalized"]], docstatus: 1, }; diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json index 9ddc44212f6d..fb519ebe7123 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json @@ -8,30 +8,26 @@ "engine": "InnoDB", "field_order": [ "title", - "company", "naming_series", - "entry_type", - "target_item_name", - "target_is_fixed_asset", - "target_has_batch_no", - "target_has_serial_no", - "column_break_9", "capitalization_method", "target_item_code", - "target_asset_location", + "target_item_name", "target_asset", "target_asset_name", - "target_warehouse", "target_qty", - "target_stock_uom", - "target_batch_no", - "target_serial_no", - "column_break_5", - "finance_book", + "target_asset_location", + "column_break_9", + "company", "posting_date", "posting_time", "set_posting_time", + "finance_book", + "target_batch_no", + "target_serial_no", "amended_from", + "target_is_fixed_asset", + "target_has_batch_no", + "target_has_serial_no", "section_break_16", "stock_items", "stock_items_total", @@ -58,12 +54,12 @@ "label": "Title" }, { - "depends_on": "eval:(doc.target_item_code && !doc.__islocal && doc.capitalization_method !== 'Choose a WIP composite asset') || ((doc.entry_type=='Capitalization' && doc.capitalization_method=='Create a new composite asset') || doc.entry_type=='Decapitalization')", + "depends_on": "eval:(doc.target_item_code && !doc.__islocal && doc.capitalization_method !== 'Choose a WIP composite asset') || doc.capitalization_method=='Create a new composite asset'", "fieldname": "target_item_code", "fieldtype": "Link", "in_standard_filter": 1, "label": "Target Item Code", - "mandatory_depends_on": "eval:(doc.entry_type=='Capitalization' && doc.capitalization_method=='Create a new composite asset') || doc.entry_type=='Decapitalization'", + "mandatory_depends_on": "eval:doc.capitalization_method=='Create a new composite asset'", "options": "Item" }, { @@ -84,22 +80,18 @@ "read_only": 1 }, { - "fieldname": "column_break_5", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:(doc.target_asset && !doc.__islocal) || (doc.entry_type=='Capitalization' && doc.capitalization_method=='Choose a WIP composite asset')", + "depends_on": "eval:(doc.target_asset && !doc.__islocal) || doc.capitalization_method=='Choose a WIP composite asset'", "fieldname": "target_asset", "fieldtype": "Link", "in_standard_filter": 1, "label": "Target Asset", - "mandatory_depends_on": "eval:doc.entry_type=='Capitalization' && doc.capitalization_method=='Choose a WIP composite asset'", + "mandatory_depends_on": "eval:doc.capitalization_method=='Choose a WIP composite asset'", "no_copy": 1, "options": "Asset", - "read_only_depends_on": "eval:(doc.entry_type=='Decapitalization') || (doc.entry_type=='Capitalization' && doc.capitalization_method=='Create a new composite asset')" + "read_only_depends_on": "eval:doc.capitalization_method=='Create a new composite asset'" }, { - "depends_on": "eval:(doc.target_asset_name && !doc.__islocal) || (doc.target_asset && doc.entry_type=='Capitalization' && doc.capitalization_method=='Choose a WIP composite asset')", + "depends_on": "eval:(doc.target_asset_name && !doc.__islocal) || (doc.target_asset && doc.capitalization_method=='Choose a WIP composite asset')", "fetch_from": "target_asset.asset_name", "fieldname": "target_asset_name", "fieldtype": "Data", @@ -162,7 +154,7 @@ "read_only": 1 }, { - "depends_on": "eval:doc.entry_type=='Capitalization' && (doc.docstatus == 0 || (doc.stock_items && doc.stock_items.length))", + "depends_on": "eval:doc.docstatus == 0 || (doc.stock_items && doc.stock_items.length)", "fieldname": "section_break_16", "fieldtype": "Section Break", "label": "Consumed Stock Items" @@ -173,14 +165,6 @@ "label": "Stock Items", "options": "Asset Capitalization Stock Item" }, - { - "depends_on": "eval:doc.entry_type=='Decapitalization'", - "fieldname": "target_warehouse", - "fieldtype": "Link", - "label": "Target Warehouse", - "mandatory_depends_on": "eval:doc.entry_type=='Decapitalization'", - "options": "Warehouse" - }, { "depends_on": "target_has_batch_no", "fieldname": "target_batch_no", @@ -190,20 +174,9 @@ }, { "default": "1", - "depends_on": "eval:doc.entry_type=='Decapitalization'", "fieldname": "target_qty", "fieldtype": "Float", - "label": "Target Qty", - "read_only_depends_on": "eval:doc.entry_type=='Capitalization'" - }, - { - "depends_on": "eval:doc.entry_type=='Decapitalization'", - "fetch_from": "target_item_code.stock_uom", - "fieldname": "target_stock_uom", - "fieldtype": "Link", - "label": "Stock UOM", - "options": "UOM", - "read_only": 1 + "label": "Target Qty" }, { "default": "0", @@ -241,16 +214,6 @@ "label": "Assets", "options": "Asset Capitalization Asset Item" }, - { - "default": "Capitalization", - "fieldname": "entry_type", - "fieldtype": "Select", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Entry Type", - "options": "Capitalization\nDecapitalization", - "reqd": 1 - }, { "fieldname": "stock_items_total", "fieldtype": "Currency", @@ -272,7 +235,7 @@ "options": "Finance Book" }, { - "depends_on": "eval:doc.entry_type=='Capitalization' && (doc.docstatus == 0 || (doc.service_items && doc.service_items.length))", + "depends_on": "eval:doc.docstatus == 0 || (doc.service_items && doc.service_items.length)", "fieldname": "service_expenses_section", "fieldtype": "Section Break", "label": "Service Expenses" @@ -337,26 +300,28 @@ "read_only": 1 }, { - "depends_on": "eval:doc.entry_type=='Capitalization' && doc.capitalization_method=='Create a new composite asset'", + "depends_on": "eval:doc.capitalization_method=='Create a new composite asset'", "fieldname": "target_asset_location", "fieldtype": "Link", "label": "Target Asset Location", - "mandatory_depends_on": "eval:doc.entry_type=='Capitalization' && doc.capitalization_method=='Create a new composite asset'", + "mandatory_depends_on": "eval:doc.capitalization_method=='Create a new composite asset'", "options": "Location" }, { - "depends_on": "eval:doc.entry_type=='Capitalization'", "fieldname": "capitalization_method", "fieldtype": "Select", "label": "Capitalization Method", - "mandatory_depends_on": "eval:doc.entry_type=='Capitalization'", "options": "\nCreate a new composite asset\nChoose a WIP composite asset" } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2023-10-03 22:55:59.461456", +======= + "modified": "2025-01-08 13:14:33.008458", +>>>>>>> 7ea73d8265 (chore: removal of decapitalization feature (#45162)) "modified_by": "Administrator", "module": "Assets", "name": "Asset Capitalization", diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py index d33d5c4df733..bed6cda43edc 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py @@ -41,7 +41,6 @@ "target_is_fixed_asset", "target_has_serial_no", "target_has_batch_no", - "target_stock_uom", "stock_uom", "fixed_asset_account", "valuation_rate", @@ -73,7 +72,6 @@ class AssetCapitalization(StockController): capitalization_method: DF.Literal["", "Create a new composite asset", "Choose a WIP composite asset"] company: DF.Link cost_center: DF.Link | None - entry_type: DF.Literal["Capitalization", "Decapitalization"] finance_book: DF.Link | None naming_series: DF.Literal["ACC-ASC-.YYYY.-"] posting_date: DF.Date @@ -96,8 +94,6 @@ class AssetCapitalization(StockController): target_item_name: DF.Data | None target_qty: DF.Float target_serial_no: DF.SmallText | None - target_stock_uom: DF.Link | None - target_warehouse: DF.Link | None title: DF.Data | None total_value: DF.Currency # end: auto-generated types @@ -190,31 +186,18 @@ def set_missing_values(self, for_validate=False): def validate_target_item(self): target_item = frappe.get_cached_doc("Item", self.target_item_code) - if not target_item.is_fixed_asset and not target_item.is_stock_item: - frappe.throw( - _("Target Item {0} is neither a Fixed Asset nor a Stock Item").format(target_item.name) - ) - - if self.entry_type == "Capitalization" and not target_item.is_fixed_asset: + if not target_item.is_fixed_asset: frappe.throw(_("Target Item {0} must be a Fixed Asset item").format(target_item.name)) - elif self.entry_type == "Decapitalization" and not target_item.is_stock_item: - frappe.throw(_("Target Item {0} must be a Stock Item").format(target_item.name)) if target_item.is_fixed_asset: self.target_qty = 1 if flt(self.target_qty) <= 0: frappe.throw(_("Target Qty must be a positive number")) - - if not target_item.is_stock_item: - self.target_warehouse = None if not target_item.has_batch_no: self.target_batch_no = None if not target_item.has_serial_no: self.target_serial_no = "" - if target_item.is_stock_item and not self.target_warehouse: - frappe.throw(_("Target Warehouse is mandatory for Decapitalization")) - self.validate_item(target_item) def validate_target_asset(self): @@ -231,7 +214,7 @@ def validate_target_asset(self): ) ) - if target_asset.status in ("Scrapped", "Sold", "Capitalized", "Decapitalized"): + if target_asset.status in ("Scrapped", "Sold", "Capitalized"): frappe.throw( _("Target Asset {0} cannot be {1}").format(target_asset.name, target_asset.status) ) @@ -273,7 +256,7 @@ def validate_consumed_asset_item(self): asset = self.get_asset_for_validation(d.asset) - if asset.status in ("Draft", "Scrapped", "Sold", "Capitalized", "Decapitalized"): + if asset.status in ("Draft", "Scrapped", "Sold", "Capitalized"): frappe.throw( _("Row #{0}: Consumed Asset {1} cannot be {2}").format( d.idx, asset.name, asset.status @@ -314,9 +297,6 @@ def validate_service_item(self): d.cost_center = frappe.get_cached_value("Company", self.company, "cost_center") def validate_source_mandatory(self): - if not self.target_is_fixed_asset and not self.get("asset_items"): - frappe.throw(_("Consumed Asset Items is mandatory for Decapitalization")) - if self.capitalization_method == "Create a new composite asset" and not ( self.get("stock_items") or self.get("asset_items") ): @@ -420,18 +400,6 @@ def update_stock_ledger(self): ) sl_entries.append(sle) - if self.entry_type == "Decapitalization" and not self.target_is_fixed_asset: - sle = self.get_sl_entries( - self, - { - "item_code": self.target_item_code, - "warehouse": self.target_warehouse, - "actual_qty": flt(self.target_qty), - "incoming_rate": flt(self.target_incoming_rate), - }, - ) - sl_entries.append(sle) - # reverse sl entries if cancel if self.docstatus == 2: sl_entries.reverse() @@ -474,21 +442,18 @@ def get_gl_entries(self, warehouse_account=None, default_expense_account=None, d return gl_entries def get_target_account(self): - if self.target_is_fixed_asset: - from erpnext.assets.doctype.asset.asset import is_cwip_accounting_enabled - - asset_category = frappe.get_cached_value("Asset", self.target_asset, "asset_category") - if is_cwip_accounting_enabled(asset_category): - target_account = get_asset_category_account( - "capital_work_in_progress_account", - asset_category=asset_category, - company=self.company, - ) - return target_account if target_account else self.target_fixed_asset_account - else: - return self.target_fixed_asset_account + from erpnext.assets.doctype.asset.asset import is_cwip_accounting_enabled + + asset_category = frappe.get_cached_value("Asset", self.target_asset, "asset_category") + if is_cwip_accounting_enabled(asset_category): + target_account = get_asset_category_account( + "capital_work_in_progress_account", + asset_category=asset_category, + company=self.company, + ) + return target_account if target_account else self.target_fixed_asset_account else: - return self.warehouse_account[self.target_warehouse]["account"] + return self.target_fixed_asset_account def get_gl_entries_for_consumed_stock_items(self, gl_entries, target_account, target_against, precision): # Consumed Stock Items @@ -589,33 +554,9 @@ def get_gl_entries_for_target_item(self, gl_entries, target_account, target_agai item=self, ) ) - else: - # Target Stock Item - sle_list = self.sle_map.get(self.name) - for sle in sle_list: - stock_value_difference = flt(sle.stock_value_difference, precision) - account = self.warehouse_account[sle.warehouse]["account"] - - gl_entries.append( - self.get_gl_dict( - { - "account": account, - "against": ", ".join(target_against), - "cost_center": self.cost_center, - "project": self.get("project"), - "remarks": self.get("remarks") or "Accounting Entry for Stock", - "debit": stock_value_difference, - }, - self.warehouse_account[sle.warehouse]["account_currency"], - item=self, - ) - ) def create_target_asset(self): - if ( - self.entry_type != "Capitalization" - or self.capitalization_method != "Create a new composite asset" - ): + if self.capitalization_method != "Create a new composite asset": return total_target_asset_value = flt(self.total_value, self.precision("total_value")) @@ -654,10 +595,7 @@ def create_target_asset(self): ) def update_target_asset(self): - if ( - self.entry_type != "Capitalization" - or self.capitalization_method != "Choose a WIP composite asset" - ): + if self.capitalization_method != "Choose a WIP composite asset": return total_target_asset_value = flt(self.total_value, self.precision("total_value")) @@ -700,14 +638,6 @@ def set_consumed_asset_status(self, asset): get_link_to_form("Asset Capitalization", self.name) ), ) - else: - asset.set_status("Decapitalized") - add_asset_activity( - asset.name, - _("Asset decapitalized after Asset Capitalization {0} was submitted").format( - get_link_to_form("Asset Capitalization", self.name) - ), - ) else: asset.set_status() add_asset_activity( @@ -729,16 +659,12 @@ def get_target_item_details(item_code=None, company=None): # Set Item Details out.target_item_name = item.item_name - out.target_stock_uom = item.stock_uom out.target_is_fixed_asset = cint(item.is_fixed_asset) out.target_has_batch_no = cint(item.has_batch_no) out.target_has_serial_no = cint(item.has_serial_no) if out.target_is_fixed_asset: out.target_qty = 1 - out.target_warehouse = None - else: - out.target_asset = None if not out.target_has_batch_no: out.target_batch_no = None diff --git a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py index ba1c5fc2444e..e0ff61020466 100644 --- a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py +++ b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py @@ -61,7 +61,6 @@ def test_capitalization_with_perpetual_inventory(self): # Create and submit Asset Captitalization asset_capitalization = create_asset_capitalization( - entry_type="Capitalization", capitalization_method="Create a new composite asset", target_item_code="Macbook Pro", target_asset_location="Test Location", @@ -76,7 +75,6 @@ def test_capitalization_with_perpetual_inventory(self): ) # Test Asset Capitalization values - self.assertEqual(asset_capitalization.entry_type, "Capitalization") self.assertEqual(asset_capitalization.target_qty, 1) self.assertEqual(asset_capitalization.stock_items[0].valuation_rate, stock_rate) @@ -152,7 +150,6 @@ def test_capitalization_with_periodical_inventory(self): # Create and submit Asset Captitalization asset_capitalization = create_asset_capitalization( - entry_type="Capitalization", capitalization_method="Create a new composite asset", target_item_code="Macbook Pro", target_asset_location="Test Location", @@ -167,7 +164,6 @@ def test_capitalization_with_periodical_inventory(self): ) # Test Asset Capitalization values - self.assertEqual(asset_capitalization.entry_type, "Capitalization") self.assertEqual(asset_capitalization.target_qty, 1) self.assertEqual(asset_capitalization.stock_items[0].valuation_rate, stock_rate) @@ -244,7 +240,6 @@ def test_capitalization_with_wip_composite_asset(self): # Create and submit Asset Captitalization asset_capitalization = create_asset_capitalization( - entry_type="Capitalization", capitalization_method="Choose a WIP composite asset", target_asset=wip_composite_asset.name, target_asset_location="Test Location", @@ -256,7 +251,6 @@ def test_capitalization_with_wip_composite_asset(self): ) # Test Asset Capitalization values - self.assertEqual(asset_capitalization.entry_type, "Capitalization") self.assertEqual(asset_capitalization.capitalization_method, "Choose a WIP composite asset") self.assertEqual(asset_capitalization.target_qty, 1) @@ -297,110 +291,6 @@ def test_capitalization_with_wip_composite_asset(self): self.assertFalse(get_actual_gle_dict(asset_capitalization.name)) self.assertFalse(get_actual_sle_dict(asset_capitalization.name)) - def test_decapitalization_with_depreciation(self): - # Variables - purchase_date = "2020-01-01" - depreciation_start_date = "2020-12-31" - capitalization_date = "2021-06-30" - - total_number_of_depreciations = 3 - expected_value_after_useful_life = 10_000 - consumed_asset_purchase_value = 100_000 - consumed_asset_current_value = 70_000 - consumed_asset_value_before_disposal = 55_000 - - target_qty = 10 - target_incoming_rate = 5500 - - depreciation_before_disposal_amount = 15_000 - accumulated_depreciation = 45_000 - - # to accomodate for depreciation on disposal calculation minor difference - consumed_asset_value_before_disposal = 55_123.29 - target_incoming_rate = 5512.329 - depreciation_before_disposal_amount = 14_876.71 - accumulated_depreciation = 44_876.71 - - # Create assets - consumed_asset = create_depreciation_asset( - asset_name="Asset Capitalization Consumable Asset", - asset_value=consumed_asset_purchase_value, - purchase_date=purchase_date, - depreciation_start_date=depreciation_start_date, - depreciation_method="Straight Line", - total_number_of_depreciations=total_number_of_depreciations, - frequency_of_depreciation=12, - expected_value_after_useful_life=expected_value_after_useful_life, - company="_Test Company with perpetual inventory", - submit=1, - ) - - first_asset_depr_schedule = get_asset_depr_schedule_doc(consumed_asset.name, "Active") - self.assertEqual(first_asset_depr_schedule.status, "Active") - - # Create and submit Asset Captitalization - asset_capitalization = create_asset_capitalization( - entry_type="Decapitalization", - posting_date=capitalization_date, # half a year - target_item_code="Capitalization Target Stock Item", - target_qty=target_qty, - consumed_asset=consumed_asset.name, - company="_Test Company with perpetual inventory", - submit=1, - ) - - # Test Asset Capitalization values - self.assertEqual(asset_capitalization.entry_type, "Decapitalization") - - self.assertEqual( - asset_capitalization.asset_items[0].current_asset_value, consumed_asset_current_value - ) - self.assertEqual( - asset_capitalization.asset_items[0].asset_value, consumed_asset_value_before_disposal - ) - self.assertEqual(asset_capitalization.asset_items_total, consumed_asset_value_before_disposal) - - self.assertEqual(asset_capitalization.total_value, consumed_asset_value_before_disposal) - self.assertEqual(asset_capitalization.target_incoming_rate, target_incoming_rate) - - # Test Consumed Asset values - consumed_asset.reload() - self.assertEqual(consumed_asset.status, "Decapitalized") - - first_asset_depr_schedule.load_from_db() - - second_asset_depr_schedule = get_asset_depr_schedule_doc(consumed_asset.name, "Active") - self.assertEqual(second_asset_depr_schedule.status, "Active") - self.assertEqual(first_asset_depr_schedule.status, "Cancelled") - - depr_schedule_of_consumed_asset = second_asset_depr_schedule.get("depreciation_schedule") - - consumed_depreciation_schedule = [ - d - for d in depr_schedule_of_consumed_asset - if getdate(d.schedule_date) == getdate(capitalization_date) - ] - self.assertTrue(consumed_depreciation_schedule and consumed_depreciation_schedule[0].journal_entry) - self.assertEqual( - consumed_depreciation_schedule[0].depreciation_amount, depreciation_before_disposal_amount - ) - - # Test General Ledger Entries - expected_gle = { - "_Test Warehouse - TCP1": consumed_asset_value_before_disposal, - "_Test Accumulated Depreciations - TCP1": accumulated_depreciation, - "_Test Fixed Asset - TCP1": -consumed_asset_purchase_value, - } - actual_gle = get_actual_gle_dict(asset_capitalization.name) - self.assertEqual(actual_gle, expected_gle) - - # Cancel Asset Capitalization and make test entries and status are reversed - asset_capitalization.reload() - asset_capitalization.cancel() - self.assertEqual(consumed_asset.db_get("status"), "Partially Depreciated") - self.assertFalse(get_actual_gle_dict(asset_capitalization.name)) - self.assertFalse(get_actual_sle_dict(asset_capitalization.name)) - def test_capitalize_only_service_item(self): company = "_Test Company" # Variables @@ -420,7 +310,6 @@ def test_capitalize_only_service_item(self): # Create and submit Asset Captitalization asset_capitalization = create_asset_capitalization( - entry_type="Capitalization", capitalization_method="Choose a WIP composite asset", target_asset=wip_composite_asset.name, target_asset_location="Test Location", @@ -468,13 +357,11 @@ def create_asset_capitalization(**args): target_item_code = target_asset.item_code or args.target_item_code company = target_asset.company or args.company or "_Test Company" warehouse = args.warehouse or create_warehouse("_Test Warehouse", company=company) - target_warehouse = args.target_warehouse or warehouse source_warehouse = args.source_warehouse or warehouse asset_capitalization = frappe.new_doc("Asset Capitalization") asset_capitalization.update( { - "entry_type": args.entry_type or "Capitalization", "capitalization_method": args.capitalization_method or None, "company": company, "posting_date": args.posting_date or now.strftime("%Y-%m-%d"), @@ -482,7 +369,6 @@ def create_asset_capitalization(**args): "target_item_code": target_item_code, "target_asset": target_asset.name, "target_asset_location": "Test Location", - "target_warehouse": target_warehouse, "target_qty": flt(args.target_qty) or 1, "target_batch_no": args.target_batch_no, "target_serial_no": args.target_serial_no, diff --git a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py index 8ebf9d6d389d..2b4c55d6ec87 100644 --- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py +++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py @@ -66,12 +66,12 @@ def get_conditions(filters): conditions["cost_center"] = filters.get("cost_center") if status: - # In Store assets are those that are not sold or scrapped or capitalized or decapitalized + # In Store assets are those that are not sold or scrapped or capitalized operand = "not in" if status not in "In Location": operand = "in" - conditions["status"] = (operand, ["Sold", "Scrapped", "Capitalized", "Decapitalized"]) + conditions["status"] = (operand, ["Sold", "Scrapped", "Capitalized"]) return conditions @@ -272,9 +272,9 @@ def get_asset_depreciation_amount_map(filters, finance_book): query = query.where(asset.cost_center == filters.cost_center) if filters.status: if filters.status == "In Location": - query = query.where(asset.status.notin(["Sold", "Scrapped", "Capitalized", "Decapitalized"])) + query = query.where(asset.status.notin(["Sold", "Scrapped", "Capitalized"])) else: - query = query.where(asset.status.isin(["Sold", "Scrapped", "Capitalized", "Decapitalized"])) + query = query.where(asset.status.isin(["Sold", "Scrapped", "Capitalized"])) if finance_book: query = query.where((gle.finance_book.isin([cstr(finance_book), ""])) | (gle.finance_book.isnull())) else: From a49034a2c38da9784e0973a65c3ff63be82ae461 Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:26:37 +0530 Subject: [PATCH 2/2] fix: resolved conflicts --- .../doctype/asset_capitalization/asset_capitalization.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json index fb519ebe7123..a6796e55f826 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.json @@ -317,11 +317,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2023-10-03 22:55:59.461456", -======= "modified": "2025-01-08 13:14:33.008458", ->>>>>>> 7ea73d8265 (chore: removal of decapitalization feature (#45162)) "modified_by": "Administrator", "module": "Assets", "name": "Asset Capitalization", @@ -365,4 +361,4 @@ "title_field": "title", "track_changes": 1, "track_seen": 1 -} \ No newline at end of file +}