From 1d6ef4b0d3dd84ad84c64c602a919f6776c62eb4 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Tue, 24 Aug 2021 22:06:19 +0530 Subject: [PATCH] fix: replacing $.each -> forEach in SI (#26995) * fix: replacing $.each -> forEach in SI * fix: removed console log Co-authored-by: Nabin Hait --- .../doctype/sales_invoice/sales_invoice.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index d8dee99b99..1e37e4b207 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -154,9 +154,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e return } - $.each(doc["items"], function(i, row) { + doc.items.forEach((row) => { if(row.delivery_note) frappe.model.clear_doc("Delivery Note", row.delivery_note) - }) + }); } set_default_print_format() { @@ -455,12 +455,15 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e } currency() { + var me = this; super.currency(); - $.each(cur_frm.doc.timesheets, function(i, d) { - let row = frappe.get_doc(d.doctype, d.name) - set_timesheet_detail_rate(row.doctype, row.name, cur_frm.doc.currency, row.timesheet_detail) - }); - calculate_total_billing_amount(cur_frm) + if (this.frm.doc.timesheets) { + this.frm.doc.timesheets.forEach((d) => { + let row = frappe.get_doc(d.doctype, d.name) + set_timesheet_detail_rate(row.doctype, row.name, me.frm.doc.currency, row.timesheet_detail) + }); + calculate_total_billing_amount(this.frm); + } } }; @@ -983,9 +986,9 @@ var calculate_total_billing_amount = function(frm) { doc.total_billing_amount = 0.0 if (doc.timesheets) { - $.each(doc.timesheets, function(index, data){ - doc.total_billing_amount += flt(data.billing_amount) - }) + doc.timesheets.forEach((d) => { + doc.total_billing_amount += flt(d.billing_amount) + }); } refresh_field('total_billing_amount')