From ca2123edb4bdfcb49466f5b9581c688ba31efefe Mon Sep 17 00:00:00 2001 From: Felix van Hove Date: Fri, 21 Feb 2025 04:55:51 +0100 Subject: [PATCH] fix: Javascript "is undefined" error (#2266) Make Chart of Accounts Javascript run without error when no accounts exist Fixes: WEB-10 --- .../accounting/chart-of-accounts/gl-account-tree.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/accounting/chart-of-accounts/gl-account-tree.service.ts b/src/app/accounting/chart-of-accounts/gl-account-tree.service.ts index 72718e90e..50f85ec38 100644 --- a/src/app/accounting/chart-of-accounts/gl-account-tree.service.ts +++ b/src/app/accounting/chart-of-accounts/gl-account-tree.service.ts @@ -59,6 +59,10 @@ export class GlAccountTreeService { new GLAccountNode(this.translateService.instant('labels.inputs.accounting.LIABILITY')) ); + if (glAccountData.length === 0) { + return glAccountTree; + } + // Sort by parent id (so that child nodes can be added properly) if (!glAccountData[0].parentId) { glAccountData[0].parentId = 0;