feat: confirm with user before resetting posting date (#47667)

* feat: confirm with user before resetting posting date

* chore: pre-commit

* changes made as per review

---------

Co-authored-by: ruthra kumar <ruthra@erpnext.com>
This commit is contained in:
Debin Robert
2025-06-10 15:20:18 +05:30
committed by GitHub
parent 751815745f
commit 6529b288c2
4 changed files with 37 additions and 0 deletions

View File

@@ -875,6 +875,33 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
async validate() {
await this.calculate_taxes_and_totals(false);
await this.confirm_posting_date_change()
}
async confirm_posting_date_change() {
if (!frappe.meta.has_field(this.frm.doc.doctype, "set_posting_time")) return;
if (this.frm.doc.set_posting_time) return;
if (frappe.datetime.get_today() == this.frm.doc.posting_date) return;
let is_confirmation_reqd = await frappe.db.get_single_value(
'Accounts Settings', 'confirm_before_resetting_posting_date'
)
if (!is_confirmation_reqd) return;
return new Promise((resolve, reject) => {
frappe.confirm(
__(
"Posting Date will change to today's date as Edit Posting Date and Time is unchecked. Are you sure want to proceed?"
),
() => {
this.frm.doc.posting_date = frappe.datetime.get_today();
this.frm.refresh_field("posting_date");
resolve();
},
() => reject()
);
});
}
update_stock() {