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

@@ -19,6 +19,7 @@
"column_break_17", "column_break_17",
"enable_common_party_accounting", "enable_common_party_accounting",
"allow_multi_currency_invoices_against_single_party_account", "allow_multi_currency_invoices_against_single_party_account",
"confirm_before_resetting_posting_date",
"journals_section", "journals_section",
"merge_similar_account_heads", "merge_similar_account_heads",
"deferred_accounting_settings_section", "deferred_accounting_settings_section",
@@ -606,6 +607,13 @@
"fieldtype": "Check", "fieldtype": "Check",
"label": "Use New Budget Controller" "label": "Use New Budget Controller"
}, },
{
"default": "1",
"description": "If enabled, user will be alerted before resetting posting date to current date in relevant transactions",
"fieldname": "confirm_before_resetting_posting_date",
"fieldtype": "Check",
"label": "Confirm before resetting posting date"
},
{ {
"fieldname": "item_price_settings_section", "fieldname": "item_price_settings_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",

View File

@@ -37,6 +37,7 @@ class AccountsSettings(Document):
book_tax_discount_loss: DF.Check book_tax_discount_loss: DF.Check
calculate_depr_using_total_days: DF.Check calculate_depr_using_total_days: DF.Check
check_supplier_invoice_uniqueness: DF.Check check_supplier_invoice_uniqueness: DF.Check
confirm_before_resetting_posting_date: DF.Check
create_pr_in_draft_status: DF.Check create_pr_in_draft_status: DF.Check
credit_controller: DF.Link | None credit_controller: DF.Link | None
delete_linked_ledger_entries: DF.Check delete_linked_ledger_entries: DF.Check

View File

@@ -419,3 +419,4 @@ erpnext.patches.v15_0.rename_group_by_to_categorize_by_in_custom_reports
erpnext.patches.v15_0.remove_agriculture_roles erpnext.patches.v15_0.remove_agriculture_roles
erpnext.patches.v14_0.update_full_name_in_contract erpnext.patches.v14_0.update_full_name_in_contract
erpnext.patches.v15_0.drop_sle_indexes erpnext.patches.v15_0.drop_sle_indexes
execute:frappe.db.set_single_value("Accounts Settings", "confirm_before_resetting_posting_date", 1)

View File

@@ -875,6 +875,33 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
async validate() { async validate() {
await this.calculate_taxes_and_totals(false); 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() { update_stock() {