@dynamatix/gb-schemas 2.3.267 → 2.3.269

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.
@@ -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;AAymBhC,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;AAspBhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA4D,CAAC;AAEnF,eAAe,gBAAgB,CAAC"}
@@ -247,59 +247,42 @@ welcomeCallSchema.virtual('customerCurrentResidentialAddress').get(function () {
247
247
  });
248
248
  // Virtual property for applicant employer/business name based on income settings
249
249
  welcomeCallSchema.virtual('applicantEmployerBusinessName').get(function () {
250
- console.log(this.applicantId, 'testing');
251
250
  if (this.applicantId && typeof this.applicantId === 'object') {
252
251
  const applicant = this.applicantId;
253
- console.log(applicant, 'applicant data');
254
252
  // Check if applicant has income settings
255
253
  if (applicant.incomeSourceId && typeof applicant.incomeSourceId === 'object') {
256
254
  const incomeSettings = applicant.incomeSourceId;
257
- // Debug logging
258
- console.log('Income Settings:', {
259
- incomeFromEmployment: incomeSettings.incomeFromEmployment,
260
- employmentStatusLid: incomeSettings.employmentStatusLid
261
- });
262
255
  // If incomeFromEmployment is false, return N/A
263
- if (!incomeSettings.incomeFromEmployment) {
264
- console.log('Returning N/A: incomeFromEmployment is false');
256
+ if (!incomeSettings.incomeFromEmployment)
265
257
  return 'N/A';
266
- }
267
258
  // Check employment status to determine if employed or self-employed
268
259
  if (incomeSettings.employmentStatusLid && typeof incomeSettings.employmentStatusLid === 'object') {
269
260
  const employmentStatus = incomeSettings.employmentStatusLid;
270
- const statusValue = employmentStatus.value || employmentStatus.name;
271
- console.log('Employment Status:', {
272
- statusValue,
273
- name: employmentStatus.name,
274
- value: employmentStatus.value
275
- });
276
- // Check if it's employed status (options 1, 3, 5)
277
- if (statusValue === '1' || statusValue === '3' || statusValue === '5') {
278
- console.log('Matched employed status, checking employment info');
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') {
279
266
  // Check employment information
280
267
  if (applicant.employmentInformationId && typeof applicant.employmentInformationId === 'object') {
281
268
  const employment = applicant.employmentInformationId;
282
- console.log('Employment Info:', { employerName: employment.employerName });
283
269
  if (employment.employerName && employment.employerName.trim() !== '') {
284
270
  return employment.employerName;
285
271
  }
286
272
  }
287
273
  }
288
- // Check if it's self-employed or solo trader status (options 2, 4)
289
- else if (statusValue === '2' || statusValue === '4' || statusValue === '6') {
290
- console.log('Matched self-employed status, checking self-employment info');
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') {
291
278
  // Check self-employment information
292
279
  if (applicant.selfEmployedInformationId && typeof applicant.selfEmployedInformationId === 'object') {
293
280
  const selfEmployment = applicant.selfEmployedInformationId;
294
- console.log('Self-Employment Info:', { nameOfBusiness: selfEmployment.nameOfBusiness });
295
281
  if (selfEmployment.nameOfBusiness && selfEmployment.nameOfBusiness.trim() !== '') {
296
282
  return selfEmployment.nameOfBusiness;
297
283
  }
298
284
  }
299
285
  }
300
- else {
301
- console.log('No matching employment status found for:', statusValue);
302
- }
303
286
  }
304
287
  else {
305
288
  console.log('No employment status found');
@@ -397,6 +380,73 @@ welcomeCallSchema.virtual('allApplicantsNameAndDOB').get(function () {
397
380
  // If application not populated or no applicants, return "N/A"
398
381
  return 'N/A';
399
382
  });
383
+ // Virtual property for other applicants name and DOB in the requested format
384
+ welcomeCallSchema.virtual('otherApplicantsNameAndDOB').get(function () {
385
+ // Get application and its applicants
386
+ if (this.applicationId && typeof this.applicationId === 'object') {
387
+ const application = this.applicationId;
388
+ // Get all applicants from the application (field name is 'applicants')
389
+ if (application.applicants && Array.isArray(application.applicants) && application.applicants.length > 0) {
390
+ // Get current applicant ID for comparison
391
+ const currentApplicantId = this.applicantId?._id || this.applicantId;
392
+ // Filter out the current applicant to get only OTHER applicants
393
+ const otherApplicants = application.applicants.filter((applicant) => {
394
+ const applicantId = applicant._id || applicant;
395
+ return applicantId.toString() !== currentApplicantId.toString();
396
+ });
397
+ // If no other applicants, return "N/A" (single applicant case)
398
+ if (otherApplicants.length === 0) {
399
+ return 'N/A';
400
+ }
401
+ // Format each other applicant as: "First and middle names, last name, Date of birth"
402
+ const formattedApplicants = otherApplicants.map((applicant) => {
403
+ // Check if applicant is an ObjectId (not populated)
404
+ if (typeof applicant === 'string' || (applicant.constructor && applicant.constructor.name === 'ObjectId')) {
405
+ return null; // Skip unpopulated references
406
+ }
407
+ const firstName = applicant.firstName || '';
408
+ const middleName = applicant.middleName || '';
409
+ const lastName = applicant.lastName || '';
410
+ // Combine first and middle names with space
411
+ const fullFirstName = middleName ? `${firstName} ${middleName}` : firstName;
412
+ // Format date of birth to dd/mm/yyyy
413
+ let formattedDOB = '';
414
+ if (applicant.dateOfBirth) {
415
+ // Check if dateOfBirth is already a formatted string (DD/MM/YYYY)
416
+ if (typeof applicant.dateOfBirth === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(applicant.dateOfBirth)) {
417
+ // Already in DD/MM/YYYY format
418
+ formattedDOB = applicant.dateOfBirth;
419
+ }
420
+ else {
421
+ // Try to parse as Date object or ISO string
422
+ try {
423
+ const date = new Date(applicant.dateOfBirth);
424
+ // Check if date is valid
425
+ if (!isNaN(date.getTime())) {
426
+ const day = String(date.getDate()).padStart(2, '0');
427
+ const month = String(date.getMonth() + 1).padStart(2, '0');
428
+ const year = date.getFullYear();
429
+ formattedDOB = `${day}/${month}/${year}`;
430
+ }
431
+ }
432
+ catch (e) {
433
+ // Date parsing failed, try to use as-is if it's a string
434
+ if (typeof applicant.dateOfBirth === 'string') {
435
+ formattedDOB = applicant.dateOfBirth;
436
+ }
437
+ }
438
+ }
439
+ }
440
+ // Format as "First and middle names, last name, Date of birth"
441
+ return `${fullFirstName}, ${lastName}, ${formattedDOB}`;
442
+ }).filter((line) => line && line.trim() !== ', ,' && line.trim() !== '');
443
+ // Join all applicants with newline
444
+ return formattedApplicants.join('\n');
445
+ }
446
+ }
447
+ // If application not populated or no applicants, return "N/A"
448
+ return 'N/A';
449
+ });
400
450
  // Virtual property for broker name and firm
401
451
  welcomeCallSchema.virtual('brokerNameAndFirm').get(function () {
402
452
  // Access application from welcome call directly
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamatix/gb-schemas",
3
- "version": "2.3.267",
3
+ "version": "2.3.269",
4
4
  "description": "All the schemas for gatehouse bank back-end",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",