@tomei/rental 0.17.3-dev.5 → 0.17.3-dev.6
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/.commitlintrc.json +22 -22
- package/.gitlab-ci.yml +16 -16
- package/.husky/commit-msg +9 -9
- package/.husky/pre-commit +7 -7
- package/.prettierrc +4 -4
- package/Jenkinsfile +51 -51
- package/README.md +8 -8
- package/dist/ClassMappings/ItemClassMap.d.ts +4 -0
- package/dist/ClassMappings/ItemClassMap.js +8 -0
- package/dist/ClassMappings/ItemClassMap.js.map +1 -0
- package/dist/ClassMappings/index.d.ts +2 -0
- package/dist/ClassMappings/index.js +6 -0
- package/dist/ClassMappings/index.js.map +1 -0
- package/dist/components/agreement/agreement.d.ts +27 -0
- package/dist/components/agreement/agreement.js +120 -0
- package/dist/components/agreement/agreement.js.map +1 -0
- package/dist/components/agreement/agreement.repository.d.ts +8 -0
- package/dist/components/agreement/agreement.repository.js +52 -0
- package/dist/components/agreement/agreement.repository.js.map +1 -0
- package/dist/components/agreement-history/agreement-history.d.ts +17 -0
- package/dist/components/agreement-history/agreement-history.js +40 -0
- package/dist/components/agreement-history/agreement-history.js.map +1 -0
- package/dist/components/agreement-history/agreement-history.repository.d.ts +8 -0
- package/dist/components/agreement-history/agreement-history.repository.js +52 -0
- package/dist/components/agreement-history/agreement-history.repository.js.map +1 -0
- package/dist/components/agreement-signature/agreement-signature.d.ts +27 -0
- package/dist/components/agreement-signature/agreement-signature.js +99 -0
- package/dist/components/agreement-signature/agreement-signature.js.map +1 -0
- package/dist/components/agreement-signature/agreement-signature.repository.d.ts +8 -0
- package/dist/components/agreement-signature/agreement-signature.repository.js +53 -0
- package/dist/components/agreement-signature/agreement-signature.repository.js.map +1 -0
- package/dist/components/booking/booking.d.ts +46 -0
- package/dist/components/booking/booking.js +289 -0
- package/dist/components/booking/booking.js.map +1 -0
- package/dist/components/booking/booking.repository.d.ts +8 -0
- package/dist/components/booking/booking.repository.js +52 -0
- package/dist/components/booking/booking.repository.js.map +1 -0
- package/dist/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.d.ts +32 -0
- package/dist/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.js +106 -0
- package/dist/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.js.map +1 -0
- package/dist/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.d.ts +9 -0
- package/dist/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.js +62 -0
- package/dist/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.js.map +1 -0
- package/dist/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.d.ts +22 -0
- package/dist/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.js +89 -0
- package/dist/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.js.map +1 -0
- package/dist/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.d.ts +9 -0
- package/dist/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.js +63 -0
- package/dist/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.js.map +1 -0
- package/dist/components/hirer-change-request-signature/hirer-change-request-signature.d.ts +30 -0
- package/dist/components/hirer-change-request-signature/hirer-change-request-signature.js +208 -0
- package/dist/components/hirer-change-request-signature/hirer-change-request-signature.js.map +1 -0
- package/dist/components/hirer-change-request-signature/hirer-change-request-signature.repository.d.ts +9 -0
- package/dist/components/hirer-change-request-signature/hirer-change-request-signature.repository.js +63 -0
- package/dist/components/hirer-change-request-signature/hirer-change-request-signature.repository.js.map +1 -0
- package/dist/components/joint-hirer/joint-hirer.d.ts +26 -0
- package/dist/components/joint-hirer/joint-hirer.js +137 -0
- package/dist/components/joint-hirer/joint-hirer.js.map +1 -0
- package/dist/components/joint-hirer/joint-hirer.repository.d.ts +8 -0
- package/dist/components/joint-hirer/joint-hirer.repository.js +52 -0
- package/dist/components/joint-hirer/joint-hirer.repository.js.map +1 -0
- package/dist/components/rental/rental.d.ts +71 -0
- package/dist/components/rental/rental.js +841 -0
- package/dist/components/rental/rental.js.map +1 -0
- package/dist/components/rental/rental.repository.d.ts +8 -0
- package/dist/components/rental/rental.repository.js +52 -0
- package/dist/components/rental/rental.repository.js.map +1 -0
- package/dist/components/rental-hirer-change-request/rental-hirer-change-request.d.ts +71 -0
- package/dist/components/rental-hirer-change-request/rental-hirer-change-request.js +531 -0
- package/dist/components/rental-hirer-change-request/rental-hirer-change-request.js.map +1 -0
- package/dist/components/rental-hirer-change-request/rental-hirer-change-request.repository.d.ts +9 -0
- package/dist/components/rental-hirer-change-request/rental-hirer-change-request.repository.js +62 -0
- package/dist/components/rental-hirer-change-request/rental-hirer-change-request.repository.js.map +1 -0
- package/dist/components/rental-price/rental-price.d.ts +18 -0
- package/dist/components/rental-price/rental-price.js +66 -0
- package/dist/components/rental-price/rental-price.js.map +1 -0
- package/dist/components/rental-price/rental-price.repository.d.ts +8 -0
- package/dist/components/rental-price/rental-price.repository.js +52 -0
- package/dist/components/rental-price/rental-price.repository.js.map +1 -0
- package/dist/database.d.ts +4 -0
- package/dist/database.js +37 -0
- package/dist/database.js.map +1 -0
- package/dist/enum/account-type.enum.d.ts +4 -0
- package/dist/enum/account-type.enum.js +9 -0
- package/dist/enum/account-type.enum.js.map +1 -0
- package/dist/enum/aggrement-status.enum.d.ts +5 -0
- package/dist/enum/aggrement-status.enum.js +10 -0
- package/dist/enum/aggrement-status.enum.js.map +1 -0
- package/dist/enum/agreement-signature-status.enum.d.ts +4 -0
- package/dist/enum/agreement-signature-status.enum.js +9 -0
- package/dist/enum/agreement-signature-status.enum.js.map +1 -0
- package/dist/enum/booking.enum.d.ts +5 -0
- package/dist/enum/booking.enum.js +10 -0
- package/dist/enum/booking.enum.js.map +1 -0
- package/dist/enum/hirer-type.enum.d.ts +4 -0
- package/dist/enum/hirer-type.enum.js +9 -0
- package/dist/enum/hirer-type.enum.js.map +1 -0
- package/dist/enum/index.d.ts +10 -0
- package/dist/enum/index.js +22 -0
- package/dist/enum/index.js.map +1 -0
- package/dist/enum/rental-hirer-change-request-hirer-role.d.ts +4 -0
- package/dist/enum/rental-hirer-change-request-hirer-role.js +9 -0
- package/dist/enum/rental-hirer-change-request-hirer-role.js.map +1 -0
- package/dist/enum/rental-hirer-change-request-status.d.ts +7 -0
- package/dist/enum/rental-hirer-change-request-status.js +12 -0
- package/dist/enum/rental-hirer-change-request-status.js.map +1 -0
- package/dist/enum/rental-hirer-change-request-type.d.ts +4 -0
- package/dist/enum/rental-hirer-change-request-type.js +9 -0
- package/dist/enum/rental-hirer-change-request-type.js.map +1 -0
- package/dist/enum/rental-status.enum.d.ts +9 -0
- package/dist/enum/rental-status.enum.js +14 -0
- package/dist/enum/rental-status.enum.js.map +1 -0
- package/dist/index.d.ts +28 -1
- package/dist/index.js +52 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/agreemeent-signature-attr.interface.d.ts +14 -0
- package/dist/interfaces/agreemeent-signature-attr.interface.js +3 -0
- package/dist/interfaces/agreemeent-signature-attr.interface.js.map +1 -0
- package/dist/interfaces/agreement-attr.interface.d.ts +7 -0
- package/dist/{src/interfaces/hirer-signature-attr.interface.js → interfaces/agreement-attr.interface.js} +1 -1
- package/dist/interfaces/agreement-attr.interface.js.map +1 -0
- package/dist/interfaces/agreement-history-attr.interface.d.ts +7 -0
- package/dist/interfaces/agreement-history-attr.interface.js +3 -0
- package/dist/interfaces/agreement-history-attr.interface.js.map +1 -0
- package/dist/interfaces/booking-attr.interface.d.ts +18 -0
- package/dist/interfaces/booking-attr.interface.js +3 -0
- package/dist/interfaces/booking-attr.interface.js.map +1 -0
- package/dist/interfaces/booking-find-all-search-attr.interface.d.ts +12 -0
- package/dist/interfaces/booking-find-all-search-attr.interface.js +3 -0
- package/dist/interfaces/booking-find-all-search-attr.interface.js.map +1 -0
- package/dist/interfaces/hirer-change-request-new-hirer-attr.interface.d.ts +15 -0
- package/dist/interfaces/hirer-change-request-new-hirer-attr.interface.js +3 -0
- package/dist/interfaces/hirer-change-request-new-hirer-attr.interface.js.map +1 -0
- package/dist/interfaces/hirer-change-request-remove-hirer-attr.interface.d.ts +5 -0
- package/dist/interfaces/hirer-change-request-remove-hirer-attr.interface.js +3 -0
- package/dist/interfaces/hirer-change-request-remove-hirer-attr.interface.js.map +1 -0
- package/dist/interfaces/hirer-change-request-signature-attr.interface.d.ts +14 -0
- package/dist/interfaces/hirer-change-request-signature-attr.interface.js +3 -0
- package/dist/interfaces/hirer-change-request-signature-attr.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +14 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/joint-hirer-attr.interface.d.ts +11 -0
- package/dist/interfaces/joint-hirer-attr.interface.js +3 -0
- package/dist/interfaces/joint-hirer-attr.interface.js.map +1 -0
- package/dist/interfaces/rental-attr.interface.d.ts +24 -0
- package/dist/interfaces/rental-attr.interface.js +3 -0
- package/dist/interfaces/rental-attr.interface.js.map +1 -0
- package/dist/interfaces/rental-find-all-search-attr.interface.d.ts +10 -0
- package/dist/interfaces/rental-find-all-search-attr.interface.js +3 -0
- package/dist/interfaces/rental-find-all-search-attr.interface.js.map +1 -0
- package/dist/interfaces/rental-hirer-change-request.attr.interface.d.ts +16 -0
- package/dist/interfaces/rental-hirer-change-request.attr.interface.js +3 -0
- package/dist/interfaces/rental-hirer-change-request.attr.interface.js.map +1 -0
- package/dist/interfaces/rental-hirer-change-request.update.interface.d.ts +4 -0
- package/dist/interfaces/rental-hirer-change-request.update.interface.js +3 -0
- package/dist/interfaces/rental-hirer-change-request.update.interface.js.map +1 -0
- package/dist/interfaces/rental-price-attr.interface.d.ts +7 -0
- package/dist/interfaces/rental-price-attr.interface.js +3 -0
- package/dist/interfaces/rental-price-attr.interface.js.map +1 -0
- package/dist/interfaces/response-hirer-signature-attr.interface.d.ts +14 -0
- package/dist/interfaces/response-hirer-signature-attr.interface.js +3 -0
- package/dist/interfaces/response-hirer-signature-attr.interface.js.map +1 -0
- package/dist/models/agreement-history.entity.d.ts +10 -0
- package/dist/models/agreement-history.entity.js +65 -0
- package/dist/models/agreement-history.entity.js.map +1 -0
- package/dist/models/agreement-signature.entity.d.ts +18 -0
- package/dist/{src/models/hirer-signature.entity.js → models/agreement-signature.entity.js} +7 -6
- package/dist/models/agreement-signature.entity.js.map +1 -0
- package/dist/models/agreement.entity.d.ts +14 -0
- package/dist/models/agreement.entity.js +70 -0
- package/dist/models/agreement.entity.js.map +1 -0
- package/dist/models/booking.entity.d.ts +21 -0
- package/dist/models/booking.entity.js +128 -0
- package/dist/models/booking.entity.js.map +1 -0
- package/dist/models/hirer-change-request-new-hirer.entity.d.ts +19 -0
- package/dist/models/hirer-change-request-new-hirer.entity.js +121 -0
- package/dist/models/hirer-change-request-new-hirer.entity.js.map +1 -0
- package/dist/models/hirer-change-request-remove-hirer.entity.d.ts +11 -0
- package/dist/models/hirer-change-request-remove-hirer.entity.js +57 -0
- package/dist/models/hirer-change-request-remove-hirer.entity.js.map +1 -0
- package/dist/models/hirer-change-request-signature.entity.d.ts +18 -0
- package/dist/models/hirer-change-request-signature.entity.js +101 -0
- package/dist/models/hirer-change-request-signature.entity.js.map +1 -0
- package/dist/models/index.d.ts +12 -0
- package/dist/models/index.js +26 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/joint-hirer.entity.d.ts +14 -0
- package/dist/models/joint-hirer.entity.js +91 -0
- package/dist/models/joint-hirer.entity.js.map +1 -0
- package/dist/models/rental-hirer-change-request.entity.d.ts +22 -0
- package/dist/models/rental-hirer-change-request.entity.js +108 -0
- package/dist/models/rental-hirer-change-request.entity.js.map +1 -0
- package/dist/models/rental-price.entity.d.ts +8 -0
- package/dist/models/rental-price.entity.js +59 -0
- package/dist/models/rental-price.entity.js.map +1 -0
- package/dist/models/rental.entity.d.ts +29 -0
- package/dist/models/rental.entity.js +160 -0
- package/dist/models/rental.entity.js.map +1 -0
- package/dist/src/components/agreement/agreement.d.ts +1 -1
- package/dist/src/components/agreement/agreement.js +77 -94
- package/dist/src/components/agreement/agreement.js.map +1 -1
- package/dist/src/components/agreement/agreement.repository.js +35 -50
- package/dist/src/components/agreement/agreement.repository.js.map +1 -1
- package/dist/src/components/agreement-history/agreement-history.js +10 -21
- package/dist/src/components/agreement-history/agreement-history.js.map +1 -1
- package/dist/src/components/agreement-history/agreement-history.repository.js +35 -50
- package/dist/src/components/agreement-history/agreement-history.repository.js.map +1 -1
- package/dist/src/components/agreement-signature/agreement-signature.js +57 -70
- package/dist/src/components/agreement-signature/agreement-signature.js.map +1 -1
- package/dist/src/components/agreement-signature/agreement-signature.repository.js +36 -51
- package/dist/src/components/agreement-signature/agreement-signature.repository.js.map +1 -1
- package/dist/src/components/booking/booking.js +206 -231
- package/dist/src/components/booking/booking.js.map +1 -1
- package/dist/src/components/booking/booking.repository.js +35 -50
- package/dist/src/components/booking/booking.repository.js.map +1 -1
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.js +47 -62
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.js.map +1 -1
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.js +46 -63
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.js.map +1 -1
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.js +49 -64
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.js.map +1 -1
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.js +47 -64
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.js.map +1 -1
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.js +150 -167
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.js.map +1 -1
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.js +47 -64
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.js.map +1 -1
- package/dist/src/components/joint-hirer/joint-hirer.js +82 -97
- package/dist/src/components/joint-hirer/joint-hirer.js.map +1 -1
- package/dist/src/components/joint-hirer/joint-hirer.repository.js +35 -50
- package/dist/src/components/joint-hirer/joint-hirer.repository.js.map +1 -1
- package/dist/src/components/rental/rental.d.ts +2 -2
- package/dist/src/components/rental/rental.js +566 -595
- package/dist/src/components/rental/rental.js.map +1 -1
- package/dist/src/components/rental/rental.repository.js +35 -50
- package/dist/src/components/rental/rental.repository.js.map +1 -1
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.js +416 -455
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.js.map +1 -1
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.repository.js +46 -63
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.repository.js.map +1 -1
- package/dist/src/components/rental-price/rental-price.js +33 -46
- package/dist/src/components/rental-price/rental-price.js.map +1 -1
- package/dist/src/components/rental-price/rental-price.repository.js +35 -50
- package/dist/src/components/rental-price/rental-price.repository.js.map +1 -1
- package/dist/src/models/hirer-change-request-new-hirer.entity.d.ts +1 -1
- package/dist/src/models/hirer-change-request-remove-hirer.entity.d.ts +1 -1
- package/dist/src/models/hirer-change-request-signature.entity.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +58 -58
- package/jest.config.js +10 -10
- package/migrations/20250529092130-add-status-to-joint-hirer.js +19 -19
- package/migrations/agreement-signature-table-migration.js +64 -64
- package/migrations/booking-table-migration.js +79 -79
- package/migrations/hirer-change-request-new-hirer-migration.js +72 -72
- package/migrations/hirer-change-request-remove-hirer-migration.js +39 -39
- package/migrations/hirer-change-request-signature-migration.js +65 -65
- package/migrations/joint-hirer-table-migration.js +52 -52
- package/migrations/rental-aggreement-history-migration.js +41 -41
- package/migrations/rental-aggrement-table-migration.js +30 -30
- package/migrations/rental-hirer-change-request-migrations.js +64 -64
- package/migrations/rental-price-table-migration.js +32 -32
- package/migrations/rental-table-migrations.js +96 -96
- package/package.json +77 -75
- package/sonar-project.properties +12 -12
- package/src/ClassMappings/ItemClassMap.ts +7 -0
- package/src/ClassMappings/index.ts +3 -0
- package/src/components/agreement/agreement.repository.ts +54 -54
- package/src/components/agreement/agreement.ts +185 -185
- package/src/components/agreement-history/agreement-history.repository.ts +54 -54
- package/src/components/agreement-history/agreement-history.ts +57 -57
- package/src/components/agreement-signature/agreement-signature.repository.ts +55 -55
- package/src/components/agreement-signature/agreement-signature.ts +143 -143
- package/src/components/booking/booking.repository.ts +51 -51
- package/src/components/booking/booking.ts +492 -492
- package/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.ts +64 -64
- package/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.ts +153 -153
- package/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.ts +65 -65
- package/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.ts +134 -134
- package/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.ts +65 -65
- package/src/components/hirer-change-request-signature/hirer-change-request-signature.ts +272 -272
- package/src/components/joint-hirer/joint-hirer.repository.ts +54 -54
- package/src/components/joint-hirer/joint-hirer.ts +189 -189
- package/src/components/rental/rental.repository.ts +51 -51
- package/src/components/rental/rental.ts +1395 -1167
- package/src/components/rental-hirer-change-request/rental-hirer-change-request.repository.ts +64 -64
- package/src/components/rental-hirer-change-request/rental-hirer-change-request.ts +917 -917
- package/src/components/rental-price/rental-price.repository.ts +54 -54
- package/src/components/rental-price/rental-price.ts +100 -100
- package/src/database.ts +39 -39
- package/src/enum/account-type.enum.ts +4 -4
- package/src/enum/agreement-signature-status.enum.ts +4 -4
- package/src/enum/booking.enum.ts +5 -5
- package/src/enum/hirer-type.enum.ts +4 -4
- package/src/enum/index.ts +21 -21
- package/src/enum/rental-hirer-change-request-hirer-role.ts +4 -4
- package/src/enum/rental-hirer-change-request-status.ts +7 -7
- package/src/enum/rental-hirer-change-request-type.ts +4 -4
- package/src/enum/rental-status.enum.ts +39 -39
- package/src/index.ts +54 -52
- package/src/interfaces/agreemeent-signature-attr.interface.ts +15 -15
- package/src/interfaces/agreement-attr.interface.ts +7 -7
- package/src/interfaces/agreement-history-attr.interface.ts +7 -7
- package/src/interfaces/booking-attr.interface.ts +19 -19
- package/src/interfaces/booking-find-all-search-attr.interface.ts +12 -12
- package/src/interfaces/hirer-change-request-new-hirer-attr.interface.ts +15 -15
- package/src/interfaces/hirer-change-request-remove-hirer-attr.interface.ts +5 -5
- package/src/interfaces/hirer-change-request-signature-attr.interface.ts +15 -15
- package/src/interfaces/index.ts +29 -29
- package/src/interfaces/joint-hirer-attr.interface.ts +11 -11
- package/src/interfaces/rental-attr.interface.ts +25 -25
- package/src/interfaces/rental-find-all-search-attr.interface.ts +11 -11
- package/src/interfaces/rental-hirer-change-request.attr.interface.ts +17 -17
- package/src/interfaces/rental-hirer-change-request.update.interface.ts +4 -4
- package/src/interfaces/rental-price-attr.interface.ts +7 -7
- package/src/interfaces/response-hirer-signature-attr.interface.ts +15 -15
- package/src/models/agreement-history.entity.ts +51 -51
- package/src/models/agreement-signature.entity.ts +86 -86
- package/src/models/agreement.entity.ts +47 -47
- package/src/models/booking.entity.ts +105 -105
- package/src/models/hirer-change-request-new-hirer.entity.ts +102 -102
- package/src/models/hirer-change-request-remove-hirer.entity.ts +47 -47
- package/src/models/hirer-change-request-signature.entity.ts +86 -86
- package/src/models/index.ts +25 -25
- package/src/models/joint-hirer.entity.ts +70 -70
- package/src/models/rental-price.entity.ts +38 -38
- package/src/models/rental.entity.ts +133 -133
- package/tsconfig.build.json +11 -6
- package/tsconfig.json +22 -24
- package/dist/src/components/agreement-signature/hirer-signature.d.ts +0 -27
- package/dist/src/components/agreement-signature/hirer-signature.js +0 -112
- package/dist/src/components/agreement-signature/hirer-signature.js.map +0 -1
- package/dist/src/components/agreement-signature/hirer-signature.repository.d.ts +0 -8
- package/dist/src/components/agreement-signature/hirer-signature.repository.js +0 -67
- package/dist/src/components/agreement-signature/hirer-signature.repository.js.map +0 -1
- package/dist/src/components/hirer-signature/hirer-signature.d.ts +0 -27
- package/dist/src/components/hirer-signature/hirer-signature.js +0 -112
- package/dist/src/components/hirer-signature/hirer-signature.js.map +0 -1
- package/dist/src/components/hirer-signature/hirer-signature.repository.d.ts +0 -8
- package/dist/src/components/hirer-signature/hirer-signature.repository.js +0 -67
- package/dist/src/components/hirer-signature/hirer-signature.repository.js.map +0 -1
- package/dist/src/enum/hirer-signature-status.enum.d.ts +0 -4
- package/dist/src/enum/hirer-signature-status.enum.js +0 -9
- package/dist/src/enum/hirer-signature-status.enum.js.map +0 -1
- package/dist/src/interfaces/hirer-signature-attr.interface.d.ts +0 -14
- package/dist/src/interfaces/hirer-signature-attr.interface.js.map +0 -1
- package/dist/src/models/hirer-signature.entity.d.ts +0 -16
- package/dist/src/models/hirer-signature.entity.js.map +0 -1
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.RentalHirerChangeRequest = void 0;
|
|
13
4
|
const general_1 = require("@tomei/general");
|
|
@@ -67,500 +58,470 @@ class RentalHirerChangeRequest extends general_1.ObjectBase {
|
|
|
67
58
|
UpdatedById: this.UpdatedById,
|
|
68
59
|
};
|
|
69
60
|
}
|
|
70
|
-
static init(requestId, dbTransaction) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return new RentalHirerChangeRequest(hirerChangeReq.get({ plain: true }));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg00', 'HirerChangeRequest not found');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return new RentalHirerChangeRequest();
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
console.error('Error initializing RentalHirerChangeRequest:', error);
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
checkForDuplicate(dbTransaction) {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
try {
|
|
93
|
-
if (!this.RentalId) {
|
|
94
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg08', 'RentalId is required to check for duplicate requests.');
|
|
95
|
-
}
|
|
96
|
-
const isDuplicate = yield RentalHirerChangeRequest._Repository.findAll({
|
|
97
|
-
where: {
|
|
98
|
-
RentalId: this.RentalId,
|
|
99
|
-
Type: this.Type,
|
|
100
|
-
Status: {
|
|
101
|
-
[sequelize_1.Op.notIn]: [
|
|
102
|
-
rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.COMPLETED,
|
|
103
|
-
rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.CANCELLED,
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
transaction: dbTransaction,
|
|
108
|
-
});
|
|
109
|
-
if (isDuplicate.length > 0) {
|
|
110
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg04', 'Duplicate record detected.');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
throw error;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
getSignatures(dbTransaction) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
try {
|
|
121
|
-
if (this.Signatures.length > 0) {
|
|
122
|
-
return this.Signatures;
|
|
123
|
-
}
|
|
124
|
-
const hirers = yield RentalHirerChangeRequest._HirerSignatureRepository.findAll({
|
|
125
|
-
where: {
|
|
126
|
-
RequestId: this.RequestId,
|
|
127
|
-
},
|
|
128
|
-
transaction: dbTransaction,
|
|
129
|
-
});
|
|
130
|
-
this.Signatures = yield Promise.all(hirers.map((hirer) => __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
return yield hirer_change_request_signature_1.HirerChangeRequestSignature.init(hirer.SignatureId, dbTransaction);
|
|
132
|
-
})));
|
|
133
|
-
return this.Signatures;
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
checkIsAllSigned(dbTransaction) {
|
|
141
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
try {
|
|
143
|
-
const listUpdatedHirer = yield this.getSignatures(dbTransaction);
|
|
144
|
-
if (listUpdatedHirer.length > 0) {
|
|
145
|
-
return listUpdatedHirer.every((record) => record.SignedAt !== null);
|
|
61
|
+
static async init(requestId, dbTransaction) {
|
|
62
|
+
try {
|
|
63
|
+
if (requestId) {
|
|
64
|
+
const hirerChangeReq = await RentalHirerChangeRequest._Repository.findByPk(requestId, dbTransaction);
|
|
65
|
+
if (hirerChangeReq) {
|
|
66
|
+
return new RentalHirerChangeRequest(hirerChangeReq.get({ plain: true }));
|
|
146
67
|
}
|
|
147
68
|
else {
|
|
148
|
-
|
|
69
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg00', 'HirerChangeRequest not found');
|
|
149
70
|
}
|
|
150
71
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
72
|
+
return new RentalHirerChangeRequest();
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.error('Error initializing RentalHirerChangeRequest:', error);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
155
78
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'HIRER_CHANGE_REQUEST');
|
|
161
|
-
if (!isPrivileged) {
|
|
162
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg01', "You do not have 'HIRER_CHANGE_REQUEST' privilege.");
|
|
163
|
-
}
|
|
164
|
-
if (!this.RentalId || !this.RequestingHirerId) {
|
|
165
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg02', 'RentalId and RequestingHirerId are required.');
|
|
166
|
-
}
|
|
167
|
-
const rental = yield rental_1.Rental.init(dbTransaction, this.RentalId);
|
|
168
|
-
if (rental.AccountType !== enum_1.RentalAccountTypeEnum.JOINT) {
|
|
169
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg03', 'Only Rental with Joint Account Type Allowed.');
|
|
170
|
-
}
|
|
171
|
-
const jointHirers = yield rental.getJointHirers(dbTransaction);
|
|
172
|
-
if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD) {
|
|
173
|
-
const maxJointHirer = config_1.ComponentConfig.getComponentConfigValue('@tomei/rental', 'maxJointHirerLength');
|
|
174
|
-
if ((jointHirers === null || jointHirers === void 0 ? void 0 : jointHirers.length) >= maxJointHirer) {
|
|
175
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg05', 'Joint Hirer exceed max joint hirer length.');
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (this.Type == rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.REMOVE &&
|
|
179
|
-
(jointHirers === null || jointHirers === void 0 ? void 0 : jointHirers.length) <= 1) {
|
|
180
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg05', 'Cannot remove the last joint hirer.');
|
|
181
|
-
}
|
|
182
|
-
yield this.checkForDuplicate(dbTransaction);
|
|
183
|
-
this.ObjectId = this.createId();
|
|
184
|
-
this.RequestedById = loginUser.ObjectId;
|
|
185
|
-
this.RequestedAt = new Date();
|
|
186
|
-
this.UpdatedById = loginUser.ObjectId;
|
|
187
|
-
this.UpdatedAt = new Date();
|
|
188
|
-
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.PENDINGSIGNATURES;
|
|
189
|
-
this.RequestingHirerType =
|
|
190
|
-
rental.CustomerId === this.RequestingHirerId
|
|
191
|
-
? enum_1.HirerChangeRequestHirerRoleEnum.MAIN
|
|
192
|
-
: enum_1.HirerChangeRequestHirerRoleEnum.JOINT;
|
|
193
|
-
const entityValueAfter = {
|
|
194
|
-
RequestId: this.RequestId,
|
|
195
|
-
RentalId: this.RentalId,
|
|
196
|
-
Type: this.Type,
|
|
197
|
-
Status: this.Status,
|
|
198
|
-
RequestedById: this.RequestedById,
|
|
199
|
-
RequestedAt: this.RequestedAt,
|
|
200
|
-
RequestingHirerId: this.RequestingHirerId,
|
|
201
|
-
RequestingHirerType: this.RequestingHirerType,
|
|
202
|
-
CancelRemarks: this.CancelRemarks,
|
|
203
|
-
UpdatedById: this.UpdatedById,
|
|
204
|
-
UpdatedAt: this.UpdatedAt,
|
|
205
|
-
};
|
|
206
|
-
yield RentalHirerChangeRequest._Repository.create(entityValueAfter, {
|
|
207
|
-
transaction: dbTransaction,
|
|
208
|
-
});
|
|
209
|
-
yield this.generateSignatures(loginUser, dbTransaction);
|
|
210
|
-
const activity = new activity_history_1.Activity();
|
|
211
|
-
activity.ObjectId = this._createId();
|
|
212
|
-
activity.Action = activity_history_1.ActionEnum.CREATE;
|
|
213
|
-
activity.Description =
|
|
214
|
-
this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD
|
|
215
|
-
? 'Add New Hirer'
|
|
216
|
-
: 'Remove Hirer';
|
|
217
|
-
activity.EntityId = this.ObjectId;
|
|
218
|
-
activity.EntityType = this.ObjectType;
|
|
219
|
-
activity.EntityValueBefore = JSON.stringify({});
|
|
220
|
-
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
221
|
-
yield activity.create(loginUser.ObjectId, dbTransaction);
|
|
222
|
-
return this;
|
|
79
|
+
async checkForDuplicate(dbTransaction) {
|
|
80
|
+
try {
|
|
81
|
+
if (!this.RentalId) {
|
|
82
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg08', 'RentalId is required to check for duplicate requests.');
|
|
223
83
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
update(loginUser, dbTransaction, params) {
|
|
230
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
-
try {
|
|
232
|
-
if (!this.RequestId) {
|
|
233
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg06', 'RequestId are required.');
|
|
234
|
-
}
|
|
235
|
-
const entityValueBefore = {
|
|
236
|
-
RequestId: this.RequestId,
|
|
84
|
+
const isDuplicate = await RentalHirerChangeRequest._Repository.findAll({
|
|
85
|
+
where: {
|
|
237
86
|
RentalId: this.RentalId,
|
|
238
87
|
Type: this.Type,
|
|
239
|
-
Status:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
CancelRemarks: this.CancelRemarks,
|
|
245
|
-
UpdatedById: this.UpdatedById,
|
|
246
|
-
UpdatedAt: this.UpdatedAt,
|
|
247
|
-
};
|
|
248
|
-
let { jointHirerId, customerId } = params;
|
|
249
|
-
if (!customerId && !jointHirerId) {
|
|
250
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg07', 'At least one of customerId or jointHirerId must be provided.');
|
|
251
|
-
}
|
|
252
|
-
const listHirer = yield this.getSignatures(dbTransaction);
|
|
253
|
-
if ((listHirer === null || listHirer === void 0 ? void 0 : listHirer.length) > 0) {
|
|
254
|
-
let foundHirer = listHirer === null || listHirer === void 0 ? void 0 : listHirer.find((record) => {
|
|
255
|
-
record.CustomerId === customerId;
|
|
256
|
-
});
|
|
257
|
-
let hirer = yield hirer_change_request_signature_1.HirerChangeRequestSignature.init(foundHirer.SignatureId, dbTransaction);
|
|
258
|
-
yield hirer.update(loginUser, dbTransaction);
|
|
259
|
-
}
|
|
260
|
-
const isSigned = yield this.checkIsAllSigned(dbTransaction);
|
|
261
|
-
if (isSigned) {
|
|
262
|
-
if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD) {
|
|
263
|
-
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.AWAITINGNEWHIRER;
|
|
264
|
-
}
|
|
265
|
-
else if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.REMOVE) {
|
|
266
|
-
yield RentalHirerChangeRequest._JointHirerRepository.update({ Status: 'Inactive' }, {
|
|
267
|
-
where: {
|
|
268
|
-
HirerId: this.RequestId,
|
|
269
|
-
},
|
|
270
|
-
transaction: dbTransaction,
|
|
271
|
-
});
|
|
272
|
-
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.COMPLETED;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const entityValueAfter = {
|
|
276
|
-
RequestId: this.RequestId,
|
|
277
|
-
RentalId: this.RentalId,
|
|
278
|
-
Type: this.Type,
|
|
279
|
-
Status: this.Status,
|
|
280
|
-
RequestedById: this.RequestedById,
|
|
281
|
-
RequestedAt: this.RequestedAt,
|
|
282
|
-
RequestingHirerId: this.RequestingHirerId,
|
|
283
|
-
RequestingHirerType: this.RequestingHirerType,
|
|
284
|
-
CancelRemarks: this.CancelRemarks,
|
|
285
|
-
UpdatedById: this.UpdatedById,
|
|
286
|
-
UpdatedAt: this.UpdatedAt,
|
|
287
|
-
};
|
|
288
|
-
yield RentalHirerChangeRequest._Repository.update(entityValueAfter, {
|
|
289
|
-
where: {
|
|
290
|
-
RequestId: this.RequestId,
|
|
88
|
+
Status: {
|
|
89
|
+
[sequelize_1.Op.notIn]: [
|
|
90
|
+
rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.COMPLETED,
|
|
91
|
+
rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.CANCELLED,
|
|
92
|
+
],
|
|
291
93
|
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
activity.Description = 'Update Hirer Change Request';
|
|
298
|
-
activity.EntityId = this.ObjectId;
|
|
299
|
-
activity.EntityType = this.ObjectType;
|
|
300
|
-
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
301
|
-
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
302
|
-
yield activity.create(loginUser.ObjectId, dbTransaction);
|
|
303
|
-
return this;
|
|
304
|
-
}
|
|
305
|
-
catch (error) {
|
|
306
|
-
throw error;
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
generateSignatures(loginUser, dbTransaction) {
|
|
311
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
312
|
-
try {
|
|
313
|
-
if (!this.RentalId) {
|
|
314
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg09', 'RentalId is required to create signatures.');
|
|
315
|
-
}
|
|
316
|
-
if (!this.Rental) {
|
|
317
|
-
this.Rental = yield rental_1.Rental.init(dbTransaction, this.RentalId);
|
|
318
|
-
}
|
|
319
|
-
const jointHirers = yield this.Rental.getJointHirers(dbTransaction);
|
|
320
|
-
const mainSignature = yield hirer_change_request_signature_1.HirerChangeRequestSignature.init();
|
|
321
|
-
mainSignature.RequestId = this.RequestId;
|
|
322
|
-
mainSignature.CustomerId = this.Rental.CustomerId;
|
|
323
|
-
mainSignature.HirerType = enum_1.HirerChangeRequestHirerRoleEnum.MAIN;
|
|
324
|
-
mainSignature.Method = 'Upload';
|
|
325
|
-
const jointSignaturePromises = jointHirers.map((jointHirer) => __awaiter(this, void 0, void 0, function* () {
|
|
326
|
-
const signature = yield hirer_change_request_signature_1.HirerChangeRequestSignature.init();
|
|
327
|
-
signature.RequestId = this.RequestId;
|
|
328
|
-
signature.JointHirerId = jointHirer.HirerId;
|
|
329
|
-
signature.HirerType = enum_1.HirerChangeRequestHirerRoleEnum.JOINT;
|
|
330
|
-
signature.Method = 'Upload';
|
|
331
|
-
return signature;
|
|
332
|
-
}));
|
|
333
|
-
const jointSignatures = yield Promise.all(jointSignaturePromises);
|
|
334
|
-
yield Promise.all([
|
|
335
|
-
mainSignature.create(loginUser, dbTransaction),
|
|
336
|
-
...jointSignatures.map((sig) => sig.create(loginUser, dbTransaction)),
|
|
337
|
-
]);
|
|
338
|
-
this.Signatures = [mainSignature, ...jointSignatures];
|
|
339
|
-
}
|
|
340
|
-
catch (error) {
|
|
341
|
-
console.error('Error creating signatures:', error);
|
|
342
|
-
throw error;
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
createAddRequest(newHirer, loginUser, dbTransaction) {
|
|
347
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
-
try {
|
|
349
|
-
if (!newHirer.FullName ||
|
|
350
|
-
!newHirer.IdNo ||
|
|
351
|
-
!newHirer.IdType ||
|
|
352
|
-
!newHirer.ContactNo ||
|
|
353
|
-
!newHirer.Address ||
|
|
354
|
-
!newHirer.City ||
|
|
355
|
-
!newHirer.State ||
|
|
356
|
-
!newHirer.Postcode ||
|
|
357
|
-
!newHirer.Country) {
|
|
358
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg10', 'FullName, IdNo, IdType, ContactNo, and Address are required.');
|
|
359
|
-
}
|
|
360
|
-
this.Type = rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD;
|
|
361
|
-
yield this.create(loginUser, dbTransaction);
|
|
362
|
-
const nh = yield hirer_change_request_new_hirer_1.HirerChangeRequestNewHirer.init();
|
|
363
|
-
nh.RequestId = this.RequestId;
|
|
364
|
-
nh.FullName = newHirer.FullName;
|
|
365
|
-
nh.Email = newHirer.Email;
|
|
366
|
-
nh.IdType = newHirer.IdType;
|
|
367
|
-
nh.IdNo = newHirer.IdNo;
|
|
368
|
-
nh.ContactNo = newHirer.ContactNo;
|
|
369
|
-
nh.Relationship = newHirer.Relationship;
|
|
370
|
-
nh.Address = newHirer.Address;
|
|
371
|
-
nh.City = newHirer.City;
|
|
372
|
-
nh.State = newHirer.State;
|
|
373
|
-
nh.Postcode = newHirer.Postcode;
|
|
374
|
-
nh.Country = newHirer.Country;
|
|
375
|
-
yield nh.create(loginUser, dbTransaction);
|
|
376
|
-
return {
|
|
377
|
-
hirerChangeRequest: this,
|
|
378
|
-
NewHirer: nh,
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
catch (error) {
|
|
382
|
-
console.error('Error creating add request:', error);
|
|
383
|
-
throw error;
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
createRemoveRequest(loginUser, dbTransaction, targetHirerId) {
|
|
388
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
389
|
-
try {
|
|
390
|
-
yield joint_hirer_1.JointHirer.init(targetHirerId, dbTransaction);
|
|
391
|
-
this.Type = rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.REMOVE;
|
|
392
|
-
yield this.create(loginUser, dbTransaction);
|
|
393
|
-
const removeHirer = yield hirer_change_request_remove_hirer_1.HirerChangeRequestRemoveHirer.init();
|
|
394
|
-
removeHirer.RequestId = this.RequestId;
|
|
395
|
-
removeHirer.TargetHirerId = targetHirerId;
|
|
396
|
-
yield removeHirer.create(loginUser, dbTransaction);
|
|
397
|
-
return {
|
|
398
|
-
hirerChangeRequest: this,
|
|
399
|
-
RemoveHirer: removeHirer,
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
catch (error) {
|
|
403
|
-
console.error('Error creating remove request:', error);
|
|
404
|
-
throw error;
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
static findAll(loginUser, dbTransaction, rentalId) {
|
|
409
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
410
|
-
try {
|
|
411
|
-
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
412
|
-
const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'HIRER_CHANGE_REQUEST');
|
|
413
|
-
if (!isPrivileged) {
|
|
414
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg01', "You do not have 'HIRER_CHANGE_REQUEST' privilege.");
|
|
415
|
-
}
|
|
416
|
-
if (!rentalId) {
|
|
417
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg12', 'rentalId is required.');
|
|
418
|
-
}
|
|
419
|
-
yield rental_1.Rental.init(dbTransaction, rentalId);
|
|
420
|
-
const records = yield RentalHirerChangeRequest._Repository.findAll({
|
|
421
|
-
where: { RentalId: rentalId },
|
|
422
|
-
transaction: dbTransaction,
|
|
423
|
-
});
|
|
424
|
-
const result = (records || []).map((rec) => new RentalHirerChangeRequest(rec.get({ plain: true })));
|
|
425
|
-
return result;
|
|
426
|
-
}
|
|
427
|
-
catch (error) {
|
|
428
|
-
console.error('Error finding all RentalHirerChangeRequest:', error);
|
|
429
|
-
throw error;
|
|
94
|
+
},
|
|
95
|
+
transaction: dbTransaction,
|
|
96
|
+
});
|
|
97
|
+
if (isDuplicate.length > 0) {
|
|
98
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg04', 'Duplicate record detected.');
|
|
430
99
|
}
|
|
431
|
-
}
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
432
104
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg13', 'RequestId is required to get new hirer.');
|
|
438
|
-
}
|
|
439
|
-
const newHirerRecords = yield hirer_change_request_new_hirer_1.HirerChangeRequestNewHirer.findAll({
|
|
440
|
-
RequestId: this.RequestId,
|
|
441
|
-
}, dbTransaction);
|
|
442
|
-
return newHirerRecords[0] || null;
|
|
443
|
-
}
|
|
444
|
-
catch (error) {
|
|
445
|
-
console.error('Error getting new hirer:', error);
|
|
446
|
-
throw error;
|
|
105
|
+
async getSignatures(dbTransaction) {
|
|
106
|
+
try {
|
|
107
|
+
if (this.Signatures.length > 0) {
|
|
108
|
+
return this.Signatures;
|
|
447
109
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
getRemoveHirer(dbTransaction) {
|
|
451
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
452
|
-
try {
|
|
453
|
-
if (!this.RequestId) {
|
|
454
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg13', 'RequestId is required to get remove hirer.');
|
|
455
|
-
}
|
|
456
|
-
const removeHirerRecords = yield hirer_change_request_remove_hirer_1.HirerChangeRequestRemoveHirer.findAll({
|
|
110
|
+
const hirers = await RentalHirerChangeRequest._HirerSignatureRepository.findAll({
|
|
111
|
+
where: {
|
|
457
112
|
RequestId: this.RequestId,
|
|
458
|
-
},
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
113
|
+
},
|
|
114
|
+
transaction: dbTransaction,
|
|
115
|
+
});
|
|
116
|
+
this.Signatures = await Promise.all(hirers.map(async (hirer) => {
|
|
117
|
+
return await hirer_change_request_signature_1.HirerChangeRequestSignature.init(hirer.SignatureId, dbTransaction);
|
|
118
|
+
}));
|
|
119
|
+
return this.Signatures;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
466
124
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
const hcrSignature = yield hirer_change_request_signature_1.HirerChangeRequestSignature.init(signatureId, dbTransaction);
|
|
474
|
-
yield hcrSignature.markSigned(loginUser, dbTransaction);
|
|
475
|
-
return hcrSignature;
|
|
125
|
+
async checkIsAllSigned(dbTransaction) {
|
|
126
|
+
try {
|
|
127
|
+
const listUpdatedHirer = await this.getSignatures(dbTransaction);
|
|
128
|
+
if (listUpdatedHirer.length > 0) {
|
|
129
|
+
return listUpdatedHirer.every((record) => record.SignedAt !== null);
|
|
476
130
|
}
|
|
477
|
-
|
|
478
|
-
|
|
131
|
+
else {
|
|
132
|
+
return false;
|
|
479
133
|
}
|
|
480
|
-
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
481
138
|
}
|
|
482
|
-
|
|
483
|
-
|
|
139
|
+
async create(loginUser, dbTransaction) {
|
|
140
|
+
try {
|
|
484
141
|
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
485
|
-
const isPrivileged =
|
|
142
|
+
const isPrivileged = await loginUser.checkPrivileges(systemCode, 'HIRER_CHANGE_REQUEST');
|
|
486
143
|
if (!isPrivileged) {
|
|
487
144
|
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg01', "You do not have 'HIRER_CHANGE_REQUEST' privilege.");
|
|
488
145
|
}
|
|
489
|
-
if (!this.
|
|
490
|
-
throw new general_1.ClassError('HirerChangeRequest', '
|
|
146
|
+
if (!this.RentalId || !this.RequestingHirerId) {
|
|
147
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg02', 'RentalId and RequestingHirerId are required.');
|
|
491
148
|
}
|
|
492
|
-
const
|
|
493
|
-
if (
|
|
494
|
-
throw new general_1.ClassError('HirerChangeRequest', '
|
|
149
|
+
const rental = await rental_1.Rental.init(dbTransaction, this.RentalId);
|
|
150
|
+
if (rental.AccountType !== enum_1.RentalAccountTypeEnum.JOINT) {
|
|
151
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg03', 'Only Rental with Joint Account Type Allowed.');
|
|
495
152
|
}
|
|
153
|
+
const jointHirers = await rental.getJointHirers(dbTransaction);
|
|
496
154
|
if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD) {
|
|
497
|
-
|
|
498
|
-
|
|
155
|
+
const maxJointHirer = config_1.ComponentConfig.getComponentConfigValue('@tomei/rental', 'maxJointHirerLength');
|
|
156
|
+
if ((jointHirers === null || jointHirers === void 0 ? void 0 : jointHirers.length) >= maxJointHirer) {
|
|
157
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg05', 'Joint Hirer exceed max joint hirer length.');
|
|
499
158
|
}
|
|
500
|
-
const jointHirer = yield joint_hirer_1.JointHirer.init();
|
|
501
|
-
jointHirer.RentalId = this.RentalId;
|
|
502
|
-
jointHirer.CustomerId = customerId;
|
|
503
|
-
jointHirer.CustomerType = customerType;
|
|
504
|
-
yield jointHirer.create(loginUser, dbTransaction);
|
|
505
159
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
yield jointHirer.remove(loginUser, dbTransaction);
|
|
160
|
+
if (this.Type == rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.REMOVE &&
|
|
161
|
+
(jointHirers === null || jointHirers === void 0 ? void 0 : jointHirers.length) <= 1) {
|
|
162
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg05', 'Cannot remove the last joint hirer.');
|
|
510
163
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
this.
|
|
514
|
-
this.
|
|
164
|
+
await this.checkForDuplicate(dbTransaction);
|
|
165
|
+
this.ObjectId = this.createId();
|
|
166
|
+
this.RequestedById = loginUser.ObjectId;
|
|
167
|
+
this.RequestedAt = new Date();
|
|
515
168
|
this.UpdatedById = loginUser.ObjectId;
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
169
|
+
this.UpdatedAt = new Date();
|
|
170
|
+
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.PENDINGSIGNATURES;
|
|
171
|
+
this.RequestingHirerType =
|
|
172
|
+
rental.CustomerId === this.RequestingHirerId
|
|
173
|
+
? enum_1.HirerChangeRequestHirerRoleEnum.MAIN
|
|
174
|
+
: enum_1.HirerChangeRequestHirerRoleEnum.JOINT;
|
|
175
|
+
const entityValueAfter = {
|
|
176
|
+
RequestId: this.RequestId,
|
|
177
|
+
RentalId: this.RentalId,
|
|
178
|
+
Type: this.Type,
|
|
179
|
+
Status: this.Status,
|
|
180
|
+
RequestedById: this.RequestedById,
|
|
181
|
+
RequestedAt: this.RequestedAt,
|
|
182
|
+
RequestingHirerId: this.RequestingHirerId,
|
|
183
|
+
RequestingHirerType: this.RequestingHirerType,
|
|
184
|
+
CancelRemarks: this.CancelRemarks,
|
|
185
|
+
UpdatedById: this.UpdatedById,
|
|
186
|
+
UpdatedAt: this.UpdatedAt,
|
|
187
|
+
};
|
|
188
|
+
await RentalHirerChangeRequest._Repository.create(entityValueAfter, {
|
|
519
189
|
transaction: dbTransaction,
|
|
520
190
|
});
|
|
191
|
+
await this.generateSignatures(loginUser, dbTransaction);
|
|
521
192
|
const activity = new activity_history_1.Activity();
|
|
522
193
|
activity.ObjectId = this._createId();
|
|
523
|
-
activity.Action = activity_history_1.ActionEnum.
|
|
524
|
-
activity.Description =
|
|
525
|
-
|
|
194
|
+
activity.Action = activity_history_1.ActionEnum.CREATE;
|
|
195
|
+
activity.Description =
|
|
196
|
+
this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD
|
|
197
|
+
? 'Add New Hirer'
|
|
198
|
+
: 'Remove Hirer';
|
|
199
|
+
activity.EntityId = this.ObjectId;
|
|
526
200
|
activity.EntityType = this.ObjectType;
|
|
527
|
-
activity.EntityValueBefore = JSON.stringify(
|
|
201
|
+
activity.EntityValueBefore = JSON.stringify({});
|
|
528
202
|
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
529
|
-
|
|
203
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
530
204
|
return this;
|
|
531
|
-
}
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
532
209
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
536
|
-
const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'HIRER_CHANGE_REQUEST');
|
|
537
|
-
if (!isPrivileged) {
|
|
538
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg01', "You do not have 'HIRER_CHANGE_REQUEST' privilege.");
|
|
539
|
-
}
|
|
210
|
+
async update(loginUser, dbTransaction, params) {
|
|
211
|
+
try {
|
|
540
212
|
if (!this.RequestId) {
|
|
541
|
-
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg06', 'RequestId
|
|
213
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg06', 'RequestId are required.');
|
|
214
|
+
}
|
|
215
|
+
const entityValueBefore = {
|
|
216
|
+
RequestId: this.RequestId,
|
|
217
|
+
RentalId: this.RentalId,
|
|
218
|
+
Type: this.Type,
|
|
219
|
+
Status: this.Status,
|
|
220
|
+
RequestedById: this.RequestedById,
|
|
221
|
+
RequestedAt: this.RequestedAt,
|
|
222
|
+
RequestingHirerId: this.RequestingHirerId,
|
|
223
|
+
RequestingHirerType: this.RequestingHirerType,
|
|
224
|
+
CancelRemarks: this.CancelRemarks,
|
|
225
|
+
UpdatedById: this.UpdatedById,
|
|
226
|
+
UpdatedAt: this.UpdatedAt,
|
|
227
|
+
};
|
|
228
|
+
let { jointHirerId, customerId } = params;
|
|
229
|
+
if (!customerId && !jointHirerId) {
|
|
230
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg07', 'At least one of customerId or jointHirerId must be provided.');
|
|
231
|
+
}
|
|
232
|
+
const listHirer = await this.getSignatures(dbTransaction);
|
|
233
|
+
if ((listHirer === null || listHirer === void 0 ? void 0 : listHirer.length) > 0) {
|
|
234
|
+
let foundHirer = listHirer === null || listHirer === void 0 ? void 0 : listHirer.find((record) => {
|
|
235
|
+
record.CustomerId === customerId;
|
|
236
|
+
});
|
|
237
|
+
let hirer = await hirer_change_request_signature_1.HirerChangeRequestSignature.init(foundHirer.SignatureId, dbTransaction);
|
|
238
|
+
await hirer.update(loginUser, dbTransaction);
|
|
542
239
|
}
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
240
|
+
const isSigned = await this.checkIsAllSigned(dbTransaction);
|
|
241
|
+
if (isSigned) {
|
|
242
|
+
if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD) {
|
|
243
|
+
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.AWAITINGNEWHIRER;
|
|
244
|
+
}
|
|
245
|
+
else if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.REMOVE) {
|
|
246
|
+
await RentalHirerChangeRequest._JointHirerRepository.update({ Status: 'Inactive' }, {
|
|
247
|
+
where: {
|
|
248
|
+
HirerId: this.RequestId,
|
|
249
|
+
},
|
|
250
|
+
transaction: dbTransaction,
|
|
251
|
+
});
|
|
252
|
+
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.COMPLETED;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const entityValueAfter = {
|
|
256
|
+
RequestId: this.RequestId,
|
|
257
|
+
RentalId: this.RentalId,
|
|
258
|
+
Type: this.Type,
|
|
259
|
+
Status: this.Status,
|
|
260
|
+
RequestedById: this.RequestedById,
|
|
261
|
+
RequestedAt: this.RequestedAt,
|
|
262
|
+
RequestingHirerId: this.RequestingHirerId,
|
|
263
|
+
RequestingHirerType: this.RequestingHirerType,
|
|
264
|
+
CancelRemarks: this.CancelRemarks,
|
|
265
|
+
UpdatedById: this.UpdatedById,
|
|
266
|
+
UpdatedAt: this.UpdatedAt,
|
|
267
|
+
};
|
|
268
|
+
await RentalHirerChangeRequest._Repository.update(entityValueAfter, {
|
|
269
|
+
where: {
|
|
270
|
+
RequestId: this.RequestId,
|
|
271
|
+
},
|
|
551
272
|
transaction: dbTransaction,
|
|
552
273
|
});
|
|
553
274
|
const activity = new activity_history_1.Activity();
|
|
554
275
|
activity.ObjectId = this._createId();
|
|
555
276
|
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
556
|
-
activity.Description =
|
|
557
|
-
activity.EntityId = this.
|
|
277
|
+
activity.Description = 'Update Hirer Change Request';
|
|
278
|
+
activity.EntityId = this.ObjectId;
|
|
558
279
|
activity.EntityType = this.ObjectType;
|
|
559
280
|
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
560
281
|
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
561
|
-
|
|
282
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
562
283
|
return this;
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async generateSignatures(loginUser, dbTransaction) {
|
|
290
|
+
try {
|
|
291
|
+
if (!this.RentalId) {
|
|
292
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg09', 'RentalId is required to create signatures.');
|
|
293
|
+
}
|
|
294
|
+
if (!this.Rental) {
|
|
295
|
+
this.Rental = await rental_1.Rental.init(dbTransaction, this.RentalId);
|
|
296
|
+
}
|
|
297
|
+
const jointHirers = await this.Rental.getJointHirers(dbTransaction);
|
|
298
|
+
const mainSignature = await hirer_change_request_signature_1.HirerChangeRequestSignature.init();
|
|
299
|
+
mainSignature.RequestId = this.RequestId;
|
|
300
|
+
mainSignature.CustomerId = this.Rental.CustomerId;
|
|
301
|
+
mainSignature.HirerType = enum_1.HirerChangeRequestHirerRoleEnum.MAIN;
|
|
302
|
+
mainSignature.Method = 'Upload';
|
|
303
|
+
const jointSignaturePromises = jointHirers.map(async (jointHirer) => {
|
|
304
|
+
const signature = await hirer_change_request_signature_1.HirerChangeRequestSignature.init();
|
|
305
|
+
signature.RequestId = this.RequestId;
|
|
306
|
+
signature.JointHirerId = jointHirer.HirerId;
|
|
307
|
+
signature.HirerType = enum_1.HirerChangeRequestHirerRoleEnum.JOINT;
|
|
308
|
+
signature.Method = 'Upload';
|
|
309
|
+
return signature;
|
|
310
|
+
});
|
|
311
|
+
const jointSignatures = await Promise.all(jointSignaturePromises);
|
|
312
|
+
await Promise.all([
|
|
313
|
+
mainSignature.create(loginUser, dbTransaction),
|
|
314
|
+
...jointSignatures.map((sig) => sig.create(loginUser, dbTransaction)),
|
|
315
|
+
]);
|
|
316
|
+
this.Signatures = [mainSignature, ...jointSignatures];
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
console.error('Error creating signatures:', error);
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
async createAddRequest(newHirer, loginUser, dbTransaction) {
|
|
324
|
+
try {
|
|
325
|
+
if (!newHirer.FullName ||
|
|
326
|
+
!newHirer.IdNo ||
|
|
327
|
+
!newHirer.IdType ||
|
|
328
|
+
!newHirer.ContactNo ||
|
|
329
|
+
!newHirer.Address ||
|
|
330
|
+
!newHirer.City ||
|
|
331
|
+
!newHirer.State ||
|
|
332
|
+
!newHirer.Postcode ||
|
|
333
|
+
!newHirer.Country) {
|
|
334
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg10', 'FullName, IdNo, IdType, ContactNo, and Address are required.');
|
|
335
|
+
}
|
|
336
|
+
this.Type = rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD;
|
|
337
|
+
await this.create(loginUser, dbTransaction);
|
|
338
|
+
const nh = await hirer_change_request_new_hirer_1.HirerChangeRequestNewHirer.init();
|
|
339
|
+
nh.RequestId = this.RequestId;
|
|
340
|
+
nh.FullName = newHirer.FullName;
|
|
341
|
+
nh.Email = newHirer.Email;
|
|
342
|
+
nh.IdType = newHirer.IdType;
|
|
343
|
+
nh.IdNo = newHirer.IdNo;
|
|
344
|
+
nh.ContactNo = newHirer.ContactNo;
|
|
345
|
+
nh.Relationship = newHirer.Relationship;
|
|
346
|
+
nh.Address = newHirer.Address;
|
|
347
|
+
nh.City = newHirer.City;
|
|
348
|
+
nh.State = newHirer.State;
|
|
349
|
+
nh.Postcode = newHirer.Postcode;
|
|
350
|
+
nh.Country = newHirer.Country;
|
|
351
|
+
await nh.create(loginUser, dbTransaction);
|
|
352
|
+
return {
|
|
353
|
+
hirerChangeRequest: this,
|
|
354
|
+
NewHirer: nh,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
console.error('Error creating add request:', error);
|
|
359
|
+
throw error;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
async createRemoveRequest(loginUser, dbTransaction, targetHirerId) {
|
|
363
|
+
try {
|
|
364
|
+
await joint_hirer_1.JointHirer.init(targetHirerId, dbTransaction);
|
|
365
|
+
this.Type = rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.REMOVE;
|
|
366
|
+
await this.create(loginUser, dbTransaction);
|
|
367
|
+
const removeHirer = await hirer_change_request_remove_hirer_1.HirerChangeRequestRemoveHirer.init();
|
|
368
|
+
removeHirer.RequestId = this.RequestId;
|
|
369
|
+
removeHirer.TargetHirerId = targetHirerId;
|
|
370
|
+
await removeHirer.create(loginUser, dbTransaction);
|
|
371
|
+
return {
|
|
372
|
+
hirerChangeRequest: this,
|
|
373
|
+
RemoveHirer: removeHirer,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
console.error('Error creating remove request:', error);
|
|
378
|
+
throw error;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
static async findAll(loginUser, dbTransaction, rentalId) {
|
|
382
|
+
try {
|
|
383
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
384
|
+
const isPrivileged = await loginUser.checkPrivileges(systemCode, 'HIRER_CHANGE_REQUEST');
|
|
385
|
+
if (!isPrivileged) {
|
|
386
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg01', "You do not have 'HIRER_CHANGE_REQUEST' privilege.");
|
|
387
|
+
}
|
|
388
|
+
if (!rentalId) {
|
|
389
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg12', 'rentalId is required.');
|
|
390
|
+
}
|
|
391
|
+
await rental_1.Rental.init(dbTransaction, rentalId);
|
|
392
|
+
const records = await RentalHirerChangeRequest._Repository.findAll({
|
|
393
|
+
where: { RentalId: rentalId },
|
|
394
|
+
transaction: dbTransaction,
|
|
395
|
+
});
|
|
396
|
+
const result = (records || []).map((rec) => new RentalHirerChangeRequest(rec.get({ plain: true })));
|
|
397
|
+
return result;
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
console.error('Error finding all RentalHirerChangeRequest:', error);
|
|
401
|
+
throw error;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
async getNewHirer(dbTransaction) {
|
|
405
|
+
try {
|
|
406
|
+
if (!this.RequestId) {
|
|
407
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg13', 'RequestId is required to get new hirer.');
|
|
408
|
+
}
|
|
409
|
+
const newHirerRecords = await hirer_change_request_new_hirer_1.HirerChangeRequestNewHirer.findAll({
|
|
410
|
+
RequestId: this.RequestId,
|
|
411
|
+
}, dbTransaction);
|
|
412
|
+
return newHirerRecords[0] || null;
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
console.error('Error getting new hirer:', error);
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
async getRemoveHirer(dbTransaction) {
|
|
420
|
+
try {
|
|
421
|
+
if (!this.RequestId) {
|
|
422
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg13', 'RequestId is required to get remove hirer.');
|
|
423
|
+
}
|
|
424
|
+
const removeHirerRecords = await hirer_change_request_remove_hirer_1.HirerChangeRequestRemoveHirer.findAll({
|
|
425
|
+
RequestId: this.RequestId,
|
|
426
|
+
}, dbTransaction);
|
|
427
|
+
return removeHirerRecords[0] || null;
|
|
428
|
+
}
|
|
429
|
+
catch (error) {
|
|
430
|
+
console.error('Error getting remove hirer:', error);
|
|
431
|
+
throw error;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
async sign(loginUser, dbTransaction, signatureId) {
|
|
435
|
+
try {
|
|
436
|
+
if (!this.RequestId) {
|
|
437
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg13', 'RequestId is required to sign signature.');
|
|
438
|
+
}
|
|
439
|
+
const hcrSignature = await hirer_change_request_signature_1.HirerChangeRequestSignature.init(signatureId, dbTransaction);
|
|
440
|
+
await hcrSignature.markSigned(loginUser, dbTransaction);
|
|
441
|
+
return hcrSignature;
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
throw error;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
async complete(loginUser, dbTransaction, customerId, customerType) {
|
|
448
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
449
|
+
const isPrivileged = await loginUser.checkPrivileges(systemCode, 'HIRER_CHANGE_REQUEST');
|
|
450
|
+
if (!isPrivileged) {
|
|
451
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg01', "You do not have 'HIRER_CHANGE_REQUEST' privilege.");
|
|
452
|
+
}
|
|
453
|
+
if (!this.RequestId) {
|
|
454
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg06', 'RequestId is required.');
|
|
455
|
+
}
|
|
456
|
+
const signatures = await this.getSignatures(dbTransaction);
|
|
457
|
+
if (!signatures.length || !signatures.every((sig) => sig.SignedAt)) {
|
|
458
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg14', 'All signatures must be signed before completing the request.');
|
|
459
|
+
}
|
|
460
|
+
if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.ADD) {
|
|
461
|
+
if (!customerId || !customerType) {
|
|
462
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg15', 'CustomerId and CustomerType are required for new hirer.');
|
|
463
|
+
}
|
|
464
|
+
const jointHirer = await joint_hirer_1.JointHirer.init();
|
|
465
|
+
jointHirer.RentalId = this.RentalId;
|
|
466
|
+
jointHirer.CustomerId = customerId;
|
|
467
|
+
jointHirer.CustomerType = customerType;
|
|
468
|
+
await jointHirer.create(loginUser, dbTransaction);
|
|
469
|
+
}
|
|
470
|
+
else if (this.Type === rental_hirer_change_request_type_1.HirerChangeRequestTypeEnum.REMOVE) {
|
|
471
|
+
const removeHirer = await this.getRemoveHirer(dbTransaction);
|
|
472
|
+
const jointHirer = await joint_hirer_1.JointHirer.init(removeHirer.TargetHirerId, dbTransaction);
|
|
473
|
+
await jointHirer.remove(loginUser, dbTransaction);
|
|
474
|
+
}
|
|
475
|
+
const now = new Date();
|
|
476
|
+
const entityValueBefore = this.toJSON();
|
|
477
|
+
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.COMPLETED;
|
|
478
|
+
this.UpdatedAt = new Date();
|
|
479
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
480
|
+
const entityValueAfter = this.toJSON();
|
|
481
|
+
await RentalHirerChangeRequest._Repository.update(entityValueAfter, {
|
|
482
|
+
where: { RequestId: this.RequestId },
|
|
483
|
+
transaction: dbTransaction,
|
|
484
|
+
});
|
|
485
|
+
const activity = new activity_history_1.Activity();
|
|
486
|
+
activity.ObjectId = this._createId();
|
|
487
|
+
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
488
|
+
activity.Description = `Mark request as completed.`;
|
|
489
|
+
activity.EntityId = this.RequestId;
|
|
490
|
+
activity.EntityType = this.ObjectType;
|
|
491
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
492
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
493
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
494
|
+
return this;
|
|
495
|
+
}
|
|
496
|
+
async cancel(loginUser, dbTransaction, cancelRemarks) {
|
|
497
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
498
|
+
const isPrivileged = await loginUser.checkPrivileges(systemCode, 'HIRER_CHANGE_REQUEST');
|
|
499
|
+
if (!isPrivileged) {
|
|
500
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg01', "You do not have 'HIRER_CHANGE_REQUEST' privilege.");
|
|
501
|
+
}
|
|
502
|
+
if (!this.RequestId) {
|
|
503
|
+
throw new general_1.ClassError('HirerChangeRequest', 'HirerChangeRequestErrMsg06', 'RequestId is required.');
|
|
504
|
+
}
|
|
505
|
+
const entityValueBefore = this.toJSON();
|
|
506
|
+
this.Status = rental_hirer_change_request_status_1.HirerChangeRequestStatusEnum.CANCELLED;
|
|
507
|
+
this.CancelRemarks = cancelRemarks;
|
|
508
|
+
this.UpdatedAt = new Date();
|
|
509
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
510
|
+
const entityValueAfter = this.toJSON();
|
|
511
|
+
await RentalHirerChangeRequest._Repository.update(entityValueAfter, {
|
|
512
|
+
where: { RequestId: this.RequestId },
|
|
513
|
+
transaction: dbTransaction,
|
|
563
514
|
});
|
|
515
|
+
const activity = new activity_history_1.Activity();
|
|
516
|
+
activity.ObjectId = this._createId();
|
|
517
|
+
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
518
|
+
activity.Description = `Cancel hirer change request.`;
|
|
519
|
+
activity.EntityId = this.RequestId;
|
|
520
|
+
activity.EntityType = this.ObjectType;
|
|
521
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
522
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
523
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
524
|
+
return this;
|
|
564
525
|
}
|
|
565
526
|
}
|
|
566
527
|
exports.RentalHirerChangeRequest = RentalHirerChangeRequest;
|