From 65f80abf2fef35f355e66c89cbfb10be2aafb59f Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 20 Jul 2024 00:44:31 +0200 Subject: [PATCH] fix: provide initial value for `.reduce()` call Fixes the error "TypeError: Reduce of empty array with no initial value" (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value#invalid_cases) --- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index d5fc02d3229a..3d92aa304e00 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -161,7 +161,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends ( const payment_is_overdue = doc.payment_schedule .map((row) => Date.parse(row.due_date) < Date.now()) - .reduce((prev, current) => prev || current); + .reduce((prev, current) => prev || current, false); if (payment_is_overdue) { this.frm.add_custom_button(