refactor: use correct field name

This commit is contained in:
khushi8112
2025-08-12 01:53:46 +05:30
parent bc17d778a6
commit 8f43b41cad
5 changed files with 14 additions and 13 deletions

View File

@@ -379,7 +379,7 @@ class Asset(AccountsController):
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:
frappe.throw(_("Gross Purchase Amount is mandatory"), frappe.MandatoryError)
frappe.throw(_("Net Purchase Amount is mandatory"), frappe.MandatoryError)
if is_cwip_accounting_enabled(self.asset_category):
if (
@@ -440,11 +440,11 @@ class Asset(AccountsController):
if self.net_purchase_amount and self.net_purchase_amount != self.purchase_amount:
error_message = _(
"Gross Purchase Amount should be <b>equal</b> to purchase amount of one single Asset."
"Net Purchase Amount should be <b>equal</b> to purchase amount of one single Asset."
)
error_message += "<br>"
error_message += _("Please do not book expense of multiple assets against one single Asset.")
frappe.throw(error_message, title=_("Invalid Gross Purchase Amount"))
frappe.throw(error_message, title=_("Invalid Net Purchase Amount"))
def make_asset_movement(self):
reference_doctype = "Purchase Receipt" if self.purchase_receipt else "Purchase Invoice"
@@ -488,7 +488,7 @@ class Asset(AccountsController):
)
if flt(row.expected_value_after_useful_life) >= flt(self.net_purchase_amount):
frappe.throw(
_("Row {0}: Expected Value After Useful Life must be less than Gross Purchase Amount").format(
_("Row {0}: Expected Value After Useful Life must be less than Net Purchase Amount").format(
row.idx
)
)

View File

@@ -380,12 +380,12 @@ class DepreciationScheduleController(StraightLineMethod, WDVMethod):
def validate_depreciation_amount_for_low_value_assets(self):
"""
If gross purchase amount is too low, then depreciation amount
If net purchase amount is too low, then depreciation amount
can come zero sometimes based on the frequency and number of depreciations.
"""
if flt(self.depreciation_amount, self.asset_doc.precision("net_purchase_amount")) <= 0:
frappe.throw(
_("Gross Purchase Amount {0} cannot be depreciated over {1} cycles.").format(
_("Net Purchase Amount {0} cannot be depreciated over {1} cycles.").format(
frappe.bold(self.asset_doc.net_purchase_amount),
frappe.bold(self.fb_row.total_number_of_depreciations),
)

View File

@@ -72,7 +72,7 @@ def get_data(filters):
"purchase_receipt",
"asset_category",
"purchase_date",
"gross_purchase_amount",
"net_purchase_amount",
"location",
"available_for_use_date",
"purchase_invoice",
@@ -87,7 +87,7 @@ def get_data(filters):
depreciation_amount = depreciation_amount_map.get(asset.asset_id) or 0.0
revaluation_amount = revaluation_amount_map.get(asset.asset_id, 0.0)
asset_value = (
asset.gross_purchase_amount
asset.net_purchase_amount
- asset.opening_accumulated_depreciation
- depreciation_amount
+ revaluation_amount
@@ -101,7 +101,7 @@ def get_data(filters):
"cost_center": asset.cost_center,
"vendor_name": pr_supplier_map.get(asset.purchase_receipt)
or pi_supplier_map.get(asset.purchase_invoice),
"gross_purchase_amount": asset.gross_purchase_amount,
"net_purchase_amount": asset.net_purchase_amount,
"opening_accumulated_depreciation": asset.opening_accumulated_depreciation,
"depreciated_amount": depreciation_amount,
"available_for_use_date": asset.available_for_use_date,
@@ -370,7 +370,7 @@ def get_group_by_data(
a["depreciated_amount"] = depreciation_amount_map.get(a["name"], 0.0)
a["revaluation_amount"] = revaluation_amount_map.get(a["name"], 0.0)
a["asset_value"] = (
a["gross_purchase_amount"]
a["net_purchase_amount"]
- a["opening_accumulated_depreciation"]
- a["depreciated_amount"]
+ a["revaluation_amount"]
@@ -435,7 +435,7 @@ def get_columns(filters):
"width": 216,
},
{
"label": _("Gross Purchase Amount"),
"label": _("Net Purchase Amount"),
"fieldname": "net_purchase_amount",
"fieldtype": "Currency",
"options": "Company:company:default_currency",
@@ -496,7 +496,7 @@ def get_columns(filters):
"width": 90,
},
{
"label": _("Gross Purchase Amount"),
"label": _("Net Purchase Amount"),
"fieldname": "net_purchase_amount",
"fieldtype": "Currency",
"options": "Company:company:default_currency",

View File

@@ -263,6 +263,7 @@ erpnext.patches.v15_0.rename_subcontracting_fields
erpnext.patches.v15_0.unset_incorrect_additional_discount_percentage
[post_model_sync]
erpnext.patches.v15_0.rename_gross_purchase_amount_to_net_purchase_amount
erpnext.patches.v15_0.create_asset_depreciation_schedules_from_assets
execute:frappe.delete_doc_if_exists('Workspace', 'ERPNext Integrations Settings')
erpnext.patches.v14_0.update_posting_datetime_and_dropped_indexes #22-02-2024

View File

@@ -562,7 +562,7 @@ class TestLandedCostVoucher(IntegrationTestCase):
self.assertEqual(entry.credit_in_account_currency, amounts[1])
def test_asset_lcv(self):
"Check if LCV for an Asset updates the Assets Gross Purchase Amount correctly."
"Check if LCV for an Asset updates the Assets Net Purchase Amount correctly."
frappe.db.set_value(
"Company", "_Test Company", "capital_work_in_progress_account", "CWIP Account - _TC"
)