chore: Update allow on submit for Sales Invoice fields

This commit is contained in:
Deepesh Garg 2022-10-17 16:48:13 +05:30
parent 30da6ab2c1
commit e626107d3d
5 changed files with 32 additions and 15 deletions

View File

@ -76,13 +76,11 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
callback: (r) => {
if (!r.exc) {
frappe.msgprint(__('Accounting Entries are reposted'));
this.frm.trigger('refresh');
me.frm.refresh();
}
}
});
});
$(`["${encodeURIComponent("Repost Accounting Entries")}"]`).css('color', 'red');
}).removeClass('btn-default').addClass('btn-warning');
}
if (this.frm.doc.is_return) {

View File

@ -522,9 +522,10 @@ class SalesInvoice(SellingController):
def on_update_after_submit(self):
needs_repost = 0
# Check if any field affecting accounting entry is altered
doc_before_update = self.get_doc_before_save()
accounting_dimensions = get_accounting_dimensions()
accounting_dimensions = get_accounting_dimensions() + ["cost_center", "project"]
# Check if opening entry check updated
if doc_before_update.get("is_opening") != self.is_opening:
@ -552,12 +553,7 @@ class SalesInvoice(SellingController):
# Check for parent level
for index, item in enumerate(self.get("items")):
for field in (
"income_account",
"expense_account",
"discount_account",
"deferred_revenue_account",
):
for field in ("income_account", "expense_account", "discount_account"):
if doc_before_update.get("items")[index].get(field) != item.get(field):
needs_repost = 1
break
@ -567,6 +563,16 @@ class SalesInvoice(SellingController):
needs_repost = 1
break
for index, tax in enumerate(self.get("taxes")):
if doc_before_update.get("taxes")[index].get("account_head") != tax.get("account_head"):
needs_repost = 1
break
for dimension in accounting_dimensions:
if doc_before_update.get("taxes")[index].get(dimension) != tax.get(dimension):
needs_repost = 1
break
self.validate_accounts()
self.db_set("repost_required", needs_repost)

View File

@ -436,6 +436,7 @@
"label": "Accounting Details"
},
{
"allow_on_submit": 1,
"fieldname": "income_account",
"fieldtype": "Link",
"label": "Income Account",
@ -448,6 +449,7 @@
"width": "120px"
},
{
"allow_on_submit": 1,
"fieldname": "expense_account",
"fieldtype": "Link",
"label": "Expense Account",
@ -467,6 +469,7 @@
"print_hide": 1
},
{
"allow_on_submit": 1,
"default": ":Company",
"fieldname": "cost_center",
"fieldtype": "Link",
@ -798,6 +801,7 @@
"options": "Finance Book"
},
{
"allow_on_submit": 1,
"fieldname": "project",
"fieldtype": "Link",
"label": "Project",
@ -820,7 +824,6 @@
"label": "Incoming Rate (Costing)",
"no_copy": 1,
"options": "Company:company:default_currency",
"precision": "6",
"print_hide": 1
},
{
@ -833,6 +836,7 @@
"read_only": 1
},
{
"allow_on_submit": 1,
"fieldname": "discount_account",
"fieldtype": "Link",
"label": "Discount Account",
@ -876,7 +880,7 @@
"idx": 1,
"istable": 1,
"links": [],
"modified": "2022-10-10 20:57:38.340026",
"modified": "2022-10-17 12:51:44.825398",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",

View File

@ -51,6 +51,7 @@
"oldfieldtype": "Data"
},
{
"allow_on_submit": 1,
"columns": 2,
"fieldname": "account_head",
"fieldtype": "Link",
@ -63,6 +64,7 @@
"search_index": 1
},
{
"allow_on_submit": 1,
"default": ":Company",
"fieldname": "cost_center",
"fieldtype": "Link",
@ -216,12 +218,13 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2021-08-05 20:04:01.726867",
"modified": "2022-10-17 13:08:17.776528",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Taxes and Charges",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "ASC"
"sort_order": "ASC",
"states": []
}

View File

@ -143,6 +143,12 @@ var get_payment_mode_account = function(frm, mode_of_payment, callback) {
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (doc.docstatus == 1) {
// Should not trigger any changes on change post submit
return;
}
if(!d.charge_type && d.account_head){
frappe.msgprint(__("Please select Charge Type first"));
frappe.model.set_value(cdt, cdn, "account_head", "");