Skip to content

Commit

Permalink
feat: work in progress status for asset (#45066)
Browse files Browse the repository at this point in the history
* feat: work in progress status for asset

* fix: test case correction

* fix(patch): added patch to update status of assets

* fix: updated tests

(cherry picked from commit 6850019)

# Conflicts:
#	erpnext/assets/doctype/asset/asset.json
#	erpnext/patches.txt
  • Loading branch information
khushi8112 authored and mergify[bot] committed Jan 7, 2025
1 parent 807d591 commit 1ea36bb
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 7 deletions.
6 changes: 5 additions & 1 deletion erpnext/assets/doctype/asset/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"options": "Draft\nSubmitted\nPartially Depreciated\nFully Depreciated\nSold\nScrapped\nIn Maintenance\nOut of Order\nIssue\nReceipt\nCapitalized\nDecapitalized\nWork In Progress",
"read_only": 1
},
{
Expand Down Expand Up @@ -595,7 +595,11 @@
"link_fieldname": "target_asset"
}
],
<<<<<<< HEAD
"modified": "2024-08-26 23:28:29.095139",
=======
"modified": "2024-12-26 14:23:20.968882",
>>>>>>> 6850019649 (feat: work in progress status for asset (#45066))
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset",
Expand Down
1 change: 1 addition & 0 deletions erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class Asset(AccountsController):
"Receipt",
"Capitalized",
"Decapitalized",
"Work In Progress",
]
supplier: DF.Link | None
total_asset_cost: DF.Currency
Expand Down
7 changes: 5 additions & 2 deletions erpnext/assets/doctype/asset/asset_list.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
frappe.listview_settings["Asset"] = {
add_fields: ["status"],
add_fields: ["status", "docstatus"],
has_indicator_for_draft: 1,
get_indicator: function (doc) {
if (doc.status === "Fully Depreciated") {
return [__("Fully Depreciated"), "green", "status,=,Fully Depreciated"];
} else if (doc.status === "Partially Depreciated") {
return [__("Partially Depreciated"), "grey", "status,=,Partially Depreciated"];
} else if (doc.status === "Sold") {
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 === "Scrapped") {
Expand All @@ -21,7 +24,7 @@ frappe.listview_settings["Asset"] = {
return [__("Receipt"), "green", "status,=,Receipt"];
} else if (doc.status === "Submitted") {
return [__("Submitted"), "blue", "status,=,Submitted"];
} else if (doc.status === "Draft") {
} else if (doc.status === "Draft" || doc.docstatus === 0) {
return [__("Draft"), "red", "status,=,Draft"];
}
},
Expand Down
4 changes: 4 additions & 0 deletions erpnext/assets/doctype/asset/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,10 @@ def create_asset(**args):
},
)

if asset.is_composite_asset:
asset.gross_purchase_amount = 0
asset.purchase_amount = 0

if not args.do_not_save:
try:
asset.insert(ignore_if_duplicate=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ def create_target_asset(self):
self.target_fixed_asset_account = get_asset_category_account(
"fixed_asset_account", item=self.target_item_code, company=asset_doc.company
)
asset_doc.set_status("Work In Progress")

add_asset_activity(
asset_doc.name,
Expand All @@ -662,8 +663,9 @@ def update_target_asset(self):
total_target_asset_value = flt(self.total_value, self.precision("total_value"))

asset_doc = frappe.get_doc("Asset", self.target_asset)
asset_doc.gross_purchase_amount = total_target_asset_value
asset_doc.purchase_amount = total_target_asset_value
asset_doc.gross_purchase_amount += total_target_asset_value
asset_doc.purchase_amount += total_target_asset_value
asset_doc.set_status("Work In Progress")
asset_doc.flags.ignore_validate = True
asset_doc.save()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_capitalization_with_perpetual_inventory(self):
target_asset = frappe.get_doc("Asset", asset_capitalization.target_asset)
self.assertEqual(target_asset.gross_purchase_amount, total_amount)
self.assertEqual(target_asset.purchase_amount, total_amount)
self.assertEqual(target_asset.status, "Work In Progress")

# Test Consumed Asset values
self.assertEqual(consumed_asset.db_get("status"), "Capitalized")
Expand Down Expand Up @@ -270,6 +271,7 @@ def test_capitalization_with_wip_composite_asset(self):
target_asset = frappe.get_doc("Asset", asset_capitalization.target_asset)
self.assertEqual(target_asset.gross_purchase_amount, total_amount)
self.assertEqual(target_asset.purchase_amount, total_amount)
self.assertEqual(target_asset.status, "Work In Progress")

# Test General Ledger Entries
expected_gle = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
flt,
get_first_day,
get_last_day,
get_link_to_form,
getdate,
is_last_day_of_the_month,
month_diff,
Expand Down Expand Up @@ -1062,7 +1063,7 @@ def make_new_active_asset_depr_schedules_and_cancel_current_ones(
if not current_asset_depr_schedule_doc:
frappe.throw(
_("Asset Depreciation Schedule not found for Asset {0} and Finance Book {1}").format(
asset_doc.name, row.finance_book
get_link_to_form("Asset", asset_doc.name), row.finance_book
)
)

Expand Down Expand Up @@ -1108,7 +1109,7 @@ def get_temp_asset_depr_schedule_doc(
if not current_asset_depr_schedule_doc:
frappe.throw(
_("Asset Depreciation Schedule not found for Asset {0} and Finance Book {1}").format(
asset_doc.name, row.finance_book
get_link_to_form("Asset", asset_doc.name), row.finance_book
)
)

Expand Down
5 changes: 5 additions & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,8 @@ erpnext.patches.v14_0.update_stock_uom_in_work_order_item
erpnext.patches.v15_0.set_is_exchange_gain_loss_in_payment_entry_deductions
erpnext.patches.v15_0.enable_allow_existing_serial_no
erpnext.patches.v15_0.update_cc_in_process_statement_of_accounts
<<<<<<< HEAD
=======
erpnext.patches.v15_0.refactor_closing_stock_balance #5
erpnext.patches.v15_0.update_asset_status_to_work_in_progress
>>>>>>> 6850019649 (feat: work in progress status for asset (#45066))
11 changes: 11 additions & 0 deletions erpnext/patches/v15_0/update_asset_status_to_work_in_progress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import frappe


def execute():
Asset = frappe.qb.DocType("Asset")
query = (
frappe.qb.update(Asset)
.set(Asset.status, "Work In Progress")
.where((Asset.docstatus == 0) & (Asset.is_composite_asset == 1))
)
query.run()

0 comments on commit 1ea36bb

Please sign in to comment.