mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 20:35:09 +00:00
refactor: use selectbox instead of checkboxes for asset type
(cherry picked from commit f7b9221324)
This commit is contained in:
@@ -97,7 +97,7 @@ def validate_accounting_period_on_doc_save(doc, method=None):
|
||||
if doc.doctype == "Bank Clearance":
|
||||
return
|
||||
elif doc.doctype == "Asset":
|
||||
if doc.is_existing_asset:
|
||||
if doc.asset_type == "Existing Asset":
|
||||
return
|
||||
else:
|
||||
date = doc.available_for_use_date
|
||||
|
||||
@@ -534,7 +534,7 @@ cur_frm.fields_dict["select_print_heading"].get_query = function (doc, cdt, cdn)
|
||||
|
||||
cur_frm.set_query("wip_composite_asset", "items", function () {
|
||||
return {
|
||||
filters: { is_composite_asset: 1, docstatus: 0 },
|
||||
filters: { asset_type: "Composite Asset", docstatus: 0 },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
"docstatus": 0,
|
||||
"doctype": "Dashboard Chart",
|
||||
"dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.datetime.add_months(frappe.datetime.nowdate(), -12)\",\"to_date\":\"frappe.datetime.nowdate()\"}",
|
||||
"filters_json": "{\"status\":\"In Location\",\"group_by\":\"Asset Category\",\"is_existing_asset\":0}",
|
||||
"filters_json": "{\"status\":\"In Location\",\"group_by\":\"Asset Category\",\"asset_type\":[\"!=\",\"Existing Asset\"]}",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"modified": "2020-10-28 23:16:16.939070",
|
||||
"modified": "2026-02-03 15:48:13.407835",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Assets",
|
||||
"name": "Category-wise Asset Value",
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
"docstatus": 0,
|
||||
"doctype": "Dashboard Chart",
|
||||
"dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.datetime.add_months(frappe.datetime.nowdate(), -12)\",\"to_date\":\"frappe.datetime.nowdate()\"}",
|
||||
"filters_json": "{\"status\":\"In Location\",\"group_by\":\"Location\",\"is_existing_asset\":0}",
|
||||
"filters_json": "{\"status\":\"In Location\",\"group_by\":\"Location\",\"asset_type\":[\"!=\",\"Existing Asset\"]}",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"modified": "2020-10-28 23:16:07.883312",
|
||||
"modified": "2026-02-03 15:48:13.407835",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Assets",
|
||||
"name": "Location-wise Asset Value",
|
||||
|
||||
@@ -100,7 +100,7 @@ def get_charts(fiscal_year, year_start_date, year_end_date):
|
||||
"company": company,
|
||||
"status": "In Location",
|
||||
"group_by": "Asset Category",
|
||||
"is_existing_asset": 0,
|
||||
"asset_type": ["!=", "Existing Asset"],
|
||||
}
|
||||
),
|
||||
"type": "Donut",
|
||||
@@ -126,7 +126,12 @@ def get_charts(fiscal_year, year_start_date, year_end_date):
|
||||
"x_field": "location",
|
||||
"timeseries": 0,
|
||||
"filters_json": json.dumps(
|
||||
{"company": company, "status": "In Location", "group_by": "Location", "is_existing_asset": 0}
|
||||
{
|
||||
"company": company,
|
||||
"status": "In Location",
|
||||
"group_by": "Location",
|
||||
"asset_type": ["!=", "Existing Asset"],
|
||||
}
|
||||
),
|
||||
"type": "Donut",
|
||||
"doctype": "Dashboard Chart",
|
||||
|
||||
@@ -81,13 +81,13 @@ frappe.ui.form.on("Asset", {
|
||||
},
|
||||
|
||||
before_submit: function (frm) {
|
||||
if (frm.doc.is_composite_asset && !frm.has_active_capitalization) {
|
||||
if (frm.doc.asset_type == "Composite Asset" && !frm.has_active_capitalization) {
|
||||
frappe.throw(__("Please capitalize this asset before submitting."));
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function (frm) {
|
||||
frappe.ui.form.trigger("Asset", "is_existing_asset");
|
||||
frappe.ui.form.trigger("Asset", "asset_type");
|
||||
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
|
||||
|
||||
if (frm.doc.docstatus == 1) {
|
||||
@@ -167,7 +167,7 @@ frappe.ui.form.on("Asset", {
|
||||
);
|
||||
}
|
||||
|
||||
if (frm.doc.purchase_receipt || !frm.doc.is_existing_asset) {
|
||||
if (frm.doc.purchase_receipt || !frm.doc.asset_type == "Existing Asset") {
|
||||
frm.add_custom_button(
|
||||
__("View General Ledger"),
|
||||
function () {
|
||||
@@ -195,7 +195,7 @@ frappe.ui.form.on("Asset", {
|
||||
if (frm.doc.docstatus == 0) {
|
||||
frm.toggle_reqd("finance_books", frm.doc.calculate_depreciation);
|
||||
|
||||
if (frm.doc.is_composite_asset) {
|
||||
if (frm.doc.asset_type == "Composite Asset") {
|
||||
frappe.call({
|
||||
method: "erpnext.assets.doctype.asset.asset.has_active_capitalization",
|
||||
args: {
|
||||
@@ -232,7 +232,8 @@ frappe.ui.form.on("Asset", {
|
||||
|
||||
toggle_reference_doc: function (frm) {
|
||||
const is_submitted = frm.doc.docstatus === 1;
|
||||
const is_special_asset = frm.doc.is_existing_asset || frm.doc.is_composite_asset;
|
||||
const is_special_asset =
|
||||
frm.doc.asset_type == "Existing Asset" || frm.doc.asset_type == "Composite Asset";
|
||||
|
||||
const clear_field = (field) => {
|
||||
if (frm.doc[field]) {
|
||||
@@ -508,18 +509,13 @@ frappe.ui.form.on("Asset", {
|
||||
});
|
||||
},
|
||||
|
||||
is_existing_asset: function (frm) {
|
||||
frm.trigger("toggle_reference_doc");
|
||||
},
|
||||
|
||||
is_composite_asset: function (frm) {
|
||||
asset_type: function (frm) {
|
||||
if (frm.doc.docstatus == 0) {
|
||||
if (frm.doc.is_composite_asset) {
|
||||
if (frm.doc.asset_type == "Composite Asset") {
|
||||
frm.set_value("net_purchase_amount", 0);
|
||||
} else {
|
||||
frm.set_df_property("net_purchase_amount", "read_only", 0);
|
||||
}
|
||||
frm.trigger("toggle_reference_doc");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
"asset_owner_company",
|
||||
"customer",
|
||||
"supplier",
|
||||
"is_existing_asset",
|
||||
"is_composite_asset",
|
||||
"is_composite_component",
|
||||
"asset_type",
|
||||
"purchase_details_section",
|
||||
"purchase_receipt",
|
||||
"purchase_receipt_item",
|
||||
@@ -199,7 +197,7 @@
|
||||
"fieldname": "purchase_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Purchase Date",
|
||||
"read_only_depends_on": "eval:!doc.is_existing_asset && !doc.is_composite_asset",
|
||||
"read_only_depends_on": "eval:doc.asset_type != \"Existing Asset\" && doc.asset_type != \"Composite Asset\"",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -222,24 +220,17 @@
|
||||
"fieldname": "available_for_use_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Available for Use Date",
|
||||
"mandatory_depends_on": "eval:(!(doc.is_composite_component || doc.is_composite_asset) || doc.docstatus==1)"
|
||||
"mandatory_depends_on": "eval:(!(doc.asset_type == \"Composite Component\" || doc.asset_type == \"Composite Asset\") || doc.docstatus==1)"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "calculate_depreciation",
|
||||
"fieldtype": "Check",
|
||||
"label": "Calculate Depreciation",
|
||||
"read_only_depends_on": "eval:(doc.is_composite_asset && !doc.net_purchase_amount) || doc.is_composite_component"
|
||||
"read_only_depends_on": "eval:(doc.asset_type == \"Composite Asset\" && !doc.net_purchase_amount) || doc.asset_type == \"Composite Component\""
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:(!doc.is_composite_asset && !doc.is_composite_component)",
|
||||
"fieldname": "is_existing_asset",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Existing Asset"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:(doc.is_existing_asset)",
|
||||
"depends_on": "eval:(doc.asset_type == \"Existing Asset\")",
|
||||
"fieldname": "opening_accumulated_depreciation",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Opening Accumulated Depreciation",
|
||||
@@ -357,7 +348,7 @@
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.is_composite_asset && !doc.is_existing_asset",
|
||||
"depends_on": "eval:doc.asset_type != \"Composite Asset\" && doc.asset_type != \"Existing Asset\"",
|
||||
"fieldname": "purchase_receipt",
|
||||
"fieldtype": "Link",
|
||||
"label": "Purchase Receipt",
|
||||
@@ -366,7 +357,7 @@
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.is_composite_asset && !doc.is_existing_asset",
|
||||
"depends_on": "eval:doc.asset_type != \"Composite Asset\" && doc.asset_type != \"Existing Asset\"",
|
||||
"fieldname": "purchase_invoice",
|
||||
"fieldtype": "Link",
|
||||
"label": "Purchase Invoice",
|
||||
@@ -392,7 +383,7 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"collapsible_depends_on": "is_existing_asset",
|
||||
"collapsible_depends_on": "eval:doc.asset_type == \"Existing Asset\"",
|
||||
"fieldname": "purchase_details_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Purchase Details"
|
||||
@@ -447,18 +438,11 @@
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:(doc.is_existing_asset)",
|
||||
"depends_on": "eval:(doc.asset_type == \"Existing Asset\")",
|
||||
"fieldname": "is_fully_depreciated",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Fully Depreciated"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:(!doc.is_existing_asset && !doc.is_composite_component)",
|
||||
"fieldname": "is_composite_asset",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Composite Asset"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.docstatus > 0",
|
||||
"fieldname": "total_asset_cost",
|
||||
@@ -488,7 +472,7 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:(doc.is_existing_asset)",
|
||||
"depends_on": "eval:(doc.asset_type == \"Existing Asset\")",
|
||||
"fieldname": "opening_number_of_booked_depreciations",
|
||||
"fieldtype": "Int",
|
||||
"label": "Opening Number of Booked Depreciations"
|
||||
@@ -536,20 +520,19 @@
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Additional Info"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:(!doc.is_existing_asset && !doc.is_composite_asset)",
|
||||
"fieldname": "is_composite_component",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Composite Component"
|
||||
},
|
||||
{
|
||||
"fieldname": "net_purchase_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Net Purchase Amount",
|
||||
"mandatory_depends_on": "eval:(!doc.is_composite_asset || doc.docstatus==1)",
|
||||
"mandatory_depends_on": "eval:(doc.asset_type != \"Composite Asset\" || doc.docstatus==1)",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only_depends_on": "eval: doc.is_composite_asset"
|
||||
"read_only_depends_on": "eval: doc.asset_type == \"Composite Asset\""
|
||||
},
|
||||
{
|
||||
"fieldname": "asset_type",
|
||||
"fieldtype": "Select",
|
||||
"label": "Asset Type",
|
||||
"options": "\nExisting Asset\nComposite Asset\nComposite Component"
|
||||
}
|
||||
],
|
||||
"idx": 72,
|
||||
@@ -593,7 +576,7 @@
|
||||
"link_fieldname": "target_asset"
|
||||
}
|
||||
],
|
||||
"modified": "2026-02-03 15:29:21.504376",
|
||||
"modified": "2026-02-03 15:48:13.407835",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Assets",
|
||||
"name": "Asset",
|
||||
|
||||
@@ -56,6 +56,7 @@ class Asset(AccountsController):
|
||||
asset_owner: DF.Literal["", "Company", "Supplier", "Customer"]
|
||||
asset_owner_company: DF.Link | None
|
||||
asset_quantity: DF.Int
|
||||
asset_type: DF.Literal["", "Existing Asset", "Composite Asset", "Composite Component"]
|
||||
available_for_use_date: DF.Date | None
|
||||
booked_fixed_asset: DF.Check
|
||||
calculate_depreciation: DF.Check
|
||||
@@ -76,9 +77,6 @@ class Asset(AccountsController):
|
||||
insurance_start_date: DF.Date | None
|
||||
insured_value: DF.Data | None
|
||||
insurer: DF.Data | None
|
||||
is_composite_asset: DF.Check
|
||||
is_composite_component: DF.Check
|
||||
is_existing_asset: DF.Check
|
||||
is_fully_depreciated: DF.Check
|
||||
item_code: DF.Link
|
||||
journal_entry_for_scrap: DF.Link | None
|
||||
@@ -242,7 +240,7 @@ class Asset(AccountsController):
|
||||
self.set_total_booked_depreciations()
|
||||
|
||||
def before_submit(self):
|
||||
if self.is_composite_asset and not has_active_capitalization(self.name):
|
||||
if self.asset_type == "Composite Asset" and not has_active_capitalization(self.name):
|
||||
if self.split_from and has_active_capitalization(self.split_from):
|
||||
return
|
||||
frappe.throw(_("Please capitalize this asset before submitting."))
|
||||
@@ -251,7 +249,11 @@ class Asset(AccountsController):
|
||||
self.validate_in_use_date()
|
||||
self.make_asset_movement()
|
||||
self.reload()
|
||||
if not self.booked_fixed_asset and not self.is_composite_component and self.validate_make_gl_entry():
|
||||
if (
|
||||
not self.booked_fixed_asset
|
||||
and self.asset_type == "Composite Component"
|
||||
and self.validate_make_gl_entry()
|
||||
):
|
||||
self.make_gl_entries()
|
||||
if self.calculate_depreciation and not self.split_from:
|
||||
convert_draft_asset_depr_schedules_into_active(self)
|
||||
@@ -266,7 +268,7 @@ class Asset(AccountsController):
|
||||
cancel_asset_depr_schedules(self)
|
||||
self.set_status()
|
||||
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry")
|
||||
if not self.is_composite_component:
|
||||
if self.asset_type != "Composite Component":
|
||||
make_reverse_gl_entries(voucher_type="Asset", voucher_no=self.name)
|
||||
self.db_set("booked_fixed_asset", 0)
|
||||
add_asset_activity(self.name, _("Asset cancelled"))
|
||||
@@ -284,7 +286,7 @@ class Asset(AccountsController):
|
||||
add_asset_activity(self.name, _("Asset deleted"))
|
||||
|
||||
def set_purchase_doc_row_item(self):
|
||||
if self.is_existing_asset or self.is_composite_asset:
|
||||
if self.asset_type == "Existing Asset" or self.asset_type == "Composite Asset":
|
||||
return
|
||||
|
||||
self.purchase_amount = self.net_purchase_amount
|
||||
@@ -327,7 +329,7 @@ class Asset(AccountsController):
|
||||
)
|
||||
)
|
||||
|
||||
if self.is_existing_asset and self.purchase_invoice:
|
||||
if self.asset_type == "Existing Asset" and self.purchase_invoice:
|
||||
frappe.throw(_("Purchase Invoice cannot be made against an existing asset {0}").format(self.name))
|
||||
|
||||
def validate_item(self):
|
||||
@@ -373,7 +375,7 @@ class Asset(AccountsController):
|
||||
)
|
||||
|
||||
def validate_in_use_date(self):
|
||||
if not self.available_for_use_date and not self.is_composite_component:
|
||||
if not self.available_for_use_date and self.asset_type != "Composite Component":
|
||||
frappe.throw(_("Available for use date is required"))
|
||||
|
||||
for d in self.finance_books:
|
||||
@@ -441,13 +443,13 @@ class Asset(AccountsController):
|
||||
if not self.asset_category:
|
||||
self.asset_category = frappe.get_cached_value("Item", self.item_code, "asset_category")
|
||||
|
||||
if not flt(self.net_purchase_amount) and not self.is_composite_asset:
|
||||
if not flt(self.net_purchase_amount) and self.asset_type != "Composite Asset":
|
||||
frappe.throw(_("Net Purchase Amount is mandatory"), frappe.MandatoryError)
|
||||
|
||||
if is_cwip_accounting_enabled(self.asset_category):
|
||||
if (
|
||||
not self.is_existing_asset
|
||||
and not self.is_composite_asset
|
||||
not self.asset_type == "Existing Asset"
|
||||
and not self.asset_type == "Composite Asset"
|
||||
and not self.purchase_receipt
|
||||
and not self.purchase_invoice
|
||||
):
|
||||
@@ -476,7 +478,7 @@ class Asset(AccountsController):
|
||||
if self.is_fully_depreciated:
|
||||
frappe.throw(_("Depreciation cannot be calculated for fully depreciated assets"))
|
||||
|
||||
if self.is_existing_asset:
|
||||
if self.asset_type == "Existing Asset":
|
||||
return
|
||||
|
||||
if self.available_for_use_date and getdate(self.available_for_use_date) < getdate(self.purchase_date):
|
||||
@@ -548,7 +550,7 @@ class Asset(AccountsController):
|
||||
)
|
||||
|
||||
def validate_gross_and_purchase_amount(self):
|
||||
if self.is_existing_asset:
|
||||
if self.asset_type == "Existing Asset":
|
||||
return
|
||||
|
||||
if self.net_purchase_amount and self.net_purchase_amount != self.purchase_amount:
|
||||
@@ -616,7 +618,7 @@ class Asset(AccountsController):
|
||||
self.validate_depreciation_start_date(row)
|
||||
self.validate_total_number_of_depreciations_and_frequency(row)
|
||||
|
||||
if not self.is_existing_asset:
|
||||
if self.asset_type != "Existing Asset":
|
||||
self.opening_accumulated_depreciation = 0
|
||||
self.opening_number_of_booked_depreciations = 0
|
||||
else:
|
||||
@@ -769,7 +771,7 @@ class Asset(AccountsController):
|
||||
def get_status(self):
|
||||
"""Returns status based on whether it is draft, submitted, scrapped or depreciated"""
|
||||
if self.docstatus == 0:
|
||||
if self.is_composite_asset:
|
||||
if self.asset_type == "Composite Asset":
|
||||
status = "Work In Progress"
|
||||
else:
|
||||
status = "Draft"
|
||||
@@ -842,7 +844,7 @@ class Asset(AccountsController):
|
||||
return records
|
||||
|
||||
def validate_make_gl_entry(self):
|
||||
if self.is_composite_asset:
|
||||
if self.asset_type == "Composite Asset":
|
||||
return True
|
||||
|
||||
purchase_document = self.get_purchase_document()
|
||||
@@ -923,7 +925,7 @@ class Asset(AccountsController):
|
||||
purchase_document = self.get_purchase_document()
|
||||
fixed_asset_account, cwip_account = self.get_fixed_asset_account(), self.get_cwip_account()
|
||||
|
||||
if (self.is_composite_asset or (purchase_document and self.purchase_amount)) and getdate(
|
||||
if (self.asset_type == "Composite Asset" or (purchase_document and self.purchase_amount)) and getdate(
|
||||
self.available_for_use_date
|
||||
) <= getdate():
|
||||
gl_entries.append(
|
||||
@@ -963,7 +965,7 @@ class Asset(AccountsController):
|
||||
self.db_set("booked_fixed_asset", 1)
|
||||
|
||||
def check_asset_capitalization_gl_entries(self):
|
||||
if self.is_composite_asset:
|
||||
if self.asset_type == "Composite Asset":
|
||||
result = frappe.db.get_value(
|
||||
"Asset Capitalization",
|
||||
{"target_asset": self.name, "docstatus": 1},
|
||||
|
||||
@@ -789,7 +789,7 @@ def get_disposal_account_and_cost_center(company):
|
||||
def get_value_after_depreciation_on_disposal_date(asset, disposal_date, finance_book=None):
|
||||
asset_doc = frappe.get_doc("Asset", asset)
|
||||
|
||||
if asset_doc.is_composite_component:
|
||||
if asset_doc.asset_type == "Composite Component":
|
||||
validate_disposal_date(asset_doc.purchase_date, getdate(disposal_date), "purchase")
|
||||
return flt(asset_doc.value_after_depreciation)
|
||||
|
||||
|
||||
@@ -71,16 +71,16 @@ class TestAsset(AssetSetup):
|
||||
self.assertRaises(frappe.MandatoryError, asset.save)
|
||||
|
||||
def test_pr_or_pi_mandatory_if_not_existing_asset(self):
|
||||
"""Tests if either PI or PR is present if CWIP is enabled and is_existing_asset=0."""
|
||||
"""Tests if either PI or PR is present if CWIP is enabled and asset_type == Existing Asset."""
|
||||
|
||||
asset = create_asset(item_code="Macbook Pro", do_not_save=1)
|
||||
asset.is_existing_asset = 0
|
||||
asset.asset_type = ""
|
||||
|
||||
self.assertRaises(frappe.ValidationError, asset.save)
|
||||
|
||||
def test_available_for_use_date_is_after_purchase_date(self):
|
||||
asset = create_asset(item_code="Macbook Pro", calculate_depreciation=1, do_not_save=1)
|
||||
asset.is_existing_asset = 0
|
||||
asset.asset_type = ""
|
||||
asset.purchase_date = getdate("2021-10-10")
|
||||
asset.available_for_use_date = getdate("2021-10-1")
|
||||
|
||||
@@ -183,7 +183,7 @@ class TestAsset(AssetSetup):
|
||||
asset.submit()
|
||||
|
||||
def test_is_fixed_asset_set(self):
|
||||
asset = create_asset(is_existing_asset=1)
|
||||
asset = create_asset(asset_type="Existing Asset")
|
||||
doc = frappe.new_doc("Purchase Invoice")
|
||||
doc.company = "_Test Company"
|
||||
doc.supplier = "_Test Supplier"
|
||||
@@ -710,7 +710,7 @@ class TestAsset(AssetSetup):
|
||||
# create an asset
|
||||
asset = create_asset(
|
||||
item_code="Macbook Pro",
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
calculate_depreciation=1,
|
||||
available_for_use_date=purchase_date,
|
||||
purchase_date=purchase_date,
|
||||
@@ -890,7 +890,7 @@ class TestDepreciationMethods(AssetSetup):
|
||||
asset = create_asset(
|
||||
calculate_depreciation=1,
|
||||
available_for_use_date="2030-06-06",
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
opening_number_of_booked_depreciations=2,
|
||||
opening_accumulated_depreciation=47178.08,
|
||||
expected_value_after_useful_life=10000,
|
||||
@@ -939,7 +939,7 @@ class TestDepreciationMethods(AssetSetup):
|
||||
asset = create_asset(
|
||||
calculate_depreciation=1,
|
||||
available_for_use_date="2030-01-01",
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
depreciation_method="Double Declining Balance",
|
||||
opening_number_of_booked_depreciations=1,
|
||||
opening_accumulated_depreciation=50000,
|
||||
@@ -1680,7 +1680,7 @@ class TestDepreciationBasics(AssetSetup):
|
||||
self.assertEqual(asset.finance_books[0].value_after_depreciation, 100000.0)
|
||||
|
||||
def test_asset_cost_center(self):
|
||||
asset = create_asset(is_existing_asset=1, do_not_save=1)
|
||||
asset = create_asset(asset_type="Existing Asset", do_not_save=1)
|
||||
asset.cost_center = "Main - WP"
|
||||
|
||||
self.assertRaises(frappe.ValidationError, asset.submit)
|
||||
@@ -1717,7 +1717,7 @@ class TestDepreciationBasics(AssetSetup):
|
||||
def test_manual_depreciation_for_existing_asset(self):
|
||||
asset = create_asset(
|
||||
item_code="Macbook Pro",
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
purchase_date="2020-01-30",
|
||||
available_for_use_date="2020-01-30",
|
||||
submit=1,
|
||||
@@ -1843,7 +1843,7 @@ class TestDepreciationBasics(AssetSetup):
|
||||
# Create composite asset
|
||||
wip_composite_asset = create_asset(
|
||||
asset_name="Asset Capitalization WIP Composite Asset for Split",
|
||||
is_composite_asset=1,
|
||||
asset_type="Composite Asset",
|
||||
warehouse="Stores - TCP1",
|
||||
company=company,
|
||||
asset_quantity=2, # Set quantity > 1 to allow splitting
|
||||
@@ -1937,9 +1937,7 @@ def create_asset(**args):
|
||||
"available_for_use_date": args.available_for_use_date or "2020-06-06",
|
||||
"location": args.location or "Test Location",
|
||||
"asset_owner": args.asset_owner or "Company",
|
||||
"is_existing_asset": args.is_existing_asset or 1,
|
||||
"is_composite_asset": args.is_composite_asset or 0,
|
||||
"is_composite_component": args.is_composite_component or 0,
|
||||
"asset_type": args.asset_type or "",
|
||||
"asset_quantity": args.get("asset_quantity") or 1,
|
||||
"depr_entry_posting_status": args.depr_entry_posting_status or "",
|
||||
}
|
||||
@@ -1961,7 +1959,7 @@ def create_asset(**args):
|
||||
},
|
||||
)
|
||||
|
||||
if asset.is_composite_asset:
|
||||
if asset.asset_type == "Composite Asset":
|
||||
asset.net_purchase_amount = 0
|
||||
asset.purchase_amount = 0
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.s
|
||||
|
||||
me.frm.set_query("target_asset", function () {
|
||||
return {
|
||||
filters: { is_composite_asset: 1, docstatus: 0 },
|
||||
filters: { asset_type: "Composite Asset", docstatus: 0 },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ class AssetCapitalization(StockController):
|
||||
if self.target_asset:
|
||||
target_asset = self.get_asset_for_validation(self.target_asset)
|
||||
|
||||
if not target_asset.is_composite_asset:
|
||||
if not target_asset.asset_type == "Composite Asset":
|
||||
frappe.throw(_("Target Asset {0} needs to be composite asset").format(target_asset.name))
|
||||
|
||||
if target_asset.item_code != self.target_item_code:
|
||||
@@ -314,7 +314,7 @@ class AssetCapitalization(StockController):
|
||||
return frappe.db.get_value(
|
||||
"Asset",
|
||||
asset,
|
||||
["name", "item_code", "company", "status", "docstatus", "is_composite_asset"],
|
||||
["name", "item_code", "company", "status", "docstatus", "asset_type"],
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
@@ -489,7 +489,7 @@ class AssetCapitalization(StockController):
|
||||
for item in self.asset_items:
|
||||
asset = frappe.get_doc("Asset", item.asset)
|
||||
|
||||
if not asset.is_composite_component:
|
||||
if asset.asset_type != "Composite Component":
|
||||
if asset.calculate_depreciation:
|
||||
notes = _(
|
||||
"This schedule was created when Asset {0} was consumed through Asset Capitalization {1}."
|
||||
@@ -542,8 +542,8 @@ class AssetCapitalization(StockController):
|
||||
def get_composite_component_value(self):
|
||||
composite_component_value = 0
|
||||
for item in self.asset_items:
|
||||
asset = frappe.db.get_value("Asset", item.asset, ["is_composite_component"], as_dict=True)
|
||||
if asset and asset.is_composite_component:
|
||||
asset = frappe.db.get_value("Asset", item.asset, ["asset_type"], as_dict=True)
|
||||
if asset and asset.asset_type == "Composite Component":
|
||||
composite_component_value += flt(item.asset_value, item.precision("asset_value"))
|
||||
return composite_component_value
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestAssetCapitalization(IntegrationTestCase):
|
||||
|
||||
wip_composite_asset = create_asset(
|
||||
asset_name="Asset Capitalization WIP Composite Asset",
|
||||
is_composite_asset=1,
|
||||
asset_type="Composite Asset",
|
||||
warehouse="Stores - TCP1",
|
||||
company=company,
|
||||
)
|
||||
@@ -156,7 +156,7 @@ class TestAssetCapitalization(IntegrationTestCase):
|
||||
|
||||
wip_composite_asset = create_asset(
|
||||
asset_name="Asset Capitalization WIP Composite Asset",
|
||||
is_composite_asset=1,
|
||||
asset_type="Composite Asset",
|
||||
warehouse="Stores - TCP1",
|
||||
company=company,
|
||||
)
|
||||
@@ -245,7 +245,7 @@ class TestAssetCapitalization(IntegrationTestCase):
|
||||
|
||||
wip_composite_asset = create_asset(
|
||||
asset_name="Asset Capitalization WIP Composite Asset",
|
||||
is_composite_asset=1,
|
||||
asset_type="Composite Asset",
|
||||
warehouse="Stores - TCP1",
|
||||
company=company,
|
||||
)
|
||||
@@ -313,7 +313,7 @@ class TestAssetCapitalization(IntegrationTestCase):
|
||||
|
||||
wip_composite_asset = create_asset(
|
||||
asset_name="Asset Capitalization WIP Composite Asset",
|
||||
is_composite_asset=1,
|
||||
asset_type="Composite Asset",
|
||||
warehouse="Stores - TCP1",
|
||||
company=company,
|
||||
)
|
||||
@@ -361,7 +361,7 @@ class TestAssetCapitalization(IntegrationTestCase):
|
||||
|
||||
wip_composite_asset = create_asset(
|
||||
asset_name="Asset Capitalization WIP Composite Asset",
|
||||
is_composite_asset=1,
|
||||
asset_type="Composite Asset",
|
||||
warehouse="Stores - TCP1",
|
||||
company=company,
|
||||
)
|
||||
@@ -373,7 +373,7 @@ class TestAssetCapitalization(IntegrationTestCase):
|
||||
asset_value=consumed_asset_value,
|
||||
submit=1,
|
||||
warehouse="Stores - _TC",
|
||||
is_composite_component=1,
|
||||
asset_type="Composite Component",
|
||||
company=company,
|
||||
)
|
||||
|
||||
@@ -516,7 +516,7 @@ def create_depreciation_asset(**args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
asset = frappe.new_doc("Asset")
|
||||
asset.is_existing_asset = 1
|
||||
asset.asset_type = args.asset_type or "Existing Asset"
|
||||
asset.calculate_depreciation = 1
|
||||
asset.asset_owner = "Company"
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
calculate_depreciation=1,
|
||||
depreciation_method="Straight Line",
|
||||
available_for_use_date="2023-10-10",
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
opening_number_of_booked_depreciations=9,
|
||||
opening_accumulated_depreciation=265,
|
||||
depreciation_start_date="2024-07-31",
|
||||
@@ -127,7 +127,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
calculate_depreciation=1,
|
||||
depreciation_method="Straight Line",
|
||||
available_for_use_date="2023-10-10",
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
opening_number_of_booked_depreciations=9,
|
||||
opening_accumulated_depreciation=265.30,
|
||||
depreciation_start_date="2024-07-31",
|
||||
@@ -165,7 +165,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
calculate_depreciation=1,
|
||||
depreciation_method="Straight Line",
|
||||
available_for_use_date="2023-11-01",
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
opening_number_of_booked_depreciations=4,
|
||||
opening_accumulated_depreciation=223.15,
|
||||
depreciation_start_date="2024-12-31",
|
||||
@@ -529,7 +529,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
depreciation_start_date="2023-03-31",
|
||||
frequency_of_depreciation=1,
|
||||
total_number_of_depreciations=12,
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
opening_accumulated_depreciation=64.52,
|
||||
opening_number_of_booked_depreciations=2,
|
||||
submit=1,
|
||||
@@ -851,7 +851,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
depreciation_start_date="2023-03-31",
|
||||
frequency_of_depreciation=1,
|
||||
total_number_of_depreciations=12,
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
opening_accumulated_depreciation=64.52,
|
||||
opening_number_of_booked_depreciations=2,
|
||||
submit=1,
|
||||
@@ -925,7 +925,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
depreciation_start_date="2021-12-31",
|
||||
frequency_of_depreciation=12,
|
||||
total_number_of_depreciations=3,
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
submit=1,
|
||||
)
|
||||
post_depreciation_entries(date="2021-12-31")
|
||||
@@ -1014,7 +1014,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
depreciation_start_date="2021-12-31",
|
||||
frequency_of_depreciation=12,
|
||||
total_number_of_depreciations=3,
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
submit=1,
|
||||
)
|
||||
post_depreciation_entries(date="2021-12-31")
|
||||
@@ -1093,7 +1093,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase):
|
||||
rate_of_depreciation=50,
|
||||
frequency_of_depreciation=12,
|
||||
total_number_of_depreciations=3,
|
||||
is_existing_asset=1,
|
||||
asset_type="Existing Asset",
|
||||
submit=1,
|
||||
)
|
||||
post_depreciation_entries(date="2021-12-31")
|
||||
|
||||
@@ -360,7 +360,7 @@ class TestAssetRepair(IntegrationTestCase):
|
||||
self.assertEqual(stock_entry.asset_repair, asset_repair.name)
|
||||
|
||||
def test_gl_entries_with_capitalized_asset_repair(self):
|
||||
asset = create_asset(is_existing_asset=1, calculate_depreciation=1, submit=1)
|
||||
asset = create_asset(asset_type="Existing Asset", calculate_depreciation=1, submit=1)
|
||||
asset_repair = create_asset_repair(
|
||||
asset=asset, capitalize_repair_cost=1, item="_Test Non Stock Item", submit=1
|
||||
)
|
||||
@@ -400,7 +400,7 @@ def create_asset_repair(**args):
|
||||
if args.asset:
|
||||
asset = args.asset
|
||||
else:
|
||||
asset = create_asset(is_existing_asset=1, submit=1, company=args.company)
|
||||
asset = create_asset(asset_type=args.asset_type or "Existing Asset", submit=1, company=args.company)
|
||||
asset_repair = frappe.new_doc("Asset Repair")
|
||||
asset_repair.update(
|
||||
{
|
||||
|
||||
@@ -144,7 +144,7 @@ def get_conditions(filters):
|
||||
conditions[date_field] = ["between", [filters.year_start_date, filters.year_end_date]]
|
||||
|
||||
if filters.get("only_existing_assets"):
|
||||
conditions["is_existing_asset"] = filters.get("only_existing_assets")
|
||||
conditions["asset_type"] = "Existing Asset"
|
||||
if filters.get("asset_category"):
|
||||
conditions["asset_category"] = filters.get("asset_category")
|
||||
if filters.get("cost_center"):
|
||||
@@ -274,7 +274,7 @@ def get_asset_depreciation_amount_map(filters, finance_book):
|
||||
)
|
||||
|
||||
if filters.only_existing_assets:
|
||||
query = query.where(asset.is_existing_asset == 1)
|
||||
query = query.where(asset.asset_type == "Existing Asset")
|
||||
if filters.asset_category:
|
||||
query = query.where(asset.asset_category == filters.asset_category)
|
||||
if filters.cost_center:
|
||||
@@ -325,7 +325,7 @@ def get_asset_value_adjustment_map(filters, finance_book):
|
||||
)
|
||||
|
||||
if filters.only_existing_assets:
|
||||
query = query.where(asset.is_existing_asset == 1)
|
||||
query = query.where(asset.asset_type == "Existing Asset")
|
||||
if filters.asset_category:
|
||||
query = query.where(asset.asset_category == filters.asset_category)
|
||||
if filters.cost_center:
|
||||
|
||||
Reference in New Issue
Block a user