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:
@@ -19,6 +19,7 @@
|
||||
"column_break_17",
|
||||
"enable_common_party_accounting",
|
||||
"allow_multi_currency_invoices_against_single_party_account",
|
||||
"confirm_before_resetting_posting_date",
|
||||
"journals_section",
|
||||
"merge_similar_account_heads",
|
||||
"deferred_accounting_settings_section",
|
||||
@@ -606,6 +607,13 @@
|
||||
"fieldtype": "Check",
|
||||
"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",
|
||||
"fieldtype": "Section Break",
|
||||
|
||||
@@ -37,6 +37,7 @@ class AccountsSettings(Document):
|
||||
book_tax_discount_loss: DF.Check
|
||||
calculate_depr_using_total_days: DF.Check
|
||||
check_supplier_invoice_uniqueness: DF.Check
|
||||
confirm_before_resetting_posting_date: DF.Check
|
||||
create_pr_in_draft_status: DF.Check
|
||||
credit_controller: DF.Link | None
|
||||
delete_linked_ledger_entries: DF.Check
|
||||
|
||||
@@ -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.v14_0.update_full_name_in_contract
|
||||
erpnext.patches.v15_0.drop_sle_indexes
|
||||
execute:frappe.db.set_single_value("Accounts Settings", "confirm_before_resetting_posting_date", 1)
|
||||
|
||||
@@ -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