@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.js CHANGED
@@ -1265,14 +1265,6 @@ var form_field_base_specs_default = {
1265
1265
  {
1266
1266
  id: "13",
1267
1267
  name: "Document Upload"
1268
- },
1269
- {
1270
- id: "14",
1271
- name: "SSM Company Profile Data"
1272
- },
1273
- {
1274
- id: "15",
1275
- name: "NRIC Data"
1276
1268
  }
1277
1269
  ],
1278
1270
  fields: [
@@ -1335,7 +1327,7 @@ var form_field_base_specs_default = {
1335
1327
  title: "ID Number",
1336
1328
  placeholder: "E.g. 700513065143",
1337
1329
  isRequired: true,
1338
- displayName: "IC Number (Manual Entry)",
1330
+ displayName: "IC Number",
1339
1331
  maxLength: 25,
1340
1332
  inputType: "text",
1341
1333
  validators: [
@@ -8620,165 +8612,6 @@ var form_field_base_specs_default = {
8620
8612
  "payslipOtherDeductionT6"
8621
8613
  ],
8622
8614
  category: "13"
8623
- },
8624
- {
8625
- name: "ic",
8626
- displayName: "Identity Card (NRIC)",
8627
- type: "file",
8628
- ihs_column_names: [
8629
- "icName",
8630
- "icNumber",
8631
- "icAddress",
8632
- "icGender",
8633
- "icReligion",
8634
- "icDateOfBirth",
8635
- "icPlaceOfBirth",
8636
- "icNationality",
8637
- "icRace"
8638
- ],
8639
- category: "13"
8640
- },
8641
- {
8642
- name: "ssmCompanyName",
8643
- displayName: "Company Name (SSM Profile)",
8644
- type: "text",
8645
- category: "14"
8646
- },
8647
- {
8648
- name: "ssmCompanyRegNo",
8649
- displayName: "Company Registration No (SSM Profile)",
8650
- type: "text",
8651
- category: "14"
8652
- },
8653
- {
8654
- name: "ssmIncorporatedDate",
8655
- displayName: "Incorporated Date (SSM Profile)",
8656
- type: "text",
8657
- inputType: "date",
8658
- category: "14"
8659
- },
8660
- {
8661
- name: "businessCommencementDate",
8662
- displayName: "Business Commencement Date",
8663
- type: "text",
8664
- inputType: "date",
8665
- category: "14"
8666
- },
8667
- {
8668
- name: "businessNature",
8669
- displayName: "Business Nature",
8670
- type: "text",
8671
- category: "14"
8672
- },
8673
- {
8674
- name: "companyStatus",
8675
- displayName: "Company Status (SSM)",
8676
- type: "text",
8677
- category: "14"
8678
- },
8679
- {
8680
- name: "shareholders",
8681
- displayName: "Shareholders",
8682
- type: "text",
8683
- category: "14"
8684
- },
8685
- {
8686
- name: "directors",
8687
- displayName: "Directors",
8688
- type: "text",
8689
- category: "14"
8690
- },
8691
- {
8692
- name: "previousDirectors",
8693
- displayName: "Previous Directors",
8694
- type: "text",
8695
- category: "14"
8696
- },
8697
- {
8698
- name: "totalShareIssued",
8699
- displayName: "Total Shares Issued",
8700
- type: "text",
8701
- category: "14"
8702
- },
8703
- {
8704
- name: "companyLastOldName",
8705
- displayName: "Previous Company Name",
8706
- type: "text",
8707
- category: "14"
8708
- },
8709
- {
8710
- name: "companyNameDateOfChange",
8711
- displayName: "Company Name Change Date",
8712
- type: "text",
8713
- inputType: "date",
8714
- category: "14"
8715
- },
8716
- {
8717
- name: "businessOrigin",
8718
- displayName: "Business Origin",
8719
- type: "text",
8720
- category: "14"
8721
- },
8722
- {
8723
- name: "registeredAddress",
8724
- displayName: "Registered Address (SSM)",
8725
- type: "text",
8726
- category: "14"
8727
- },
8728
- {
8729
- name: "icName",
8730
- displayName: "Full Name (NRIC)",
8731
- type: "text",
8732
- category: "15"
8733
- },
8734
- {
8735
- name: "icNumber",
8736
- displayName: "IC Number (NRIC Extracted)",
8737
- type: "text",
8738
- category: "15"
8739
- },
8740
- {
8741
- name: "icAddress",
8742
- displayName: "Address (NRIC)",
8743
- type: "text",
8744
- category: "15"
8745
- },
8746
- {
8747
- name: "icGender",
8748
- displayName: "Gender (NRIC)",
8749
- type: "text",
8750
- category: "15"
8751
- },
8752
- {
8753
- name: "icReligion",
8754
- displayName: "Religion (NRIC)",
8755
- type: "text",
8756
- category: "15"
8757
- },
8758
- {
8759
- name: "icDateOfBirth",
8760
- displayName: "Date of Birth (NRIC)",
8761
- type: "text",
8762
- inputType: "date",
8763
- category: "15"
8764
- },
8765
- {
8766
- name: "icPlaceOfBirth",
8767
- displayName: "Place of Birth (NRIC)",
8768
- type: "text",
8769
- category: "15"
8770
- },
8771
- {
8772
- name: "icNationality",
8773
- displayName: "Nationality (NRIC)",
8774
- type: "text",
8775
- category: "15"
8776
- },
8777
- {
8778
- name: "icRace",
8779
- displayName: "Race (NRIC)",
8780
- type: "text",
8781
- category: "15"
8782
8615
  }
8783
8616
  ]
8784
8617
  };
