From e5cb3e34fe26f4733056fea01fdcc47ef127f016 Mon Sep 17 00:00:00 2001 From: nick9822 Date: Wed, 15 Feb 2017 15:32:50 +0530 Subject: [PATCH 1/2] nowdate changed to purchase_date next depreciation date should be compared with purchase_date instead of nowdate. --- erpnext/accounts/doctype/asset/asset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/asset/asset.py b/erpnext/accounts/doctype/asset/asset.py index 9caac071f9..6a0cef5a11 100644 --- a/erpnext/accounts/doctype/asset/asset.py +++ b/erpnext/accounts/doctype/asset/asset.py @@ -80,7 +80,7 @@ class Asset(Document): if cint(self.number_of_depreciations_booked) > cint(self.total_number_of_depreciations): frappe.throw(_("Number of Depreciations Booked cannot be greater than Total Number of Depreciations")) - if self.next_depreciation_date and getdate(self.next_depreciation_date) < getdate(nowdate()): + if self.next_depreciation_date and getdate(self.next_depreciation_date) < getdate(self.purchase_date): frappe.msgprint(_("Next Depreciation Date is entered as past date")) if (flt(self.value_after_depreciation) > flt(self.expected_value_after_useful_life) @@ -242,4 +242,4 @@ def get_item_details(item_code): "asset_category": asset_category }) - return ret \ No newline at end of file + return ret From 23e174c270b72505e5e87363dc45f88882202660 Mon Sep 17 00:00:00 2001 From: nick9822 Date: Thu, 16 Feb 2017 16:26:38 +0530 Subject: [PATCH 2/2] Validation for purchase_date Separate validation for purchase date. --- erpnext/accounts/doctype/asset/asset.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/asset/asset.py b/erpnext/accounts/doctype/asset/asset.py index 6a0cef5a11..b8d0ec8170 100644 --- a/erpnext/accounts/doctype/asset/asset.py +++ b/erpnext/accounts/doctype/asset/asset.py @@ -80,8 +80,11 @@ class Asset(Document): if cint(self.number_of_depreciations_booked) > cint(self.total_number_of_depreciations): frappe.throw(_("Number of Depreciations Booked cannot be greater than Total Number of Depreciations")) + if self.next_depreciation_date and getdate(self.next_depreciation_date) < getdate(nowdate()): + frappe.msgprint(_("Next Depreciation Date is entered as past date"), title=_('Warning'), indicator='red') + if self.next_depreciation_date and getdate(self.next_depreciation_date) < getdate(self.purchase_date): - frappe.msgprint(_("Next Depreciation Date is entered as past date")) + frappe.throw(_("Next Depreciation Date cannot be before Purchase Date")) if (flt(self.value_after_depreciation) > flt(self.expected_value_after_useful_life) and not self.next_depreciation_date):