addio-admin-sdk 1.7.21 → 1.7.22
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/.babelrc +17 -17
- package/.env +14 -14
- package/.env.dev +14 -14
- package/.github/workflows/publish_coverage.yaml +69 -69
- package/addio-sdk-doc.md +1473 -1380
- package/changelog.md +469 -469
- package/dist/Interfaces/Address/index.d.ts +21 -21
- package/dist/Interfaces/Address/index.js +16 -16
- package/dist/Interfaces/Algolia/index.d.ts +149 -148
- package/dist/Interfaces/Algolia/index.js +2 -2
- package/dist/Interfaces/Attachement/index.d.ts +5 -5
- package/dist/Interfaces/Attachement/index.js +2 -2
- package/dist/Interfaces/Attribute/index.d.ts +47 -47
- package/dist/Interfaces/Attribute/index.js +10 -10
- package/dist/Interfaces/BGJob/index.d.ts +56 -56
- package/dist/Interfaces/BGJob/index.js +36 -36
- package/dist/Interfaces/BaseClass/index.d.ts +8 -8
- package/dist/Interfaces/BaseClass/index.js +2 -2
- package/dist/Interfaces/Blog/IBlogArticle.d.ts +18 -18
- package/dist/Interfaces/Blog/IBlogArticle.js +2 -2
- package/dist/Interfaces/Blog/IBlogAuthor.d.ts +7 -7
- package/dist/Interfaces/Blog/IBlogAuthor.js +2 -2
- package/dist/Interfaces/Blog/IBlogCategory.d.ts +9 -9
- package/dist/Interfaces/Blog/IBlogCategory.js +2 -2
- package/dist/Interfaces/Blog/IBlogComment.d.ts +13 -13
- package/dist/Interfaces/Blog/IBlogComment.js +2 -2
- package/dist/Interfaces/Blog/IBlogKeywords.d.ts +9 -9
- package/dist/Interfaces/Blog/IBlogKeywords.js +2 -2
- package/dist/Interfaces/Booking/index.d.ts +68 -68
- package/dist/Interfaces/Booking/index.js +17 -17
- package/dist/Interfaces/Brand/index.d.ts +13 -13
- package/dist/Interfaces/Brand/index.js +2 -2
- package/dist/Interfaces/CMS/index.d.ts +25 -25
- package/dist/Interfaces/CMS/index.js +2 -2
- package/dist/Interfaces/Cart/IPandaPayload.d.ts +64 -64
- package/dist/Interfaces/Cart/IPandaPayload.js +18 -18
- package/dist/Interfaces/Cart/IPaymentCard.d.ts +22 -22
- package/dist/Interfaces/Cart/IPaymentCard.js +44 -44
- package/dist/Interfaces/Cart/IPaypalPayload.d.ts +9 -9
- package/dist/Interfaces/Cart/IPaypalPayload.js +2 -2
- package/dist/Interfaces/Cart/IPaysafePayload.d.ts +72 -72
- package/dist/Interfaces/Cart/IPaysafePayload.js +2 -2
- package/dist/Interfaces/Cart/IStripePayload.d.ts +66 -66
- package/dist/Interfaces/Cart/IStripePayload.js +2 -2
- package/dist/Interfaces/Cart/index.d.ts +412 -410
- package/dist/Interfaces/Cart/index.js +191 -191
- package/dist/Interfaces/Cart/index.js.map +1 -1
- package/dist/Interfaces/Catalogue/index.d.ts +68 -68
- package/dist/Interfaces/Catalogue/index.js +37 -37
- package/dist/Interfaces/Category/index.d.ts +26 -26
- package/dist/Interfaces/Category/index.js +2 -2
- package/dist/Interfaces/Chart/index.d.ts +11 -11
- package/dist/Interfaces/Chart/index.js +2 -2
- package/dist/Interfaces/Class/index.d.ts +8 -8
- package/dist/Interfaces/Class/index.js +2 -2
- package/dist/Interfaces/Consent/index.d.ts +6 -6
- package/dist/Interfaces/Consent/index.js +2 -2
- package/dist/Interfaces/Context/IContextProps.d.ts +4 -4
- package/dist/Interfaces/Context/IContextProps.js +2 -2
- package/dist/Interfaces/Context/IContextState.d.ts +15 -15
- package/dist/Interfaces/Context/IContextState.js +2 -2
- package/dist/Interfaces/Customer/ICustomerBadge.d.ts +2 -2
- package/dist/Interfaces/Customer/ICustomerBadge.js +2 -2
- package/dist/Interfaces/Customer/ICustomerRating.d.ts +10 -10
- package/dist/Interfaces/Customer/ICustomerRating.js +2 -2
- package/dist/Interfaces/Customer/index.d.ts +95 -95
- package/dist/Interfaces/Customer/index.js +158 -158
- package/dist/Interfaces/Declination/index.d.ts +111 -111
- package/dist/Interfaces/Declination/index.js +77 -77
- package/dist/Interfaces/Document/index.d.ts +8 -8
- package/dist/Interfaces/Document/index.js +2 -2
- package/dist/Interfaces/Elastic/index.d.ts +89 -89
- package/dist/Interfaces/Elastic/index.js +2 -2
- package/dist/Interfaces/Email/CustomGR/I3DPrintEmail.d.ts +11 -11
- package/dist/Interfaces/Email/CustomGR/I3DPrintEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/IBorrowToolsEmail.d.ts +15 -15
- package/dist/Interfaces/Email/CustomGR/IBorrowToolsEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/IPickupMaterialsEmail.d.ts +12 -12
- package/dist/Interfaces/Email/CustomGR/IPickupMaterialsEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/IPreMeetingFormEmail.d.ts +36 -36
- package/dist/Interfaces/Email/CustomGR/IPreMeetingFormEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/ISponsorRequestEmail.d.ts +12 -12
- package/dist/Interfaces/Email/CustomGR/ISponsorRequestEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/ITransportEmail.d.ts +12 -12
- package/dist/Interfaces/Email/CustomGR/ITransportEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/ITransportQuoteEmail.d.ts +12 -12
- package/dist/Interfaces/Email/CustomGR/ITransportQuoteEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/IVegetalsEmail.d.ts +16 -16
- package/dist/Interfaces/Email/CustomGR/IVegetalsEmail.js +2 -2
- package/dist/Interfaces/Email/CustomGR/IWishlistEmail.d.ts +15 -15
- package/dist/Interfaces/Email/CustomGR/IWishlistEmail.js +2 -2
- package/dist/Interfaces/Email/IAbandonnedCartEmail.d.ts +29 -29
- package/dist/Interfaces/Email/IAbandonnedCartEmail.js +2 -2
- package/dist/Interfaces/Email/IAccountConfirmationEmail.d.ts +22 -22
- package/dist/Interfaces/Email/IAccountConfirmationEmail.js +2 -2
- package/dist/Interfaces/Email/IApplicationEmail.d.ts +19 -19
- package/dist/Interfaces/Email/IApplicationEmail.js +2 -2
- package/dist/Interfaces/Email/IBackInStockEmail.d.ts +21 -21
- package/dist/Interfaces/Email/IBackInStockEmail.js +2 -2
- package/dist/Interfaces/Email/IContactEmail.d.ts +20 -20
- package/dist/Interfaces/Email/IContactEmail.js +2 -2
- package/dist/Interfaces/Email/ICustomerBookingAdminEmail.d.ts +15 -15
- package/dist/Interfaces/Email/ICustomerBookingAdminEmail.js +2 -2
- package/dist/Interfaces/Email/ICustomerBookingEmail.d.ts +14 -14
- package/dist/Interfaces/Email/ICustomerBookingEmail.js +2 -2
- package/dist/Interfaces/Email/IEmail.d.ts +20 -20
- package/dist/Interfaces/Email/IEmail.js +69 -69
- package/dist/Interfaces/Email/IOrderConfirmationEmail.d.ts +47 -47
- package/dist/Interfaces/Email/IOrderConfirmationEmail.js +2 -2
- package/dist/Interfaces/Email/IPasswordResetEmail.d.ts +17 -17
- package/dist/Interfaces/Email/IPasswordResetEmail.js +2 -2
- package/dist/Interfaces/Email/IPhotoShootEmail.d.ts +14 -14
- package/dist/Interfaces/Email/IPhotoShootEmail.js +2 -2
- package/dist/Interfaces/Email/IPickupConfirmation.d.ts +23 -23
- package/dist/Interfaces/Email/IPickupConfirmation.js +2 -2
- package/dist/Interfaces/Email/IShippingConfirmation.d.ts +23 -23
- package/dist/Interfaces/Email/IShippingConfirmation.js +2 -2
- package/dist/Interfaces/Email/IWelcomeEmail.d.ts +19 -19
- package/dist/Interfaces/Email/IWelcomeEmail.js +2 -2
- package/dist/Interfaces/ExportSchema/index.d.ts +7 -7
- package/dist/Interfaces/ExportSchema/index.js +2 -2
- package/dist/Interfaces/ExternalService/BaseExternalService.d.ts +12 -12
- package/dist/Interfaces/ExternalService/BaseExternalService.js +2 -2
- package/dist/Interfaces/ExternalService/index.d.ts +9 -9
- package/dist/Interfaces/ExternalService/index.js +2 -2
- package/dist/Interfaces/FirstOrderTracking/index.d.ts +5 -5
- package/dist/Interfaces/FirstOrderTracking/index.js +2 -2
- package/dist/Interfaces/G2/index.d.ts +556 -556
- package/dist/Interfaces/G2/index.js +36 -36
- package/dist/Interfaces/Indexed/Product/IIndexedLastSavedProduct.d.ts +20 -20
- package/dist/Interfaces/Indexed/Product/IIndexedLastSavedProduct.js +2 -2
- package/dist/Interfaces/Indexed/Product/index.d.ts +94 -94
- package/dist/Interfaces/Indexed/Product/index.js +287 -287
- package/dist/Interfaces/Inventory/index.d.ts +19 -19
- package/dist/Interfaces/Inventory/index.js +8 -8
- package/dist/Interfaces/Invoice/index.d.ts +4 -4
- package/dist/Interfaces/Invoice/index.js +2 -2
- package/dist/Interfaces/MarketplacePublication/MarketplaceOrderData.d.ts +3 -3
- package/dist/Interfaces/MarketplacePublication/MarketplaceOrderData.js +2 -2
- package/dist/Interfaces/MarketplacePublication/index.d.ts +23 -23
- package/dist/Interfaces/MarketplacePublication/index.js +33 -33
- package/dist/Interfaces/Operations/ICreatedBy.d.ts +6 -6
- package/dist/Interfaces/Operations/ICreatedBy.js +2 -2
- package/dist/Interfaces/Operations/IUpdate.d.ts +5 -5
- package/dist/Interfaces/Operations/IUpdate.js +2 -2
- package/dist/Interfaces/Order/index.d.ts +4 -4
- package/dist/Interfaces/Order/index.js +2 -2
- package/dist/Interfaces/Org/IRelUser.d.ts +9 -9
- package/dist/Interfaces/Org/IRelUser.js +2 -2
- package/dist/Interfaces/Org/index.d.ts +29 -29
- package/dist/Interfaces/Org/index.js +12 -12
- package/dist/Interfaces/Payment/index.d.ts +13 -13
- package/dist/Interfaces/Payment/index.js +2 -2
- package/dist/Interfaces/Product/IAttributeFamily.d.ts +6 -6
- package/dist/Interfaces/Product/IAttributeFamily.js +2 -2
- package/dist/Interfaces/Product/IImportProduct.d.ts +42 -42
- package/dist/Interfaces/Product/IImportProduct.js +971 -971
- package/dist/Interfaces/Product/IInventoryItem.d.ts +84 -84
- package/dist/Interfaces/Product/IInventoryItem.js +36 -36
- package/dist/Interfaces/Product/IPricing.d.ts +177 -177
- package/dist/Interfaces/Product/IPricing.js +174 -174
- package/dist/Interfaces/Product/index.d.ts +121 -121
- package/dist/Interfaces/Product/index.js +56 -56
- package/dist/Interfaces/ProductAttribute/index.d.ts +11 -11
- package/dist/Interfaces/ProductAttribute/index.js +2 -2
- package/dist/Interfaces/PromiseToPurchase/BankType.d.ts +41 -41
- package/dist/Interfaces/PromiseToPurchase/BankType.js +42 -42
- package/dist/Interfaces/PromiseToPurchase/IIndexedBankUsed.d.ts +33 -33
- package/dist/Interfaces/PromiseToPurchase/IIndexedBankUsed.js +15 -15
- package/dist/Interfaces/PromiseToPurchase/IIndexedCustomerPromiseToPurchase.d.ts +19 -19
- package/dist/Interfaces/PromiseToPurchase/IIndexedCustomerPromiseToPurchase.js +2 -2
- package/dist/Interfaces/PromiseToPurchase/index.d.ts +50 -50
- package/dist/Interfaces/PromiseToPurchase/index.js +13 -13
- package/dist/Interfaces/PurchaseOrder/index.d.ts +17 -17
- package/dist/Interfaces/PurchaseOrder/index.js +2 -2
- package/dist/Interfaces/Query/IBrandQueryOptions.d.ts +11 -11
- package/dist/Interfaces/Query/IBrandQueryOptions.js +2 -2
- package/dist/Interfaces/Query/ICategoryQueryOptions.d.ts +11 -11
- package/dist/Interfaces/Query/ICategoryQueryOptions.js +2 -2
- package/dist/Interfaces/Query/IProductQueryOptions.d.ts +16 -16
- package/dist/Interfaces/Query/IProductQueryOptions.js +2 -2
- package/dist/Interfaces/Quote/index.d.ts +5 -5
- package/dist/Interfaces/Quote/index.js +2 -2
- package/dist/Interfaces/Refunds/index.d.ts +106 -106
- package/dist/Interfaces/Refunds/index.js +2 -2
- package/dist/Interfaces/Rules/IDiscountRule.d.ts +137 -137
- package/dist/Interfaces/Rules/IDiscountRule.js +107 -107
- package/dist/Interfaces/Schedule/index.d.ts +47 -46
- package/dist/Interfaces/Schedule/index.js +2 -2
- package/dist/Interfaces/Services/IAddServiceResponse.d.ts +4 -4
- package/dist/Interfaces/Services/IAddServiceResponse.js +2 -2
- package/dist/Interfaces/Services/IService.d.ts +12 -12
- package/dist/Interfaces/Services/IService.js +2 -2
- package/dist/Interfaces/Services/IServiceSecret.d.ts +8 -8
- package/dist/Interfaces/Services/IServiceSecret.js +2 -2
- package/dist/Interfaces/Shipping/Shipstation/carriers.d.ts +10 -10
- package/dist/Interfaces/Shipping/Shipstation/carriers.js +2 -2
- package/dist/Interfaces/Shipping/Shipstation/order.d.ts +227 -227
- package/dist/Interfaces/Shipping/Shipstation/order.js +2 -2
- package/dist/Interfaces/Shipping/Shipstation/quote.d.ts +31 -31
- package/dist/Interfaces/Shipping/Shipstation/quote.js +2 -2
- package/dist/Interfaces/Shipping/Shiptime/order.d.ts +54 -54
- package/dist/Interfaces/Shipping/Shiptime/order.js +48 -48
- package/dist/Interfaces/Shipping/Shiptime/quote.d.ts +111 -111
- package/dist/Interfaces/Shipping/Shiptime/quote.js +2 -2
- package/dist/Interfaces/Slider/GR.d.ts +130 -130
- package/dist/Interfaces/Slider/GR.js +271 -271
- package/dist/Interfaces/Slider/index.d.ts +14 -14
- package/dist/Interfaces/Slider/index.js +2 -2
- package/dist/Interfaces/Space/IMember.d.ts +16 -16
- package/dist/Interfaces/Space/IMember.js +9 -9
- package/dist/Interfaces/Space/index.d.ts +403 -387
- package/dist/Interfaces/Space/index.js +139 -123
- package/dist/Interfaces/Space/index.js.map +1 -1
- package/dist/Interfaces/Specials/gr.d.ts +61 -61
- package/dist/Interfaces/Specials/gr.js +2 -2
- package/dist/Interfaces/StockNotification/index.d.ts +7 -7
- package/dist/Interfaces/StockNotification/index.js +2 -2
- package/dist/Interfaces/Store/index.d.ts +62 -62
- package/dist/Interfaces/Store/index.js +27 -27
- package/dist/Interfaces/Supplier/ICommand.d.ts +11 -11
- package/dist/Interfaces/Supplier/ICommand.js +2 -2
- package/dist/Interfaces/Supplier/index.d.ts +36 -36
- package/dist/Interfaces/Supplier/index.js +24 -24
- package/dist/Interfaces/Tag/index.d.ts +18 -18
- package/dist/Interfaces/Tag/index.js +2 -2
- package/dist/Interfaces/Tax/index.d.ts +12 -12
- package/dist/Interfaces/Tax/index.js +2 -2
- package/dist/Interfaces/TransferRequest/index.d.ts +91 -59
- package/dist/Interfaces/TransferRequest/index.js +38 -31
- package/dist/Interfaces/TransferRequest/index.js.map +1 -1
- package/dist/Interfaces/Translation/index.d.ts +8 -4
- package/dist/Interfaces/Translation/index.js +5 -2
- package/dist/Interfaces/Translation/index.js.map +1 -1
- package/dist/Interfaces/Update/index.d.ts +10 -10
- package/dist/Interfaces/Update/index.js +2 -2
- package/dist/Interfaces/User/IUser.d.ts +65 -65
- package/dist/Interfaces/User/IUser.js +8 -8
- package/dist/Interfaces/Version/index.d.ts +11 -11
- package/dist/Interfaces/Version/index.js +2 -2
- package/dist/Interfaces/Wishlist/index.d.ts +7 -7
- package/dist/Interfaces/Wishlist/index.js +2 -2
- package/dist/constants/Interfaces/IBaseApi.d.ts +15 -15
- package/dist/constants/Interfaces/IBaseApi.js +2 -2
- package/dist/constants/Interfaces/IEndpointResult.d.ts +9 -9
- package/dist/constants/Interfaces/IEndpointResult.js +2 -2
- package/dist/constants/enums.d.ts +6 -6
- package/dist/constants/enums.js +10 -10
- package/dist/constants/version.d.ts +2 -2
- package/dist/constants/version.js +5 -5
- package/dist/index.d.ts +32 -32
- package/dist/index.js +416 -416
- package/dist/lib/Attribute/index.d.ts +14 -14
- package/dist/lib/Attribute/index.js +248 -248
- package/dist/lib/BGJob/index.d.ts +9 -9
- package/dist/lib/BGJob/index.js +376 -376
- package/dist/lib/BackgroundWorker/index.d.ts +34 -34
- package/dist/lib/BackgroundWorker/index.js +72 -72
- package/dist/lib/Blog/BlogArticle.d.ts +5 -5
- package/dist/lib/Blog/BlogArticle.js +28 -28
- package/dist/lib/Blog/BlogAuthor.d.ts +5 -5
- package/dist/lib/Blog/BlogAuthor.js +28 -28
- package/dist/lib/Blog/BlogCategory.d.ts +5 -5
- package/dist/lib/Blog/BlogCategory.js +28 -28
- package/dist/lib/Blog/BlogKeyword.d.ts +5 -5
- package/dist/lib/Blog/BlogKeyword.js +28 -28
- package/dist/lib/Booking/index.d.ts +65 -65
- package/dist/lib/Booking/index.js +839 -839
- package/dist/lib/Brand/index.d.ts +17 -17
- package/dist/lib/Brand/index.js +275 -275
- package/dist/lib/Cart/index.d.ts +195 -186
- package/dist/lib/Cart/index.js +4120 -3982
- package/dist/lib/Cart/index.js.map +1 -1
- package/dist/lib/Catalogue/index.d.ts +9 -9
- package/dist/lib/Catalogue/index.js +207 -207
- package/dist/lib/Category/index.d.ts +26 -26
- package/dist/lib/Category/index.js +361 -361
- package/dist/lib/Class/index.d.ts +12 -12
- package/dist/lib/Class/index.js +159 -159
- package/dist/lib/Consent/index.d.ts +4 -4
- package/dist/lib/Consent/index.js +79 -79
- package/dist/lib/Customer/index.d.ts +10 -10
- package/dist/lib/Customer/index.js +147 -147
- package/dist/lib/Declination/index.d.ts +9 -9
- package/dist/lib/Declination/index.js +84 -84
- package/dist/lib/Discount/index.d.ts +18 -18
- package/dist/lib/Discount/index.js +759 -759
- package/dist/lib/ElasticSearch/index.d.ts +8 -8
- package/dist/lib/ElasticSearch/index.js +101 -101
- package/dist/lib/Email/AbandonedCartEmail.d.ts +8 -8
- package/dist/lib/Email/AbandonedCartEmail.js +78 -78
- package/dist/lib/Email/AccountConfirmationEmail.d.ts +11 -11
- package/dist/lib/Email/AccountConfirmationEmail.js +95 -95
- package/dist/lib/Email/AdminOrderConfirmationEmail.d.ts +8 -8
- package/dist/lib/Email/AdminOrderConfirmationEmail.js +78 -78
- package/dist/lib/Email/ApplicationEmail.d.ts +8 -8
- package/dist/lib/Email/ApplicationEmail.js +78 -78
- package/dist/lib/Email/BackInStockEmail.d.ts +8 -8
- package/dist/lib/Email/BackInStockEmail.js +78 -78
- package/dist/lib/Email/ContactEmail.d.ts +8 -8
- package/dist/lib/Email/ContactEmail.js +78 -78
- package/dist/lib/Email/CustomerBookingAdminEmail.d.ts +8 -8
- package/dist/lib/Email/CustomerBookingAdminEmail.js +78 -78
- package/dist/lib/Email/CustomerBookingEmail.d.ts +8 -8
- package/dist/lib/Email/CustomerBookingEmail.js +78 -78
- package/dist/lib/Email/OrderConfirmationEmail.d.ts +8 -8
- package/dist/lib/Email/OrderConfirmationEmail.js +79 -78
- package/dist/lib/Email/OrderConfirmationEmail.js.map +1 -1
- package/dist/lib/Email/OrderDenounciationEmail.d.ts +8 -8
- package/dist/lib/Email/OrderDenounciationEmail.js +78 -78
- package/dist/lib/Email/OrderSampleEmail.d.ts +8 -8
- package/dist/lib/Email/OrderSampleEmail.js +78 -78
- package/dist/lib/Email/OtherTypeEmails.d.ts +8 -8
- package/dist/lib/Email/OtherTypeEmails.js +90 -90
- package/dist/lib/Email/PasswordResetEmail.d.ts +8 -8
- package/dist/lib/Email/PasswordResetEmail.js +78 -78
- package/dist/lib/Email/PhotoShootEmail.d.ts +8 -8
- package/dist/lib/Email/PhotoShootEmail.js +78 -78
- package/dist/lib/Email/PickUpConfirmation.d.ts +8 -8
- package/dist/lib/Email/PickUpConfirmation.js +78 -78
- package/dist/lib/Email/ShippingConfirmation.d.ts +8 -8
- package/dist/lib/Email/ShippingConfirmation.js +78 -78
- package/dist/lib/Email/WelcomeEmail.d.ts +8 -8
- package/dist/lib/Email/WelcomeEmail.js +78 -78
- package/dist/lib/Email/index.d.ts +8 -8
- package/dist/lib/Email/index.js +82 -82
- package/dist/lib/ExternalService/Ebay.d.ts +62 -62
- package/dist/lib/ExternalService/Ebay.js +184 -184
- package/dist/lib/ExternalService/index.d.ts +5 -5
- package/dist/lib/ExternalService/index.js +28 -28
- package/dist/lib/FirstOrderTracking/index.d.ts +5 -5
- package/dist/lib/FirstOrderTracking/index.js +28 -28
- package/dist/lib/Indexed/IndexedCart.d.ts +13 -13
- package/dist/lib/Indexed/IndexedCart.js +194 -194
- package/dist/lib/Indexed/Product.d.ts +17 -17
- package/dist/lib/Indexed/Product.js +116 -116
- package/dist/lib/Inventory/index.d.ts +48 -32
- package/dist/lib/Inventory/index.js +629 -579
- package/dist/lib/Inventory/index.js.map +1 -1
- package/dist/lib/Invoice/index.d.ts +5 -5
- package/dist/lib/Invoice/index.js +28 -28
- package/dist/lib/MarketplacePublication/index.d.ts +9 -9
- package/dist/lib/MarketplacePublication/index.js +220 -220
- package/dist/lib/MarketplacePublication/index.js.map +1 -1
- package/dist/lib/MongoDB/BaseAPI.d.ts +18 -18
- package/dist/lib/MongoDB/BaseAPI.js +308 -308
- package/dist/lib/Order/index.d.ts +7 -7
- package/dist/lib/Order/index.js +62 -62
- package/dist/lib/Org/index.d.ts +26 -26
- package/dist/lib/Org/index.js +283 -283
- package/dist/lib/PandaPay/index.d.ts +16 -16
- package/dist/lib/PandaPay/index.js +218 -218
- package/dist/lib/Paysafe/index.d.ts +11 -11
- package/dist/lib/Paysafe/index.js +100 -100
- package/dist/lib/Product/index.d.ts +143 -143
- package/dist/lib/Product/index.js +1326 -1326
- package/dist/lib/ProductAttribute/index.d.ts +15 -15
- package/dist/lib/ProductAttribute/index.js +114 -114
- package/dist/lib/PromiseToPurchase/index.d.ts +37 -37
- package/dist/lib/PromiseToPurchase/index.js +475 -475
- package/dist/lib/PurchaseOrder/index.d.ts +9 -9
- package/dist/lib/PurchaseOrder/index.js +72 -72
- package/dist/lib/Schedule/index.d.ts +5 -5
- package/dist/lib/Schedule/index.js +30 -30
- package/dist/lib/Service/Enum/ServiceEnum.d.ts +3 -3
- package/dist/lib/Service/Enum/ServiceEnum.js +7 -7
- package/dist/lib/Service/index.d.ts +5 -5
- package/dist/lib/Service/index.js +57 -57
- package/dist/lib/Shipment/index.d.ts +28 -28
- package/dist/lib/Shipment/index.js +562 -562
- package/dist/lib/Slider/index.d.ts +16 -16
- package/dist/lib/Slider/index.js +235 -235
- package/dist/lib/Space/index.d.ts +817 -801
- package/dist/lib/Space/index.js +6981 -6862
- package/dist/lib/Space/index.js.map +1 -1
- package/dist/lib/StockNotification/index.d.ts +4 -4
- package/dist/lib/StockNotification/index.js +26 -26
- package/dist/lib/Store/index.d.ts +5 -5
- package/dist/lib/Store/index.js +30 -30
- package/dist/lib/Supplier/Command.d.ts +5 -5
- package/dist/lib/Supplier/Command.js +28 -28
- package/dist/lib/Supplier/index.d.ts +25 -25
- package/dist/lib/Supplier/index.js +86 -86
- package/dist/lib/Tags/index.d.ts +6 -6
- package/dist/lib/Tags/index.js +84 -84
- package/dist/lib/Tax/index.d.ts +8 -8
- package/dist/lib/Tax/index.js +136 -136
- package/dist/lib/TransferRequest/index.d.ts +98 -21
- package/dist/lib/TransferRequest/index.js +1149 -302
- package/dist/lib/TransferRequest/index.js.map +1 -1
- package/dist/lib/Update/index.d.ts +10 -10
- package/dist/lib/Update/index.js +71 -71
- package/dist/lib/User/index.d.ts +33 -33
- package/dist/lib/User/index.js +360 -360
- package/dist/lib/Wishlist/index.d.ts +5 -5
- package/dist/lib/Wishlist/index.js +28 -28
- package/dist/lib/base.d.ts +14 -14
- package/dist/lib/base.js +135 -135
- package/dist/lib/baseService.d.ts +17 -17
- package/dist/lib/baseService.js +113 -113
- package/dist/rules/GR/constants/data.d.ts +25 -25
- package/dist/rules/GR/constants/data.js +54 -54
- package/dist/rules/GR/constants/products.d.ts +8 -8
- package/dist/rules/GR/constants/products.js +234 -234
- package/dist/rules/GR/interfaces/cart.d.ts +83 -83
- package/dist/rules/GR/interfaces/cart.js +51 -51
- package/dist/rules/GR/interfaces/data.d.ts +97 -97
- package/dist/rules/GR/interfaces/data.js +104 -104
- package/dist/rules/GR/interfaces/products.d.ts +61 -61
- package/dist/rules/GR/interfaces/products.js +10 -10
- package/dist/rules/GR/utils/cart.d.ts +53 -53
- package/dist/rules/GR/utils/cart.js +767 -767
- package/dist/rules/GR/utils/data.d.ts +3 -3
- package/dist/rules/GR/utils/data.js +25 -25
- package/dist/rules/GR/utils/expedition.d.ts +65 -65
- package/dist/rules/GR/utils/expedition.js +1676 -1676
- package/dist/rules/GR/utils/expedition.js.map +1 -1
- package/dist/rules/GR/utils/g2.d.ts +174 -174
- package/dist/rules/GR/utils/g2.js +1025 -1025
- package/dist/rules/GR/utils/invoices.d.ts +16 -16
- package/dist/rules/GR/utils/invoices.js +181 -181
- package/dist/rules/GR/utils/products.d.ts +103 -96
- package/dist/rules/GR/utils/products.js +1101 -1085
- package/dist/rules/GR/utils/products.js.map +1 -1
- package/dist/rules/GR/utils/upsells.d.ts +75 -75
- package/dist/rules/GR/utils/upsells.js +278 -278
- package/dist/rules/GR/utils/upsells.js.map +1 -1
- package/dist/services/database/BaseProvider.d.ts +29 -29
- package/dist/services/database/BaseProvider.js +77 -77
- package/dist/services/database/BatchUtils.d.ts +14 -14
- package/dist/services/database/BatchUtils.js +88 -88
- package/dist/services/database/Config.d.ts +2 -2
- package/dist/services/database/Config.js +5 -5
- package/dist/services/database/DatabaseService.d.ts +41 -41
- package/dist/services/database/DatabaseService.js +297 -297
- package/dist/services/database/DatabaseService.js.map +1 -1
- package/dist/services/database/FirebaseProvider.d.ts +17 -17
- package/dist/services/database/FirebaseProvider.js +312 -312
- package/dist/services/database/NotFirebaseProvider.d.ts +35 -35
- package/dist/services/database/NotFirebaseProvider.js +380 -380
- package/dist/services/g2/G2OrderSlip.d.ts +42 -42
- package/dist/services/g2/G2OrderSlip.js +264 -264
- package/dist/services/g2/utils.d.ts +9 -9
- package/dist/services/g2/utils.js +919 -919
- package/dist/services/logs/index.d.ts +20 -20
- package/dist/services/logs/index.js +126 -126
- package/dist/utils/algolia.d.ts +6 -6
- package/dist/utils/algolia.js +22 -22
- package/dist/utils/anonymisation.d.ts +30 -30
- package/dist/utils/anonymisation.js +264 -264
- package/dist/utils/array.d.ts +5 -5
- package/dist/utils/array.js +36 -36
- package/dist/utils/aws.d.ts +14 -14
- package/dist/utils/aws.js +220 -220
- package/dist/utils/booking.d.ts +22 -22
- package/dist/utils/booking.js +175 -175
- package/dist/utils/cart.d.ts +88 -69
- package/dist/utils/cart.js +767 -656
- package/dist/utils/cart.js.map +1 -1
- package/dist/utils/cmv.d.ts +10 -10
- package/dist/utils/cmv.js +107 -107
- package/dist/utils/console.d.ts +6 -6
- package/dist/utils/console.js +121 -121
- package/dist/utils/context.d.ts +20 -19
- package/dist/utils/context.js +59 -41
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/currency.d.ts +6 -6
- package/dist/utils/currency.js +62 -62
- package/dist/utils/data.d.ts +31 -31
- package/dist/utils/data.js +300 -300
- package/dist/utils/date.d.ts +1 -1
- package/dist/utils/date.js +16 -16
- package/dist/utils/dimensions.d.ts +3 -3
- package/dist/utils/dimensions.js +18 -18
- package/dist/utils/discount.d.ts +46 -46
- package/dist/utils/discount.js +981 -981
- package/dist/utils/errors.d.ts +113 -113
- package/dist/utils/errors.js +113 -113
- package/dist/utils/file-admin.d.ts +8 -8
- package/dist/utils/file-admin.js +94 -94
- package/dist/utils/file.d.ts +38 -38
- package/dist/utils/file.js +318 -318
- package/dist/utils/firebase-admin.d.ts +2 -2
- package/dist/utils/firebase-admin.js +118 -118
- package/dist/utils/firebase.d.ts +41 -41
- package/dist/utils/firebase.js +220 -220
- package/dist/utils/import.d.ts +1 -1
- package/dist/utils/import.js +81 -81
- package/dist/utils/inventories.d.ts +35 -34
- package/dist/utils/inventories.js +445 -432
- package/dist/utils/inventories.js.map +1 -1
- package/dist/utils/locale.d.ts +13 -13
- package/dist/utils/locale.js +67 -67
- package/dist/utils/mailchimp.d.ts +58 -58
- package/dist/utils/mailchimp.js +735 -735
- package/dist/utils/mongodb.d.ts +1 -1
- package/dist/utils/mongodb.js +68 -68
- package/dist/utils/object.d.ts +12 -12
- package/dist/utils/object.js +129 -129
- package/dist/utils/payment.d.ts +10 -10
- package/dist/utils/payment.js +25 -25
- package/dist/utils/products.d.ts +32 -26
- package/dist/utils/products.js +307 -301
- package/dist/utils/products.js.map +1 -1
- package/dist/utils/promiseToPurchase.d.ts +56 -56
- package/dist/utils/promiseToPurchase.js +228 -228
- package/dist/utils/prosprsearch.d.ts +21 -21
- package/dist/utils/prosprsearch.js +276 -276
- package/dist/utils/refunds.d.ts +2 -2
- package/dist/utils/refunds.js +21 -21
- package/dist/utils/sdc.d.ts +10 -10
- package/dist/utils/sdc.js +1308 -1308
- package/dist/utils/searchIndexes.d.ts +21 -21
- package/dist/utils/searchIndexes.js +318 -318
- package/dist/utils/services.d.ts +40 -40
- package/dist/utils/services.js +407 -407
- package/dist/utils/shipment.d.ts +110 -110
- package/dist/utils/shipment.js +410 -410
- package/dist/utils/simpletexting.d.ts +2 -2
- package/dist/utils/simpletexting.js +91 -91
- package/dist/utils/sliders.d.ts +4 -4
- package/dist/utils/sliders.js +70 -70
- package/dist/utils/string.d.ts +16 -16
- package/dist/utils/string.js +194 -194
- package/dist/utils/tools.d.ts +1 -1
- package/dist/utils/tools.js +49 -49
- package/dist/utils/transferRequests.d.ts +19 -16
- package/dist/utils/transferRequests.js +44 -33
- package/dist/utils/transferRequests.js.map +1 -1
- package/dist/utils/update.d.ts +7 -7
- package/dist/utils/update.js +245 -245
- package/dist/utils/weight.d.ts +3 -3
- package/dist/utils/weight.js +18 -18
- package/dist/utils/zones.d.ts +11 -11
- package/dist/utils/zones.js +313 -313
- package/package.json +110 -110
- package/publish.sh +143 -143
- package/readme.md +182 -182
- package/dist/lib/Queue/index.d.ts +0 -40
- package/dist/lib/Queue/index.js +0 -255
- package/dist/lib/Queue/index.js.map +0 -1
|
@@ -1,303 +1,1150 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
var
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
_this
|
|
101
|
-
_this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_this._data
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
_this.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
73
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
74
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
75
|
+
};
|
|
76
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
+
exports.TransferRequest = void 0;
|
|
78
|
+
var TransferRequest_1 = require("../../Interfaces/TransferRequest");
|
|
79
|
+
var DatabaseService_1 = __importDefault(require("../../services/database/DatabaseService"));
|
|
80
|
+
var baseService_1 = require("../baseService");
|
|
81
|
+
var Inventory_1 = __importDefault(require("../Inventory"));
|
|
82
|
+
var Space_1 = __importDefault(require("../Space"));
|
|
83
|
+
var toNumber_1 = __importDefault(require("lodash/toNumber"));
|
|
84
|
+
var ceil_1 = __importDefault(require("lodash/ceil"));
|
|
85
|
+
var round_1 = __importDefault(require("lodash/round"));
|
|
86
|
+
var data_1 = require("../../utils/data");
|
|
87
|
+
var inventories_1 = require("../../utils/inventories");
|
|
88
|
+
var transferRequests_1 = require("../../utils/transferRequests");
|
|
89
|
+
var sumBy_1 = __importDefault(require("lodash/sumBy"));
|
|
90
|
+
var weight_1 = require("../../utils/weight");
|
|
91
|
+
var algolia_1 = require("../../utils/algolia");
|
|
92
|
+
var __1 = require("../..");
|
|
93
|
+
var console_1 = require("../../utils/console");
|
|
94
|
+
var context_1 = require("../../utils/context");
|
|
95
|
+
var tools_1 = require("../../utils/tools");
|
|
96
|
+
var products_1 = require("../../rules/GR/utils/products");
|
|
97
|
+
var TransferRequest = (function (_super) {
|
|
98
|
+
__extends(TransferRequest, _super);
|
|
99
|
+
function TransferRequest(_data, _collection, _user) {
|
|
100
|
+
var _this = _super.call(this, _data, _collection, _user) || this;
|
|
101
|
+
_this._listener = null;
|
|
102
|
+
_this.prevProducts = [];
|
|
103
|
+
_this.processData = function (data) { return (__assign(__assign({}, data), { transfer_updates: data.transfer_updates.map(function (update) { return (__assign(__assign({}, update), { date: (0, data_1.formatDate)(update.date) })); }) })); };
|
|
104
|
+
_this.checkIfTransferCanBeClosedManually = function () {
|
|
105
|
+
return _this._data.status == TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL;
|
|
106
|
+
};
|
|
107
|
+
_this.transferAllowEditFromStore = function () { return TransferRequest.transferAllowEditFromStore(_this._data); };
|
|
108
|
+
_this.transferAllowAddProductOnEdit = function () { return TransferRequest.transferAllowAddProductOnEdit(_this._data); };
|
|
109
|
+
_this.transferAllowProductDelete = function () { return TransferRequest.transferAllowProductDelete(_this._data); };
|
|
110
|
+
_this.transferAllowEditProductOnEdit = function () { return TransferRequest.transferAllowEditProductOnEdit(_this._data); };
|
|
111
|
+
_this.transferShouldDisplayWeight = function () { return TransferRequest.transferShouldDisplayWeight(_this._data); };
|
|
112
|
+
_this.transferAllowsIndependantProductUpdate = function () {
|
|
113
|
+
return TransferRequest.transferAllowsIndependantProductUpdate(_this._data);
|
|
114
|
+
};
|
|
115
|
+
_this.fetchAssociatedCart = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
116
|
+
var associatedCart, space, cartQuery, e_1;
|
|
117
|
+
return __generator(this, function (_b) {
|
|
118
|
+
switch (_b.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
if (!!!this._data.associated_order)
|
|
121
|
+
return [2];
|
|
122
|
+
associatedCart = undefined;
|
|
123
|
+
_b.label = 1;
|
|
124
|
+
case 1:
|
|
125
|
+
_b.trys.push([1, 4, , 5]);
|
|
126
|
+
return [4, Space_1.default.getCurrentSpaceWithRef(this._collection.path, this._user)];
|
|
127
|
+
case 2:
|
|
128
|
+
space = _b.sent();
|
|
129
|
+
return [4, space.carts.get({
|
|
130
|
+
query: [{ field: 'ref', operator: '==', value: this._data.associated_order }]
|
|
131
|
+
})];
|
|
132
|
+
case 3:
|
|
133
|
+
cartQuery = _b.sent();
|
|
134
|
+
if (!!cartQuery && !!cartQuery.length)
|
|
135
|
+
associatedCart = cartQuery[0];
|
|
136
|
+
return [3, 5];
|
|
137
|
+
case 4:
|
|
138
|
+
e_1 = _b.sent();
|
|
139
|
+
console.log('could not fetch cart associated to transfer: ', e_1.toString());
|
|
140
|
+
return [3, 5];
|
|
141
|
+
case 5: return [2, associatedCart];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); };
|
|
145
|
+
_this.addProduct = function (sku, parent_slug, qte, name, image, other_units, weight, count_in_pallet_total) {
|
|
146
|
+
var data = _this.data();
|
|
147
|
+
if (!TransferRequest.transferAllowEditProductOnEdit(_this._data))
|
|
148
|
+
return false;
|
|
149
|
+
var updatedProducts = data.products;
|
|
150
|
+
if (!updatedProducts.find(function (p) { return p.sku == sku; })) {
|
|
151
|
+
updatedProducts.push({
|
|
152
|
+
sku: sku,
|
|
153
|
+
parent_slug: parent_slug,
|
|
154
|
+
qte: qte,
|
|
155
|
+
name: name,
|
|
156
|
+
image: image,
|
|
157
|
+
other_units: other_units,
|
|
158
|
+
weight: weight,
|
|
159
|
+
count_in_pallet_total: count_in_pallet_total,
|
|
160
|
+
qte_received: 0
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
updatedProducts = updatedProducts.map(function (p) {
|
|
165
|
+
if (p.sku !== sku)
|
|
166
|
+
return p;
|
|
167
|
+
return __assign(__assign({}, p), { qte: p.qte + qte <= 1 ? 1 : p.qte + qte });
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
_this._data = __assign(__assign({}, data), { products: updatedProducts });
|
|
171
|
+
return true;
|
|
172
|
+
};
|
|
173
|
+
_this.editProduct = function (sku, newQte) {
|
|
174
|
+
var data = _this.data();
|
|
175
|
+
if (!TransferRequest.transferAllowEditProductOnEdit(_this._data))
|
|
176
|
+
return false;
|
|
177
|
+
_this._data = __assign(__assign({}, data), { products: data.products.map(function (p) {
|
|
178
|
+
if (p.sku !== sku)
|
|
179
|
+
return p;
|
|
180
|
+
return __assign(__assign({}, p), { qte: newQte });
|
|
181
|
+
}) });
|
|
182
|
+
return true;
|
|
183
|
+
};
|
|
184
|
+
_this.deleteProduct = function (sku) {
|
|
185
|
+
var data = _this.data();
|
|
186
|
+
if (!TransferRequest.transferAllowProductDelete(_this._data))
|
|
187
|
+
return false;
|
|
188
|
+
_this._data = __assign(__assign({}, data), { products: data.products.filter(function (p) { return p.sku !== sku; }) });
|
|
189
|
+
return true;
|
|
190
|
+
};
|
|
191
|
+
_this.data = function () { return _this._data; };
|
|
192
|
+
_this.isListening = function () { return !!_this._listener; };
|
|
193
|
+
_this.killListener = function () {
|
|
194
|
+
if (!!!_this._listener)
|
|
195
|
+
return false;
|
|
196
|
+
_this._listener = null;
|
|
197
|
+
return true;
|
|
198
|
+
};
|
|
199
|
+
_this.listen = function (callback) {
|
|
200
|
+
if (!!_this._listener)
|
|
201
|
+
return false;
|
|
202
|
+
DatabaseService_1.default.registerListener(function (snap) {
|
|
203
|
+
if (snap === null)
|
|
204
|
+
_this._listener = null;
|
|
205
|
+
if (snap.length === 0)
|
|
206
|
+
_this._listener = null;
|
|
207
|
+
snap.map(function (s) {
|
|
208
|
+
if (s.id == _this.data().id) {
|
|
209
|
+
_this._data = _this.processData(s.data);
|
|
210
|
+
if (!!callback)
|
|
211
|
+
callback();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}, _this._collection.path, { id: _this.data().id });
|
|
215
|
+
return true;
|
|
216
|
+
};
|
|
217
|
+
_this._getTransferRef = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
218
|
+
var newRef, space, token, api, triesLeft, resp, data, e_2, e_3;
|
|
219
|
+
return __generator(this, function (_b) {
|
|
220
|
+
switch (_b.label) {
|
|
221
|
+
case 0:
|
|
222
|
+
newRef = undefined;
|
|
223
|
+
_b.label = 1;
|
|
224
|
+
case 1:
|
|
225
|
+
_b.trys.push([1, 12, , 13]);
|
|
226
|
+
return [4, Space_1.default.getCurrentSpaceWithRef(this._collection.path, this._user)];
|
|
227
|
+
case 2:
|
|
228
|
+
space = _b.sent();
|
|
229
|
+
token = (0, context_1.getSpaceTokenFromSpaceOnly)(space);
|
|
230
|
+
api = __1.API_URL;
|
|
231
|
+
triesLeft = 3;
|
|
232
|
+
_b.label = 3;
|
|
233
|
+
case 3:
|
|
234
|
+
if (!(triesLeft > 0)) return [3, 11];
|
|
235
|
+
_b.label = 4;
|
|
236
|
+
case 4:
|
|
237
|
+
_b.trys.push([4, 8, , 9]);
|
|
238
|
+
return [4, fetch("".concat(api, "/transfers/refnumber"), {
|
|
239
|
+
method: 'GET',
|
|
240
|
+
headers: {
|
|
241
|
+
'Content-Type': 'application/json',
|
|
242
|
+
Authorization: "Bearer ".concat(token)
|
|
243
|
+
}
|
|
244
|
+
})];
|
|
245
|
+
case 5:
|
|
246
|
+
resp = _b.sent();
|
|
247
|
+
if (!(resp.status >= 200 && resp.status < 300)) return [3, 7];
|
|
248
|
+
return [4, resp.json()];
|
|
249
|
+
case 6:
|
|
250
|
+
data = _b.sent();
|
|
251
|
+
if (data.status == 'success') {
|
|
252
|
+
newRef = (0, toNumber_1.default)(data.result);
|
|
253
|
+
return [3, 11];
|
|
254
|
+
}
|
|
255
|
+
_b.label = 7;
|
|
256
|
+
case 7: return [3, 9];
|
|
257
|
+
case 8:
|
|
258
|
+
e_2 = _b.sent();
|
|
259
|
+
console.log('Error fetching transfer number', e_2);
|
|
260
|
+
return [3, 9];
|
|
261
|
+
case 9: return [4, (0, tools_1.waitFor)(1000)];
|
|
262
|
+
case 10:
|
|
263
|
+
_b.sent();
|
|
264
|
+
triesLeft--;
|
|
265
|
+
return [3, 3];
|
|
266
|
+
case 11:
|
|
267
|
+
if (triesLeft == 0)
|
|
268
|
+
throw new Error('could not get a Ref number');
|
|
269
|
+
return [2, newRef];
|
|
270
|
+
case 12:
|
|
271
|
+
e_3 = _b.sent();
|
|
272
|
+
console.log('error on fetching new transfer ref: ', e_3.toString());
|
|
273
|
+
return [2];
|
|
274
|
+
case 13: return [2];
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}); };
|
|
278
|
+
_this.save = function (partial, saveToDatabase, merge) {
|
|
279
|
+
if (saveToDatabase === void 0) { saveToDatabase = true; }
|
|
280
|
+
if (merge === void 0) { merge = true; }
|
|
281
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
282
|
+
var saveResult;
|
|
283
|
+
return __generator(this, function (_b) {
|
|
284
|
+
switch (_b.label) {
|
|
285
|
+
case 0: return [4, _super.prototype.save.call(this, partial, undefined, saveToDatabase, undefined, merge)];
|
|
286
|
+
case 1:
|
|
287
|
+
saveResult = _b.sent();
|
|
288
|
+
if (typeof saveResult === 'string') {
|
|
289
|
+
this._data = __assign(__assign({}, this._data), { id: saveResult });
|
|
290
|
+
}
|
|
291
|
+
return [2, saveResult];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
_this.validateBeforeSubmit = function (strictQty) {
|
|
297
|
+
if (strictQty === void 0) { strictQty = true; }
|
|
298
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
299
|
+
return __generator(this, function (_b) {
|
|
300
|
+
if (strictQty) {
|
|
301
|
+
return [2, this.data().products.every(function (p) { return typeof p.qte_validation == 'undefined' || p.qte === p.qte_validation; })];
|
|
302
|
+
}
|
|
303
|
+
return [2, this.data().products.every(function (p) { return typeof p.qte_validation == 'undefined' || p.qte_validation >= 0; })];
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
_this.clearValidationQuantitiesFromProductData = function (copyQte) {
|
|
308
|
+
if (copyQte === void 0) { copyQte = false; }
|
|
309
|
+
_this._data = __assign(__assign({}, _this._data), { products: _this._data.products.map(function (p) { return (__assign(__assign({}, p), { qte: copyQte ? p.qte_validation || 0 : p.qte, qte_validation: undefined })); }) });
|
|
310
|
+
};
|
|
311
|
+
_this.addValidationQuantitiesToReceivedQuantities = function () {
|
|
312
|
+
_this._data = __assign(__assign({}, _this._data), { products: _this._data.products.map(function (p) { return (__assign(__assign({}, p), { qte_received: (p.qte_validation || 0) + (p.qte_received || 0), qte_validation: undefined })); }) });
|
|
313
|
+
};
|
|
314
|
+
_this.getPreviousReceivedQuantity = function (sku) {
|
|
315
|
+
var entry = _this._data.transfer_updates.find(function (u) {
|
|
316
|
+
return (u.status == TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL || u.status == TransferRequest_1.TransferRequestStatusEnum.RECEIVED) &&
|
|
317
|
+
u.products &&
|
|
318
|
+
u.products[sku];
|
|
319
|
+
});
|
|
320
|
+
if (entry) {
|
|
321
|
+
return entry.products[sku].qte_after;
|
|
322
|
+
}
|
|
323
|
+
return 0;
|
|
324
|
+
};
|
|
325
|
+
_this.getOriginalRequestedQuantity = function (sku) {
|
|
326
|
+
var product = _this._data.products.find(function (p) { return p.sku == sku; });
|
|
327
|
+
if (!product)
|
|
328
|
+
return 0;
|
|
329
|
+
var result = product.qte;
|
|
330
|
+
_this._data.transfer_updates.map(function (u) {
|
|
331
|
+
if (u.status != TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL &&
|
|
332
|
+
u.status != TransferRequest_1.TransferRequestStatusEnum.RECEIVED &&
|
|
333
|
+
u.products &&
|
|
334
|
+
u.products[sku])
|
|
335
|
+
result = u.products[sku].qte_before;
|
|
336
|
+
});
|
|
337
|
+
return result;
|
|
338
|
+
};
|
|
339
|
+
_this.getQuantityAtStatus = function (sku, status) {
|
|
340
|
+
var statusPos = (0, transferRequests_1.getOrderPositionForStatus)(status, TransferRequest_1.transferRequestStatusOrder) || 0;
|
|
341
|
+
if (statusPos == 0) {
|
|
342
|
+
var updates = _this._data.transfer_updates.filter(function (u) { return u.status == status; });
|
|
343
|
+
if (!updates.some(function (u) { return !!u.products && !!u.products && !!u.products[sku]; }))
|
|
344
|
+
return _this.getOriginalRequestedQuantity(sku);
|
|
345
|
+
}
|
|
346
|
+
var product = _this._data.products.find(function (p) { return p.sku == sku; });
|
|
347
|
+
if (!product)
|
|
348
|
+
return 0;
|
|
349
|
+
var result = product.qte;
|
|
350
|
+
for (var _i = 0, _b = _this._data.transfer_updates; _i < _b.length; _i++) {
|
|
351
|
+
var i = _b[_i];
|
|
352
|
+
if (((0, transferRequests_1.getOrderPositionForStatus)(i.status, TransferRequest_1.transferRequestStatusOrder) || 0) <= statusPos &&
|
|
353
|
+
i.products &&
|
|
354
|
+
i.products[sku]) {
|
|
355
|
+
result = i.products[sku].qte_after;
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return result;
|
|
360
|
+
};
|
|
361
|
+
_this.getInventoryQuantitiesStillMissingForCartTransfer = function (associatedCart, itemSku, otherUnits) {
|
|
362
|
+
var _b;
|
|
363
|
+
if (!!!associatedCart)
|
|
364
|
+
return 0;
|
|
365
|
+
var sameProd = associatedCart.data().items.find(function (i) { return i.sku == itemSku; });
|
|
366
|
+
if (!!!sameProd)
|
|
367
|
+
return 0;
|
|
368
|
+
var alreadyReservedQuantities = (_b = sameProd.qte_reserved) !== null && _b !== void 0 ? _b : 0;
|
|
369
|
+
var quantitiesNeededForCart = sameProd.qte - alreadyReservedQuantities;
|
|
370
|
+
var convertedToInventoryForCartQuantities = (0, inventories_1.getConvertedUnitQuantity)(otherUnits, quantitiesNeededForCart);
|
|
371
|
+
return convertedToInventoryForCartQuantities;
|
|
372
|
+
};
|
|
373
|
+
_this.handleFreeTransitInventory = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
374
|
+
var inventoryColl, _i, _b, product, inventoryItemQuery, inventoryItem, err_1;
|
|
375
|
+
return __generator(this, function (_c) {
|
|
376
|
+
switch (_c.label) {
|
|
377
|
+
case 0:
|
|
378
|
+
if (!this._data.from || this._data.status != TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL)
|
|
379
|
+
return [2, false];
|
|
380
|
+
_c.label = 1;
|
|
381
|
+
case 1:
|
|
382
|
+
_c.trys.push([1, 7, , 8]);
|
|
383
|
+
if (DatabaseService_1.default.getPathParent(this._collection.path) == '/')
|
|
384
|
+
return [2, false];
|
|
385
|
+
inventoryColl = DatabaseService_1.default.asCollectionObject(DatabaseService_1.default.getPathParent(this._collection.path), 'inventories');
|
|
386
|
+
_i = 0, _b = this._data.products;
|
|
387
|
+
_c.label = 2;
|
|
388
|
+
case 2:
|
|
389
|
+
if (!(_i < _b.length)) return [3, 6];
|
|
390
|
+
product = _b[_i];
|
|
391
|
+
if (product.qte_received >= product.qte)
|
|
392
|
+
return [3, 5];
|
|
393
|
+
return [4, DatabaseService_1.default.getDocument(inventoryColl.path, product.sku)];
|
|
394
|
+
case 3:
|
|
395
|
+
inventoryItemQuery = _c.sent();
|
|
396
|
+
if (!!!inventoryItemQuery.exists)
|
|
397
|
+
return [3, 5];
|
|
398
|
+
inventoryItem = new Inventory_1.default(inventoryItemQuery.data, inventoryColl, this._user);
|
|
399
|
+
return [4, inventoryItem.handleCancelInTransit(this._data.from, product.qte - product.qte_received, undefined, !!this._data.associated_order)];
|
|
400
|
+
case 4:
|
|
401
|
+
_c.sent();
|
|
402
|
+
_c.label = 5;
|
|
403
|
+
case 5:
|
|
404
|
+
_i++;
|
|
405
|
+
return [3, 2];
|
|
406
|
+
case 6: return [3, 8];
|
|
407
|
+
case 7:
|
|
408
|
+
err_1 = _c.sent();
|
|
409
|
+
console.log('err', err_1);
|
|
410
|
+
return [2, false];
|
|
411
|
+
case 8: return [2];
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}); };
|
|
415
|
+
_this.handleChangeStoreInventory = function (newStatus) { return __awaiter(_this, void 0, void 0, function () {
|
|
416
|
+
var inventoryColl, associatedCart, e_4, _i, _b, product, inventoryItemQuery, inventoryItem, _c, qteReceivedSinceLastStatus, qteToReserve, err_2;
|
|
417
|
+
return __generator(this, function (_d) {
|
|
418
|
+
switch (_d.label) {
|
|
419
|
+
case 0:
|
|
420
|
+
if (!this._data.from)
|
|
421
|
+
return [2, false];
|
|
422
|
+
_d.label = 1;
|
|
423
|
+
case 1:
|
|
424
|
+
_d.trys.push([1, 15, , 16]);
|
|
425
|
+
if (DatabaseService_1.default.getPathParent(this._collection.path) == '/')
|
|
426
|
+
return [2, false];
|
|
427
|
+
inventoryColl = DatabaseService_1.default.asCollectionObject(DatabaseService_1.default.getPathParent(this._collection.path), 'inventories');
|
|
428
|
+
associatedCart = void 0;
|
|
429
|
+
if (!(newStatus == TransferRequest_1.TransferRequestStatusEnum.RECEIVED || newStatus == TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL)) return [3, 5];
|
|
430
|
+
_d.label = 2;
|
|
431
|
+
case 2:
|
|
432
|
+
_d.trys.push([2, 4, , 5]);
|
|
433
|
+
return [4, this.fetchAssociatedCart()];
|
|
434
|
+
case 3:
|
|
435
|
+
associatedCart = _d.sent();
|
|
436
|
+
return [3, 5];
|
|
437
|
+
case 4:
|
|
438
|
+
e_4 = _d.sent();
|
|
439
|
+
console.log('error on fetching cart for transfer: ', e_4.toString());
|
|
440
|
+
return [3, 5];
|
|
441
|
+
case 5:
|
|
442
|
+
_i = 0, _b = this._data.products;
|
|
443
|
+
_d.label = 6;
|
|
444
|
+
case 6:
|
|
445
|
+
if (!(_i < _b.length)) return [3, 14];
|
|
446
|
+
product = _b[_i];
|
|
447
|
+
return [4, DatabaseService_1.default.getDocument(inventoryColl.path, product.sku)];
|
|
448
|
+
case 7:
|
|
449
|
+
inventoryItemQuery = _d.sent();
|
|
450
|
+
if (!!!inventoryItemQuery.exists)
|
|
451
|
+
return [3, 13];
|
|
452
|
+
inventoryItem = new Inventory_1.default(inventoryItemQuery.data, inventoryColl, this._user);
|
|
453
|
+
_c = newStatus;
|
|
454
|
+
switch (_c) {
|
|
455
|
+
case TransferRequest_1.TransferRequestStatusEnum.IN_TRANSIT: return [3, 8];
|
|
456
|
+
case TransferRequest_1.TransferRequestStatusEnum.RECEIVED: return [3, 10];
|
|
457
|
+
case TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL: return [3, 10];
|
|
458
|
+
}
|
|
459
|
+
return [3, 12];
|
|
460
|
+
case 8: return [4, inventoryItem.handleTransferInTransit(this._data.from, product.qte, undefined, !!this._data.associated_order)];
|
|
461
|
+
case 9:
|
|
462
|
+
_d.sent();
|
|
463
|
+
return [3, 12];
|
|
464
|
+
case 10:
|
|
465
|
+
qteReceivedSinceLastStatus = product.qte_received - this.getPreviousReceivedQuantity(product.sku);
|
|
466
|
+
if (qteReceivedSinceLastStatus == 0)
|
|
467
|
+
return [3, 13];
|
|
468
|
+
qteToReserve = this.getInventoryQuantitiesStillMissingForCartTransfer(associatedCart, product.sku, inventoryItem.data().other_units);
|
|
469
|
+
return [4, inventoryItem.handleTransferReceived(this._data.from, this._data.to, qteReceivedSinceLastStatus, undefined, {
|
|
470
|
+
forOrder: !!this._data.associated_order,
|
|
471
|
+
maxProcessingQte: typeof qteToReserve == 'number' && qteToReserve >= 0
|
|
472
|
+
? qteToReserve > qteReceivedSinceLastStatus
|
|
473
|
+
? qteReceivedSinceLastStatus
|
|
474
|
+
: qteToReserve
|
|
475
|
+
: 0
|
|
476
|
+
})];
|
|
477
|
+
case 11:
|
|
478
|
+
_d.sent();
|
|
479
|
+
return [3, 12];
|
|
480
|
+
case 12: return [3, 13];
|
|
481
|
+
case 13:
|
|
482
|
+
_i++;
|
|
483
|
+
return [3, 6];
|
|
484
|
+
case 14: return [2, true];
|
|
485
|
+
case 15:
|
|
486
|
+
err_2 = _d.sent();
|
|
487
|
+
console.log('err', err_2);
|
|
488
|
+
return [2, false];
|
|
489
|
+
case 16: return [2];
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}); };
|
|
493
|
+
_this.handleUpdateAssociatedCartReservedQuantities = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
494
|
+
var associatedCart, somethingHasChanged, cartItems, updatedCartItems, _loop_1, this_1, _i, cartItems_1, item, e_5;
|
|
495
|
+
var _b;
|
|
496
|
+
return __generator(this, function (_c) {
|
|
497
|
+
switch (_c.label) {
|
|
498
|
+
case 0: return [4, this.fetchAssociatedCart()];
|
|
499
|
+
case 1:
|
|
500
|
+
associatedCart = _c.sent();
|
|
501
|
+
if (!!!associatedCart)
|
|
502
|
+
return [2];
|
|
503
|
+
somethingHasChanged = false;
|
|
504
|
+
cartItems = associatedCart.data().items;
|
|
505
|
+
updatedCartItems = [];
|
|
506
|
+
_loop_1 = function (item) {
|
|
507
|
+
var sameInTransfer = this_1._data.products.find(function (p) { return p.sku == item.sku; });
|
|
508
|
+
if (!!!sameInTransfer) {
|
|
509
|
+
updatedCartItems.push(item);
|
|
510
|
+
return "continue";
|
|
511
|
+
}
|
|
512
|
+
var sellUnit = (item.other_units || []).find(function (o) { return o.is_sale_unit; });
|
|
513
|
+
var unitHasDecimals = !!sellUnit && (0, products_1.productUnitSupportsDecimals)(sellUnit.unit_slug);
|
|
514
|
+
if (typeof item.qte_reserved == 'number' && (0, round_1.default)(item.qte_reserved, unitHasDecimals ? 2 : 0) >= item.qte) {
|
|
515
|
+
updatedCartItems.push(item);
|
|
516
|
+
return "continue";
|
|
517
|
+
}
|
|
518
|
+
var qteReceivedSinceLastStatus = sameInTransfer.qte_received - this_1.getPreviousReceivedQuantity(sameInTransfer.sku);
|
|
519
|
+
if (!!!qteReceivedSinceLastStatus) {
|
|
520
|
+
updatedCartItems.push(item);
|
|
521
|
+
return "continue";
|
|
522
|
+
}
|
|
523
|
+
var newReservedQte = (0, inventories_1.getConvertedUnitQuantity)(item.other_units, (_b = item.qte_reserved) !== null && _b !== void 0 ? _b : 0, 'inventory_unit') +
|
|
524
|
+
qteReceivedSinceLastStatus;
|
|
525
|
+
updatedCartItems.push(__assign(__assign({}, item), { qte_reserved: (0, inventories_1.getConvertedUnitQuantity)(item.other_units, newReservedQte > item.qte ? item.qte : newReservedQte, 'sale_unit') }));
|
|
526
|
+
somethingHasChanged = true;
|
|
527
|
+
};
|
|
528
|
+
this_1 = this;
|
|
529
|
+
for (_i = 0, cartItems_1 = cartItems; _i < cartItems_1.length; _i++) {
|
|
530
|
+
item = cartItems_1[_i];
|
|
531
|
+
_loop_1(item);
|
|
532
|
+
}
|
|
533
|
+
if (!!!somethingHasChanged)
|
|
534
|
+
return [2];
|
|
535
|
+
_c.label = 2;
|
|
536
|
+
case 2:
|
|
537
|
+
_c.trys.push([2, 4, , 5]);
|
|
538
|
+
return [4, associatedCart.save({ items: updatedCartItems, id: associatedCart.data().id }, undefined, true, true, true)];
|
|
539
|
+
case 3:
|
|
540
|
+
_c.sent();
|
|
541
|
+
return [3, 5];
|
|
542
|
+
case 4:
|
|
543
|
+
e_5 = _c.sent();
|
|
544
|
+
console.log('error on saving cart with new qte_received in items: ', e_5.toString());
|
|
545
|
+
return [3, 5];
|
|
546
|
+
case 5: return [2];
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}); };
|
|
550
|
+
_this.constructProductObjFromUpdates = function (updatesToDo) {
|
|
551
|
+
var updatedProducts = _this._data.products.map(function (currentProd) {
|
|
552
|
+
var sameInUpdates = updatesToDo.find(function (u) { return u.sku == currentProd.sku; });
|
|
553
|
+
if (!!!sameInUpdates)
|
|
554
|
+
return currentProd;
|
|
555
|
+
var newQte = currentProd.qte + sameInUpdates.ajustmentQte;
|
|
556
|
+
if (newQte < 0)
|
|
557
|
+
newQte = 0;
|
|
558
|
+
return __assign(__assign({}, currentProd), { qte: newQte });
|
|
559
|
+
});
|
|
560
|
+
return updatedProducts;
|
|
561
|
+
};
|
|
562
|
+
_this.saveUpdatesToProductsOnly = function (updatedProducts, options, cancelTransferIfAllProductsAtZero) { return __awaiter(_this, void 0, void 0, function () {
|
|
563
|
+
var statusPositionObj, shouldCancelTransfer, statusToUse, newUpdates, e_6, errorStr;
|
|
564
|
+
return __generator(this, function (_b) {
|
|
565
|
+
switch (_b.label) {
|
|
566
|
+
case 0:
|
|
567
|
+
if (!TransferRequest.transferAllowsIndependantProductUpdate(this._data)) {
|
|
568
|
+
throw new Error('Cannot update products without changing status for current transfer status.');
|
|
569
|
+
}
|
|
570
|
+
return [4, this.save({ products: updatedProducts }, false, true)];
|
|
571
|
+
case 1:
|
|
572
|
+
_b.sent();
|
|
573
|
+
if (!!updatedProducts.some(function (p) { return typeof p.qte_validation == 'number'; })) {
|
|
574
|
+
this.clearValidationQuantitiesFromProductData(true);
|
|
575
|
+
}
|
|
576
|
+
_b.label = 2;
|
|
577
|
+
case 2:
|
|
578
|
+
_b.trys.push([2, 5, , 6]);
|
|
579
|
+
return [4, this._getOrderObject()];
|
|
580
|
+
case 3:
|
|
581
|
+
statusPositionObj = _b.sent();
|
|
582
|
+
shouldCancelTransfer = !!cancelTransferIfAllProductsAtZero &&
|
|
583
|
+
updatedProducts.every(function (p) { return p.qte <= 0; }) &&
|
|
584
|
+
TransferRequest.checkIfTransferCanBeCancelled(this._data.status, statusPositionObj);
|
|
585
|
+
statusToUse = !!shouldCancelTransfer ? TransferRequest_1.TransferRequestStatusEnum.CANCELLED : this._data.status;
|
|
586
|
+
newUpdates = this._generateNewTransferStatusUpdates(statusToUse, options.user, options.comment);
|
|
587
|
+
return [4, this.save(__assign({ transfer_updates: newUpdates }, (shouldCancelTransfer ? { status: statusToUse, completed: true } : {})), true, true)];
|
|
588
|
+
case 4:
|
|
589
|
+
_b.sent();
|
|
590
|
+
return [3, 6];
|
|
591
|
+
case 5:
|
|
592
|
+
e_6 = _b.sent();
|
|
593
|
+
errorStr = 'error on updating products independantly from status: ' + e_6.toString();
|
|
594
|
+
console.log(errorStr);
|
|
595
|
+
throw new Error(errorStr);
|
|
596
|
+
case 6: return [2, this.data()];
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
}); };
|
|
600
|
+
_this.setDraftValue = function (newVal) {
|
|
601
|
+
_this._data = __assign(__assign({}, _this._data), { draft: newVal });
|
|
602
|
+
};
|
|
603
|
+
_this.setAssociatedOrder = function (newVal) {
|
|
604
|
+
_this._data = __assign(__assign({}, _this._data), { associated_order: newVal });
|
|
605
|
+
};
|
|
606
|
+
_this.setTransportRef = function (newVal, saveToDatabase) {
|
|
607
|
+
if (saveToDatabase === void 0) { saveToDatabase = false; }
|
|
608
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
609
|
+
return __generator(this, function (_b) {
|
|
610
|
+
switch (_b.label) {
|
|
611
|
+
case 0: return [4, this.save({ transport_ref: newVal }, saveToDatabase, true)];
|
|
612
|
+
case 1:
|
|
613
|
+
_b.sent();
|
|
614
|
+
return [2];
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
};
|
|
619
|
+
_this.setOriginalTransferId = function (newVal) { return __awaiter(_this, void 0, void 0, function () {
|
|
620
|
+
return __generator(this, function (_b) {
|
|
621
|
+
this._data = __assign(__assign({}, this._data), { original_transfer_id: newVal });
|
|
622
|
+
return [2];
|
|
623
|
+
});
|
|
624
|
+
}); };
|
|
625
|
+
_this.setAsCompleted = function (user, comment) { return __awaiter(_this, void 0, void 0, function () {
|
|
626
|
+
return __generator(this, function (_b) {
|
|
627
|
+
switch (_b.label) {
|
|
628
|
+
case 0:
|
|
629
|
+
this._generateNewTransferStatusUpdates(this._data.status, user, "Ferm\u00E9 manuellement".concat(!!comment ? ' : ' + comment : ''), this._data.products);
|
|
630
|
+
return [4, this.handleFreeTransitInventory()];
|
|
631
|
+
case 1:
|
|
632
|
+
_b.sent();
|
|
633
|
+
return [4, this.save({ completed: true }, true, true)];
|
|
634
|
+
case 2:
|
|
635
|
+
_b.sent();
|
|
636
|
+
return [2];
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}); };
|
|
640
|
+
_this.changeStatus = function (newStatus, comment, user, saveToDatabase, setAsCompleted, originalRequestProducts, space) {
|
|
641
|
+
if (saveToDatabase === void 0) { saveToDatabase = true; }
|
|
642
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
643
|
+
var options, fncToCall, e_7;
|
|
644
|
+
return __generator(this, function (_b) {
|
|
645
|
+
switch (_b.label) {
|
|
646
|
+
case 0:
|
|
647
|
+
options = {
|
|
648
|
+
comment: comment,
|
|
649
|
+
user: user,
|
|
650
|
+
saveToDatabase: saveToDatabase,
|
|
651
|
+
originalRequestProducts: originalRequestProducts,
|
|
652
|
+
space: space
|
|
653
|
+
};
|
|
654
|
+
switch (newStatus) {
|
|
655
|
+
case TransferRequest_1.TransferRequestStatusEnum.OPEN:
|
|
656
|
+
fncToCall = this.updateToStatus.open;
|
|
657
|
+
break;
|
|
658
|
+
case TransferRequest_1.TransferRequestStatusEnum.TO_BE_PREPARED:
|
|
659
|
+
fncToCall = this.updateToStatus.toBePrepared;
|
|
660
|
+
break;
|
|
661
|
+
case TransferRequest_1.TransferRequestStatusEnum.IN_TRANSIT:
|
|
662
|
+
fncToCall = this.updateToStatus.inTransit;
|
|
663
|
+
break;
|
|
664
|
+
case TransferRequest_1.TransferRequestStatusEnum.RECEIVED:
|
|
665
|
+
fncToCall = this.updateToStatus.received;
|
|
666
|
+
break;
|
|
667
|
+
case TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL:
|
|
668
|
+
options.markAsCompleted = setAsCompleted;
|
|
669
|
+
fncToCall = this.updateToStatus.receivedPartial;
|
|
670
|
+
break;
|
|
671
|
+
case TransferRequest_1.TransferRequestStatusEnum.CANCELLED:
|
|
672
|
+
fncToCall = this.updateToStatus.cancelled;
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
if (!!!fncToCall)
|
|
676
|
+
throw new Error('No status update function associated to provided status! Returning.');
|
|
677
|
+
_b.label = 1;
|
|
678
|
+
case 1:
|
|
679
|
+
_b.trys.push([1, 3, , 4]);
|
|
680
|
+
return [4, fncToCall(options)];
|
|
681
|
+
case 2:
|
|
682
|
+
_b.sent();
|
|
683
|
+
return [2, this.data()];
|
|
684
|
+
case 3:
|
|
685
|
+
e_7 = _b.sent();
|
|
686
|
+
throw new Error('Impossible de soumettre le(s) transfert(s)');
|
|
687
|
+
case 4: return [2];
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
};
|
|
692
|
+
_this.saveNewTransfer = function (currentUser, comment, saveToDatabase, skipRef) {
|
|
693
|
+
if (saveToDatabase === void 0) { saveToDatabase = true; }
|
|
694
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
695
|
+
var newUpdates, newTransferRef;
|
|
696
|
+
return __generator(this, function (_b) {
|
|
697
|
+
switch (_b.label) {
|
|
698
|
+
case 0:
|
|
699
|
+
if (!!this.data().id)
|
|
700
|
+
throw 'Cette demande de transfert existe déjà en base de données!';
|
|
701
|
+
if (!!!this.data().status)
|
|
702
|
+
throw "Cette demande n'a pas encore de statut initial, et ne peut être sauvegardée!";
|
|
703
|
+
newUpdates = this._generateNewTransferStatusUpdates(this.data().status, currentUser, comment);
|
|
704
|
+
newTransferRef = undefined;
|
|
705
|
+
if (!!!!skipRef) return [3, 2];
|
|
706
|
+
return [4, this._getTransferRef()];
|
|
707
|
+
case 1:
|
|
708
|
+
newTransferRef = _b.sent();
|
|
709
|
+
_b.label = 2;
|
|
710
|
+
case 2: return [4, this.save(__assign(__assign({}, this.data()), { ref: newTransferRef, transfer_updates: newUpdates }), saveToDatabase)];
|
|
711
|
+
case 3: return [2, _b.sent()];
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
};
|
|
716
|
+
_this.getProductWeight = function (sku, unit) {
|
|
717
|
+
if (unit === void 0) { unit = 'pounds'; }
|
|
718
|
+
var item = _this.data().products.find(function (p) { return p.sku == sku; });
|
|
719
|
+
if (!item)
|
|
720
|
+
return 0;
|
|
721
|
+
if (!!!item.weight)
|
|
722
|
+
return 0;
|
|
723
|
+
var value = (0, toNumber_1.default)(item.weight.value) || 0;
|
|
724
|
+
return item.weight.unit === unit ? value * item.qte : (0, weight_1.convertWeight)(value, item.weight.unit, unit) * item.qte;
|
|
725
|
+
};
|
|
726
|
+
_this._getOrderObject = function (space) { return __awaiter(_this, void 0, void 0, function () {
|
|
727
|
+
return __generator(this, function (_b) {
|
|
728
|
+
switch (_b.label) {
|
|
729
|
+
case 0:
|
|
730
|
+
if (!!space) return [3, 2];
|
|
731
|
+
return [4, Space_1.default.getCurrentSpaceWithRef(this._collection.path, this._user)];
|
|
732
|
+
case 1:
|
|
733
|
+
space = _b.sent();
|
|
734
|
+
_b.label = 2;
|
|
735
|
+
case 2: return [2, space.transferRequests.getTransferStatusOrder()];
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
}); };
|
|
739
|
+
_this._checkIfCanChangeToStatus = function (statusToCheck, space) { return __awaiter(_this, void 0, void 0, function () {
|
|
740
|
+
var currentStatus, orderObj, possibleNextStatus, e_8;
|
|
741
|
+
return __generator(this, function (_b) {
|
|
742
|
+
switch (_b.label) {
|
|
743
|
+
case 0:
|
|
744
|
+
currentStatus = this._data.status;
|
|
745
|
+
if (currentStatus == statusToCheck)
|
|
746
|
+
return [2, true];
|
|
747
|
+
_b.label = 1;
|
|
748
|
+
case 1:
|
|
749
|
+
_b.trys.push([1, 3, , 4]);
|
|
750
|
+
return [4, this._getOrderObject(space)];
|
|
751
|
+
case 2:
|
|
752
|
+
orderObj = _b.sent();
|
|
753
|
+
possibleNextStatus = (0, transferRequests_1.getTransferStatusAfter)(currentStatus, orderObj);
|
|
754
|
+
return [2, possibleNextStatus !== null && possibleNextStatus.values.includes(statusToCheck)];
|
|
755
|
+
case 3:
|
|
756
|
+
e_8 = _b.sent();
|
|
757
|
+
console.log('error on checking status change: ', e_8.toString());
|
|
758
|
+
return [2, false];
|
|
759
|
+
case 4: return [2];
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}); };
|
|
763
|
+
_this._generateNewTransferStatusUpdates = function (newStatus, user, comment, originalRequestProducts) {
|
|
764
|
+
var updates = _this._data.transfer_updates;
|
|
765
|
+
var newProducts = _this._data.products;
|
|
766
|
+
var prodUpdateObj = {};
|
|
767
|
+
if (!!_this._data.id || !!originalRequestProducts) {
|
|
768
|
+
if (newStatus == TransferRequest_1.TransferRequestStatusEnum.RECEIVED || newStatus == TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL) {
|
|
769
|
+
for (var _i = 0, newProducts_1 = newProducts; _i < newProducts_1.length; _i++) {
|
|
770
|
+
var prod = newProducts_1[_i];
|
|
771
|
+
var addedQty = prod.qte_received - _this.getPreviousReceivedQuantity(prod.sku);
|
|
772
|
+
if (addedQty != 0) {
|
|
773
|
+
prodUpdateObj[prod.sku] = {
|
|
774
|
+
qte_before: prod.qte_received - addedQty,
|
|
775
|
+
qte_after: prod.qte_received,
|
|
776
|
+
name: prod.name
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
var prevProducts = !!originalRequestProducts ? originalRequestProducts : _this.prevProducts;
|
|
783
|
+
var _loop_2 = function (prod) {
|
|
784
|
+
var name_1 = prod.name;
|
|
785
|
+
var sameInPrev = prevProducts.find(function (p) { return p.sku == prod.sku; });
|
|
786
|
+
if (!!!sameInPrev) {
|
|
787
|
+
prodUpdateObj[prod.sku] = { qte_before: 0, qte_after: prod.qte, name: name_1 };
|
|
788
|
+
}
|
|
789
|
+
else if (sameInPrev.qte !== prod.qte) {
|
|
790
|
+
prodUpdateObj[prod.sku] = { qte_before: sameInPrev.qte, qte_after: prod.qte, name: name_1 };
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
for (var _b = 0, newProducts_2 = newProducts; _b < newProducts_2.length; _b++) {
|
|
794
|
+
var prod = newProducts_2[_b];
|
|
795
|
+
_loop_2(prod);
|
|
796
|
+
}
|
|
797
|
+
var _loop_3 = function (prevProd) {
|
|
798
|
+
var sameInNew = newProducts.find(function (p) { return p.sku == prevProd.sku; });
|
|
799
|
+
if (!!!sameInNew) {
|
|
800
|
+
prodUpdateObj[prevProd.sku] = { qte_before: prevProd.qte, qte_after: 0, name: prevProd.name };
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
for (var _c = 0, _d = _this.prevProducts; _c < _d.length; _c++) {
|
|
804
|
+
var prevProd = _d[_c];
|
|
805
|
+
_loop_3(prevProd);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
updates.unshift({
|
|
810
|
+
status: newStatus,
|
|
811
|
+
date: new Date(),
|
|
812
|
+
updated_by: user,
|
|
813
|
+
comment: comment,
|
|
814
|
+
products: !!Object.keys(prodUpdateObj).length ? prodUpdateObj : null
|
|
815
|
+
});
|
|
816
|
+
return updates;
|
|
817
|
+
};
|
|
818
|
+
_this._saveNewStatus = function (newStatus, options, forceCompleted) {
|
|
819
|
+
if (forceCompleted === void 0) { forceCompleted = false; }
|
|
820
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
821
|
+
var newUpdates, completedProps, canSetAsCompleted, response, e_9;
|
|
822
|
+
return __generator(this, function (_b) {
|
|
823
|
+
switch (_b.label) {
|
|
824
|
+
case 0:
|
|
825
|
+
newUpdates = this._generateNewTransferStatusUpdates(newStatus, options.user, options.comment, options.originalRequestProducts);
|
|
826
|
+
completedProps = options.markAsCompleted;
|
|
827
|
+
canSetAsCompleted = !!completedProps && TransferRequest.checkIfStatusCountsAsCompleted(newStatus);
|
|
828
|
+
if (!!completedProps && !canSetAsCompleted) {
|
|
829
|
+
console.log('Could not set completed property to true since provided new status was not found in "elligible" array!');
|
|
830
|
+
}
|
|
831
|
+
_b.label = 1;
|
|
832
|
+
case 1:
|
|
833
|
+
_b.trys.push([1, 3, , 4]);
|
|
834
|
+
return [4, this.save(__assign({ status: newStatus, transfer_updates: newUpdates }, (forceCompleted || canSetAsCompleted ? { completed: true } : {})), options.saveToDatabase)];
|
|
835
|
+
case 2:
|
|
836
|
+
response = _b.sent();
|
|
837
|
+
if (!!!response)
|
|
838
|
+
throw new Error('Error while saving the transfer reqeust.');
|
|
839
|
+
return [3, 4];
|
|
840
|
+
case 3:
|
|
841
|
+
e_9 = _b.sent();
|
|
842
|
+
console.error('Error while saving the transfer reqeust.');
|
|
843
|
+
throw new Error('Error while saving the transfer reqeust.');
|
|
844
|
+
case 4: return [2];
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
};
|
|
849
|
+
_this._setAsOpen = function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
850
|
+
var newStatus, statusChangeValid;
|
|
851
|
+
return __generator(this, function (_b) {
|
|
852
|
+
switch (_b.label) {
|
|
853
|
+
case 0:
|
|
854
|
+
newStatus = TransferRequest_1.TransferRequestStatusEnum.OPEN;
|
|
855
|
+
return [4, this._checkIfCanChangeToStatus(newStatus, options.space)];
|
|
856
|
+
case 1:
|
|
857
|
+
statusChangeValid = _b.sent();
|
|
858
|
+
if (!statusChangeValid)
|
|
859
|
+
throw new Error('Trying to change to wrong status! Returning.');
|
|
860
|
+
return [4, this._saveNewStatus(newStatus, options)];
|
|
861
|
+
case 2:
|
|
862
|
+
_b.sent();
|
|
863
|
+
return [2];
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
}); };
|
|
867
|
+
_this._setAsToBePrepared = function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
868
|
+
var newStatus, statusChangeValid;
|
|
869
|
+
return __generator(this, function (_b) {
|
|
870
|
+
switch (_b.label) {
|
|
871
|
+
case 0:
|
|
872
|
+
newStatus = TransferRequest_1.TransferRequestStatusEnum.TO_BE_PREPARED;
|
|
873
|
+
return [4, this._checkIfCanChangeToStatus(newStatus, options.space)];
|
|
874
|
+
case 1:
|
|
875
|
+
statusChangeValid = _b.sent();
|
|
876
|
+
if (!statusChangeValid)
|
|
877
|
+
throw new Error('Trying to change to wrong status! Returning.');
|
|
878
|
+
return [4, this._saveNewStatus(newStatus, options)];
|
|
879
|
+
case 2:
|
|
880
|
+
_b.sent();
|
|
881
|
+
return [2];
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
}); };
|
|
885
|
+
_this._setAsInTransit = function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
886
|
+
var newStatus, statusChangeValid, inventoryChangesSuccess;
|
|
887
|
+
return __generator(this, function (_b) {
|
|
888
|
+
switch (_b.label) {
|
|
889
|
+
case 0:
|
|
890
|
+
newStatus = TransferRequest_1.TransferRequestStatusEnum.IN_TRANSIT;
|
|
891
|
+
return [4, this._checkIfCanChangeToStatus(newStatus, options.space)];
|
|
892
|
+
case 1:
|
|
893
|
+
statusChangeValid = _b.sent();
|
|
894
|
+
if (!statusChangeValid)
|
|
895
|
+
throw new Error('Trying to change to wrong status! Returning.');
|
|
896
|
+
return [4, this.handleChangeStoreInventory(newStatus)];
|
|
897
|
+
case 2:
|
|
898
|
+
inventoryChangesSuccess = _b.sent();
|
|
899
|
+
if (!!!inventoryChangesSuccess) {
|
|
900
|
+
throw "Une erreur est survenue lors de la mise à jour de l'inventaire.";
|
|
901
|
+
}
|
|
902
|
+
return [4, this._saveNewStatus(newStatus, options)];
|
|
903
|
+
case 3:
|
|
904
|
+
_b.sent();
|
|
905
|
+
return [2];
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}); };
|
|
909
|
+
_this._setAsReceived = function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
910
|
+
var newStatus, statusChangeValid, inventoryChangesSuccess;
|
|
911
|
+
return __generator(this, function (_b) {
|
|
912
|
+
switch (_b.label) {
|
|
913
|
+
case 0:
|
|
914
|
+
newStatus = TransferRequest_1.TransferRequestStatusEnum.RECEIVED;
|
|
915
|
+
return [4, this._checkIfCanChangeToStatus(newStatus, options.space)];
|
|
916
|
+
case 1:
|
|
917
|
+
statusChangeValid = _b.sent();
|
|
918
|
+
if (!statusChangeValid)
|
|
919
|
+
throw new Error('Trying to change to wrong status! Returning.');
|
|
920
|
+
return [4, this.handleChangeStoreInventory(newStatus)];
|
|
921
|
+
case 2:
|
|
922
|
+
inventoryChangesSuccess = _b.sent();
|
|
923
|
+
if (!!!inventoryChangesSuccess) {
|
|
924
|
+
throw "Une erreur est survenue lors de la mise à jour de l'inventaire.";
|
|
925
|
+
}
|
|
926
|
+
return [4, this.handleUpdateAssociatedCartReservedQuantities()];
|
|
927
|
+
case 3:
|
|
928
|
+
_b.sent();
|
|
929
|
+
return [4, this._saveNewStatus(newStatus, options, true)];
|
|
930
|
+
case 4:
|
|
931
|
+
_b.sent();
|
|
932
|
+
return [2];
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
}); };
|
|
936
|
+
_this._setAsReceivedPartially = function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
937
|
+
var newStatus, statusChangeValid, inventoryChangesSuccess;
|
|
938
|
+
return __generator(this, function (_b) {
|
|
939
|
+
switch (_b.label) {
|
|
940
|
+
case 0:
|
|
941
|
+
newStatus = TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL;
|
|
942
|
+
return [4, this._checkIfCanChangeToStatus(newStatus, options.space)];
|
|
943
|
+
case 1:
|
|
944
|
+
statusChangeValid = _b.sent();
|
|
945
|
+
if (!statusChangeValid)
|
|
946
|
+
throw new Error('Trying to change to wrong status! Returning.');
|
|
947
|
+
return [4, this.handleChangeStoreInventory(newStatus)];
|
|
948
|
+
case 2:
|
|
949
|
+
inventoryChangesSuccess = _b.sent();
|
|
950
|
+
if (!!!inventoryChangesSuccess) {
|
|
951
|
+
throw "Une erreur est survenue lors de la mise à jour de l'inventaire.";
|
|
952
|
+
}
|
|
953
|
+
return [4, this.handleUpdateAssociatedCartReservedQuantities()];
|
|
954
|
+
case 3:
|
|
955
|
+
_b.sent();
|
|
956
|
+
return [4, this._saveNewStatus(newStatus, options)];
|
|
957
|
+
case 4:
|
|
958
|
+
_b.sent();
|
|
959
|
+
return [2];
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
}); };
|
|
963
|
+
_this._setAsCancelled = function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
964
|
+
var newStatus, statusPositionObj, canBeCancelled;
|
|
965
|
+
return __generator(this, function (_b) {
|
|
966
|
+
switch (_b.label) {
|
|
967
|
+
case 0:
|
|
968
|
+
newStatus = TransferRequest_1.TransferRequestStatusEnum.CANCELLED;
|
|
969
|
+
return [4, this._getOrderObject()];
|
|
970
|
+
case 1:
|
|
971
|
+
statusPositionObj = _b.sent();
|
|
972
|
+
canBeCancelled = TransferRequest.checkIfTransferCanBeCancelled(this._data.status, statusPositionObj);
|
|
973
|
+
if (!canBeCancelled) {
|
|
974
|
+
throw new Error('transfer cannot be cancelled, status is same of after IN_TRANSIT');
|
|
975
|
+
}
|
|
976
|
+
return [4, this._saveNewStatus(newStatus, options, true)];
|
|
977
|
+
case 2:
|
|
978
|
+
_b.sent();
|
|
979
|
+
return [2];
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
}); };
|
|
983
|
+
_this.updateToStatus = {
|
|
984
|
+
open: _this._setAsOpen,
|
|
985
|
+
toBePrepared: _this._setAsToBePrepared,
|
|
986
|
+
inTransit: _this._setAsInTransit,
|
|
987
|
+
received: _this._setAsReceived,
|
|
988
|
+
receivedPartial: _this._setAsReceivedPartially,
|
|
989
|
+
cancelled: _this._setAsCancelled
|
|
990
|
+
};
|
|
991
|
+
_this.getFormattedRef = function (spaceTransferSettings) {
|
|
992
|
+
if (typeof _this._data.ref == 'undefined') {
|
|
993
|
+
console.log('transfer has no ref, returning!');
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
if (!!!spaceTransferSettings)
|
|
997
|
+
return _this._data.ref.toString();
|
|
998
|
+
var prefix = spaceTransferSettings.prefix;
|
|
999
|
+
var suffix = spaceTransferSettings.suffix;
|
|
1000
|
+
return "".concat(prefix ? prefix + '-' : '').concat(_this._data.ref).concat(suffix ? '-' + suffix : '');
|
|
1001
|
+
};
|
|
1002
|
+
_this._data = _this.processData(_data);
|
|
1003
|
+
if (!!_this._data.products.length) {
|
|
1004
|
+
_this.prevProducts = __spreadArray([], _this._data.products, true);
|
|
1005
|
+
}
|
|
1006
|
+
return _this;
|
|
1007
|
+
}
|
|
1008
|
+
var _a;
|
|
1009
|
+
_a = TransferRequest;
|
|
1010
|
+
TransferRequest.fetch = function (_b) {
|
|
1011
|
+
var app = _b.app, api = _b.api, _c = _b.hpp, hpp = _c === void 0 ? 10 : _c, _d = _b.page, page = _d === void 0 ? 0 : _d, _e = _b.query, query = _e === void 0 ? '' : _e, _f = _b.filters, filters = _f === void 0 ? '' : _f, _g = _b.indice, indice = _g === void 0 ? 'transfer_request' : _g, _h = _b.f, f = _h === void 0 ? '' : _h, space = _b.space, _j = _b.useProspr, useProspr = _j === void 0 ? false : _j;
|
|
1012
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
1013
|
+
var prosprSearch, prosprService, algolia, results, error_1;
|
|
1014
|
+
return __generator(_a, function (_k) {
|
|
1015
|
+
switch (_k.label) {
|
|
1016
|
+
case 0:
|
|
1017
|
+
_k.trys.push([0, 2, , 3]);
|
|
1018
|
+
prosprSearch = false;
|
|
1019
|
+
if (!!space) {
|
|
1020
|
+
prosprService = space
|
|
1021
|
+
.data()
|
|
1022
|
+
.external_services.find(function (es) { return es.external_service_name.toLowerCase().trim() === 'prosprsearch'; });
|
|
1023
|
+
prosprSearch = !!prosprService && prosprService.is_active;
|
|
1024
|
+
}
|
|
1025
|
+
algolia = (0, algolia_1.createClient)({
|
|
1026
|
+
app: app,
|
|
1027
|
+
indexId: "".concat(__1.isTestEnv ? 'test' : 'prod', "_").concat(indice),
|
|
1028
|
+
key: !!useProspr ? api : prosprSearch && !!space ? space.preferences.prosprsearch.app() : api,
|
|
1029
|
+
prospr: !!prosprSearch || !!useProspr
|
|
1030
|
+
});
|
|
1031
|
+
return [4, algolia.search(query, {
|
|
1032
|
+
hitsPerPage: hpp,
|
|
1033
|
+
facetFilters: filters,
|
|
1034
|
+
filters: f,
|
|
1035
|
+
page: page,
|
|
1036
|
+
facets: ['*']
|
|
1037
|
+
})];
|
|
1038
|
+
case 1:
|
|
1039
|
+
results = _k.sent();
|
|
1040
|
+
return [2, results];
|
|
1041
|
+
case 2:
|
|
1042
|
+
error_1 = _k.sent();
|
|
1043
|
+
(0, console_1.errorMessage)(error_1);
|
|
1044
|
+
throw error_1;
|
|
1045
|
+
case 3: return [2];
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
};
|
|
1050
|
+
TransferRequest.getStatusLabel = function (status) {
|
|
1051
|
+
switch (status) {
|
|
1052
|
+
case TransferRequest_1.TransferRequestStatusEnum.INITIATED:
|
|
1053
|
+
return 'Initialisée';
|
|
1054
|
+
case TransferRequest_1.TransferRequestStatusEnum.OPEN:
|
|
1055
|
+
return 'Ouverte';
|
|
1056
|
+
case TransferRequest_1.TransferRequestStatusEnum.TO_BE_PREPARED:
|
|
1057
|
+
return 'À préparer';
|
|
1058
|
+
case TransferRequest_1.TransferRequestStatusEnum.IN_TRANSIT:
|
|
1059
|
+
return 'En transit';
|
|
1060
|
+
case TransferRequest_1.TransferRequestStatusEnum.CANCELLED:
|
|
1061
|
+
return 'Annulée';
|
|
1062
|
+
case TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL:
|
|
1063
|
+
return 'Reçue partiellement';
|
|
1064
|
+
case TransferRequest_1.TransferRequestStatusEnum.RECEIVED:
|
|
1065
|
+
return 'Reçue';
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
TransferRequest.checkIfTransferCanBeCancelled = function (currentTransferStatus, statusOrderObj) {
|
|
1069
|
+
var currentPosition = (0, transferRequests_1.getOrderPositionForStatus)(currentTransferStatus, statusOrderObj);
|
|
1070
|
+
if (typeof currentPosition != 'number') {
|
|
1071
|
+
console.log('could not compare status since currentPosition was not found');
|
|
1072
|
+
return false;
|
|
1073
|
+
}
|
|
1074
|
+
var inTransitPosition = (0, transferRequests_1.getOrderPositionForStatus)(TransferRequest_1.TransferRequestStatusEnum.IN_TRANSIT, statusOrderObj);
|
|
1075
|
+
if (typeof inTransitPosition != 'number') {
|
|
1076
|
+
console.log('could not compare status since inTransitPosition was not found');
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
return (0, toNumber_1.default)(currentPosition) < (0, toNumber_1.default)(inTransitPosition);
|
|
1080
|
+
};
|
|
1081
|
+
TransferRequest.checkIfStatusCountsAsCompleted = function (statusToCheck) {
|
|
1082
|
+
return [
|
|
1083
|
+
TransferRequest_1.TransferRequestStatusEnum.RECEIVED,
|
|
1084
|
+
TransferRequest_1.TransferRequestStatusEnum.RECEIVED_PARTIAL,
|
|
1085
|
+
TransferRequest_1.TransferRequestStatusEnum.CANCELLED
|
|
1086
|
+
].includes(statusToCheck);
|
|
1087
|
+
};
|
|
1088
|
+
TransferRequest.transferAllowEditFromStore = function (data) {
|
|
1089
|
+
if (!!data.completed)
|
|
1090
|
+
return false;
|
|
1091
|
+
return !!data.id && [TransferRequest_1.TransferRequestStatusEnum.INITIATED].includes(data.status);
|
|
1092
|
+
};
|
|
1093
|
+
TransferRequest.transferAllowAddProductOnEdit = function (data) {
|
|
1094
|
+
if (!!data.completed)
|
|
1095
|
+
return false;
|
|
1096
|
+
return [TransferRequest_1.TransferRequestStatusEnum.INITIATED].includes(data.status);
|
|
1097
|
+
};
|
|
1098
|
+
TransferRequest.transferAllowProductDelete = function (data) {
|
|
1099
|
+
if (!!data.completed)
|
|
1100
|
+
return false;
|
|
1101
|
+
if (!!!data.id)
|
|
1102
|
+
return true;
|
|
1103
|
+
return [TransferRequest_1.TransferRequestStatusEnum.INITIATED].includes(data.status);
|
|
1104
|
+
};
|
|
1105
|
+
TransferRequest.transferAllowEditProductOnEdit = function (data) {
|
|
1106
|
+
if (!!data.completed)
|
|
1107
|
+
return false;
|
|
1108
|
+
return [
|
|
1109
|
+
TransferRequest_1.TransferRequestStatusEnum.INITIATED,
|
|
1110
|
+
TransferRequest_1.TransferRequestStatusEnum.OPEN,
|
|
1111
|
+
TransferRequest_1.TransferRequestStatusEnum.TO_BE_PREPARED
|
|
1112
|
+
].includes(data.status);
|
|
1113
|
+
};
|
|
1114
|
+
TransferRequest.transferShouldDisplayWeight = function (data) {
|
|
1115
|
+
return ![TransferRequest_1.TransferRequestStatusEnum.INITIATED].includes(data.status);
|
|
1116
|
+
};
|
|
1117
|
+
TransferRequest.transferAllowsIndependantProductUpdate = function (data) {
|
|
1118
|
+
if (!!data.completed)
|
|
1119
|
+
return false;
|
|
1120
|
+
var acceptedStatuses = [TransferRequest_1.TransferRequestStatusEnum.INITIATED, TransferRequest_1.TransferRequestStatusEnum.OPEN];
|
|
1121
|
+
if (!data.associated_order)
|
|
1122
|
+
acceptedStatuses.push(TransferRequest_1.TransferRequestStatusEnum.TO_BE_PREPARED);
|
|
1123
|
+
return acceptedStatuses.includes(data.status);
|
|
1124
|
+
};
|
|
1125
|
+
TransferRequest.getTotalWeight = function (products, unit) {
|
|
1126
|
+
if (unit === void 0) { unit = 'pounds'; }
|
|
1127
|
+
return (0, sumBy_1.default)(products, function (item) {
|
|
1128
|
+
if (!!!item.weight)
|
|
1129
|
+
return 0;
|
|
1130
|
+
var value = (0, toNumber_1.default)(item.weight.value) || 0;
|
|
1131
|
+
return item.weight.unit === unit ? value * item.qte : (0, weight_1.convertWeight)(value, item.weight.unit, unit) * item.qte;
|
|
1132
|
+
});
|
|
1133
|
+
};
|
|
1134
|
+
TransferRequest.getTotalPalletQte = function (items) {
|
|
1135
|
+
var total = (0, sumBy_1.default)(items.map(function (item) {
|
|
1136
|
+
if (!!!item.other_units || !!!item.count_in_pallet_total) {
|
|
1137
|
+
return 0;
|
|
1138
|
+
}
|
|
1139
|
+
var paletteUnit = item.other_units.find(function (u) { return u.unit_slug === 'pal'; });
|
|
1140
|
+
if (!!!paletteUnit || !!!paletteUnit.fitting_unit) {
|
|
1141
|
+
return 0;
|
|
1142
|
+
}
|
|
1143
|
+
return item.qte / paletteUnit.fitting_unit;
|
|
1144
|
+
}));
|
|
1145
|
+
return (0, ceil_1.default)(total);
|
|
1146
|
+
};
|
|
1147
|
+
return TransferRequest;
|
|
1148
|
+
}(baseService_1.BaseServiceClass));
|
|
1149
|
+
exports.TransferRequest = TransferRequest;
|
|
303
1150
|
//# sourceMappingURL=index.js.map
|