fix: correct validation for depreciation posting date

(cherry picked from commit da4ed90a3e)
This commit is contained in:
Khushi Rawat
2024-07-17 19:19:31 +05:30
committed by Mergify
parent 926fd41a2b
commit ffacf4222b
2 changed files with 4 additions and 7 deletions

View File

@@ -775,11 +775,8 @@ frappe.ui.form.on("Asset Finance Book", {
depreciation_start_date: function (frm, cdt, cdn) {
const book = locals[cdt][cdn];
if (
frm.doc.available_for_use_date &&
book.depreciation_start_date == frm.doc.available_for_use_date
) {
frappe.msgprint(__("Depreciation Posting Date should not be equal to Available for Use Date."));
if (frm.doc.available_for_use_date && book.depreciation_start_date < frm.doc.available_for_use_date) {
frappe.msgprint(__("Depreciation Posting Date cannot be before Available-for-use Date"));
book.depreciation_start_date = "";
frm.refresh_field("finance_books");
}

View File

@@ -267,10 +267,10 @@ class Asset(AccountsController):
frappe.throw(_("Available for use date is required"))
for d in self.finance_books:
if d.depreciation_start_date == self.available_for_use_date:
if getdate(d.depreciation_start_date) < getdate(self.available_for_use_date):
frappe.throw(
_(
"Row #{}: Depreciation Posting Date should not be equal to Available for Use Date."
"Depreciation Row {0}: Depreciation Posting Date cannot be before Available-for-use Date"
).format(d.idx),
title=_("Incorrect Date"),
)