@things-factory/sales-base 4.3.669 → 4.3.671
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/server/controllers/ecommerce/powrup-controller.ts +1 -1
- package/dist-server/constants/attachment-type.js +0 -15
- package/dist-server/constants/attachment-type.js.map +0 -1
- package/dist-server/constants/index.js +0 -24
- package/dist-server/constants/index.js.map +0 -1
- package/dist-server/constants/load-type.js +0 -8
- package/dist-server/constants/load-type.js.map +0 -1
- package/dist-server/constants/order.js +0 -235
- package/dist-server/constants/order.js.map +0 -1
- package/dist-server/constants/product-group-type.js +0 -8
- package/dist-server/constants/product-group-type.js.map +0 -1
- package/dist-server/constants/release-good.js +0 -13
- package/dist-server/constants/release-good.js.map +0 -1
- package/dist-server/constants/transfer-order-type.js +0 -9
- package/dist-server/constants/transfer-order-type.js.map +0 -1
- package/dist-server/constants/validation-error-code.js +0 -7
- package/dist-server/constants/validation-error-code.js.map +0 -1
- package/dist-server/constants/vas-target-type.js +0 -26
- package/dist-server/constants/vas-target-type.js.map +0 -1
- package/dist-server/controllers/ecommerce/ecommerce-controller.js +0 -138
- package/dist-server/controllers/ecommerce/ecommerce-controller.js.map +0 -1
- package/dist-server/controllers/ecommerce/index.js +0 -21
- package/dist-server/controllers/ecommerce/index.js.map +0 -1
- package/dist-server/controllers/ecommerce/powrup-controller.js +0 -747
- package/dist-server/controllers/ecommerce/powrup-controller.js.map +0 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +0 -148
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +0 -1
- package/dist-server/controllers/ecommerce/webspert-controller.js +0 -237
- package/dist-server/controllers/ecommerce/webspert-controller.js.map +0 -1
- package/dist-server/controllers/index.js +0 -19
- package/dist-server/controllers/index.js.map +0 -1
- package/dist-server/controllers/order-controller.js +0 -244
- package/dist-server/controllers/order-controller.js.map +0 -1
- package/dist-server/errors/index.js +0 -18
- package/dist-server/errors/index.js.map +0 -1
- package/dist-server/errors/validation-error.js +0 -41
- package/dist-server/errors/validation-error.js.map +0 -1
- package/dist-server/index.js +0 -30
- package/dist-server/index.js.map +0 -1
- package/dist-server/migrations/index.js +0 -12
- package/dist-server/migrations/index.js.map +0 -1
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js +0 -1453
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +0 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js +0 -638
- package/dist-server/service/arrival-notice/arrival-notice-query.js.map +0 -1
- package/dist-server/service/arrival-notice/arrival-notice-types.js +0 -443
- package/dist-server/service/arrival-notice/arrival-notice-types.js.map +0 -1
- package/dist-server/service/arrival-notice/arrival-notice.js +0 -259
- package/dist-server/service/arrival-notice/arrival-notice.js.map +0 -1
- package/dist-server/service/arrival-notice/index.js +0 -25
- package/dist-server/service/arrival-notice/index.js.map +0 -1
- package/dist-server/service/claim/claim-mutation.js +0 -243
- package/dist-server/service/claim/claim-mutation.js.map +0 -1
- package/dist-server/service/claim/claim-query.js +0 -165
- package/dist-server/service/claim/claim-query.js.map +0 -1
- package/dist-server/service/claim/claim-types.js +0 -191
- package/dist-server/service/claim/claim-types.js.map +0 -1
- package/dist-server/service/claim/claim.js +0 -176
- package/dist-server/service/claim/claim.js.map +0 -1
- package/dist-server/service/claim/index.js +0 -25
- package/dist-server/service/claim/index.js.map +0 -1
- package/dist-server/service/claim-detail/claim-detail-mutation.js +0 -110
- package/dist-server/service/claim-detail/claim-detail-mutation.js.map +0 -1
- package/dist-server/service/claim-detail/claim-detail-query.js +0 -90
- package/dist-server/service/claim-detail/claim-detail-query.js.map +0 -1
- package/dist-server/service/claim-detail/claim-detail-types.js +0 -81
- package/dist-server/service/claim-detail/claim-detail-types.js.map +0 -1
- package/dist-server/service/claim-detail/claim-detail.js +0 -102
- package/dist-server/service/claim-detail/claim-detail.js.map +0 -1
- package/dist-server/service/claim-detail/index.js +0 -25
- package/dist-server/service/claim-detail/index.js.map +0 -1
- package/dist-server/service/claim-order/claim-order-mutation.js +0 -110
- package/dist-server/service/claim-order/claim-order-mutation.js.map +0 -1
- package/dist-server/service/claim-order/claim-order-query.js +0 -86
- package/dist-server/service/claim-order/claim-order-query.js.map +0 -1
- package/dist-server/service/claim-order/claim-order-types.js +0 -65
- package/dist-server/service/claim-order/claim-order-types.js.map +0 -1
- package/dist-server/service/claim-order/claim-order.js +0 -104
- package/dist-server/service/claim-order/claim-order.js.map +0 -1
- package/dist-server/service/claim-order/index.js +0 -25
- package/dist-server/service/claim-order/index.js.map +0 -1
- package/dist-server/service/collection-order/collection-order-mutation.js +0 -241
- package/dist-server/service/collection-order/collection-order-mutation.js.map +0 -1
- package/dist-server/service/collection-order/collection-order-query.js +0 -125
- package/dist-server/service/collection-order/collection-order-query.js.map +0 -1
- package/dist-server/service/collection-order/collection-order-types.js +0 -241
- package/dist-server/service/collection-order/collection-order-types.js.map +0 -1
- package/dist-server/service/collection-order/collection-order.js +0 -183
- package/dist-server/service/collection-order/collection-order.js.map +0 -1
- package/dist-server/service/collection-order/index.js +0 -25
- package/dist-server/service/collection-order/index.js.map +0 -1
- package/dist-server/service/delivery-order/delivery-order-mutation.js +0 -746
- package/dist-server/service/delivery-order/delivery-order-mutation.js.map +0 -1
- package/dist-server/service/delivery-order/delivery-order-query.js +0 -570
- package/dist-server/service/delivery-order/delivery-order-query.js.map +0 -1
- package/dist-server/service/delivery-order/delivery-order-types.js +0 -397
- package/dist-server/service/delivery-order/delivery-order-types.js.map +0 -1
- package/dist-server/service/delivery-order/delivery-order.js +0 -365
- package/dist-server/service/delivery-order/delivery-order.js.map +0 -1
- package/dist-server/service/delivery-order/index.js +0 -25
- package/dist-server/service/delivery-order/index.js.map +0 -1
- package/dist-server/service/draft-release-good/draft-release-good-create.js +0 -647
- package/dist-server/service/draft-release-good/draft-release-good-create.js.map +0 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +0 -486
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +0 -1
- package/dist-server/service/draft-release-good/draft-release-good-query.js +0 -372
- package/dist-server/service/draft-release-good/draft-release-good-query.js.map +0 -1
- package/dist-server/service/draft-release-good/draft-release-good-type.js +0 -424
- package/dist-server/service/draft-release-good/draft-release-good-type.js.map +0 -1
- package/dist-server/service/draft-release-good/draft-release-good.js +0 -444
- package/dist-server/service/draft-release-good/draft-release-good.js.map +0 -1
- package/dist-server/service/draft-release-good/index.js +0 -29
- package/dist-server/service/draft-release-good/index.js.map +0 -1
- package/dist-server/service/goods-receival-note/goods-receival-note-mutation.js +0 -140
- package/dist-server/service/goods-receival-note/goods-receival-note-mutation.js.map +0 -1
- package/dist-server/service/goods-receival-note/goods-receival-note-query.js +0 -273
- package/dist-server/service/goods-receival-note/goods-receival-note-query.js.map +0 -1
- package/dist-server/service/goods-receival-note/goods-receival-note-types.js +0 -159
- package/dist-server/service/goods-receival-note/goods-receival-note-types.js.map +0 -1
- package/dist-server/service/goods-receival-note/goods-receival-note.js +0 -156
- package/dist-server/service/goods-receival-note/goods-receival-note.js.map +0 -1
- package/dist-server/service/goods-receival-note/index.js +0 -25
- package/dist-server/service/goods-receival-note/index.js.map +0 -1
- package/dist-server/service/index.js +0 -282
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/service/inventory-check/index.js +0 -25
- package/dist-server/service/inventory-check/index.js.map +0 -1
- package/dist-server/service/inventory-check/inventory-check-mutation.js +0 -151
- package/dist-server/service/inventory-check/inventory-check-mutation.js.map +0 -1
- package/dist-server/service/inventory-check/inventory-check-query.js +0 -138
- package/dist-server/service/inventory-check/inventory-check-query.js.map +0 -1
- package/dist-server/service/inventory-check/inventory-check-types.js +0 -82
- package/dist-server/service/inventory-check/inventory-check-types.js.map +0 -1
- package/dist-server/service/inventory-check/inventory-check.js +0 -115
- package/dist-server/service/inventory-check/inventory-check.js.map +0 -1
- package/dist-server/service/inventory-check-item/index.js +0 -25
- package/dist-server/service/inventory-check-item/index.js.map +0 -1
- package/dist-server/service/inventory-check-item/inventory-check-item-mutation.js +0 -120
- package/dist-server/service/inventory-check-item/inventory-check-item-mutation.js.map +0 -1
- package/dist-server/service/inventory-check-item/inventory-check-item-query.js +0 -196
- package/dist-server/service/inventory-check-item/inventory-check-item-query.js.map +0 -1
- package/dist-server/service/inventory-check-item/inventory-check-item-types.js +0 -157
- package/dist-server/service/inventory-check-item/inventory-check-item-types.js.map +0 -1
- package/dist-server/service/inventory-check-item/inventory-check-item.js +0 -273
- package/dist-server/service/inventory-check-item/inventory-check-item.js.map +0 -1
- package/dist-server/service/invoice/index.js +0 -25
- package/dist-server/service/invoice/index.js.map +0 -1
- package/dist-server/service/invoice/invoice-mutation.js +0 -105
- package/dist-server/service/invoice/invoice-mutation.js.map +0 -1
- package/dist-server/service/invoice/invoice-query.js +0 -94
- package/dist-server/service/invoice/invoice-query.js.map +0 -1
- package/dist-server/service/invoice/invoice-types.js +0 -388
- package/dist-server/service/invoice/invoice-types.js.map +0 -1
- package/dist-server/service/invoice/invoice.js +0 -312
- package/dist-server/service/invoice/invoice.js.map +0 -1
- package/dist-server/service/invoice-product/index.js +0 -25
- package/dist-server/service/invoice-product/index.js.map +0 -1
- package/dist-server/service/invoice-product/invoice-product-mutation.js +0 -70
- package/dist-server/service/invoice-product/invoice-product-mutation.js.map +0 -1
- package/dist-server/service/invoice-product/invoice-product-query.js +0 -95
- package/dist-server/service/invoice-product/invoice-product-query.js.map +0 -1
- package/dist-server/service/invoice-product/invoice-product-types.js +0 -131
- package/dist-server/service/invoice-product/invoice-product-types.js.map +0 -1
- package/dist-server/service/invoice-product/invoice-product.js +0 -130
- package/dist-server/service/invoice-product/invoice-product.js.map +0 -1
- package/dist-server/service/job-sheet/index.js +0 -25
- package/dist-server/service/job-sheet/index.js.map +0 -1
- package/dist-server/service/job-sheet/job-sheet-mutation.js +0 -93
- package/dist-server/service/job-sheet/job-sheet-mutation.js.map +0 -1
- package/dist-server/service/job-sheet/job-sheet-query.js +0 -134
- package/dist-server/service/job-sheet/job-sheet-query.js.map +0 -1
- package/dist-server/service/job-sheet/job-sheet-types.js +0 -113
- package/dist-server/service/job-sheet/job-sheet-types.js.map +0 -1
- package/dist-server/service/job-sheet/job-sheet.js +0 -132
- package/dist-server/service/job-sheet/job-sheet.js.map +0 -1
- package/dist-server/service/manifest/index.js +0 -9
- package/dist-server/service/manifest/index.js.map +0 -1
- package/dist-server/service/manifest/manifest-mutation.js +0 -264
- package/dist-server/service/manifest/manifest-mutation.js.map +0 -1
- package/dist-server/service/manifest/manifest-query.js +0 -228
- package/dist-server/service/manifest/manifest-query.js.map +0 -1
- package/dist-server/service/manifest/manifest-type.js +0 -183
- package/dist-server/service/manifest/manifest-type.js.map +0 -1
- package/dist-server/service/manifest/manifest.js +0 -134
- package/dist-server/service/manifest/manifest.js.map +0 -1
- package/dist-server/service/order-consignment/index.js +0 -9
- package/dist-server/service/order-consignment/index.js.map +0 -1
- package/dist-server/service/order-consignment/order-consignment-mutation.js +0 -120
- package/dist-server/service/order-consignment/order-consignment-mutation.js.map +0 -1
- package/dist-server/service/order-consignment/order-consignment-query.js +0 -87
- package/dist-server/service/order-consignment/order-consignment-query.js.map +0 -1
- package/dist-server/service/order-consignment/order-consignment-type.js +0 -69
- package/dist-server/service/order-consignment/order-consignment-type.js.map +0 -1
- package/dist-server/service/order-consignment/order-consignment.js +0 -115
- package/dist-server/service/order-consignment/order-consignment.js.map +0 -1
- package/dist-server/service/order-inventory/index.js +0 -25
- package/dist-server/service/order-inventory/index.js.map +0 -1
- package/dist-server/service/order-inventory/order-inventory-mutation.js +0 -80
- package/dist-server/service/order-inventory/order-inventory-mutation.js.map +0 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +0 -592
- package/dist-server/service/order-inventory/order-inventory-query.js.map +0 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +0 -341
- package/dist-server/service/order-inventory/order-inventory-types.js.map +0 -1
- package/dist-server/service/order-inventory/order-inventory.js +0 -785
- package/dist-server/service/order-inventory/order-inventory.js.map +0 -1
- package/dist-server/service/order-package/index.js +0 -9
- package/dist-server/service/order-package/index.js.map +0 -1
- package/dist-server/service/order-package/order-package-mutation.js +0 -120
- package/dist-server/service/order-package/order-package-mutation.js.map +0 -1
- package/dist-server/service/order-package/order-package-query.js +0 -142
- package/dist-server/service/order-package/order-package-query.js.map +0 -1
- package/dist-server/service/order-package/order-package-types.js +0 -113
- package/dist-server/service/order-package/order-package-types.js.map +0 -1
- package/dist-server/service/order-package/order-package.js +0 -229
- package/dist-server/service/order-package/order-package.js.map +0 -1
- package/dist-server/service/order-package-item/index.js +0 -9
- package/dist-server/service/order-package-item/index.js.map +0 -1
- package/dist-server/service/order-package-item/order-package-item-mutation.js +0 -120
- package/dist-server/service/order-package-item/order-package-item-mutation.js.map +0 -1
- package/dist-server/service/order-package-item/order-package-item-query.js +0 -127
- package/dist-server/service/order-package-item/order-package-item-query.js.map +0 -1
- package/dist-server/service/order-package-item/order-package-item-types.js +0 -99
- package/dist-server/service/order-package-item/order-package-item-types.js.map +0 -1
- package/dist-server/service/order-package-item/order-package-item.js +0 -162
- package/dist-server/service/order-package-item/order-package-item.js.map +0 -1
- package/dist-server/service/order-product/index.js +0 -25
- package/dist-server/service/order-product/index.js.map +0 -1
- package/dist-server/service/order-product/order-product-mutation.js +0 -74
- package/dist-server/service/order-product/order-product-mutation.js.map +0 -1
- package/dist-server/service/order-product/order-product-query.js +0 -125
- package/dist-server/service/order-product/order-product-query.js.map +0 -1
- package/dist-server/service/order-product/order-product-types.js +0 -545
- package/dist-server/service/order-product/order-product-types.js.map +0 -1
- package/dist-server/service/order-product/order-product.js +0 -605
- package/dist-server/service/order-product/order-product.js.map +0 -1
- package/dist-server/service/order-tote/index.js +0 -25
- package/dist-server/service/order-tote/index.js.map +0 -1
- package/dist-server/service/order-tote/order-tote-mutation.js +0 -56
- package/dist-server/service/order-tote/order-tote-mutation.js.map +0 -1
- package/dist-server/service/order-tote/order-tote-query.js +0 -123
- package/dist-server/service/order-tote/order-tote-query.js.map +0 -1
- package/dist-server/service/order-tote/order-tote-types.js +0 -79
- package/dist-server/service/order-tote/order-tote-types.js.map +0 -1
- package/dist-server/service/order-tote/order-tote.js +0 -92
- package/dist-server/service/order-tote/order-tote.js.map +0 -1
- package/dist-server/service/order-tote-item/index.js +0 -25
- package/dist-server/service/order-tote-item/index.js.map +0 -1
- package/dist-server/service/order-tote-item/order-tote-item-mutation.js +0 -56
- package/dist-server/service/order-tote-item/order-tote-item-mutation.js.map +0 -1
- package/dist-server/service/order-tote-item/order-tote-item-query.js +0 -100
- package/dist-server/service/order-tote-item/order-tote-item-query.js.map +0 -1
- package/dist-server/service/order-tote-item/order-tote-item-types.js +0 -91
- package/dist-server/service/order-tote-item/order-tote-item-types.js.map +0 -1
- package/dist-server/service/order-tote-item/order-tote-item.js +0 -118
- package/dist-server/service/order-tote-item/order-tote-item.js.map +0 -1
- package/dist-server/service/order-tote-seal/index.js +0 -25
- package/dist-server/service/order-tote-seal/index.js.map +0 -1
- package/dist-server/service/order-tote-seal/order-tote-seal-mutation.js +0 -56
- package/dist-server/service/order-tote-seal/order-tote-seal-mutation.js.map +0 -1
- package/dist-server/service/order-tote-seal/order-tote-seal-query.js +0 -97
- package/dist-server/service/order-tote-seal/order-tote-seal-query.js.map +0 -1
- package/dist-server/service/order-tote-seal/order-tote-seal-types.js +0 -71
- package/dist-server/service/order-tote-seal/order-tote-seal-types.js.map +0 -1
- package/dist-server/service/order-tote-seal/order-tote-seal.js +0 -71
- package/dist-server/service/order-tote-seal/order-tote-seal.js.map +0 -1
- package/dist-server/service/order-vas/index.js +0 -25
- package/dist-server/service/order-vas/index.js.map +0 -1
- package/dist-server/service/order-vas/order-vas-mutation.js +0 -148
- package/dist-server/service/order-vas/order-vas-mutation.js.map +0 -1
- package/dist-server/service/order-vas/order-vas-query.js +0 -148
- package/dist-server/service/order-vas/order-vas-query.js.map +0 -1
- package/dist-server/service/order-vas/order-vas-types.js +0 -348
- package/dist-server/service/order-vas/order-vas-types.js.map +0 -1
- package/dist-server/service/order-vas/order-vas.js +0 -476
- package/dist-server/service/order-vas/order-vas.js.map +0 -1
- package/dist-server/service/order-vas-item/index.js +0 -9
- package/dist-server/service/order-vas-item/index.js.map +0 -1
- package/dist-server/service/order-vas-item/order-vas-item-mutation.js +0 -164
- package/dist-server/service/order-vas-item/order-vas-item-mutation.js.map +0 -1
- package/dist-server/service/order-vas-item/order-vas-item-query.js +0 -99
- package/dist-server/service/order-vas-item/order-vas-item-query.js.map +0 -1
- package/dist-server/service/order-vas-item/order-vas-item-type.js +0 -131
- package/dist-server/service/order-vas-item/order-vas-item-type.js.map +0 -1
- package/dist-server/service/order-vas-item/order-vas-item.js +0 -166
- package/dist-server/service/order-vas-item/order-vas-item.js.map +0 -1
- package/dist-server/service/others/index.js +0 -21
- package/dist-server/service/others/index.js.map +0 -1
- package/dist-server/service/others/other-query.js +0 -605
- package/dist-server/service/others/other-query.js.map +0 -1
- package/dist-server/service/others/other-types.js +0 -198
- package/dist-server/service/others/other-types.js.map +0 -1
- package/dist-server/service/purchase-order/index.js +0 -25
- package/dist-server/service/purchase-order/index.js.map +0 -1
- package/dist-server/service/purchase-order/purchase-order-mutation.js +0 -398
- package/dist-server/service/purchase-order/purchase-order-mutation.js.map +0 -1
- package/dist-server/service/purchase-order/purchase-order-query.js +0 -126
- package/dist-server/service/purchase-order/purchase-order-query.js.map +0 -1
- package/dist-server/service/purchase-order/purchase-order-types.js +0 -240
- package/dist-server/service/purchase-order/purchase-order-types.js.map +0 -1
- package/dist-server/service/purchase-order/purchase-order.js +0 -236
- package/dist-server/service/purchase-order/purchase-order.js.map +0 -1
- package/dist-server/service/purchase-order-other-charge/index.js +0 -25
- package/dist-server/service/purchase-order-other-charge/index.js.map +0 -1
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge-mutation.js +0 -56
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge-mutation.js.map +0 -1
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge-query.js +0 -87
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge-query.js.map +0 -1
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge-types.js +0 -77
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge-types.js.map +0 -1
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge.js +0 -101
- package/dist-server/service/purchase-order-other-charge/purchase-order-other-charge.js.map +0 -1
- package/dist-server/service/release-good/index.js +0 -25
- package/dist-server/service/release-good/index.js.map +0 -1
- package/dist-server/service/release-good/release-good-mutation.js +0 -1598
- package/dist-server/service/release-good/release-good-mutation.js.map +0 -1
- package/dist-server/service/release-good/release-good-query.js +0 -1132
- package/dist-server/service/release-good/release-good-query.js.map +0 -1
- package/dist-server/service/release-good/release-good-types.js +0 -1043
- package/dist-server/service/release-good/release-good-types.js.map +0 -1
- package/dist-server/service/release-good/release-good.js +0 -817
- package/dist-server/service/release-good/release-good.js.map +0 -1
- package/dist-server/service/release-good-logs/index.js +0 -11
- package/dist-server/service/release-good-logs/index.js.map +0 -1
- package/dist-server/service/release-good-logs/release-good-logs-mutation.js +0 -126
- package/dist-server/service/release-good-logs/release-good-logs-mutation.js.map +0 -1
- package/dist-server/service/release-good-logs/release-good-logs-query.js +0 -71
- package/dist-server/service/release-good-logs/release-good-logs-query.js.map +0 -1
- package/dist-server/service/release-good-logs/release-good-logs-type.js +0 -65
- package/dist-server/service/release-good-logs/release-good-logs-type.js.map +0 -1
- package/dist-server/service/release-good-logs/release-good-logs.js +0 -96
- package/dist-server/service/release-good-logs/release-good-logs.js.map +0 -1
- package/dist-server/service/replenishment/index.js +0 -9
- package/dist-server/service/replenishment/index.js.map +0 -1
- package/dist-server/service/replenishment/replenishment-mutation.js +0 -234
- package/dist-server/service/replenishment/replenishment-mutation.js.map +0 -1
- package/dist-server/service/replenishment/replenishment-query.js +0 -185
- package/dist-server/service/replenishment/replenishment-query.js.map +0 -1
- package/dist-server/service/replenishment/replenishment-type.js +0 -119
- package/dist-server/service/replenishment/replenishment-type.js.map +0 -1
- package/dist-server/service/replenishment/replenishment.js +0 -114
- package/dist-server/service/replenishment/replenishment.js.map +0 -1
- package/dist-server/service/retail-replenishment-order/index.js +0 -25
- package/dist-server/service/retail-replenishment-order/index.js.map +0 -1
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order-mutation.js +0 -314
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order-mutation.js.map +0 -1
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order-query.js +0 -89
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order-query.js.map +0 -1
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order-types.js +0 -148
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order-types.js.map +0 -1
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order.js +0 -141
- package/dist-server/service/retail-replenishment-order/retail-replenishment-order.js.map +0 -1
- package/dist-server/service/return-order/index.js +0 -25
- package/dist-server/service/return-order/index.js.map +0 -1
- package/dist-server/service/return-order/return-order-mutation.js +0 -451
- package/dist-server/service/return-order/return-order-mutation.js.map +0 -1
- package/dist-server/service/return-order/return-order-query.js +0 -243
- package/dist-server/service/return-order/return-order-query.js.map +0 -1
- package/dist-server/service/return-order/return-order-types.js +0 -274
- package/dist-server/service/return-order/return-order-types.js.map +0 -1
- package/dist-server/service/return-order/return-order.js +0 -159
- package/dist-server/service/return-order/return-order.js.map +0 -1
- package/dist-server/service/reverse-kitting-order/index.js +0 -25
- package/dist-server/service/reverse-kitting-order/index.js.map +0 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-mutation.js +0 -407
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-mutation.js.map +0 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-query.js +0 -222
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-query.js.map +0 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-type.js +0 -230
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-type.js.map +0 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order.js +0 -145
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order.js.map +0 -1
- package/dist-server/service/reverse-kitting-order-inventory/index.js +0 -25
- package/dist-server/service/reverse-kitting-order-inventory/index.js.map +0 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.js +0 -130
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.js.map +0 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-query.js +0 -87
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-query.js.map +0 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.js +0 -143
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.js.map +0 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +0 -178
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +0 -1
- package/dist-server/service/shipping-order/index.js +0 -25
- package/dist-server/service/shipping-order/index.js.map +0 -1
- package/dist-server/service/shipping-order/shipping-order-mutation.js +0 -78
- package/dist-server/service/shipping-order/shipping-order-mutation.js.map +0 -1
- package/dist-server/service/shipping-order/shipping-order-query.js +0 -96
- package/dist-server/service/shipping-order/shipping-order-query.js.map +0 -1
- package/dist-server/service/shipping-order/shipping-order-types.js +0 -137
- package/dist-server/service/shipping-order/shipping-order-types.js.map +0 -1
- package/dist-server/service/shipping-order/shipping-order.js +0 -165
- package/dist-server/service/shipping-order/shipping-order.js.map +0 -1
- package/dist-server/service/transfer-order/index.js +0 -25
- package/dist-server/service/transfer-order/index.js.map +0 -1
- package/dist-server/service/transfer-order/transfer-order-mutation.js +0 -252
- package/dist-server/service/transfer-order/transfer-order-mutation.js.map +0 -1
- package/dist-server/service/transfer-order/transfer-order-query.js +0 -104
- package/dist-server/service/transfer-order/transfer-order-query.js.map +0 -1
- package/dist-server/service/transfer-order/transfer-order-types.js +0 -148
- package/dist-server/service/transfer-order/transfer-order-types.js.map +0 -1
- package/dist-server/service/transfer-order/transfer-order.js +0 -146
- package/dist-server/service/transfer-order/transfer-order.js.map +0 -1
- package/dist-server/service/vas/index.js +0 -25
- package/dist-server/service/vas/index.js.map +0 -1
- package/dist-server/service/vas/vas-mutation.js +0 -562
- package/dist-server/service/vas/vas-mutation.js.map +0 -1
- package/dist-server/service/vas/vas-query.js +0 -114
- package/dist-server/service/vas/vas-query.js.map +0 -1
- package/dist-server/service/vas/vas-types.js +0 -113
- package/dist-server/service/vas/vas-types.js.map +0 -1
- package/dist-server/service/vas/vas.js +0 -114
- package/dist-server/service/vas/vas.js.map +0 -1
- package/dist-server/service/vas-order/index.js +0 -25
- package/dist-server/service/vas-order/index.js.map +0 -1
- package/dist-server/service/vas-order/vas-order-mutation.js +0 -241
- package/dist-server/service/vas-order/vas-order-mutation.js.map +0 -1
- package/dist-server/service/vas-order/vas-order-query.js +0 -151
- package/dist-server/service/vas-order/vas-order-query.js.map +0 -1
- package/dist-server/service/vas-order/vas-order-types.js +0 -83
- package/dist-server/service/vas-order/vas-order-types.js.map +0 -1
- package/dist-server/service/vas-order/vas-order.js +0 -104
- package/dist-server/service/vas-order/vas-order.js.map +0 -1
- package/dist-server/utils/datetime-util.js +0 -82
- package/dist-server/utils/datetime-util.js.map +0 -1
- package/dist-server/utils/index.js +0 -20
- package/dist-server/utils/index.js.map +0 -1
- package/dist-server/utils/inventory-util.js +0 -1098
- package/dist-server/utils/inventory-util.js.map +0 -1
- package/dist-server/utils/order-no-generator.js +0 -112
- package/dist-server/utils/order-no-generator.js.map +0 -1
|
@@ -1,1453 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
var _a;
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.editArrivalNoticeProducts = exports.addArrivalNoticeProducts = exports.rejectArrivalNotice = exports.checkArrivedNoticeFunction = exports.receiveArrivalNoticeFunction = exports.confirmArrivalNoticeFunction = exports.generateArrivalNoticeFunction = exports.deleteArrivalNotice = exports.ArrivalNoticeMutation = void 0;
|
|
20
|
-
const graphql_upload_1 = require("graphql-upload");
|
|
21
|
-
const type_graphql_1 = require("type-graphql");
|
|
22
|
-
const typeorm_1 = require("typeorm");
|
|
23
|
-
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
24
|
-
const auth_base_1 = require("@things-factory/auth-base");
|
|
25
|
-
const biz_base_1 = require("@things-factory/biz-base");
|
|
26
|
-
const id_rule_base_1 = require("@things-factory/id-rule-base");
|
|
27
|
-
const notification_1 = require("@things-factory/notification");
|
|
28
|
-
const product_base_1 = require("@things-factory/product-base");
|
|
29
|
-
const setting_base_1 = require("@things-factory/setting-base");
|
|
30
|
-
const constants_1 = require("../../constants");
|
|
31
|
-
const attachment_type_1 = require("../../constants/attachment-type");
|
|
32
|
-
const errors_1 = require("../../errors");
|
|
33
|
-
const order_no_generator_1 = require("../../utils/order-no-generator");
|
|
34
|
-
const collection_order_1 = require("../collection-order/collection-order");
|
|
35
|
-
const job_sheet_1 = require("../job-sheet/job-sheet");
|
|
36
|
-
const job_sheet_mutation_1 = require("../job-sheet/job-sheet-mutation");
|
|
37
|
-
const order_product_1 = require("../order-product/order-product");
|
|
38
|
-
const warehouse_base_1 = require("@things-factory/warehouse-base");
|
|
39
|
-
const order_product_types_1 = require("../order-product/order-product-types");
|
|
40
|
-
const order_vas_1 = require("../order-vas/order-vas");
|
|
41
|
-
const release_good_1 = require("../release-good/release-good");
|
|
42
|
-
const integration_base_1 = require("@things-factory/integration-base");
|
|
43
|
-
const release_good_mutation_1 = require("../release-good/release-good-mutation");
|
|
44
|
-
const vas_1 = require("../vas/vas");
|
|
45
|
-
const _1 = require("./");
|
|
46
|
-
const arrival_notice_1 = require("./arrival-notice");
|
|
47
|
-
const arrival_notice_types_1 = require("./arrival-notice-types");
|
|
48
|
-
const i18next_1 = __importDefault(require("i18next"));
|
|
49
|
-
const order_inventory_1 = require("../order-inventory/order-inventory");
|
|
50
|
-
const goods_receival_note_1 = require("../goods-receival-note/goods-receival-note");
|
|
51
|
-
const debug = require('debug')('things-factory:operato-wms:addArrivalNotice');
|
|
52
|
-
let ArrivalNoticeMutation = class ArrivalNoticeMutation {
|
|
53
|
-
async deleteArrivalNotice(name, context) {
|
|
54
|
-
const { tx, user, domain } = context.state;
|
|
55
|
-
return await deleteArrivalNotice(tx, name, user, domain);
|
|
56
|
-
}
|
|
57
|
-
async generateArrivalNotice(context, arrivalNotice, files) {
|
|
58
|
-
const { tx } = context.state;
|
|
59
|
-
const createdArrivalNotice = await generateArrivalNoticeFunction(null, arrivalNotice, false, files, context, tx);
|
|
60
|
-
(0, integration_base_1.webhookHandler)(createdArrivalNotice, createdArrivalNotice.bizplace, integration_base_1.WebhookEventsEnum.ArrivalNoticeCreated);
|
|
61
|
-
return createdArrivalNotice;
|
|
62
|
-
}
|
|
63
|
-
async confirmArrivalNotice(name, context) {
|
|
64
|
-
const { tx } = context.state;
|
|
65
|
-
const arrivalNotice = await confirmArrivalNoticeFunction(name, context, tx);
|
|
66
|
-
// If current has cross docking
|
|
67
|
-
if (arrivalNotice.crossDocking) {
|
|
68
|
-
const { releaseGood } = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne(arrivalNotice.id, {
|
|
69
|
-
relations: ['releaseGood']
|
|
70
|
-
});
|
|
71
|
-
// If status of related RO is not equal to PENDING_RECEIVE (i.e. Wasn't confirmed yet.)
|
|
72
|
-
if (releaseGood.status !== constants_1.ORDER_STATUS.PENDING_RECEIVE) {
|
|
73
|
-
await (0, release_good_mutation_1.confirmReleaseGood)(releaseGood.name, context);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
(0, integration_base_1.webhookHandler)(arrivalNotice, arrivalNotice.bizplace, integration_base_1.WebhookEventsEnum.ArrivalNoticeConfirmed);
|
|
77
|
-
return arrivalNotice;
|
|
78
|
-
}
|
|
79
|
-
async receiveArrivalNotice(name, context) {
|
|
80
|
-
const receiveArrivalNotice = await receiveArrivalNoticeFunction(null, name, context);
|
|
81
|
-
return receiveArrivalNotice;
|
|
82
|
-
}
|
|
83
|
-
async checkArrivedNotice(name, context) {
|
|
84
|
-
const { tx } = context.state;
|
|
85
|
-
return await checkArrivedNoticeFunction(name, context, tx);
|
|
86
|
-
}
|
|
87
|
-
async rejectArrivalNotice(name, patch, context) {
|
|
88
|
-
const { tx } = context.state;
|
|
89
|
-
const arrivalNotice = await rejectArrivalNotice(tx, name, patch.remark, context);
|
|
90
|
-
if (arrivalNotice.crossDocking) {
|
|
91
|
-
const { releaseGood } = await tx
|
|
92
|
-
.getRepository(arrival_notice_1.ArrivalNotice)
|
|
93
|
-
.findOne(arrivalNotice.id, {
|
|
94
|
-
relations: ['releaseGood']
|
|
95
|
-
});
|
|
96
|
-
if (releaseGood.status !== constants_1.ORDER_STATUS.REJECTED) {
|
|
97
|
-
await (0, release_good_mutation_1.rejectReleaseGood)(tx, releaseGood.name, patch.remark, context);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return arrivalNotice;
|
|
101
|
-
}
|
|
102
|
-
async submitDirectInboundArrivalNotice(context, arrivalNotice, files) {
|
|
103
|
-
const { user, domain, tx } = context.state;
|
|
104
|
-
let orderProducts = arrivalNotice.orderProducts;
|
|
105
|
-
let myBizplace;
|
|
106
|
-
if (arrivalNotice.customerBizplaceId) {
|
|
107
|
-
const permittedBizplaces = await (0, biz_base_1.getPermittedBizplaces)(domain, user);
|
|
108
|
-
let foundPermittedBizplace = permittedBizplaces.find(biz => biz.id == arrivalNotice.customerBizplaceId);
|
|
109
|
-
if (!foundPermittedBizplace)
|
|
110
|
-
throw new Error(`This user does not permitted for this company`);
|
|
111
|
-
myBizplace = { id: arrivalNotice.customerBizplaceId };
|
|
112
|
-
}
|
|
113
|
-
else if (arrivalNotice.partnerBizplaceId) {
|
|
114
|
-
const permittedBizplaces = await (0, biz_base_1.getPermittedBizplaces)(domain, user);
|
|
115
|
-
let foundPermittedBizplace = permittedBizplaces.find(biz => biz.id == arrivalNotice.partnerBizplaceId);
|
|
116
|
-
if (!foundPermittedBizplace)
|
|
117
|
-
throw new Error(`This user does not permitted for this company`);
|
|
118
|
-
myBizplace = { id: arrivalNotice.partnerBizplaceId };
|
|
119
|
-
}
|
|
120
|
-
else if (arrivalNotice.warehouseId)
|
|
121
|
-
myBizplace = await (0, biz_base_1.getOutletBizplace)(arrivalNotice.warehouseId);
|
|
122
|
-
else
|
|
123
|
-
myBizplace = await (0, biz_base_1.getMyBizplace)(domain, user);
|
|
124
|
-
let orderProductsMap = mergeDuplicateRow(orderProducts, ['product.id', 'location.id', 'batchId', 'expDate'], 'packQty');
|
|
125
|
-
orderProducts = [...orderProductsMap.values()];
|
|
126
|
-
const pendingArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).save(Object.assign(Object.assign({}, arrivalNotice), { name: order_no_generator_1.OrderNoGenerator.arrivalNotice(), domain, bizplace: myBizplace, status: constants_1.ORDER_STATUS.PENDING, creator: user, updater: user }));
|
|
127
|
-
const orderProductRepo = tx.getRepository(order_product_1.OrderProduct);
|
|
128
|
-
const pendingOrderProducts = orderProducts.map(op => {
|
|
129
|
-
var _a;
|
|
130
|
-
return ({
|
|
131
|
-
name: order_no_generator_1.OrderNoGenerator.orderProduct(),
|
|
132
|
-
product_id: op.product.id,
|
|
133
|
-
product_detail_id: op.productDetail.id,
|
|
134
|
-
batch_id: op.batchId,
|
|
135
|
-
batch_id_ref: op.batchIdRef,
|
|
136
|
-
packing_type: op.packingType,
|
|
137
|
-
packing_size: op.packingSize,
|
|
138
|
-
uom: op.uom,
|
|
139
|
-
uom_value: op.uomValue || 0,
|
|
140
|
-
pack_qty: op.packQty || 0,
|
|
141
|
-
total_uom_value: op.totalUomValue,
|
|
142
|
-
pallet_qty: op.palletQty,
|
|
143
|
-
pallet_id: op.palletId,
|
|
144
|
-
unit_price: op.unitPrice,
|
|
145
|
-
remark: op.remark,
|
|
146
|
-
manufacture_date: op.manufactureDate,
|
|
147
|
-
status: constants_1.ORDER_STATUS.PENDING,
|
|
148
|
-
adjusted_batch_id: op.adjustedBatchId,
|
|
149
|
-
adjusted_batch_id_ref: op.adjustedBatchIdRef,
|
|
150
|
-
adjusted_packing_type: op.adjustedPackingType,
|
|
151
|
-
adjusted_uom_value: op.adjustedUomValue,
|
|
152
|
-
adjusted_uom: op.adjustedUom,
|
|
153
|
-
adjusted_pack_qty: op.adjustedPackQty,
|
|
154
|
-
adjusted_total_uom_value: op.adjustedTotalUomValue,
|
|
155
|
-
adjusted_pallet_qty: op.adjustedPalletQty,
|
|
156
|
-
adjusted_unit_price: op.adjustedUnitPrice,
|
|
157
|
-
domain_id: domain.id,
|
|
158
|
-
bizplace_id: pendingArrivalNotice.bizplaceId || ((_a = pendingArrivalNotice.bizplace) === null || _a === void 0 ? void 0 : _a.id),
|
|
159
|
-
arrival_notice_id: pendingArrivalNotice.id,
|
|
160
|
-
creator_id: user.id,
|
|
161
|
-
updater_id: user.id,
|
|
162
|
-
warehouse_id: op.warehouse.id,
|
|
163
|
-
location_id: op.location.id,
|
|
164
|
-
exp_date: op.expDate
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
await orderProductRepo.query(`
|
|
168
|
-
INSERT INTO order_products (
|
|
169
|
-
"name", "product_detail_id", "product_id",
|
|
170
|
-
"batch_id", "batch_id_ref", "packing_type",
|
|
171
|
-
"packing_size", "uom", "uom_value",
|
|
172
|
-
"pack_qty", "total_uom_value", "pallet_qty",
|
|
173
|
-
"pallet_id", "unit_price", "remark",
|
|
174
|
-
"manufacture_date", "status", "adjusted_batch_id",
|
|
175
|
-
"adjusted_batch_id_ref", "adjusted_packing_type",
|
|
176
|
-
"adjusted_uom_value", "adjusted_uom",
|
|
177
|
-
"adjusted_pack_qty", "adjusted_total_uom_value",
|
|
178
|
-
"adjusted_pallet_qty", "adjusted_unit_price",
|
|
179
|
-
"domain_id", "bizplace_id", "arrival_notice_id",
|
|
180
|
-
"creator_id", "updater_id", "warehouse_id", "location_id", "exp_date"
|
|
181
|
-
)
|
|
182
|
-
SELECT
|
|
183
|
-
"name",
|
|
184
|
-
"product_detail_id",
|
|
185
|
-
"product_id",
|
|
186
|
-
"batch_id",
|
|
187
|
-
"batch_id_ref",
|
|
188
|
-
"packing_type",
|
|
189
|
-
"packing_size",
|
|
190
|
-
"uom",
|
|
191
|
-
"uom_value",
|
|
192
|
-
"pack_qty",
|
|
193
|
-
"total_uom_value",
|
|
194
|
-
"pallet_qty",
|
|
195
|
-
"pallet_id",
|
|
196
|
-
"unit_price",
|
|
197
|
-
"remark",
|
|
198
|
-
"manufacture_date",
|
|
199
|
-
"status",
|
|
200
|
-
"adjusted_batch_id",
|
|
201
|
-
"adjusted_batch_id_ref",
|
|
202
|
-
"adjusted_packing_type",
|
|
203
|
-
"adjusted_uom_value",
|
|
204
|
-
"adjusted_uom",
|
|
205
|
-
"adjusted_pack_qty",
|
|
206
|
-
"adjusted_total_uom_value",
|
|
207
|
-
"adjusted_pallet_qty",
|
|
208
|
-
"adjusted_unit_price",
|
|
209
|
-
"domain_id",
|
|
210
|
-
"bizplace_id",
|
|
211
|
-
"arrival_notice_id",
|
|
212
|
-
"creator_id",
|
|
213
|
-
"updater_id",
|
|
214
|
-
"warehouse_id",
|
|
215
|
-
"location_id",
|
|
216
|
-
"exp_date"
|
|
217
|
-
FROM
|
|
218
|
-
JSON_POPULATE_RECORDSET(NULL :: order_products, $1) op
|
|
219
|
-
`, [JSON.stringify(pendingOrderProducts)]);
|
|
220
|
-
return pendingArrivalNotice;
|
|
221
|
-
}
|
|
222
|
-
async confirmDirectInboundArrivalNotice(context, name) {
|
|
223
|
-
const { user, domain, tx } = context.state;
|
|
224
|
-
const pendingArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
225
|
-
where: { domain, name, status: constants_1.ORDER_STATUS.PENDING },
|
|
226
|
-
relations: [
|
|
227
|
-
'bizplace',
|
|
228
|
-
'bizplace.domain',
|
|
229
|
-
'releaseGood',
|
|
230
|
-
'orderProducts',
|
|
231
|
-
'orderProducts.product',
|
|
232
|
-
'orderVass',
|
|
233
|
-
'orderVass.vas',
|
|
234
|
-
'creator',
|
|
235
|
-
'updater'
|
|
236
|
-
]
|
|
237
|
-
});
|
|
238
|
-
if (!pendingArrivalNotice)
|
|
239
|
-
throw new Error(`Arrival notice doesn't exist.`);
|
|
240
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).update({ id: pendingArrivalNotice.id }, {
|
|
241
|
-
status: constants_1.ORDER_STATUS.DONE,
|
|
242
|
-
updater: user,
|
|
243
|
-
acceptedBy: user,
|
|
244
|
-
acceptedAt: new Date()
|
|
245
|
-
});
|
|
246
|
-
// find orderProducts tied to the arrival notice and assign inventory, inventory_histories, order_inventories
|
|
247
|
-
let pendingOrderProducts = await tx.getRepository(order_product_1.OrderProduct).find({
|
|
248
|
-
where: { arrivalNotice: { id: pendingArrivalNotice.id } },
|
|
249
|
-
relations: ['bizplace', 'domain', 'warehouse', 'location']
|
|
250
|
-
});
|
|
251
|
-
const inventoryRepo = tx.getRepository(warehouse_base_1.Inventory);
|
|
252
|
-
const opRepo = tx.getRepository(order_product_1.OrderProduct);
|
|
253
|
-
const inventoryHistoryRepo = tx.getRepository(warehouse_base_1.InventoryHistory);
|
|
254
|
-
const orderInventoryRepo = tx.getRepository(order_inventory_1.OrderInventory);
|
|
255
|
-
const inventories = [];
|
|
256
|
-
for (const op of pendingOrderProducts) {
|
|
257
|
-
const palletId = op.palletId ||
|
|
258
|
-
(await (0, id_rule_base_1.generateId)({ domain, type: warehouse_base_1.RULE_TYPE.LOT_NUMBER_ID, seed: { date: warehouse_base_1.DateGenerator.generateDate() } }));
|
|
259
|
-
const numericTotalUomValue = typeof op.totalUomValue === 'string' ? parseFloat(op.totalUomValue) : op.totalUomValue;
|
|
260
|
-
const cartonId = await (0, id_rule_base_1.generateId)({
|
|
261
|
-
domain,
|
|
262
|
-
type: warehouse_base_1.RULE_TYPE.CARTON_NUMBER_ID,
|
|
263
|
-
seed: { date: warehouse_base_1.DateGenerator.generateDate() }
|
|
264
|
-
});
|
|
265
|
-
const inventory = inventoryRepo.create({
|
|
266
|
-
domain,
|
|
267
|
-
bizplace: pendingArrivalNotice.bizplace,
|
|
268
|
-
name: warehouse_base_1.InventoryNoGenerator.inventoryName(),
|
|
269
|
-
cartonId: cartonId,
|
|
270
|
-
refOrderId: pendingArrivalNotice.id,
|
|
271
|
-
product: op.productId,
|
|
272
|
-
productDetail: op.productDetailId,
|
|
273
|
-
palletId,
|
|
274
|
-
packingType: op.packingType,
|
|
275
|
-
packingSize: op.packingSize,
|
|
276
|
-
batchId: op.batchId,
|
|
277
|
-
batchIdRef: op.batchIdRef,
|
|
278
|
-
expirationDate: op.expDate,
|
|
279
|
-
manufactureDate: op.manufactureDate,
|
|
280
|
-
uom: op.uom,
|
|
281
|
-
qty: op.packQty,
|
|
282
|
-
uomValue: numericTotalUomValue,
|
|
283
|
-
status: warehouse_base_1.INVENTORY_STATUS.STORED,
|
|
284
|
-
warehouse: op.warehouse,
|
|
285
|
-
zone: op.location.zone,
|
|
286
|
-
location: op.location,
|
|
287
|
-
creator: user,
|
|
288
|
-
updater: user
|
|
289
|
-
});
|
|
290
|
-
inventories.push(inventory);
|
|
291
|
-
op.status = constants_1.ORDER_PRODUCT_STATUS.STORED;
|
|
292
|
-
op.updater = user;
|
|
293
|
-
op.updatedAt = new Date();
|
|
294
|
-
op.actualPackQty = op.packQty;
|
|
295
|
-
await opRepo.save(op);
|
|
296
|
-
const newInventoryHistory = inventoryHistoryRepo.create({
|
|
297
|
-
name: warehouse_base_1.InventoryNoGenerator.inventoryHistoryName(),
|
|
298
|
-
refOrderId: pendingArrivalNotice.id,
|
|
299
|
-
orderNo: pendingArrivalNotice.name,
|
|
300
|
-
uom: inventory.uom,
|
|
301
|
-
transactionType: warehouse_base_1.INVENTORY_TRANSACTION_TYPE.NEW,
|
|
302
|
-
status: inventory.status,
|
|
303
|
-
qty: inventory.qty,
|
|
304
|
-
uomValue: inventory.uomValue,
|
|
305
|
-
openingQty: 0,
|
|
306
|
-
openingUomValue: 0,
|
|
307
|
-
seq: 0,
|
|
308
|
-
domain: inventory.domain,
|
|
309
|
-
bizplace: pendingArrivalNotice.bizplace,
|
|
310
|
-
inventory: inventory,
|
|
311
|
-
product: inventory.product,
|
|
312
|
-
productDetail: inventory.productDetail,
|
|
313
|
-
warehouse: inventory.warehouse,
|
|
314
|
-
location: inventory.location,
|
|
315
|
-
cartonId: inventory.cartonId,
|
|
316
|
-
palletId: inventory.palletId,
|
|
317
|
-
batchId: inventory.batchId,
|
|
318
|
-
zone: inventory.zone,
|
|
319
|
-
packingType: inventory.packingType,
|
|
320
|
-
description: inventory.description,
|
|
321
|
-
expirationDate: inventory.expirationDate,
|
|
322
|
-
unitCost: inventory.unitCost,
|
|
323
|
-
batchIdRef: inventory.batchIdRef,
|
|
324
|
-
manufactureDate: inventory.manufactureDate,
|
|
325
|
-
creator: user,
|
|
326
|
-
updater: user
|
|
327
|
-
});
|
|
328
|
-
await inventoryHistoryRepo.save(newInventoryHistory);
|
|
329
|
-
const orderInventory = orderInventoryRepo.create({
|
|
330
|
-
domain,
|
|
331
|
-
bizplace: inventory.bizplace,
|
|
332
|
-
name: order_no_generator_1.OrderNoGenerator.orderInventory(),
|
|
333
|
-
status: constants_1.ORDER_INVENTORY_STATUS.DONE,
|
|
334
|
-
batchId: inventory.batchId,
|
|
335
|
-
batchIdRef: inventory.batchIdRef,
|
|
336
|
-
packingType: inventory.packingType,
|
|
337
|
-
actualPackQty: inventory.qty,
|
|
338
|
-
actualPackUomValue: inventory.uomValue,
|
|
339
|
-
uom: inventory.uom,
|
|
340
|
-
product: inventory.product,
|
|
341
|
-
productDetail: inventory.productDetail,
|
|
342
|
-
unloadedBy: inventory.creator,
|
|
343
|
-
unloadedAt: inventory.createdAt,
|
|
344
|
-
putawayBy: inventory.creator,
|
|
345
|
-
putawayAt: inventory.createdAt,
|
|
346
|
-
type: constants_1.ORDER_TYPES.ARRIVAL_NOTICE,
|
|
347
|
-
arrivalNotice: pendingArrivalNotice,
|
|
348
|
-
inventory,
|
|
349
|
-
creator: user,
|
|
350
|
-
updater: user
|
|
351
|
-
});
|
|
352
|
-
await orderInventoryRepo.save(orderInventory);
|
|
353
|
-
}
|
|
354
|
-
await inventoryRepo.save(inventories);
|
|
355
|
-
const grnRepo = tx.getRepository(goods_receival_note_1.GoodsReceivalNote);
|
|
356
|
-
const orderNo = order_no_generator_1.OrderNoGenerator.goodsReceiveNote();
|
|
357
|
-
const grn = {
|
|
358
|
-
refNo: pendingArrivalNotice.name,
|
|
359
|
-
name: orderNo,
|
|
360
|
-
bizplace: pendingArrivalNotice.bizplace,
|
|
361
|
-
domain,
|
|
362
|
-
status: constants_1.GRN_STATUS.PENDING_RECEIVE,
|
|
363
|
-
creator: user,
|
|
364
|
-
updater: user,
|
|
365
|
-
arrivalNotice: pendingArrivalNotice
|
|
366
|
-
};
|
|
367
|
-
await grnRepo.save(grn);
|
|
368
|
-
return pendingArrivalNotice;
|
|
369
|
-
}
|
|
370
|
-
async addEditArrivalNoticeProducts(context, ganNo, approvedAddEditProducts, newOrderProducts, existingOrderProducts) {
|
|
371
|
-
var _a;
|
|
372
|
-
const { user, domain, tx } = context.state;
|
|
373
|
-
try {
|
|
374
|
-
let arrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
375
|
-
where: { name: ganNo },
|
|
376
|
-
relations: ['bizplace', 'orderProducts']
|
|
377
|
-
});
|
|
378
|
-
arrivalNotice.status = approvedAddEditProducts ? constants_1.ORDER_STATUS.PENDING : constants_1.ORDER_STATUS.PENDING_APPROVAL;
|
|
379
|
-
arrivalNotice.updater = user;
|
|
380
|
-
arrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).save(arrivalNotice);
|
|
381
|
-
//only for status GAN in 'PENDING'
|
|
382
|
-
//allow to add/edit products without approval from client
|
|
383
|
-
if (approvedAddEditProducts) {
|
|
384
|
-
if ((newOrderProducts === null || newOrderProducts === void 0 ? void 0 : newOrderProducts.length) > 0) {
|
|
385
|
-
let updatedNewOrderProducts = newOrderProducts.map(op => {
|
|
386
|
-
op.status = constants_1.ORDER_PRODUCT_STATUS.PENDING;
|
|
387
|
-
return op;
|
|
388
|
-
});
|
|
389
|
-
await addArrivalNoticeProducts(domain, arrivalNotice, updatedNewOrderProducts, user, tx);
|
|
390
|
-
}
|
|
391
|
-
for (const op of existingOrderProducts) {
|
|
392
|
-
await tx
|
|
393
|
-
.createQueryBuilder()
|
|
394
|
-
.update(order_product_1.OrderProduct)
|
|
395
|
-
.set({
|
|
396
|
-
batchId: op.batchId,
|
|
397
|
-
batchIdRef: op.batchIdRef,
|
|
398
|
-
expDate: op.expDate,
|
|
399
|
-
warehouse: op.warehouse ? { id: op.warehouse.id } : null,
|
|
400
|
-
location: op.location ? { id: op.location.id } : null,
|
|
401
|
-
manufactureDate: op.manufactureDate,
|
|
402
|
-
packQty: op.packQty,
|
|
403
|
-
packingType: op.packingType,
|
|
404
|
-
palletQty: op.palletQty,
|
|
405
|
-
palletId: op.palletId,
|
|
406
|
-
remark: op.remark,
|
|
407
|
-
totalUomValue: op.totalUomValue,
|
|
408
|
-
uom: op.uom,
|
|
409
|
-
uomValue: op.uomValue,
|
|
410
|
-
unitPrice: op.unitPrice,
|
|
411
|
-
updater: user
|
|
412
|
-
})
|
|
413
|
-
.where('id = :id', { id: op.id })
|
|
414
|
-
.andWhere('domain_id = :domainId', { domainId: domain.id })
|
|
415
|
-
.execute();
|
|
416
|
-
}
|
|
417
|
-
return true;
|
|
418
|
-
}
|
|
419
|
-
if ((newOrderProducts === null || newOrderProducts === void 0 ? void 0 : newOrderProducts.length) > 0)
|
|
420
|
-
await addArrivalNoticeProducts(domain, arrivalNotice, newOrderProducts, user, tx);
|
|
421
|
-
if ((existingOrderProducts === null || existingOrderProducts === void 0 ? void 0 : existingOrderProducts.length) > 0)
|
|
422
|
-
await editArrivalNoticeProducts(existingOrderProducts, user, tx);
|
|
423
|
-
// notification logics
|
|
424
|
-
const users = await (0, biz_base_1.getDomainUsers)(arrivalNotice === null || arrivalNotice === void 0 ? void 0 : arrivalNotice.bizplace, tx);
|
|
425
|
-
if ((users === null || users === void 0 ? void 0 : users.length) && ((_a = context.header) === null || _a === void 0 ? void 0 : _a.referer)) {
|
|
426
|
-
const receivers = users.map(user => user.id);
|
|
427
|
-
const msg = {
|
|
428
|
-
title: `Products are added/edited for ${arrivalNotice.name}`,
|
|
429
|
-
body: `Warehouse need your review for changes to be approved`,
|
|
430
|
-
url: context.header.referer,
|
|
431
|
-
data: { url: context.header.referer }
|
|
432
|
-
};
|
|
433
|
-
/**
|
|
434
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
435
|
-
*/
|
|
436
|
-
// await sendNotification({
|
|
437
|
-
// receivers,
|
|
438
|
-
// message: { ...msg }
|
|
439
|
-
// })
|
|
440
|
-
}
|
|
441
|
-
return true;
|
|
442
|
-
}
|
|
443
|
-
catch (error) {
|
|
444
|
-
throw new Error(error);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
async addArrivalNotice(context, arrivalNotice, file) {
|
|
448
|
-
const { tx } = context.state;
|
|
449
|
-
const createdGAN = await generateArrivalNoticeFunction(null, arrivalNotice, false, file, context, tx);
|
|
450
|
-
debug('createdGAN', createdGAN);
|
|
451
|
-
const confirmedGAN = await confirmArrivalNoticeFunction(createdGAN.name, context, tx);
|
|
452
|
-
debug('confirmedGAN', confirmedGAN);
|
|
453
|
-
return confirmedGAN;
|
|
454
|
-
}
|
|
455
|
-
async updateArrivalNoticeDetails(context, arrivalNotice) {
|
|
456
|
-
const { domain, tx } = context.state;
|
|
457
|
-
let existingArrivalNotice = await tx
|
|
458
|
-
.getRepository(arrival_notice_1.ArrivalNotice)
|
|
459
|
-
.findOne({ where: { name: arrivalNotice.name, domain } });
|
|
460
|
-
if (!existingArrivalNotice) {
|
|
461
|
-
throw new Error('Existing Arrival Notice not found.');
|
|
462
|
-
}
|
|
463
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).update(existingArrivalNotice.id, arrivalNotice);
|
|
464
|
-
const updatedArrivalNotice = await tx
|
|
465
|
-
.getRepository(arrival_notice_1.ArrivalNotice)
|
|
466
|
-
.findOne({ where: { id: existingArrivalNotice.id }, relations: ['bizplace', 'domain'] });
|
|
467
|
-
(0, integration_base_1.webhookHandler)(updatedArrivalNotice, updatedArrivalNotice.bizplace, integration_base_1.WebhookEventsEnum.ArrivalNoticeUpdated);
|
|
468
|
-
return updatedArrivalNotice;
|
|
469
|
-
}
|
|
470
|
-
async bulkGenerateArrivalNotices(context, rawArrivalNotices, bizplaceId, bufferLocation) {
|
|
471
|
-
const { domain, user, tx } = context.state;
|
|
472
|
-
let createdArrivalNoticeIds = [], createdOrderProductIds = [], errorsCaught = [], finalArrivalNoticeList = [];
|
|
473
|
-
let opStatus = constants_1.ORDER_PRODUCT_STATUS.PENDING_RECEIVE;
|
|
474
|
-
let anStatus = constants_1.ORDER_STATUS.PENDING_RECEIVE;
|
|
475
|
-
const foundBizplace = await tx
|
|
476
|
-
.getRepository(biz_base_1.Bizplace)
|
|
477
|
-
.findOne({ where: { id: bizplaceId }, relations: ['domain'] });
|
|
478
|
-
if (!foundBizplace)
|
|
479
|
-
throw new Error('company not found');
|
|
480
|
-
// to check whether the raw data are valid
|
|
481
|
-
const validatedArrivalNotices = await (0, _1.validateBulkArrivalNoticesFunction)(rawArrivalNotices, bizplaceId, domain, tx);
|
|
482
|
-
// check for custom GAN order no setting
|
|
483
|
-
const ganNoSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
484
|
-
where: {
|
|
485
|
-
domain,
|
|
486
|
-
name: constants_1.ORDER_NUMBER_SETTING_KEY.GAN_NUMBER_RULE
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
const ganProcessingSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
490
|
-
where: { domain, category: 'id-rule', name: 'gan-order-processing' }
|
|
491
|
-
});
|
|
492
|
-
const partnerGanProcessingSetting = await tx.getRepository(setting_base_1.PartnerSetting).findOne({
|
|
493
|
-
where: { setting: ganProcessingSetting, domain, partnerDomain: foundBizplace.domain.id }
|
|
494
|
-
});
|
|
495
|
-
// If status of GAN is PENDING_RECEIVE then directly to assign warehouse
|
|
496
|
-
if (ganProcessingSetting) {
|
|
497
|
-
let setting = !isNaN(partnerGanProcessingSetting === null || partnerGanProcessingSetting === void 0 ? void 0 : partnerGanProcessingSetting.value)
|
|
498
|
-
? partnerGanProcessingSetting === null || partnerGanProcessingSetting === void 0 ? void 0 : partnerGanProcessingSetting.value
|
|
499
|
-
: ganProcessingSetting.value;
|
|
500
|
-
// CONFIRM to assign if setting value is 1
|
|
501
|
-
if (setting == 1) {
|
|
502
|
-
opStatus = constants_1.ORDER_PRODUCT_STATUS.ARRIVED;
|
|
503
|
-
anStatus = constants_1.ORDER_STATUS.ARRIVED;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
// extract rawArrivalNotices data into normal ArrivalNotice format
|
|
507
|
-
let arrivalNotices = extractArrivalNotices(validatedArrivalNotices);
|
|
508
|
-
for (let i = 0, l = arrivalNotices.length; i < l; i++) {
|
|
509
|
-
try {
|
|
510
|
-
await (0, typeorm_1.getConnection)().transaction(async (childTx) => {
|
|
511
|
-
// check for duplication
|
|
512
|
-
const duplicatedArrivalNotice = await childTx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
513
|
-
where: {
|
|
514
|
-
refNo: arrivalNotices[i].refNo,
|
|
515
|
-
refNo2: arrivalNotices[i].refNo2,
|
|
516
|
-
refNo3: arrivalNotices[i].refNo3,
|
|
517
|
-
etaDate: arrivalNotices[i].etaDate,
|
|
518
|
-
truckNo: arrivalNotices[i].truckNo,
|
|
519
|
-
containerNo: arrivalNotices[i].containerNo,
|
|
520
|
-
containerSize: arrivalNotices[i].containerSize,
|
|
521
|
-
looseItem: arrivalNotices[i].looseItem,
|
|
522
|
-
importCargo: arrivalNotices[i].importCargo
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
if (duplicatedArrivalNotice) {
|
|
526
|
-
throw new Error(`duplicated with ${duplicatedArrivalNotice.name}`);
|
|
527
|
-
}
|
|
528
|
-
// save new arrival notice
|
|
529
|
-
const createdArrivalNotice = await childTx.getRepository(arrival_notice_1.ArrivalNotice).save(Object.assign(Object.assign({}, arrivalNotices[i]), { name: ganNoSetting
|
|
530
|
-
? await (0, id_rule_base_1.generateId)({ domain, type: constants_1.ORDER_NUMBER_RULE_TYPE.GAN_NUMBER, seed: {} })
|
|
531
|
-
: order_no_generator_1.OrderNoGenerator.arrivalNotice(), domain, bizplace: foundBizplace, status: constants_1.ORDER_STATUS.PENDING, creator: user, updater: user }));
|
|
532
|
-
// save new order products
|
|
533
|
-
let createdOrderProducts = await Promise.all(arrivalNotices[i].orderProducts.map(async (op) => {
|
|
534
|
-
return Object.assign(Object.assign({}, op), { domain, bizplace: foundBizplace, name: order_no_generator_1.OrderNoGenerator.orderProduct(), status: constants_1.ORDER_PRODUCT_STATUS.PENDING, arrivalNotice: createdArrivalNotice, creator: user });
|
|
535
|
-
}));
|
|
536
|
-
createdOrderProducts = await childTx.getRepository(order_product_1.OrderProduct).save(createdOrderProducts);
|
|
537
|
-
// generate new jobsheet
|
|
538
|
-
await (0, job_sheet_mutation_1.generateJobSheet)(domain, user, createdArrivalNotice, childTx);
|
|
539
|
-
// push arrivalNotice and orderProducts IDs if successfully saved
|
|
540
|
-
createdArrivalNoticeIds.push(createdArrivalNotice.id);
|
|
541
|
-
createdOrderProductIds.push(...createdOrderProducts.map(op => op.id));
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
catch (error) {
|
|
545
|
-
// collect the arrivalNotice details and its error
|
|
546
|
-
let rawArrivalNotices = formRawArrivalNotices(arrivalNotices[i], error.message);
|
|
547
|
-
errorsCaught.push(...rawArrivalNotices);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
if (createdArrivalNoticeIds.length && createdOrderProductIds.length) {
|
|
551
|
-
await (0, typeorm_1.getConnection)().transaction(async (childTx) => {
|
|
552
|
-
// update arrivalNotices status to PENDING_RECEIVE
|
|
553
|
-
await childTx
|
|
554
|
-
.getRepository(arrival_notice_1.ArrivalNotice)
|
|
555
|
-
.update({ id: (0, typeorm_1.In)(createdArrivalNoticeIds) }, { status: anStatus, updater: user });
|
|
556
|
-
// update orderProducts status to PENDING_RECEIVE
|
|
557
|
-
await childTx
|
|
558
|
-
.getRepository(order_product_1.OrderProduct)
|
|
559
|
-
.update({ id: (0, typeorm_1.In)(createdOrderProductIds) }, { status: opStatus, updater: user });
|
|
560
|
-
finalArrivalNoticeList = await childTx.getRepository(arrival_notice_1.ArrivalNotice).find({
|
|
561
|
-
where: { id: (0, typeorm_1.In)(createdArrivalNoticeIds) },
|
|
562
|
-
relations: ['orderProducts', 'orderProducts.product', 'bizplace']
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
if (errorsCaught.length) {
|
|
567
|
-
// should return this error list in the grist so that user know which gan need to amend
|
|
568
|
-
throw new errors_1.ValidationError(Object.assign(Object.assign({}, errors_1.ValidationError.ERROR_CODES.INVALID_DATA_FOUND), { detail: { data: JSON.stringify(errorsCaught) } }));
|
|
569
|
-
}
|
|
570
|
-
// return arrivalNotices with its orderProducts list
|
|
571
|
-
return { items: finalArrivalNoticeList, total: 0 };
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
__decorate([
|
|
575
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
576
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
577
|
-
(0, type_graphql_1.Mutation)(returns => Boolean),
|
|
578
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
579
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
580
|
-
__metadata("design:type", Function),
|
|
581
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
582
|
-
__metadata("design:returntype", Promise)
|
|
583
|
-
], ArrivalNoticeMutation.prototype, "deleteArrivalNotice", null);
|
|
584
|
-
__decorate([
|
|
585
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
586
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
587
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
588
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
589
|
-
__param(1, (0, type_graphql_1.Arg)('arrivalNotice', type => arrival_notice_types_1.NewArrivalNotice)),
|
|
590
|
-
__param(2, (0, type_graphql_1.Arg)('files', type => [graphql_upload_1.GraphQLUpload], { nullable: true })),
|
|
591
|
-
__metadata("design:type", Function),
|
|
592
|
-
__metadata("design:paramtypes", [Object, arrival_notice_types_1.NewArrivalNotice, Array]),
|
|
593
|
-
__metadata("design:returntype", Promise)
|
|
594
|
-
], ArrivalNoticeMutation.prototype, "generateArrivalNotice", null);
|
|
595
|
-
__decorate([
|
|
596
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
597
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
598
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
599
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
600
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
601
|
-
__metadata("design:type", Function),
|
|
602
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
603
|
-
__metadata("design:returntype", Promise)
|
|
604
|
-
], ArrivalNoticeMutation.prototype, "confirmArrivalNotice", null);
|
|
605
|
-
__decorate([
|
|
606
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_warehouse", privilege: "mutation")'),
|
|
607
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
608
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
609
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
610
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
611
|
-
__metadata("design:type", Function),
|
|
612
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
613
|
-
__metadata("design:returntype", Promise)
|
|
614
|
-
], ArrivalNoticeMutation.prototype, "receiveArrivalNotice", null);
|
|
615
|
-
__decorate([
|
|
616
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_warehouse", privilege: "mutation")'),
|
|
617
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
618
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
619
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
620
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
621
|
-
__metadata("design:type", Function),
|
|
622
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
623
|
-
__metadata("design:returntype", Promise)
|
|
624
|
-
], ArrivalNoticeMutation.prototype, "checkArrivedNotice", null);
|
|
625
|
-
__decorate([
|
|
626
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_warehouse", privilege: "mutation")'),
|
|
627
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
628
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
629
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
630
|
-
__param(1, (0, type_graphql_1.Arg)('patch', type => arrival_notice_types_1.ArrivalNoticePatch)),
|
|
631
|
-
__param(2, (0, type_graphql_1.Ctx)()),
|
|
632
|
-
__metadata("design:type", Function),
|
|
633
|
-
__metadata("design:paramtypes", [String, arrival_notice_types_1.ArrivalNoticePatch, Object]),
|
|
634
|
-
__metadata("design:returntype", Promise)
|
|
635
|
-
], ArrivalNoticeMutation.prototype, "rejectArrivalNotice", null);
|
|
636
|
-
__decorate([
|
|
637
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_warehouse", privilege: "mutation")'),
|
|
638
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
639
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
640
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
641
|
-
__param(1, (0, type_graphql_1.Arg)('arrivalNotice', type => arrival_notice_types_1.NewArrivalNotice)),
|
|
642
|
-
__param(2, (0, type_graphql_1.Arg)('files', type => [graphql_upload_1.GraphQLUpload], { nullable: true })),
|
|
643
|
-
__metadata("design:type", Function),
|
|
644
|
-
__metadata("design:paramtypes", [Object, arrival_notice_types_1.NewArrivalNotice, Array]),
|
|
645
|
-
__metadata("design:returntype", Promise)
|
|
646
|
-
], ArrivalNoticeMutation.prototype, "submitDirectInboundArrivalNotice", null);
|
|
647
|
-
__decorate([
|
|
648
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_warehouse", privilege: "mutation")'),
|
|
649
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
650
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
651
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
652
|
-
__param(1, (0, type_graphql_1.Arg)('name')),
|
|
653
|
-
__metadata("design:type", Function),
|
|
654
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
655
|
-
__metadata("design:returntype", Promise)
|
|
656
|
-
], ArrivalNoticeMutation.prototype, "confirmDirectInboundArrivalNotice", null);
|
|
657
|
-
__decorate([
|
|
658
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_warehouse", privilege: "mutation")'),
|
|
659
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
660
|
-
(0, type_graphql_1.Mutation)(returns => Boolean),
|
|
661
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
662
|
-
__param(1, (0, type_graphql_1.Arg)('ganNo')),
|
|
663
|
-
__param(2, (0, type_graphql_1.Arg)('approvedAddEditProducts', type => Boolean, { nullable: true })),
|
|
664
|
-
__param(3, (0, type_graphql_1.Arg)('newOrderProducts', type => [order_product_types_1.NewOrderProduct], { nullable: true })),
|
|
665
|
-
__param(4, (0, type_graphql_1.Arg)('existingOrderProducts', type => [order_product_types_1.OrderProductPatch], { nullable: true })),
|
|
666
|
-
__metadata("design:type", Function),
|
|
667
|
-
__metadata("design:paramtypes", [Object, String, Boolean, Array, Array]),
|
|
668
|
-
__metadata("design:returntype", Promise)
|
|
669
|
-
], ArrivalNoticeMutation.prototype, "addEditArrivalNoticeProducts", null);
|
|
670
|
-
__decorate([
|
|
671
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
672
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
673
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
674
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
675
|
-
__param(1, (0, type_graphql_1.Arg)('arrivalNotice', type => arrival_notice_types_1.NewArrivalNotice)),
|
|
676
|
-
__param(2, (0, type_graphql_1.Arg)('file', type => graphql_upload_1.GraphQLUpload, { nullable: true })),
|
|
677
|
-
__metadata("design:type", Function),
|
|
678
|
-
__metadata("design:paramtypes", [Object, arrival_notice_types_1.NewArrivalNotice, typeof (_a = typeof graphql_upload_1.FileUpload !== "undefined" && graphql_upload_1.FileUpload) === "function" ? _a : Object]),
|
|
679
|
-
__metadata("design:returntype", Promise)
|
|
680
|
-
], ArrivalNoticeMutation.prototype, "addArrivalNotice", null);
|
|
681
|
-
__decorate([
|
|
682
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
683
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
684
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_1.ArrivalNotice),
|
|
685
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
686
|
-
__param(1, (0, type_graphql_1.Arg)('arrivalNotice', type => arrival_notice_types_1.ArrivalNoticePatch)),
|
|
687
|
-
__metadata("design:type", Function),
|
|
688
|
-
__metadata("design:paramtypes", [Object, arrival_notice_types_1.ArrivalNoticePatch]),
|
|
689
|
-
__metadata("design:returntype", Promise)
|
|
690
|
-
], ArrivalNoticeMutation.prototype, "updateArrivalNoticeDetails", null);
|
|
691
|
-
__decorate([
|
|
692
|
-
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
693
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
694
|
-
(0, type_graphql_1.Mutation)(returns => arrival_notice_types_1.ArrivalNoticeList),
|
|
695
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
696
|
-
__param(1, (0, type_graphql_1.Arg)('rawArrivalNotices', type => [arrival_notice_types_1.NewArrivalNotice], { nullable: true })),
|
|
697
|
-
__param(2, (0, type_graphql_1.Arg)('bizplaceId', type => String)),
|
|
698
|
-
__param(3, (0, type_graphql_1.Arg)('bufferLocation', type => String, { nullable: true })),
|
|
699
|
-
__metadata("design:type", Function),
|
|
700
|
-
__metadata("design:paramtypes", [Object, Array, String, String]),
|
|
701
|
-
__metadata("design:returntype", Promise)
|
|
702
|
-
], ArrivalNoticeMutation.prototype, "bulkGenerateArrivalNotices", null);
|
|
703
|
-
ArrivalNoticeMutation = __decorate([
|
|
704
|
-
(0, type_graphql_1.Resolver)(arrival_notice_1.ArrivalNotice)
|
|
705
|
-
], ArrivalNoticeMutation);
|
|
706
|
-
exports.ArrivalNoticeMutation = ArrivalNoticeMutation;
|
|
707
|
-
async function deleteArrivalNotice(tx, name, user, domain) {
|
|
708
|
-
var _a;
|
|
709
|
-
try {
|
|
710
|
-
let foundArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
711
|
-
where: { domain, name },
|
|
712
|
-
relations: ['bizplace', 'releaseGood', 'orderProducts', 'orderVass', 'collectionOrders', 'creator', 'updater']
|
|
713
|
-
});
|
|
714
|
-
if (!foundArrivalNotice)
|
|
715
|
-
throw new Error(`Arrival notice doesn't exists.`);
|
|
716
|
-
const foundJS = await tx.getRepository(job_sheet_1.JobSheet).findOne({
|
|
717
|
-
where: {
|
|
718
|
-
bizplace: foundArrivalNotice.bizplace,
|
|
719
|
-
arrivalNoticeRefNo: foundArrivalNotice.name
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
if (foundJS) {
|
|
723
|
-
await tx
|
|
724
|
-
.getRepository(job_sheet_1.JobSheet)
|
|
725
|
-
.createQueryBuilder()
|
|
726
|
-
.delete()
|
|
727
|
-
.from(job_sheet_1.JobSheet)
|
|
728
|
-
.where('id = :id', { id: foundJS.id })
|
|
729
|
-
.execute();
|
|
730
|
-
}
|
|
731
|
-
const foundOPs = foundArrivalNotice.orderProducts;
|
|
732
|
-
const foundOVs = foundArrivalNotice.orderVass;
|
|
733
|
-
// 1. delete order products
|
|
734
|
-
await tx
|
|
735
|
-
.getRepository(order_product_1.OrderProduct)
|
|
736
|
-
.createQueryBuilder('op')
|
|
737
|
-
.delete()
|
|
738
|
-
.from(order_product_1.OrderProduct)
|
|
739
|
-
.where('arrival_notice_id = :arrivalNoticeId', { arrivalNoticeId: foundArrivalNotice.id })
|
|
740
|
-
.execute();
|
|
741
|
-
// 2. delete order vass
|
|
742
|
-
const vasIds = foundOVs.map((vas) => vas.id);
|
|
743
|
-
if (vasIds.length) {
|
|
744
|
-
await tx.getRepository(order_vas_1.OrderVas).delete({ id: (0, typeorm_1.In)(vasIds) });
|
|
745
|
-
}
|
|
746
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).save(Object.assign(Object.assign({}, foundArrivalNotice), { updater: user }));
|
|
747
|
-
// 4. Remove relation with RO if it's cross docking
|
|
748
|
-
if (foundArrivalNotice.crossDocking && ((_a = foundArrivalNotice.releaseGood) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
749
|
-
let releaseGood = foundArrivalNotice.releaseGood;
|
|
750
|
-
releaseGood.arrivalNotice = null;
|
|
751
|
-
releaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(releaseGood);
|
|
752
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).delete({ domain, name });
|
|
753
|
-
await (0, release_good_mutation_1.deleteReleaseGood)(tx, releaseGood.name, user, domain);
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
// 5. delete GAN
|
|
757
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).delete({ domain, name });
|
|
758
|
-
}
|
|
759
|
-
return true;
|
|
760
|
-
}
|
|
761
|
-
catch (e) {
|
|
762
|
-
console.log(e);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
exports.deleteArrivalNotice = deleteArrivalNotice;
|
|
766
|
-
async function generateArrivalNoticeFunction(_, arrivalNotice, fromPo, files, context, tx) {
|
|
767
|
-
const { domain, user } = context.state;
|
|
768
|
-
let orderProducts = arrivalNotice.orderProducts;
|
|
769
|
-
let orderVass = arrivalNotice.orderVass;
|
|
770
|
-
let myBizplace;
|
|
771
|
-
let orderNo = '';
|
|
772
|
-
const settingRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(setting_base_1.Setting)) || (0, typeorm_1.getRepository)(setting_base_1.Setting);
|
|
773
|
-
try {
|
|
774
|
-
if (arrivalNotice.bizplace)
|
|
775
|
-
myBizplace = arrivalNotice.bizplace;
|
|
776
|
-
else if (arrivalNotice.customerBizplaceId) {
|
|
777
|
-
const permittedBizplaces = await (0, biz_base_1.getPermittedBizplaces)(domain, user);
|
|
778
|
-
let foundPermittedBizplace = permittedBizplaces.find(biz => biz.id == arrivalNotice.customerBizplaceId);
|
|
779
|
-
if (!foundPermittedBizplace)
|
|
780
|
-
throw new Error(`This user does not permitted for this company`);
|
|
781
|
-
myBizplace = arrivalNotice.customerBizplaceId;
|
|
782
|
-
}
|
|
783
|
-
else if (arrivalNotice.partnerBizplaceId) {
|
|
784
|
-
const permittedBizplaces = await (0, biz_base_1.getPermittedBizplaces)(domain, user);
|
|
785
|
-
let foundPermittedBizplace = permittedBizplaces.find(biz => biz.id == arrivalNotice.partnerBizplaceId);
|
|
786
|
-
if (!foundPermittedBizplace)
|
|
787
|
-
throw new Error(`This user does not permitted for this company`);
|
|
788
|
-
myBizplace = arrivalNotice.partnerBizplaceId;
|
|
789
|
-
}
|
|
790
|
-
else if (arrivalNotice.warehouseId)
|
|
791
|
-
myBizplace = await (0, biz_base_1.getOutletBizplace)(arrivalNotice.warehouseId);
|
|
792
|
-
else
|
|
793
|
-
myBizplace = await (0, biz_base_1.getMyBizplace)(domain, user);
|
|
794
|
-
// Add validation for decimal quantities
|
|
795
|
-
for (let patch of orderProducts) {
|
|
796
|
-
// Get product details to check isInventoryDecimal
|
|
797
|
-
const product = (await tx.getRepository(product_base_1.Product).findOne({
|
|
798
|
-
where: { id: patch.product.id }
|
|
799
|
-
}));
|
|
800
|
-
if (!product) {
|
|
801
|
-
throw new Error(`Product not found for ID: ${patch.product.id}`);
|
|
802
|
-
}
|
|
803
|
-
// Validate packQty based on isInventoryDecimal flag
|
|
804
|
-
const validatePackQty = (qty) => {
|
|
805
|
-
if (qty === null || qty === undefined)
|
|
806
|
-
return true;
|
|
807
|
-
const numQty = Number(qty);
|
|
808
|
-
if (isNaN(numQty))
|
|
809
|
-
return false;
|
|
810
|
-
if (product.isInventoryDecimal) {
|
|
811
|
-
// For decimal products, check if decimal places <= 3
|
|
812
|
-
const decimalPlaces = (numQty.toString().split('.')[1] || '').length;
|
|
813
|
-
return decimalPlaces <= 3;
|
|
814
|
-
}
|
|
815
|
-
else {
|
|
816
|
-
// For non-decimal products, check if it's a whole number
|
|
817
|
-
return numQty === Math.floor(numQty);
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
// Validate only packQty
|
|
821
|
-
if (!validatePackQty(patch.packQty)) {
|
|
822
|
-
throw new Error(`Invalid pack quantity for product ${product.name} (SKU: ${product.sku}). ${product.isInventoryDecimal
|
|
823
|
-
? 'Decimal quantities must have at most 3 decimal places'
|
|
824
|
-
: 'Only whole numbers are allowed'}`);
|
|
825
|
-
}
|
|
826
|
-
// Check for existing LotID in Inventory
|
|
827
|
-
let foundInventoryPallet = await tx.getRepository(warehouse_base_1.Inventory).findOne({
|
|
828
|
-
where: {
|
|
829
|
-
domain,
|
|
830
|
-
palletId: patch.palletId
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
if (patch.palletId) {
|
|
834
|
-
// Check for existing LotID in OrderProduct
|
|
835
|
-
let foundOrderProductsPallet = await tx.getRepository(order_product_1.OrderProduct).find({
|
|
836
|
-
where: {
|
|
837
|
-
domain,
|
|
838
|
-
palletId: patch.palletId
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
// Check for existing LotID in ArrivalNotice
|
|
842
|
-
let arrivalNotices = await Promise.all(foundOrderProductsPallet.map(async (product) => {
|
|
843
|
-
return await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
844
|
-
where: {
|
|
845
|
-
id: product.arrivalNoticeId
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
}));
|
|
849
|
-
//Allow the reuse if PalletID if all the entered products has at least one of the conditions
|
|
850
|
-
let allProductsValid = foundOrderProductsPallet.every((product, index) => {
|
|
851
|
-
let arrivalNotice = arrivalNotices[index];
|
|
852
|
-
return (product.status === 'REJECTED' || product.issue || (arrivalNotice && arrivalNotice.status === 'CANCELLED'));
|
|
853
|
-
});
|
|
854
|
-
if (!allProductsValid || foundInventoryPallet) {
|
|
855
|
-
throw new Error(i18next_1.default.t('Lot ID is already in use. Please enter a new Lot ID.'));
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
// find GAN number rule setting
|
|
860
|
-
const ganNoSetting = await settingRepo.findOne({
|
|
861
|
-
where: {
|
|
862
|
-
domain,
|
|
863
|
-
name: constants_1.ORDER_NUMBER_SETTING_KEY.GAN_NUMBER_RULE
|
|
864
|
-
}
|
|
865
|
-
});
|
|
866
|
-
if (ganNoSetting) {
|
|
867
|
-
orderNo = await (0, id_rule_base_1.generateId)({ domain, type: constants_1.ORDER_NUMBER_RULE_TYPE.GAN_NUMBER, seed: {} });
|
|
868
|
-
}
|
|
869
|
-
else {
|
|
870
|
-
orderNo = order_no_generator_1.OrderNoGenerator.arrivalNotice();
|
|
871
|
-
}
|
|
872
|
-
// 1. Create arrival notice
|
|
873
|
-
const createdArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).save(Object.assign(Object.assign({}, arrivalNotice), { name: orderNo, domain, bizplace: myBizplace, looseItem: (arrivalNotice === null || arrivalNotice === void 0 ? void 0 : arrivalNotice.looseItem) ? arrivalNotice.looseItem : false, status: fromPo ? constants_1.ORDER_STATUS.INTRANSIT : constants_1.ORDER_STATUS.PENDING, creator: user, updater: user }));
|
|
874
|
-
// 2. Create arrival notice product
|
|
875
|
-
await addArrivalNoticeProducts(domain, createdArrivalNotice, orderProducts.map((op) => {
|
|
876
|
-
return Object.assign(Object.assign({}, op), { status: fromPo ? constants_1.ORDER_PRODUCT_STATUS.INTRANSIT : constants_1.ORDER_PRODUCT_STATUS.PENDING });
|
|
877
|
-
}), user, tx);
|
|
878
|
-
await (0, job_sheet_mutation_1.generateJobSheet)(domain, user, createdArrivalNotice, tx);
|
|
879
|
-
// 3. Create arrival notice vas
|
|
880
|
-
if (orderVass === null || orderVass === void 0 ? void 0 : orderVass.length) {
|
|
881
|
-
orderVass = await Promise.all(orderVass.map(async (ov) => {
|
|
882
|
-
if (ov.targetProduct) {
|
|
883
|
-
ov.targetProduct = await tx.getRepository(product_base_1.Product).findOne(ov.targetProduct.id);
|
|
884
|
-
}
|
|
885
|
-
return Object.assign(Object.assign({}, ov), { domain, bizplace: myBizplace, name: order_no_generator_1.OrderNoGenerator.orderVas(), vas: await tx.getRepository(vas_1.Vas).findOne({ domain, id: ov.vas.id }), type: constants_1.ORDER_TYPES.ARRIVAL_NOTICE, arrivalNotice: createdArrivalNotice, status: fromPo ? constants_1.ORDER_VAS_STATUS.INTRANSIT : constants_1.ORDER_VAS_STATUS.PENDING, creator: user, updater: user });
|
|
886
|
-
}));
|
|
887
|
-
await tx.getRepository(order_vas_1.OrderVas).save(orderVass);
|
|
888
|
-
}
|
|
889
|
-
if (files === null || files === void 0 ? void 0 : files.length) {
|
|
890
|
-
const attachments = files.map(attachment => {
|
|
891
|
-
return {
|
|
892
|
-
file: attachment,
|
|
893
|
-
refBy: createdArrivalNotice.id,
|
|
894
|
-
category: attachment_type_1.ATTACHMENT_TYPE.GAN
|
|
895
|
-
};
|
|
896
|
-
});
|
|
897
|
-
await (0, attachment_base_1.createAttachments)(_, { attachments }, context);
|
|
898
|
-
}
|
|
899
|
-
return createdArrivalNotice;
|
|
900
|
-
}
|
|
901
|
-
catch (error) {
|
|
902
|
-
throw new Error(error.message);
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
exports.generateArrivalNoticeFunction = generateArrivalNoticeFunction;
|
|
906
|
-
async function confirmArrivalNoticeFunction(name, context, tx) {
|
|
907
|
-
var _a, _b;
|
|
908
|
-
try {
|
|
909
|
-
const { user, domain } = context.state;
|
|
910
|
-
const foundArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
911
|
-
where: { domain, name, status: constants_1.ORDER_STATUS.PENDING },
|
|
912
|
-
relations: [
|
|
913
|
-
'bizplace',
|
|
914
|
-
'bizplace.domain',
|
|
915
|
-
'releaseGood',
|
|
916
|
-
'orderProducts',
|
|
917
|
-
'orderProducts.product',
|
|
918
|
-
'orderVass',
|
|
919
|
-
'orderVass.vas',
|
|
920
|
-
'creator',
|
|
921
|
-
'updater'
|
|
922
|
-
]
|
|
923
|
-
});
|
|
924
|
-
let foundOPs = foundArrivalNotice.orderProducts;
|
|
925
|
-
let foundOVs = foundArrivalNotice.orderVass;
|
|
926
|
-
let customerBizplace = foundArrivalNotice.bizplace;
|
|
927
|
-
let opStatus = constants_1.ORDER_PRODUCT_STATUS.PENDING_RECEIVE;
|
|
928
|
-
let anStatus = constants_1.ORDER_STATUS.PENDING_RECEIVE;
|
|
929
|
-
let ovStatus = constants_1.ORDER_VAS_STATUS.PENDING_RECEIVE;
|
|
930
|
-
let acceptedByUser = null;
|
|
931
|
-
let acceptedTime = null;
|
|
932
|
-
const ganProcessingSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
933
|
-
where: { domain, category: 'id-rule', name: 'gan-order-processing' }
|
|
934
|
-
});
|
|
935
|
-
const partnerGanProcessingSetting = await tx.getRepository(setting_base_1.PartnerSetting).findOne({
|
|
936
|
-
where: { setting: ganProcessingSetting, domain, partnerDomain: customerBizplace === null || customerBizplace === void 0 ? void 0 : customerBizplace.domain }
|
|
937
|
-
});
|
|
938
|
-
// If status of GAN is PENDING_RECEIVE then directly to assign warehouse
|
|
939
|
-
if (ganProcessingSetting) {
|
|
940
|
-
let setting = !isNaN(partnerGanProcessingSetting === null || partnerGanProcessingSetting === void 0 ? void 0 : partnerGanProcessingSetting.value)
|
|
941
|
-
? partnerGanProcessingSetting === null || partnerGanProcessingSetting === void 0 ? void 0 : partnerGanProcessingSetting.value
|
|
942
|
-
: ganProcessingSetting.value;
|
|
943
|
-
// CONFIRM to assign if setting value is 1
|
|
944
|
-
if (setting == 1) {
|
|
945
|
-
opStatus = constants_1.ORDER_PRODUCT_STATUS.ARRIVED;
|
|
946
|
-
anStatus = constants_1.ORDER_STATUS.ARRIVED;
|
|
947
|
-
ovStatus = constants_1.ORDER_VAS_STATUS.ARRIVED;
|
|
948
|
-
acceptedByUser = user;
|
|
949
|
-
acceptedTime = new Date();
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
if (!foundArrivalNotice)
|
|
953
|
-
throw new Error(`Arrival notice doesn't exists.`);
|
|
954
|
-
// 1. GAN Status change (PENDING => PENDING_RECEIVE)
|
|
955
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).update({ id: foundArrivalNotice.id }, {
|
|
956
|
-
status: anStatus,
|
|
957
|
-
updater: user,
|
|
958
|
-
acceptedBy: acceptedByUser,
|
|
959
|
-
acceptedAt: acceptedTime
|
|
960
|
-
});
|
|
961
|
-
let arrivalNotice = await tx
|
|
962
|
-
.getRepository(arrival_notice_1.ArrivalNotice)
|
|
963
|
-
.findOne({ where: { id: foundArrivalNotice.id }, relations: ['bizplace', 'domain'] });
|
|
964
|
-
await tx
|
|
965
|
-
.getRepository(order_product_1.OrderProduct)
|
|
966
|
-
.createQueryBuilder()
|
|
967
|
-
.update(order_product_1.OrderProduct)
|
|
968
|
-
.set({ status: opStatus })
|
|
969
|
-
.whereInIds(foundOPs.map(op => op.id))
|
|
970
|
-
.execute();
|
|
971
|
-
// 2. Update order vas status if it exists.
|
|
972
|
-
if (foundOVs && foundOVs.length) {
|
|
973
|
-
foundOVs = foundOVs.map((ov) => {
|
|
974
|
-
return Object.assign(Object.assign({}, ov), { status: ovStatus });
|
|
975
|
-
});
|
|
976
|
-
await tx.getRepository(order_vas_1.OrderVas).save(foundOVs);
|
|
977
|
-
}
|
|
978
|
-
// notification logics
|
|
979
|
-
// get Office Admin Users
|
|
980
|
-
if (((_a = context === null || context === void 0 ? void 0 : context.state) === null || _a === void 0 ? void 0 : _a.type) != 'api') {
|
|
981
|
-
const users = await tx
|
|
982
|
-
.getRepository('users_roles')
|
|
983
|
-
.createQueryBuilder('ur')
|
|
984
|
-
.select('ur.users_id', 'id')
|
|
985
|
-
.where(qb => {
|
|
986
|
-
const subQuery = qb
|
|
987
|
-
.subQuery()
|
|
988
|
-
.select('role.id')
|
|
989
|
-
.from(auth_base_1.Role, 'role')
|
|
990
|
-
.where("role.name = 'Office Admin'")
|
|
991
|
-
.andWhere('role.domain_id = :domain', { domain: domain.id })
|
|
992
|
-
.getQuery();
|
|
993
|
-
return 'ur.roles_id IN ' + subQuery;
|
|
994
|
-
})
|
|
995
|
-
.getRawMany();
|
|
996
|
-
// send notification to Office Admin Users
|
|
997
|
-
if ((users === null || users === void 0 ? void 0 : users.length) && ((_b = context.header) === null || _b === void 0 ? void 0 : _b.referer)) {
|
|
998
|
-
const receivers = users.map(user => user.id);
|
|
999
|
-
const msg = {
|
|
1000
|
-
title: `New Arrival Notice from ${customerBizplace.name}`,
|
|
1001
|
-
body: `New incoming order, ${foundArrivalNotice.name} is pending for receiving`,
|
|
1002
|
-
url: context.header.referer,
|
|
1003
|
-
data: { url: context.header.referer }
|
|
1004
|
-
};
|
|
1005
|
-
/**
|
|
1006
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
1007
|
-
*/
|
|
1008
|
-
(0, notification_1.sendNotification)({
|
|
1009
|
-
receivers,
|
|
1010
|
-
message: Object.assign({}, msg)
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
return arrivalNotice;
|
|
1015
|
-
}
|
|
1016
|
-
catch (e) {
|
|
1017
|
-
console.log(e);
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
exports.confirmArrivalNoticeFunction = confirmArrivalNoticeFunction;
|
|
1021
|
-
async function receiveArrivalNoticeFunction(_, name, context) {
|
|
1022
|
-
var _a;
|
|
1023
|
-
const { user, domain, tx } = context.state;
|
|
1024
|
-
try {
|
|
1025
|
-
const foundArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
1026
|
-
where: { domain, name, status: constants_1.ORDER_STATUS.PENDING_RECEIVE },
|
|
1027
|
-
relations: ['domain', 'bizplace', 'bizplace.domain', 'collectionOrders', 'orderProducts', 'orderVass']
|
|
1028
|
-
});
|
|
1029
|
-
let foundOPs = foundArrivalNotice.orderProducts;
|
|
1030
|
-
let foundOVs = foundArrivalNotice.orderVass;
|
|
1031
|
-
let foundCOs = await tx.getRepository(collection_order_1.CollectionOrder).find({
|
|
1032
|
-
where: { domain, refNo: foundArrivalNotice.name }
|
|
1033
|
-
});
|
|
1034
|
-
let customerBizplace = foundArrivalNotice.bizplace;
|
|
1035
|
-
let opStatus = constants_1.ORDER_PRODUCT_STATUS.INTRANSIT;
|
|
1036
|
-
let anStatus = constants_1.ORDER_STATUS.INTRANSIT;
|
|
1037
|
-
let ovStatus = constants_1.ORDER_VAS_STATUS.INTRANSIT;
|
|
1038
|
-
let coStatus = constants_1.ORDER_STATUS.READY_TO_DISPATCH;
|
|
1039
|
-
const ganProcessingSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
1040
|
-
where: { domain, category: 'id-rule', name: 'gan-order-processing' }
|
|
1041
|
-
});
|
|
1042
|
-
const partnerGanProcessingSetting = await tx.getRepository(setting_base_1.PartnerSetting).findOne({
|
|
1043
|
-
where: { setting: ganProcessingSetting, domain, partnerDomain: customerBizplace === null || customerBizplace === void 0 ? void 0 : customerBizplace.domain }
|
|
1044
|
-
});
|
|
1045
|
-
// If status of GAN is INTRANSIT then directly to assign warehouse
|
|
1046
|
-
if (ganProcessingSetting) {
|
|
1047
|
-
let setting = !isNaN(partnerGanProcessingSetting === null || partnerGanProcessingSetting === void 0 ? void 0 : partnerGanProcessingSetting.value)
|
|
1048
|
-
? partnerGanProcessingSetting === null || partnerGanProcessingSetting === void 0 ? void 0 : partnerGanProcessingSetting.value
|
|
1049
|
-
: ganProcessingSetting.value;
|
|
1050
|
-
// RECEIVE to assign if setting value is 2
|
|
1051
|
-
if (setting == 2) {
|
|
1052
|
-
opStatus = constants_1.ORDER_PRODUCT_STATUS.ARRIVED;
|
|
1053
|
-
anStatus = constants_1.ORDER_STATUS.ARRIVED;
|
|
1054
|
-
ovStatus = constants_1.ORDER_VAS_STATUS.ARRIVED;
|
|
1055
|
-
coStatus = constants_1.ORDER_STATUS.READY_TO_DISPATCH;
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
if (!foundArrivalNotice)
|
|
1059
|
-
throw new Error(`Arrival notice doesn't exists.`);
|
|
1060
|
-
// 1. Update status of order products (PENDING_RECEIVE => INTRANSIT)
|
|
1061
|
-
foundOPs = foundOPs.map((op) => {
|
|
1062
|
-
return Object.assign(Object.assign({}, op), { status: opStatus, updater: user });
|
|
1063
|
-
});
|
|
1064
|
-
await tx.getRepository(order_product_1.OrderProduct).save(foundOPs);
|
|
1065
|
-
// 2. Update status of order vass if it exists (PENDING_RECEIVE => INTRANSIT)
|
|
1066
|
-
if (foundOVs && foundOVs.length) {
|
|
1067
|
-
foundOVs = foundOVs.map((ov) => {
|
|
1068
|
-
return Object.assign(Object.assign({}, ov), { status: ovStatus, updater: user });
|
|
1069
|
-
});
|
|
1070
|
-
await tx.getRepository(order_vas_1.OrderVas).save(foundOVs);
|
|
1071
|
-
}
|
|
1072
|
-
// 3. If there's collection order, update status of collection order (PENDING_RECEIVE => READY_TO_DISPATCH)
|
|
1073
|
-
if (foundCOs) {
|
|
1074
|
-
foundCOs = foundCOs.map((co) => {
|
|
1075
|
-
return Object.assign(Object.assign({}, co), { status: coStatus, updater: user });
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
// notification logics
|
|
1079
|
-
const users = await (0, biz_base_1.getDomainUsers)(foundArrivalNotice === null || foundArrivalNotice === void 0 ? void 0 : foundArrivalNotice.bizplace, tx);
|
|
1080
|
-
// send notification to Customer Users
|
|
1081
|
-
if ((users === null || users === void 0 ? void 0 : users.length) && ((_a = context.header) === null || _a === void 0 ? void 0 : _a.referer)) {
|
|
1082
|
-
const receivers = users.map(user => user.id);
|
|
1083
|
-
const msg = {
|
|
1084
|
-
title: `Latest status for ${foundArrivalNotice.name}`,
|
|
1085
|
-
body: `Your GAN has been received and processed by ${domain.name}`,
|
|
1086
|
-
url: context.header.referer,
|
|
1087
|
-
data: { url: context.header.referer }
|
|
1088
|
-
};
|
|
1089
|
-
/**
|
|
1090
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
1091
|
-
*/
|
|
1092
|
-
// await sendNotification({
|
|
1093
|
-
// receivers,
|
|
1094
|
-
// message: { ...msg }
|
|
1095
|
-
// })
|
|
1096
|
-
}
|
|
1097
|
-
// 4. Update status of arrival notice (PENDING_RECEIVE => INTRANSIT)
|
|
1098
|
-
let rcvArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).save(Object.assign(Object.assign({}, foundArrivalNotice), { status: anStatus, acceptedBy: user, acceptedAt: new Date(), updater: user }));
|
|
1099
|
-
(0, integration_base_1.webhookHandler)(foundArrivalNotice, foundArrivalNotice.bizplace, integration_base_1.WebhookEventsEnum.ArrivalNoticeUpdated);
|
|
1100
|
-
return foundArrivalNotice;
|
|
1101
|
-
}
|
|
1102
|
-
catch (e) {
|
|
1103
|
-
throw e;
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
exports.receiveArrivalNoticeFunction = receiveArrivalNoticeFunction;
|
|
1107
|
-
async function checkArrivedNoticeFunction(name, context, tx) {
|
|
1108
|
-
var _a;
|
|
1109
|
-
const { user, domain } = context.state;
|
|
1110
|
-
try {
|
|
1111
|
-
const foundArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
1112
|
-
where: { domain, name, status: constants_1.ORDER_STATUS.INTRANSIT },
|
|
1113
|
-
relations: ['domain', 'bizplace', 'collectionOrders', 'orderProducts', 'orderVass']
|
|
1114
|
-
});
|
|
1115
|
-
debug('ganNo', name, foundArrivalNotice);
|
|
1116
|
-
if (!foundArrivalNotice)
|
|
1117
|
-
throw new Error(`Arrival notice doesn't exists.`);
|
|
1118
|
-
// 1. Check wheter related collection order is done or not
|
|
1119
|
-
const foundCOs = foundArrivalNotice.collectionOrders;
|
|
1120
|
-
if (foundCOs && foundCOs.length) {
|
|
1121
|
-
foundCOs.map((co) => {
|
|
1122
|
-
if (co.status !== constants_1.ORDER_STATUS.DONE) {
|
|
1123
|
-
throw new Error(`Collection Order: ${co.name} is not finished yet.`);
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
let foundOPs = foundArrivalNotice.orderProducts;
|
|
1128
|
-
let foundOVs = foundArrivalNotice.orderVass;
|
|
1129
|
-
// 2. Update status of order products (INTRANSIT => ARRIVED)
|
|
1130
|
-
foundOPs = foundOPs.map((op) => {
|
|
1131
|
-
return Object.assign(Object.assign({}, op), { status: constants_1.ORDER_PRODUCT_STATUS.ARRIVED, updater: user });
|
|
1132
|
-
});
|
|
1133
|
-
await tx.getRepository(order_product_1.OrderProduct).save(foundOPs);
|
|
1134
|
-
// 3. Update status of order vass if it exists (INTRANSIT => ARRIVED)
|
|
1135
|
-
if (foundOVs && foundOVs.length) {
|
|
1136
|
-
foundOVs = foundOVs.map((ov) => {
|
|
1137
|
-
return Object.assign(Object.assign({}, ov), { status: constants_1.ORDER_VAS_STATUS.ARRIVED, updater: user });
|
|
1138
|
-
});
|
|
1139
|
-
await tx.getRepository(order_vas_1.OrderVas).save(foundOVs);
|
|
1140
|
-
}
|
|
1141
|
-
// 4. Update status of arrival notice (INTRANSIT => ARRIVED)
|
|
1142
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).save(Object.assign(Object.assign({}, foundArrivalNotice), { status: constants_1.ORDER_STATUS.ARRIVED, updater: user }));
|
|
1143
|
-
(0, integration_base_1.webhookHandler)(foundArrivalNotice, foundArrivalNotice.bizplace, integration_base_1.WebhookEventsEnum.ArrivalNoticeUpdated);
|
|
1144
|
-
// notification logics
|
|
1145
|
-
const users = await (0, biz_base_1.getDomainUsers)(foundArrivalNotice === null || foundArrivalNotice === void 0 ? void 0 : foundArrivalNotice.bizplace, tx);
|
|
1146
|
-
if ((users === null || users === void 0 ? void 0 : users.length) && ((_a = context.header) === null || _a === void 0 ? void 0 : _a.referer)) {
|
|
1147
|
-
const receivers = users.map(user => user.id);
|
|
1148
|
-
const msg = {
|
|
1149
|
-
title: `Latest status for ${foundArrivalNotice.name}`,
|
|
1150
|
-
body: `Your goods has safely arrived at ${domain.name}`,
|
|
1151
|
-
url: context.header.referer,
|
|
1152
|
-
data: { url: context.header.referer }
|
|
1153
|
-
};
|
|
1154
|
-
/**
|
|
1155
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
1156
|
-
*/
|
|
1157
|
-
// await sendNotification({
|
|
1158
|
-
// receivers,
|
|
1159
|
-
// message: { ...msg }
|
|
1160
|
-
// })
|
|
1161
|
-
}
|
|
1162
|
-
return foundArrivalNotice;
|
|
1163
|
-
}
|
|
1164
|
-
catch (e) {
|
|
1165
|
-
throw e;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
exports.checkArrivedNoticeFunction = checkArrivedNoticeFunction;
|
|
1169
|
-
async function rejectArrivalNotice(tx, name, remark, context) {
|
|
1170
|
-
var _a;
|
|
1171
|
-
const { user, domain } = context.state;
|
|
1172
|
-
const foundArrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
1173
|
-
where: { domain, name, status: constants_1.ORDER_STATUS.PENDING_RECEIVE },
|
|
1174
|
-
relations: ['domain', 'bizplace', 'orderProducts', 'orderVass', 'collectionOrders']
|
|
1175
|
-
});
|
|
1176
|
-
if (!foundArrivalNotice)
|
|
1177
|
-
throw new Error(`Arrival notice doesn't exists.`);
|
|
1178
|
-
if (!remark)
|
|
1179
|
-
throw new Error('Remark is not exist.');
|
|
1180
|
-
let foundOPs = foundArrivalNotice.orderProducts;
|
|
1181
|
-
let foundOVs = foundArrivalNotice.orderVass;
|
|
1182
|
-
let foundCOs = foundArrivalNotice.collectionOrders;
|
|
1183
|
-
// 1. Update status of order products (PENDING_RECEIVE => REJECTED)
|
|
1184
|
-
foundOPs = foundOPs.map((op) => {
|
|
1185
|
-
op.status = constants_1.ORDER_PRODUCT_STATUS.REJECTED;
|
|
1186
|
-
op.updater = user;
|
|
1187
|
-
return op;
|
|
1188
|
-
});
|
|
1189
|
-
await tx.getRepository(order_product_1.OrderProduct).save(foundOPs);
|
|
1190
|
-
// 2. Update status of order vass if it exists (PENDING_RECEIVE => REJECTED)
|
|
1191
|
-
if (foundOVs && foundOVs.length) {
|
|
1192
|
-
foundOVs = foundOVs.map((ov) => {
|
|
1193
|
-
ov.status = constants_1.ORDER_VAS_STATUS.REJECTED;
|
|
1194
|
-
ov.updater = user;
|
|
1195
|
-
return ov;
|
|
1196
|
-
});
|
|
1197
|
-
await tx.getRepository(order_vas_1.OrderVas).save(foundOVs);
|
|
1198
|
-
}
|
|
1199
|
-
// 3. If there's collection order, update status of collection order (PENDING_RECEIVE => REJECTED)
|
|
1200
|
-
if (foundCOs) {
|
|
1201
|
-
foundCOs = foundCOs.map((co) => {
|
|
1202
|
-
co.status = constants_1.ORDER_STATUS.REJECTED;
|
|
1203
|
-
co.updater = user;
|
|
1204
|
-
return co;
|
|
1205
|
-
});
|
|
1206
|
-
await tx.getRepository(collection_order_1.CollectionOrder).save(foundCOs);
|
|
1207
|
-
}
|
|
1208
|
-
foundArrivalNotice.remark = remark;
|
|
1209
|
-
foundArrivalNotice.status = constants_1.ORDER_STATUS.REJECTED;
|
|
1210
|
-
foundArrivalNotice.updater = user;
|
|
1211
|
-
await tx.getRepository(arrival_notice_1.ArrivalNotice).save(foundArrivalNotice);
|
|
1212
|
-
(0, integration_base_1.webhookHandler)(foundArrivalNotice, foundArrivalNotice.bizplace, integration_base_1.WebhookEventsEnum.ArrivalNoticeUpdated);
|
|
1213
|
-
// notification logics
|
|
1214
|
-
const users = await (0, biz_base_1.getDomainUsers)(foundArrivalNotice === null || foundArrivalNotice === void 0 ? void 0 : foundArrivalNotice.bizplace, tx);
|
|
1215
|
-
// send notification to Customer Users
|
|
1216
|
-
if ((users === null || users === void 0 ? void 0 : users.length) && ((_a = context.header) === null || _a === void 0 ? void 0 : _a.referer)) {
|
|
1217
|
-
const receivers = users.map(user => user.id);
|
|
1218
|
-
const msg = {
|
|
1219
|
-
title: `Latest status for ${foundArrivalNotice.name}`,
|
|
1220
|
-
body: `Your GAN has been rejected.`,
|
|
1221
|
-
url: context.header.referer,
|
|
1222
|
-
data: { url: context.header.referer }
|
|
1223
|
-
};
|
|
1224
|
-
/**
|
|
1225
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
1226
|
-
*/
|
|
1227
|
-
// await sendNotification({
|
|
1228
|
-
// receivers,
|
|
1229
|
-
// message: { ...msg }
|
|
1230
|
-
// })
|
|
1231
|
-
}
|
|
1232
|
-
return foundArrivalNotice;
|
|
1233
|
-
}
|
|
1234
|
-
exports.rejectArrivalNotice = rejectArrivalNotice;
|
|
1235
|
-
async function addArrivalNoticeProducts(domain, arrivalNotice, newOrderProducts, user, tx) {
|
|
1236
|
-
var _a, _b, _c, _d, _e;
|
|
1237
|
-
const orderProductRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(order_product_1.OrderProduct)) || (0, typeorm_1.getRepository)(order_product_1.OrderProduct);
|
|
1238
|
-
if (!(arrivalNotice === null || arrivalNotice === void 0 ? void 0 : arrivalNotice.bizplace) || !((_a = arrivalNotice === null || arrivalNotice === void 0 ? void 0 : arrivalNotice.orderProducts) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1239
|
-
arrivalNotice = await tx.getRepository(arrival_notice_1.ArrivalNotice).findOne({
|
|
1240
|
-
where: { domain, name: arrivalNotice.name },
|
|
1241
|
-
relations: ['bizplace', 'orderProducts']
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
let createdOrderProducts = [];
|
|
1245
|
-
for (let index = 0; index < newOrderProducts.length; index++) {
|
|
1246
|
-
const op = newOrderProducts[index];
|
|
1247
|
-
createdOrderProducts.push({
|
|
1248
|
-
name: order_no_generator_1.OrderNoGenerator.orderProduct(),
|
|
1249
|
-
product_id: op.product.id,
|
|
1250
|
-
product_detail_id: op.productDetail.id,
|
|
1251
|
-
warehouse_id: ((_b = op.warehouse) === null || _b === void 0 ? void 0 : _b.id) || null,
|
|
1252
|
-
location_id: ((_c = op.location) === null || _c === void 0 ? void 0 : _c.id) || null,
|
|
1253
|
-
batch_id: op.batchId,
|
|
1254
|
-
batch_id_ref: op.batchIdRef,
|
|
1255
|
-
packing_type: op.packingType,
|
|
1256
|
-
packing_size: op.packingSize,
|
|
1257
|
-
uom: op.uom,
|
|
1258
|
-
uom_value: op.uomValue || 0,
|
|
1259
|
-
pack_qty: op.packQty || 0,
|
|
1260
|
-
total_uom_value: op.totalUomValue,
|
|
1261
|
-
pallet_qty: op.palletQty,
|
|
1262
|
-
pallet_id: op.palletId,
|
|
1263
|
-
unit_price: op.unitPrice,
|
|
1264
|
-
remark: op.remark,
|
|
1265
|
-
exp_date: (_d = op.expDate) !== null && _d !== void 0 ? _d : null,
|
|
1266
|
-
manufacture_date: op.manufactureDate,
|
|
1267
|
-
status: op.status,
|
|
1268
|
-
adjusted_batch_id: op.adjustedBatchId,
|
|
1269
|
-
adjusted_batch_id_ref: op.adjustedBatchIdRef,
|
|
1270
|
-
adjusted_packing_type: op.adjustedPackingType,
|
|
1271
|
-
adjusted_uom_value: op.adjustedUomValue,
|
|
1272
|
-
adjusted_uom: op.adjustedUom,
|
|
1273
|
-
adjusted_pack_qty: op.adjustedPackQty,
|
|
1274
|
-
adjusted_total_uom_value: op.adjustedTotalUomValue,
|
|
1275
|
-
adjusted_pallet_qty: op.adjustedPalletQty,
|
|
1276
|
-
adjusted_unit_price: op.adjustedUnitPrice,
|
|
1277
|
-
domain_id: domain.id,
|
|
1278
|
-
bizplace_id: (arrivalNotice === null || arrivalNotice === void 0 ? void 0 : arrivalNotice.bizplaceId) || ((_e = arrivalNotice === null || arrivalNotice === void 0 ? void 0 : arrivalNotice.bizplace) === null || _e === void 0 ? void 0 : _e.id) || (arrivalNotice === null || arrivalNotice === void 0 ? void 0 : arrivalNotice.bizplace),
|
|
1279
|
-
arrival_notice_id: arrivalNotice.id,
|
|
1280
|
-
creator_id: user.id,
|
|
1281
|
-
updater_id: user.id
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
|
-
await orderProductRepo.query(`
|
|
1285
|
-
INSERT INTO order_products (
|
|
1286
|
-
"name", "product_detail_id", "product_id",
|
|
1287
|
-
"warehouse_id", "location_id",
|
|
1288
|
-
"batch_id", "batch_id_ref", "packing_type",
|
|
1289
|
-
"packing_size", "uom", "uom_value",
|
|
1290
|
-
"pack_qty", "total_uom_value", "pallet_qty",
|
|
1291
|
-
"pallet_id", "unit_price", "remark",
|
|
1292
|
-
"exp_date",
|
|
1293
|
-
"manufacture_date", "status", "adjusted_batch_id",
|
|
1294
|
-
"adjusted_batch_id_ref", "adjusted_packing_type",
|
|
1295
|
-
"adjusted_uom_value", "adjusted_uom",
|
|
1296
|
-
"adjusted_pack_qty", "adjusted_total_uom_value",
|
|
1297
|
-
"adjusted_pallet_qty", "adjusted_unit_price",
|
|
1298
|
-
"domain_id", "bizplace_id", "arrival_notice_id",
|
|
1299
|
-
"creator_id", "updater_id"
|
|
1300
|
-
)
|
|
1301
|
-
SELECT
|
|
1302
|
-
"name",
|
|
1303
|
-
"product_detail_id",
|
|
1304
|
-
"product_id",
|
|
1305
|
-
"warehouse_id",
|
|
1306
|
-
"location_id",
|
|
1307
|
-
"batch_id",
|
|
1308
|
-
"batch_id_ref",
|
|
1309
|
-
"packing_type",
|
|
1310
|
-
"packing_size",
|
|
1311
|
-
"uom",
|
|
1312
|
-
"uom_value",
|
|
1313
|
-
"pack_qty",
|
|
1314
|
-
"total_uom_value",
|
|
1315
|
-
"pallet_qty",
|
|
1316
|
-
"pallet_id",
|
|
1317
|
-
"unit_price",
|
|
1318
|
-
"remark",
|
|
1319
|
-
"exp_date",
|
|
1320
|
-
"manufacture_date",
|
|
1321
|
-
"status",
|
|
1322
|
-
"adjusted_batch_id",
|
|
1323
|
-
"adjusted_batch_id_ref",
|
|
1324
|
-
"adjusted_packing_type",
|
|
1325
|
-
"adjusted_uom_value",
|
|
1326
|
-
"adjusted_uom",
|
|
1327
|
-
"adjusted_pack_qty",
|
|
1328
|
-
"adjusted_total_uom_value",
|
|
1329
|
-
"adjusted_pallet_qty",
|
|
1330
|
-
"adjusted_unit_price",
|
|
1331
|
-
"domain_id",
|
|
1332
|
-
"bizplace_id",
|
|
1333
|
-
"arrival_notice_id",
|
|
1334
|
-
"creator_id",
|
|
1335
|
-
"updater_id"
|
|
1336
|
-
FROM
|
|
1337
|
-
JSON_POPULATE_RECORDSET(NULL :: order_products, $1) op
|
|
1338
|
-
`, [JSON.stringify(createdOrderProducts)]);
|
|
1339
|
-
}
|
|
1340
|
-
exports.addArrivalNoticeProducts = addArrivalNoticeProducts;
|
|
1341
|
-
async function editArrivalNoticeProducts(existingOrderProducts, user, tx) {
|
|
1342
|
-
const orderProductRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(order_product_1.OrderProduct)) || (0, typeorm_1.getRepository)(order_product_1.OrderProduct);
|
|
1343
|
-
const updatedOrderProducts = await Promise.all(existingOrderProducts.map(async (op) => {
|
|
1344
|
-
return Object.assign(Object.assign({}, op), { status: constants_1.ORDER_PRODUCT_STATUS.EDITED, updater: user });
|
|
1345
|
-
}));
|
|
1346
|
-
debug('gan-updated-order-products', updatedOrderProducts);
|
|
1347
|
-
await orderProductRepo.save(updatedOrderProducts);
|
|
1348
|
-
}
|
|
1349
|
-
exports.editArrivalNoticeProducts = editArrivalNoticeProducts;
|
|
1350
|
-
function extractArrivalNotices(rawArrivalNotices) {
|
|
1351
|
-
return rawArrivalNotices.reduce((arrivalNotices, raw) => {
|
|
1352
|
-
// discard the item that has no productId or productDetailId
|
|
1353
|
-
if (!raw.productId || !raw.productDetailId)
|
|
1354
|
-
return;
|
|
1355
|
-
const idx = arrivalNotices.findIndex(an => {
|
|
1356
|
-
// consider these attributes if they are exist in "item"
|
|
1357
|
-
const comparison = [
|
|
1358
|
-
'refNo2',
|
|
1359
|
-
'refNo3',
|
|
1360
|
-
'truckNo',
|
|
1361
|
-
'ownTransport',
|
|
1362
|
-
'container',
|
|
1363
|
-
'containerNo',
|
|
1364
|
-
'containerSize',
|
|
1365
|
-
'looseItem',
|
|
1366
|
-
'importCargo'
|
|
1367
|
-
];
|
|
1368
|
-
let a = {}, b = {};
|
|
1369
|
-
comparison.forEach(cc => {
|
|
1370
|
-
if (raw[cc] !== null) {
|
|
1371
|
-
a[cc] = raw[cc];
|
|
1372
|
-
b[cc] = an[cc];
|
|
1373
|
-
}
|
|
1374
|
-
});
|
|
1375
|
-
a = JSON.stringify(Object.fromEntries(Object.entries(a).sort()));
|
|
1376
|
-
b = JSON.stringify(Object.fromEntries(Object.entries(b).sort()));
|
|
1377
|
-
return an.refNo == raw.refNo && an.etaDate == raw.etaDate && a === b;
|
|
1378
|
-
});
|
|
1379
|
-
const product = Object.assign(new product_base_1.Product(), { id: raw.productId, sku: raw.sku });
|
|
1380
|
-
const productDetail = Object.assign(new product_base_1.ProductDetail(), { id: raw.productDetailId });
|
|
1381
|
-
const orderProduct = {
|
|
1382
|
-
product,
|
|
1383
|
-
productDetail,
|
|
1384
|
-
batchId: raw.batchId,
|
|
1385
|
-
batchIdRef: raw.batchIdRef,
|
|
1386
|
-
packingType: raw.packingType,
|
|
1387
|
-
packingSize: raw.packingSize,
|
|
1388
|
-
packQty: raw.packQty,
|
|
1389
|
-
uomValue: raw.uomValue,
|
|
1390
|
-
uom: raw.uom,
|
|
1391
|
-
totalUomValue: raw.totalUomValue,
|
|
1392
|
-
palletQty: raw.palletQty,
|
|
1393
|
-
palletId: raw.palletId,
|
|
1394
|
-
unitPrice: raw.unitPrice,
|
|
1395
|
-
manufactureDate: raw.manufactureDate
|
|
1396
|
-
};
|
|
1397
|
-
if (idx >= 0) {
|
|
1398
|
-
const duplicateSkuIdx = arrivalNotices[idx].orderProducts.findIndex(op => op.sku === raw.sku &&
|
|
1399
|
-
op.packingType === raw.packingType &&
|
|
1400
|
-
op.packingSize === raw.packingSize &&
|
|
1401
|
-
op.batchId === raw.batchId);
|
|
1402
|
-
if (duplicateSkuIdx >= 0)
|
|
1403
|
-
arrivalNotices[idx].orderProducts[duplicateSkuIdx].packQty += raw.packQty;
|
|
1404
|
-
else
|
|
1405
|
-
arrivalNotices[idx].orderProducts.push(orderProduct);
|
|
1406
|
-
}
|
|
1407
|
-
else {
|
|
1408
|
-
arrivalNotices.push({
|
|
1409
|
-
refNo: raw.refNo,
|
|
1410
|
-
refNo2: raw.refNo2,
|
|
1411
|
-
refNo3: raw.refNo3,
|
|
1412
|
-
etaDate: raw.etaDate,
|
|
1413
|
-
truckNo: raw.truckNo,
|
|
1414
|
-
ownTransport: raw.ownTransport,
|
|
1415
|
-
container: raw.container,
|
|
1416
|
-
containerNo: raw.containerNo,
|
|
1417
|
-
containerSize: raw.containerSize,
|
|
1418
|
-
importCargo: raw.importCargo,
|
|
1419
|
-
looseItem: raw.looseItem,
|
|
1420
|
-
orderProducts: [orderProduct]
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
return arrivalNotices;
|
|
1424
|
-
}, []);
|
|
1425
|
-
}
|
|
1426
|
-
function formRawArrivalNotices(arrivalNotice, errorMsg) {
|
|
1427
|
-
let rawArrivalNotices = [];
|
|
1428
|
-
for (let i = 0, l = arrivalNotice.orderProducts.length; i < l; i++) {
|
|
1429
|
-
let rawArrivalNotice = Object.assign(Object.assign(Object.assign({}, arrivalNotice), arrivalNotice.orderProducts[i]), { sku: arrivalNotice.orderProducts[i].product.sku, errorMsg });
|
|
1430
|
-
delete rawArrivalNotice.orderProducts;
|
|
1431
|
-
delete rawArrivalNotice.product;
|
|
1432
|
-
rawArrivalNotices.push(rawArrivalNotice);
|
|
1433
|
-
}
|
|
1434
|
-
return rawArrivalNotices;
|
|
1435
|
-
}
|
|
1436
|
-
function mergeDuplicateRow(arr, groupByKey, qty) {
|
|
1437
|
-
return arr.reduce((acc, currentItem) => {
|
|
1438
|
-
const getNestedValue = (obj, path) => {
|
|
1439
|
-
return path.split('.').reduce((o, p) => (o ? o[p] : undefined), obj);
|
|
1440
|
-
};
|
|
1441
|
-
const compositeKey = groupByKey.map(key => getNestedValue(currentItem, key)).join('::');
|
|
1442
|
-
if (acc.has(compositeKey)) {
|
|
1443
|
-
const existingItem = acc.get(compositeKey);
|
|
1444
|
-
existingItem[qty] = parseFloat(existingItem[qty]) + parseFloat(currentItem[qty]);
|
|
1445
|
-
existingItem['palletQty'] = parseFloat(existingItem['palletQty']) + parseFloat(currentItem['palletQty']);
|
|
1446
|
-
existingItem['totalUomValue'] = (parseFloat(existingItem['totalUomValue']) + parseFloat(currentItem['totalUomValue'])).toString();
|
|
1447
|
-
}
|
|
1448
|
-
else
|
|
1449
|
-
acc.set(compositeKey, Object.assign({}, currentItem));
|
|
1450
|
-
return acc;
|
|
1451
|
-
}, new Map());
|
|
1452
|
-
}
|
|
1453
|
-
//# sourceMappingURL=arrival-notice-mutation.js.map
|