@dynamatix/gb-schemas 2.3.269 → 2.3.271
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;
|
|
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"}
|
|
@@ -382,36 +382,75 @@ welcomeCallSchema.virtual('allApplicantsNameAndDOB').get(function () {
|
|
|
382
382
|
});
|
|
383
383
|
// Virtual property for other applicants name and DOB in the requested format
|
|
384
384
|
welcomeCallSchema.virtual('otherApplicantsNameAndDOB').get(function () {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
+
}
|
|
388
418
|
// Get all applicants from the application (field name is 'applicants')
|
|
389
419
|
if (application.applicants && Array.isArray(application.applicants) && application.applicants.length > 0) {
|
|
420
|
+
console.log('Found applicants array with length:', application.applicants.length);
|
|
390
421
|
// Get current applicant ID for comparison
|
|
391
422
|
const currentApplicantId = this.applicantId?._id || this.applicantId;
|
|
423
|
+
console.log('currentApplicantId:', currentApplicantId);
|
|
392
424
|
// Filter out the current applicant to get only OTHER applicants
|
|
393
425
|
const otherApplicants = application.applicants.filter((applicant) => {
|
|
394
426
|
const applicantId = applicant._id || applicant;
|
|
427
|
+
console.log('Comparing applicantId:', applicantId, 'with currentApplicantId:', currentApplicantId);
|
|
395
428
|
return applicantId.toString() !== currentApplicantId.toString();
|
|
396
429
|
});
|
|
430
|
+
console.log('otherApplicants after filtering:', otherApplicants.length);
|
|
397
431
|
// If no other applicants, return "N/A" (single applicant case)
|
|
398
432
|
if (otherApplicants.length === 0) {
|
|
433
|
+
console.log('No other applicants found, returning N/A');
|
|
399
434
|
return 'N/A';
|
|
400
435
|
}
|
|
401
436
|
// Format each other applicant as: "First and middle names, last name, Date of birth"
|
|
402
437
|
const formattedApplicants = otherApplicants.map((applicant) => {
|
|
438
|
+
console.log('Processing applicant:', applicant);
|
|
403
439
|
// Check if applicant is an ObjectId (not populated)
|
|
404
440
|
if (typeof applicant === 'string' || (applicant.constructor && applicant.constructor.name === 'ObjectId')) {
|
|
441
|
+
console.log('Applicant is not populated, skipping');
|
|
405
442
|
return null; // Skip unpopulated references
|
|
406
443
|
}
|
|
407
444
|
const firstName = applicant.firstName || '';
|
|
408
445
|
const middleName = applicant.middleName || '';
|
|
409
446
|
const lastName = applicant.lastName || '';
|
|
447
|
+
console.log('Applicant names:', { firstName, middleName, lastName });
|
|
410
448
|
// Combine first and middle names with space
|
|
411
449
|
const fullFirstName = middleName ? `${firstName} ${middleName}` : firstName;
|
|
412
450
|
// Format date of birth to dd/mm/yyyy
|
|
413
451
|
let formattedDOB = '';
|
|
414
452
|
if (applicant.dateOfBirth) {
|
|
453
|
+
console.log('Applicant dateOfBirth:', applicant.dateOfBirth);
|
|
415
454
|
// Check if dateOfBirth is already a formatted string (DD/MM/YYYY)
|
|
416
455
|
if (typeof applicant.dateOfBirth === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(applicant.dateOfBirth)) {
|
|
417
456
|
// Already in DD/MM/YYYY format
|
|
@@ -438,13 +477,24 @@ welcomeCallSchema.virtual('otherApplicantsNameAndDOB').get(function () {
|
|
|
438
477
|
}
|
|
439
478
|
}
|
|
440
479
|
// Format as "First and middle names, last name, Date of birth"
|
|
441
|
-
|
|
480
|
+
const result = `${fullFirstName}, ${lastName}, ${formattedDOB}`;
|
|
481
|
+
console.log('Formatted applicant result:', result);
|
|
482
|
+
return result;
|
|
442
483
|
}).filter((line) => line && line.trim() !== ', ,' && line.trim() !== '');
|
|
484
|
+
console.log('Final formattedApplicants:', formattedApplicants);
|
|
443
485
|
// Join all applicants with newline
|
|
444
|
-
|
|
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" } })');
|
|
445
494
|
}
|
|
446
495
|
}
|
|
447
496
|
// If application not populated or no applicants, return "N/A"
|
|
497
|
+
console.log('Returning N/A - no application or applicants found');
|
|
448
498
|
return 'N/A';
|
|
449
499
|
});
|
|
450
500
|
// Virtual property for broker name and firm
|