mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 04:09:11 +00:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user