Merge pull request #42372 from khushi8112/correct-validation-for-depreciation-posting-date

fix: correct validation for depreciation posting date
This commit is contained in:
Khushi Rawat
2024-07-23 15:23:41 +05:30
committed by GitHub
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) { depreciation_start_date: function (frm, cdt, cdn) {
const book = locals[cdt][cdn]; const book = locals[cdt][cdn];
if ( if (frm.doc.available_for_use_date && book.depreciation_start_date < frm.doc.available_for_use_date) {
frm.doc.available_for_use_date && frappe.msgprint(__("Depreciation Posting Date cannot be before 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."));
book.depreciation_start_date = ""; book.depreciation_start_date = "";
frm.refresh_field("finance_books"); frm.refresh_field("finance_books");
} }

View File

@@ -268,10 +268,10 @@ class Asset(AccountsController):
frappe.throw(_("Available for use date is required")) frappe.throw(_("Available for use date is required"))
for d in self.finance_books: 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( 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), ).format(d.idx),
title=_("Incorrect Date"), title=_("Incorrect Date"),
) )