@tomei/rental 0.17.4-dev.2 → 0.17.4-dev.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/rental",
3
- "version": "0.17.4-dev.2",
3
+ "version": "0.17.4-dev.3",
4
4
  "description": "Tomei Rental Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -445,6 +445,7 @@ export class RentalHirerChangeRequest
445
445
  }
446
446
 
447
447
  // 2. Prepare all signature data (main + joint) in one go
448
+ this.Rental.AccountType = RentalAccountTypeEnum.JOINT;
448
449
  const jointHirers = await this.Rental.getJointHirers(dbTransaction);
449
450
 
450
451
  // Main hirer signature
@@ -454,23 +455,32 @@ export class RentalHirerChangeRequest
454
455
  mainSignature.HirerType = HirerChangeRequestHirerRoleEnum.MAIN;
455
456
  mainSignature.Method = 'Upload';
456
457
 
457
- // Joint hirer signatures
458
- const jointSignaturePromises = jointHirers.map(async (jointHirer) => {
459
- const signature = await HirerChangeRequestSignature.init();
460
- signature.RequestId = this.RequestId;
461
- signature.JointHirerId = jointHirer.HirerId;
462
- signature.HirerType = HirerChangeRequestHirerRoleEnum.JOINT;
463
- signature.Method = 'Upload';
464
- return signature;
465
- });
458
+ // Joint hirer signatures - only if there are joint hirers
459
+ let jointSignatures = [];
460
+ if (jointHirers.length > 0) {
461
+ const jointSignaturePromises = jointHirers.map(async (jointHirer) => {
462
+ const signature = await HirerChangeRequestSignature.init();
463
+ signature.RequestId = this.RequestId;
464
+ signature.JointHirerId = jointHirer.HirerId;
465
+ signature.HirerType = HirerChangeRequestHirerRoleEnum.JOINT;
466
+ signature.Method = 'Upload';
467
+ return signature;
468
+ });
466
469
 
467
- const jointSignatures = await Promise.all(jointSignaturePromises);
470
+ jointSignatures = await Promise.all(jointSignaturePromises);
471
+ }
468
472
 
469
473
  // 3. Create all signatures in parallel
470
- await Promise.all([
474
+ const signaturesToCreate = [
471
475
  mainSignature.create(loginUser, dbTransaction),
472
- ...jointSignatures.map((sig) => sig.create(loginUser, dbTransaction)),
473
- ]);
476
+ ];
477
+ if (jointSignatures.length > 0) {
478
+ signaturesToCreate.push(
479
+ ...jointSignatures.map((sig) => sig.create(loginUser, dbTransaction)),
480
+ );
481
+ }
482
+
483
+ await Promise.all(signaturesToCreate);
474
484
 
475
485
  this.Signatures = [mainSignature, ...jointSignatures];
476
486
  } catch (error) {