@unchainedshop/core 4.0.0-rc.16 → 4.0.0-rc.18
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/lib/bulk-importer/createBulkImporter.d.ts +29 -6
- package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -1
- package/lib/bulk-importer/createBulkImporter.js +26 -19
- package/lib/bulk-importer/createBulkImporter.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.d.ts +552 -2
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.js +32 -5
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +20 -2
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.js +7 -2
- package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +552 -2
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.js +43 -7
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +14 -6
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +15 -6
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +17 -8
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +67 -2
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +18 -4
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts +125 -0
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.js +22 -0
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts +10 -2
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.js +4 -0
- package/lib/bulk-importer/handlers/filter/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts +125 -0
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.js +22 -0
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/create.d.ts +1317 -2
- package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/create.js +87 -8
- package/lib/bulk-importer/handlers/product/create.js.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts +20 -2
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.js +5 -0
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +278 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +64 -3
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +1 -1
- package/lib/bulk-importer/handlers/product/update.d.ts +1317 -2
- package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/update.js +89 -5
- package/lib/bulk-importer/handlers/product/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +67 -2
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.js +16 -2
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +73 -2
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.js +26 -2
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -1
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts +21 -0
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js +64 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js.map +1 -0
- package/lib/bulk-importer/index.d.ts +4 -0
- package/lib/bulk-importer/index.d.ts.map +1 -0
- package/lib/bulk-importer/index.js +4 -0
- package/lib/bulk-importer/index.js.map +1 -0
- package/lib/bulk-importer/upsertAsset.d.ts +21 -5
- package/lib/bulk-importer/upsertAsset.d.ts.map +1 -1
- package/lib/bulk-importer/upsertAsset.js +8 -0
- package/lib/bulk-importer/upsertAsset.js.map +1 -1
- package/lib/core-index.d.ts +4 -3
- package/lib/core-index.d.ts.map +1 -1
- package/lib/core-index.js +2 -2
- package/lib/core-index.js.map +1 -1
- package/lib/directors/BaseDiscountAdapter.d.ts +4 -4
- package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/BaseDiscountAdapter.js +1 -1
- package/lib/directors/BaseDiscountAdapter.js.map +1 -1
- package/lib/directors/BaseDiscountDirector.d.ts +1 -1
- package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
- package/lib/directors/BaseDiscountDirector.js +1 -1
- package/lib/directors/BaseDiscountDirector.js.map +1 -1
- package/lib/directors/BasePricingAdapter.d.ts +2 -2
- package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
- package/lib/directors/BasePricingDirector.d.ts.map +1 -1
- package/lib/directors/BasePricingDirector.js +3 -3
- package/lib/directors/BasePricingDirector.js.map +1 -1
- package/lib/directors/BasePricingSheet.js.map +1 -1
- package/lib/directors/BaseWorker.js +1 -1
- package/lib/directors/BaseWorker.js.map +1 -1
- package/lib/directors/DeliveryAdapter.d.ts +3 -3
- package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
- package/lib/directors/DeliveryDirector.d.ts +3 -3
- package/lib/directors/DeliveryDirector.d.ts.map +1 -1
- package/lib/directors/DeliveryDirector.js +29 -16
- package/lib/directors/DeliveryDirector.js.map +1 -1
- package/lib/directors/DeliveryPricingAdapter.d.ts +1 -1
- package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingDirector.js +3 -4
- package/lib/directors/DeliveryPricingDirector.js.map +1 -1
- package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingSheet.js +2 -1
- package/lib/directors/DeliveryPricingSheet.js.map +1 -1
- package/lib/directors/EnrollmentAdapter.d.ts +7 -4
- package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
- package/lib/directors/EnrollmentAdapter.js +1 -4
- package/lib/directors/EnrollmentAdapter.js.map +1 -1
- package/lib/directors/EnrollmentDirector.d.ts +1 -1
- package/lib/directors/EnrollmentDirector.d.ts.map +1 -1
- package/lib/directors/EnrollmentDirector.js +1 -5
- package/lib/directors/EnrollmentDirector.js.map +1 -1
- package/lib/directors/FilterAdapter.d.ts +3 -3
- package/lib/directors/FilterAdapter.d.ts.map +1 -1
- package/lib/directors/FilterDirector.d.ts +1 -1
- package/lib/directors/FilterDirector.d.ts.map +1 -1
- package/lib/directors/FilterDirector.js +1 -1
- package/lib/directors/FilterDirector.js.map +1 -1
- package/lib/directors/MessagingDirector.d.ts +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/OrderDiscountAdapter.js.map +1 -1
- package/lib/directors/OrderPricingAdapter.d.ts +2 -2
- package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
- package/lib/directors/OrderPricingDirector.d.ts +2 -2
- package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
- package/lib/directors/OrderPricingDirector.js +1 -1
- package/lib/directors/OrderPricingDirector.js.map +1 -1
- package/lib/directors/OrderPricingSheet.d.ts.map +1 -1
- package/lib/directors/OrderPricingSheet.js +2 -1
- package/lib/directors/OrderPricingSheet.js.map +1 -1
- package/lib/directors/PaymentAdapter.d.ts +2 -2
- package/lib/directors/PaymentAdapter.d.ts.map +1 -1
- package/lib/directors/PaymentDirector.d.ts +4 -4
- package/lib/directors/PaymentDirector.d.ts.map +1 -1
- package/lib/directors/PaymentDirector.js +22 -4
- package/lib/directors/PaymentDirector.js.map +1 -1
- package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
- package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
- package/lib/directors/PaymentPricingDirector.d.ts +1 -1
- package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
- package/lib/directors/PaymentPricingDirector.js +3 -5
- package/lib/directors/PaymentPricingDirector.js.map +1 -1
- package/lib/directors/PaymentPricingSheet.d.ts.map +1 -1
- package/lib/directors/PaymentPricingSheet.js +2 -1
- package/lib/directors/PaymentPricingSheet.js.map +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/ProductDiscountAdapter.js.map +1 -1
- package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
- package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
- package/lib/directors/ProductPricingAdapter.d.ts +1 -1
- package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
- package/lib/directors/ProductPricingDirector.d.ts +2 -2
- package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
- package/lib/directors/ProductPricingDirector.js +3 -3
- package/lib/directors/ProductPricingDirector.js.map +1 -1
- package/lib/directors/ProductPricingSheet.d.ts +2 -2
- package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
- package/lib/directors/ProductPricingSheet.js +2 -1
- package/lib/directors/ProductPricingSheet.js.map +1 -1
- package/lib/directors/QuotationAdapter.d.ts +2 -2
- package/lib/directors/QuotationAdapter.d.ts.map +1 -1
- package/lib/directors/QuotationDirector.js +2 -2
- package/lib/directors/WarehousingAdapter.d.ts +3 -4
- package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
- package/lib/directors/WarehousingAdapter.js.map +1 -1
- package/lib/directors/WarehousingDirector.d.ts +5 -5
- package/lib/directors/WarehousingDirector.d.ts.map +1 -1
- package/lib/directors/WarehousingDirector.js +10 -13
- package/lib/directors/WarehousingDirector.js.map +1 -1
- package/lib/directors/WorkerAdapter.d.ts +1 -1
- package/lib/directors/WorkerAdapter.d.ts.map +1 -1
- package/lib/directors/WorkerAdapter.js +1 -1
- package/lib/directors/WorkerAdapter.js.map +1 -1
- package/lib/directors/WorkerDirector.d.ts +2 -2
- package/lib/directors/WorkerDirector.d.ts.map +1 -1
- package/lib/directors/WorkerDirector.js +2 -3
- package/lib/directors/WorkerDirector.js.map +1 -1
- package/lib/modules.d.ts +1 -1
- package/lib/modules.d.ts.map +1 -1
- package/lib/services/activateEnrollment.js +3 -3
- package/lib/services/activateEnrollment.js.map +1 -1
- package/lib/services/calculateDiscountTotal.js +2 -2
- package/lib/services/calculateDiscountTotal.js.map +1 -1
- package/lib/services/checkoutOrder.d.ts +1 -1
- package/lib/services/checkoutOrder.d.ts.map +1 -1
- package/lib/services/checkoutOrder.js +9 -3
- package/lib/services/checkoutOrder.js.map +1 -1
- package/lib/services/confirmOrder.d.ts +1 -1
- package/lib/services/confirmOrder.d.ts.map +1 -1
- package/lib/services/createDownloadStream.d.ts +1 -1
- package/lib/services/createDownloadStream.d.ts.map +1 -1
- package/lib/services/createDownloadStream.js +2 -0
- package/lib/services/createDownloadStream.js.map +1 -1
- package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
- package/lib/services/createEnrollmentFromCheckout.js +2 -2
- package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
- package/lib/services/createManualOrderDiscount.d.ts +2 -2
- package/lib/services/createManualOrderDiscount.d.ts.map +1 -1
- package/lib/services/createSignedURL.d.ts.map +1 -1
- package/lib/services/createSignedURL.js +2 -0
- package/lib/services/createSignedURL.js.map +1 -1
- package/lib/services/deleteUser.d.ts +1 -1
- package/lib/services/deleteUser.d.ts.map +1 -1
- package/lib/services/deleteUser.js +4 -2
- package/lib/services/deleteUser.js.map +1 -1
- package/lib/services/discountedEntities.js.map +1 -1
- package/lib/services/findOrInitCart.d.ts +1 -2
- package/lib/services/findOrInitCart.d.ts.map +1 -1
- package/lib/services/findOrInitCart.js.map +1 -1
- package/lib/services/fullfillQuotation.d.ts +1 -1
- package/lib/services/fullfillQuotation.d.ts.map +1 -1
- package/lib/services/fullfillQuotation.js.map +1 -1
- package/lib/services/generateOrderFromEnrollment.d.ts +7 -0
- package/lib/services/generateOrderFromEnrollment.d.ts.map +1 -0
- package/lib/services/generateOrderFromEnrollment.js +34 -0
- package/lib/services/generateOrderFromEnrollment.js.map +1 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +2 -0
- package/lib/services/index.js.map +1 -1
- package/lib/services/initCartProviders.js.map +1 -1
- package/lib/services/initializeEnrollment.d.ts +1 -1
- package/lib/services/initializeEnrollment.d.ts.map +1 -1
- package/lib/services/initializeEnrollment.js +6 -3
- package/lib/services/initializeEnrollment.js.map +1 -1
- package/lib/services/linkFileService.d.ts +1 -1
- package/lib/services/linkFileService.d.ts.map +1 -1
- package/lib/services/linkFileService.js +3 -1
- package/lib/services/linkFileService.js.map +1 -1
- package/lib/services/loadFilterOptions.d.ts +2 -2
- package/lib/services/loadFilterOptions.d.ts.map +1 -1
- package/lib/services/migrateOrderCart.d.ts +1 -1
- package/lib/services/migrateOrderCart.d.ts.map +1 -1
- package/lib/services/nextUserCart.d.ts +1 -1
- package/lib/services/nextUserCart.d.ts.map +1 -1
- package/lib/services/nextUserCart.js +1 -1
- package/lib/services/nextUserCart.js.map +1 -1
- package/lib/services/processEnrollment.d.ts.map +1 -1
- package/lib/services/processEnrollment.js +13 -5
- package/lib/services/processEnrollment.js.map +1 -1
- package/lib/services/processOrder.d.ts.map +1 -1
- package/lib/services/processOrder.js +26 -30
- package/lib/services/processOrder.js.map +1 -1
- package/lib/services/processQuotation.js +6 -6
- package/lib/services/processQuotation.js.map +1 -1
- package/lib/services/proposeQuotation.d.ts +1 -1
- package/lib/services/proposeQuotation.d.ts.map +1 -1
- package/lib/services/proposeQuotation.js +2 -2
- package/lib/services/proposeQuotation.js.map +1 -1
- package/lib/services/registerPaymentCredentials.d.ts +1 -2
- package/lib/services/registerPaymentCredentials.d.ts.map +1 -1
- package/lib/services/registerPaymentCredentials.js +4 -6
- package/lib/services/registerPaymentCredentials.js.map +1 -1
- package/lib/services/rejectOrder.d.ts +1 -1
- package/lib/services/rejectOrder.d.ts.map +1 -1
- package/lib/services/rejectQuotation.d.ts +1 -1
- package/lib/services/rejectQuotation.d.ts.map +1 -1
- package/lib/services/rejectQuotation.js +2 -2
- package/lib/services/rejectQuotation.js.map +1 -1
- package/lib/services/removeProduct.js +3 -3
- package/lib/services/removeProduct.js.map +1 -1
- package/lib/services/searchAssortments.js +1 -1
- package/lib/services/searchAssortments.js.map +1 -1
- package/lib/services/searchProducts.js +1 -1
- package/lib/services/searchProducts.js.map +1 -1
- package/lib/services/simulateProductDispatching.d.ts +1 -1
- package/lib/services/simulateProductDispatching.d.ts.map +1 -1
- package/lib/services/simulateProductInventory.d.ts +1 -1
- package/lib/services/simulateProductInventory.d.ts.map +1 -1
- package/lib/services/simulateProductInventory.js.map +1 -1
- package/lib/services/simulateProductPricing.d.ts +7 -4
- package/lib/services/simulateProductPricing.d.ts.map +1 -1
- package/lib/services/simulateProductPricing.js.map +1 -1
- package/lib/services/updateCalculation.d.ts +2 -1
- package/lib/services/updateCalculation.d.ts.map +1 -1
- package/lib/services/updateCalculation.js +16 -10
- package/lib/services/updateCalculation.js.map +1 -1
- package/lib/services/updateScheduling.d.ts +1 -1
- package/lib/services/updateScheduling.d.ts.map +1 -1
- package/lib/services/updateScheduling.js +7 -11
- package/lib/services/updateScheduling.js.map +1 -1
- package/lib/services/updateUserAvatarAfterUpload.d.ts +1 -1
- package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -1
- package/lib/services/updateUserAvatarAfterUpload.js.map +1 -1
- package/lib/services/uploadFileFromStream.d.ts.map +1 -1
- package/lib/services/uploadFileFromStream.js +4 -1
- package/lib/services/uploadFileFromStream.js.map +1 -1
- package/lib/services/uploadFileFromURL.d.ts +1 -2
- package/lib/services/uploadFileFromURL.d.ts.map +1 -1
- package/lib/services/uploadFileFromURL.js.map +1 -1
- package/lib/services/validateOrder.d.ts +1 -1
- package/lib/services/validateOrder.d.ts.map +1 -1
- package/lib/services/validateOrder.js +17 -24
- package/lib/services/validateOrder.js.map +1 -1
- package/lib/services/verifyQuotation.d.ts +1 -1
- package/lib/services/verifyQuotation.d.ts.map +1 -1
- package/lib/services/verifyQuotation.js +2 -2
- package/lib/services/verifyQuotation.js.map +1 -1
- package/package.json +20 -20
- package/src/bulk-importer/createBulkImporter.ts +34 -22
- package/src/bulk-importer/handlers/assortment/create.ts +38 -7
- package/src/bulk-importer/handlers/assortment/remove.ts +14 -3
- package/src/bulk-importer/handlers/assortment/update.ts +53 -9
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +44 -19
- package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +37 -9
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +35 -9
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +23 -5
- package/src/bulk-importer/handlers/filter/create.ts +28 -0
- package/src/bulk-importer/handlers/filter/remove.ts +6 -1
- package/src/bulk-importer/handlers/filter/update.ts +28 -1
- package/src/bulk-importer/handlers/product/create.ts +109 -9
- package/src/bulk-importer/handlers/product/remove.ts +7 -1
- package/src/bulk-importer/handlers/product/update.ts +117 -8
- package/src/bulk-importer/handlers/product/upsertMedia.ts +20 -3
- package/src/bulk-importer/handlers/product/upsertVariations.ts +43 -4
- package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +1 -1
- package/src/bulk-importer/index.ts +3 -0
- package/src/bulk-importer/upsertAsset.ts +10 -2
- package/src/core-index.ts +4 -6
- package/src/directors/BaseDiscountAdapter.test.ts +1 -1
- package/src/directors/BaseDiscountAdapter.ts +5 -5
- package/src/directors/BaseDiscountDirector.ts +2 -2
- package/src/directors/BasePricingAdapter.ts +2 -2
- package/src/directors/BasePricingDirector.ts +47 -44
- package/src/directors/BasePricingSheet.ts +1 -1
- package/src/directors/BaseWorker.ts +1 -1
- package/src/directors/DeliveryAdapter.ts +3 -3
- package/src/directors/DeliveryDirector.ts +33 -23
- package/src/directors/DeliveryPricingAdapter.ts +1 -1
- package/src/directors/DeliveryPricingDirector.ts +5 -6
- package/src/directors/DeliveryPricingSheet.ts +3 -2
- package/src/directors/EnrollmentAdapter.ts +9 -6
- package/src/directors/EnrollmentDirector.ts +9 -8
- package/src/directors/FilterAdapter.ts +3 -3
- package/src/directors/FilterDirector.ts +5 -5
- package/src/directors/OrderDiscountAdapter.ts +2 -2
- package/src/directors/OrderPricingAdapter.ts +2 -2
- package/src/directors/OrderPricingDirector.ts +3 -3
- package/src/directors/OrderPricingSheet.ts +3 -2
- package/src/directors/PaymentAdapter.ts +2 -2
- package/src/directors/PaymentDirector.ts +32 -8
- package/src/directors/PaymentPricingAdapter.ts +2 -2
- package/src/directors/PaymentPricingDirector.ts +6 -8
- package/src/directors/PaymentPricingSheet.ts +3 -2
- package/src/directors/ProductDiscountAdapter.ts +2 -2
- package/src/directors/ProductDiscountConfiguration.ts +1 -1
- package/src/directors/ProductPricingAdapter.ts +1 -1
- package/src/directors/ProductPricingDirector.ts +7 -7
- package/src/directors/ProductPricingSheet.ts +4 -3
- package/src/directors/QuotationAdapter.ts +2 -2
- package/src/directors/QuotationDirector.ts +2 -2
- package/src/directors/WarehousingAdapter.ts +3 -4
- package/src/directors/WarehousingDirector.ts +20 -23
- package/src/directors/WorkerAdapter.ts +2 -2
- package/src/directors/WorkerDirector.ts +5 -6
- package/src/modules.ts +1 -1
- package/src/services/activateEnrollment.ts +5 -5
- package/src/services/calculateDiscountTotal.ts +4 -4
- package/src/services/checkoutOrder.ts +9 -4
- package/src/services/createDownloadStream.ts +1 -0
- package/src/services/createEnrollmentFromCheckout.ts +22 -20
- package/src/services/createManualOrderDiscount.ts +2 -2
- package/src/services/createSignedURL.ts +1 -0
- package/src/services/deleteUser.ts +7 -2
- package/src/services/discountedEntities.ts +6 -6
- package/src/services/findOrInitCart.ts +1 -2
- package/src/services/fullfillQuotation.ts +1 -1
- package/src/services/generateOrderFromEnrollment.ts +54 -0
- package/src/services/index.ts +4 -0
- package/src/services/initCartProviders.ts +2 -2
- package/src/services/initializeEnrollment.ts +11 -4
- package/src/services/linkFileService.ts +3 -1
- package/src/services/nextUserCart.ts +1 -1
- package/src/services/processEnrollment.ts +18 -6
- package/src/services/processOrder.ts +33 -36
- package/src/services/processQuotation.ts +6 -6
- package/src/services/proposeQuotation.ts +2 -2
- package/src/services/registerPaymentCredentials.ts +6 -8
- package/src/services/rejectQuotation.ts +2 -2
- package/src/services/removeProduct.ts +3 -3
- package/src/services/searchAssortments.ts +1 -1
- package/src/services/searchProducts.ts +1 -1
- package/src/services/simulateProductDispatching.ts +1 -1
- package/src/services/simulateProductInventory.ts +7 -3
- package/src/services/simulateProductPricing.ts +6 -3
- package/src/services/updateCalculation.ts +33 -18
- package/src/services/updateScheduling.ts +19 -20
- package/src/services/updateUserAvatarAfterUpload.ts +4 -1
- package/src/services/uploadFileFromStream.ts +3 -1
- package/src/services/uploadFileFromURL.ts +2 -2
- package/src/services/validateOrder.ts +34 -38
- package/src/services/verifyQuotation.ts +2 -2
- package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts +0 -5
- package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts.map +0 -1
- package/lib/factory/registerProductDiscoverabilityFilter copy.js +0 -28
- package/lib/factory/registerProductDiscoverabilityFilter copy.js.map +0 -1
- package/src/bulk-importer/handlers/product/transformSpecificationToProductStructure.ts +0 -22
package/src/services/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { simulateProductDispatchingService } from './simulateProductDispatching.
|
|
|
45
45
|
import { simulateProductInventoryService } from './simulateProductInventory.js';
|
|
46
46
|
import { findOrInitCartService } from './findOrInitCart.js';
|
|
47
47
|
import { addMessageService } from './addMessage.js';
|
|
48
|
+
import { generateOrderFromEnrollmentService } from './generateOrderFromEnrollment.js';
|
|
48
49
|
|
|
49
50
|
// Auto-Inject Unchained API as last parameter
|
|
50
51
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
|
|
@@ -135,6 +136,9 @@ export default function initServices(modules: Modules, customServices: CustomSer
|
|
|
135
136
|
createEnrollmentFromCheckout: createEnrollmentFromCheckoutService as Bound<
|
|
136
137
|
typeof createEnrollmentFromCheckoutService
|
|
137
138
|
>,
|
|
139
|
+
generateOrderFromEnrollment: generateOrderFromEnrollmentService as Bound<
|
|
140
|
+
typeof generateOrderFromEnrollmentService
|
|
141
|
+
>,
|
|
138
142
|
processEnrollment: processOrderService as Bound<typeof processOrderService>,
|
|
139
143
|
initializeEnrollment: initializeEnrollmentService as Bound<typeof initializeEnrollmentService>,
|
|
140
144
|
activateEnrollment: activateEnrollmentService as Bound<typeof activateEnrollmentService>,
|
|
@@ -14,7 +14,7 @@ export async function initCartProvidersService(this: Modules, order: Order) {
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const orderDelivery = await this.orders.deliveries.findDelivery({
|
|
17
|
-
orderDeliveryId: updatedOrder.deliveryId
|
|
17
|
+
orderDeliveryId: updatedOrder.deliveryId!,
|
|
18
18
|
});
|
|
19
19
|
const deliveryProviderId = orderDelivery?.deliveryProviderId;
|
|
20
20
|
|
|
@@ -45,7 +45,7 @@ export async function initCartProvidersService(this: Modules, order: Order) {
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
48
|
-
orderPaymentId: updatedOrder.paymentId
|
|
48
|
+
orderPaymentId: updatedOrder.paymentId!,
|
|
49
49
|
});
|
|
50
50
|
const paymentProviderId = orderPayment?.paymentProviderId;
|
|
51
51
|
|
|
@@ -9,20 +9,27 @@ export async function initializeEnrollmentService(
|
|
|
9
9
|
enrollment: Enrollment,
|
|
10
10
|
params: { orderIdForFirstPeriod?: string; reason: string },
|
|
11
11
|
) {
|
|
12
|
-
const
|
|
12
|
+
const product = await this.products.findProduct({
|
|
13
|
+
productId: enrollment.productId,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const director = await EnrollmentDirector.actions(
|
|
17
|
+
{ enrollment, product: product! },
|
|
18
|
+
{ modules: this },
|
|
19
|
+
);
|
|
13
20
|
const period = await director.nextPeriod();
|
|
14
21
|
|
|
15
22
|
let updatedEnrollment = enrollment;
|
|
16
23
|
if (period && (params.orderIdForFirstPeriod || period.isTrial)) {
|
|
17
|
-
updatedEnrollment = await this.enrollments.addEnrollmentPeriod(enrollment._id, {
|
|
24
|
+
updatedEnrollment = (await this.enrollments.addEnrollmentPeriod(enrollment._id, {
|
|
18
25
|
...period,
|
|
19
26
|
orderId: params.orderIdForFirstPeriod,
|
|
20
|
-
});
|
|
27
|
+
})) as Enrollment;
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
const processedEnrollment = await processEnrollmentService.bind(this)(updatedEnrollment);
|
|
24
31
|
const user = await this.users.findUserById(enrollment.userId);
|
|
25
|
-
const locale = this.users.userLocale(user);
|
|
32
|
+
const locale = this.users.userLocale(user!);
|
|
26
33
|
|
|
27
34
|
await addMessageService.bind(this)('ENROLLMENT_STATUS', {
|
|
28
35
|
reason: 'status_change',
|
|
@@ -6,11 +6,13 @@ export async function linkFileService(
|
|
|
6
6
|
{ fileId, size, type }: { fileId: string; size?: number; type?: string },
|
|
7
7
|
) {
|
|
8
8
|
const file = await this.files.findFile({ fileId });
|
|
9
|
+
if (!file) return null;
|
|
10
|
+
|
|
9
11
|
await this.files.update(file._id, {
|
|
10
12
|
size: size || file.size,
|
|
11
13
|
type: type || file.type,
|
|
12
|
-
expires: null,
|
|
13
14
|
});
|
|
15
|
+
await this.files.unexpire(file._id);
|
|
14
16
|
if (file?.expires) {
|
|
15
17
|
const callback = FileDirector.getFileUploadCallback(file.path);
|
|
16
18
|
if (callback) {
|
|
@@ -30,7 +30,7 @@ export async function nextUserCartService(
|
|
|
30
30
|
|
|
31
31
|
const countryObject = await this.countries.findCountry({ isoCode: countryCode });
|
|
32
32
|
const currencies = await this.currencies.findCurrencies({ includeInactive: false });
|
|
33
|
-
const currencyCode = resolveBestCurrency(countryObject
|
|
33
|
+
const currencyCode = resolveBestCurrency(countryObject?.defaultCurrencyCode || null, currencies);
|
|
34
34
|
|
|
35
35
|
const order = await this.orders.create({
|
|
36
36
|
userId: user._id,
|
|
@@ -2,9 +2,18 @@ import { Enrollment, EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
|
2
2
|
import { Modules } from '../modules.js';
|
|
3
3
|
import { EnrollmentDirector } from '../core-index.js';
|
|
4
4
|
|
|
5
|
-
const findNextStatus = async (
|
|
5
|
+
const findNextStatus = async (
|
|
6
|
+
enrollment: Enrollment,
|
|
7
|
+
modules: Modules,
|
|
8
|
+
): Promise<EnrollmentStatus | null> => {
|
|
6
9
|
let status = enrollment.status;
|
|
7
|
-
const
|
|
10
|
+
const product = await modules.products.findProduct({
|
|
11
|
+
productId: enrollment.productId,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!product) throw new Error('Product not found for enrollment');
|
|
15
|
+
|
|
16
|
+
const director = await EnrollmentDirector.actions({ enrollment, product }, { modules });
|
|
8
17
|
|
|
9
18
|
if (status === EnrollmentStatus.INITIAL || status === EnrollmentStatus.PAUSED) {
|
|
10
19
|
if (await director.isValidForActivation()) {
|
|
@@ -30,8 +39,11 @@ export async function processEnrollmentService(this: Modules, enrollment: Enroll
|
|
|
30
39
|
// status = await findNextStatus(nextEnrollment, unchainedAPI);
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
if (status) {
|
|
43
|
+
return this.enrollments.updateStatus(enrollment._id, {
|
|
44
|
+
status,
|
|
45
|
+
info: 'enrollment processed',
|
|
46
|
+
}) as Promise<Enrollment>;
|
|
47
|
+
}
|
|
48
|
+
return enrollment;
|
|
37
49
|
}
|
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
OrderDeliveryStatus,
|
|
5
5
|
OrderPayment,
|
|
6
6
|
OrderPaymentStatus,
|
|
7
|
+
OrderPosition,
|
|
7
8
|
OrderStatus,
|
|
8
9
|
} from '@unchainedshop/core-orders';
|
|
9
10
|
import { Modules } from '../modules.js';
|
|
10
11
|
import { createEnrollmentFromCheckoutService } from './createEnrollmentFromCheckout.js';
|
|
11
|
-
import { ProductTypes } from '@unchainedshop/core-products';
|
|
12
|
+
import { Product, ProductTypes } from '@unchainedshop/core-products';
|
|
12
13
|
import { WarehousingProviderType } from '@unchainedshop/core-warehousing';
|
|
13
14
|
import { WarehousingDirector, DeliveryDirector, PaymentDirector } from '../directors/index.js';
|
|
14
15
|
import { fullfillQuotationService } from './fullfillQuotation.js';
|
|
@@ -24,10 +25,12 @@ const isAutoConfirmationEnabled = async (
|
|
|
24
25
|
modules: Modules,
|
|
25
26
|
) => {
|
|
26
27
|
if (orderPayment.status !== OrderPaymentStatus.PAID) {
|
|
27
|
-
const
|
|
28
|
+
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
28
29
|
paymentProviderId: orderPayment.paymentProviderId,
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
+
if (!paymentProvider)
|
|
32
|
+
throw new Error('Payment provider not found: ' + orderPayment.paymentProviderId);
|
|
33
|
+
const actions = await PaymentDirector.actions(paymentProvider, {}, { modules });
|
|
31
34
|
if (!actions.isPayLaterAllowed()) return false;
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -35,6 +38,8 @@ const isAutoConfirmationEnabled = async (
|
|
|
35
38
|
const deliveryProvider = await modules.delivery.findProvider({
|
|
36
39
|
deliveryProviderId: orderDelivery.deliveryProviderId,
|
|
37
40
|
});
|
|
41
|
+
if (!deliveryProvider)
|
|
42
|
+
throw new Error('Delivery provider not found: ' + orderDelivery.deliveryProviderId);
|
|
38
43
|
const director = await DeliveryDirector.actions(deliveryProvider, {}, { modules });
|
|
39
44
|
if (!director.isAutoReleaseAllowed()) return false;
|
|
40
45
|
}
|
|
@@ -56,14 +61,18 @@ const findNextStatus = async (
|
|
|
56
61
|
return status;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
const orderPayment =
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
const orderPayment =
|
|
65
|
+
order.paymentId &&
|
|
66
|
+
(await modules.orders.payments.findOrderPayment({
|
|
67
|
+
orderPaymentId: order.paymentId,
|
|
68
|
+
}));
|
|
62
69
|
if (!orderPayment) return status;
|
|
63
70
|
|
|
64
|
-
const orderDelivery =
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
const orderDelivery =
|
|
72
|
+
order.deliveryId &&
|
|
73
|
+
(await modules.orders.deliveries.findDelivery({
|
|
74
|
+
orderDeliveryId: order.deliveryId,
|
|
75
|
+
}));
|
|
67
76
|
if (!orderDelivery) return status;
|
|
68
77
|
|
|
69
78
|
// Ok, we have a payment and a delivery and the correct status,
|
|
@@ -108,26 +117,18 @@ export async function processOrderService(
|
|
|
108
117
|
|
|
109
118
|
if (nextStatus === OrderStatus.PENDING) {
|
|
110
119
|
// auto charge during transition to pending
|
|
111
|
-
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
112
|
-
orderPaymentId: order.paymentId,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
120
|
await PaymentDirector.chargeOrderPayment(
|
|
116
|
-
|
|
121
|
+
order,
|
|
117
122
|
{ userId: order.userId, transactionContext: paymentContext },
|
|
118
123
|
{ modules: this },
|
|
119
124
|
);
|
|
120
|
-
|
|
121
125
|
nextStatus = await findNextStatus(nextStatus, order, this);
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
if (nextStatus === OrderStatus.REJECTED) {
|
|
125
129
|
// auto cancel during transition to rejected
|
|
126
|
-
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
127
|
-
orderPaymentId: order.paymentId,
|
|
128
|
-
});
|
|
129
130
|
await PaymentDirector.cancelOrderPayment(
|
|
130
|
-
|
|
131
|
+
order,
|
|
131
132
|
{ userId: order.userId, transactionContext: paymentContext },
|
|
132
133
|
{ modules: this },
|
|
133
134
|
);
|
|
@@ -135,11 +136,8 @@ export async function processOrderService(
|
|
|
135
136
|
|
|
136
137
|
if (nextStatus === OrderStatus.CONFIRMED) {
|
|
137
138
|
// confirm pre-authorized payments
|
|
138
|
-
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
139
|
-
orderPaymentId: order.paymentId,
|
|
140
|
-
});
|
|
141
139
|
await PaymentDirector.confirmOrderPayment(
|
|
142
|
-
|
|
140
|
+
order,
|
|
143
141
|
{ userId: order.userId, transactionContext: paymentContext },
|
|
144
142
|
{ modules: this },
|
|
145
143
|
);
|
|
@@ -147,27 +145,23 @@ export async function processOrderService(
|
|
|
147
145
|
// we have to stop here shortly to complete the confirmation
|
|
148
146
|
// before auto delivery is started, else we have no chance to create
|
|
149
147
|
// numbers that are needed for delivery
|
|
150
|
-
order = await this.orders.updateStatus(orderId, {
|
|
148
|
+
order = (await this.orders.updateStatus(orderId, {
|
|
151
149
|
status: OrderStatus.CONFIRMED,
|
|
152
150
|
info: comment,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const orderDelivery = await this.orders.deliveries.findDelivery({
|
|
156
|
-
orderDeliveryId: order.deliveryId,
|
|
157
|
-
});
|
|
151
|
+
})) as Order;
|
|
158
152
|
|
|
159
153
|
// TODO: What happens if this THROWS?
|
|
160
154
|
// Tokenization would be skipped?
|
|
161
155
|
// Enrollments will not be there?
|
|
162
156
|
// Quotations would not fulfil?
|
|
163
|
-
await DeliveryDirector.sendOrderDelivery(
|
|
157
|
+
await DeliveryDirector.sendOrderDelivery(order, deliveryContext, { modules: this });
|
|
164
158
|
|
|
165
159
|
const orderPositions = await this.orders.positions.findOrderPositions({ orderId });
|
|
166
160
|
const mappedProductOrderPositions = await Promise.all(
|
|
167
161
|
orderPositions.map(async (orderPosition) => {
|
|
168
|
-
const product = await this.products.findProduct({
|
|
162
|
+
const product = (await this.products.findProduct({
|
|
169
163
|
productId: orderPosition.productId,
|
|
170
|
-
});
|
|
164
|
+
})) as Product;
|
|
171
165
|
return {
|
|
172
166
|
orderPosition,
|
|
173
167
|
product,
|
|
@@ -176,7 +170,8 @@ export async function processOrderService(
|
|
|
176
170
|
);
|
|
177
171
|
const tokenizedItems = mappedProductOrderPositions.filter(
|
|
178
172
|
(item) => item.product?.type === ProductTypes.TokenizedProduct,
|
|
179
|
-
);
|
|
173
|
+
) as { orderPosition: OrderPosition; product: Product }[];
|
|
174
|
+
|
|
180
175
|
if (tokenizedItems.length > 0) {
|
|
181
176
|
// Give virtual warehouse a chance to instantiate new virtual objects
|
|
182
177
|
const virtualProviders = (await this.warehousing.allProviders()).filter(
|
|
@@ -184,7 +179,7 @@ export async function processOrderService(
|
|
|
184
179
|
);
|
|
185
180
|
|
|
186
181
|
// It's very important to do this in a series and not in Promise.all
|
|
187
|
-
// TODO: Actually, only createTokens should decide on the unique
|
|
182
|
+
// TODO: Actually, only createTokens should decide on the unique tokenSerialNumber
|
|
188
183
|
// and the tokens should be created with a distributed Lock to not assign the same id multiple times!
|
|
189
184
|
for (const { orderPosition, product } of tokenizedItems) {
|
|
190
185
|
for (const virtualProvider of virtualProviders) {
|
|
@@ -225,12 +220,14 @@ export async function processOrderService(
|
|
|
225
220
|
// Quotations: If we came here, the checkout succeeded, so we can fullfill underlying quotations
|
|
226
221
|
const quotationItems = mappedProductOrderPositions.filter(
|
|
227
222
|
(item) => item.orderPosition.quotationId,
|
|
228
|
-
);
|
|
223
|
+
) as { orderPosition: OrderPosition & { quotationId: string }; product: Product }[];
|
|
224
|
+
|
|
229
225
|
await Promise.all(
|
|
230
226
|
quotationItems.map(async ({ orderPosition }) => {
|
|
231
227
|
const quotation = await this.quotations.findQuotation({
|
|
232
228
|
quotationId: orderPosition.quotationId,
|
|
233
229
|
});
|
|
230
|
+
if (!quotation) return; // TODO: What happens then?
|
|
234
231
|
await fullfillQuotationService.bind(this)(quotation, {
|
|
235
232
|
orderId,
|
|
236
233
|
orderPositionId: orderPosition._id,
|
|
@@ -242,5 +239,5 @@ export async function processOrderService(
|
|
|
242
239
|
nextStatus = await findNextStatus(nextStatus, order, this);
|
|
243
240
|
}
|
|
244
241
|
|
|
245
|
-
return this.orders.updateStatus(order._id, { status: nextStatus, info: comment });
|
|
242
|
+
return (await this.orders.updateStatus(order._id, { status: nextStatus, info: comment })) as Order;
|
|
246
243
|
}
|
|
@@ -34,30 +34,30 @@ export async function processQuotationService(
|
|
|
34
34
|
await director.submitRequest(params.quotationContext);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
quotation = await this.quotations.findQuotation({ quotationId });
|
|
37
|
+
quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
|
|
38
38
|
nextStatus = await findNextStatus(quotation, this);
|
|
39
39
|
if (nextStatus !== QuotationStatus.PROCESSING) {
|
|
40
40
|
await director.verifyRequest(params.quotationContext);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
quotation = await this.quotations.findQuotation({ quotationId });
|
|
43
|
+
quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
|
|
44
44
|
nextStatus = await findNextStatus(quotation, this);
|
|
45
45
|
if (nextStatus === QuotationStatus.REJECTED) {
|
|
46
46
|
await director.rejectRequest(params.quotationContext);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
quotation = await this.quotations.findQuotation({ quotationId });
|
|
49
|
+
quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
|
|
50
50
|
nextStatus = await findNextStatus(quotation, this);
|
|
51
51
|
if (nextStatus === QuotationStatus.PROPOSED) {
|
|
52
52
|
const proposal = await director.quote();
|
|
53
|
-
quotation = await this.quotations.updateProposal(quotation._id, proposal);
|
|
53
|
+
quotation = (await this.quotations.updateProposal(quotation._id, proposal)) as Quotation;
|
|
54
54
|
nextStatus = await findNextStatus(quotation, this);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
|
|
57
|
+
const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
|
|
58
58
|
status: nextStatus,
|
|
59
59
|
info: 'quotation processed',
|
|
60
|
-
});
|
|
60
|
+
})) as Quotation;
|
|
61
61
|
|
|
62
62
|
const user = await this.users.findUserById(updatedQuotation.userId);
|
|
63
63
|
const locale = this.users.userLocale(user);
|
|
@@ -9,10 +9,10 @@ export async function proposeQuotationService(
|
|
|
9
9
|
) {
|
|
10
10
|
if (quotation.status !== QuotationStatus.PROCESSING) return quotation;
|
|
11
11
|
|
|
12
|
-
const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
|
|
12
|
+
const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
|
|
13
13
|
status: QuotationStatus.PROPOSED,
|
|
14
14
|
info: 'proposed manually',
|
|
15
|
-
});
|
|
15
|
+
})) as Quotation;
|
|
16
16
|
|
|
17
17
|
return processQuotationService.bind(this)(updatedQuotation, { quotationContext });
|
|
18
18
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PaymentCredentials } from '@unchainedshop/core-payment';
|
|
2
1
|
import { PaymentContext } from '../directors/PaymentAdapter.js';
|
|
3
2
|
import { PaymentDirector } from '../directors/PaymentDirector.js';
|
|
4
3
|
import { Modules } from '../modules.js';
|
|
@@ -7,24 +6,23 @@ export async function registerPaymentCredentialsService(
|
|
|
7
6
|
this: Modules,
|
|
8
7
|
paymentProviderId: string,
|
|
9
8
|
paymentContext: PaymentContext,
|
|
10
|
-
)
|
|
9
|
+
) {
|
|
11
10
|
const paymentProvider = await this.payment.paymentProviders.findProvider({
|
|
12
11
|
paymentProviderId,
|
|
13
12
|
});
|
|
13
|
+
|
|
14
|
+
if (!paymentProvider) return null;
|
|
15
|
+
|
|
14
16
|
const actions = await PaymentDirector.actions(paymentProvider, paymentContext, { modules: this });
|
|
15
17
|
const registration = await actions.register();
|
|
16
18
|
|
|
17
19
|
if (!registration) return null;
|
|
18
20
|
|
|
19
|
-
const
|
|
21
|
+
const paymentCredentials = await this.payment.paymentCredentials.upsertCredentials({
|
|
20
22
|
userId: paymentContext.userId,
|
|
21
23
|
paymentProviderId,
|
|
22
24
|
...registration,
|
|
23
25
|
});
|
|
24
26
|
|
|
25
|
-
return
|
|
26
|
-
paymentCredentialsId,
|
|
27
|
-
userId: paymentContext.userId,
|
|
28
|
-
paymentProviderId,
|
|
29
|
-
});
|
|
27
|
+
return paymentCredentials;
|
|
30
28
|
}
|
|
@@ -9,10 +9,10 @@ export async function rejectQuotationService(
|
|
|
9
9
|
) {
|
|
10
10
|
if (quotation.status === QuotationStatus.FULLFILLED) return quotation;
|
|
11
11
|
|
|
12
|
-
const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
|
|
12
|
+
const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
|
|
13
13
|
status: QuotationStatus.REJECTED,
|
|
14
14
|
info: 'rejected manually',
|
|
15
|
-
});
|
|
15
|
+
})) as Quotation;
|
|
16
16
|
|
|
17
17
|
return processQuotationService.bind(this)(updatedQuotation, { quotationContext });
|
|
18
18
|
}
|
|
@@ -8,7 +8,7 @@ export async function removeProductService(
|
|
|
8
8
|
): Promise<boolean> {
|
|
9
9
|
const product = await this.products.findProduct({ productId });
|
|
10
10
|
|
|
11
|
-
switch (product
|
|
11
|
+
switch (product?.status) {
|
|
12
12
|
case ProductStatus.ACTIVE:
|
|
13
13
|
await this.products.unpublish(product);
|
|
14
14
|
// falls through
|
|
@@ -16,7 +16,7 @@ export async function removeProductService(
|
|
|
16
16
|
case ProductStatus.DRAFT:
|
|
17
17
|
{
|
|
18
18
|
await this.bookmarks.deleteByProductId(productId);
|
|
19
|
-
await this.assortments.products.
|
|
19
|
+
await this.assortments.products.deleteMany({ productId });
|
|
20
20
|
await this.products.removeAllAssignmentsAndBundleItems(productId);
|
|
21
21
|
const orderIdsToRecalculate =
|
|
22
22
|
await this.orders.positions.removeProductByIdFromAllOpenPositions(productId);
|
|
@@ -29,7 +29,7 @@ export async function removeProductService(
|
|
|
29
29
|
}
|
|
30
30
|
break;
|
|
31
31
|
default:
|
|
32
|
-
throw new Error(`Invalid status
|
|
32
|
+
throw new Error(`Invalid status: ${product?.status}`);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Modules } from '../modules.js';
|
|
2
2
|
import { supportedWarehousingProvidersService } from './supportedWarehousingProviders.js';
|
|
3
3
|
import { Product } from '@unchainedshop/core-products';
|
|
4
|
-
import {
|
|
4
|
+
import { WarehousingDirector } from '../directors/WarehousingDirector.js';
|
|
5
5
|
import { WarehousingContext } from '../directors/WarehousingAdapter.js';
|
|
6
6
|
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
7
7
|
|
|
@@ -18,7 +18,11 @@ export async function simulateProductInventoryService(
|
|
|
18
18
|
const deliveryProviders = await this.delivery.allProviders();
|
|
19
19
|
|
|
20
20
|
return deliveryProviders.reduce<
|
|
21
|
-
Promise<
|
|
21
|
+
Promise<
|
|
22
|
+
(WarehousingContext & { quantity?: number } & {
|
|
23
|
+
warehousingProvider: WarehousingProvider;
|
|
24
|
+
})[]
|
|
25
|
+
>
|
|
22
26
|
>(async (oldResult, deliveryProvider) => {
|
|
23
27
|
const result = await oldResult;
|
|
24
28
|
|
|
@@ -31,7 +35,7 @@ export async function simulateProductInventoryService(
|
|
|
31
35
|
|
|
32
36
|
const mappedWarehousingProviders = await Promise.all(
|
|
33
37
|
warehousingProviders.map(async (warehousingProvider) => {
|
|
34
|
-
const warehousingContext
|
|
38
|
+
const warehousingContext = {
|
|
35
39
|
deliveryProvider,
|
|
36
40
|
product,
|
|
37
41
|
referenceDate,
|
|
@@ -2,16 +2,19 @@ import { Product, ProductConfiguration } from '@unchainedshop/core-products';
|
|
|
2
2
|
import { ProductPricingDirector } from '../core-index.js';
|
|
3
3
|
import { User } from '@unchainedshop/core-users';
|
|
4
4
|
import { Modules } from '../modules.js';
|
|
5
|
+
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
5
6
|
|
|
6
7
|
export async function simulateProductPricingService(
|
|
7
8
|
this: Modules,
|
|
8
9
|
pricingContext: {
|
|
9
|
-
product: Product;
|
|
10
|
-
user: User;
|
|
11
|
-
countryCode: string;
|
|
12
10
|
currencyCode: string;
|
|
11
|
+
countryCode: string;
|
|
13
12
|
quantity: number;
|
|
13
|
+
discounts: OrderDiscount[];
|
|
14
|
+
order?: Order;
|
|
15
|
+
product: Product;
|
|
14
16
|
configuration?: ProductConfiguration[];
|
|
17
|
+
user?: User;
|
|
15
18
|
},
|
|
16
19
|
) {
|
|
17
20
|
const calculated = await ProductPricingDirector.rebuildCalculation(pricingContext, { modules: this });
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
OrderDelivery,
|
|
3
|
+
OrderDiscountTrigger,
|
|
4
|
+
OrderPayment,
|
|
5
|
+
Order,
|
|
6
|
+
OrderPosition,
|
|
7
|
+
} from '@unchainedshop/core-orders';
|
|
2
8
|
import { initCartProvidersService } from './initCartProviders.js';
|
|
3
9
|
import { Modules } from '../modules.js';
|
|
4
10
|
import { updateSchedulingService } from './updateScheduling.js';
|
|
@@ -12,6 +18,7 @@ import {
|
|
|
12
18
|
|
|
13
19
|
export async function updateCalculationService(this: Modules, orderId: string) {
|
|
14
20
|
let order = await this.orders.findOrder({ orderId });
|
|
21
|
+
if (!order) throw new Error('Order not found');
|
|
15
22
|
|
|
16
23
|
// Don't recalculate orders, only carts
|
|
17
24
|
if (order.status !== null) return order;
|
|
@@ -27,15 +34,17 @@ export async function updateCalculationService(this: Modules, orderId: string) {
|
|
|
27
34
|
const Adapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
|
|
28
35
|
if (!Adapter) return null;
|
|
29
36
|
const adapter = await Adapter.actions({
|
|
30
|
-
context: { order
|
|
37
|
+
context: { order: order!, orderDiscount, code: orderDiscount.code, modules: this },
|
|
31
38
|
});
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
let isValid = false;
|
|
41
|
+
if (orderDiscount.trigger === OrderDiscountTrigger.SYSTEM) {
|
|
42
|
+
isValid = await adapter.isValidForSystemTriggering();
|
|
43
|
+
} else if (orderDiscount.trigger === OrderDiscountTrigger.USER && orderDiscount.code) {
|
|
44
|
+
isValid = await adapter.isValidForCodeTriggering({
|
|
45
|
+
code: orderDiscount.code,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
39
48
|
|
|
40
49
|
if (!isValid) {
|
|
41
50
|
if (orderDiscount.trigger === OrderDiscountTrigger.USER) {
|
|
@@ -52,14 +61,14 @@ export async function updateCalculationService(this: Modules, orderId: string) {
|
|
|
52
61
|
});
|
|
53
62
|
|
|
54
63
|
const currentDiscountKeys = cleanedDiscounts.map(({ discountKey }) => discountKey);
|
|
55
|
-
const director = await OrderDiscountDirector.actions({ order
|
|
64
|
+
const director = await OrderDiscountDirector.actions({ order }, { modules: this });
|
|
56
65
|
const systemDiscounts = await director.findSystemDiscounts();
|
|
57
66
|
await Promise.all(
|
|
58
67
|
systemDiscounts
|
|
59
68
|
.filter((key) => currentDiscountKeys.indexOf(key) === -1)
|
|
60
69
|
.map(async (discountKey) =>
|
|
61
70
|
this.orders.discounts.create({
|
|
62
|
-
orderId: order
|
|
71
|
+
orderId: order!._id,
|
|
63
72
|
discountKey,
|
|
64
73
|
trigger: OrderDiscountTrigger.SYSTEM,
|
|
65
74
|
}),
|
|
@@ -73,18 +82,21 @@ export async function updateCalculationService(this: Modules, orderId: string) {
|
|
|
73
82
|
orderPositions.map(async (orderPosition) => {
|
|
74
83
|
const positionCalculation = await ProductPricingDirector.rebuildCalculation(
|
|
75
84
|
{
|
|
76
|
-
currencyCode: order
|
|
85
|
+
currencyCode: order!.currencyCode,
|
|
77
86
|
quantity: orderPosition.quantity,
|
|
78
87
|
item: orderPosition,
|
|
79
88
|
},
|
|
80
89
|
{ modules: this },
|
|
81
90
|
);
|
|
82
|
-
return this.orders.positions.updateCalculation(
|
|
91
|
+
return (await this.orders.positions.updateCalculation(
|
|
92
|
+
orderPosition._id,
|
|
93
|
+
positionCalculation,
|
|
94
|
+
)) as OrderPosition;
|
|
83
95
|
}),
|
|
84
96
|
);
|
|
85
97
|
|
|
86
98
|
let orderDelivery = await this.orders.deliveries.findDelivery({
|
|
87
|
-
orderDeliveryId: order.deliveryId
|
|
99
|
+
orderDeliveryId: order.deliveryId!,
|
|
88
100
|
});
|
|
89
101
|
if (orderDelivery) {
|
|
90
102
|
const deliveryCalculation = await DeliveryPricingDirector.rebuildCalculation(
|
|
@@ -94,13 +106,13 @@ export async function updateCalculationService(this: Modules, orderId: string) {
|
|
|
94
106
|
},
|
|
95
107
|
{ modules: this },
|
|
96
108
|
);
|
|
97
|
-
orderDelivery = await this.orders.deliveries.updateCalculation(
|
|
109
|
+
orderDelivery = (await this.orders.deliveries.updateCalculation(
|
|
98
110
|
orderDelivery._id,
|
|
99
111
|
deliveryCalculation,
|
|
100
|
-
);
|
|
112
|
+
)) as OrderDelivery;
|
|
101
113
|
}
|
|
102
114
|
let orderPayment = await this.orders.payments.findOrderPayment({
|
|
103
|
-
orderPaymentId: order.paymentId
|
|
115
|
+
orderPaymentId: order.paymentId!,
|
|
104
116
|
});
|
|
105
117
|
if (orderPayment) {
|
|
106
118
|
const paymentCalculation = await PaymentPricingDirector.rebuildCalculation(
|
|
@@ -110,7 +122,10 @@ export async function updateCalculationService(this: Modules, orderId: string) {
|
|
|
110
122
|
},
|
|
111
123
|
{ modules: this },
|
|
112
124
|
);
|
|
113
|
-
orderPayment = await this.orders.payments.updateCalculation(
|
|
125
|
+
orderPayment = (await this.orders.payments.updateCalculation(
|
|
126
|
+
orderPayment._id,
|
|
127
|
+
paymentCalculation,
|
|
128
|
+
)) as OrderPayment;
|
|
114
129
|
}
|
|
115
130
|
|
|
116
131
|
orderPositions = await updateSchedulingService.bind(this)({
|
|
@@ -125,7 +140,7 @@ export async function updateCalculationService(this: Modules, orderId: string) {
|
|
|
125
140
|
);
|
|
126
141
|
|
|
127
142
|
if (JSON.stringify(order.calculation) !== JSON.stringify(calculation)) {
|
|
128
|
-
order = await this.orders.updateCalculationSheet(orderId, calculation);
|
|
143
|
+
order = (await this.orders.updateCalculationSheet(orderId, calculation)) as Order;
|
|
129
144
|
}
|
|
130
145
|
|
|
131
146
|
/*
|