@things-factory/operato-hub 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/config.development.js +20 -12
- package/openapi/v1/inbound.yaml +12 -1
- package/openapi/v1/outbound.yaml +11 -1
- package/openapi/v1/upload-attachments.yaml +83 -0
- package/package.json +45 -45
- package/server/routers/api/restful-apis/v1/middlewares/validation-middleware.ts +95 -0
- package/server/routers/api/restful-apis/v1/utils/params.ts +7 -3
- package/server/routers/api/restful-apis/v1/warehouse/add-inbound-order.ts +22 -2
- package/server/routers/api/restful-apis/v1/warehouse/add-release-order.ts +23 -2
- package/server/routers/api/restful-apis/v1/warehouse/index.ts +2 -1
- package/server/routers/api/restful-apis/v1/warehouse/upload-attachments.ts +113 -0
- package/dist-server/controllers/bizplace-initializer/codes.js +0 -21
- package/dist-server/controllers/bizplace-initializer/codes.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/dataset/codes.js +0 -403
- package/dist-server/controllers/bizplace-initializer/dataset/codes.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/dataset/groups.js +0 -24
- package/dist-server/controllers/bizplace-initializer/dataset/groups.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/dataset/index.js +0 -22
- package/dist-server/controllers/bizplace-initializer/dataset/index.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/dataset/menus.js +0 -504
- package/dist-server/controllers/bizplace-initializer/dataset/menus.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/dataset/roles-privileges.js +0 -406
- package/dist-server/controllers/bizplace-initializer/dataset/roles-privileges.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/dataset/settings.js +0 -112
- package/dist-server/controllers/bizplace-initializer/dataset/settings.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain-roles.js +0 -26
- package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain-roles.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain.js +0 -43
- package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/groups.js +0 -18
- package/dist-server/controllers/bizplace-initializer/groups.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/index.js +0 -22
- package/dist-server/controllers/bizplace-initializer/index.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/menus.js +0 -28
- package/dist-server/controllers/bizplace-initializer/menus.js.map +0 -1
- package/dist-server/controllers/bizplace-initializer/settings.js +0 -16
- package/dist-server/controllers/bizplace-initializer/settings.js.map +0 -1
- package/dist-server/controllers/company-initializer/business-register.js +0 -48
- package/dist-server/controllers/company-initializer/business-register.js.map +0 -1
- package/dist-server/controllers/company-initializer/codes.js +0 -137
- package/dist-server/controllers/company-initializer/codes.js.map +0 -1
- package/dist-server/controllers/company-initializer/generate-company-roles.js +0 -117
- package/dist-server/controllers/company-initializer/generate-company-roles.js.map +0 -1
- package/dist-server/controllers/company-initializer/index.js +0 -23
- package/dist-server/controllers/company-initializer/index.js.map +0 -1
- package/dist-server/controllers/company-initializer/menus.js +0 -348
- package/dist-server/controllers/company-initializer/menus.js.map +0 -1
- package/dist-server/controllers/company-initializer/settings.js +0 -36
- package/dist-server/controllers/company-initializer/settings.js.map +0 -1
- package/dist-server/controllers/company-initializer/transporter.js +0 -18
- package/dist-server/controllers/company-initializer/transporter.js.map +0 -1
- package/dist-server/controllers/index.js +0 -1
- package/dist-server/controllers/index.js.map +0 -1
- package/dist-server/controllers/invitation.js +0 -118
- package/dist-server/controllers/invitation.js.map +0 -1
- package/dist-server/controllers/utils/make-invitation-token.js +0 -12
- package/dist-server/controllers/utils/make-invitation-token.js.map +0 -1
- package/dist-server/controllers/utils/save-invitation-token.js +0 -13
- package/dist-server/controllers/utils/save-invitation-token.js.map +0 -1
- package/dist-server/entities/email-attachment.js +0 -81
- package/dist-server/entities/email-attachment.js.map +0 -1
- package/dist-server/entities/email-recipient.js +0 -69
- package/dist-server/entities/email-recipient.js.map +0 -1
- package/dist-server/entities/email.js +0 -98
- package/dist-server/entities/email.js.map +0 -1
- package/dist-server/entities/index.js +0 -11
- package/dist-server/entities/index.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 -14
- package/dist-server/errors/validation-error.js.map +0 -1
- package/dist-server/graphql/index.js +0 -33
- package/dist-server/graphql/index.js.map +0 -1
- package/dist-server/graphql/resolvers/email/index.js +0 -6
- package/dist-server/graphql/resolvers/email/index.js.map +0 -1
- package/dist-server/graphql/resolvers/email/send-emails.js +0 -263
- package/dist-server/graphql/resolvers/email/send-emails.js.map +0 -1
- package/dist-server/graphql/resolvers/generators/generate-bizplace.js +0 -39
- package/dist-server/graphql/resolvers/generators/generate-bizplace.js.map +0 -1
- package/dist-server/graphql/resolvers/generators/generate-company.js +0 -62
- package/dist-server/graphql/resolvers/generators/generate-company.js.map +0 -1
- package/dist-server/graphql/resolvers/generators/index.js +0 -8
- package/dist-server/graphql/resolvers/generators/index.js.map +0 -1
- package/dist-server/graphql/resolvers/generators/update-domain-extType.js +0 -45
- package/dist-server/graphql/resolvers/generators/update-domain-extType.js.map +0 -1
- package/dist-server/graphql/resolvers/index.js +0 -35
- package/dist-server/graphql/resolvers/index.js.map +0 -1
- package/dist-server/graphql/resolvers/invitations/index.js +0 -6
- package/dist-server/graphql/resolvers/invitations/index.js.map +0 -1
- package/dist-server/graphql/resolvers/invitations/partner-invitation.js +0 -52
- package/dist-server/graphql/resolvers/invitations/partner-invitation.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2/company-roles-by-scope.js +0 -30
- package/dist-server/graphql/resolvers/oauth2/company-roles-by-scope.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2/index.js +0 -6
- package/dist-server/graphql/resolvers/oauth2/index.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/admiral-asn-report.js +0 -127
- package/dist-server/graphql/resolvers/reports/admiral-asn-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/asn-report.js +0 -126
- package/dist-server/graphql/resolvers/reports/asn-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/custom/elccl/aging-report.js +0 -157
- package/dist-server/graphql/resolvers/reports/custom/elccl/aging-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/custom/elccl/custom-elccl-fn-dispatch-report.js +0 -74
- package/dist-server/graphql/resolvers/reports/custom/elccl/custom-elccl-fn-dispatch-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/custom/elccl/custom-elccl-fn-monthly-dispatch-report.js +0 -99
- package/dist-server/graphql/resolvers/reports/custom/elccl/custom-elccl-fn-monthly-dispatch-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/custom/elccl/export-report.js +0 -156
- package/dist-server/graphql/resolvers/reports/custom/elccl/export-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/custom/posmy/custom-posmy-aging-report.js +0 -131
- package/dist-server/graphql/resolvers/reports/custom/posmy/custom-posmy-aging-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/custom/yltc/custom-yltc-inventory-report.js +0 -216
- package/dist-server/graphql/resolvers/reports/custom/yltc/custom-yltc-inventory-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js +0 -189
- package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/index.js +0 -17
- package/dist-server/graphql/resolvers/reports/index.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +0 -231
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/receiving-report.js +0 -103
- package/dist-server/graphql/resolvers/reports/receiving-report.js.map +0 -1
- package/dist-server/graphql/resolvers/reports/shortage-report.js +0 -164
- package/dist-server/graphql/resolvers/reports/shortage-report.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.js +0 -187
- package/dist-server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/create-dat-shipments.js +0 -58
- package/dist-server/graphql/resolvers/synchronization/create-dat-shipments.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/fetch-sync-invoices.js +0 -41
- package/dist-server/graphql/resolvers/synchronization/fetch-sync-invoices.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/fetch-sync-products.js +0 -79
- package/dist-server/graphql/resolvers/synchronization/fetch-sync-products.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.js +0 -57
- package/dist-server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/get-lmd-awb.js +0 -34
- package/dist-server/graphql/resolvers/synchronization/get-lmd-awb.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/index.js +0 -30
- package/dist-server/graphql/resolvers/synchronization/index.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/mms-retry-create-lmd-parcels.js +0 -70
- package/dist-server/graphql/resolvers/synchronization/mms-retry-create-lmd-parcels.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/powrup-get-airway-bill.js +0 -78
- package/dist-server/graphql/resolvers/synchronization/powrup-get-airway-bill.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/powrup-get-tracking-no.js +0 -61
- package/dist-server/graphql/resolvers/synchronization/powrup-get-tracking-no.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/powrup-initiate-shipment.js +0 -88
- package/dist-server/graphql/resolvers/synchronization/powrup-initiate-shipment.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/powrup-pack-order.js +0 -185
- package/dist-server/graphql/resolvers/synchronization/powrup-pack-order.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/refresh-lmd-access-token.js +0 -72
- package/dist-server/graphql/resolvers/synchronization/refresh-lmd-access-token.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/retry-create-lmd-parcels.js +0 -96
- package/dist-server/graphql/resolvers/synchronization/retry-create-lmd-parcels.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sellercraft-initiate-shipment.js +0 -97
- package/dist-server/graphql/resolvers/synchronization/sellercraft-initiate-shipment.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.js +0 -202
- package/dist-server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-powrup.js +0 -32
- package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-powrup.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.js +0 -35
- package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sync-products-from-account.js +0 -32
- package/dist-server/graphql/resolvers/synchronization/sync-products-from-account.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-account.js +0 -53
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-account.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-powrup.js +0 -100
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-powrup.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js +0 -142
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/versafleet-fetch-driver-runsheet.js +0 -45
- package/dist-server/graphql/resolvers/synchronization/versafleet-fetch-driver-runsheet.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/webspert-initiate-shipment.js +0 -37
- package/dist-server/graphql/resolvers/synchronization/webspert-initiate-shipment.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/webspert-pack-and-get.js +0 -66
- package/dist-server/graphql/resolvers/synchronization/webspert-pack-and-get.js.map +0 -1
- package/dist-server/graphql/resolvers/synchronization/webspert-update-stocks.js +0 -27
- package/dist-server/graphql/resolvers/synchronization/webspert-update-stocks.js.map +0 -1
- package/dist-server/graphql/types/generators/generate-bizplace-input.js +0 -17
- package/dist-server/graphql/types/generators/generate-bizplace-input.js.map +0 -1
- package/dist-server/graphql/types/generators/generate-company-input.js +0 -17
- package/dist-server/graphql/types/generators/generate-company-input.js.map +0 -1
- package/dist-server/graphql/types/generators/index.js +0 -13
- package/dist-server/graphql/types/generators/index.js.map +0 -1
- package/dist-server/graphql/types/generators/update-domain-type-input.js +0 -14
- package/dist-server/graphql/types/generators/update-domain-type-input.js.map +0 -1
- package/dist-server/graphql/types/index.js +0 -35
- package/dist-server/graphql/types/index.js.map +0 -1
- package/dist-server/graphql/types/invitations/index.js +0 -9
- package/dist-server/graphql/types/invitations/index.js.map +0 -1
- package/dist-server/graphql/types/oauth2/company-role.js +0 -14
- package/dist-server/graphql/types/oauth2/company-role.js.map +0 -1
- package/dist-server/graphql/types/oauth2/index.js +0 -9
- package/dist-server/graphql/types/oauth2/index.js.map +0 -1
- package/dist-server/graphql/types/reports/admiral-asn-report-list.js +0 -14
- package/dist-server/graphql/types/reports/admiral-asn-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/admiral-asn-report.js +0 -21
- package/dist-server/graphql/types/reports/admiral-asn-report.js.map +0 -1
- package/dist-server/graphql/types/reports/asn-report-list.js +0 -14
- package/dist-server/graphql/types/reports/asn-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/asn-report.js +0 -21
- package/dist-server/graphql/types/reports/asn-report.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/elccl/agingreport/aging-report-list.js +0 -14
- package/dist-server/graphql/types/reports/custom/elccl/agingreport/aging-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/elccl/agingreport/aging-report.js +0 -31
- package/dist-server/graphql/types/reports/custom/elccl/agingreport/aging-report.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/elccl/dispatchreport/custom-elccl-fn-dispatch-report-list.js +0 -14
- package/dist-server/graphql/types/reports/custom/elccl/dispatchreport/custom-elccl-fn-dispatch-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/elccl/dispatchreport/custom-elccl-fn-dispatch-report.js +0 -26
- package/dist-server/graphql/types/reports/custom/elccl/dispatchreport/custom-elccl-fn-dispatch-report.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/elccl/exportreport/export-report-list.js +0 -14
- package/dist-server/graphql/types/reports/custom/elccl/exportreport/export-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/elccl/exportreport/export-report.js +0 -31
- package/dist-server/graphql/types/reports/custom/elccl/exportreport/export-report.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/posmy/custom-posmy-aging-report-list.js +0 -13
- package/dist-server/graphql/types/reports/custom/posmy/custom-posmy-aging-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/posmy/custom-posmy-aging-report.js +0 -28
- package/dist-server/graphql/types/reports/custom/posmy/custom-posmy-aging-report.js.map +0 -1
- package/dist-server/graphql/types/reports/custom/yltc/custom-yltc-inventory-report.js +0 -23
- package/dist-server/graphql/types/reports/custom/yltc/custom-yltc-inventory-report.js.map +0 -1
- package/dist-server/graphql/types/reports/inbound-order-details-report-list.js +0 -14
- package/dist-server/graphql/types/reports/inbound-order-details-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/inbound-order-details-report.js +0 -59
- package/dist-server/graphql/types/reports/inbound-order-details-report.js.map +0 -1
- package/dist-server/graphql/types/reports/index.js +0 -63
- package/dist-server/graphql/types/reports/index.js.map +0 -1
- package/dist-server/graphql/types/reports/outbound-order-details-report-list.js +0 -14
- package/dist-server/graphql/types/reports/outbound-order-details-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/outbound-order-details-report.js +0 -76
- package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +0 -1
- package/dist-server/graphql/types/reports/receiving-report-list.js +0 -14
- package/dist-server/graphql/types/reports/receiving-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/receiving-report.js +0 -23
- package/dist-server/graphql/types/reports/receiving-report.js.map +0 -1
- package/dist-server/graphql/types/reports/shortage-report-list.js +0 -14
- package/dist-server/graphql/types/reports/shortage-report-list.js.map +0 -1
- package/dist-server/graphql/types/reports/shortage-report-type.js +0 -26
- package/dist-server/graphql/types/reports/shortage-report-type.js.map +0 -1
- package/dist-server/graphql/types/synchronization/index.js +0 -49
- package/dist-server/graphql/types/synchronization/index.js.map +0 -1
- package/dist-server/graphql/types/synchronization/sync-invoice-list.js +0 -14
- package/dist-server/graphql/types/synchronization/sync-invoice-list.js.map +0 -1
- package/dist-server/graphql/types/synchronization/sync-invoice-set.js +0 -44
- package/dist-server/graphql/types/synchronization/sync-invoice-set.js.map +0 -1
- package/dist-server/graphql/types/synchronization/sync-product-list.js +0 -14
- package/dist-server/graphql/types/synchronization/sync-product-list.js.map +0 -1
- package/dist-server/graphql/types/synchronization/sync-product-set.js +0 -14
- package/dist-server/graphql/types/synchronization/sync-product-set.js.map +0 -1
- package/dist-server/graphql/types/synchronization/sync-purchase-order-list.js +0 -14
- package/dist-server/graphql/types/synchronization/sync-purchase-order-list.js.map +0 -1
- package/dist-server/graphql/types/synchronization/sync-purchase-order-set.js +0 -34
- package/dist-server/graphql/types/synchronization/sync-purchase-order-set.js.map +0 -1
- package/dist-server/index.js +0 -43
- package/dist-server/index.js.map +0 -1
- package/dist-server/middlewares/business-middleware.js +0 -32
- package/dist-server/middlewares/business-middleware.js.map +0 -1
- package/dist-server/middlewares/index.js +0 -21
- package/dist-server/middlewares/index.js.map +0 -1
- package/dist-server/middlewares/store-middleware.js +0 -34
- package/dist-server/middlewares/store-middleware.js.map +0 -1
- package/dist-server/middlewares/warehouse-middleware.js +0 -33
- package/dist-server/middlewares/warehouse-middleware.js.map +0 -1
- package/dist-server/migrations/1597668478399-SeedBusinessDomain.js +0 -27
- package/dist-server/migrations/1597668478399-SeedBusinessDomain.js.map +0 -1
- package/dist-server/migrations/1597668478401-SeedBusinessRoles.js +0 -377
- package/dist-server/migrations/1597668478401-SeedBusinessRoles.js.map +0 -1
- package/dist-server/migrations/1608009991065-SeedUser.js +0 -53
- package/dist-server/migrations/1608009991065-SeedUser.js.map +0 -1
- package/dist-server/migrations/index.js +0 -12
- package/dist-server/migrations/index.js.map +0 -1
- package/dist-server/routers/api/index.js +0 -5
- package/dist-server/routers/api/index.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-contact-point.js +0 -76
- package/dist-server/routers/api/restful-apis/unstable/add-contact-point.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js +0 -174
- package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js +0 -217
- package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js +0 -144
- package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-products.js +0 -88
- package/dist-server/routers/api/restful-apis/unstable/add-products.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +0 -1080
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-sales-invoice.js +0 -140
- package/dist-server/routers/api/restful-apis/unstable/add-sales-invoice.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/bizplace.js +0 -45
- package/dist-server/routers/api/restful-apis/unstable/bizplace.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/cancel-marketplace-order.js +0 -63
- package/dist-server/routers/api/restful-apis/unstable/cancel-marketplace-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js +0 -82
- package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-contact-point-list.js +0 -103
- package/dist-server/routers/api/restful-apis/unstable/get-contact-point-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-delivery-order-detail.js +0 -47
- package/dist-server/routers/api/restful-apis/unstable/get-delivery-order-detail.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-delivery-order-list.js +0 -124
- package/dist-server/routers/api/restful-apis/unstable/get-delivery-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-delivery-orders.js +0 -164
- package/dist-server/routers/api/restful-apis/unstable/get-delivery-orders.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-goods-received-notes.js +0 -120
- package/dist-server/routers/api/restful-apis/unstable/get-goods-received-notes.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-inbound-order-detail.js +0 -115
- package/dist-server/routers/api/restful-apis/unstable/get-inbound-order-detail.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-inbound-order-list.js +0 -125
- package/dist-server/routers/api/restful-apis/unstable/get-inbound-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.js +0 -88
- package/dist-server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-inventory-product-group.js +0 -95
- package/dist-server/routers/api/restful-apis/unstable/get-inventory-product-group.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js +0 -146
- package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-marketplace-store-list.js +0 -79
- package/dist-server/routers/api/restful-apis/unstable/get-marketplace-store-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-onhand-inventories.js +0 -110
- package/dist-server/routers/api/restful-apis/unstable/get-onhand-inventories.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-partners.js +0 -23
- package/dist-server/routers/api/restful-apis/unstable/get-partners.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-products.js +0 -214
- package/dist-server/routers/api/restful-apis/unstable/get-products.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-release-order-detail.js +0 -125
- package/dist-server/routers/api/restful-apis/unstable/get-release-order-detail.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-release-order-list.js +0 -195
- package/dist-server/routers/api/restful-apis/unstable/get-release-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/get-warehouses.js +0 -20
- package/dist-server/routers/api/restful-apis/unstable/get-warehouses.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/index.js +0 -35
- package/dist-server/routers/api/restful-apis/unstable/index.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/reject-inbound-order.js +0 -35
- package/dist-server/routers/api/restful-apis/unstable/reject-inbound-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/set-marketplace-order-delivered.js +0 -45
- package/dist-server/routers/api/restful-apis/unstable/set-marketplace-order-delivered.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/set-marketplace-order-failed-delivery.js +0 -45
- package/dist-server/routers/api/restful-apis/unstable/set-marketplace-order-failed-delivery.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/update-marketplace-order.js +0 -93
- package/dist-server/routers/api/restful-apis/unstable/update-marketplace-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/update-marketplace-shipping-order.js +0 -88
- package/dist-server/routers/api/restful-apis/unstable/update-marketplace-shipping-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js +0 -82
- package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/add-contact-points.js +0 -105
- package/dist-server/routers/api/restful-apis/v1/company/add-contact-points.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/add-products.js +0 -157
- package/dist-server/routers/api/restful-apis/v1/company/add-products.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/get-bizplace-list.js +0 -49
- package/dist-server/routers/api/restful-apis/v1/company/get-bizplace-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/get-contact-point-list.js +0 -62
- package/dist-server/routers/api/restful-apis/v1/company/get-contact-point-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/get-partner-list.js +0 -88
- package/dist-server/routers/api/restful-apis/v1/company/get-partner-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/get-product-by-skus.js +0 -95
- package/dist-server/routers/api/restful-apis/v1/company/get-product-by-skus.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/get-product-list.js +0 -104
- package/dist-server/routers/api/restful-apis/v1/company/get-product-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/get-webhook-details.js +0 -58
- package/dist-server/routers/api/restful-apis/v1/company/get-webhook-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/index.js +0 -14
- package/dist-server/routers/api/restful-apis/v1/company/index.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/upsert-product.js +0 -111
- package/dist-server/routers/api/restful-apis/v1/company/upsert-product.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/upsert-products.js +0 -356
- package/dist-server/routers/api/restful-apis/v1/company/upsert-products.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/company/upsert-webhooks.js +0 -146
- package/dist-server/routers/api/restful-apis/v1/company/upsert-webhooks.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/index.js +0 -6
- package/dist-server/routers/api/restful-apis/v1/index.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/add-marketplace-order.js +0 -254
- package/dist-server/routers/api/restful-apis/v1/marketplace/add-marketplace-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/add-marketplace-products.js +0 -78
- package/dist-server/routers/api/restful-apis/v1/marketplace/add-marketplace-products.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/cancel-marketplace-order.js +0 -90
- package/dist-server/routers/api/restful-apis/v1/marketplace/cancel-marketplace-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/get-marketplace-order-shipping-list.js +0 -138
- package/dist-server/routers/api/restful-apis/v1/marketplace/get-marketplace-order-shipping-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/get-marketplace-store-list.js +0 -51
- package/dist-server/routers/api/restful-apis/v1/marketplace/get-marketplace-store-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/index.js +0 -11
- package/dist-server/routers/api/restful-apis/v1/marketplace/index.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/update-marketplace-order-delivered.js +0 -62
- package/dist-server/routers/api/restful-apis/v1/marketplace/update-marketplace-order-delivered.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/update-marketplace-product.js +0 -76
- package/dist-server/routers/api/restful-apis/v1/marketplace/update-marketplace-product.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/marketplace/update-marketplace-shipping-order.js +0 -40
- package/dist-server/routers/api/restful-apis/v1/marketplace/update-marketplace-shipping-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/middlewares/business-middleware.js +0 -70
- package/dist-server/routers/api/restful-apis/v1/middlewares/business-middleware.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/middlewares/index.js +0 -40
- package/dist-server/routers/api/restful-apis/v1/middlewares/index.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/middlewares/logging-middleware.js +0 -53
- package/dist-server/routers/api/restful-apis/v1/middlewares/logging-middleware.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/middlewares/store-middleware.js +0 -32
- package/dist-server/routers/api/restful-apis/v1/middlewares/store-middleware.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/middlewares/validation-middleware.js +0 -118
- package/dist-server/routers/api/restful-apis/v1/middlewares/validation-middleware.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/middlewares/warehouse-middleware.js +0 -31
- package/dist-server/routers/api/restful-apis/v1/middlewares/warehouse-middleware.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/utils/error-util.js +0 -71
- package/dist-server/routers/api/restful-apis/v1/utils/error-util.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/utils/params.js +0 -1164
- package/dist-server/routers/api/restful-apis/v1/utils/params.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/utils/validate-util.js +0 -68
- package/dist-server/routers/api/restful-apis/v1/utils/validate-util.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-inbound-order.js +0 -254
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-inbound-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-release-order.js +0 -1091
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-release-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-return-order.js +0 -325
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-return-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.js +0 -97
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/cancel-inbound-order.js +0 -199
- package/dist-server/routers/api/restful-apis/v1/warehouse/cancel-inbound-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/cancel-release-order.js +0 -197
- package/dist-server/routers/api/restful-apis/v1/warehouse/cancel-release-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/complete-delivery-order.js +0 -170
- package/dist-server/routers/api/restful-apis/v1/warehouse/complete-delivery-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/dispatch-delivery-order.js +0 -327
- package/dist-server/routers/api/restful-apis/v1/warehouse/dispatch-delivery-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-delivery-order-list.js +0 -223
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-delivery-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-do-document.js +0 -65
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-do-document.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-draft-order-details.js +0 -144
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-draft-order-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-draft-order-list.js +0 -305
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-draft-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-goods-received-note-list.js +0 -100
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-goods-received-note-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-grn-document.js +0 -102
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-grn-document.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inbound-order-details.js +0 -179
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inbound-order-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inbound-order-list.js +0 -96
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inbound-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inventory-adjustment-details.js +0 -146
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inventory-adjustment-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inventory-adjustment-list.js +0 -214
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inventory-adjustment-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inventory-product-group-list.js +0 -90
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-inventory-product-group-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-manifest-details.js +0 -138
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-manifest-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-onhand-inventory-list.js +0 -106
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-onhand-inventory-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-release-order-details.js +0 -278
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-release-order-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-release-order-list.js +0 -142
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-release-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-return-order-details.js +0 -106
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-return-order-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-return-order-list.js +0 -63
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-return-order-list.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.js +0 -68
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/index.js +0 -32
- package/dist-server/routers/api/restful-apis/v1/warehouse/index.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/update-gan-to-arrived.js +0 -96
- package/dist-server/routers/api/restful-apis/v1/warehouse/update-gan-to-arrived.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/update-order-package-details.js +0 -46
- package/dist-server/routers/api/restful-apis/v1/warehouse/update-order-package-details.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/update-release-order-details.js +0 -70
- package/dist-server/routers/api/restful-apis/v1/warehouse/update-release-order-details.js.map +0 -1
- package/dist-server/routers/auth-invitation-router.js +0 -25
- package/dist-server/routers/auth-invitation-router.js.map +0 -1
- package/dist-server/routers/business/bizplace-register-router.js +0 -25
- package/dist-server/routers/business/bizplace-register-router.js.map +0 -1
- package/dist-server/routers/business/business-register-router.js +0 -31
- package/dist-server/routers/business/business-register-router.js.map +0 -1
- package/dist-server/routers/business/index.js +0 -20
- package/dist-server/routers/business/index.js.map +0 -1
- package/dist-server/routers/business/path-base-business-router.js +0 -21
- package/dist-server/routers/business/path-base-business-router.js.map +0 -1
- package/dist-server/routers/internal/apis/create-bizplace.js +0 -70
- package/dist-server/routers/internal/apis/create-bizplace.js.map +0 -1
- package/dist-server/routers/internal/apis/create-company.js +0 -77
- package/dist-server/routers/internal/apis/create-company.js.map +0 -1
- package/dist-server/routers/internal/apis/create-partner.js +0 -41
- package/dist-server/routers/internal/apis/create-partner.js.map +0 -1
- package/dist-server/routers/internal/apis/create-user.js +0 -23
- package/dist-server/routers/internal/apis/create-user.js.map +0 -1
- package/dist-server/routers/internal/apis/index.js +0 -37
- package/dist-server/routers/internal/apis/index.js.map +0 -1
- package/dist-server/routers/internal/apis/invite-user.js +0 -48
- package/dist-server/routers/internal/apis/invite-user.js.map +0 -1
- package/dist-server/routers/internal/apis/terminate-partner.js +0 -38
- package/dist-server/routers/internal/apis/terminate-partner.js.map +0 -1
- package/dist-server/routers/internal/apis/terminate-user.js +0 -53
- package/dist-server/routers/internal/apis/terminate-user.js.map +0 -1
- package/dist-server/routers/internal/apis/update-bizplace.js +0 -52
- package/dist-server/routers/internal/apis/update-bizplace.js.map +0 -1
- package/dist-server/routers/internal/apis/update-company.js +0 -55
- package/dist-server/routers/internal/apis/update-company.js.map +0 -1
- package/dist-server/routers/internal/apis/update-user.js +0 -33
- package/dist-server/routers/internal/apis/update-user.js.map +0 -1
- package/dist-server/routers/internal/index.js +0 -8
- package/dist-server/routers/internal/index.js.map +0 -1
- package/dist-server/routers/internal/middlewares/index.js +0 -20
- package/dist-server/routers/internal/middlewares/index.js.map +0 -1
- package/dist-server/routers/internal/middlewares/logging-middleware.js +0 -23
- package/dist-server/routers/internal/middlewares/logging-middleware.js.map +0 -1
- package/dist-server/routers/internal/middlewares/validation-middleware.js +0 -110
- package/dist-server/routers/internal/middlewares/validation-middleware.js.map +0 -1
- package/dist-server/routers/internal/powrup-router.js +0 -291
- package/dist-server/routers/internal/powrup-router.js.map +0 -1
- package/dist-server/routers/internal/sellercraft-router.js +0 -53
- package/dist-server/routers/internal/sellercraft-router.js.map +0 -1
- package/dist-server/routers/internal/utils/error-util.js +0 -71
- package/dist-server/routers/internal/utils/error-util.js.map +0 -1
- package/dist-server/routers/internal/utils/params.js +0 -153
- package/dist-server/routers/internal/utils/params.js.map +0 -1
- package/dist-server/routers/support-router.js +0 -386
- package/dist-server/routers/support-router.js.map +0 -1
- package/dist-server/routers/webhook-service/versafleet-router.js +0 -93
- package/dist-server/routers/webhook-service/versafleet-router.js.map +0 -1
- package/dist-server/routers/xilnex-router.js +0 -1103
- package/dist-server/routers/xilnex-router.js.map +0 -1
- package/dist-server/routes.js +0 -26
- package/dist-server/routes.js.map +0 -1
- package/dist-server/templates/account-unlock-email.js +0 -69
- package/dist-server/templates/account-unlock-email.js.map +0 -1
- package/dist-server/templates/invitation-email.js +0 -70
- package/dist-server/templates/invitation-email.js.map +0 -1
- package/dist-server/templates/reset-password-email.js +0 -66
- package/dist-server/templates/reset-password-email.js.map +0 -1
- package/dist-server/templates/verification-email.js +0 -70
- package/dist-server/templates/verification-email.js.map +0 -1
- package/dist-server/utils/build-map.js +0 -19
- package/dist-server/utils/build-map.js.map +0 -1
- package/dist-server/utils/get-warehouses.js +0 -113
- package/dist-server/utils/get-warehouses.js.map +0 -1
- package/dist-server/utils/index.js +0 -21
- package/dist-server/utils/index.js.map +0 -1
- package/dist-server/utils/order-no-generator.js +0 -11
- package/dist-server/utils/order-no-generator.js.map +0 -1
- package/dist-server/utils/report-query-util.js +0 -42
- package/dist-server/utils/report-query-util.js.map +0 -1
|
@@ -1,1091 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const typeorm_1 = require("typeorm");
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const integration_base_1 = require("@things-factory/integration-base");
|
|
6
|
-
const api_1 = require("@things-factory/api");
|
|
7
|
-
const biz_base_1 = require("@things-factory/biz-base");
|
|
8
|
-
const geography_1 = require("@things-factory/geography");
|
|
9
|
-
const id_rule_base_1 = require("@things-factory/id-rule-base");
|
|
10
|
-
const integration_lmd_1 = require("@things-factory/integration-lmd");
|
|
11
|
-
const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
|
|
12
|
-
const marketplace_base_1 = require("@things-factory/marketplace-base");
|
|
13
|
-
const product_base_1 = require("@things-factory/product-base");
|
|
14
|
-
const sales_base_1 = require("@things-factory/sales-base");
|
|
15
|
-
const setting_base_1 = require("@things-factory/setting-base");
|
|
16
|
-
const warehouse_base_1 = require("@things-factory/warehouse-base");
|
|
17
|
-
const middlewares_1 = require("../middlewares");
|
|
18
|
-
const error_util_1 = require("../utils/error-util");
|
|
19
|
-
const integration_lmd_2 = require("@things-factory/integration-lmd");
|
|
20
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-release-order');
|
|
21
|
-
const apiVersion = 'v1';
|
|
22
|
-
api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/add-release-order`, middlewares_1.businessMiddleware, middlewares_1.validationMiddleware, middlewares_1.loggingMiddleware, async (context, next) => {
|
|
23
|
-
return await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
25
|
-
const { client, domain, user, application } = context.state;
|
|
26
|
-
const { bizplaceId: customerBizplaceId } = context.request.body.data;
|
|
27
|
-
const { t } = context;
|
|
28
|
-
const bodyReq = context.request.body.data;
|
|
29
|
-
const requiredDraft = bodyReq.hasOwnProperty('requiredDraft') ? bodyReq.requiredDraft : true;
|
|
30
|
-
let releaseGood;
|
|
31
|
-
let xilnexSetting = null;
|
|
32
|
-
let massagedData = { orderProducts: [], combinedItems: [] };
|
|
33
|
-
// const isAutoAssign: Boolean = bodyReq.hasOwnProperty('isAutoAssign') ? bodyReq.isAutoAssign : true
|
|
34
|
-
try {
|
|
35
|
-
if (!customerBizplaceId)
|
|
36
|
-
throw new error_util_1.ApiError('E04', 'warehouse id not found');
|
|
37
|
-
if (typeof bodyReq === undefined || !((_a = Object.keys(bodyReq)) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
38
|
-
throw new error_util_1.ApiError('E01', 'invalid body request format');
|
|
39
|
-
}
|
|
40
|
-
debug('post:/add-release-order request.body', bodyReq);
|
|
41
|
-
// get customer company's bizplace
|
|
42
|
-
const custCompanyBizplace = await (0, biz_base_1.getCompanyBizplace)(null, null, customerBizplaceId, tx);
|
|
43
|
-
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
44
|
-
where: { id: customerBizplaceId },
|
|
45
|
-
relations: ['domain']
|
|
46
|
-
});
|
|
47
|
-
const worksheetPickingAssignment = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
48
|
-
where: { domain, category: 'id-rule', name: 'enable-worksheet-picking-activation-assignment' }
|
|
49
|
-
});
|
|
50
|
-
// conditional validation
|
|
51
|
-
if (bodyReq.ownTransport && !bodyReq.collectionOrderNo)
|
|
52
|
-
throw new error_util_1.ApiError('E03', 'collectionOrderNo');
|
|
53
|
-
if (bodyReq.exportOption && !bodyReq.shippingOrder)
|
|
54
|
-
throw new error_util_1.ApiError('E03', 'shippingOrder');
|
|
55
|
-
if (bodyReq.exportOption && !bodyReq.ownTransport)
|
|
56
|
-
throw new error_util_1.ApiError('E01', 'ownTransport');
|
|
57
|
-
if (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.xilnexSetting) {
|
|
58
|
-
xilnexSetting = JSON.stringify({
|
|
59
|
-
outletName: ((_b = bodyReq.xilnexSetting) === null || _b === void 0 ? void 0 : _b.outletName) || '',
|
|
60
|
-
clientId: ((_c = bodyReq.xilnexSetting) === null || _c === void 0 ? void 0 : _c.clientId) || '',
|
|
61
|
-
clientPayment: ((_d = bodyReq.xilnexSetting) === null || _d === void 0 ? void 0 : _d.clientPayment) || '',
|
|
62
|
-
salesType: ((_e = bodyReq.xilnexSetting) === null || _e === void 0 ? void 0 : _e.salesType) || ''
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
let newPhone1 = ((_f = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _f === void 0 ? void 0 : _f.phone1) ? bodyReq.deliverTo.phone1.replace(/\D/g, '') : null;
|
|
66
|
-
let newPhone2 = ((_g = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _g === void 0 ? void 0 : _g.phone2) ? bodyReq.deliverTo.phone2.replace(/\D/g, '') : null;
|
|
67
|
-
releaseGood = {
|
|
68
|
-
domain,
|
|
69
|
-
bizplace: customerBizplace,
|
|
70
|
-
companyBizplace: custCompanyBizplace,
|
|
71
|
-
courierOption: bodyReq.courierOption,
|
|
72
|
-
codOption: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.codOption,
|
|
73
|
-
collectionOrderNo: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.collectionOrderNo,
|
|
74
|
-
exportOption: bodyReq.exportOption,
|
|
75
|
-
ownTransport: bodyReq.ownTransport,
|
|
76
|
-
packingOption: bodyReq.packingOption,
|
|
77
|
-
refNo: bodyReq.refNo,
|
|
78
|
-
refNo2: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo2,
|
|
79
|
-
refNo3: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo3,
|
|
80
|
-
refOrderId: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refOrderId,
|
|
81
|
-
releaseDate: bodyReq.releaseDate,
|
|
82
|
-
type: bodyReq.type,
|
|
83
|
-
marketplaceOrderStatus: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.marketplaceOrderStatus,
|
|
84
|
-
remark: (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.remark) || null,
|
|
85
|
-
billingAddress: ((_h = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.billTo) === null || _h === void 0 ? void 0 : _h.billingAddress) || null,
|
|
86
|
-
deliveryAddress1: ((_j = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _j === void 0 ? void 0 : _j.deliveryAddress1) || null,
|
|
87
|
-
deliveryAddress2: ((_k = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _k === void 0 ? void 0 : _k.deliveryAddress2) || null,
|
|
88
|
-
deliveryAddress3: ((_l = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _l === void 0 ? void 0 : _l.deliveryAddress3) || null,
|
|
89
|
-
deliveryAddress4: ((_m = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _m === void 0 ? void 0 : _m.deliveryAddress4) || null,
|
|
90
|
-
deliveryAddress5: ((_o = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _o === void 0 ? void 0 : _o.deliveryAddress5) || null,
|
|
91
|
-
attentionTo: ((_p = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _p === void 0 ? void 0 : _p.attentionTo) || null,
|
|
92
|
-
attentionCompany: ((_q = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _q === void 0 ? void 0 : _q.attentionCompany) || null,
|
|
93
|
-
city: ((_r = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _r === void 0 ? void 0 : _r.city) || null,
|
|
94
|
-
ward: (_s = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _s === void 0 ? void 0 : _s.ward,
|
|
95
|
-
district: (_t = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _t === void 0 ? void 0 : _t.district,
|
|
96
|
-
state: ((_u = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _u === void 0 ? void 0 : _u.state) || null,
|
|
97
|
-
postalCode: ((_v = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _v === void 0 ? void 0 : _v.postalCode) || null,
|
|
98
|
-
country: ((_w = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _w === void 0 ? void 0 : _w.country) || null,
|
|
99
|
-
phone1: newPhone1,
|
|
100
|
-
phone2: newPhone2,
|
|
101
|
-
email: ((_x = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _x === void 0 ? void 0 : _x.email) || null,
|
|
102
|
-
transporter: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.transporter,
|
|
103
|
-
trackingNo: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.trackingNo,
|
|
104
|
-
airwayBill: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.airwayBill,
|
|
105
|
-
invoice: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.invoice,
|
|
106
|
-
packageId: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.packageId,
|
|
107
|
-
storeName: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.storeName,
|
|
108
|
-
storeId: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.storeId,
|
|
109
|
-
routeId: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.routeId,
|
|
110
|
-
stopId: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.stopId,
|
|
111
|
-
source: application === null || application === void 0 ? void 0 : application.type,
|
|
112
|
-
paidAmount: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.paidAmount,
|
|
113
|
-
platformCode: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.platformCode,
|
|
114
|
-
platformCountry: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.platformCountry,
|
|
115
|
-
platformName: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.platformName,
|
|
116
|
-
discountAmount: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.discountAmount,
|
|
117
|
-
taxAmount: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.taxAmount,
|
|
118
|
-
shippingFee: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingFee,
|
|
119
|
-
lmdOption: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.lmdOption,
|
|
120
|
-
priorityDelivery: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.priorityDelivery,
|
|
121
|
-
shippingOrder: (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder)
|
|
122
|
-
? {
|
|
123
|
-
shipName: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder.shipName,
|
|
124
|
-
containerNo: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder.containerNo,
|
|
125
|
-
loadType: (_y = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder) === null || _y === void 0 ? void 0 : _y.loadType,
|
|
126
|
-
from: (_z = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder) === null || _z === void 0 ? void 0 : _z.from,
|
|
127
|
-
to: (_0 = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder) === null || _0 === void 0 ? void 0 : _0.to,
|
|
128
|
-
containerArrivalDate: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder.containerArrivalDate,
|
|
129
|
-
containerLeavingDate: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingOrder.containerLeavingDate
|
|
130
|
-
}
|
|
131
|
-
: null,
|
|
132
|
-
assignedInventory: (worksheetPickingAssignment === null || worksheetPickingAssignment === void 0 ? void 0 : worksheetPickingAssignment.value) == 'true' ? false : true,
|
|
133
|
-
xilnexSetting: xilnexSetting || null
|
|
134
|
-
};
|
|
135
|
-
// check existing order
|
|
136
|
-
await checkExistingOrder(releaseGood, customerBizplace, bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.checkDuplicationValidation, context, tx);
|
|
137
|
-
//find oi got batchId or not
|
|
138
|
-
const batchIdStates = bodyReq.orderInventories.reduce((acc, oi) => {
|
|
139
|
-
// Check if batchId is not an empty string or string with only spaces
|
|
140
|
-
const decimalPlaces = (String(oi.releaseQty).split('.')[1] || '').length;
|
|
141
|
-
if (decimalPlaces > 3) {
|
|
142
|
-
throw new error_util_1.ApiError('E01', `releaseQty cannot have more than 3 decimal places for product ${oi.sku || oi.refCode}`);
|
|
143
|
-
}
|
|
144
|
-
if (oi.batchId && oi.batchId.trim() !== '') {
|
|
145
|
-
acc.withBatchId = true;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
acc.withoutBatchId = true;
|
|
149
|
-
}
|
|
150
|
-
return acc;
|
|
151
|
-
}, { withBatchId: false, withoutBatchId: false });
|
|
152
|
-
if (batchIdStates.withBatchId && batchIdStates.withoutBatchId) {
|
|
153
|
-
throw new error_util_1.ApiError('E01', 'Please provide batch id for all inventories');
|
|
154
|
-
}
|
|
155
|
-
// massage data
|
|
156
|
-
massagedData = await massageOrderItems(releaseGood, bodyReq.orderInventories, context); //double check this function
|
|
157
|
-
const invWithoutBatchId = batchIdStates.withoutBatchId;
|
|
158
|
-
//inv without batchId will check stock in wboi
|
|
159
|
-
if (invWithoutBatchId) {
|
|
160
|
-
// validation
|
|
161
|
-
await Promise.all(massagedData.combinedItems.map(async (item) => {
|
|
162
|
-
let itemList = await tx.query(`
|
|
163
|
-
select wboi.* from warehouse_bizplace_onhand_inventories wboi
|
|
164
|
-
left join (
|
|
165
|
-
select i2.product_id, i2.domain_id, i2.bizplace_id, i2.packing_type, i2.packing_size, i2.uom, sum(i2.qty) as storage_qty, sum(i2.uom_value) as storage_uom_value from inventories i2
|
|
166
|
-
inner join locations l2 on l2.id = i2.location_id
|
|
167
|
-
where i2.domain_id = $1 and i2.bizplace_id = $2
|
|
168
|
-
and i2.product_id = $3 and i2.packing_type= $4 and i2.packing_size= $5 and i2.uom = $6 and i2.status='STORED'
|
|
169
|
-
and l2.type='STORAGE'
|
|
170
|
-
group by i2.product_id, i2.domain_id, i2.bizplace_id, i2.packing_type, i2.packing_size, i2.uom
|
|
171
|
-
) storageInv on storageInv.product_id = wboi.product_id and storageInv.domain_id=wboi.domain_id and storageInv.bizplace_id=wboi.bizplace_id
|
|
172
|
-
and storageInv.packing_type=wboi.packing_type and storageInv.packing_size=wboi.packing_size and storageInv.uom=wboi.uom
|
|
173
|
-
left join (
|
|
174
|
-
select i.product_id, i.domain_id, i.bizplace_id, i.packing_type, i.packing_size, i.uom, i.lock_inventory from inventories i
|
|
175
|
-
where i.domain_id = $1 and i.bizplace_id = $2
|
|
176
|
-
and i.product_id = $3 and i.packing_type= $4 and i.packing_size= $5 and i.uom = $6 and i.status='STORED'
|
|
177
|
-
group by i.product_id, i.domain_id, i.bizplace_id, i.packing_type, i.packing_size, i.uom, i.lock_inventory
|
|
178
|
-
) lockInv on lockInv.product_id = wboi.product_id and lockInv.domain_id=wboi.domain_id and lockInv.bizplace_id=wboi.bizplace_id
|
|
179
|
-
and lockInv.packing_type=wboi.packing_type and lockInv.packing_size=wboi.packing_size and lockInv.uom=wboi.uom
|
|
180
|
-
where wboi."domain_id"= $1 and
|
|
181
|
-
wboi."bizplace_id" = $2 and
|
|
182
|
-
wboi."group_type" = 'SINGLE' and
|
|
183
|
-
wboi."product_id" = $3 and
|
|
184
|
-
wboi."packing_type" = $4 and
|
|
185
|
-
wboi."packing_size" = $5 and
|
|
186
|
-
wboi."uom" = $6 and
|
|
187
|
-
lockInv.lock_inventory is not true and
|
|
188
|
-
(wboi."remain_qty" - wboi."transfer_qty" - coalesce(storageInv.storage_qty, 0)) >= $7 and
|
|
189
|
-
(wboi."remain_uom_value" - wboi."transfer_uom_value" - coalesce(storageInv.storage_uom_value, 0)) >= $8
|
|
190
|
-
`, [
|
|
191
|
-
domain.id,
|
|
192
|
-
customerBizplace.id,
|
|
193
|
-
item.product.id,
|
|
194
|
-
item.packingType,
|
|
195
|
-
item.packingSize,
|
|
196
|
-
item.uom,
|
|
197
|
-
item.releaseQty,
|
|
198
|
-
item.releaseUomValue
|
|
199
|
-
]);
|
|
200
|
-
if (itemList.length <= 0) {
|
|
201
|
-
throw new error_util_1.ApiError('E01', 'INSUFFICIENT_STOCK');
|
|
202
|
-
}
|
|
203
|
-
console.log();
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
// assignment
|
|
207
|
-
// console.time('assign')
|
|
208
|
-
let assignedOrderProducts = await assignToInventory(massagedData.orderProducts, customerBizplace, context, tx, worksheetPickingAssignment);
|
|
209
|
-
// console.timeEnd('assign')
|
|
210
|
-
// create order
|
|
211
|
-
// console.time('save')
|
|
212
|
-
let result = await createReleaseGood(releaseGood, assignedOrderProducts, customerBizplace, context, tx, worksheetPickingAssignment);
|
|
213
|
-
// console.timeEnd('save')
|
|
214
|
-
let data = {
|
|
215
|
-
id: result.id,
|
|
216
|
-
roNo: result.name,
|
|
217
|
-
refNo: result.refNo,
|
|
218
|
-
refNo2: result.refNo2,
|
|
219
|
-
refNo3: result.refNo3,
|
|
220
|
-
refOrderId: result.refOrderId,
|
|
221
|
-
status: result.status,
|
|
222
|
-
truckNo: result.truckNo,
|
|
223
|
-
ownTransport: result.ownTransport,
|
|
224
|
-
crossDocking: result.crossDocking,
|
|
225
|
-
marketplaceOrderStatus: result.marketplaceOrderStatus,
|
|
226
|
-
billingAddress: result.billingAddress,
|
|
227
|
-
deliveryAddress1: result.deliveryAddress1,
|
|
228
|
-
deliveryAddress2: result.deliveryAddress2,
|
|
229
|
-
deliveryAddress3: result.deliveryAddress3,
|
|
230
|
-
deliveryAddress4: result.deliveryAddress4,
|
|
231
|
-
deliveryAddress5: result.deliveryAddress5,
|
|
232
|
-
attentionTo: result.attentionTo,
|
|
233
|
-
attentionCompany: result.attentionCompany,
|
|
234
|
-
city: result.city,
|
|
235
|
-
ward: result.ward,
|
|
236
|
-
district: result.district,
|
|
237
|
-
state: result.state,
|
|
238
|
-
postalCode: result.postalCode,
|
|
239
|
-
country: result.country,
|
|
240
|
-
phone1: result.phone1,
|
|
241
|
-
phone2: result.phone2,
|
|
242
|
-
email: result.email,
|
|
243
|
-
transporter: result.transporter,
|
|
244
|
-
trackingNo: result.trackingNo,
|
|
245
|
-
airwayBill: result.airwayBill,
|
|
246
|
-
invoice: result.invoice,
|
|
247
|
-
type: result.type,
|
|
248
|
-
packageId: result.packageId,
|
|
249
|
-
storeName: result.storeName,
|
|
250
|
-
storeId: result.storeId,
|
|
251
|
-
routeId: result.routeId,
|
|
252
|
-
stopId: result.stopId,
|
|
253
|
-
exportOption: result.exportOption,
|
|
254
|
-
releaseDate: result.releaseDate,
|
|
255
|
-
collectionOrderNo: result.collectionOrderNo,
|
|
256
|
-
platformCode: result === null || result === void 0 ? void 0 : result.platformCode,
|
|
257
|
-
platformCountry: result === null || result === void 0 ? void 0 : result.platformCountry,
|
|
258
|
-
platformName: result === null || result === void 0 ? void 0 : result.platformName,
|
|
259
|
-
paidAmount: result === null || result === void 0 ? void 0 : result.paidAmount,
|
|
260
|
-
discountAmount: result === null || result === void 0 ? void 0 : result.discountAmount,
|
|
261
|
-
taxAmount: result === null || result === void 0 ? void 0 : result.taxAmount,
|
|
262
|
-
shippingFee: result === null || result === void 0 ? void 0 : result.shippingFee,
|
|
263
|
-
priorityDelivery: result === null || result === void 0 ? void 0 : result.priorityDelivery,
|
|
264
|
-
bizplace: { name: result.bizplace.name },
|
|
265
|
-
domain: { name: result.domain.name },
|
|
266
|
-
orderProducts: result.orderProducts,
|
|
267
|
-
orderInventories: result.orderInventories
|
|
268
|
-
};
|
|
269
|
-
//trigger webhook
|
|
270
|
-
(0, integration_base_1.webhookHandler)(result, result.bizplace, integration_base_1.WebhookEventsEnum.ReleaseOrderCreated);
|
|
271
|
-
// return body
|
|
272
|
-
context.body = { result: { data } };
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
if (error.details) {
|
|
276
|
-
if (error.details == 'INSUFFICIENT_STOCK' && requiredDraft) {
|
|
277
|
-
const result = await createDraftOrder(releaseGood, massagedData.orderProducts, context);
|
|
278
|
-
let data = {
|
|
279
|
-
id: result.id,
|
|
280
|
-
name: result.name,
|
|
281
|
-
refNo: result.refNo,
|
|
282
|
-
refNo2: result.refNo2,
|
|
283
|
-
refNo3: result.refNo3,
|
|
284
|
-
refOrderId: result.refOrderId,
|
|
285
|
-
status: result.status,
|
|
286
|
-
truckNo: result.truckNo,
|
|
287
|
-
ownTransport: result.ownTransport,
|
|
288
|
-
marketplaceOrderStatus: result.marketplaceOrderStatus,
|
|
289
|
-
billingAddress: result.billingAddress,
|
|
290
|
-
deliveryAddress1: result.deliveryAddress1,
|
|
291
|
-
deliveryAddress2: result.deliveryAddress2,
|
|
292
|
-
deliveryAddress3: result.deliveryAddress3,
|
|
293
|
-
deliveryAddress4: result.deliveryAddress4,
|
|
294
|
-
deliveryAddress5: result.deliveryAddress5,
|
|
295
|
-
attentionTo: result.attentionTo,
|
|
296
|
-
attentionCompany: result.attentionCompany,
|
|
297
|
-
city: result.city,
|
|
298
|
-
ward: result.ward,
|
|
299
|
-
district: result.district,
|
|
300
|
-
state: result.state,
|
|
301
|
-
postalCode: result.postalCode,
|
|
302
|
-
country: result.country,
|
|
303
|
-
phone1: result.phone1,
|
|
304
|
-
phone2: result.phone2,
|
|
305
|
-
email: result.email,
|
|
306
|
-
type: result.type,
|
|
307
|
-
packageId: result.packageId,
|
|
308
|
-
exportOption: result.exportOption,
|
|
309
|
-
releaseDate: result.releaseDate,
|
|
310
|
-
collectionOrderNo: result.collectionOrderNo,
|
|
311
|
-
platformCode: result === null || result === void 0 ? void 0 : result.platformCode,
|
|
312
|
-
platformCountry: result === null || result === void 0 ? void 0 : result.platformCountry,
|
|
313
|
-
platformName: result === null || result === void 0 ? void 0 : result.platformName,
|
|
314
|
-
paidAmount: result === null || result === void 0 ? void 0 : result.paidAmount,
|
|
315
|
-
discountAmount: result === null || result === void 0 ? void 0 : result.discountAmount,
|
|
316
|
-
taxAmount: result === null || result === void 0 ? void 0 : result.taxAmount,
|
|
317
|
-
shippingFee: result === null || result === void 0 ? void 0 : result.shippingFee,
|
|
318
|
-
priorityDelivery: result === null || result === void 0 ? void 0 : result.priorityDelivery,
|
|
319
|
-
bizplace: { name: result.bizplace.name },
|
|
320
|
-
domain: { name: result.domain.name }
|
|
321
|
-
};
|
|
322
|
-
//trigger webhook
|
|
323
|
-
(0, integration_base_1.webhookHandler)(result, result.bizplace, integration_base_1.WebhookEventsEnum.DraftOrderCreated);
|
|
324
|
-
context.body = { result: { data } };
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
if (error instanceof error_util_1.ApiError)
|
|
328
|
-
(0, error_util_1.ApiErrorHandler)(context, error);
|
|
329
|
-
else
|
|
330
|
-
(0, error_util_1.throwInternalServerError)(context, error);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
if (error instanceof error_util_1.ApiError)
|
|
335
|
-
(0, error_util_1.ApiErrorHandler)(context, error);
|
|
336
|
-
else
|
|
337
|
-
(0, error_util_1.throwInternalServerError)(context, error);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
async function checkExistingOrder(releaseGood, bizplace, checkDuplicationValidation = true, context, tx) {
|
|
343
|
-
const { domain, user } = context.state;
|
|
344
|
-
const refNo = releaseGood.refNo;
|
|
345
|
-
const refNo2 = releaseGood.refNo2;
|
|
346
|
-
const refNo3 = releaseGood.refNo3;
|
|
347
|
-
if (checkDuplicationValidation) {
|
|
348
|
-
const foundDraftReleaseGood = await tx.getRepository(sales_base_1.DraftReleaseGood).findOne({
|
|
349
|
-
where: {
|
|
350
|
-
domain,
|
|
351
|
-
bizplace: { id: bizplace.id },
|
|
352
|
-
refNo: refNo || null,
|
|
353
|
-
refNo2: refNo2 || null,
|
|
354
|
-
refNo3: refNo3 || null,
|
|
355
|
-
status: (0, typeorm_1.Not)((0, typeorm_1.In)([sales_base_1.DRAFT_RELEASE_ORDER_STATUS.CANCELLED]))
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
if (foundDraftReleaseGood) {
|
|
359
|
-
throw new error_util_1.ApiError('E05', `existing draft release order found: ${foundDraftReleaseGood.name}`);
|
|
360
|
-
}
|
|
361
|
-
const sellercraft = await tx
|
|
362
|
-
.getRepository(integration_sellercraft_1.Sellercraft)
|
|
363
|
-
.findOne({ domain: bizplace.domain, status: 'ACTIVE' });
|
|
364
|
-
if (sellercraft) {
|
|
365
|
-
const sellercraftCtrl = new sales_base_1.SellercraftController(tx, bizplace.domain, user);
|
|
366
|
-
await sellercraftCtrl.checkExistingReleaseGood(sellercraft, releaseGood);
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
const foundReleaseGood = await tx.getRepository(sales_base_1.ReleaseGood).findOne({
|
|
370
|
-
where: {
|
|
371
|
-
domain: domain,
|
|
372
|
-
bizplace: { id: bizplace.id },
|
|
373
|
-
refNo,
|
|
374
|
-
status: (0, typeorm_1.Not)((0, typeorm_1.In)([sales_base_1.ORDER_STATUS.CANCELLED, sales_base_1.ORDER_STATUS.PENDING_CANCEL]))
|
|
375
|
-
},
|
|
376
|
-
relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
377
|
-
});
|
|
378
|
-
if (foundReleaseGood) {
|
|
379
|
-
const customerCompanyDomain = foundReleaseGood.bizplace.company.domain;
|
|
380
|
-
const marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
381
|
-
where: { orderNo: refNo, domain: customerCompanyDomain }
|
|
382
|
-
});
|
|
383
|
-
// Need to restructure the validation
|
|
384
|
-
if (marketplaceOrder === null || marketplaceOrder === void 0 ? void 0 : marketplaceOrder.isSplitted) {
|
|
385
|
-
const refNo2 = releaseGood.refNo2;
|
|
386
|
-
const foundSplittedReleaseGood = await tx.getRepository(sales_base_1.ReleaseGood).findOne({
|
|
387
|
-
where: {
|
|
388
|
-
domain,
|
|
389
|
-
refNo2,
|
|
390
|
-
status: (0, typeorm_1.Not)((0, typeorm_1.In)([sales_base_1.ORDER_STATUS.CANCELLED, sales_base_1.ORDER_STATUS.PENDING_CANCEL]))
|
|
391
|
-
},
|
|
392
|
-
relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
393
|
-
});
|
|
394
|
-
if (foundSplittedReleaseGood)
|
|
395
|
-
throw new error_util_1.ApiError('E05', `existing release order found: ${foundSplittedReleaseGood.name}`);
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
throw new error_util_1.ApiError('E05', `existing release order found: ${foundReleaseGood.name}`);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
async function createDraftOrder(releaseGood, orderProducts, context) {
|
|
405
|
-
return await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
406
|
-
return await (0, sales_base_1.createDraftReleaseGoodFunction)(null, releaseGood, orderProducts, null, [], context, tx);
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
async function createReleaseGood(releaseGood, orderProducts, bizplace, context, tx, worksheetPickingAssignment) {
|
|
410
|
-
var _a;
|
|
411
|
-
const { domain, user } = context.state;
|
|
412
|
-
const settingRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(setting_base_1.Setting)) || (0, typeorm_1.getRepository)(setting_base_1.Setting);
|
|
413
|
-
const geoCountryRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(geography_1.GeoCountry)) || (0, typeorm_1.getRepository)(geography_1.GeoCountry);
|
|
414
|
-
if (orderProducts.length <= 0) {
|
|
415
|
-
throw new error_util_1.ApiError('E04', `no order items found: ${JSON.stringify(releaseGood)}`);
|
|
416
|
-
}
|
|
417
|
-
let newReleaseGood = new sales_base_1.ReleaseGood();
|
|
418
|
-
// find RO number rule setting
|
|
419
|
-
const roNoSetting = await settingRepo.findOne({
|
|
420
|
-
where: {
|
|
421
|
-
domain,
|
|
422
|
-
name: sales_base_1.ORDER_NUMBER_SETTING_KEY.RO_NUMBER_RULE
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
let shippingOrder;
|
|
426
|
-
if (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.shippingOrder) {
|
|
427
|
-
shippingOrder = await tx.getRepository(sales_base_1.ShippingOrder).save({
|
|
428
|
-
name: sales_base_1.OrderNoGenerator.shippingOrder(),
|
|
429
|
-
shipName: releaseGood.shippingOrder.shipName,
|
|
430
|
-
containerNo: releaseGood.shippingOrder.containerNo,
|
|
431
|
-
loadType: releaseGood.shippingOrder.loadType,
|
|
432
|
-
from: releaseGood.shippingOrder.from,
|
|
433
|
-
to: releaseGood.shippingOrder.to,
|
|
434
|
-
containerArrivalDate: releaseGood.shippingOrder.containerArrivalDate,
|
|
435
|
-
containerLeavingDate: releaseGood.shippingOrder.containerLeavingDate,
|
|
436
|
-
status: sales_base_1.ORDER_STATUS.PENDING,
|
|
437
|
-
creator: user,
|
|
438
|
-
updater: user
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
// standardise country
|
|
442
|
-
let country = (_a = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.country) === null || _a === void 0 ? void 0 : _a.trim();
|
|
443
|
-
let deliveryCountry = country
|
|
444
|
-
? await geoCountryRepo.findOne({
|
|
445
|
-
where: [{ name: (0, typeorm_1.ILike)(country) }, { description: (0, typeorm_1.ILike)(country) }]
|
|
446
|
-
})
|
|
447
|
-
: null;
|
|
448
|
-
let platformCountry = (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.platformCountry)
|
|
449
|
-
? await geoCountryRepo.findOne({
|
|
450
|
-
where: [{ name: (0, typeorm_1.ILike)(releaseGood.platformCountry) }, { description: (0, typeorm_1.ILike)(releaseGood.platformCountry) }]
|
|
451
|
-
})
|
|
452
|
-
: null;
|
|
453
|
-
// assign lmd
|
|
454
|
-
let lmd = null;
|
|
455
|
-
if (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.lmdOption) {
|
|
456
|
-
lmd = await autoAssignLmd(domain, deliveryCountry === null || deliveryCountry === void 0 ? void 0 : deliveryCountry.id, releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.postalCode, bizplace);
|
|
457
|
-
}
|
|
458
|
-
let phoneNum = (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone1) ? releaseGood.phone1.replace(/[^\d]/g, '') : null;
|
|
459
|
-
let packingOption = lmd ? (lmd.isTms ? false : true) : releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.packingOption;
|
|
460
|
-
let courierOption = lmd ? (lmd.isTms ? false : true) : releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.courierOption;
|
|
461
|
-
newReleaseGood = {
|
|
462
|
-
name: roNoSetting
|
|
463
|
-
? await (0, id_rule_base_1.generateId)({ domain, type: sales_base_1.ORDER_NUMBER_RULE_TYPE.RO_NUMBER, seed: {} })
|
|
464
|
-
: sales_base_1.OrderNoGenerator.releaseGood(),
|
|
465
|
-
domain: domain,
|
|
466
|
-
bizplace: bizplace,
|
|
467
|
-
collectionOrderNo: releaseGood.collectionOrderNo,
|
|
468
|
-
courierOption: courierOption,
|
|
469
|
-
codOption: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.codOption,
|
|
470
|
-
exportOption: releaseGood.exportOption,
|
|
471
|
-
ownTransport: releaseGood.ownTransport,
|
|
472
|
-
packingOption: packingOption,
|
|
473
|
-
marketplaceOrderStatus: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.marketplaceOrderStatus) || null,
|
|
474
|
-
billingAddress: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.billingAddress) || null,
|
|
475
|
-
deliveryAddress1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress1) || null,
|
|
476
|
-
deliveryAddress2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress2) || null,
|
|
477
|
-
deliveryAddress3: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress3) || null,
|
|
478
|
-
deliveryAddress4: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress4) || null,
|
|
479
|
-
deliveryAddress5: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress5) || null,
|
|
480
|
-
attentionTo: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionTo) || null,
|
|
481
|
-
attentionCompany: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionCompany) || null,
|
|
482
|
-
city: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.city) || null,
|
|
483
|
-
ward: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.ward) || null,
|
|
484
|
-
district: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.district) || null,
|
|
485
|
-
state: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.state) || null,
|
|
486
|
-
postalCode: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.postalCode) || null,
|
|
487
|
-
country: (deliveryCountry === null || deliveryCountry === void 0 ? void 0 : deliveryCountry.description) || (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.country) || null,
|
|
488
|
-
phone1: phoneNum,
|
|
489
|
-
phone2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone2) || null,
|
|
490
|
-
email: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.email) || null,
|
|
491
|
-
transporter: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.transporter,
|
|
492
|
-
trackingNo: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.trackingNo,
|
|
493
|
-
airwayBill: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.airwayBill,
|
|
494
|
-
invoice: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.invoice,
|
|
495
|
-
refNo: releaseGood.refNo,
|
|
496
|
-
refNo2: releaseGood.refNo2 || null,
|
|
497
|
-
refNo3: releaseGood.refNo3 || null,
|
|
498
|
-
refOrderId: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.refOrderId) || null,
|
|
499
|
-
remark: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.remark) || null,
|
|
500
|
-
releaseDate: releaseGood.releaseDate,
|
|
501
|
-
truckNo: releaseGood.truckNo,
|
|
502
|
-
type: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.type) ? releaseGood.type : 'b2b',
|
|
503
|
-
status: sales_base_1.ORDER_STATUS.PENDING_WORKSHEET,
|
|
504
|
-
storeName: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.storeName,
|
|
505
|
-
storeId: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.storeId,
|
|
506
|
-
routeId: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.routeId,
|
|
507
|
-
stopId: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.stopId,
|
|
508
|
-
packageId: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.packageId) || null,
|
|
509
|
-
noOfItems: orderProducts.length,
|
|
510
|
-
source: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.source,
|
|
511
|
-
platformCode: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.platformCode,
|
|
512
|
-
platformCountry: (platformCountry === null || platformCountry === void 0 ? void 0 : platformCountry.description) || (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.platformCountry) || null,
|
|
513
|
-
platformName: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.platformName,
|
|
514
|
-
paidAmount: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.paidAmount,
|
|
515
|
-
discountAmount: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.discountAmount,
|
|
516
|
-
taxAmount: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.taxAmount,
|
|
517
|
-
shippingFee: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.shippingFee,
|
|
518
|
-
creator: user,
|
|
519
|
-
updater: user,
|
|
520
|
-
acceptedBy: user,
|
|
521
|
-
acceptedAt: new Date(),
|
|
522
|
-
shippingOrder: shippingOrder ? shippingOrder : null,
|
|
523
|
-
lastMileDelivery: lmd,
|
|
524
|
-
lmdOption: releaseGood.lmdOption,
|
|
525
|
-
priorityDelivery: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.priorityDelivery,
|
|
526
|
-
assignedInventory: (worksheetPickingAssignment === null || worksheetPickingAssignment === void 0 ? void 0 : worksheetPickingAssignment.value) == 'true' ? false : true,
|
|
527
|
-
orderMethod: sales_base_1.ORDER_METHOD.SELECT_BY_PRODUCT,
|
|
528
|
-
xilnexSetting: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.xilnexSetting,
|
|
529
|
-
sourceData: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.sourceData
|
|
530
|
-
};
|
|
531
|
-
let resultReleaseGood = await tx.getRepository(sales_base_1.ReleaseGood).save(newReleaseGood);
|
|
532
|
-
let combinedOrderInventories = [];
|
|
533
|
-
let combinedOrderProducts = [];
|
|
534
|
-
let savedOrderProducts = await Promise.all(orderProducts.map(async (orderProduct) => {
|
|
535
|
-
let orderInventories = orderProduct.orderInventories;
|
|
536
|
-
orderProduct = Object.assign(new sales_base_1.OrderProduct(), Object.assign(Object.assign({}, orderProduct), { name: (0, uuid_1.v4)(), domain: domain, bizplace: bizplace, releaseGood: resultReleaseGood, type: sales_base_1.ORDER_TYPES.RELEASE_OF_GOODS, status: sales_base_1.ORDER_PRODUCT_STATUS.ASSIGNED }));
|
|
537
|
-
let newOrderProduct = await tx.getRepository(sales_base_1.OrderProduct).save(orderProduct);
|
|
538
|
-
combinedOrderProducts.push({
|
|
539
|
-
product: { name: orderProduct.product.name, sku: orderProduct.product.sku },
|
|
540
|
-
packingType: orderProduct.packingType,
|
|
541
|
-
packingSize: orderProduct.packingSize,
|
|
542
|
-
releaseQty: orderProduct.releaseQty,
|
|
543
|
-
releaseUomValue: orderProduct.releaseUomValue,
|
|
544
|
-
refItemId: orderProduct.refItemId
|
|
545
|
-
});
|
|
546
|
-
if ((worksheetPickingAssignment === null || worksheetPickingAssignment === void 0 ? void 0 : worksheetPickingAssignment.value) !== 'true') {
|
|
547
|
-
for (let oiIdx = 0; oiIdx < orderInventories.length; oiIdx++) {
|
|
548
|
-
let orderInventory = Object.assign(new sales_base_1.OrderInventory(), Object.assign(Object.assign({}, orderInventories[oiIdx]), { name: (0, uuid_1.v4)(), domain: domain, bizplace: bizplace, releaseGood: resultReleaseGood, type: sales_base_1.ORDER_TYPES.RELEASE_OF_GOODS, status: sales_base_1.ORDER_INVENTORY_STATUS.PENDING_WORKSHEET, orderProduct: newOrderProduct }));
|
|
549
|
-
await tx.getRepository(sales_base_1.OrderInventory).save(orderInventory);
|
|
550
|
-
combinedOrderInventories.push({
|
|
551
|
-
product: { name: orderInventory.product.name, sku: orderInventory.product.sku },
|
|
552
|
-
batchId: orderInventory.batchId,
|
|
553
|
-
packingType: orderInventory.packingType,
|
|
554
|
-
packingSize: orderInventory.packingSize,
|
|
555
|
-
releaseQty: orderInventory.releaseQty,
|
|
556
|
-
releaseUomValue: orderInventory.releaseUomValue
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
return newOrderProduct;
|
|
561
|
-
}));
|
|
562
|
-
newReleaseGood.orderProducts = combinedOrderProducts;
|
|
563
|
-
newReleaseGood.orderInventories = combinedOrderInventories;
|
|
564
|
-
if (lmd === null || lmd === void 0 ? void 0 : lmd.isTms) {
|
|
565
|
-
const tmsService = (0, integration_lmd_2.getTmsService)(lmd === null || lmd === void 0 ? void 0 : lmd.platform);
|
|
566
|
-
tmsService.createShipment([resultReleaseGood]);
|
|
567
|
-
}
|
|
568
|
-
return newReleaseGood;
|
|
569
|
-
}
|
|
570
|
-
async function massageOrderItems(releaseGood, inputOrderProducts, context) {
|
|
571
|
-
const { t } = context;
|
|
572
|
-
let orderProducts = [];
|
|
573
|
-
//combine any repeated skus
|
|
574
|
-
inputOrderProducts = await inputOrderProducts.reduce(async (accPromise, itm, idx) => {
|
|
575
|
-
const acc = await accPromise;
|
|
576
|
-
let { sku, refCode } = itm.product;
|
|
577
|
-
let { packingType, packingSize, batchId, releaseQty, sellingPrice, paidAmount, uom, refItemId } = itm;
|
|
578
|
-
if (!sku && !refCode) {
|
|
579
|
-
throw new error_util_1.ApiError('E01', 'sku or refCode not found');
|
|
580
|
-
}
|
|
581
|
-
if (releaseQty <= 0) {
|
|
582
|
-
throw new error_util_1.ApiError('E01', 'negative stock request');
|
|
583
|
-
}
|
|
584
|
-
let existingIndex = acc.findIndex(itm => (itm === null || itm === void 0 ? void 0 : itm.sku) == (sku === null || sku === void 0 ? void 0 : sku.trim()) &&
|
|
585
|
-
(itm === null || itm === void 0 ? void 0 : itm.refCode) == (refCode === null || refCode === void 0 ? void 0 : refCode.trim()) &&
|
|
586
|
-
(itm === null || itm === void 0 ? void 0 : itm.packingType) == (packingType === null || packingType === void 0 ? void 0 : packingType.trim()) &&
|
|
587
|
-
(itm === null || itm === void 0 ? void 0 : itm.packingSize) == packingSize &&
|
|
588
|
-
(itm === null || itm === void 0 ? void 0 : itm.uom) == uom &&
|
|
589
|
-
(itm === null || itm === void 0 ? void 0 : itm.batchId) == ((batchId === null || batchId === void 0 ? void 0 : batchId.trim()) || ''));
|
|
590
|
-
if (existingIndex >= 0 && releaseQty > 0) {
|
|
591
|
-
acc[existingIndex].releaseQty = acc[existingIndex].releaseQty + releaseQty;
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
594
|
-
acc.push({
|
|
595
|
-
sku: sku === null || sku === void 0 ? void 0 : sku.trim(),
|
|
596
|
-
refCode: refCode === null || refCode === void 0 ? void 0 : refCode.trim(),
|
|
597
|
-
packingType: packingType === null || packingType === void 0 ? void 0 : packingType.trim(),
|
|
598
|
-
packingSize: packingSize,
|
|
599
|
-
releaseQty: releaseQty,
|
|
600
|
-
sellingPrice: sellingPrice,
|
|
601
|
-
paidAmount: paidAmount,
|
|
602
|
-
uom: uom,
|
|
603
|
-
batchId: (batchId === null || batchId === void 0 ? void 0 : batchId.trim()) || '',
|
|
604
|
-
refItemId: refItemId !== null && refItemId !== void 0 ? refItemId : ''
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
return acc;
|
|
608
|
-
}, Promise.resolve([]));
|
|
609
|
-
//find customer sku in system
|
|
610
|
-
await Promise.all(inputOrderProducts.map(async (inputOrderItem) => {
|
|
611
|
-
const sku = inputOrderItem.sku;
|
|
612
|
-
const uom = inputOrderItem === null || inputOrderItem === void 0 ? void 0 : inputOrderItem.uom;
|
|
613
|
-
const refCode = inputOrderItem.refCode;
|
|
614
|
-
const packingType = inputOrderItem.packingType;
|
|
615
|
-
const packingSize = inputOrderItem.packingSize;
|
|
616
|
-
const releaseQty = inputOrderItem.releaseQty;
|
|
617
|
-
const qb = (0, typeorm_1.getRepository)(product_base_1.ProductDetail)
|
|
618
|
-
.createQueryBuilder('PD')
|
|
619
|
-
.innerJoinAndSelect('PD.product', 'PROD')
|
|
620
|
-
.where('PROD.bizplace_id = :bizplaceId', { bizplaceId: releaseGood.companyBizplace.id })
|
|
621
|
-
.andWhere('PD.deleted_at ISNULL');
|
|
622
|
-
if (!sku && !refCode) {
|
|
623
|
-
throw new error_util_1.ApiError('E04', t('sku or refCode not found'));
|
|
624
|
-
}
|
|
625
|
-
if (refCode) {
|
|
626
|
-
qb.andWhere('PD.ref_code = :refCode', { refCode });
|
|
627
|
-
}
|
|
628
|
-
if (sku) {
|
|
629
|
-
qb.andWhere('PROD.sku = :sku', { sku });
|
|
630
|
-
}
|
|
631
|
-
if (packingType) {
|
|
632
|
-
qb.andWhere('PD.packing_type = :packingType', { packingType });
|
|
633
|
-
}
|
|
634
|
-
if (packingSize) {
|
|
635
|
-
qb.andWhere('PD.packing_size = :packingSize', { packingSize });
|
|
636
|
-
}
|
|
637
|
-
if (!packingType && !refCode && !packingSize) {
|
|
638
|
-
qb.andWhere('PD.is_default = :isDefault', { isDefault: true });
|
|
639
|
-
}
|
|
640
|
-
const productDetail = await qb.getOne();
|
|
641
|
-
// order Product based on product detail
|
|
642
|
-
if (productDetail) {
|
|
643
|
-
if (!productDetail.product.isInventoryDecimal && parseInt(String(releaseQty)) % 1 !== 0) {
|
|
644
|
-
throw new error_util_1.ApiError('E01', `releaseQty must be an integer for product ${sku || refCode}`);
|
|
645
|
-
}
|
|
646
|
-
let newOrderProduct = Object.assign({}, inputOrderItem);
|
|
647
|
-
newOrderProduct = Object.assign(Object.assign({}, newOrderProduct), { product: productDetail.product, productDetail: productDetail, packingType: productDetail.packingType, packingSize: packingSize || productDetail.packingSize, uom: productDetail.uom, uomValue: productDetail.uomValue, refCode: inputOrderItem.refCode, releaseQty: Math.round(inputOrderItem.releaseQty * 1000) / 1000, releaseUomValue: inputOrderItem.releaseQty * (productDetail.uomValue || 1), packQty: 0, actualPackQty: 0, palletQty: 0, actualPalletQty: 0, type: 'RELEASE_OF_GOODS', status: sales_base_1.ORDER_PRODUCT_STATUS.ASSIGNED, batchId: (inputOrderItem === null || inputOrderItem === void 0 ? void 0 : inputOrderItem.batchId) || '' });
|
|
648
|
-
newOrderProduct.orderInventories = [
|
|
649
|
-
Object.assign(Object.assign({}, newOrderProduct), { packQty: 0, actualPackQty: 0, palletQty: 0, actualPalletQty: 0, type: 'RELEASE_OF_GOODS', status: sales_base_1.ORDER_INVENTORY_STATUS.PENDING_WORKSHEET })
|
|
650
|
-
];
|
|
651
|
-
orderProducts.push(newOrderProduct);
|
|
652
|
-
}
|
|
653
|
-
if (!productDetail) {
|
|
654
|
-
const qb = (0, typeorm_1.getRepository)(product_base_1.ProductBundle)
|
|
655
|
-
.createQueryBuilder('PB')
|
|
656
|
-
.innerJoinAndSelect('PB.productBundleSettings', 'PBS')
|
|
657
|
-
.innerJoinAndSelect('PBS.productDetail', 'PBD')
|
|
658
|
-
.innerJoinAndSelect('PBD.product', 'PROD')
|
|
659
|
-
.where('PB.bizplace_id = :bizplaceId', { bizplaceId: releaseGood.companyBizplace.id });
|
|
660
|
-
if (!sku && !refCode) {
|
|
661
|
-
throw new error_util_1.ApiError('E04', 'sku or refCode not found');
|
|
662
|
-
}
|
|
663
|
-
if (refCode) {
|
|
664
|
-
qb.andWhere('PB.ref_code = :refCode', { refCode });
|
|
665
|
-
}
|
|
666
|
-
if (sku) {
|
|
667
|
-
qb.andWhere('PB.sku = :sku', { sku });
|
|
668
|
-
}
|
|
669
|
-
if (packingType) {
|
|
670
|
-
qb.andWhere('PB.packing_type = :packingType', { packingType });
|
|
671
|
-
}
|
|
672
|
-
const foundProductBundle = await qb.getOne();
|
|
673
|
-
if (foundProductBundle) {
|
|
674
|
-
if (inputOrderItem === null || inputOrderItem === void 0 ? void 0 : inputOrderItem.batchId)
|
|
675
|
-
throw new error_util_1.ApiError('E04', t('batchId not allowed for product bundle')); //bundle have no batchId
|
|
676
|
-
//to be further enhanced
|
|
677
|
-
let orderProduct = {
|
|
678
|
-
productBundle: foundProductBundle,
|
|
679
|
-
refCode,
|
|
680
|
-
packingType: foundProductBundle.packingType,
|
|
681
|
-
packingSize: packingSize || 1,
|
|
682
|
-
uom: inputOrderItem === null || inputOrderItem === void 0 ? void 0 : inputOrderItem.uom,
|
|
683
|
-
releaseQty: inputOrderItem.releaseQty,
|
|
684
|
-
releaseUomValue: inputOrderItem.releaseQty,
|
|
685
|
-
packQty: 0,
|
|
686
|
-
actualPackQty: 0,
|
|
687
|
-
palletQty: 0,
|
|
688
|
-
actualPalletQty: 0,
|
|
689
|
-
orderInventories: [],
|
|
690
|
-
type: 'RELEASE_OF_GOODS',
|
|
691
|
-
status: sales_base_1.ORDER_PRODUCT_STATUS.ASSIGNED,
|
|
692
|
-
batchId: ''
|
|
693
|
-
};
|
|
694
|
-
const bundleProductSettings = foundProductBundle.productBundleSettings;
|
|
695
|
-
bundleProductSettings.map(bundleProductSetting => {
|
|
696
|
-
const productDetailBundle = bundleProductSetting.productDetail;
|
|
697
|
-
let newOrderInventory = {
|
|
698
|
-
product: productDetailBundle.product,
|
|
699
|
-
productDetail: productDetailBundle,
|
|
700
|
-
sku: productDetailBundle.product.sku,
|
|
701
|
-
packingType: productDetailBundle.packingType,
|
|
702
|
-
packingSize: productDetailBundle.packingSize,
|
|
703
|
-
uom: productDetailBundle.uom,
|
|
704
|
-
packQty: 0,
|
|
705
|
-
actualPackQty: 0,
|
|
706
|
-
palletQty: 0,
|
|
707
|
-
actualPalletQty: 0,
|
|
708
|
-
releaseQty: inputOrderItem.releaseQty * bundleProductSetting.bundleQty,
|
|
709
|
-
releaseUomValue: inputOrderItem.releaseQty *
|
|
710
|
-
bundleProductSetting.bundleQty *
|
|
711
|
-
(productDetailBundle.uomValue <= 0 ? 1 : productDetailBundle.uomValue),
|
|
712
|
-
type: 'RELEASE_OF_GOODS',
|
|
713
|
-
status: sales_base_1.ORDER_INVENTORY_STATUS.PENDING_WORKSHEET
|
|
714
|
-
};
|
|
715
|
-
orderProduct.orderInventories.push(newOrderInventory);
|
|
716
|
-
});
|
|
717
|
-
orderProducts.push(orderProduct);
|
|
718
|
-
}
|
|
719
|
-
else {
|
|
720
|
-
if (sku && refCode) {
|
|
721
|
-
throw new error_util_1.ApiError('E04', t(`error.sku ${sku} and refCode ${refCode} not exist in product / bundle master`));
|
|
722
|
-
}
|
|
723
|
-
if (sku) {
|
|
724
|
-
throw new error_util_1.ApiError('E04', t(`error.sku ${sku} not exist in product / bundle master`));
|
|
725
|
-
}
|
|
726
|
-
if (refCode) {
|
|
727
|
-
throw new error_util_1.ApiError('E04', t(`error.refCode ${refCode} not exist in product / bundle master`));
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}));
|
|
732
|
-
//combine any repeated skus
|
|
733
|
-
let combinedItems = orderProducts.reduce((acc, op, idx) => {
|
|
734
|
-
let oi = (op === null || op === void 0 ? void 0 : op.orderInventories) || [];
|
|
735
|
-
oi.forEach(itm => {
|
|
736
|
-
let { sku, refCode } = itm.product;
|
|
737
|
-
let { packingType, packingSize, batchId, releaseQty, product, productDetail, uom } = itm;
|
|
738
|
-
if (!sku && !refCode) {
|
|
739
|
-
throw new error_util_1.ApiError('E04', t('error.sku or refCode not found'));
|
|
740
|
-
}
|
|
741
|
-
let existingIndex = acc.findIndex(itm => (itm === null || itm === void 0 ? void 0 : itm.sku) == (sku === null || sku === void 0 ? void 0 : sku.trim()) &&
|
|
742
|
-
(itm === null || itm === void 0 ? void 0 : itm.refCode) == (refCode === null || refCode === void 0 ? void 0 : refCode.trim()) &&
|
|
743
|
-
(itm === null || itm === void 0 ? void 0 : itm.packingType) == (packingType === null || packingType === void 0 ? void 0 : packingType.trim()) &&
|
|
744
|
-
(itm === null || itm === void 0 ? void 0 : itm.packingSize) == packingSize &&
|
|
745
|
-
(itm === null || itm === void 0 ? void 0 : itm.batchId) == (batchId === null || batchId === void 0 ? void 0 : batchId.trim()) &&
|
|
746
|
-
(itm === null || itm === void 0 ? void 0 : itm.uom) == (uom === null || uom === void 0 ? void 0 : uom.trim()));
|
|
747
|
-
if (existingIndex >= 0 && releaseQty > 0) {
|
|
748
|
-
acc[existingIndex].releaseQty = acc[existingIndex].releaseQty + releaseQty;
|
|
749
|
-
acc[existingIndex].releaseUomValue =
|
|
750
|
-
acc[existingIndex].releaseUomValue + releaseQty * (productDetail.uomValue <= 0 ? 1 : productDetail.uomValue);
|
|
751
|
-
}
|
|
752
|
-
else {
|
|
753
|
-
let updateObj = {
|
|
754
|
-
sku: sku === null || sku === void 0 ? void 0 : sku.trim(),
|
|
755
|
-
packingType: packingType === null || packingType === void 0 ? void 0 : packingType.trim(),
|
|
756
|
-
packingSize: packingSize,
|
|
757
|
-
uom: uom === null || uom === void 0 ? void 0 : uom.trim(),
|
|
758
|
-
releaseQty: releaseQty,
|
|
759
|
-
releaseUomValue: releaseQty * (productDetail.uomValue <= 0 ? 1 : productDetail.uomValue),
|
|
760
|
-
product,
|
|
761
|
-
productDetail
|
|
762
|
-
};
|
|
763
|
-
if (refCode)
|
|
764
|
-
updateObj['refCode'] = refCode.trim();
|
|
765
|
-
updateObj['batchId'] = batchId ? batchId === null || batchId === void 0 ? void 0 : batchId.trim() : '-';
|
|
766
|
-
acc.push(updateObj);
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
return acc;
|
|
770
|
-
}, []);
|
|
771
|
-
const mapJsonData = (releaseGood, orderProducts) => {
|
|
772
|
-
let mapData = {
|
|
773
|
-
refNo: releaseGood.refNo || null,
|
|
774
|
-
refOrderItem: releaseGood.refOrderItem || null,
|
|
775
|
-
orderProducts: orderProducts.map(itm => {
|
|
776
|
-
return {
|
|
777
|
-
releaseQty: itm.releaseQty,
|
|
778
|
-
refItemId: itm === null || itm === void 0 ? void 0 : itm.refItemId,
|
|
779
|
-
product: (itm === null || itm === void 0 ? void 0 : itm.product)
|
|
780
|
-
? {
|
|
781
|
-
id: itm.product.id,
|
|
782
|
-
sku: itm.product.sku
|
|
783
|
-
}
|
|
784
|
-
: null,
|
|
785
|
-
productBundle: (itm === null || itm === void 0 ? void 0 : itm.productBundle)
|
|
786
|
-
? {
|
|
787
|
-
id: itm.productBundle.id,
|
|
788
|
-
sku: itm.productBundle.sku,
|
|
789
|
-
sellingPrice: (itm === null || itm === void 0 ? void 0 : itm.sellingPrice) || null,
|
|
790
|
-
paidAmount: (itm === null || itm === void 0 ? void 0 : itm.paidAmount) || null
|
|
791
|
-
}
|
|
792
|
-
: null,
|
|
793
|
-
productDetail: (itm === null || itm === void 0 ? void 0 : itm.productDetail)
|
|
794
|
-
? {
|
|
795
|
-
id: itm.productDetail.id,
|
|
796
|
-
refCode: itm.productDetail.refCode,
|
|
797
|
-
uom: itm.productDetail.uom,
|
|
798
|
-
uomValue: itm.productDetail.uomValue,
|
|
799
|
-
packingType: itm.productDetail.packingType,
|
|
800
|
-
sellingPrice: (itm === null || itm === void 0 ? void 0 : itm.sellingPrice) || null,
|
|
801
|
-
paidAmount: (itm === null || itm === void 0 ? void 0 : itm.paidAmount) || null
|
|
802
|
-
}
|
|
803
|
-
: null
|
|
804
|
-
};
|
|
805
|
-
})
|
|
806
|
-
};
|
|
807
|
-
releaseGood.sourceData = JSON.stringify(mapData);
|
|
808
|
-
};
|
|
809
|
-
mapJsonData(releaseGood, orderProducts);
|
|
810
|
-
return { orderProducts, combinedItems };
|
|
811
|
-
}
|
|
812
|
-
async function assignToInventory(orderProducts, customerBizplace, context, tx, worksheetPickingAssignment) {
|
|
813
|
-
const { client, domain, user } = context.state;
|
|
814
|
-
const pickingProductSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
815
|
-
where: { domain, name: 'rule-for-picking-product' }
|
|
816
|
-
});
|
|
817
|
-
for (let opIdx = 0; opIdx < orderProducts.length; opIdx++) {
|
|
818
|
-
let orderProduct = orderProducts[opIdx];
|
|
819
|
-
let assignedOrderInventories = [];
|
|
820
|
-
const orderInventory = orderProduct.orderInventories;
|
|
821
|
-
let productBundle = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.productBundle;
|
|
822
|
-
let sortings = [];
|
|
823
|
-
for (let oiIdx = 0; oiIdx < orderInventory.length; oiIdx++) {
|
|
824
|
-
if ((worksheetPickingAssignment === null || worksheetPickingAssignment === void 0 ? void 0 : worksheetPickingAssignment.value) !== 'true') {
|
|
825
|
-
switch (orderInventory[oiIdx].product.pickingStrategy) {
|
|
826
|
-
case 'LIFO':
|
|
827
|
-
sortings.push({ name: 'iv.created_at', desc: true });
|
|
828
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
829
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
830
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
else {
|
|
834
|
-
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
835
|
-
}
|
|
836
|
-
break;
|
|
837
|
-
case 'FEFO':
|
|
838
|
-
sortings.push({ name: 'iv.expiration_date', desc: false }, { name: 'iv.created_at', desc: false });
|
|
839
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
840
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
841
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
else {
|
|
845
|
-
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
846
|
-
}
|
|
847
|
-
break;
|
|
848
|
-
case 'FMFO':
|
|
849
|
-
sortings.push({ name: 'iv.manufacture_date', desc: false }, { name: 'iv.created_at', desc: false });
|
|
850
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
851
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
852
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
else {
|
|
856
|
-
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
857
|
-
}
|
|
858
|
-
break;
|
|
859
|
-
case 'LOCATION':
|
|
860
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
861
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
862
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
else {
|
|
866
|
-
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
867
|
-
}
|
|
868
|
-
break;
|
|
869
|
-
//Every other case includes 'FIFO' will be applicable for this case
|
|
870
|
-
default:
|
|
871
|
-
sortings.push({ name: 'iv.created_at', desc: false });
|
|
872
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
873
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
874
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
else {
|
|
878
|
-
sortings.push({ name: 'loc.name', desc: false });
|
|
879
|
-
sortings.push({ name: 'iv.pallet_id', desc: false });
|
|
880
|
-
}
|
|
881
|
-
break;
|
|
882
|
-
}
|
|
883
|
-
let queryFilters = [];
|
|
884
|
-
let queryStrings = queryFilters.reduce((acc, itm, idx, arr) => {
|
|
885
|
-
acc.values.push(itm.filters);
|
|
886
|
-
switch (itm === null || itm === void 0 ? void 0 : itm.operator) {
|
|
887
|
-
case 'notin':
|
|
888
|
-
case 'in':
|
|
889
|
-
acc.query.push(`${itm.query} ${itm.operator == 'notin' ? 'NOT IN' : 'IN'} (${itm.filters
|
|
890
|
-
.map((itm, idx) => {
|
|
891
|
-
return `$${acc.values.length + 1}`;
|
|
892
|
-
})
|
|
893
|
-
.join(',')})`);
|
|
894
|
-
break;
|
|
895
|
-
default:
|
|
896
|
-
acc.query.push(`${itm.query} ${(itm === null || itm === void 0 ? void 0 : itm.operator) ? itm.operator : '='} $${acc.values.length + 1}`);
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
acc.query.push(`${itm.query} ${(itm === null || itm === void 0 ? void 0 : itm.operator) ? itm.operator : '='} $${acc.values.length + 1}`);
|
|
900
|
-
}, {
|
|
901
|
-
query: [],
|
|
902
|
-
values: []
|
|
903
|
-
});
|
|
904
|
-
let sortQuery = sortings
|
|
905
|
-
.map(itm => {
|
|
906
|
-
return `${itm.name} ${itm.desc ? 'DESC' : 'ASC'}`;
|
|
907
|
-
})
|
|
908
|
-
.join(`,`);
|
|
909
|
-
let params = [
|
|
910
|
-
user.id,
|
|
911
|
-
domain.id,
|
|
912
|
-
customerBizplace.id,
|
|
913
|
-
orderInventory[oiIdx].packingType,
|
|
914
|
-
orderInventory[oiIdx].packingSize,
|
|
915
|
-
orderInventory[oiIdx].product.id,
|
|
916
|
-
warehouse_base_1.INVENTORY_STATUS.STORED,
|
|
917
|
-
warehouse_base_1.LOCATION_TYPE.QUARANTINE,
|
|
918
|
-
warehouse_base_1.LOCATION_TYPE.RESERVE,
|
|
919
|
-
warehouse_base_1.LOCATION_TYPE.STORAGE
|
|
920
|
-
];
|
|
921
|
-
let batchId = orderInventory[oiIdx].batchId;
|
|
922
|
-
if (batchId)
|
|
923
|
-
params.push(batchId);
|
|
924
|
-
params = [...params, ...queryStrings.values];
|
|
925
|
-
let query = `
|
|
926
|
-
update inventories tgt set locked_qty = coalesce(locked_qty,0) + src.reserve_qty,
|
|
927
|
-
locked_uom_value = coalesce(locked_uom_value,0) + src.reserve_uom_value,
|
|
928
|
-
updated_at = NOW(),
|
|
929
|
-
updater_id = $1
|
|
930
|
-
from (
|
|
931
|
-
select "id", "pallet_id","carton_id", "batch_id", "batch_id_ref", "unit", "uom", "packing_type", "packing_size", "manufacture_year",
|
|
932
|
-
"reserve_qty", (("uom_value"/"qty") * "reserve_qty") as "reserve_uom_value" from (
|
|
933
|
-
select "sort_seq", "id", "pallet_id", "batch_id", "batch_id_ref", "unit", "uom", "packing_type", "packing_size", "manufacture_year", "carton_id", "uom_value", "locked_uom_value", "qty", "locked_qty", "created_at",
|
|
934
|
-
"release_qty", "release_uom_value", lock_amount,
|
|
935
|
-
case when "lock_amount" < 0 then "available_qty" else "available_qty" - "lock_amount" end as "reserve_qty"
|
|
936
|
-
from (
|
|
937
|
-
select *,
|
|
938
|
-
(
|
|
939
|
-
case when (qty - greatest(locked_qty, 0) - greatest(unassigned_qty, 0)) < 0 then 0
|
|
940
|
-
else qty - greatest(locked_qty, 0) - greatest(unassigned_qty, 0) end
|
|
941
|
-
) as available_qty,
|
|
942
|
-
sum(qty - locked_qty - release_qty - unassigned_qty) over (order by sort_seq asc rows between unbounded preceding and current row) as lock_amount
|
|
943
|
-
from (
|
|
944
|
-
SELECT 0 as sort_seq, null as id, null as pallet_id, null as batch_id, null as batch_id_ref,
|
|
945
|
-
null as unit, '${orderInventory[oiIdx].uom}' as uom, '${orderInventory[oiIdx].packingType}' as packing_type, '${orderInventory[oiIdx].packingSize}' as packing_size,
|
|
946
|
-
null as manufacture_year, null as carton_id, 0 as uom_value, 0 as locked_uom_value, 0 as qty, 0 as locked_qty, 0 as unassigned_uom_value, 0 as unassigned_qty, null as created_at,
|
|
947
|
-
${orderInventory[oiIdx].releaseQty}::numeric as release_qty, ${orderInventory[oiIdx].releaseUomValue}::numeric as release_uom_value
|
|
948
|
-
UNION
|
|
949
|
-
(
|
|
950
|
-
SELECT ROW_NUMBER() OVER(PARTITION BY iv.domain_id ORDER BY wiar.rank ${sortQuery ? ', ' + sortQuery : ''}) as sort_seq,
|
|
951
|
-
iv.id, iv.pallet_id, iv.batch_id, iv.batch_id_ref,
|
|
952
|
-
iv.unit, iv.uom, iv.packing_type, iv.packing_size,
|
|
953
|
-
iv.manufacture_year, iv.carton_id, iv.uom_value,
|
|
954
|
-
coalesce(iv.locked_uom_value,0) as locked_uom_value, iv.qty, greatest(coalesce(iv.locked_qty,0),0) as locked_qty, coalesce(pds.unassigned_uom_value,0) as unassigned_uom_value, greatest(coalesce(pds.unassigned_qty,0),0) as unassigned_qty,
|
|
955
|
-
iv.created_at, 0 as release_qty, 0 as release_uom_value
|
|
956
|
-
FROM "inventories" "iv"
|
|
957
|
-
LEFT JOIN "product_detail_stocks" "pds" ON "pds"."product_detail_id" = "iv"."product_detail_id"
|
|
958
|
-
INNER JOIN "locations" "loc" ON "loc"."id"="iv"."location_id"
|
|
959
|
-
INNER JOIN "products" "p" ON "p"."id"="iv"."product_id"
|
|
960
|
-
INNER JOIN "warehouse_inventory_assignment_rankings" "wiar" ON "wiar"."location_type"="loc"."type"
|
|
961
|
-
WHERE case when coalesce("iv"."locked_qty",0) < 0 then 0 else ("iv"."qty" - coalesce("iv"."locked_qty",0)) end > 0 AND
|
|
962
|
-
"iv"."domain_id" = $2 AND "iv"."bizplace_id" = $3 AND "iv"."packing_type" = $4 AND "iv"."packing_size" = $5 AND "iv"."product_id" = $6 AND "iv"."status" = $7 AND "loc"."type" NOT IN ($8, $9, $10)
|
|
963
|
-
AND ${batchId ? `"iv"."batch_id" = $11` : `1=1`}
|
|
964
|
-
AND "iv"."obsolete" = false AND case when "iv"."expiration_date" is not null and "p"."min_outbound_shelf_life" is not null then CURRENT_DATE < "iv"."expiration_date" - "p"."min_outbound_shelf_life" else true end
|
|
965
|
-
${queryStrings.query.length > 0 ? `AND ${queryStrings.join(' AND ')}` : ''}
|
|
966
|
-
ORDER BY wiar.rank ${sortQuery ? ', ' + sortQuery : ''}
|
|
967
|
-
)
|
|
968
|
-
) dt1
|
|
969
|
-
) dt2 where case when "lock_amount" < 0 then "available_qty" else "available_qty" - "lock_amount" end > 0
|
|
970
|
-
) dt3 where sort_seq > 0
|
|
971
|
-
) src where src.id = tgt.id
|
|
972
|
-
returning
|
|
973
|
-
tgt."id", tgt."qty", tgt."pallet_id", tgt."carton_id", tgt."batch_id", tgt."batch_id_ref", tgt."unit",
|
|
974
|
-
tgt."uom", tgt."packing_type", tgt."packing_size", tgt."manufacture_year",
|
|
975
|
-
tgt."locked_qty", tgt."uom_value", tgt."locked_uom_value", src."reserve_qty", src."reserve_uom_value";`;
|
|
976
|
-
let updatedInventories = await tx.getRepository(warehouse_base_1.Inventory).query(query, params);
|
|
977
|
-
console.log({
|
|
978
|
-
params: {
|
|
979
|
-
user: user.id || '',
|
|
980
|
-
domain: domain.id || '',
|
|
981
|
-
bizplace: customerBizplace.id || '',
|
|
982
|
-
packingType: orderInventory[oiIdx].packingType || '',
|
|
983
|
-
packingSize: orderInventory[oiIdx].packingSize || '',
|
|
984
|
-
productId: orderInventory[oiIdx].product.id || ''
|
|
985
|
-
},
|
|
986
|
-
result: updatedInventories[0] || '',
|
|
987
|
-
location: 'add-release-order unstable assignInventory',
|
|
988
|
-
time: new Date()
|
|
989
|
-
});
|
|
990
|
-
let totalAssigned = updatedInventories[0].reduce((acc, inv) => {
|
|
991
|
-
return acc + inv.reserve_qty;
|
|
992
|
-
}, 0);
|
|
993
|
-
let opReleaseQty = productBundle ? orderInventory[oiIdx].releaseQty : orderProduct.releaseQty;
|
|
994
|
-
// For non-decimal products, round the values before comparison
|
|
995
|
-
if (!orderInventory[oiIdx].product.isInventoryDecimal) {
|
|
996
|
-
opReleaseQty = Math.round(opReleaseQty);
|
|
997
|
-
totalAssigned = Math.round(totalAssigned);
|
|
998
|
-
}
|
|
999
|
-
else {
|
|
1000
|
-
// For decimal products, round to 3 decimal places
|
|
1001
|
-
opReleaseQty = Math.round(opReleaseQty * 1000) / 1000;
|
|
1002
|
-
totalAssigned = Math.round(totalAssigned * 1000) / 1000;
|
|
1003
|
-
}
|
|
1004
|
-
if (Math.abs(opReleaseQty - totalAssigned) > 0.001) {
|
|
1005
|
-
// Using small epsilon for float comparison
|
|
1006
|
-
throw new error_util_1.ApiError('E01', 'INSUFFICIENT_STOCK');
|
|
1007
|
-
}
|
|
1008
|
-
updatedInventories[0].forEach(inv => {
|
|
1009
|
-
let oi = Object.assign(Object.assign({}, orderInventory[oiIdx]), { inventory: { id: inv.id }, uom: inv.uom, packingType: inv.packing_type, batchId: inv.batch_id, releaseQty: inv.reserve_qty, releaseUomValue: inv.reserve_uom_value, pickedQty: 0, packedQty: 0, type: sales_base_1.ORDER_TYPES.RELEASE_OF_GOODS, status: sales_base_1.ORDER_INVENTORY_STATUS.PENDING_WORKSHEET, domain: { id: domain.id }, bizplace: { id: customerBizplace.id } });
|
|
1010
|
-
assignedOrderInventories.push(oi);
|
|
1011
|
-
});
|
|
1012
|
-
orderProducts[opIdx].orderInventories = assignedOrderInventories;
|
|
1013
|
-
}
|
|
1014
|
-
else {
|
|
1015
|
-
await tx
|
|
1016
|
-
.getRepository(warehouse_base_1.ProductDetailStock)
|
|
1017
|
-
.createQueryBuilder()
|
|
1018
|
-
.update(warehouse_base_1.ProductDetailStock)
|
|
1019
|
-
.set({
|
|
1020
|
-
unassignedQty: () => `"unassigned_qty" + ${orderInventory[oiIdx].releaseQty}`,
|
|
1021
|
-
unassignedUomValue: () => `"unassigned_uom_value" + ${orderInventory[oiIdx].releaseUomValue}`
|
|
1022
|
-
})
|
|
1023
|
-
.where({ productDetail: orderInventory[oiIdx].productDetail.id })
|
|
1024
|
-
.execute();
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
return orderProducts;
|
|
1029
|
-
}
|
|
1030
|
-
async function autoAssignLmd(domain, countryId, postalCode, bizplace) {
|
|
1031
|
-
let lmdResult;
|
|
1032
|
-
const qb = (0, typeorm_1.getRepository)(integration_lmd_1.LastMileDelivery)
|
|
1033
|
-
.createQueryBuilder('lmd')
|
|
1034
|
-
.leftJoinAndSelect('lmd.lastMileDeliverySettings', 'lmds')
|
|
1035
|
-
.innerJoinAndSelect('lmds.geoCountry', 'gc')
|
|
1036
|
-
.leftJoinAndSelect(`lmd.lastMileDeliveryBizplaces`, `lmdb`)
|
|
1037
|
-
.leftJoinAndSelect('lmdb.bizplace', 'bz')
|
|
1038
|
-
.where('lmd.domain_id = :domainId', { domainId: domain.id })
|
|
1039
|
-
.andWhere('lower(lmd.status) = :status', { status: 'active' })
|
|
1040
|
-
.andWhere('gc.id = :gcId', { gcId: countryId })
|
|
1041
|
-
.andWhere('lmdb.bizplace_id = :bzId', { bzId: bizplace.id })
|
|
1042
|
-
.orderBy('lmdb.bizplace_id', 'ASC');
|
|
1043
|
-
let lmdList = await qb.getMany();
|
|
1044
|
-
if (lmdList.length > 1) {
|
|
1045
|
-
qb.andWhere('lmd.id IN (:...lmdIds)', {
|
|
1046
|
-
lmdIds: lmdList.map(lmd => {
|
|
1047
|
-
return lmd.id;
|
|
1048
|
-
})
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
qb.andWhere(new typeorm_1.Brackets(qb => {
|
|
1052
|
-
qb.where(`lmds.include_postal_code = ''`)
|
|
1053
|
-
.orWhere('lmds.include_postal_code is null')
|
|
1054
|
-
.orWhere('lmds.include_postal_code like :includePostCode', { includePostCode: `%${postalCode}%` });
|
|
1055
|
-
}))
|
|
1056
|
-
.andWhere(new typeorm_1.Brackets(qb => {
|
|
1057
|
-
qb.where(`lmds.exclude_postal_code = ''`)
|
|
1058
|
-
.orWhere('lmds.exclude_postal_code is null')
|
|
1059
|
-
.orWhere('lmds.exclude_postal_code not like :excludePostCode', { excludePostCode: `%${postalCode}%` });
|
|
1060
|
-
}))
|
|
1061
|
-
.addOrderBy('lmds.include_postal_code')
|
|
1062
|
-
.addOrderBy('lmd.rank', 'ASC');
|
|
1063
|
-
lmdResult = await qb.getOne();
|
|
1064
|
-
if (!lmdResult) {
|
|
1065
|
-
const newQb = (0, typeorm_1.getRepository)(integration_lmd_1.LastMileDelivery)
|
|
1066
|
-
.createQueryBuilder('lmd')
|
|
1067
|
-
.leftJoinAndSelect('lmd.lastMileDeliverySettings', 'lmds')
|
|
1068
|
-
.innerJoinAndSelect('lmds.geoCountry', 'gc')
|
|
1069
|
-
.leftJoinAndSelect(`lmd.lastMileDeliveryBizplaces`, `lmdb`)
|
|
1070
|
-
.leftJoinAndSelect('lmdb.bizplace', 'bz')
|
|
1071
|
-
.where('lmd.domain_id = :domainId', { domainId: domain.id })
|
|
1072
|
-
.andWhere('lower(lmd.status) = :status', { status: 'active' })
|
|
1073
|
-
.andWhere('gc.id = :gcId', { gcId: countryId })
|
|
1074
|
-
.andWhere('lmdb.bizplace_id is null')
|
|
1075
|
-
.andWhere(new typeorm_1.Brackets(qb => {
|
|
1076
|
-
qb.where(`lmds.include_postal_code = ''`)
|
|
1077
|
-
.orWhere('lmds.include_postal_code is null')
|
|
1078
|
-
.orWhere('lmds.include_postal_code like :includePostCode', { includePostCode: `%${postalCode}%` });
|
|
1079
|
-
}))
|
|
1080
|
-
.andWhere(new typeorm_1.Brackets(qb => {
|
|
1081
|
-
qb.where(`lmds.exclude_postal_code = ''`)
|
|
1082
|
-
.orWhere('lmds.exclude_postal_code is null')
|
|
1083
|
-
.orWhere('lmds.exclude_postal_code not like :excludePostCode', { excludePostCode: `%${postalCode}%` });
|
|
1084
|
-
}))
|
|
1085
|
-
.orderBy('lmds.include_postal_code')
|
|
1086
|
-
.addOrderBy('lmd.rank', 'ASC');
|
|
1087
|
-
lmdResult = await newQb.getOne();
|
|
1088
|
-
}
|
|
1089
|
-
return lmdResult;
|
|
1090
|
-
}
|
|
1091
|
-
//# sourceMappingURL=add-release-order.js.map
|