@finsys/core 1.4.2 → 1.5.1

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,
@@ -9151,6 +9161,453 @@ function getBaseFieldNames() {
9151
9161
  cachedFieldNames = [...new Set(names)];
9152
9162
  return cachedFieldNames;
9153
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_business_information", "ssm_company_profile"],
9394
+ ["ssm", "ssm_documents"],
9395
+ ["ic_", "ic_documents"]
9396
+ ];
9397
+ function groupFieldsByPattern(fields) {
9398
+ const groups = {};
9399
+ for (const field of fields) {
9400
+ if (!field.name) continue;
9401
+ let groupName = field.name;
9402
+ for (const [prefix, group] of FIELD_GROUP_PREFIXES) {
9403
+ if (field.name.startsWith(prefix)) {
9404
+ groupName = group;
9405
+ break;
9406
+ }
9407
+ }
9408
+ if (!groups[groupName]) groups[groupName] = [];
9409
+ groups[groupName].push(field);
9410
+ }
9411
+ return groups;
9412
+ }
9413
+ var GROUP_DISPLAY_NAMES = {
9414
+ bank_statements: "Bank Statements",
9415
+ financials: "Audited Financial Statements",
9416
+ epf_statements: "EPF Statements",
9417
+ payslip_statements: "Payslip Statements",
9418
+ ssm_documents: "Form 9 / Section 17 / Form D",
9419
+ ssm_company_profile: "SSM Company Profile",
9420
+ ic_documents: "Identification Card"
9421
+ };
9422
+ function isNumericField(fieldName) {
9423
+ const patterns = [
9424
+ "balance",
9425
+ "amount",
9426
+ "credit",
9427
+ "debit",
9428
+ "total",
9429
+ "revenue",
9430
+ "cost",
9431
+ "income",
9432
+ "expense",
9433
+ "liability",
9434
+ "asset",
9435
+ "equity",
9436
+ "profit",
9437
+ "loss",
9438
+ "cash",
9439
+ "tax",
9440
+ "interest"
9441
+ ];
9442
+ const lower = fieldName.toLowerCase();
9443
+ return patterns.some((p) => lower.includes(p));
9444
+ }
9445
+ function formatValue(value, numeric) {
9446
+ if (value === null || value === void 0 || value === "") return "-";
9447
+ if (numeric) {
9448
+ const num = Number(value);
9449
+ if (!isNaN(num))
9450
+ return num.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
9451
+ }
9452
+ return String(value);
9453
+ }
9454
+ function buildTableForGroup(groupName, fields, ihsData) {
9455
+ const allColumns = [];
9456
+ for (const field of fields) {
9457
+ if (field.ihs_column_names) {
9458
+ allColumns.push(...field.ihs_column_names);
9459
+ }
9460
+ }
9461
+ if (allColumns.length === 0) return null;
9462
+ const periods = extractTimePeriods(allColumns);
9463
+ const isTimeSeries = periods.length > 0;
9464
+ const tableType = isTimeSeries ? "timeSeries" /* TIME_SERIES */ : "keyValue" /* KEY_VALUE */;
9465
+ const groupDisplayName = GROUP_DISPLAY_NAMES[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9466
+ if (isTimeSeries) {
9467
+ const columnGroups = groupColumnsByTimePeriod(allColumns);
9468
+ const items = [];
9469
+ for (const [baseName, periodMap] of Object.entries(columnGroups)) {
9470
+ const numeric = isNumericField(baseName);
9471
+ const data = {};
9472
+ const formattedData = {};
9473
+ for (const period of periods) {
9474
+ const colName = periodMap[period];
9475
+ const value = colName ? ihsData[colName] ?? null : null;
9476
+ data[period] = value;
9477
+ formattedData[period] = formatValue(value, numeric);
9478
+ }
9479
+ items.push({
9480
+ displayName: getDisplayName(baseName),
9481
+ timePeriods: periods,
9482
+ data,
9483
+ formattedData,
9484
+ type: tableType,
9485
+ isNumeric: numeric
9486
+ });
9487
+ }
9488
+ const hasData = items.some(
9489
+ (item) => Object.values(item.data).some((v) => v !== null && v !== void 0 && v !== "")
9490
+ );
9491
+ return { name: groupName, displayName: groupDisplayName, type: tableType, items, hasData };
9492
+ } else {
9493
+ const items = [];
9494
+ for (const colName of allColumns) {
9495
+ const value = ihsData[colName] ?? null;
9496
+ const numeric = isNumericField(colName);
9497
+ items.push({
9498
+ displayName: getDisplayName(colName),
9499
+ timePeriods: [],
9500
+ data: { value },
9501
+ formattedData: { value: formatValue(value, numeric) },
9502
+ type: tableType,
9503
+ isNumeric: numeric
9504
+ });
9505
+ }
9506
+ const hasData = items.some((item) => {
9507
+ const v = item.data["value"];
9508
+ return v !== null && v !== void 0 && v !== "";
9509
+ });
9510
+ return { name: groupName, displayName: groupDisplayName, type: tableType, items, hasData };
9511
+ }
9512
+ }
9513
+ function buildFileFieldTables(ihsData) {
9514
+ const specs = getBaseFieldSpecs();
9515
+ const fileFields = specs.filter((f) => f.type === "file" && f.ihs_column_names?.length);
9516
+ const grouped = groupFieldsByPattern(fileFields);
9517
+ const tables = {};
9518
+ for (const [groupName, fields] of Object.entries(grouped)) {
9519
+ const table = buildTableForGroup(groupName, fields, ihsData);
9520
+ if (table && table.hasData) {
9521
+ tables[groupName] = table;
9522
+ }
9523
+ }
9524
+ return tables;
9525
+ }
9526
+ function isFileOrFinancialColumn(fieldName, fileColumnSet) {
9527
+ return fileColumnSet.has(fieldName) || fieldName.startsWith("financials") || fieldName.startsWith("bank_statement");
9528
+ }
9529
+ function inferValueFormat(fieldName, value) {
9530
+ const currencyFields = /* @__PURE__ */ new Set([
9531
+ "totalFinancing",
9532
+ "monthlyGrossIncome",
9533
+ "approvedAmount",
9534
+ "monthlyInstallment"
9535
+ ]);
9536
+ if (currencyFields.has(fieldName)) return "currency" /* CURRENCY */;
9537
+ const numberFields = /* @__PURE__ */ new Set([
9538
+ "age",
9539
+ "noOfDependants",
9540
+ "financingTenure",
9541
+ "ihsId",
9542
+ "programId",
9543
+ "borrowerAgentId"
9544
+ ]);
9545
+ if (numberFields.has(fieldName)) return "number" /* NUMBER */;
9546
+ const tableFields = /* @__PURE__ */ new Set(["shareholders", "directors", "previousDirectors"]);
9547
+ if (tableFields.has(fieldName)) return "table" /* TABLE */;
9548
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value)) return "date" /* DATE */;
9549
+ return "string" /* STRING */;
9550
+ }
9551
+ var EXCLUDED_FIELDS = /* @__PURE__ */ new Set([
9552
+ "updatedAt",
9553
+ "programIds",
9554
+ "borrowerAgentId",
9555
+ "programId",
9556
+ "__v",
9557
+ "_id",
9558
+ "id"
9559
+ ]);
9560
+ function processIhsDetails(ihsData) {
9561
+ const specs = getBaseFieldSpecs();
9562
+ const fileColumnSet = /* @__PURE__ */ new Set();
9563
+ for (const field of specs) {
9564
+ if (field.type === "file" && field.ihs_column_names) {
9565
+ for (const col of field.ihs_column_names) {
9566
+ fileColumnSet.add(col);
9567
+ }
9568
+ }
9569
+ }
9570
+ const specMap = getBaseFieldSpecMap();
9571
+ const categories = getBaseCategories();
9572
+ const categoryNameMap = {};
9573
+ for (const cat of categories) {
9574
+ categoryNameMap[String(cat.id)] = cat.name;
9575
+ }
9576
+ const details = [];
9577
+ for (const [key, value] of Object.entries(ihsData)) {
9578
+ if (value === null || value === void 0 || value === "" || value === "Not Specified") continue;
9579
+ if (value === false) continue;
9580
+ if (EXCLUDED_FIELDS.has(key)) continue;
9581
+ if (isFileOrFinancialColumn(key, fileColumnSet)) continue;
9582
+ const spec = specMap.get(key);
9583
+ const categoryId = spec?.category ? String(spec.category) : "0";
9584
+ const category = categoryNameMap[categoryId] || "General";
9585
+ details.push({
9586
+ name: key,
9587
+ displayName: getDisplayName(key),
9588
+ category,
9589
+ value,
9590
+ valueFormat: inferValueFormat(key, value)
9591
+ });
9592
+ }
9593
+ return details;
9594
+ }
9595
+ function groupDetailsByCategory(details) {
9596
+ const groups = {};
9597
+ for (const detail of details) {
9598
+ if (!groups[detail.category]) groups[detail.category] = [];
9599
+ groups[detail.category].push(detail);
9600
+ }
9601
+ return Object.entries(groups).filter(([cat]) => cat !== "Default Category" && cat !== "General").map(([category, items]) => ({
9602
+ category,
9603
+ items: items.map((d) => ({
9604
+ name: d.name,
9605
+ displayName: d.displayName,
9606
+ value: d.value,
9607
+ valueFormat: d.valueFormat
9608
+ }))
9609
+ }));
9610
+ }
9154
9611
  // Annotate the CommonJS export names for ESM import in node:
9155
9612
  0 && (module.exports = {
9156
9613
  BASE_FIELD_SPECS,
@@ -9158,13 +9615,17 @@ function getBaseFieldNames() {
9158
9615
  DEFAULT_VALIDATOR_DEFINITIONS,
9159
9616
  FIELD_TYPE_DEFINITIONS,
9160
9617
  FieldType,
9618
+ FileFieldTableType,
9161
9619
  FileFormField,
9162
9620
  FormField,
9163
9621
  FormFieldCategory,
9164
9622
  FormFieldValidator,
9165
9623
  FormSpec,
9624
+ IhsValueFormat,
9166
9625
  applyDynamicTitles,
9626
+ buildFileFieldTables,
9167
9627
  evaluateExpression,
9628
+ extractTimePeriods,
9168
9629
  generateRHFSchema,
9169
9630
  generateSurveyJson,
9170
9631
  getBaseCategories,
@@ -9172,11 +9633,17 @@ function getBaseFieldNames() {
9172
9633
  getBaseFieldSpecMap,
9173
9634
  getBaseFieldSpecs,
9174
9635
  getCategoryName,
9636
+ getDisplayName,
9637
+ getDisplayNames,
9175
9638
  getPastMonthLabel,
9176
9639
  getPastYearLabel,
9177
9640
  getStepDefaultValues,
9178
9641
  getStepSchema,
9642
+ groupColumnsByTimePeriod,
9643
+ groupDetailsByCategory,
9179
9644
  groupFieldsByCategory,
9645
+ groupFieldsByPattern,
9646
+ processIhsDetails,
9180
9647
  resolvePageFields,
9181
9648
  validateFormConfig,
9182
9649
  validateFormSpec,