@dynamatix/gb-schemas 2.3.271 → 2.3.272

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.
Files changed (105) hide show
  1. package/README.md +308 -308
  2. package/dist/applicants/applicant-additional-income.model.d.ts.map +1 -1
  3. package/dist/applicants/applicant-additional-income.model.js +3 -0
  4. package/dist/applicants/applicant-commitment-creditCard.model.d.ts.map +1 -1
  5. package/dist/applicants/applicant-commitment-creditCard.model.js +3 -0
  6. package/dist/applicants/applicant-commitment-loan.model.d.ts.map +1 -1
  7. package/dist/applicants/applicant-commitment-loan.model.js +2 -0
  8. package/dist/applicants/applicant-commitment-mortgage.model.d.ts.map +1 -1
  9. package/dist/applicants/applicant-commitment-mortgage.model.js +3 -0
  10. package/dist/applicants/applicant-commitment-residence.model.d.ts.map +1 -1
  11. package/dist/applicants/applicant-commitment-residence.model.js +2 -0
  12. package/dist/applicants/applicant-commitment-secureLoan.model.d.ts.map +1 -1
  13. package/dist/applicants/applicant-commitment-secureLoan.model.js +3 -0
  14. package/dist/applicants/applicant-commitment-unsecuredLoan.model.d.ts.map +1 -1
  15. package/dist/applicants/applicant-commitment-unsecuredLoan.model.js +3 -0
  16. package/dist/applicants/applicant-credit-report.model.js +1 -0
  17. package/dist/applicants/applicant-employment-income.model.d.ts.map +1 -1
  18. package/dist/applicants/applicant-employment-income.model.js +3 -0
  19. package/dist/applicants/applicant-expenditure.model.d.ts.map +1 -1
  20. package/dist/applicants/applicant-expenditure.model.js +3 -0
  21. package/dist/applicants/applicant-income-settings.model.d.ts.map +1 -1
  22. package/dist/applicants/applicant-income-settings.model.js +1 -0
  23. package/dist/applicants/applicant-income-summary.model.d.ts.map +1 -1
  24. package/dist/applicants/applicant-income-summary.model.js +2 -0
  25. package/dist/applicants/applicant-pension-income.model.d.ts.map +1 -1
  26. package/dist/applicants/applicant-pension-income.model.js +2 -0
  27. package/dist/applicants/applicant-property-income.model.d.ts.map +1 -1
  28. package/dist/applicants/applicant-property-income.model.js +1 -0
  29. package/dist/applicants/applicant-self-employed-income.model.d.ts.map +1 -1
  30. package/dist/applicants/applicant-self-employed-income.model.js +1 -0
  31. package/dist/applicants/applicant-self-employment.model.d.ts.map +1 -1
  32. package/dist/applicants/applicant-self-employment.model.js +2 -0
  33. package/dist/applicants/applicant-sole-trader-income.model.d.ts.map +1 -1
  34. package/dist/applicants/applicant-sole-trader-income.model.js +1 -0
  35. package/dist/applicants/applicant-uk-tax-credits.model.d.ts.map +1 -1
  36. package/dist/applicants/applicant-uk-tax-credits.model.js +2 -0
  37. package/dist/applicants/applicant-welcome-call.model.d.ts.map +1 -1
  38. package/dist/applicants/applicant-welcome-call.model.js +4 -171
  39. package/dist/applicants/applicant.model.d.ts.map +1 -1
  40. package/dist/applicants/applicant.model.js +14 -0
  41. package/dist/applications/application-direct-debit.model.js +2 -0
  42. package/dist/applications/application-euc.model.d.ts.map +1 -1
  43. package/dist/applications/application-euc.model.js +2 -0
  44. package/dist/applications/application-mortgage.model.js +2 -0
  45. package/dist/applications/application-note.model.d.ts.map +1 -1
  46. package/dist/applications/application-note.model.js +18 -0
  47. package/dist/applications/application-product.model.d.ts.map +1 -1
  48. package/dist/applications/application-product.model.js +3 -0
  49. package/dist/applications/application.model.d.ts.map +1 -1
  50. package/dist/applications/application.model.js +11 -0
  51. package/dist/applications/applications-task.model.d.ts.map +1 -1
  52. package/dist/applications/applications-task.model.js +3 -0
  53. package/dist/product-catalogues/product-catalogue.model.d.ts.map +1 -1
  54. package/dist/product-catalogues/product-catalogue.model.js +1 -0
  55. package/dist/product-catalogues/product-variant.model.d.ts.map +1 -1
  56. package/dist/product-catalogues/product-variant.model.js +1 -0
  57. package/dist/properties/security.model.d.ts.map +1 -1
  58. package/dist/properties/security.model.js +4 -0
  59. package/dist/shared/api-log.model.d.ts +6 -0
  60. package/dist/shared/api-log.model.d.ts.map +1 -1
  61. package/dist/shared/api-log.model.js +4 -0
  62. package/dist/shared/apprivo-sync-journey.model.d.ts.map +1 -1
  63. package/dist/shared/apprivo-sync-journey.model.js +2 -0
  64. package/dist/shared/audit-log.model.d.ts +180 -0
  65. package/dist/shared/audit-log.model.d.ts.map +1 -0
  66. package/dist/shared/audit-log.model.js +43 -0
  67. package/dist/shared/checklist.model.d.ts.map +1 -1
  68. package/dist/shared/checklist.model.js +5 -0
  69. package/dist/shared/document.model.d.ts +180 -0
  70. package/dist/shared/document.model.d.ts.map +1 -0
  71. package/dist/shared/document.model.js +40 -0
  72. package/dist/shared/lookup-group.model.d.ts.map +1 -1
  73. package/dist/shared/lookup-group.model.js +3 -0
  74. package/dist/shared/lookup.model.d.ts.map +1 -1
  75. package/dist/shared/lookup.model.js +6 -0
  76. package/dist/shared/queue.model.d.ts +180 -0
  77. package/dist/shared/queue.model.d.ts.map +1 -0
  78. package/dist/shared/queue.model.js +42 -0
  79. package/dist/shared/webhook-event.model.d.ts.map +1 -1
  80. package/dist/shared/webhook-event.model.js +4 -0
  81. package/dist/users/auth-log.model.d.ts.map +1 -1
  82. package/dist/users/auth-log.model.js +3 -0
  83. package/dist/users/permission.model.d.ts.map +1 -1
  84. package/dist/users/permission.model.js +2 -0
  85. package/dist/users/role-group.model.d.ts.map +1 -1
  86. package/dist/users/role-group.model.js +3 -0
  87. package/dist/users/role.model.d.ts.map +1 -1
  88. package/dist/users/role.model.js +3 -0
  89. package/dist/users/user.model.d.ts.map +1 -1
  90. package/dist/users/user.model.js +10 -0
  91. package/package.json +86 -86
  92. package/dist/applicants/applicant-income-source.model.d.ts +0 -26
  93. package/dist/applicants/applicant-income-source.model.d.ts.map +0 -1
  94. package/dist/applicants/applicant-income.model.d.ts +0 -160
  95. package/dist/applicants/applicant-income.model.d.ts.map +0 -1
  96. package/dist/applicants/applicant-other-income.model.d.ts +0 -85
  97. package/dist/applicants/applicant-other-income.model.d.ts.map +0 -1
  98. package/dist/applications/application-document.model.d.ts +0 -158
  99. package/dist/applications/application-document.model.d.ts.map +0 -1
  100. package/dist/applications/document.model.d.ts +0 -158
  101. package/dist/applications/document.model.d.ts.map +0 -1
  102. package/dist/applications/productfeatures.model.d.ts +0 -368
  103. package/dist/applications/productfeatures.model.d.ts.map +0 -1
  104. package/dist/shared/document-type-model.d.ts +0 -48
  105. package/dist/shared/document-type-model.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-commitment-mortgage.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-commitment-mortgage.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AA0E5D,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAiE,CAAC;AAC/F,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"applicant-commitment-mortgage.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-commitment-mortgage.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AA6E5D,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAiE,CAAC;AAC/F,eAAe,uBAAuB,CAAC"}
