diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 0df6a6c7de0..7c147545372 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -22,6 +22,7 @@ class Asset(AccountsController): self.validate_item() self.set_missing_values() self.prepare_depreciation_data() + self.validate_gross_and_purchase_amount() if self.get("schedules"): self.validate_expected_value_after_useful_life() @@ -123,6 +124,12 @@ class Asset(AccountsController): if self.available_for_use_date and getdate(self.available_for_use_date) < getdate(self.purchase_date): frappe.throw(_("Available-for-use Date should be after purchase date")) + + def validate_gross_and_purchase_amount(self): + if self.gross_purchase_amount and self.gross_purchase_amount != self.purchase_receipt_amount: + frappe.throw(_("Gross Purchase Amount should be {} to purchase amount of one single Asset. {}\ + Please do not book expense of multiple assets against one single Asset.") + .format(frappe.bold("equal"), "
"), title=_("Invalid Gross Purchase Amount")) def cancel_auto_gen_movement(self): movements = frappe.db.sql( diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index a56440de3d3..b767393532f 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -82,7 +82,6 @@ class TestAsset(unittest.TestCase): doc.set_missing_values() self.assertEquals(doc.items[0].is_fixed_asset, 1) - def test_schedule_for_straight_line_method(self): pr = make_purchase_receipt(item_code="Macbook Pro", qty=1, rate=100000.0, location="Test Location") @@ -599,6 +598,7 @@ def create_asset(**args): "purchase_date": "2015-01-01", "calculate_depreciation": 0, "gross_purchase_amount": 100000, + "purchase_receipt_amount": 100000, "expected_value_after_useful_life": 10000, "warehouse": args.warehouse or "_Test Warehouse - _TC", "available_for_use_date": "2020-06-06",