@finsys/core 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -35,13 +35,17 @@ __export(index_exports, {
35
35
  DEFAULT_VALIDATOR_DEFINITIONS: () => DEFAULT_VALIDATOR_DEFINITIONS,
36
36
  FIELD_TYPE_DEFINITIONS: () => FIELD_TYPE_DEFINITIONS,
37
37
  FieldType: () => FieldType,
38
+ FileFieldTableType: () => FileFieldTableType,
38
39
  FileFormField: () => FileFormField,
39
40
  FormField: () => FormField,
40
41
  FormFieldCategory: () => FormFieldCategory,
41
42
  FormFieldValidator: () => FormFieldValidator,
42
43
  FormSpec: () => FormSpec,
44
+ IhsValueFormat: () => IhsValueFormat,
43
45
  applyDynamicTitles: () => applyDynamicTitles,
46
+ buildFileFieldTables: () => buildFileFieldTables,
44
47
  evaluateExpression: () => evaluateExpression,
48
+ extractTimePeriods: () => extractTimePeriods,
45
49
  generateRHFSchema: () => generateRHFSchema,
46
50
  generateSurveyJson: () => generateSurveyJson,
47
51
  getBaseCategories: () => getBaseCategories,
@@ -49,11 +53,17 @@ __export(index_exports, {
49
53
  getBaseFieldSpecMap: () => getBaseFieldSpecMap,
50
54
  getBaseFieldSpecs: () => getBaseFieldSpecs,
51
55
  getCategoryName: () => getCategoryName,
56
+ getDisplayName: () => getDisplayName,
57
+ getDisplayNames: () => getDisplayNames,
52
58
  getPastMonthLabel: () => getPastMonthLabel,
53
59
  getPastYearLabel: () => getPastYearLabel,
54
60
  getStepDefaultValues: () => getStepDefaultValues,
55
61
  getStepSchema: () => getStepSchema,
62
+ groupColumnsByTimePeriod: () => groupColumnsByTimePeriod,
63
+ groupDetailsByCategory: () => groupDetailsByCategory,
56
64
  groupFieldsByCategory: () => groupFieldsByCategory,
65
+ groupFieldsByPattern: () => groupFieldsByPattern,
66
+ processIhsDetails: () => processIhsDetails,
57
67
  resolvePageFields: () => resolvePageFields,
58
68
  validateFormConfig: () => validateFormConfig,
59
69
  validateFormSpec: () => validateFormSpec,
@@ -1328,14 +1338,6 @@ var form_field_base_specs_default = {
1328
1338
  {
1329
1339
  id: "13",
1330
1340
  name: "Document Upload"
1331
- },
1332
- {
1333
- id: "14",
1334
- name: "SSM Company Profile Data"
1335
- },
1336
- {
1337
- id: "15",
1338
- name: "NRIC Data"
1339
1341
  }
1340
1342
  ],
1341
1343
  fields: [
@@ -1398,7 +1400,7 @@ var form_field_base_specs_default = {
1398
1400
  title: "ID Number",
1399
1401
  placeholder: "E.g. 700513065143",
1400
1402
  isRequired: true,
1401
- displayName: "IC Number (Manual Entry)",
1403
+ displayName: "IC Number",
1402
1404
  maxLength: 25,
1403
1405
  inputType: "text",
1404
1406
  validators: [
@@ -8683,165 +8685,6 @@ var form_field_base_specs_default = {
8683
8685
  "payslipOtherDeductionT6"
8684
8686
  ],
8685
8687
  category: "13"
8686
- },
8687
- {
8688
- name: "ic",
8689
- displayName: "Identity Card (NRIC)",
8690
- type: "file",
8691
- ihs_column_names: [
8692
- "icName",
8693
- "icNumber",
8694
- "icAddress",
8695
- "icGender",
8696
- "icReligion",
8697
- "icDateOfBirth",
8698
- "icPlaceOfBirth",
8699
- "icNationality",
8700
- "icRace"
8701
- ],
8702
- category: "13"
8703
- },
8704
- {
8705
- name: "ssmCompanyName",
8706
- displayName: "Company Name (SSM Profile)",
8707
- type: "text",
8708
- category: "14"
8709
- },
8710
- {
8711
- name: "ssmCompanyRegNo",
8712
- displayName: "Company Registration No (SSM Profile)",
8713
- type: "text",
8714
- category: "14"
8715
- },
8716
- {
8717
- name: "ssmIncorporatedDate",
8718
- displayName: "Incorporated Date (SSM Profile)",
8719
- type: "text",
8720
- inputType: "date",
8721
- category: "14"
8722
- },
8723
- {
8724
- name: "businessCommencementDate",
8725
- displayName: "Business Commencement Date",
8726
- type: "text",
8727
- inputType: "date",
8728
- category: "14"
8729
- },
8730
- {
8731
- name: "businessNature",
8732
- displayName: "Business Nature",
8733
- type: "text",
8734
- category: "14"
8735
- },
8736
- {
8737
- name: "companyStatus",
8738
- displayName: "Company Status (SSM)",
8739
- type: "text",
8740
- category: "14"
8741
- },
8742
- {
8743
- name: "shareholders",
8744
- displayName: "Shareholders",
8745
- type: "text",
8746
- category: "14"
8747
- },
8748
- {
8749
- name: "directors",
8750
- displayName: "Directors",
8751
- type: "text",
8752
- category: "14"
8753
- },
8754
- {
8755
- name: "previousDirectors",
8756
- displayName: "Previous Directors",
8757
- type: "text",
8758
- category: "14"
8759
- },
8760
- {
8761
- name: "totalShareIssued",
8762
- displayName: "Total Shares Issued",
8763
- type: "text",
8764
- category: "14"
8765
- },
8766
- {
8767
- name: "companyLastOldName",
8768
- displayName: "Previous Company Name",
8769
- type: "text",
8770
- category: "14"
8771
- },
8772
- {
8773
- name: "companyNameDateOfChange",
8774
- displayName: "Company Name Change Date",
8775
- type: "text",
8776
- inputType: "date",
8777
- category: "14"
8778
- },
8779
- {
8780
- name: "businessOrigin",
8781
- displayName: "Business Origin",
8782
- type: "text",
8783
- category: "14"
8784
- },
8785
- {
8786
- name: "registeredAddress",
8787
- displayName: "Registered Address (SSM)",
8788
- type: "text",
8789
- category: "14"
8790
- },
8791
- {
8792
- name: "icName",
8793
- displayName: "Full Name (NRIC)",
8794
- type: "text",
8795
- category: "15"
8796
- },
8797
- {
8798
- name: "icNumber",
8799
- displayName: "IC Number (NRIC Extracted)",
8800
- type: "text",
8801
- category: "15"
8802
- },
8803
- {
8804
- name: "icAddress",
8805
- displayName: "Address (NRIC)",
8806
- type: "text",
8807
- category: "15"
8808
- },
8809
- {
8810
- name: "icGender",
8811
- displayName: "Gender (NRIC)",
8812
- type: "text",
8813
- category: "15"
8814
- },
8815
- {
8816
- name: "icReligion",
8817
- displayName: "Religion (NRIC)",
8818
- type: "text",
8819
- category: "15"
8820
- },
8821
- {
8822
- name: "icDateOfBirth",
8823
- displayName: "Date of Birth (NRIC)",
8824
- type: "text",
8825
- inputType: "date",
8826
- category: "15"
8827
- },
8828
- {
8829
- name: "icPlaceOfBirth",
8830
- displayName: "Place of Birth (NRIC)",
8831
- type: "text",
8832
- category: "15"
8833
- },
8834
- {
8835
- name: "icNationality",
8836
- displayName: "Nationality (NRIC)",
8837
- type: "text",
8838
- category: "15"
8839
- },
8840
- {
8841
- name: "icRace",
8842
- displayName: "Race (NRIC)",
8843
- type: "text",
8844
- category: "15"
8845
8688
  }
8846
8689
  ]
8847
8690
  };
@@ -9318,6 +9161,451 @@ function getBaseFieldNames() {
9318
9161
  cachedFieldNames = [...new Set(names)];
9319
9162
  return cachedFieldNames;
9320
9163
  }
9164
+
9165
+ // src/ihs-types.ts
9166
+ var IhsValueFormat = /* @__PURE__ */ ((IhsValueFormat2) => {
9167
+ IhsValueFormat2["STRING"] = "string";
9168
+ IhsValueFormat2["CURRENCY"] = "currency";
9169
+ IhsValueFormat2["NUMBER"] = "number";
9170
+ IhsValueFormat2["PERCENTAGE"] = "percentage";
9171
+ IhsValueFormat2["DATE"] = "date";
9172
+ IhsValueFormat2["TABLE"] = "table";
9173
+ return IhsValueFormat2;
9174
+ })(IhsValueFormat || {});
9175
+ var FileFieldTableType = /* @__PURE__ */ ((FileFieldTableType2) => {
9176
+ FileFieldTableType2["TIME_SERIES"] = "timeSeries";
9177
+ FileFieldTableType2["KEY_VALUE"] = "keyValue";
9178
+ return FileFieldTableType2;
9179
+ })(FileFieldTableType || {});
9180
+
9181
+ // src/data/form-field-display-names.json
9182
+ var form_field_display_names_default = {
9183
+ accountHolderName: "Account Holder Name",
9184
+ statementDate: "Statement Date",
9185
+ bankName: "Bank Name",
9186
+ accountNumber: "Account Number",
9187
+ totalCredits: "Total Credits",
9188
+ totalDebits: "Total Debits",
9189
+ openingBalance: "Opening Balance",
9190
+ bankBalance: "Bank Balance",
9191
+ nonCurrentAssetsSubsidiaryCompanies: "Subsidiary Companies (Non-Current Assets)",
9192
+ nonCurrentAssetsAssociatedCompanies: "Associated Companies (Non-Current Assets)",
9193
+ nonCurrentAssetsDevelopmentPropertiesOrExpenditure: "Development Properties/Expenditure (Non-Current Assets)",
9194
+ nonCurrentAssetInvestmentProperties: "Investment Properties (Non-Current Assets)",
9195
+ nonCurrentAssetsInvestments: "Investments (Non-Current Assets)",
9196
+ nonCurrentAssetInvestmentSecurities: "Investment Securities (Non-Current Assets)",
9197
+ nonCurrentAssetDeferredAssets: "Deferred Assets (Non-Current Assets)",
9198
+ nonCurrentAssetDeposits: "Deposits (Non-Current Assets)",
9199
+ nonCurrentAssetOwnGoodwill: "Own Goodwill (Non-Current Assets)",
9200
+ nonCurrentAssetGoodwillOnConsolidation: "Goodwill on Consolidation (Non-Current Assets)",
9201
+ nonCurrentAssetSinkingFund: "Sinking Fund (Non-Current Assets)",
9202
+ nonCurrentAssetPropertyPlantEquipment: "Property, Plant & Equipment (Non-Current Assets)",
9203
+ nonCurrentAssetInventories: "Inventories (Non-Current Assets)",
9204
+ nonCurrentAssetRightOfUseAssets: "Right of Use Assets (Non-Current Assets)",
9205
+ nonCurrentAssetIntangibleAssets: "Intangible Assets (Non-Current Assets)",
9206
+ nonCurrentAssetPrepaidLeasePayments: "Prepaid Lease Payments (Non-Current Assets)",
9207
+ nonCurrentAssetFinancialAssetAtFairValue: "Financial Assets at Fair Value (Non-Current Assets)",
9208
+ nonCurrentAssetLandUseRight: "Land Use Rights (Non-Current Assets)",
9209
+ nonCurrentAssetTradeReceivables: "Trade Receivables (Non-Current Assets)",
9210
+ nonCurrentAssetOtherReceivables: "Other Receivables (Non-Current Assets)",
9211
+ nonCurrentAssetTradeAndOtherReceivables: "Trade and Other Receivables (Non-Current Assets)",
9212
+ nonCurrentAssetOtherReceivablesDepositsAndPrepayments: "Other Receivables, Deposits and Prepayments (Non-Current Assets)",
9213
+ totalNonCurrentAssets: "Total Non-Current Assets",
9214
+ currentAssetDevelopmentPropertiesOrExpenditure: "Development Properties/Expenditure (Current Assets)",
9215
+ currentAssetShortTermInvestments: "Short Term Investments (Current Assets)",
9216
+ currentAssetTradeDebtors: "Trade Debtors (Current Assets)",
9217
+ currentAssetShortTermDeposits: "Short Term Deposits (Current Assets)",
9218
+ currentAssetAmountDueFromHoldingCompany: "Amount Due from Holding Company (Current Assets)",
9219
+ currentAssetAmountDueFromSubsidiaryCompanies: "Amount Due from Subsidiary Companies (Current Assets)",
9220
+ currentAssetAmountDueFromAssociatedCompanies: "Amount Due from Associated Companies (Current Assets)",
9221
+ currentAssetAmountDueFromDirector: "Amount Due from Director (Current Assets)",
9222
+ currentAssetAmountDueFromCustomer: "Amount Due from Customer (Current Assets)",
9223
+ currentAssetAmountOwingByShareholders: "Amount Owing by Shareholders (Current Assets)",
9224
+ currentAssetInventories: "Inventories (Current Assets)",
9225
+ currentAssetFinancialAssetAtFairValue: "Financial Assets at Fair Value (Current Assets)",
9226
+ currentAssetLandUseRight: "Land Use Rights (Current Assets)",
9227
+ currentAssetTaxRecoverable: "Tax Recoverable (Current Assets)",
9228
+ currentAssetContractAssets: "Contract Assets (Current Assets)",
9229
+ currentAssetCurrentTaxAssets: "Current Tax Assets (Current Assets)",
9230
+ currentAssetPrepayments: "Prepayments (Current Assets)",
9231
+ currentAssetDerivative: "Derivatives (Current Assets)",
9232
+ currentAssetCashAndBankBalances: "Cash and Bank Balances (Current Assets)",
9233
+ currentAssetOtherReceivables: "Other Receivables (Current Assets)",
9234
+ currentAssetRestrictedCash: "Restricted Cash (Current Assets)",
9235
+ currentAssetCashAndCashEquivalents: "Cash and Cash Equivalents (Current Assets)",
9236
+ currentAssetDepositsCashAndBankBalances: "Deposits, Cash and Bank Balances (Current Assets)",
9237
+ currentAssetCashAtBanks: "Cash at Banks (Current Assets)",
9238
+ currentAssetCashOnHand: "Cash on Hand (Current Assets)",
9239
+ currentAssetDepositsAndPrepayments: "Deposits and Prepayments (Current Assets)",
9240
+ currentAssetTradeAndOtherReceivables: "Trade and Other Receivables (Current Assets)",
9241
+ currentAssetOtherReceivablesDepositsAndPrepayments: "Other Receivables, Deposits and Prepayments (Current Assets)",
9242
+ currentAssetOtherReceivablesAndDeposits: "Other Receivables and Deposits (Current Assets)",
9243
+ currentAssetOtherReceivablesAndPrepayments: "Other Receivables and Prepayments (Current Assets)",
9244
+ currentAssetCash: "Cash (Current Assets)",
9245
+ totalCurrentAssets: "Total Current Assets",
9246
+ totalAssets: "Total Assets",
9247
+ currentLiabilitiesTradeCreditors: "Trade Creditors (Current Liabilities)",
9248
+ currentLiabilitiesHirePurchasePayables: "Hire Purchase Payables (Current Liabilities)",
9249
+ currentLiabilitiesBankOverdraft: "Bank Overdraft (Current Liabilities)",
9250
+ currentLiabilitiesBankAcceptance: "Bank Acceptance (Current Liabilities)",
9251
+ currentLiabilitiesBorrowingsOrTermLoans: "Borrowings/Term Loans (Current Liabilities)",
9252
+ currentLiabilitiesBankborrowings: "Bank Borrowings (Current Liabilities)",
9253
+ currentLiabilitiesAmountsOwingToHoldingCompany: "Amounts Owing to Holding Company (Current Liabilities)",
9254
+ currentLiabilitiesAmountsOwingToSubsidiaryCompanies: "Amounts Owing to Subsidiary Companies (Current Liabilities)",
9255
+ currentLiabilitiesAmountOwingToAssociatedCompanies: "Amount Owing to Associated Companies (Current Liabilities)",
9256
+ currentLiabilitiesAmountsOwingToDirector: "Amounts Owing to Director (Current Liabilities)",
9257
+ currentLiabilitiesProvisionForTaxation: "Provision for Taxation (Current Liabilities)",
9258
+ currentLiabilitiesLeasePayables: "Lease Payables (Current Liabilities)",
9259
+ currentLiabilitiesFinanceLeasePayables: "Finance Lease Payables (Current Liabilities)",
9260
+ currentLiabilitiesOtherPayables: "Other Payables (Current Liabilities)",
9261
+ currentLiabilitiesDividendPayables: "Dividend Payables (Current Liabilities)",
9262
+ currentLiabilitiesTradeAndOtherPayables: "Trade and Other Payables (Current Liabilities)",
9263
+ currentLiabilitiesDepositsFromCustomers: "Deposits from Customers (Current Liabilities)",
9264
+ currentLiabilitiesOtherPayablesAccrualsAndDeposits: "Other Payables, Accruals and Deposits (Current Liabilities)",
9265
+ currentLiabilitiesOtherPayablesAndAccruals: "Other Payables and Accruals (Current Liabilities)",
9266
+ currentLiabilitiesContractLiabilities: "Contract Liabilities (Current Liabilities)",
9267
+ currentLiabilitiesDerivative: "Derivative Liabilities (Current Liabilities)",
9268
+ totalCurrentLiabilities: "Total Current Liabilities",
9269
+ shortTermLiabilities: "Short Term Liabilities",
9270
+ nonCurrentLiabilitiesBorrowingsOrTermLoans: "Borrowings/Term Loans (Non-Current Liabilities)",
9271
+ nonCurrentLiabilitiesBankBorrowings: "Bank Borrowings (Non-Current Liabilities)",
9272
+ nonCurrentLiabilitiesLeaseObligations: "Lease Obligations (Non-Current Liabilities)",
9273
+ nonCurrentLiabilitiesFinanceLeaseObligations: "Finance Lease Obligations (Non-Current Liabilities)",
9274
+ nonCurrentLiabilitiesDeferredTaxation: "Deferred Taxation (Non-Current Liabilities)",
9275
+ nonCurrentLiabilitiesRetirementBenefits: "Retirement Benefits (Non-Current Liabilities)",
9276
+ nonCurrentLiabilitiesHirePurchasePayables: "Hire Purchase Payables (Non-Current Liabilities)",
9277
+ nonCurrentLiabilitiesDepositsFromCustomers: "Deposits from Customers (Non-Current Liabilities)",
9278
+ nonCurrentLiabilitiesContractLiabilities: "Contract Liabilities (Non-Current Liabilities)",
9279
+ totalNonCurrentLiabilities: "Total Non-Current Liabilities",
9280
+ totalLiabilities: "Total Liabilities",
9281
+ tangibleAssets: "Tangible Assets",
9282
+ shareCapital: "Share Capital",
9283
+ preferenceShareCapital: "Preference Share Capital",
9284
+ sharePremium: "Share Premium",
9285
+ reserves: "Reserves",
9286
+ capitalReserves: "Capital Reserves",
9287
+ revaluationReserves: "Revaluation Reserves",
9288
+ exchangeEqualisationOrFluctuationReserves: "Exchange Equalisation/Fluctuation Reserves",
9289
+ retainedEarnings: "Retained Earnings",
9290
+ totalEquity: "Total Equity",
9291
+ revenue: "Revenue",
9292
+ costOfGoodsSold: "Cost of Goods Sold",
9293
+ grossProfit: "Gross Profit",
9294
+ otherIncome: "Other Income",
9295
+ profitFromOperations: "Profit from Operations",
9296
+ financeCost: "Finance Cost",
9297
+ ebitda: "Profit Before Tax",
9298
+ taxes: "Taxes",
9299
+ zakat: "Zakat",
9300
+ profitAfterTax: "Profit After Tax",
9301
+ netProfit: "Net Profit",
9302
+ netOperatingCashFlow: "Net Operating Cash Flow",
9303
+ depreciation: "Depreciation",
9304
+ depreciationOfPropertyPlantEquipment: "Depreciation of Property, Plant & Equipment",
9305
+ depreciationRightOfUseAssets: "Depreciation of Right of Use Assets",
9306
+ depreciationOfInvestmentProperties: "Depreciation of Investment Properties",
9307
+ depreciationOfInvestmentSecurities: "Depreciation of Investment Securities",
9308
+ endOfYearCash: "End of Year Cash",
9309
+ epfAccountHolderName: "Account Holder Name",
9310
+ epfAccountHolderAddress: "Account Holder Address",
9311
+ epfStatementYear: "Statement Year",
9312
+ epfKwspMemberNumber: "KWSP Member Number",
9313
+ epfIcNumber: "IC No.",
9314
+ epfEmployerNumber: "Employer Number",
9315
+ epfDateOfStatement: "Date Of Statement",
9316
+ epfTotalContribution: "Total Contribution",
9317
+ epfTotalCurrentContribution: "Total Current Contribution",
9318
+ payslipEmployerName: "Employer Name",
9319
+ payslipEmployeeName: "Employee Name",
9320
+ payslipPayPeriod: "Pay Period",
9321
+ payslipPayDate: "Pay Date",
9322
+ payslipGrossPay: "Gross Pay",
9323
+ payslipDeduction: "Deduction",
9324
+ payslipEmployeeEpfContribution: "Employee EPF Contribution",
9325
+ payslipEmployeeSocsoContribution: "Employee SOCSO Contribution",
9326
+ payslipNetPay: "Net Pay",
9327
+ incorporatedDate: "Incorporated Date",
9328
+ companyName: "Company Name",
9329
+ companyRegNo: "Company Registration No.",
9330
+ ssmCompanyName: "Company Name (SSM)",
9331
+ ssmCompanyRegNo: "Registration No. (SSM)",
9332
+ ssmIncorporatedDate: "Incorporated Date (SSM)",
9333
+ businessCommencementDate: "Business Commencement Date",
9334
+ businessNature: "Business Nature",
9335
+ companyStatus: "Company Status",
9336
+ shareholders: "Shareholders",
9337
+ directors: "Directors",
9338
+ previousDirectors: "Previous Directors",
9339
+ totalShareIssued: "Total Shares Issued",
9340
+ companyLastOldName: "Previous Company Name",
9341
+ companyNameDateOfChange: "Company Name Change Date",
9342
+ businessOrigin: "Business Origin",
9343
+ registeredAddress: "Registered Address",
9344
+ icName: "Name (IC)",
9345
+ icNumber: "IC Number",
9346
+ icAddress: "Address (IC)",
9347
+ icGender: "Gender (IC)",
9348
+ icReligion: "Religion (IC)",
9349
+ icDateOfBirth: "Date of Birth (IC)",
9350
+ icPlaceOfBirth: "Place of Birth (IC)",
9351
+ icNationality: "Nationality (IC)",
9352
+ icRace: "Race (IC)"
9353
+ };
9354
+
9355
+ // src/ihs-processing.ts
9356
+ var displayNames = form_field_display_names_default;
9357
+ function getDisplayNames() {
9358
+ return displayNames;
9359
+ }
9360
+ function getDisplayName(fieldName) {
9361
+ if (displayNames[fieldName]) return displayNames[fieldName];
9362
+ return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
9363
+ }
9364
+ var TIME_PERIOD_REGEX = /T(\d+)$/;
9365
+ function extractTimePeriods(columnNames) {
9366
+ const periods = /* @__PURE__ */ new Set();
9367
+ for (const col of columnNames) {
9368
+ const match = TIME_PERIOD_REGEX.exec(col);
9369
+ if (match) periods.add(`T${match[1]}`);
9370
+ }
9371
+ return [...periods].sort((a, b) => {
9372
+ const numA = parseInt(a.slice(1), 10);
9373
+ const numB = parseInt(b.slice(1), 10);
9374
+ return numA - numB;
9375
+ });
9376
+ }
9377
+ function groupColumnsByTimePeriod(columnNames) {
9378
+ const groups = {};
9379
+ for (const col of columnNames) {
9380
+ const match = /^(.+?)(T\d+)$/.exec(col);
9381
+ if (!match) continue;
9382
+ const [, baseName, period] = match;
9383
+ if (!groups[baseName]) groups[baseName] = {};
9384
+ groups[baseName][period] = col;
9385
+ }
9386
+ return groups;
9387
+ }
9388
+ var FIELD_GROUP_PREFIXES = [
9389
+ ["bank_statement", "bank_statements"],
9390
+ ["financials", "financials"],
9391
+ ["epf_statement", "epf_statements"],
9392
+ ["payslip_statement", "payslip_statements"],
9393
+ ["ssm", "ssm_documents"],
9394
+ ["ic_", "ic_documents"]
9395
+ ];
9396
+ function groupFieldsByPattern(fields) {
9397
+ const groups = {};
9398
+ for (const field of fields) {
9399
+ if (!field.name) continue;
9400
+ let groupName = field.name;
9401
+ for (const [prefix, group] of FIELD_GROUP_PREFIXES) {
9402
+ if (field.name.startsWith(prefix)) {
9403
+ groupName = group;
9404
+ break;
9405
+ }
9406
+ }
9407
+ if (!groups[groupName]) groups[groupName] = [];
9408
+ groups[groupName].push(field);
9409
+ }
9410
+ return groups;
9411
+ }
9412
+ var GROUP_DISPLAY_NAMES = {
9413
+ bank_statements: "Bank Statements",
9414
+ financials: "Audited Financial Statements",
9415
+ epf_statements: "EPF Statements",
9416
+ payslip_statements: "Payslip Statements",
9417
+ ssm_documents: "SSM Company Information",
9418
+ ic_documents: "Identification Card"
9419
+ };
9420
+ function isNumericField(fieldName) {
9421
+ const patterns = [
9422
+ "balance",
9423
+ "amount",
9424
+ "credit",
9425
+ "debit",
9426
+ "total",
9427
+ "revenue",
9428
+ "cost",
9429
+ "income",
9430
+ "expense",
9431
+ "liability",
9432
+ "asset",
9433
+ "equity",
9434
+ "profit",
9435
+ "loss",
9436
+ "cash",
9437
+ "tax",
9438
+ "interest"
9439
+ ];
9440
+ const lower = fieldName.toLowerCase();
9441
+ return patterns.some((p) => lower.includes(p));
9442
+ }
9443
+ function formatValue(value, numeric) {
9444
+ if (value === null || value === void 0 || value === "") return "-";
9445
+ if (numeric) {
9446
+ const num = Number(value);
9447
+ if (!isNaN(num))
9448
+ return num.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
9449
+ }
9450
+ return String(value);
9451
+ }
9452
+ function buildTableForGroup(groupName, fields, ihsData) {
9453
+ const allColumns = [];
9454
+ for (const field of fields) {
9455
+ if (field.ihs_column_names) {
9456
+ allColumns.push(...field.ihs_column_names);
9457
+ }
9458
+ }
9459
+ if (allColumns.length === 0) return null;
9460
+ const periods = extractTimePeriods(allColumns);
9461
+ const isTimeSeries = periods.length > 0;
9462
+ const tableType = isTimeSeries ? "timeSeries" /* TIME_SERIES */ : "keyValue" /* KEY_VALUE */;
9463
+ const groupDisplayName = GROUP_DISPLAY_NAMES[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9464
+ if (isTimeSeries) {
9465
+ const columnGroups = groupColumnsByTimePeriod(allColumns);
9466
+ const items = [];
9467
+ for (const [baseName, periodMap] of Object.entries(columnGroups)) {
9468
+ const numeric = isNumericField(baseName);
9469
+ const data = {};
9470
+ const formattedData = {};
9471
+ for (const period of periods) {
9472
+ const colName = periodMap[period];
9473
+ const value = colName ? ihsData[colName] ?? null : null;
9474
+ data[period] = value;
9475
+ formattedData[period] = formatValue(value, numeric);
9476
+ }
9477
+ items.push({
9478
+ displayName: getDisplayName(baseName),
9479
+ timePeriods: periods,
9480
+ data,
9481
+ formattedData,
9482
+ type: tableType,
9483
+ isNumeric: numeric
9484
+ });
9485
+ }
9486
+ const hasData = items.some(
9487
+ (item) => Object.values(item.data).some((v) => v !== null && v !== void 0 && v !== "")
9488
+ );
9489
+ return { name: groupName, displayName: groupDisplayName, type: tableType, items, hasData };
9490
+ } else {
9491
+ const items = [];
9492
+ for (const colName of allColumns) {
9493
+ const value = ihsData[colName] ?? null;
9494
+ const numeric = isNumericField(colName);
9495
+ items.push({
9496
+ displayName: getDisplayName(colName),
9497
+ timePeriods: [],
9498
+ data: { value },
9499
+ formattedData: { value: formatValue(value, numeric) },
9500
+ type: tableType,
9501
+ isNumeric: numeric
9502
+ });
9503
+ }
9504
+ const hasData = items.some((item) => {
9505
+ const v = item.data["value"];
9506
+ return v !== null && v !== void 0 && v !== "";
9507
+ });
9508
+ return { name: groupName, displayName: groupDisplayName, type: tableType, items, hasData };
9509
+ }
9510
+ }
9511
+ function buildFileFieldTables(ihsData) {
9512
+ const specs = getBaseFieldSpecs();
9513
+ const fileFields = specs.filter((f) => f.type === "file" && f.ihs_column_names?.length);
9514
+ const grouped = groupFieldsByPattern(fileFields);
9515
+ const tables = {};
9516
+ for (const [groupName, fields] of Object.entries(grouped)) {
9517
+ const table = buildTableForGroup(groupName, fields, ihsData);
9518
+ if (table && table.hasData) {
9519
+ tables[groupName] = table;
9520
+ }
9521
+ }
9522
+ return tables;
9523
+ }
9524
+ function isFileOrFinancialColumn(fieldName, fileColumnSet) {
9525
+ return fileColumnSet.has(fieldName) || fieldName.startsWith("financials") || fieldName.startsWith("bank_statement");
9526
+ }
9527
+ function inferValueFormat(fieldName, value) {
9528
+ const currencyFields = /* @__PURE__ */ new Set([
9529
+ "totalFinancing",
9530
+ "monthlyGrossIncome",
9531
+ "approvedAmount",
9532
+ "monthlyInstallment"
9533
+ ]);
9534
+ if (currencyFields.has(fieldName)) return "currency" /* CURRENCY */;
9535
+ const numberFields = /* @__PURE__ */ new Set([
9536
+ "age",
9537
+ "noOfDependants",
9538
+ "financingTenure",
9539
+ "ihsId",
9540
+ "programId",
9541
+ "borrowerAgentId"
9542
+ ]);
9543
+ if (numberFields.has(fieldName)) return "number" /* NUMBER */;
9544
+ const tableFields = /* @__PURE__ */ new Set(["shareholders", "directors", "previousDirectors"]);
9545
+ if (tableFields.has(fieldName)) return "table" /* TABLE */;
9546
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value)) return "date" /* DATE */;
9547
+ return "string" /* STRING */;
9548
+ }
9549
+ var EXCLUDED_FIELDS = /* @__PURE__ */ new Set([
9550
+ "updatedAt",
9551
+ "programIds",
9552
+ "borrowerAgentId",
9553
+ "programId",
9554
+ "__v",
9555
+ "_id",
9556
+ "id"
9557
+ ]);
9558
+ function processIhsDetails(ihsData) {
9559
+ const specs = getBaseFieldSpecs();
9560
+ const fileColumnSet = /* @__PURE__ */ new Set();
9561
+ for (const field of specs) {
9562
+ if (field.type === "file" && field.ihs_column_names) {
9563
+ for (const col of field.ihs_column_names) {
9564
+ fileColumnSet.add(col);
9565
+ }
9566
+ }
9567
+ }
9568
+ const specMap = getBaseFieldSpecMap();
9569
+ const categories = getBaseCategories();
9570
+ const categoryNameMap = {};
9571
+ for (const cat of categories) {
9572
+ categoryNameMap[String(cat.id)] = cat.name;
9573
+ }
9574
+ const details = [];
9575
+ for (const [key, value] of Object.entries(ihsData)) {
9576
+ if (value === null || value === void 0 || value === "" || value === "Not Specified") continue;
9577
+ if (value === false) continue;
9578
+ if (EXCLUDED_FIELDS.has(key)) continue;
9579
+ if (isFileOrFinancialColumn(key, fileColumnSet)) continue;
9580
+ const spec = specMap.get(key);
9581
+ const categoryId = spec?.category ? String(spec.category) : "0";
9582
+ const category = categoryNameMap[categoryId] || "General";
9583
+ details.push({
9584
+ name: key,
9585
+ displayName: getDisplayName(key),
9586
+ category,
9587
+ value,
9588
+ valueFormat: inferValueFormat(key, value)
9589
+ });
9590
+ }
9591
+ return details;
9592
+ }
9593
+ function groupDetailsByCategory(details) {
9594
+ const groups = {};
9595
+ for (const detail of details) {
9596
+ if (!groups[detail.category]) groups[detail.category] = [];
9597
+ groups[detail.category].push(detail);
9598
+ }
9599
+ return Object.entries(groups).filter(([cat]) => cat !== "Default Category" && cat !== "General").map(([category, items]) => ({
9600
+ category,
9601
+ items: items.map((d) => ({
9602
+ name: d.name,
9603
+ displayName: d.displayName,
9604
+ value: d.value,
9605
+ valueFormat: d.valueFormat
9606
+ }))
9607
+ }));
9608
+ }
9321
9609
  // Annotate the CommonJS export names for ESM import in node:
9322
9610
  0 && (module.exports = {
9323
9611
  BASE_FIELD_SPECS,
@@ -9325,13 +9613,17 @@ function getBaseFieldNames() {
9325
9613
  DEFAULT_VALIDATOR_DEFINITIONS,
9326
9614
  FIELD_TYPE_DEFINITIONS,
9327
9615
  FieldType,
9616
+ FileFieldTableType,
9328
9617
  FileFormField,
9329
9618
  FormField,
9330
9619
  FormFieldCategory,
9331
9620
  FormFieldValidator,
9332
9621
  FormSpec,
9622
+ IhsValueFormat,
9333
9623
  applyDynamicTitles,
9624
+ buildFileFieldTables,
9334
9625
  evaluateExpression,
9626
+ extractTimePeriods,
9335
9627
  generateRHFSchema,
9336
9628
  generateSurveyJson,
9337
9629
  getBaseCategories,
@@ -9339,11 +9631,17 @@ function getBaseFieldNames() {
9339
9631
  getBaseFieldSpecMap,
9340
9632
  getBaseFieldSpecs,
9341
9633
  getCategoryName,
9634
+ getDisplayName,
9635
+ getDisplayNames,
9342
9636
  getPastMonthLabel,
9343
9637
  getPastYearLabel,
9344
9638
  getStepDefaultValues,
9345
9639
  getStepSchema,
9640
+ groupColumnsByTimePeriod,
9641
+ groupDetailsByCategory,
9346
9642
  groupFieldsByCategory,
9643
+ groupFieldsByPattern,
9644
+ processIhsDetails,
9347
9645
  resolvePageFields,
9348
9646
  validateFormConfig,
9349
9647
  validateFormSpec,