@@ -62,5 +62,8 @@ mortgageCommitmentSchema.virtual('applicationType').get(function () {
62
62
  applyAuditMiddleware(mortgageCommitmentSchema, "MortgageCommitment");
63
63
  // Apply workflow plugin to the schema
64
64
  applyWorkflowPlugin(mortgageCommitmentSchema, 'mortgagecommitment');
65
+ // Indexes for query optimization
66
+ mortgageCommitmentSchema.index({ applicantId: 1 });
67
+ mortgageCommitmentSchema.index({ applicantId: 1, isSelected: 1 });
65
68
  const MortgageCommitmentModel = mongoose.model("MortgageCommitment", mortgageCommitmentSchema);
66
69
  export default MortgageCommitmentModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-commitment-residence.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-commitment-residence.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OA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,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAmE,CAAC;AAClG,eAAe,wBAAwB,CAAC"}
@@ -51,5 +51,7 @@ const residenceCommitmentSchema = new mongoose.Schema({
51
51
  applyAuditMiddleware(residenceCommitmentSchema, "ResidenceCommitment");
52
52
  // Apply workflow plugin to the schema
53
53
  applyWorkflowPlugin(residenceCommitmentSchema, 'residencecommitment');
54
+ // Indexes for query optimization
55
+ residenceCommitmentSchema.index({ applicantId: 1 });
54
56
  const ResidenceCommitmentModel = mongoose.model("ResidenceCommitment", residenceCommitmentSchema);
55
57
  export default ResidenceCommitmentModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-commitment-secureLoan.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-commitment-secureLoan.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AA4C5D,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuE,CAAC;AACxG,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"applicant-commitment-secureLoan.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-commitment-secureLoan.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAgD5D,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuE,CAAC;AACxG,eAAe,0BAA0B,CAAC"}
@@ -36,5 +36,8 @@ securedLoanCommitmentSchema.virtual('lendingType').get(function () {
36
36
  applyAuditMiddleware(securedLoanCommitmentSchema, "SecuredLoanCommitment");
37
37
  // Apply workflow plugin to the schema
38
38
  applyWorkflowPlugin(securedLoanCommitmentSchema, 'securedloancommitment');
39
+ // Indexes for query optimization
40
+ securedLoanCommitmentSchema.index({ applicantId: 1 });
41
+ securedLoanCommitmentSchema.index({ applicantId: 1, isSelected: 1 });
39
42
  const SecuredLoanCommitmentModel = mongoose.model("SecuredLoanCommitment", securedLoanCommitmentSchema);
40
43
  export default SecuredLoanCommitmentModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-commitment-unsecuredLoan.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-commitment-unsecuredLoan.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AA4C5D,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA2E,CAAC;AAC9G,eAAe,4BAA4B,CAAC"}
1
+ {"version":3,"file":"applicant-commitment-unsecuredLoan.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-commitment-unsecuredLoan.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAgD5D,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA2E,CAAC;AAC9G,eAAe,4BAA4B,CAAC"}
@@ -36,5 +36,8 @@ unsecuredLoanCommitmentSchema.virtual('lendingType').get(function () {
36
36
  applyAuditMiddleware(unsecuredLoanCommitmentSchema, "UnsecuredLoanCommitment");
37
37
  // Apply workflow plugin to the schema
38
38
  applyWorkflowPlugin(unsecuredLoanCommitmentSchema, 'unsecuredloancommitment');
39
+ // Indexes for query optimization
40
+ unsecuredLoanCommitmentSchema.index({ applicantId: 1 });
41
+ unsecuredLoanCommitmentSchema.index({ applicantId: 1, isSelected: 1 });
39
42
  const UnsecuredLoanCommitmentModel = mongoose.model("UnsecuredLoanCommitment", unsecuredLoanCommitmentSchema);
40
43
  export default UnsecuredLoanCommitmentModel;
@@ -111,6 +111,7 @@ const applicantCreditReportSchema = new Schema({
111
111
  noticeofCorrection: [noticeofCorrectionSchema],
112
112
  });
113
113
  // Apply workflow plugin to the schema
114
+ applicantCreditReportSchema.index({ applicantId: 1 });
114
115
  applyWorkflowPlugin(applicantCreditReportSchema, 'applicantcreditreport');
115
116
  const ApplicantCreditReportModel = mongoose.model("ApplicantCreditReport", applicantCreditReportSchema);
116
117
  export default ApplicantCreditReportModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-employment-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-employment-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAiB5D,QAAA,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAgF,CAAC;AAErH,eAAe,8BAA8B,CAAC"}
1
+ {"version":3,"file":"applicant-employment-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-employment-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAqB5D,QAAA,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAgF,CAAC;AAErH,eAAe,8BAA8B,CAAC"}
@@ -13,5 +13,8 @@ applicantEmploymentIncomeSchema.virtual('incomeSourceId').get(function () {
13
13
  });
14
14
  // Apply workflow plugin to the schema
15
15
  applyWorkflowPlugin(applicantEmploymentIncomeSchema, 'applicantemploymentincome');
16
+ // Add indexes that exist in database but missing from model
17
+ applicantEmploymentIncomeSchema.index({ applicantId: 1 }); // Filter by applicant
18
+ applicantEmploymentIncomeSchema.index({ applicantId: 1, incomeTypeLid: 1 }); // Compound: applicant + income type
16
19
  const ApplicantEmploymentIncomeModel = mongoose.model("Applicant_EmploymentIncome", applicantEmploymentIncomeSchema);
17
20
  export default ApplicantEmploymentIncomeModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-expenditure.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-expenditure.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AA0K5D,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAsE,CAAC;AACtG,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"applicant-expenditure.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-expenditure.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AA6K5D,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAsE,CAAC;AACtG,eAAe,yBAAyB,CAAC"}
@@ -138,6 +138,9 @@ const virtualEssentialExpenditure = applicantExpenditureSchema.virtual("Expendit
138
138
  virtualEssentialExpenditure.description = "Populated lookup value for essential expenditure.";
139
139
  applyAuditMiddleware(applicantExpenditureSchema, "Applicant_Expenditure");
140
140
  // Apply workflow plugin to the schema
141
+ applicantExpenditureSchema.index({ applicantId: 1 });
142
+ applicantExpenditureSchema.index({ applicantId: 1, sectionName: 1 });
143
+ applicantExpenditureSchema.index({ expenditureTypeLid: 1 });
141
144
  applyWorkflowPlugin(applicantExpenditureSchema, 'applicant_expenditure');
142
145
  const ApplicantExpenditureModel = mongoose.model("Applicant_Expenditure", applicantExpenditureSchema);
143
146
  export default ApplicantExpenditureModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-income-settings.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-income-settings.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAwBhC,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA4E,CAAC;AAE/G,eAAe,4BAA4B,CAAC"}
1
+ {"version":3,"file":"applicant-income-settings.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-income-settings.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA0BhC,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA4E,CAAC;AAE/G,eAAe,4BAA4B,CAAC"}
@@ -17,5 +17,6 @@ applicantIncomeSettingsSchema.virtual('lendingType').get(function () {
17
17
  applyAuditMiddleware(applicantIncomeSettingsSchema, "Applicant_IncomeSettings");
18
18
  // Apply workflow plugin to the schema
19
19
  applyWorkflowPlugin(applicantIncomeSettingsSchema, 'applicant_incomesettings');
20
+ applicantIncomeSettingsSchema.index({ applicantId: 1 });
20
21
  const ApplicantIncomeSettingsModel = mongoose.model("Applicant_IncomeSettings", applicantIncomeSettingsSchema);
21
22
  export default ApplicantIncomeSettingsModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-income-summary.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-income-summary.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AA6C5D,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA2E,CAAC;AAE7G,eAAe,2BAA2B,CAAC"}
@@ -37,5 +37,7 @@ const applicantIncomeSummarySchema = new mongoose.Schema({
37
37
  applyAuditMiddleware(applicantIncomeSummarySchema, "Applicant_Income_Summary");
38
38
  // Apply workflow plugin to the schema
39
39
  applyWorkflowPlugin(applicantIncomeSummarySchema, 'applicant_income_summary');
40
+ // Add indexes that exist in database but missing from model
41
+ applicantIncomeSummarySchema.index({ applicantId: 1 }, { unique: true }); // Filter by applicant - unique constraint
40
42
  const ApplicantIncomeSummaryModel = mongoose.model("Applicant_Income_Summary", applicantIncomeSummarySchema);
41
43
  export default ApplicantIncomeSummaryModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-pension-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-pension-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAuC5D,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA0E,CAAC;AAE7G,eAAe,4BAA4B,CAAC"}
@@ -29,5 +29,7 @@ applicantPensionIncomSchema.virtual('incomeSourceId').get(function () {
29
29
  });
30
30
  // Apply workflow plugin to the schema
31
31
  applyWorkflowPlugin(applicantPensionIncomSchema, 'applicant_pension_income');
32
+ // Add indexes that exist in database but missing from model
33
+ applicantPensionIncomSchema.index({ applicantId: 1 }); // Filter by applicant
32
34
  const EmploymentPensionIncomeModel = mongoose.model("Applicant_Pension_Income", applicantPensionIncomSchema);
33
35
  export default EmploymentPensionIncomeModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-property-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-property-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAqC5D,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAoE,CAAC;AAEvG,eAAe,4BAA4B,CAAC"}
@@ -29,5 +29,6 @@ propertyIncomeSchema.virtual('incomeSourceId').get(function () {
29
29
  applyAuditMiddleware(propertyIncomeSchema, "Applicant_Property_Income");
30
30
  // Apply workflow plugin to the schema
31
31
  applyWorkflowPlugin(propertyIncomeSchema, 'applicant_property_income');
32
+ propertyIncomeSchema.index({ applicantId: 1 });
32
33
  const ApplicantPropertyIncomeModel = mongoose.model("Applicant_Property_Income", propertyIncomeSchema);
33
34
  export default ApplicantPropertyIncomeModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-self-employed-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-self-employed-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAuB5D,QAAA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6E,CAAC;AAEpH,eAAe,gCAAgC,CAAC"}
1
+ {"version":3,"file":"applicant-self-employed-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-self-employed-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAwB5D,QAAA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6E,CAAC;AAEpH,eAAe,gCAAgC,CAAC"}
@@ -17,6 +17,7 @@ selfEmployedIncomeSchema.virtual('incomeSourceId').get(function () {
17
17
  });
18
18
  applyAuditMiddleware(selfEmployedIncomeSchema, "Applicant_Self_Employed_Income");
19
19
  // Apply workflow plugin to the schema
20
+ selfEmployedIncomeSchema.index({ applicantId: 1 }); // Filter by applicant
20
21
  applyWorkflowPlugin(selfEmployedIncomeSchema, 'applicant_self_employed_income');
21
22
  const ApplicantSelfEmployedIncomeModel = mongoose.model("Applicant_Self_Employed_Income", selfEmployedIncomeSchema);
22
23
  export default ApplicantSelfEmployedIncomeModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-self-employment.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-self-employment.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA2DhC,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6E,CAAC;AAEhH,eAAe,4BAA4B,CAAC"}
1
+ {"version":3,"file":"applicant-self-employment.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-self-employment.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA8DhC,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6E,CAAC;AAEhH,eAAe,4BAA4B,CAAC"}
@@ -49,5 +49,7 @@ const applicantSelfEmploymentSchema = new mongoose.Schema({
49
49
  });
50
50
  // Apply workflow plugin to the schema
51
51
  applyWorkflowPlugin(applicantSelfEmploymentSchema, 'applicant_self_employment');
52
+ // Add indexes that exist in database but missing from model
53
+ applicantSelfEmploymentSchema.index({ applicantId: 1 }); // Filter by applicant
52
54
  const ApplicantSelfEmploymentModel = mongoose.model("Applicant_Self_Employment", applicantSelfEmploymentSchema);
53
55
  export default ApplicantSelfEmploymentModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-sole-trader-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-sole-trader-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAsB5D,QAAA,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyE,CAAC;AAE9G,eAAe,8BAA8B,CAAC"}
1
+ {"version":3,"file":"applicant-sole-trader-income.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-sole-trader-income.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAwB5D,QAAA,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyE,CAAC;AAE9G,eAAe,8BAA8B,CAAC"}
@@ -16,5 +16,6 @@ soleTraderIncomeSchema.virtual('incomeSourceId').get(function () {
16
16
  });
17
17
  // Apply workflow plugin to the schema
18
18
  applyWorkflowPlugin(soleTraderIncomeSchema, 'applicant_sole_trader_income');
19
+ soleTraderIncomeSchema.index({ applicantId: 1 });
19
20
  const ApplicantSoleTraderIncomeModel = mongoose.model("Applicant_Sole_Trader_Income", soleTraderIncomeSchema);
20
21
  export default ApplicantSoleTraderIncomeModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-uk-tax-credits.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-uk-tax-credits.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAoB5D,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA0E,CAAC;AAE3G,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"applicant-uk-tax-credits.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-uk-tax-credits.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAuB5D,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA0E,CAAC;AAE3G,eAAe,0BAA0B,CAAC"}
@@ -15,5 +15,7 @@ applicantUkTaxCreditsSchema.virtual('incomeSourceId').get(function () {
15
15
  });
16
16
  // Apply workflow plugin to the schema
17
17
  applyWorkflowPlugin(applicantUkTaxCreditsSchema, 'applicant_uk_tax_credits');
18
+ // Add indexes that exist in database but missing from model
19
+ applicantUkTaxCreditsSchema.index({ applicantId: 1 }); // Filter by applicant
18
20
  const ApplicantUkTaxCreditsModel = mongoose.model("Applicant_Uk_Tax_Credits", applicantUkTaxCreditsSchema);
19
21
  export default ApplicantUkTaxCreditsModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant-welcome-call.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-welcome-call.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAqtBhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA4D,CAAC;AAEnF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"applicant-welcome-call.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-welcome-call.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA+hBhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA4D,CAAC;AAEnF,eAAe,gBAAgB,CAAC"}
@@ -237,66 +237,14 @@ welcomeCallSchema.virtual('customerCurrentResidentialAddress').get(function () {
237
237
  applicant.addressLine2,
238
238
  applicant.addressLine3,
239
239
  applicant.addressCity,
240
- applicant.propertyAddressCountry,
241
- applicant.addressPostCode
240
+ applicant.addressPostCode,
241
+ countryName
242
242
  ].filter(part => part && part.trim() !== '');
243
243
  return addressParts.join(', ');
244
244
  }
245
245
  }
246
246
  return null;
247
247
  });
248
- // Virtual property for applicant employer/business name based on income settings
249
- welcomeCallSchema.virtual('applicantEmployerBusinessName').get(function () {
250
- if (this.applicantId && typeof this.applicantId === 'object') {
251
- const applicant = this.applicantId;
252
- // Check if applicant has income settings
253
- if (applicant.incomeSourceId && typeof applicant.incomeSourceId === 'object') {
254
- const incomeSettings = applicant.incomeSourceId;
255
- // If incomeFromEmployment is false, return N/A
256
- if (!incomeSettings.incomeFromEmployment)
257
- return 'N/A';
258
- // Check employment status to determine if employed or self-employed
259
- if (incomeSettings.employmentStatusLid && typeof incomeSettings.employmentStatusLid === 'object') {
260
- const employmentStatus = incomeSettings.employmentStatusLid;
261
- const statusName = employmentStatus.name;
262
- // Check if it's employed status - compare by name for stability
263
- if (statusName === 'Employee with no shareholding' ||
264
- statusName === 'A non-equity partner in a partnership' ||
265
- statusName === 'A shareholder with less than 25% shares') {
266
- // Check employment information
267
- if (applicant.employmentInformationId && typeof applicant.employmentInformationId === 'object') {
268
- const employment = applicant.employmentInformationId;
269
- if (employment.employerName && employment.employerName.trim() !== '') {
270
- return employment.employerName;
271
- }
272
- }
273
- }
274
- // Check if it's self-employed or solo trader status - compare by name for stability
275
- else if (statusName === 'A shareholder with 25% or more shares' ||
276
- statusName === 'An equity partner in a partnership' ||
277
- statusName === 'Sole Trader') {
278
- // Check self-employment information
279
- if (applicant.selfEmployedInformationId && typeof applicant.selfEmployedInformationId === 'object') {
280
- const selfEmployment = applicant.selfEmployedInformationId;
281
- if (selfEmployment.nameOfBusiness && selfEmployment.nameOfBusiness.trim() !== '') {
282
- return selfEmployment.nameOfBusiness;
283
- }
284
- }
285
- }
286
- }
287
- else {
288
- console.log('No employment status found');
289
- }
290
- }
291
- else {
292
- console.log('No income settings found');
293
- }
294
- }
295
- else {
296
- console.log('No applicant found');
297
- }
298
- return 'N/A';
299
- });
300
248
  // Virtual property for Customer's Contact Numbers (Phone and Mobile)
301
249
  welcomeCallSchema.virtual('customerContactNumbers').get(function () {
302
250
  if (this.applicantId && typeof this.applicantId === 'object') {
@@ -380,123 +328,6 @@ welcomeCallSchema.virtual('allApplicantsNameAndDOB').get(function () {
380
328
  // If application not populated or no applicants, return "N/A"
381
329
  return 'N/A';
382
330
  });
383
- // Virtual property for other applicants name and DOB in the requested format
384
- welcomeCallSchema.virtual('otherApplicantsNameAndDOB').get(function () {
385
- console.log('=== DEBUG otherApplicantsNameAndDOB ===');
386
- console.log('this.applicationId:', this.applicationId);
387
- console.log('this.applicantId:', this.applicantId);
388
- console.log('typeof this.applicationId:', typeof this.applicationId);
389
- console.log('typeof this.applicantId:', typeof this.applicantId);
390
- // Try to get application from applicantId first, then from applicationId
391
- let application = null;
392
- if (this.applicantId &&
393
- typeof this.applicantId === 'object' &&
394
- !(typeof this.applicantId.toHexString === 'function') && // not ObjectId
395
- this.applicantId.applicationId) {
396
- application = this.applicantId.applicationId;
397
- console.log('Got application from applicantId.applicationId');
398
- }
399
- else if (this.applicationId && typeof this.applicationId === 'object') {
400
- application = this.applicationId;
401
- console.log('Got application from this.applicationId');
402
- }
403
- else {
404
- console.log('No application found in either applicantId.applicationId or this.applicationId');
405
- return 'N/A';
406
- }
407
- if (application) {
408
- console.log('application object:', application);
409
- console.log('application.applicants:', application.applicants);
410
- console.log('Array.isArray(application.applicants):', Array.isArray(application.applicants));
411
- console.log('application.applicants.length:', application.applicants?.length);
412
- // Additional debug: Check if applicants is populated
413
- if (application.applicants && application.applicants.length > 0) {
414
- console.log('First applicant sample:', application.applicants[0]);
415
- console.log('First applicant type:', typeof application.applicants[0]);
416
- console.log('First applicant has firstName:', !!application.applicants[0]?.firstName);
417
- }
418
- // Get all applicants from the application (field name is 'applicants')
419
- if (application.applicants && Array.isArray(application.applicants) && application.applicants.length > 0) {
420
- console.log('Found applicants array with length:', application.applicants.length);
421
- // Get current applicant ID for comparison
422
- const currentApplicantId = this.applicantId?._id || this.applicantId;
423
- console.log('currentApplicantId:', currentApplicantId);
424
- // Filter out the current applicant to get only OTHER applicants
425
- const otherApplicants = application.applicants.filter((applicant) => {
426
- const applicantId = applicant._id || applicant;
427
- console.log('Comparing applicantId:', applicantId, 'with currentApplicantId:', currentApplicantId);
428
- return applicantId.toString() !== currentApplicantId.toString();
429
- });
430
- console.log('otherApplicants after filtering:', otherApplicants.length);
431
- // If no other applicants, return "N/A" (single applicant case)
432
- if (otherApplicants.length === 0) {
433
- console.log('No other applicants found, returning N/A');
434
- return 'N/A';
435
- }
436
- // Format each other applicant as: "First and middle names, last name, Date of birth"
437
- const formattedApplicants = otherApplicants.map((applicant) => {
438
- console.log('Processing applicant:', applicant);
439
- // Check if applicant is an ObjectId (not populated)
440
- if (typeof applicant === 'string' || (applicant.constructor && applicant.constructor.name === 'ObjectId')) {
441
- console.log('Applicant is not populated, skipping');
442
- return null; // Skip unpopulated references
443
- }
444
- const firstName = applicant.firstName || '';
445
- const middleName = applicant.middleName || '';
446
- const lastName = applicant.lastName || '';
447
- console.log('Applicant names:', { firstName, middleName, lastName });
448
- // Combine first and middle names with space
449
- const fullFirstName = middleName ? `${firstName} ${middleName}` : firstName;
450
- // Format date of birth to dd/mm/yyyy
451
- let formattedDOB = '';
452
- if (applicant.dateOfBirth) {
453
- console.log('Applicant dateOfBirth:', applicant.dateOfBirth);
454
- // Check if dateOfBirth is already a formatted string (DD/MM/YYYY)
455
- if (typeof applicant.dateOfBirth === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(applicant.dateOfBirth)) {
456
- // Already in DD/MM/YYYY format
457
- formattedDOB = applicant.dateOfBirth;
458
- }
459
- else {
460
- // Try to parse as Date object or ISO string
461
- try {
462
- const date = new Date(applicant.dateOfBirth);
463
- // Check if date is valid
464
- if (!isNaN(date.getTime())) {
465
- const day = String(date.getDate()).padStart(2, '0');
466
- const month = String(date.getMonth() + 1).padStart(2, '0');
467
- const year = date.getFullYear();
468
- formattedDOB = `${day}/${month}/${year}`;
469
- }
470
- }
471
- catch (e) {
472
- // Date parsing failed, try to use as-is if it's a string
473
- if (typeof applicant.dateOfBirth === 'string') {
474
- formattedDOB = applicant.dateOfBirth;
475
- }
476
- }
477
- }
478
- }
479
- // Format as "First and middle names, last name, Date of birth"
480
- const result = `${fullFirstName}, ${lastName}, ${formattedDOB}`;
481
- console.log('Formatted applicant result:', result);
482
- return result;
483
- }).filter((line) => line && line.trim() !== ', ,' && line.trim() !== '');
484
- console.log('Final formattedApplicants:', formattedApplicants);
485
- // Join all applicants with newline
486
- const finalResult = formattedApplicants.join('\n');
487
- console.log('Final result:', finalResult);
488
- return finalResult;
489
- }
490
- else {
491
- console.log('No applicants array found or empty array');
492
- console.log('This means you need to populate the applicationId with applicants when querying');
493
- console.log('Use: .populate({ path: "applicationId", populate: { path: "applicants" } })');
494
- }
495
- }
496
- // If application not populated or no applicants, return "N/A"
497
- console.log('Returning N/A - no application or applicants found');
498
- return 'N/A';
499
- });
500
331
  // Virtual property for broker name and firm
501
332
  welcomeCallSchema.virtual('brokerNameAndFirm').get(function () {
502
333
  // Access application from welcome call directly
@@ -670,5 +501,7 @@ welcomeCallSchema.virtual('initialRatePercentage').get(function () {
670
501
  applyAuditMiddleware(welcomeCallSchema, "ApplicantWelcomeCall");
671
502
  // Apply workflow plugin to the schema
672
503
  applyWorkflowPlugin(welcomeCallSchema, 'applicantwelcomecall');
504
+ // Index for query optimization
505
+ welcomeCallSchema.index({ applicantId: 1, isActive: 1 }); // Compound index for getWelcomeCallByApplicantId and softDeleteByApplicantId queries
673
506
  const WelcomeCallModel = mongoose.model('ApplicantWelcomeCall', welcomeCallSchema);
674
507
  export default WelcomeCallModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applicant.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAOhC,OAAO,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAC;AAuQ5D,QAAA,MA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA+C,CAAC;AACpE,eAAe,cAAc,CAAC"}
@@ -236,5 +236,19 @@ applicantSchema.virtual('numberOfApplicants').get(function () {
236
236
  applyAuditMiddleware(applicantSchema, "Applicant");
237
237
  // Apply workflow plugin to the schema
238
238
  applyWorkflowPlugin(applicantSchema, 'applicant');
239
+ // Database indexes for performance optimization
240
+ // Single field indexes
241
+ applicantSchema.index({ applicationId: 1 });
242
+ applicantSchema.index({ applicantId: 1 });
243
+ // Compound indexes
244
+ applicantSchema.index({ applicationId: 1, isExpenseOwner: 1 }); // For expense owner queries
245
+ applicantSchema.index({ applicationId: 1, _id: 1 }); // For application-scoped queries
246
+ // Indexes for lookup operations
247
+ applicantSchema.index({ nationalityLid: 1 });
248
+ applicantSchema.index({ countryOfResidenceLid: 1 });
249
+ applicantSchema.index({ maritalStatusLid: 1 });
250
+ applicantSchema.index({ residentialStatusLid: 1 });
251
+ applicantSchema.index({ addressCountryLid: 1 });
252
+ applicantSchema.index({ incomeSummaryId: 1 });
239
253
  const ApplicantModel = mongoose.model("Applicant", applicantSchema);
240
254
  export default ApplicantModel;
@@ -90,6 +90,8 @@ const virtualApplicants = applicationDirectDebitSchema.virtual('applicants', {
90
90
  }
91
91
  });
92
92
  virtualApplicants.description = 'Full Name of the applicant';
93
+ // Index for applicationId queries
94
+ applicationDirectDebitSchema.index({ applicationId: 1 });
93
95
  // Apply workflow plugin to the schema
94
96
  applyWorkflowPlugin(applicationDirectDebitSchema, 'application_directdebit');
95
97
  const ApplicationDirectDebitModel = mongoose.model("Application_DirectDebit", applicationDirectDebitSchema);
@@ -1 +1 @@
1
- {"version":3,"file":"application-euc.model.d.ts","sourceRoot":"","sources":["../../applications/application-euc.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAiBhC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyD,CAAC;AACnF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"application-euc.model.d.ts","sourceRoot":"","sources":["../../applications/application-euc.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAoBhC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyD,CAAC;AACnF,eAAe,mBAAmB,CAAC"}
@@ -8,5 +8,7 @@ const applicationEucSchema = new mongoose.Schema({
8
8
  });
9
9
  // Apply workflow plugin to the schema
10
10
  applyWorkflowPlugin(applicationEucSchema, 'applicationeuc');
11
+ // Add indexes that exist in database but missing from model
12
+ applicationEucSchema.index({ applicationId: 1 }, { unique: true }); // Unique index for applicationId
11
13
  const ApplicationEucModel = mongoose.model("ApplicationEUC", applicationEucSchema);
12
14
  export default ApplicationEucModel;
@@ -262,5 +262,7 @@ mortgageSchema.virtual("sourceOfWealth").get(function () {
262
262
  });
263
263
  // Apply workflow plugin to the schema
264
264
  applyWorkflowPlugin(mortgageSchema, 'mortgage');
265
+ // Index for query optimization
266
+ mortgageSchema.index({ applicationId: 1 }); // Index for getByApplicationId queries
265
267
  const MortgageModel = mongoose.model("Mortgage", mortgageSchema);
266
268
  export default MortgageModel;
@@ -1 +1 @@
1
- {"version":3,"file":"application-note.model.d.ts","sourceRoot":"","sources":["../../applications/application-note.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA6FhC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA+C,CAAC;AACzE,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"application-note.model.d.ts","sourceRoot":"","sources":["../../applications/application-note.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAiHhC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA+C,CAAC;AACzE,eAAe,mBAAmB,CAAC"}
@@ -83,5 +83,23 @@ const noteSchema = new mongoose.Schema({
83
83
  });
84
84
  // Apply workflow plugin to the schema
85
85
  applyWorkflowPlugin(noteSchema, 'applictionnote');
86
+ // Database indexes for performance optimization
87
+ // Existing indexes
88
+ noteSchema.index({ applicationId: 1 });
89
+ noteSchema.index({ noteId: 1 });
90
+ noteSchema.index({ createdByUserId: 1 });
91
+ noteSchema.index({ noteTypeLid: 1 });
92
+ noteSchema.index({ noteSubTypeLid: 1 });
93
+ noteSchema.index({
94
+ applicationId: 1,
95
+ noteId: 1
96
+ });
97
+ // Additional recommended indexes for query patterns
98
+ // Compound indexes for primary query patterns
99
+ noteSchema.index({ applicationId: 1, createdOn: -1 }); // Primary query pattern with sort
100
+ noteSchema.index({ applicationId: 1, noteTypeLid: 1 }); // For filtering by type
101
+ noteSchema.index({ applicationId: 1, createdBy: 1 }); // For filtering by creator
102
+ // Single field indexes for distinct and filter operations
103
+ noteSchema.index({ createdBy: 1 }); // For distinct operations and creator filtering
86
104
  const ApplictionNoteModel = mongoose.model("ApplictionNote", noteSchema);
87
105
  export default ApplictionNoteModel;
@@ -1 +1 @@
1
- {"version":3,"file":"application-product.model.d.ts","sourceRoot":"","sources":["../../applications/application-product.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA4FhC,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA2C,CAAC;AAC9D,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"application-product.model.d.ts","sourceRoot":"","sources":["../../applications/application-product.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA6FhC,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA2C,CAAC;AAC9D,eAAe,YAAY,CAAC"}
@@ -77,5 +77,8 @@ productSchema.virtual('productFeePaymentType').get(function () {
77
77
  });
78
78
  // Apply workflow plugin to the schema
79
79
  applyWorkflowPlugin(productSchema, 'product');
80
+ // Indexes for query optimization
81
+ productSchema.index({ applicationId: 1 }); // Index for updateByApplicationId and getByApplicationIdWithRepaymentType queries
82
+ productSchema.index({ repaymentTypeLid: 1 }); // Index for populate operations on repaymentTypeLid
80
83
  const ProductModel = mongoose.model("Product", productSchema);
81
84
  export default ProductModel;
@@ -1 +1 @@
1
- {"version":3,"file":"application.model.d.ts","sourceRoot":"","sources":["../../applications/application.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAwOhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAmD,CAAC;AAC1E,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"application.model.d.ts","sourceRoot":"","sources":["../../applications/application.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAsPhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAmD,CAAC;AAC1E,eAAe,gBAAgB,CAAC"}
@@ -206,5 +206,16 @@ applicationSchema.virtual('taskCompletionPercent').get(function () {
206
206
  // Calculate (lender/total)*100
207
207
  return Number(((lender / total) * 100).toFixed(2));
208
208
  });
209
+ // Database indexes for performance optimization
210
+ // Single field indexes
211
+ applicationSchema.index({ applicationId: 1 });
212
+ applicationSchema.index({ assignedToUserId: 1 });
213
+ applicationSchema.index({ brokerId: 1 });
214
+ applicationSchema.index({ applicants: 1 }); // For array membership queries
215
+ // Compound indexes for common query combinations
216
+ applicationSchema.index({ applicants: 1, _id: 1 }); // For finding application by applicant
217
+ applicationSchema.index({ assignedToUserId: 1, statusLid: 1 }); // For filtering by assignee and status
218
+ // Text index for search functionality
219
+ applicationSchema.index({ applicationNumber: "text" });
209
220
  const ApplicationModel = mongoose.model("Application", applicationSchema);
210
221
  export default ApplicationModel;
@@ -1 +1 @@
1
- {"version":3,"file":"applications-task.model.d.ts","sourceRoot":"","sources":["../../applications/applications-task.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA4ChC,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6D,CAAC;AACzF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"applications-task.model.d.ts","sourceRoot":"","sources":["../../applications/applications-task.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA+ChC,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6D,CAAC;AACzF,eAAe,qBAAqB,CAAC"}