@@ -9255,19 +9088,468 @@ function getBaseFieldNames() {
9255
9088
  cachedFieldNames = [...new Set(names)];
9256
9089
  return cachedFieldNames;
9257
9090
  }
9091
+
9092
+ // src/ihs-types.ts
9093
+ var IhsValueFormat = /* @__PURE__ */ ((IhsValueFormat2) => {
9094
+ IhsValueFormat2["STRING"] = "string";
9095
+ IhsValueFormat2["CURRENCY"] = "currency";
9096
+ IhsValueFormat2["NUMBER"] = "number";
9097
+ IhsValueFormat2["PERCENTAGE"] = "percentage";
9098
+ IhsValueFormat2["DATE"] = "date";
9099
+ IhsValueFormat2["TABLE"] = "table";
9100
+ return IhsValueFormat2;
9101
+ })(IhsValueFormat || {});
9102
+ var FileFieldTableType = /* @__PURE__ */ ((FileFieldTableType2) => {
9103
+ FileFieldTableType2["TIME_SERIES"] = "timeSeries";
9104
+ FileFieldTableType2["KEY_VALUE"] = "keyValue";
9105
+ return FileFieldTableType2;
9106
+ })(FileFieldTableType || {});
9107
+
9108
+ // src/data/form-field-display-names.json
9109
+ var form_field_display_names_default = {
9110
+ accountHolderName: "Account Holder Name",
9111
+ statementDate: "Statement Date",
9112
+ bankName: "Bank Name",
9113
+ accountNumber: "Account Number",
9114
+ totalCredits: "Total Credits",
9115
+ totalDebits: "Total Debits",
9116
+ openingBalance: "Opening Balance",
9117
+ bankBalance: "Bank Balance",
9118
+ nonCurrentAssetsSubsidiaryCompanies: "Subsidiary Companies (Non-Current Assets)",
9119
+ nonCurrentAssetsAssociatedCompanies: "Associated Companies (Non-Current Assets)",
9120
+ nonCurrentAssetsDevelopmentPropertiesOrExpenditure: "Development Properties/Expenditure (Non-Current Assets)",
9121
+ nonCurrentAssetInvestmentProperties: "Investment Properties (Non-Current Assets)",
9122
+ nonCurrentAssetsInvestments: "Investments (Non-Current Assets)",
9123
+ nonCurrentAssetInvestmentSecurities: "Investment Securities (Non-Current Assets)",
9124
+ nonCurrentAssetDeferredAssets: "Deferred Assets (Non-Current Assets)",
9125
+ nonCurrentAssetDeposits: "Deposits (Non-Current Assets)",
9126
+ nonCurrentAssetOwnGoodwill: "Own Goodwill (Non-Current Assets)",
9127
+ nonCurrentAssetGoodwillOnConsolidation: "Goodwill on Consolidation (Non-Current Assets)",
9128
+ nonCurrentAssetSinkingFund: "Sinking Fund (Non-Current Assets)",
9129
+ nonCurrentAssetPropertyPlantEquipment: "Property, Plant & Equipment (Non-Current Assets)",
9130
+ nonCurrentAssetInventories: "Inventories (Non-Current Assets)",
9131
+ nonCurrentAssetRightOfUseAssets: "Right of Use Assets (Non-Current Assets)",
9132
+ nonCurrentAssetIntangibleAssets: "Intangible Assets (Non-Current Assets)",
9133
+ nonCurrentAssetPrepaidLeasePayments: "Prepaid Lease Payments (Non-Current Assets)",
9134
+ nonCurrentAssetFinancialAssetAtFairValue: "Financial Assets at Fair Value (Non-Current Assets)",
9135
+ nonCurrentAssetLandUseRight: "Land Use Rights (Non-Current Assets)",
9136
+ nonCurrentAssetTradeReceivables: "Trade Receivables (Non-Current Assets)",
9137
+ nonCurrentAssetOtherReceivables: "Other Receivables (Non-Current Assets)",
9138
+ nonCurrentAssetTradeAndOtherReceivables: "Trade and Other Receivables (Non-Current Assets)",
9139
+ nonCurrentAssetOtherReceivablesDepositsAndPrepayments: "Other Receivables, Deposits and Prepayments (Non-Current Assets)",
9140
+ totalNonCurrentAssets: "Total Non-Current Assets",
9141
+ currentAssetDevelopmentPropertiesOrExpenditure: "Development Properties/Expenditure (Current Assets)",
9142
+ currentAssetShortTermInvestments: "Short Term Investments (Current Assets)",
9143
+ currentAssetTradeDebtors: "Trade Debtors (Current Assets)",
9144
+ currentAssetShortTermDeposits: "Short Term Deposits (Current Assets)",
9145
+ currentAssetAmountDueFromHoldingCompany: "Amount Due from Holding Company (Current Assets)",
9146
+ currentAssetAmountDueFromSubsidiaryCompanies: "Amount Due from Subsidiary Companies (Current Assets)",
9147
+ currentAssetAmountDueFromAssociatedCompanies: "Amount Due from Associated Companies (Current Assets)",
9148
+ currentAssetAmountDueFromDirector: "Amount Due from Director (Current Assets)",
9149
+ currentAssetAmountDueFromCustomer: "Amount Due from Customer (Current Assets)",
9150
+ currentAssetAmountOwingByShareholders: "Amount Owing by Shareholders (Current Assets)",
9151
+ currentAssetInventories: "Inventories (Current Assets)",
9152
+ currentAssetFinancialAssetAtFairValue: "Financial Assets at Fair Value (Current Assets)",
9153
+ currentAssetLandUseRight: "Land Use Rights (Current Assets)",
9154
+ currentAssetTaxRecoverable: "Tax Recoverable (Current Assets)",
9155
+ currentAssetContractAssets: "Contract Assets (Current Assets)",
9156
+ currentAssetCurrentTaxAssets: "Current Tax Assets (Current Assets)",
9157
+ currentAssetPrepayments: "Prepayments (Current Assets)",
9158
+ currentAssetDerivative: "Derivatives (Current Assets)",
9159
+ currentAssetCashAndBankBalances: "Cash and Bank Balances (Current Assets)",
9160
+ currentAssetOtherReceivables: "Other Receivables (Current Assets)",
9161
+ currentAssetRestrictedCash: "Restricted Cash (Current Assets)",
9162
+ currentAssetCashAndCashEquivalents: "Cash and Cash Equivalents (Current Assets)",
9163
+ currentAssetDepositsCashAndBankBalances: "Deposits, Cash and Bank Balances (Current Assets)",
9164
+ currentAssetCashAtBanks: "Cash at Banks (Current Assets)",
9165
+ currentAssetCashOnHand: "Cash on Hand (Current Assets)",
9166
+ currentAssetDepositsAndPrepayments: "Deposits and Prepayments (Current Assets)",
9167
+ currentAssetTradeAndOtherReceivables: "Trade and Other Receivables (Current Assets)",
9168
+ currentAssetOtherReceivablesDepositsAndPrepayments: "Other Receivables, Deposits and Prepayments (Current Assets)",
9169
+ currentAssetOtherReceivablesAndDeposits: "Other Receivables and Deposits (Current Assets)",
9170
+ currentAssetOtherReceivablesAndPrepayments: "Other Receivables and Prepayments (Current Assets)",
9171
+ currentAssetCash: "Cash (Current Assets)",
9172
+ totalCurrentAssets: "Total Current Assets",
9173
+ totalAssets: "Total Assets",
9174
+ currentLiabilitiesTradeCreditors: "Trade Creditors (Current Liabilities)",
9175
+ currentLiabilitiesHirePurchasePayables: "Hire Purchase Payables (Current Liabilities)",
9176
+ currentLiabilitiesBankOverdraft: "Bank Overdraft (Current Liabilities)",
9177
+ currentLiabilitiesBankAcceptance: "Bank Acceptance (Current Liabilities)",
9178
+ currentLiabilitiesBorrowingsOrTermLoans: "Borrowings/Term Loans (Current Liabilities)",
9179
+ currentLiabilitiesBankborrowings: "Bank Borrowings (Current Liabilities)",
9180
+ currentLiabilitiesAmountsOwingToHoldingCompany: "Amounts Owing to Holding Company (Current Liabilities)",
9181
+ currentLiabilitiesAmountsOwingToSubsidiaryCompanies: "Amounts Owing to Subsidiary Companies (Current Liabilities)",
9182
+ currentLiabilitiesAmountOwingToAssociatedCompanies: "Amount Owing to Associated Companies (Current Liabilities)",
9183
+ currentLiabilitiesAmountsOwingToDirector: "Amounts Owing to Director (Current Liabilities)",
9184
+ currentLiabilitiesProvisionForTaxation: "Provision for Taxation (Current Liabilities)",
9185
+ currentLiabilitiesLeasePayables: "Lease Payables (Current Liabilities)",
9186
+ currentLiabilitiesFinanceLeasePayables: "Finance Lease Payables (Current Liabilities)",
9187
+ currentLiabilitiesOtherPayables: "Other Payables (Current Liabilities)",
9188
+ currentLiabilitiesDividendPayables: "Dividend Payables (Current Liabilities)",
9189
+ currentLiabilitiesTradeAndOtherPayables: "Trade and Other Payables (Current Liabilities)",
9190
+ currentLiabilitiesDepositsFromCustomers: "Deposits from Customers (Current Liabilities)",
9191
+ currentLiabilitiesOtherPayablesAccrualsAndDeposits: "Other Payables, Accruals and Deposits (Current Liabilities)",
9192
+ currentLiabilitiesOtherPayablesAndAccruals: "Other Payables and Accruals (Current Liabilities)",
9193
+ currentLiabilitiesContractLiabilities: "Contract Liabilities (Current Liabilities)",
9194
+ currentLiabilitiesDerivative: "Derivative Liabilities (Current Liabilities)",
9195
+ totalCurrentLiabilities: "Total Current Liabilities",
9196
+ shortTermLiabilities: "Short Term Liabilities",
9197
+ nonCurrentLiabilitiesBorrowingsOrTermLoans: "Borrowings/Term Loans (Non-Current Liabilities)",
9198
+ nonCurrentLiabilitiesBankBorrowings: "Bank Borrowings (Non-Current Liabilities)",
9199
+ nonCurrentLiabilitiesLeaseObligations: "Lease Obligations (Non-Current Liabilities)",
9200
+ nonCurrentLiabilitiesFinanceLeaseObligations: "Finance Lease Obligations (Non-Current Liabilities)",
9201
+ nonCurrentLiabilitiesDeferredTaxation: "Deferred Taxation (Non-Current Liabilities)",
9202
+ nonCurrentLiabilitiesRetirementBenefits: "Retirement Benefits (Non-Current Liabilities)",
9203
+ nonCurrentLiabilitiesHirePurchasePayables: "Hire Purchase Payables (Non-Current Liabilities)",
9204
+ nonCurrentLiabilitiesDepositsFromCustomers: "Deposits from Customers (Non-Current Liabilities)",
9205
+ nonCurrentLiabilitiesContractLiabilities: "Contract Liabilities (Non-Current Liabilities)",
9206
+ totalNonCurrentLiabilities: "Total Non-Current Liabilities",
9207
+ totalLiabilities: "Total Liabilities",
9208
+ tangibleAssets: "Tangible Assets",
9209
+ shareCapital: "Share Capital",
9210
+ preferenceShareCapital: "Preference Share Capital",
9211
+ sharePremium: "Share Premium",
9212
+ reserves: "Reserves",
9213
+ capitalReserves: "Capital Reserves",
9214
+ revaluationReserves: "Revaluation Reserves",
9215
+ exchangeEqualisationOrFluctuationReserves: "Exchange Equalisation/Fluctuation Reserves",
9216
+ retainedEarnings: "Retained Earnings",
9217
+ totalEquity: "Total Equity",
9218
+ revenue: "Revenue",
9219
+ costOfGoodsSold: "Cost of Goods Sold",
9220
+ grossProfit: "Gross Profit",
9221
+ otherIncome: "Other Income",
9222
+ profitFromOperations: "Profit from Operations",
9223
+ financeCost: "Finance Cost",
9224
+ ebitda: "Profit Before Tax",
9225
+ taxes: "Taxes",
9226
+ zakat: "Zakat",
9227
+ profitAfterTax: "Profit After Tax",
9228
+ netProfit: "Net Profit",
9229
+ netOperatingCashFlow: "Net Operating Cash Flow",
9230
+ depreciation: "Depreciation",
9231
+ depreciationOfPropertyPlantEquipment: "Depreciation of Property, Plant & Equipment",
9232
+ depreciationRightOfUseAssets: "Depreciation of Right of Use Assets",
9233
+ depreciationOfInvestmentProperties: "Depreciation of Investment Properties",
9234
+ depreciationOfInvestmentSecurities: "Depreciation of Investment Securities",
9235
+ endOfYearCash: "End of Year Cash",
9236
+ epfAccountHolderName: "Account Holder Name",
9237
+ epfAccountHolderAddress: "Account Holder Address",
9238
+ epfStatementYear: "Statement Year",
9239
+ epfKwspMemberNumber: "KWSP Member Number",
9240
+ epfIcNumber: "IC No.",
9241
+ epfEmployerNumber: "Employer Number",
9242
+ epfDateOfStatement: "Date Of Statement",
9243
+ epfTotalContribution: "Total Contribution",
9244
+ epfTotalCurrentContribution: "Total Current Contribution",
9245
+ payslipEmployerName: "Employer Name",
9246
+ payslipEmployeeName: "Employee Name",
9247
+ payslipPayPeriod: "Pay Period",
9248
+ payslipPayDate: "Pay Date",
9249
+ payslipGrossPay: "Gross Pay",
9250
+ payslipDeduction: "Deduction",
9251
+ payslipEmployeeEpfContribution: "Employee EPF Contribution",
9252
+ payslipEmployeeSocsoContribution: "Employee SOCSO Contribution",
9253
+ payslipNetPay: "Net Pay",
9254
+ incorporatedDate: "Incorporated Date",
9255
+ companyName: "Company Name",
9256
+ companyRegNo: "Company Registration No.",
9257
+ ssmCompanyName: "Company Name (SSM)",
9258
+ ssmCompanyRegNo: "Registration No. (SSM)",
9259
+ ssmIncorporatedDate: "Incorporated Date (SSM)",
9260
+ businessCommencementDate: "Business Commencement Date",
9261
+ businessNature: "Business Nature",
9262
+ companyStatus: "Company Status",
9263
+ shareholders: "Shareholders",
9264
+ directors: "Directors",
9265
+ previousDirectors: "Previous Directors",
9266
+ totalShareIssued: "Total Shares Issued",
9267
+ companyLastOldName: "Previous Company Name",
9268
+ companyNameDateOfChange: "Company Name Change Date",
9269
+ businessOrigin: "Business Origin",
9270
+ registeredAddress: "Registered Address",
9271
+ icName: "Name (IC)",
9272
+ icNumber: "IC Number",
9273
+ icAddress: "Address (IC)",
9274
+ icGender: "Gender (IC)",
9275
+ icReligion: "Religion (IC)",
9276
+ icDateOfBirth: "Date of Birth (IC)",
9277
+ icPlaceOfBirth: "Place of Birth (IC)",
9278
+ icNationality: "Nationality (IC)",
9279
+ icRace: "Race (IC)"
9280
+ };
9281
+
9282
+ // src/ihs-processing.ts
9283
+ var displayNames = form_field_display_names_default;
9284
+ function getDisplayNames() {
9285
+ return displayNames;
9286
+ }
9287
+ function getDisplayName(fieldName) {
9288
+ if (displayNames[fieldName]) return displayNames[fieldName];
9289
+ return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
9290
+ }
9291
+ var TIME_PERIOD_REGEX = /T(\d+)$/;
9292
+ function extractTimePeriods(columnNames) {
9293
+ const periods = /* @__PURE__ */ new Set();
9294
+ for (const col of columnNames) {
9295
+ const match = TIME_PERIOD_REGEX.exec(col);
9296
+ if (match) periods.add(`T${match[1]}`);
9297
+ }
9298
+ return [...periods].sort((a, b) => {
9299
+ const numA = parseInt(a.slice(1), 10);
9300
+ const numB = parseInt(b.slice(1), 10);
9301
+ return numA - numB;
9302
+ });
9303
+ }
9304
+ function groupColumnsByTimePeriod(columnNames) {
9305
+ const groups = {};
9306
+ for (const col of columnNames) {
9307
+ const match = /^(.+?)(T\d+)$/.exec(col);
9308
+ if (!match) continue;
9309
+ const [, baseName, period] = match;
9310
+ if (!groups[baseName]) groups[baseName] = {};
9311
+ groups[baseName][period] = col;
9312
+ }
9313
+ return groups;
9314
+ }
9315
+ var FIELD_GROUP_PREFIXES = [
9316
+ ["bank_statement", "bank_statements"],
9317
+ ["financials", "financials"],
9318
+ ["epf_statement", "epf_statements"],
9319
+ ["payslip_statement", "payslip_statements"],
9320
+ ["ssm", "ssm_documents"],
9321
+ ["ic_", "ic_documents"]
9322
+ ];
9323
+ function groupFieldsByPattern(fields) {
9324
+ const groups = {};
9325
+ for (const field of fields) {
9326
+ if (!field.name) continue;
9327
+ let groupName = field.name;
9328
+ for (const [prefix, group] of FIELD_GROUP_PREFIXES) {
9329
+ if (field.name.startsWith(prefix)) {
9330
+ groupName = group;
9331
+ break;
9332
+ }
9333
+ }
9334
+ if (!groups[groupName]) groups[groupName] = [];
9335
+ groups[groupName].push(field);
9336
+ }
9337
+ return groups;
9338
+ }
9339
+ var GROUP_DISPLAY_NAMES = {
9340
+ bank_statements: "Bank Statements",
9341
+ financials: "Audited Financial Statements",
9342
+ epf_statements: "EPF Statements",
9343
+ payslip_statements: "Payslip Statements",
9344
+ ssm_documents: "SSM Company Information",
9345
+ ic_documents: "Identification Card"
9346
+ };
9347
+ function isNumericField(fieldName) {
9348
+ const patterns = [
9349
+ "balance",
9350
+ "amount",
9351
+ "credit",
9352
+ "debit",
9353
+ "total",
9354
+ "revenue",
9355
+ "cost",
9356
+ "income",
9357
+ "expense",
9358
+ "liability",
9359
+ "asset",
9360
+ "equity",
9361
+ "profit",
9362
+ "loss",
9363
+ "cash",
9364
+ "tax",
9365
+ "interest"
9366
+ ];
9367
+ const lower = fieldName.toLowerCase();
9368
+ return patterns.some((p) => lower.includes(p));
9369
+ }
9370
+ function formatValue(value, numeric) {
9371
+ if (value === null || value === void 0 || value === "") return "-";
9372
+ if (numeric) {
9373
+ const num = Number(value);
9374
+ if (!isNaN(num))
9375
+ return num.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
9376
+ }
9377
+ return String(value);
9378
+ }
9379
+ function buildTableForGroup(groupName, fields, ihsData) {
9380
+ const allColumns = [];
9381
+ for (const field of fields) {
9382
+ if (field.ihs_column_names) {
9383
+ allColumns.push(...field.ihs_column_names);
9384
+ }
9385
+ }
9386
+ if (allColumns.length === 0) return null;
9387
+ const periods = extractTimePeriods(allColumns);
9388
+ const isTimeSeries = periods.length > 0;
9389
+ const tableType = isTimeSeries ? "timeSeries" /* TIME_SERIES */ : "keyValue" /* KEY_VALUE */;
9390
+ const groupDisplayName = GROUP_DISPLAY_NAMES[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9391
+ if (isTimeSeries) {
9392
+ const columnGroups = groupColumnsByTimePeriod(allColumns);
9393
+ const items = [];
9394
+ for (const [baseName, periodMap] of Object.entries(columnGroups)) {
9395
+ const numeric = isNumericField(baseName);
9396
+ const data = {};
9397
+ const formattedData = {};
9398
+ for (const period of periods) {
9399
+ const colName = periodMap[period];
9400
+ const value = colName ? ihsData[colName] ?? null : null;
9401
+ data[period] = value;
9402
+ formattedData[period] = formatValue(value, numeric);
9403
+ }
9404
+ items.push({
9405
+ displayName: getDisplayName(baseName),
9406
+ timePeriods: periods,
9407
+ data,
9408
+ formattedData,
9409
+ type: tableType,
9410
+ isNumeric: numeric
9411
+ });
9412
+ }
9413
+ const hasData = items.some(
9414
+ (item) => Object.values(item.data).some((v) => v !== null && v !== void 0 && v !== "")
9415
+ );
9416
+ return { name: groupName, displayName: groupDisplayName, type: tableType, items, hasData };
9417
+ } else {
9418
+ const items = [];
9419
+ for (const colName of allColumns) {
9420
+ const value = ihsData[colName] ?? null;
9421
+ const numeric = isNumericField(colName);
9422
+ items.push({
9423
+ displayName: getDisplayName(colName),
9424
+ timePeriods: [],
9425
+ data: { value },
9426
+ formattedData: { value: formatValue(value, numeric) },
9427
+ type: tableType,
9428
+ isNumeric: numeric
9429
+ });
9430
+ }
9431
+ const hasData = items.some((item) => {
9432
+ const v = item.data["value"];
9433
+ return v !== null && v !== void 0 && v !== "";
9434
+ });
9435
+ return { name: groupName, displayName: groupDisplayName, type: tableType, items, hasData };
9436
+ }
9437
+ }
9438
+ function buildFileFieldTables(ihsData) {
9439
+ const specs = getBaseFieldSpecs();
9440
+ const fileFields = specs.filter((f) => f.type === "file" && f.ihs_column_names?.length);
9441
+ const grouped = groupFieldsByPattern(fileFields);
9442
+ const tables = {};
9443
+ for (const [groupName, fields] of Object.entries(grouped)) {
9444
+ const table = buildTableForGroup(groupName, fields, ihsData);
9445
+ if (table && table.hasData) {
9446
+ tables[groupName] = table;
9447
+ }
9448
+ }
9449
+ return tables;
9450
+ }
9451
+ function isFileOrFinancialColumn(fieldName, fileColumnSet) {
9452
+ return fileColumnSet.has(fieldName) || fieldName.startsWith("financials") || fieldName.startsWith("bank_statement");
9453
+ }
9454
+ function inferValueFormat(fieldName, value) {
9455
+ const currencyFields = /* @__PURE__ */ new Set([
9456
+ "totalFinancing",
9457
+ "monthlyGrossIncome",
9458
+ "approvedAmount",
9459
+ "monthlyInstallment"
9460
+ ]);
9461
+ if (currencyFields.has(fieldName)) return "currency" /* CURRENCY */;
9462
+ const numberFields = /* @__PURE__ */ new Set([
9463
+ "age",
9464
+ "noOfDependants",
9465
+ "financingTenure",
9466
+ "ihsId",
9467
+ "programId",
9468
+ "borrowerAgentId"
9469
+ ]);
9470
+ if (numberFields.has(fieldName)) return "number" /* NUMBER */;
9471
+ const tableFields = /* @__PURE__ */ new Set(["shareholders", "directors", "previousDirectors"]);
9472
+ if (tableFields.has(fieldName)) return "table" /* TABLE */;
9473
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value)) return "date" /* DATE */;
9474
+ return "string" /* STRING */;
9475
+ }
9476
+ var EXCLUDED_FIELDS = /* @__PURE__ */ new Set([
9477
+ "updatedAt",
9478
+ "programIds",
9479
+ "borrowerAgentId",
9480
+ "programId",
9481
+ "__v",
9482
+ "_id",
9483
+ "id"
9484
+ ]);
9485
+ function processIhsDetails(ihsData) {
9486
+ const specs = getBaseFieldSpecs();
9487
+ const fileColumnSet = /* @__PURE__ */ new Set();
9488
+ for (const field of specs) {
9489
+ if (field.type === "file" && field.ihs_column_names) {
9490
+ for (const col of field.ihs_column_names) {
9491
+ fileColumnSet.add(col);
9492
+ }
9493
+ }
9494
+ }
9495
+ const specMap = getBaseFieldSpecMap();
9496
+ const categories = getBaseCategories();
9497
+ const categoryNameMap = {};
9498
+ for (const cat of categories) {
9499
+ categoryNameMap[String(cat.id)] = cat.name;
9500
+ }
9501
+ const details = [];
9502
+ for (const [key, value] of Object.entries(ihsData)) {
9503
+ if (value === null || value === void 0 || value === "" || value === "Not Specified") continue;
9504
+ if (value === false) continue;
9505
+ if (EXCLUDED_FIELDS.has(key)) continue;
9506
+ if (isFileOrFinancialColumn(key, fileColumnSet)) continue;
9507
+ const spec = specMap.get(key);
9508
+ const categoryId = spec?.category ? String(spec.category) : "0";
9509
+ const category = categoryNameMap[categoryId] || "General";
9510
+ details.push({
9511
+ name: key,
9512
+ displayName: getDisplayName(key),
9513
+ category,
9514
+ value,
9515
+ valueFormat: inferValueFormat(key, value)
9516
+ });
9517
+ }
9518
+ return details;
9519
+ }
9520
+ function groupDetailsByCategory(details) {
9521
+ const groups = {};
9522
+ for (const detail of details) {
9523
+ if (!groups[detail.category]) groups[detail.category] = [];
9524
+ groups[detail.category].push(detail);
9525
+ }
9526
+ return Object.entries(groups).filter(([cat]) => cat !== "Default Category" && cat !== "General").map(([category, items]) => ({
9527
+ category,
9528
+ items: items.map((d) => ({
9529
+ name: d.name,
9530
+ displayName: d.displayName,
9531
+ value: d.value,
9532
+ valueFormat: d.valueFormat
9533
+ }))
9534
+ }));
9535
+ }
9258
9536
  export {
9259
9537
  BASE_FIELD_SPECS,
9260
9538
  BasicFormField,
9261
9539
  DEFAULT_VALIDATOR_DEFINITIONS,
9262
9540
  FIELD_TYPE_DEFINITIONS,
9263
9541
  FieldType,
9542
+ FileFieldTableType,
9264
9543
  FileFormField,
9265
9544
  FormField,
9266
9545
  FormFieldCategory,
9267
9546
  FormFieldValidator,
9268
9547
  FormSpec,
9548
+ IhsValueFormat,
9269
9549
  applyDynamicTitles,
9550
+ buildFileFieldTables,
9270
9551
  evaluateExpression,
9552
+ extractTimePeriods,
9271
9553
  generateRHFSchema,
9272
9554
  generateSurveyJson,
9273
9555
  getBaseCategories,
@@ -9275,11 +9557,17 @@ export {
9275
9557
  getBaseFieldSpecMap,
9276
9558
  getBaseFieldSpecs,
9277
9559
  getCategoryName,
9560
+ getDisplayName,
9561
+ getDisplayNames,
9278
9562
  getPastMonthLabel,
9279
9563
  getPastYearLabel,
9280
9564
  getStepDefaultValues,
9281
9565
  getStepSchema,
9566
+ groupColumnsByTimePeriod,
9567
+ groupDetailsByCategory,
9282
9568
  groupFieldsByCategory,
9569
+ groupFieldsByPattern,
9570
+ processIhsDetails,
9283
9571
  resolvePageFields,
9284
9572
  validateFormConfig,
9285
9573
  validateFormSpec,