diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 272a180ca8d..496ffcd2648 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -1182,7 +1182,7 @@ class PurchaseInvoice(BuyingController): asset.name, { "gross_purchase_amount": purchase_amount, - "purchase_receipt_amount": purchase_amount, + "purchase_amount": purchase_amount, }, ) diff --git a/erpnext/assets/doctype/asset/asset.js b/erpnext/assets/doctype/asset/asset.js index 0f71e5d6f60..5ed62cb132f 100644 --- a/erpnext/assets/doctype/asset/asset.js +++ b/erpnext/assets/doctype/asset/asset.js @@ -652,7 +652,7 @@ frappe.ui.form.on("Asset", { ); frm.set_value("gross_purchase_amount", purchase_amount); - frm.set_value("purchase_receipt_amount", purchase_amount); + frm.set_value("purchase_amount", purchase_amount); frm.set_value("asset_quantity", asset_quantity); frm.set_value("cost_center", item.cost_center || purchase_doc.cost_center); if (item.asset_location) { diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index 39a0867d984..3a2a942bdf2 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -72,7 +72,7 @@ "status", "booked_fixed_asset", "column_break_51", - "purchase_receipt_amount", + "purchase_amount", "default_finance_book", "depr_entry_posting_status", "amended_from", @@ -408,15 +408,6 @@ "options": "Purchase Receipt", "print_hide": 1 }, - { - "fieldname": "purchase_receipt_amount", - "fieldtype": "Currency", - "hidden": 1, - "label": "Purchase Receipt Amount", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, { "depends_on": "eval:!doc.is_composite_asset && !doc.is_existing_asset", "fieldname": "purchase_invoice", @@ -546,6 +537,15 @@ "label": "Additional Asset Cost", "options": "Company:company:default_currency", "read_only": 1 + }, + { + "fieldname": "purchase_amount", + "fieldtype": "Currency", + "hidden": 1, + "label": "Purchase Amount", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 } ], "idx": 72, @@ -589,7 +589,7 @@ "link_fieldname": "target_asset" } ], - "modified": "2024-01-15 17:35:49.226603", + "modified": "2024-04-18 16:45:47.306032", "modified_by": "Administrator", "module": "Assets", "name": "Asset", @@ -633,4 +633,4 @@ "states": [], "title_field": "asset_name", "track_changes": 1 -} \ No newline at end of file +} diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 3a05a598b1c..4edfcd11c89 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -92,10 +92,10 @@ class Asset(AccountsController): number_of_depreciations_booked: DF.Int opening_accumulated_depreciation: DF.Currency policy_number: DF.Data | None + purchase_amount: DF.Currency purchase_date: DF.Date | None purchase_invoice: DF.Link | None purchase_receipt: DF.Link | None - purchase_receipt_amount: DF.Currency split_from: DF.Link | None status: DF.Literal[ "Draft", @@ -354,7 +354,7 @@ class Asset(AccountsController): if self.is_existing_asset: return - if self.gross_purchase_amount and self.gross_purchase_amount != self.purchase_receipt_amount: + if self.gross_purchase_amount and self.gross_purchase_amount != self.purchase_amount: error_message = _( "Gross Purchase Amount should be equal to purchase amount of one single Asset." ) @@ -696,7 +696,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 purchase_document and self.purchase_receipt_amount and self.available_for_use_date <= nowdate(): + if purchase_document and self.purchase_amount and getdate(self.available_for_use_date) <= getdate(): gl_entries.append( self.get_gl_dict( { @@ -704,8 +704,8 @@ class Asset(AccountsController): "against": fixed_asset_account, "remarks": self.get("remarks") or _("Accounting Entry for Asset"), "posting_date": self.available_for_use_date, - "credit": self.purchase_receipt_amount, - "credit_in_account_currency": self.purchase_receipt_amount, + "credit": self.purchase_amount, + "credit_in_account_currency": self.purchase_amount, "cost_center": self.cost_center, }, item=self, @@ -719,8 +719,8 @@ class Asset(AccountsController): "against": cwip_account, "remarks": self.get("remarks") or _("Accounting Entry for Asset"), "posting_date": self.available_for_use_date, - "debit": self.purchase_receipt_amount, - "debit_in_account_currency": self.purchase_receipt_amount, + "debit": self.purchase_amount, + "debit_in_account_currency": self.purchase_amount, "cost_center": self.cost_center, }, item=self, @@ -1116,8 +1116,8 @@ def create_new_asset_after_split(asset, split_qty): ) new_asset.gross_purchase_amount = new_gross_purchase_amount - if asset.purchase_receipt_amount: - new_asset.purchase_receipt_amount = new_gross_purchase_amount + if asset.purchase_amount: + new_asset.purchase_amount = new_gross_purchase_amount new_asset.opening_accumulated_depreciation = opening_accumulated_depreciation new_asset.asset_quantity = split_qty new_asset.split_from = asset.name diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 1b3951e86a6..5f5268180d4 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -1698,7 +1698,7 @@ def create_asset(**args): "opening_accumulated_depreciation": args.opening_accumulated_depreciation or 0, "number_of_depreciations_booked": args.number_of_depreciations_booked or 0, "gross_purchase_amount": args.gross_purchase_amount or 100000, - "purchase_receipt_amount": args.purchase_receipt_amount or 100000, + "purchase_amount": args.purchase_amount or 100000, "maintenance_required": args.maintenance_required or 0, "warehouse": args.warehouse or "_Test Warehouse - _TC", "available_for_use_date": args.available_for_use_date or "2020-06-06", diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py index 8d3bcfc153d..6c329b0da78 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py @@ -616,8 +616,7 @@ class AssetCapitalization(StockController): asset_doc.available_for_use_date = self.posting_date asset_doc.purchase_date = self.posting_date asset_doc.gross_purchase_amount = total_target_asset_value - asset_doc.purchase_receipt_amount = total_target_asset_value - asset_doc.purchase_receipt_amount = total_target_asset_value + asset_doc.purchase_amount = total_target_asset_value asset_doc.capitalized_in = self.name asset_doc.flags.ignore_validate = True asset_doc.flags.asset_created_via_asset_capitalization = True @@ -653,7 +652,7 @@ class AssetCapitalization(StockController): asset_doc = frappe.get_doc("Asset", self.target_asset) asset_doc.gross_purchase_amount = total_target_asset_value - asset_doc.purchase_receipt_amount = total_target_asset_value + asset_doc.purchase_amount = total_target_asset_value asset_doc.capitalized_in = self.name asset_doc.flags.ignore_validate = True asset_doc.save() diff --git a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py index 86a18c07d1f..31723ef3be3 100644 --- a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py +++ b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py @@ -89,7 +89,7 @@ class TestAssetCapitalization(unittest.TestCase): # Test Target Asset values target_asset = frappe.get_doc("Asset", asset_capitalization.target_asset) self.assertEqual(target_asset.gross_purchase_amount, total_amount) - self.assertEqual(target_asset.purchase_receipt_amount, total_amount) + self.assertEqual(target_asset.purchase_amount, total_amount) # Test Consumed Asset values self.assertEqual(consumed_asset.db_get("status"), "Capitalized") @@ -179,7 +179,7 @@ class TestAssetCapitalization(unittest.TestCase): # Test Target Asset values target_asset = frappe.get_doc("Asset", asset_capitalization.target_asset) self.assertEqual(target_asset.gross_purchase_amount, total_amount) - self.assertEqual(target_asset.purchase_receipt_amount, total_amount) + self.assertEqual(target_asset.purchase_amount, total_amount) # Test Consumed Asset values self.assertEqual(consumed_asset.db_get("status"), "Capitalized") @@ -256,7 +256,7 @@ class TestAssetCapitalization(unittest.TestCase): # Test Target Asset values target_asset = frappe.get_doc("Asset", asset_capitalization.target_asset) self.assertEqual(target_asset.gross_purchase_amount, total_amount) - self.assertEqual(target_asset.purchase_receipt_amount, total_amount) + self.assertEqual(target_asset.purchase_amount, total_amount) # Test General Ledger Entries expected_gle = { @@ -526,7 +526,7 @@ def create_depreciation_asset(**args): asset.available_for_use_date = args.available_for_use_date or asset.purchase_date asset.gross_purchase_amount = args.asset_value or 100000 - asset.purchase_receipt_amount = asset.gross_purchase_amount + asset.purchase_amount = asset.gross_purchase_amount finance_book = asset.append("finance_books") finance_book.depreciation_start_date = args.depreciation_start_date or "2020-12-31" diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 58bcc8c5fbe..14bf8ad7436 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -787,7 +787,7 @@ class BuyingController(SubcontractingController): "supplier": self.supplier, "purchase_date": self.posting_date, "calculate_depreciation": 0, - "purchase_receipt_amount": purchase_amount, + "purchase_amount": purchase_amount, "gross_purchase_amount": purchase_amount, "asset_quantity": asset_quantity, "purchase_receipt": self.name if self.doctype == "Purchase Receipt" else None, diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0465f2ca53e..f2868b90d5c 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -363,3 +363,4 @@ erpnext.patches.v14_0.set_maintain_stock_for_bom_item erpnext.patches.v15_0.delete_orphaned_asset_movement_item_records erpnext.patches.v15_0.fix_debit_credit_in_transaction_currency erpnext.patches.v15_0.remove_cancelled_asset_capitalization_from_asset +erpnext.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount diff --git a/erpnext/patches/v15_0/rename_purchase_receipt_amount_to_purchase_amount.py b/erpnext/patches/v15_0/rename_purchase_receipt_amount_to_purchase_amount.py new file mode 100644 index 00000000000..8af3ed26323 --- /dev/null +++ b/erpnext/patches/v15_0/rename_purchase_receipt_amount_to_purchase_amount.py @@ -0,0 +1,8 @@ +import frappe +from frappe.model.utils.rename_field import rename_field + + +def execute(): + frappe.reload_doc("assets", "doctype", "asset") + if frappe.db.has_column("Asset", "purchase_receipt_amount"): + rename_field("Asset", "purchase_receipt_amount", "purchase_amount") diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index af7b6c57a82..5f898b94268 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -858,7 +858,7 @@ class PurchaseReceipt(BuyingController): asset.name, { "gross_purchase_amount": purchase_amount, - "purchase_receipt_amount": purchase_amount, + "purchase_amount": purchase_amount, }, )