@tomei/rental 0.17.3-dev.4 → 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 -456
- 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 -918
- 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.Rental = void 0;
|
|
13
4
|
const rental_status_enum_1 = require("../../enum/rental-status.enum");
|
|
@@ -84,265 +75,257 @@ class Rental extends general_1.ObjectBase {
|
|
|
84
75
|
this._UpdatedAt = rentalAttr.UpdatedAt;
|
|
85
76
|
}
|
|
86
77
|
}
|
|
87
|
-
static init(dbTransaction, rentalId) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return new Rental(rental);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg00', 'Rental Not Found');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return new Rental();
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg00', 'Failed To Initialize Price');
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
create(rentalPrice, loginUser, jointHirers, dbTransaction) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
try {
|
|
109
|
-
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
110
|
-
const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'Rental - Create');
|
|
111
|
-
if (!isPrivileged) {
|
|
112
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - Create' privilege.");
|
|
113
|
-
}
|
|
114
|
-
const isItemAvailable = yield Rental.isItemAvailable(this.ItemId, this.ItemType, this.StartDateTime, this.EndDateTime, dbTransaction);
|
|
115
|
-
if (!isItemAvailable) {
|
|
116
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg02', 'Rental Item is not available at current date.');
|
|
117
|
-
}
|
|
118
|
-
yield Rental._AgreementRepo.create({
|
|
119
|
-
AgreementNo: this.AgreementNo,
|
|
120
|
-
Status: 'Not Generated',
|
|
121
|
-
}, {
|
|
122
|
-
transaction: dbTransaction,
|
|
123
|
-
});
|
|
124
|
-
yield Rental._AgreementSignatureRepo.create({
|
|
125
|
-
SignatureId: this.createId(),
|
|
126
|
-
AgreementNo: this.AgreementNo,
|
|
127
|
-
Party: hirer_type_enum_1.HirerTypeEnum.PRIMARY,
|
|
128
|
-
PartyId: this.CustomerId,
|
|
129
|
-
PartyType: 'Customer',
|
|
130
|
-
SignatureStatus: agreement_signature_status_enum_1.AgreementSignatureStatusEnum.PENDING,
|
|
131
|
-
SignedAt: new Date(),
|
|
132
|
-
CreatedById: loginUser.ObjectId,
|
|
133
|
-
CreatedAt: new Date(),
|
|
134
|
-
UpdatedById: loginUser.ObjectId,
|
|
135
|
-
UpdatedAt: new Date(),
|
|
136
|
-
}, { transaction: dbTransaction });
|
|
137
|
-
if (jointHirers && jointHirers.length > 0) {
|
|
138
|
-
for (const jointHirer of jointHirers) {
|
|
139
|
-
yield Rental._AgreementSignatureRepo.create({
|
|
140
|
-
SignatureId: this.createId(),
|
|
141
|
-
AgreementNo: this.AgreementNo,
|
|
142
|
-
Party: hirer_type_enum_1.HirerTypeEnum.JOINT,
|
|
143
|
-
PartyId: jointHirer.CustomerId,
|
|
144
|
-
PartyType: 'Customer',
|
|
145
|
-
SignatureStatus: agreement_signature_status_enum_1.AgreementSignatureStatusEnum.PENDING,
|
|
146
|
-
SignedAt: new Date(),
|
|
147
|
-
CreatedById: loginUser.ObjectId,
|
|
148
|
-
CreatedAt: new Date(),
|
|
149
|
-
UpdatedById: loginUser.ObjectId,
|
|
150
|
-
UpdatedAt: new Date(),
|
|
151
|
-
}, { transaction: dbTransaction });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (!rentalPrice.PriceId) {
|
|
155
|
-
const rentalPriceData = yield rentalPrice.create(loginUser, dbTransaction);
|
|
156
|
-
this.PriceId = rentalPriceData.PriceId;
|
|
78
|
+
static async init(dbTransaction, rentalId) {
|
|
79
|
+
try {
|
|
80
|
+
if (rentalId) {
|
|
81
|
+
const rental = await Rental._Repo.findByPk(rentalId, dbTransaction);
|
|
82
|
+
if (rental) {
|
|
83
|
+
return new Rental(rental);
|
|
157
84
|
}
|
|
158
85
|
else {
|
|
159
|
-
|
|
86
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg00', 'Rental Not Found');
|
|
160
87
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
88
|
+
}
|
|
89
|
+
return new Rental();
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg00', 'Failed To Initialize Price');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async create(rentalPrice, loginUser, jointHirers, dbTransaction) {
|
|
96
|
+
try {
|
|
97
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
98
|
+
const isPrivileged = await loginUser.checkPrivileges(systemCode, 'Rental - Create');
|
|
99
|
+
if (!isPrivileged) {
|
|
100
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - Create' privilege.");
|
|
101
|
+
}
|
|
102
|
+
const isItemAvailable = await Rental.isItemAvailable(this.ItemId, this.ItemType, this.StartDateTime, this.EndDateTime, dbTransaction);
|
|
103
|
+
if (!isItemAvailable) {
|
|
104
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg02', 'Rental Item is not available at current date.');
|
|
105
|
+
}
|
|
106
|
+
await Rental._AgreementRepo.create({
|
|
107
|
+
AgreementNo: this.AgreementNo,
|
|
108
|
+
Status: 'Not Generated',
|
|
109
|
+
}, {
|
|
110
|
+
transaction: dbTransaction,
|
|
111
|
+
});
|
|
112
|
+
await Rental._AgreementSignatureRepo.create({
|
|
113
|
+
SignatureId: this.createId(),
|
|
114
|
+
AgreementNo: this.AgreementNo,
|
|
115
|
+
Party: hirer_type_enum_1.HirerTypeEnum.PRIMARY,
|
|
116
|
+
PartyId: this.CustomerId,
|
|
117
|
+
PartyType: 'Customer',
|
|
118
|
+
SignatureStatus: agreement_signature_status_enum_1.AgreementSignatureStatusEnum.PENDING,
|
|
119
|
+
SignedAt: new Date(),
|
|
120
|
+
CreatedById: loginUser.ObjectId,
|
|
121
|
+
CreatedAt: new Date(),
|
|
122
|
+
UpdatedById: loginUser.ObjectId,
|
|
123
|
+
UpdatedAt: new Date(),
|
|
124
|
+
}, { transaction: dbTransaction });
|
|
125
|
+
if (jointHirers && jointHirers.length > 0) {
|
|
126
|
+
for (const jointHirer of jointHirers) {
|
|
127
|
+
await Rental._AgreementSignatureRepo.create({
|
|
128
|
+
SignatureId: this.createId(),
|
|
129
|
+
AgreementNo: this.AgreementNo,
|
|
130
|
+
Party: hirer_type_enum_1.HirerTypeEnum.JOINT,
|
|
131
|
+
PartyId: jointHirer.CustomerId,
|
|
132
|
+
PartyType: 'Customer',
|
|
133
|
+
SignatureStatus: agreement_signature_status_enum_1.AgreementSignatureStatusEnum.PENDING,
|
|
134
|
+
SignedAt: new Date(),
|
|
135
|
+
CreatedById: loginUser.ObjectId,
|
|
136
|
+
CreatedAt: new Date(),
|
|
137
|
+
UpdatedById: loginUser.ObjectId,
|
|
138
|
+
UpdatedAt: new Date(),
|
|
139
|
+
}, { transaction: dbTransaction });
|
|
196
140
|
}
|
|
197
|
-
const activity = new activity_history_1.Activity();
|
|
198
|
-
activity.ActivityId = activity.createId();
|
|
199
|
-
activity.Action = activity_history_1.ActionEnum.CREATE;
|
|
200
|
-
activity.Description = 'Add Rental';
|
|
201
|
-
activity.EntityType = 'Rental';
|
|
202
|
-
activity.EntityId = this.RentalId;
|
|
203
|
-
activity.EntityValueBefore = JSON.stringify({});
|
|
204
|
-
activity.EntityValueAfter = JSON.stringify(data);
|
|
205
|
-
yield activity.create(loginUser.ObjectId, dbTransaction);
|
|
206
|
-
return this;
|
|
207
141
|
}
|
|
208
|
-
|
|
209
|
-
|
|
142
|
+
if (!rentalPrice.PriceId) {
|
|
143
|
+
const rentalPriceData = await rentalPrice.create(loginUser, dbTransaction);
|
|
144
|
+
this.PriceId = rentalPriceData.PriceId;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this.PriceId = rentalPrice.PriceId;
|
|
148
|
+
}
|
|
149
|
+
this.RentalId = this.createId();
|
|
150
|
+
this._Status = rental_status_enum_1.RentalStatusEnum.PENDING_SIGNING;
|
|
151
|
+
this._CreatedById = loginUser.ObjectId;
|
|
152
|
+
this._UpdatedById = loginUser.ObjectId;
|
|
153
|
+
this._CreatedAt = new Date();
|
|
154
|
+
this._UpdatedAt = new Date();
|
|
155
|
+
const data = {
|
|
156
|
+
RentalId: this.RentalId,
|
|
157
|
+
CustomerId: this.CustomerId,
|
|
158
|
+
CustomerType: this.CustomerType,
|
|
159
|
+
ItemId: this.ItemId,
|
|
160
|
+
ItemType: this.ItemType,
|
|
161
|
+
PriceId: this.PriceId,
|
|
162
|
+
StartDateTime: this.StartDateTime,
|
|
163
|
+
EndDateTime: this.EndDateTime,
|
|
164
|
+
CancelRemarks: this.CancelRemarks,
|
|
165
|
+
TerminateRemarks: this.TerminateRemarks,
|
|
166
|
+
AgreementNo: this.AgreementNo,
|
|
167
|
+
AccountType: this.AccountType,
|
|
168
|
+
Status: this.Status,
|
|
169
|
+
EscheatmentYN: this.EscheatmentYN,
|
|
170
|
+
CreatedById: this.CreatedById,
|
|
171
|
+
CreatedAt: this.CreatedAt,
|
|
172
|
+
UpdatedById: this.UpdatedById,
|
|
173
|
+
UpdatedAt: this.UpdatedAt,
|
|
174
|
+
};
|
|
175
|
+
await Rental._Repo.create(data, {
|
|
176
|
+
transaction: dbTransaction,
|
|
177
|
+
});
|
|
178
|
+
if (jointHirers) {
|
|
179
|
+
for (let i = 0; i < jointHirers.length; i++) {
|
|
180
|
+
jointHirers[i].RentalId = this.RentalId;
|
|
181
|
+
await jointHirers[i].create(loginUser, dbTransaction);
|
|
182
|
+
this.JointHirers.push(jointHirers[i]);
|
|
183
|
+
}
|
|
210
184
|
}
|
|
211
|
-
|
|
185
|
+
const activity = new activity_history_1.Activity();
|
|
186
|
+
activity.ActivityId = activity.createId();
|
|
187
|
+
activity.Action = activity_history_1.ActionEnum.CREATE;
|
|
188
|
+
activity.Description = 'Add Rental';
|
|
189
|
+
activity.EntityType = 'Rental';
|
|
190
|
+
activity.EntityId = this.RentalId;
|
|
191
|
+
activity.EntityValueBefore = JSON.stringify({});
|
|
192
|
+
activity.EntityValueAfter = JSON.stringify(data);
|
|
193
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
212
199
|
}
|
|
213
|
-
static isItemAvailable(itemId, itemType, startDateTime, endDateTime, dbTransaction) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
[sequelize_1.Op.lte]: endDateTime,
|
|
222
|
-
},
|
|
223
|
-
EndDateTime: {
|
|
224
|
-
[sequelize_1.Op.gte]: startDateTime,
|
|
225
|
-
},
|
|
200
|
+
static async isItemAvailable(itemId, itemType, startDateTime, endDateTime, dbTransaction) {
|
|
201
|
+
try {
|
|
202
|
+
const rental = await Rental._Repo.findOne({
|
|
203
|
+
where: {
|
|
204
|
+
ItemId: itemId,
|
|
205
|
+
ItemType: itemType,
|
|
206
|
+
StartDateTime: {
|
|
207
|
+
[sequelize_1.Op.lte]: endDateTime,
|
|
226
208
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
return false;
|
|
209
|
+
EndDateTime: {
|
|
210
|
+
[sequelize_1.Op.gte]: startDateTime,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
transaction: dbTransaction,
|
|
214
|
+
});
|
|
215
|
+
if (!rental) {
|
|
216
|
+
return true;
|
|
237
217
|
}
|
|
238
|
-
|
|
239
|
-
|
|
218
|
+
if (rental.Status === rental_status_enum_1.RentalStatusEnum.TERMINATED ||
|
|
219
|
+
rental.Status === rental_status_enum_1.RentalStatusEnum.CANCELLED) {
|
|
220
|
+
return true;
|
|
240
221
|
}
|
|
241
|
-
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
242
227
|
}
|
|
243
|
-
static findAll(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const isPrivileged =
|
|
228
|
+
static async findAll(authContext, dbTransaction, page, row, search) {
|
|
229
|
+
var _a;
|
|
230
|
+
try {
|
|
231
|
+
const systemCode = await config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
232
|
+
if ('loginUser' in authContext) {
|
|
233
|
+
const isPrivileged = await authContext.loginUser.checkPrivileges(systemCode, 'Rental - View');
|
|
249
234
|
if (!isPrivileged) {
|
|
250
235
|
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - View' privilege.");
|
|
251
236
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
else if (key === 'EndDateTime') {
|
|
268
|
-
queryObj[key] = {
|
|
269
|
-
[sequelize_1.Op.lte]: value,
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
else if (key === 'CustomerId') {
|
|
273
|
-
queryObj[key] = {
|
|
274
|
-
[sequelize_1.Op.substring]: value,
|
|
275
|
-
};
|
|
276
|
-
options.include = [
|
|
277
|
-
{
|
|
278
|
-
model: joint_hirer_entity_1.JointHirerModel,
|
|
279
|
-
required: false,
|
|
280
|
-
where: {
|
|
281
|
-
CustomerId: {
|
|
282
|
-
[sequelize_1.Op.substring]: value,
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
];
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
queryObj[key] = {
|
|
290
|
-
[sequelize_1.Op.substring]: value,
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
if (((_a = options === null || options === void 0 ? void 0 : options.include) === null || _a === void 0 ? void 0 : _a.length) > 1) {
|
|
295
|
-
options.include.push({
|
|
296
|
-
model: models_1.AgreementModel,
|
|
297
|
-
required: false,
|
|
298
|
-
});
|
|
237
|
+
}
|
|
238
|
+
const queryObj = {};
|
|
239
|
+
let options = {
|
|
240
|
+
transaction: dbTransaction,
|
|
241
|
+
order: [['CreatedAt', 'DESC']],
|
|
242
|
+
};
|
|
243
|
+
if (page && row) {
|
|
244
|
+
options = Object.assign(Object.assign({}, options), { limit: row, offset: row * (page - 1) });
|
|
245
|
+
}
|
|
246
|
+
if (search) {
|
|
247
|
+
Object.entries(search).forEach(([key, value]) => {
|
|
248
|
+
if (key === 'StartDateTime') {
|
|
249
|
+
queryObj[key] = {
|
|
250
|
+
[sequelize_1.Op.gte]: value,
|
|
251
|
+
};
|
|
299
252
|
}
|
|
300
|
-
else {
|
|
253
|
+
else if (key === 'EndDateTime') {
|
|
254
|
+
queryObj[key] = {
|
|
255
|
+
[sequelize_1.Op.lte]: value,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
else if (key === 'CustomerId') {
|
|
259
|
+
queryObj[key] = {
|
|
260
|
+
[sequelize_1.Op.substring]: value,
|
|
261
|
+
};
|
|
301
262
|
options.include = [
|
|
302
263
|
{
|
|
303
|
-
model:
|
|
264
|
+
model: joint_hirer_entity_1.JointHirerModel,
|
|
304
265
|
required: false,
|
|
266
|
+
where: {
|
|
267
|
+
CustomerId: {
|
|
268
|
+
[sequelize_1.Op.substring]: value,
|
|
269
|
+
},
|
|
270
|
+
},
|
|
305
271
|
},
|
|
306
272
|
];
|
|
307
273
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
try {
|
|
320
|
-
const systemCode = yield config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
321
|
-
const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'Rental - View');
|
|
322
|
-
if (!isPrivileged) {
|
|
323
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - View' privilege.");
|
|
324
|
-
}
|
|
325
|
-
const queryObj = {
|
|
326
|
-
ItemId: itemId,
|
|
327
|
-
ItemType: itemType,
|
|
328
|
-
Status: rental_status_enum_1.RentalStatusEnum.ACTIVE,
|
|
329
|
-
};
|
|
330
|
-
const options = {
|
|
331
|
-
transaction: dbTransaction,
|
|
332
|
-
where: queryObj,
|
|
333
|
-
};
|
|
334
|
-
const rental = yield Rental._Repo.findOne(options);
|
|
335
|
-
if (rental) {
|
|
336
|
-
return true;
|
|
274
|
+
else {
|
|
275
|
+
queryObj[key] = {
|
|
276
|
+
[sequelize_1.Op.substring]: value,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
if (((_a = options === null || options === void 0 ? void 0 : options.include) === null || _a === void 0 ? void 0 : _a.length) > 1) {
|
|
281
|
+
options.include.push({
|
|
282
|
+
model: models_1.AgreementModel,
|
|
283
|
+
required: false,
|
|
284
|
+
});
|
|
337
285
|
}
|
|
338
286
|
else {
|
|
339
|
-
|
|
287
|
+
options.include = [
|
|
288
|
+
{
|
|
289
|
+
model: models_1.AgreementModel,
|
|
290
|
+
required: false,
|
|
291
|
+
},
|
|
292
|
+
];
|
|
340
293
|
}
|
|
294
|
+
options = Object.assign(Object.assign({}, options), { where: queryObj });
|
|
341
295
|
}
|
|
342
|
-
|
|
343
|
-
|
|
296
|
+
return await Rental._Repo.findAndCountAll(options);
|
|
297
|
+
}
|
|
298
|
+
catch (err) {
|
|
299
|
+
throw err;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
static async checkActiveByItemId(loginUser, itemId, itemType, dbTransaction) {
|
|
303
|
+
try {
|
|
304
|
+
const systemCode = await config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
305
|
+
const isPrivileged = await loginUser.checkPrivileges(systemCode, 'Rental - View');
|
|
306
|
+
if (!isPrivileged) {
|
|
307
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - View' privilege.");
|
|
344
308
|
}
|
|
345
|
-
|
|
309
|
+
const queryObj = {
|
|
310
|
+
ItemId: itemId,
|
|
311
|
+
ItemType: itemType,
|
|
312
|
+
Status: rental_status_enum_1.RentalStatusEnum.ACTIVE,
|
|
313
|
+
};
|
|
314
|
+
const options = {
|
|
315
|
+
transaction: dbTransaction,
|
|
316
|
+
where: queryObj,
|
|
317
|
+
};
|
|
318
|
+
const rental = await Rental._Repo.findOne(options);
|
|
319
|
+
if (rental) {
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
throw err;
|
|
328
|
+
}
|
|
346
329
|
}
|
|
347
330
|
setStartDateTime(startDateTime) {
|
|
348
331
|
const startDateTimeObject = new Date(startDateTime);
|
|
@@ -360,376 +343,364 @@ class Rental extends general_1.ObjectBase {
|
|
|
360
343
|
this._Status = rental_status_enum_1.RentalStatusEnum.ACTIVE;
|
|
361
344
|
}
|
|
362
345
|
}
|
|
363
|
-
periodEndProcess(loginUser, dbTransaction, stockInventory) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg04', "You do not have 'Rental - PeriodEndProcess' privilege.");
|
|
370
|
-
}
|
|
371
|
-
if (this.AgreementNo === undefined || this.AgreementNo === null) {
|
|
372
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg05', 'Rental must be existing rental.');
|
|
373
|
-
}
|
|
374
|
-
if (this.EndDateTime === new Date(new Date().setHours(0, 0, 0, 0))) {
|
|
375
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg06', 'Rental period is not ending today.');
|
|
376
|
-
}
|
|
377
|
-
yield stockInventory.setAvailable(loginUser, dbTransaction);
|
|
378
|
-
const entityValueBefore = {
|
|
379
|
-
RentalId: this.RentalId,
|
|
380
|
-
CustomerId: this.CustomerId,
|
|
381
|
-
CustomerType: this.CustomerType,
|
|
382
|
-
ItemId: this.ItemId,
|
|
383
|
-
ItemType: this.ItemType,
|
|
384
|
-
PriceId: this.PriceId,
|
|
385
|
-
StartDateTime: this.StartDateTime,
|
|
386
|
-
EndDateTime: this.EndDateTime,
|
|
387
|
-
CancelRemarks: this.CancelRemarks,
|
|
388
|
-
TerminateRemarks: this.TerminateRemarks,
|
|
389
|
-
AgreementNo: this.AgreementNo,
|
|
390
|
-
AccountType: this.AccountType,
|
|
391
|
-
Status: this.Status,
|
|
392
|
-
EscheatmentYN: this.EscheatmentYN,
|
|
393
|
-
CreatedById: this.CreatedById,
|
|
394
|
-
CreatedAt: this.CreatedAt,
|
|
395
|
-
UpdatedById: this.UpdatedById,
|
|
396
|
-
UpdatedAt: this.UpdatedAt,
|
|
397
|
-
};
|
|
398
|
-
this.setTerminated();
|
|
399
|
-
this._UpdatedById = loginUser.ObjectId;
|
|
400
|
-
this._UpdatedAt = new Date();
|
|
401
|
-
const entityValueAfter = {
|
|
402
|
-
RentalId: this.RentalId,
|
|
403
|
-
CustomerId: this.CustomerId,
|
|
404
|
-
CustomerType: this.CustomerType,
|
|
405
|
-
ItemId: this.ItemId,
|
|
406
|
-
ItemType: this.ItemType,
|
|
407
|
-
PriceId: this.PriceId,
|
|
408
|
-
StartDateTime: this.StartDateTime,
|
|
409
|
-
EndDateTime: this.EndDateTime,
|
|
410
|
-
CancelRemarks: this.CancelRemarks,
|
|
411
|
-
TerminateRemarks: this.TerminateRemarks,
|
|
412
|
-
AgreementNo: this.AgreementNo,
|
|
413
|
-
AccountType: this.AccountType,
|
|
414
|
-
Status: this.Status,
|
|
415
|
-
EscheatmentYN: this.EscheatmentYN,
|
|
416
|
-
CreatedById: this.CreatedById,
|
|
417
|
-
CreatedAt: this.CreatedAt,
|
|
418
|
-
UpdatedById: this.UpdatedById,
|
|
419
|
-
UpdatedAt: this.UpdatedAt,
|
|
420
|
-
};
|
|
421
|
-
const activity = new activity_history_1.Activity();
|
|
422
|
-
activity.ActivityId = activity.createId();
|
|
423
|
-
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
424
|
-
activity.Description = 'Set Rental as Terminated';
|
|
425
|
-
activity.EntityType = 'Rental';
|
|
426
|
-
activity.EntityId = this.RentalId;
|
|
427
|
-
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
428
|
-
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
429
|
-
yield activity.create(loginUser.ObjectId, dbTransaction);
|
|
430
|
-
return this;
|
|
346
|
+
async periodEndProcess(loginUser, dbTransaction, stockInventory) {
|
|
347
|
+
try {
|
|
348
|
+
const systemCode = await config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
349
|
+
const isPrivileged = await loginUser.checkPrivileges(systemCode, 'Rental – PeriodEndProcess');
|
|
350
|
+
if (!isPrivileged) {
|
|
351
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg04', "You do not have 'Rental - PeriodEndProcess' privilege.");
|
|
431
352
|
}
|
|
432
|
-
|
|
433
|
-
throw
|
|
353
|
+
if (this.AgreementNo === undefined || this.AgreementNo === null) {
|
|
354
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg05', 'Rental must be existing rental.');
|
|
434
355
|
}
|
|
435
|
-
|
|
356
|
+
if (this.EndDateTime === new Date(new Date().setHours(0, 0, 0, 0))) {
|
|
357
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg06', 'Rental period is not ending today.');
|
|
358
|
+
}
|
|
359
|
+
await stockInventory.setAvailable(loginUser, dbTransaction);
|
|
360
|
+
const entityValueBefore = {
|
|
361
|
+
RentalId: this.RentalId,
|
|
362
|
+
CustomerId: this.CustomerId,
|
|
363
|
+
CustomerType: this.CustomerType,
|
|
364
|
+
ItemId: this.ItemId,
|
|
365
|
+
ItemType: this.ItemType,
|
|
366
|
+
PriceId: this.PriceId,
|
|
367
|
+
StartDateTime: this.StartDateTime,
|
|
368
|
+
EndDateTime: this.EndDateTime,
|
|
369
|
+
CancelRemarks: this.CancelRemarks,
|
|
370
|
+
TerminateRemarks: this.TerminateRemarks,
|
|
371
|
+
AgreementNo: this.AgreementNo,
|
|
372
|
+
AccountType: this.AccountType,
|
|
373
|
+
Status: this.Status,
|
|
374
|
+
EscheatmentYN: this.EscheatmentYN,
|
|
375
|
+
CreatedById: this.CreatedById,
|
|
376
|
+
CreatedAt: this.CreatedAt,
|
|
377
|
+
UpdatedById: this.UpdatedById,
|
|
378
|
+
UpdatedAt: this.UpdatedAt,
|
|
379
|
+
};
|
|
380
|
+
this.setTerminated();
|
|
381
|
+
this._UpdatedById = loginUser.ObjectId;
|
|
382
|
+
this._UpdatedAt = new Date();
|
|
383
|
+
const entityValueAfter = {
|
|
384
|
+
RentalId: this.RentalId,
|
|
385
|
+
CustomerId: this.CustomerId,
|
|
386
|
+
CustomerType: this.CustomerType,
|
|
387
|
+
ItemId: this.ItemId,
|
|
388
|
+
ItemType: this.ItemType,
|
|
389
|
+
PriceId: this.PriceId,
|
|
390
|
+
StartDateTime: this.StartDateTime,
|
|
391
|
+
EndDateTime: this.EndDateTime,
|
|
392
|
+
CancelRemarks: this.CancelRemarks,
|
|
393
|
+
TerminateRemarks: this.TerminateRemarks,
|
|
394
|
+
AgreementNo: this.AgreementNo,
|
|
395
|
+
AccountType: this.AccountType,
|
|
396
|
+
Status: this.Status,
|
|
397
|
+
EscheatmentYN: this.EscheatmentYN,
|
|
398
|
+
CreatedById: this.CreatedById,
|
|
399
|
+
CreatedAt: this.CreatedAt,
|
|
400
|
+
UpdatedById: this.UpdatedById,
|
|
401
|
+
UpdatedAt: this.UpdatedAt,
|
|
402
|
+
};
|
|
403
|
+
const activity = new activity_history_1.Activity();
|
|
404
|
+
activity.ActivityId = activity.createId();
|
|
405
|
+
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
406
|
+
activity.Description = 'Set Rental as Terminated';
|
|
407
|
+
activity.EntityType = 'Rental';
|
|
408
|
+
activity.EntityId = this.RentalId;
|
|
409
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
410
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
411
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
412
|
+
return this;
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
throw err;
|
|
416
|
+
}
|
|
436
417
|
}
|
|
437
|
-
getCustomerActiveRentals(loginUser, dbTransaction, CustomerId) {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
r.RentalId
|
|
418
|
+
async getCustomerActiveRentals(loginUser, dbTransaction, CustomerId) {
|
|
419
|
+
try {
|
|
420
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
421
|
+
const isPrivileged = loginUser.checkPrivileges(systemCode, 'RENTAL_VIEW');
|
|
422
|
+
if (!isPrivileged) {
|
|
423
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - View' privilege.");
|
|
424
|
+
}
|
|
425
|
+
const query = `
|
|
426
|
+
SELECT
|
|
427
|
+
r.*
|
|
428
|
+
FROM
|
|
429
|
+
rental_Rental r
|
|
430
|
+
LEFT JOIN
|
|
431
|
+
rental_JointHirer jh ON r.RentalId = jh.RentalId
|
|
432
|
+
WHERE
|
|
433
|
+
r.Status = 'Active'
|
|
434
|
+
AND (
|
|
435
|
+
r.CustomerId = '${CustomerId}'
|
|
436
|
+
OR jh.CustomerId = '${CustomerId}'
|
|
437
|
+
)
|
|
438
|
+
GROUP BY
|
|
439
|
+
r.RentalId
|
|
460
440
|
`;
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
441
|
+
const db = rentalDb.getConnection();
|
|
442
|
+
const result = await db.query(query, {
|
|
443
|
+
type: sequelize_1.QueryTypes.SELECT,
|
|
444
|
+
transaction: dbTransaction,
|
|
445
|
+
model: rental_entity_1.RentalModel,
|
|
446
|
+
mapToModel: true,
|
|
447
|
+
});
|
|
448
|
+
const records = result.map((record) => {
|
|
449
|
+
return {
|
|
450
|
+
RentalId: record.RentalId,
|
|
451
|
+
CustomerId: record.CustomerId,
|
|
452
|
+
CustomerType: record.CustomerType,
|
|
453
|
+
ItemId: record.ItemId,
|
|
454
|
+
ItemType: record.ItemType,
|
|
455
|
+
PriceId: record.PriceId,
|
|
456
|
+
StartDateTime: record.StartDateTime,
|
|
457
|
+
EndDateTime: record.EndDateTime,
|
|
458
|
+
CancelRemarks: record.CancelRemarks,
|
|
459
|
+
TerminateRemarks: record.TerminateRemarks,
|
|
460
|
+
AgreementNo: record.AgreementNo,
|
|
461
|
+
AccountType: record.AccountType,
|
|
462
|
+
Status: record.Status,
|
|
463
|
+
EscheatmentYN: record.EscheatmentYN,
|
|
464
|
+
CreatedById: record.CreatedById,
|
|
465
|
+
CreatedAt: record.CreatedAt,
|
|
466
|
+
UpdatedById: record.UpdatedById,
|
|
467
|
+
UpdatedAt: record.UpdatedAt,
|
|
468
|
+
};
|
|
469
|
+
});
|
|
470
|
+
return records;
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
throw error;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
async getJointHirers(dbTransaction) {
|
|
477
|
+
try {
|
|
478
|
+
if (!this.RentalId) {
|
|
479
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', 'RentalId is missing');
|
|
491
480
|
}
|
|
492
|
-
|
|
493
|
-
throw
|
|
481
|
+
if (this.AccountType !== account_type_enum_1.RentalAccountTypeEnum.JOINT) {
|
|
482
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg07', 'This rental does not have joint hirers.');
|
|
494
483
|
}
|
|
495
|
-
|
|
484
|
+
const jointHirers = await Rental._JointHirerRepo.findAll({
|
|
485
|
+
where: {
|
|
486
|
+
RentalId: this.RentalId,
|
|
487
|
+
},
|
|
488
|
+
transaction: dbTransaction,
|
|
489
|
+
});
|
|
490
|
+
const jointHirerInstances = Promise.all(jointHirers.map(async (hirer) => {
|
|
491
|
+
return await joint_hirer_1.JointHirer.init(hirer.HirerId, dbTransaction);
|
|
492
|
+
}));
|
|
493
|
+
return jointHirerInstances;
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
console.error('Error in getJointHirers:', error);
|
|
497
|
+
throw error;
|
|
498
|
+
}
|
|
496
499
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
if (this.AccountType !== account_type_enum_1.RentalAccountTypeEnum.JOINT) {
|
|
504
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg07', 'This rental does not have joint hirers.');
|
|
505
|
-
}
|
|
506
|
-
const jointHirers = yield Rental._JointHirerRepo.findAll({
|
|
507
|
-
where: {
|
|
508
|
-
RentalId: this.RentalId,
|
|
509
|
-
},
|
|
510
|
-
transaction: dbTransaction,
|
|
511
|
-
});
|
|
512
|
-
const jointHirerInstances = Promise.all(jointHirers.map((hirer) => __awaiter(this, void 0, void 0, function* () {
|
|
513
|
-
return yield joint_hirer_1.JointHirer.init(hirer.HirerId, dbTransaction);
|
|
514
|
-
})));
|
|
515
|
-
return jointHirerInstances;
|
|
500
|
+
async getCustomerIds(loginUser, dbTransaction) {
|
|
501
|
+
try {
|
|
502
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
503
|
+
const isPrivileged = loginUser.checkPrivileges(systemCode, 'RENTAL_VIEW');
|
|
504
|
+
if (!isPrivileged) {
|
|
505
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - View' privilege.");
|
|
516
506
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
507
|
+
if (!this.RentalId) {
|
|
508
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', 'RentalId is missing');
|
|
509
|
+
}
|
|
510
|
+
const options = {
|
|
511
|
+
where: {
|
|
512
|
+
RentalId: this.RentalId,
|
|
513
|
+
},
|
|
514
|
+
transaction: dbTransaction,
|
|
515
|
+
};
|
|
516
|
+
const joinHirers = await Rental._JointHirerRepo.findAll(options);
|
|
517
|
+
const customerIds = [this.CustomerId];
|
|
518
|
+
for (let i = 0; i < joinHirers.length; i++) {
|
|
519
|
+
const jointHirer = joinHirers[i];
|
|
520
|
+
customerIds.push(jointHirer.CustomerId);
|
|
520
521
|
}
|
|
521
|
-
|
|
522
|
+
return customerIds;
|
|
523
|
+
}
|
|
524
|
+
catch (error) {
|
|
525
|
+
throw error;
|
|
526
|
+
}
|
|
522
527
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'Rental - View' privilege.");
|
|
530
|
-
}
|
|
531
|
-
if (!this.RentalId) {
|
|
532
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg01', 'RentalId is missing');
|
|
533
|
-
}
|
|
534
|
-
const options = {
|
|
535
|
-
where: {
|
|
536
|
-
RentalId: this.RentalId,
|
|
537
|
-
},
|
|
538
|
-
transaction: dbTransaction,
|
|
539
|
-
};
|
|
540
|
-
const joinHirers = yield Rental._JointHirerRepo.findAll(options);
|
|
541
|
-
const customerIds = [this.CustomerId];
|
|
542
|
-
for (let i = 0; i < joinHirers.length; i++) {
|
|
543
|
-
const jointHirer = joinHirers[i];
|
|
544
|
-
customerIds.push(jointHirer.CustomerId);
|
|
545
|
-
}
|
|
546
|
-
return customerIds;
|
|
528
|
+
async signAgreement(loginUser, party, PartyId, PartyType, dbTransaction, statusAfterSign) {
|
|
529
|
+
try {
|
|
530
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
531
|
+
const isPrivileged = loginUser.checkPrivileges(systemCode, 'RENTAL_SIGN');
|
|
532
|
+
if (!isPrivileged) {
|
|
533
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'RENTAL_SIGN' privilege.");
|
|
547
534
|
}
|
|
548
|
-
|
|
549
|
-
|
|
535
|
+
const agreement = await agreement_1.Agreement.init(this.AgreementNo, dbTransaction);
|
|
536
|
+
if (this.Status !== rental_status_enum_1.RentalStatusEnum.PENDING_SIGNING &&
|
|
537
|
+
agreement.Status !== aggrement_status_enum_1.AggrementStatusEnum.GENERATED) {
|
|
538
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', 'Rental is not ready to be signed yet.');
|
|
550
539
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
if (!isPrivileged) {
|
|
559
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'RENTAL_SIGN' privilege.");
|
|
560
|
-
}
|
|
561
|
-
const agreement = yield agreement_1.Agreement.init(this.AgreementNo, dbTransaction);
|
|
562
|
-
if (this.Status !== rental_status_enum_1.RentalStatusEnum.PENDING_SIGNING &&
|
|
563
|
-
agreement.Status !== aggrement_status_enum_1.AggrementStatusEnum.GENERATED) {
|
|
564
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg01', 'Rental is not ready to be signed yet.');
|
|
565
|
-
}
|
|
566
|
-
const signatureList = yield agreement_1.Agreement.getSignatureList(loginUser, this.AgreementNo, dbTransaction);
|
|
567
|
-
const customerSignature = signatureList.find((sig) => sig.PartyId === PartyId &&
|
|
568
|
-
sig.PartyType === PartyType &&
|
|
569
|
-
sig.Party === party &&
|
|
570
|
-
sig.SignatureStatus === agreement_signature_status_enum_1.AgreementSignatureStatusEnum.PENDING);
|
|
571
|
-
if (!customerSignature) {
|
|
572
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg01', 'Signature is not pending.');
|
|
573
|
-
}
|
|
574
|
-
const signaturePayload = {
|
|
575
|
-
SignatureStatus: agreement_signature_status_enum_1.AgreementSignatureStatusEnum.SIGNED,
|
|
576
|
-
SignedAt: new Date(),
|
|
577
|
-
UpdatedById: loginUser.ObjectId,
|
|
578
|
-
UpdatedAt: new Date(),
|
|
579
|
-
};
|
|
580
|
-
yield Rental._AgreementSignatureRepo.update(signaturePayload, {
|
|
581
|
-
where: {
|
|
582
|
-
AgreementNo: this.AgreementNo,
|
|
583
|
-
Party: party,
|
|
584
|
-
PartyId: PartyId,
|
|
585
|
-
PartyType: PartyType,
|
|
586
|
-
},
|
|
587
|
-
transaction: dbTransaction,
|
|
588
|
-
});
|
|
589
|
-
const signatureActivity = new activity_history_1.Activity();
|
|
590
|
-
signatureActivity.ActivityId = signatureActivity.createId();
|
|
591
|
-
signatureActivity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
592
|
-
signatureActivity.Description = 'Update hirer signature';
|
|
593
|
-
signatureActivity.EntityType = 'AgreementSignature';
|
|
594
|
-
signatureActivity.EntityId = this.AgreementNo;
|
|
595
|
-
signatureActivity.EntityValueBefore = JSON.stringify(customerSignature);
|
|
596
|
-
signatureActivity.EntityValueAfter = JSON.stringify(signaturePayload);
|
|
597
|
-
yield signatureActivity.create(loginUser.ObjectId, dbTransaction);
|
|
598
|
-
const updatedSignatureList = yield agreement_1.Agreement.getSignatureList(loginUser, this.AgreementNo, dbTransaction);
|
|
599
|
-
const pendingSignatures = updatedSignatureList.filter((sig) => sig.SignatureStatus === 'Pending');
|
|
600
|
-
if (pendingSignatures.length > 0) {
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
const entityValueAgreementBefore = {
|
|
604
|
-
AgreementNo: agreement.AgreementNo,
|
|
605
|
-
Status: agreement.Status,
|
|
606
|
-
DateSigned: agreement.DateSigned,
|
|
607
|
-
};
|
|
608
|
-
const payload = {
|
|
609
|
-
DateSigned: new Date(),
|
|
610
|
-
Status: aggrement_status_enum_1.AggrementStatusEnum.SIGNED,
|
|
611
|
-
};
|
|
612
|
-
yield Rental._AgreementRepo.update(payload, {
|
|
613
|
-
where: {
|
|
614
|
-
AgreementNo: this.AgreementNo,
|
|
615
|
-
},
|
|
616
|
-
transaction: dbTransaction,
|
|
617
|
-
});
|
|
618
|
-
const entityValueAgreementAfter = Object.assign({ entityValueAgreementBefore }, payload);
|
|
619
|
-
const activity = new activity_history_1.Activity();
|
|
620
|
-
activity.ActivityId = activity.createId();
|
|
621
|
-
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
622
|
-
activity.Description = 'Update agreement';
|
|
623
|
-
activity.EntityType = 'RentalAgreement';
|
|
624
|
-
activity.EntityId = this.AgreementNo;
|
|
625
|
-
activity.EntityValueBefore = JSON.stringify(entityValueAgreementBefore);
|
|
626
|
-
activity.EntityValueAfter = JSON.stringify(entityValueAgreementAfter);
|
|
627
|
-
yield activity.create(loginUser.ObjectId, dbTransaction);
|
|
628
|
-
const entityValueRentalBefore = {
|
|
629
|
-
RentalId: this.RentalId,
|
|
630
|
-
CustomerId: this.CustomerId,
|
|
631
|
-
CustomerType: this.CustomerType,
|
|
632
|
-
ItemId: this.ItemId,
|
|
633
|
-
ItemType: this.ItemType,
|
|
634
|
-
PriceId: this.PriceId,
|
|
635
|
-
StartDateTime: this.StartDateTime,
|
|
636
|
-
EndDateTime: this.EndDateTime,
|
|
637
|
-
CancelRemarks: this.CancelRemarks,
|
|
638
|
-
TerminateRemarks: this.TerminateRemarks,
|
|
639
|
-
AgreementNo: this.AgreementNo,
|
|
640
|
-
AccountType: this.AccountType,
|
|
641
|
-
Status: this.Status,
|
|
642
|
-
EscheatmentYN: this.EscheatmentYN,
|
|
643
|
-
CreatedById: this.CreatedById,
|
|
644
|
-
CreatedAt: this.CreatedAt,
|
|
645
|
-
UpdatedById: this.UpdatedById,
|
|
646
|
-
UpdatedAt: this.UpdatedAt,
|
|
647
|
-
};
|
|
648
|
-
this._Status = statusAfterSign
|
|
649
|
-
? statusAfterSign
|
|
650
|
-
: rental_status_enum_1.RentalStatusEnum.ACTIVE;
|
|
651
|
-
const payloadRental = {
|
|
652
|
-
Status: this._Status,
|
|
653
|
-
UpdatedById: loginUser.ObjectId,
|
|
654
|
-
UpdatedAt: new Date(),
|
|
655
|
-
};
|
|
656
|
-
yield Rental._Repo.update(payloadRental, {
|
|
657
|
-
where: {
|
|
658
|
-
RentalId: this.RentalId,
|
|
659
|
-
},
|
|
660
|
-
transaction: dbTransaction,
|
|
661
|
-
});
|
|
662
|
-
const entityValueRentalAfter = Object.assign({ entityValueRentalBefore }, payloadRental);
|
|
663
|
-
const rentalActivity = new activity_history_1.Activity();
|
|
664
|
-
rentalActivity.ActivityId = activity.createId();
|
|
665
|
-
rentalActivity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
666
|
-
rentalActivity.Description = 'Sign rental agreement';
|
|
667
|
-
rentalActivity.EntityType = 'Rental';
|
|
668
|
-
rentalActivity.EntityId = this.RentalId;
|
|
669
|
-
rentalActivity.EntityValueBefore = JSON.stringify(entityValueRentalBefore);
|
|
670
|
-
rentalActivity.EntityValueAfter = JSON.stringify(entityValueRentalAfter);
|
|
671
|
-
yield rentalActivity.create(loginUser.ObjectId, dbTransaction);
|
|
540
|
+
const signatureList = await agreement_1.Agreement.getSignatureList(loginUser, this.AgreementNo, dbTransaction);
|
|
541
|
+
const customerSignature = signatureList.find((sig) => sig.PartyId === PartyId &&
|
|
542
|
+
sig.PartyType === PartyType &&
|
|
543
|
+
sig.Party === party &&
|
|
544
|
+
sig.SignatureStatus === agreement_signature_status_enum_1.AgreementSignatureStatusEnum.PENDING);
|
|
545
|
+
if (!customerSignature) {
|
|
546
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', 'Signature is not pending.');
|
|
672
547
|
}
|
|
673
|
-
|
|
674
|
-
|
|
548
|
+
const signaturePayload = {
|
|
549
|
+
SignatureStatus: agreement_signature_status_enum_1.AgreementSignatureStatusEnum.SIGNED,
|
|
550
|
+
SignedAt: new Date(),
|
|
551
|
+
UpdatedById: loginUser.ObjectId,
|
|
552
|
+
UpdatedAt: new Date(),
|
|
553
|
+
};
|
|
554
|
+
await Rental._AgreementSignatureRepo.update(signaturePayload, {
|
|
555
|
+
where: {
|
|
556
|
+
AgreementNo: this.AgreementNo,
|
|
557
|
+
Party: party,
|
|
558
|
+
PartyId: PartyId,
|
|
559
|
+
PartyType: PartyType,
|
|
560
|
+
},
|
|
561
|
+
transaction: dbTransaction,
|
|
562
|
+
});
|
|
563
|
+
const signatureActivity = new activity_history_1.Activity();
|
|
564
|
+
signatureActivity.ActivityId = signatureActivity.createId();
|
|
565
|
+
signatureActivity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
566
|
+
signatureActivity.Description = 'Update hirer signature';
|
|
567
|
+
signatureActivity.EntityType = 'AgreementSignature';
|
|
568
|
+
signatureActivity.EntityId = this.AgreementNo;
|
|
569
|
+
signatureActivity.EntityValueBefore = JSON.stringify(customerSignature);
|
|
570
|
+
signatureActivity.EntityValueAfter = JSON.stringify(signaturePayload);
|
|
571
|
+
await signatureActivity.create(loginUser.ObjectId, dbTransaction);
|
|
572
|
+
const updatedSignatureList = await agreement_1.Agreement.getSignatureList(loginUser, this.AgreementNo, dbTransaction);
|
|
573
|
+
const pendingSignatures = updatedSignatureList.filter((sig) => sig.SignatureStatus === 'Pending');
|
|
574
|
+
if (pendingSignatures.length > 0) {
|
|
575
|
+
return;
|
|
675
576
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (!MediaId) {
|
|
688
|
-
throw new general_1.ClassError('Rental', 'RentalErrMsg0X', 'MediaId is required.');
|
|
689
|
-
}
|
|
690
|
-
const EntityValueBefore = agreement;
|
|
691
|
-
agreement.Status = aggrement_status_enum_1.AggrementStatusEnum.GENERATED;
|
|
692
|
-
agreement.MediaId = MediaId;
|
|
693
|
-
yield Rental._AgreementRepo.update({
|
|
694
|
-
Status: agreement.Status,
|
|
695
|
-
MediaId: agreement.MediaId,
|
|
696
|
-
}, {
|
|
697
|
-
where: {
|
|
698
|
-
AgreementNo: this.AgreementNo,
|
|
699
|
-
},
|
|
700
|
-
transaction: dbTransaction,
|
|
701
|
-
});
|
|
702
|
-
const EntityValueAfter = agreement;
|
|
703
|
-
const activity = new activity_history_1.Activity();
|
|
704
|
-
activity.ActivityId = activity.createId();
|
|
705
|
-
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
706
|
-
activity.Description = 'Generate agreement.';
|
|
707
|
-
activity.EntityType = 'RentalAgreement';
|
|
708
|
-
activity.EntityId = this.AgreementNo;
|
|
709
|
-
activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
|
|
710
|
-
activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
|
|
711
|
-
yield activity.create(loginUser.ObjectId, dbTransaction);
|
|
712
|
-
const agreementHistory = yield Rental._AgreementHistoryRepo.create({
|
|
577
|
+
const entityValueAgreementBefore = {
|
|
578
|
+
AgreementNo: agreement.AgreementNo,
|
|
579
|
+
Status: agreement.Status,
|
|
580
|
+
DateSigned: agreement.DateSigned,
|
|
581
|
+
};
|
|
582
|
+
const payload = {
|
|
583
|
+
DateSigned: new Date(),
|
|
584
|
+
Status: aggrement_status_enum_1.AggrementStatusEnum.SIGNED,
|
|
585
|
+
};
|
|
586
|
+
await Rental._AgreementRepo.update(payload, {
|
|
587
|
+
where: {
|
|
713
588
|
AgreementNo: this.AgreementNo,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
589
|
+
},
|
|
590
|
+
transaction: dbTransaction,
|
|
591
|
+
});
|
|
592
|
+
const entityValueAgreementAfter = Object.assign({ entityValueAgreementBefore }, payload);
|
|
593
|
+
const activity = new activity_history_1.Activity();
|
|
594
|
+
activity.ActivityId = activity.createId();
|
|
595
|
+
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
596
|
+
activity.Description = 'Update agreement';
|
|
597
|
+
activity.EntityType = 'RentalAgreement';
|
|
598
|
+
activity.EntityId = this.AgreementNo;
|
|
599
|
+
activity.EntityValueBefore = JSON.stringify(entityValueAgreementBefore);
|
|
600
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAgreementAfter);
|
|
601
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
602
|
+
const entityValueRentalBefore = {
|
|
603
|
+
RentalId: this.RentalId,
|
|
604
|
+
CustomerId: this.CustomerId,
|
|
605
|
+
CustomerType: this.CustomerType,
|
|
606
|
+
ItemId: this.ItemId,
|
|
607
|
+
ItemType: this.ItemType,
|
|
608
|
+
PriceId: this.PriceId,
|
|
609
|
+
StartDateTime: this.StartDateTime,
|
|
610
|
+
EndDateTime: this.EndDateTime,
|
|
611
|
+
CancelRemarks: this.CancelRemarks,
|
|
612
|
+
TerminateRemarks: this.TerminateRemarks,
|
|
613
|
+
AgreementNo: this.AgreementNo,
|
|
614
|
+
AccountType: this.AccountType,
|
|
615
|
+
Status: this.Status,
|
|
616
|
+
EscheatmentYN: this.EscheatmentYN,
|
|
617
|
+
CreatedById: this.CreatedById,
|
|
618
|
+
CreatedAt: this.CreatedAt,
|
|
619
|
+
UpdatedById: this.UpdatedById,
|
|
620
|
+
UpdatedAt: this.UpdatedAt,
|
|
621
|
+
};
|
|
622
|
+
this._Status = statusAfterSign
|
|
623
|
+
? statusAfterSign
|
|
624
|
+
: rental_status_enum_1.RentalStatusEnum.ACTIVE;
|
|
625
|
+
const payloadRental = {
|
|
626
|
+
Status: this._Status,
|
|
627
|
+
UpdatedById: loginUser.ObjectId,
|
|
628
|
+
UpdatedAt: new Date(),
|
|
629
|
+
};
|
|
630
|
+
await Rental._Repo.update(payloadRental, {
|
|
631
|
+
where: {
|
|
632
|
+
RentalId: this.RentalId,
|
|
633
|
+
},
|
|
634
|
+
transaction: dbTransaction,
|
|
635
|
+
});
|
|
636
|
+
const entityValueRentalAfter = Object.assign({ entityValueRentalBefore }, payloadRental);
|
|
637
|
+
const rentalActivity = new activity_history_1.Activity();
|
|
638
|
+
rentalActivity.ActivityId = activity.createId();
|
|
639
|
+
rentalActivity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
640
|
+
rentalActivity.Description = 'Sign rental agreement';
|
|
641
|
+
rentalActivity.EntityType = 'Rental';
|
|
642
|
+
rentalActivity.EntityId = this.RentalId;
|
|
643
|
+
rentalActivity.EntityValueBefore = JSON.stringify(entityValueRentalBefore);
|
|
644
|
+
rentalActivity.EntityValueAfter = JSON.stringify(entityValueRentalAfter);
|
|
645
|
+
await rentalActivity.create(loginUser.ObjectId, dbTransaction);
|
|
646
|
+
}
|
|
647
|
+
catch (error) {
|
|
648
|
+
throw error;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
async generateAgreement(loginUser, dbTransaction, MediaId) {
|
|
652
|
+
try {
|
|
653
|
+
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
654
|
+
const isPrivileged = loginUser.checkPrivileges(systemCode, 'RENTAL_AGREEMENT_CREATE');
|
|
655
|
+
if (!isPrivileged) {
|
|
656
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg01', "You do not have 'RENTAL_AGREEMENT_CREATE' privilege.");
|
|
728
657
|
}
|
|
729
|
-
|
|
730
|
-
|
|
658
|
+
const agreement = await agreement_1.Agreement.init(this.AgreementNo, dbTransaction);
|
|
659
|
+
if (!MediaId) {
|
|
660
|
+
throw new general_1.ClassError('Rental', 'RentalErrMsg0X', 'MediaId is required.');
|
|
731
661
|
}
|
|
732
|
-
|
|
662
|
+
const EntityValueBefore = agreement;
|
|
663
|
+
agreement.Status = aggrement_status_enum_1.AggrementStatusEnum.GENERATED;
|
|
664
|
+
agreement.MediaId = MediaId;
|
|
665
|
+
await Rental._AgreementRepo.update({
|
|
666
|
+
Status: agreement.Status,
|
|
667
|
+
MediaId: agreement.MediaId,
|
|
668
|
+
}, {
|
|
669
|
+
where: {
|
|
670
|
+
AgreementNo: this.AgreementNo,
|
|
671
|
+
},
|
|
672
|
+
transaction: dbTransaction,
|
|
673
|
+
});
|
|
674
|
+
const EntityValueAfter = agreement;
|
|
675
|
+
const activity = new activity_history_1.Activity();
|
|
676
|
+
activity.ActivityId = activity.createId();
|
|
677
|
+
activity.Action = activity_history_1.ActionEnum.UPDATE;
|
|
678
|
+
activity.Description = 'Generate agreement.';
|
|
679
|
+
activity.EntityType = 'RentalAgreement';
|
|
680
|
+
activity.EntityId = this.AgreementNo;
|
|
681
|
+
activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
|
|
682
|
+
activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
|
|
683
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
684
|
+
const agreementHistory = await Rental._AgreementHistoryRepo.create({
|
|
685
|
+
AgreementNo: this.AgreementNo,
|
|
686
|
+
MediaId,
|
|
687
|
+
ActivityCompleted: 'Agreement Generated',
|
|
688
|
+
CreatedAt: new Date(),
|
|
689
|
+
}, { transaction: dbTransaction });
|
|
690
|
+
const entityValueAfter = agreementHistory.get({ plain: true });
|
|
691
|
+
const activityHistory = new activity_history_1.Activity();
|
|
692
|
+
activityHistory.ActivityId = activityHistory.createId();
|
|
693
|
+
activityHistory.Action = activity_history_1.ActionEnum.CREATE;
|
|
694
|
+
activityHistory.Description = 'Generate agreement.';
|
|
695
|
+
activityHistory.EntityType = 'RentalAgreementHistory';
|
|
696
|
+
activityHistory.EntityId = agreementHistory.HistoryId.toString();
|
|
697
|
+
activityHistory.EntityValueBefore = JSON.stringify({});
|
|
698
|
+
activityHistory.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
699
|
+
await activityHistory.create(loginUser.ObjectId, dbTransaction);
|
|
700
|
+
}
|
|
701
|
+
catch (error) {
|
|
702
|
+
throw error;
|
|
703
|
+
}
|
|
733
704
|
}
|
|
734
705
|
}
|
|
735
706
|
exports.Rental = Rental;
|