@evershop/evershop 1.1.0 → 1.2.1
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/bin/build/index.js +24 -0
- package/bin/extension/index.js +2 -2
- package/bin/lib/addDefaultMiddlewareFuncs.js +7 -2
- package/bin/lib/buildEntry.js +20 -2
- package/bin/lib/onListening.js +7 -4
- package/bin/lib/startUp.js +6 -0
- package/package.json +9 -1
- package/src/components/admin/catalog/productEdit/category/CategoryItem.jsx +2 -7
- package/src/components/admin/catalog/productEdit/category/CategoryTree.jsx +14 -7
- package/src/components/admin/catalog/productEdit/category/CategoryTree.scss +10 -0
- package/src/components/admin/catalog/productEdit/variants/CreateVariant.jsx +2 -2
- package/src/components/admin/catalog/productEdit/variants/CreateVariantGroup.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/EditVariant.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/New.jsx +2 -2
- package/src/components/admin/catalog/productEdit/variants/Search.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/SearchModal.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/VariantModal.jsx +6 -6
- package/src/components/admin/catalog/productGrid/rows/ThumbnailRow.jsx +1 -1
- package/src/components/admin/checkout/shippingSetting/Method.jsx +6 -6
- package/src/components/admin/checkout/shippingSetting/MethodForm.jsx +4 -4
- package/src/components/admin/checkout/shippingSetting/Methods.jsx +3 -3
- package/src/components/admin/checkout/shippingSetting/PriceBasedPrice.jsx +2 -2
- package/src/components/admin/checkout/shippingSetting/WeightBasedPrice.jsx +2 -2
- package/src/components/admin/checkout/shippingSetting/Zone.jsx +7 -7
- package/src/components/admin/checkout/shippingSetting/ZoneForm.jsx +1 -1
- package/src/components/admin/cms/Card.jsx +3 -3
- package/src/components/admin/cms/PageHeading.jsx +3 -3
- package/src/components/admin/cms/widget/WidgetTypes.jsx +28 -0
- package/src/components/admin/cms/widget/grid/WidgetTypeRow.jsx +29 -0
- package/src/components/admin/oms/orderEdit/items/ItemVariantOptions.jsx +1 -1
- package/src/components/admin/oms/orderEdit/items/Name.jsx +1 -1
- package/src/components/admin/oms/orderGrid/headers/OrderDateColumnHeader.jsx +1 -1
- package/src/components/admin/promotion/couponEdit/AttributeGroupSelector.jsx +3 -3
- package/src/components/admin/promotion/couponEdit/BuyXGetY.jsx +2 -2
- package/src/components/admin/promotion/couponEdit/CategorySelector.jsx +6 -6
- package/src/components/admin/promotion/couponEdit/CollectionSelector.jsx +3 -3
- package/src/components/admin/promotion/couponEdit/ProductSkuSelector.jsx +4 -4
- package/src/components/admin/promotion/couponEdit/RequireProducts.jsx +2 -2
- package/src/components/admin/promotion/couponEdit/Setting.jsx +1 -1
- package/src/components/admin/promotion/couponEdit/TargetProducts.jsx +4 -4
- package/src/components/admin/tax/taxSetting/Rate.jsx +6 -6
- package/src/components/admin/tax/taxSetting/RateForm.jsx +5 -5
- package/src/components/admin/tax/taxSetting/Rates.jsx +6 -6
- package/src/components/admin/tax/taxSetting/TaxClass.jsx +3 -3
- package/src/components/admin/tax/taxSetting/TaxClassForm.jsx +1 -1
- package/src/components/admin/widgets/BasicMenuSetting.jsx +614 -0
- package/src/components/admin/widgets/BasicMenuSetting.scss +19 -0
- package/src/components/admin/widgets/CollectionProductsSetting.jsx +203 -0
- package/src/components/admin/widgets/TextBlockSetting.jsx +70 -0
- package/src/components/common/Area.jsx +31 -8
- package/src/components/common/Badge.jsx +1 -1
- package/src/components/common/Editor.jsx +193 -0
- package/src/components/common/Notification.scss +1 -0
- package/src/components/common/SimplePagination.jsx +2 -2
- package/src/components/common/form/Form.jsx +1 -1
- package/src/components/common/form/fields/Checkbox.jsx +1 -1
- package/src/components/common/form/fields/Ckeditor.jsx +11 -11
- package/src/components/common/form/fields/Editor.jsx +326 -0
- package/src/components/common/form/fields/Editor.scss +33 -0
- package/src/components/common/form/fields/Radio.jsx +1 -1
- package/src/components/common/form/fields/editor/FileBrowser.jsx +419 -0
- package/src/components/common/form/fields/editor/FileBrowser.scss +37 -0
- package/src/components/common/form/fields/editor/GetColumnClasses.jsx +14 -0
- package/src/components/common/form/fields/editor/GetRowClasses.jsx +18 -0
- package/src/components/common/form/fields/editor/RowTemplates.jsx +154 -0
- package/src/components/common/grid/Pagination.jsx +4 -4
- package/src/components/common/grid/headers/FromTo.jsx +1 -1
- package/src/components/common/grid/headers/Sortable.jsx +1 -1
- package/src/components/common/grid/rows/ThumbnailRow.jsx +1 -1
- package/src/components/common/list/Filter.jsx +1 -1
- package/src/components/common/modal/Alert.jsx +1 -1
- package/src/components/common/modal/Modal.jsx +1 -1
- package/src/components/frontStore/catalog/categoryView/filter/AttributeFilter.jsx +2 -2
- package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.jsx +3 -2
- package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.scss +5 -0
- package/src/components/frontStore/catalog/product/list/List.jsx +4 -4
- package/src/components/frontStore/catalog/product/list/Pagination.jsx +1 -1
- package/src/components/frontStore/catalog/product/list/Sorting.jsx +2 -2
- package/src/components/frontStore/catalog/product/list/item/Name.jsx +1 -1
- package/src/components/frontStore/checkout/cart/Empty.jsx +3 -3
- package/src/components/frontStore/checkout/cart/items/ItemOptions.jsx +1 -1
- package/src/components/frontStore/checkout/cart/items/ItemVariantOptions.jsx +1 -1
- package/src/components/frontStore/checkout/cart/items/Items.jsx +20 -21
- package/src/components/frontStore/checkout/cart/items/Items.scss +47 -0
- package/src/components/frontStore/checkout/cart/items/Quantity.jsx +154 -0
- package/src/components/frontStore/checkout/checkout/StepTitle.jsx +1 -1
- package/src/components/frontStore/checkout/checkout/payment/paymentStep/StepContent.jsx +5 -5
- package/src/components/frontStore/checkout/checkout/shipment/StepContent.jsx +1 -1
- package/src/components/frontStore/checkout/checkout/summary/Cart.jsx +10 -12
- package/src/components/frontStore/checkout/checkout/summary/Items.jsx +9 -9
- package/src/components/frontStore/checkout/checkout/summary/cart/Total.jsx +6 -6
- package/src/components/frontStore/checkout/success/summary/items/ItemOptions.jsx +1 -1
- package/src/components/frontStore/checkout/success/summary/items/Items.jsx +9 -6
- package/src/components/frontStore/checkout/success/summary/order/OrderSummary.jsx +9 -13
- package/src/components/frontStore/checkout/success/summary/order/Total.jsx +5 -5
- package/src/components/frontStore/customer/address/addressForm/AddressFormLoadingSkeleton.jsx +2 -2
- package/src/components/frontStore/customer/address/addressForm/NameAndTelephone.jsx +1 -1
- package/src/components/frontStore/customer/address/addressForm/ProvinceAndPostcode.jsx +1 -1
- package/src/components/frontStore/customer/checkout/Edit.jsx +2 -2
- package/src/components/frontStore/customer/detail/Order.jsx +4 -4
- package/src/components/frontStore/stripe/checkout/CheckoutForm.jsx +2 -2
- package/src/components/frontStore/stripe/checkout/TestCards.jsx +1 -1
- package/src/components/frontStore/widgets/BasicMenu.jsx +129 -0
- package/src/{modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx → components/frontStore/widgets/CollectionProducts.jsx} +40 -32
- package/src/components/frontStore/widgets/TextBlock.jsx +46 -0
- package/src/lib/componee/getComponentsByRoute.js +15 -2
- package/src/lib/event/event-manager.js +1 -1
- package/src/lib/middleware/tests/app/modules/404page/pages/frontStore/product/route.json +2 -1
- package/src/lib/middlewares/static.js +3 -1
- package/src/lib/response/render.js +5 -6
- package/src/lib/router/Router.js +1 -1
- package/src/lib/router/loadModuleRoutes.js +3 -0
- package/src/lib/router/registerAdminRoute.js +9 -1
- package/src/lib/router/registerFrontStoreRoute.js +2 -0
- package/src/lib/router/scanForRoutes.js +1 -0
- package/src/lib/router/tests/unit/unit.validateRoute.test.js +7 -1
- package/src/lib/util/defaultPaginationFilters.js +19 -17
- package/src/lib/util/getEnabledWidgets.js +34 -0
- package/src/lib/util/merge.js +67 -14
- package/src/lib/util/tests/unit/util.merge.test.js +21 -4
- package/src/lib/util/validateConfiguration.js +83 -0
- package/src/lib/webpack/createBaseConfig.js +4 -1
- package/src/lib/webpack/dev/createConfigClient.js +10 -2
- package/src/lib/webpack/loaders/AreaLoader.js +16 -6
- package/src/lib/webpack/util/keyGenerator.js +9 -0
- package/src/lib/webpack/util/parseGraphql.js +30 -16
- package/src/lib/webpack/util/parseGraphqlByFile.js +16 -2
- package/src/modules/auth/pages/admin/adminLogin/LoginForm.jsx +54 -21
- package/src/modules/auth/pages/admin/all/AdminUser.jsx +3 -3
- package/src/modules/base/bootstrap.js +79 -0
- package/src/modules/base/graphql/types/Route/Route.admin.graphql +15 -0
- package/src/modules/base/graphql/types/Route/Route.admin.resolvers.js +10 -0
- package/src/modules/base/pages/global/response[errorHandler].js +25 -1
- package/src/modules/catalog/bootstrap.js +125 -5
- package/src/modules/catalog/graphql/types/Category/Category.graphql +4 -3
- package/src/modules/catalog/graphql/types/Category/Category.resolvers.js +34 -0
- package/src/modules/catalog/graphql/types/Collection/Collection.graphql +2 -2
- package/src/modules/catalog/graphql/types/Collection/Collection.resolvers.js +34 -0
- package/src/modules/catalog/graphql/types/Product/Attribute/ProductAttribute.resolvers.js +1 -0
- package/src/modules/catalog/graphql/types/Product/Product.graphql +1 -1
- package/src/modules/catalog/graphql/types/Product/Product.resolvers.js +34 -0
- package/src/modules/catalog/graphql/types/Widget/CollectionProductsWidget/CollectionProductsWidget.graphql +11 -0
- package/src/modules/catalog/graphql/types/Widget/CollectionProductsWidget/CollectionProductsWidget.resolvers.js +8 -0
- package/src/modules/catalog/migration/Version-1.0.0.js +1 -0
- package/src/modules/catalog/migration/Version-1.0.7.js +10 -0
- package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/FormContent.jsx +4 -4
- package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/General.jsx +5 -5
- package/src/modules/catalog/pages/admin/attributeGrid/Grid.jsx +2 -2
- package/src/modules/catalog/pages/admin/categoryEdit/Products.jsx +4 -4
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/FormContent.jsx +4 -4
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/General.jsx +16 -18
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/Image.jsx +1 -2
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/Status.jsx +16 -1
- package/src/modules/catalog/pages/admin/categoryGrid/Grid.jsx +3 -3
- package/src/modules/catalog/pages/admin/collectionEdit/Products.jsx +4 -4
- package/src/modules/catalog/pages/admin/collectionEdit+collectionNew/FormContent.jsx +2 -2
- package/src/modules/catalog/pages/admin/collectionEdit+collectionNew/General.jsx +2 -2
- package/src/modules/catalog/pages/admin/collectionGrid/Grid.jsx +3 -3
- package/src/modules/catalog/pages/admin/productEdit/Collection.jsx +7 -7
- package/src/modules/catalog/pages/admin/productEdit+productNew/Attributes.jsx +8 -3
- package/src/modules/catalog/pages/admin/productEdit+productNew/CustomOptions.jsss +4 -4
- package/src/modules/catalog/pages/admin/productEdit+productNew/FormContent.jsx +4 -4
- package/src/modules/catalog/pages/admin/productEdit+productNew/General.jsx +15 -17
- package/src/modules/catalog/pages/admin/productGrid/Grid.jsx +3 -3
- package/src/modules/catalog/pages/frontStore/catalogSearch/General.jsx +2 -2
- package/src/modules/catalog/pages/frontStore/catalogSearch/Products.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/catalogSearch/route.json +2 -1
- package/src/modules/catalog/pages/frontStore/categoryView/CategoryView.jsx +19 -2
- package/src/modules/catalog/pages/frontStore/categoryView/Filter.scss +1 -0
- package/src/modules/catalog/pages/frontStore/categoryView/General.jsx +6 -8
- package/src/modules/catalog/pages/frontStore/categoryView/General.scss +0 -2
- package/src/modules/catalog/pages/frontStore/categoryView/Pagination.jsx +6 -0
- package/src/modules/catalog/pages/frontStore/categoryView/Products.jsx +8 -1
- package/src/modules/catalog/pages/frontStore/categoryView/route.json +2 -1
- package/src/modules/catalog/pages/frontStore/productView/Description.jsx +15 -4
- package/src/modules/catalog/pages/frontStore/productView/Form.jsx +4 -4
- package/src/modules/catalog/pages/frontStore/productView/Form.scss +1 -0
- package/src/modules/catalog/pages/frontStore/productView/GeneralInfo.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Images.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Layout.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Options.jsx +7 -3
- package/src/modules/catalog/pages/frontStore/productView/Variants.jsx +6 -6
- package/src/modules/catalog/pages/frontStore/productView/route.json +2 -1
- package/src/modules/catalog/services/AttributeCollection.js +10 -10
- package/src/modules/catalog/services/AttributeGroupCollection.js +10 -10
- package/src/modules/catalog/services/CategoryCollection.js +10 -10
- package/src/modules/catalog/services/CollectionCollection.js +10 -10
- package/src/modules/catalog/services/registerCartItemProductUrlField.js +35 -0
- package/src/modules/catalog/services/registerCartItemVariantOptionsField.js +51 -0
- package/src/modules/catalog/services/registerDefaultCategoryCollectionFilters.js +16 -0
- package/src/modules/checkout/api/addShippingNote/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/addShippingNote/payloadSchema.json +15 -0
- package/src/modules/checkout/api/addShippingNote/route.json +5 -0
- package/src/modules/checkout/api/addShippingNote/saveShippingNote.js +50 -0
- package/src/modules/checkout/api/createCart/createNewCart.js +28 -3
- package/src/modules/checkout/api/updateCartItemQty/[bodyParser]updateQty.js +49 -0
- package/src/modules/checkout/api/updateCartItemQty/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/updateCartItemQty/payloadSchema.json +21 -0
- package/src/modules/checkout/api/updateCartItemQty/route.json +5 -0
- package/src/modules/checkout/api/updateMineCartItemQty/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/updateMineCartItemQty/[detectCurrentCart]updateQty.js +51 -0
- package/src/modules/checkout/api/updateMineCartItemQty/[getCurrentCustomer]detectCurrentCart.js +32 -0
- package/src/modules/checkout/api/updateMineCartItemQty/payloadSchema.json +21 -0
- package/src/modules/checkout/api/updateMineCartItemQty/route.json +5 -0
- package/src/modules/checkout/bootstrap.js +27 -0
- package/src/modules/checkout/graphql/types/Cart/Cart.graphql +22 -3
- package/src/modules/checkout/graphql/types/Cart/Cart.resolvers.js +18 -2
- package/src/modules/checkout/graphql/types/CheckoutSetting/CheckoutSetting.graphql +3 -0
- package/src/modules/checkout/graphql/types/CheckoutSetting/CheckoutSetting.resolvers.js +7 -0
- package/src/modules/checkout/migration/Version-1.0.0.js +14 -0
- package/src/modules/checkout/migration/Version-1.0.6.js +201 -0
- package/src/modules/checkout/pages/admin/shippingSetting/ShippingSetting.jsx +2 -2
- package/src/modules/checkout/pages/frontStore/all/[context]detectCurrentCart[auth].js +5 -0
- package/src/modules/checkout/pages/frontStore/cart/ShoppingCart.jsx +20 -12
- package/src/modules/checkout/pages/frontStore/cart/Summary.jsx +34 -23
- package/src/modules/checkout/pages/frontStore/cart/route.json +2 -1
- package/src/modules/checkout/pages/frontStore/checkout/Checkout.jsx +5 -5
- package/src/modules/checkout/pages/frontStore/checkout/Checkout.scss +4 -0
- package/src/modules/checkout/pages/frontStore/checkout/ShippingMethods.jsx +2 -2
- package/src/modules/checkout/pages/frontStore/checkout/ShippingNote.jsx +105 -0
- package/src/modules/checkout/pages/frontStore/checkout/Summary.jsx +14 -14
- package/src/modules/checkout/pages/frontStore/checkout/SummaryMobile.jsx +12 -15
- package/src/modules/checkout/pages/frontStore/checkout/route.json +2 -1
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/CheckoutSuccess.jsx +1 -1
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/CheckoutSuccess.scss +4 -0
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/CustomerInfo.jsx +30 -32
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/ShippingNote.jsx +47 -0
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/Summary.jsx +12 -15
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/route.json +2 -1
- package/src/modules/checkout/services/cart/Cart.js +31 -27
- package/src/modules/checkout/services/cart/registerCartBaseFields.js +133 -41
- package/src/modules/checkout/services/cart/registerCartItemBaseFields.js +300 -374
- package/src/modules/checkout/services/toPrice.js +1 -1
- package/src/modules/checkout/tests/basicSetup.js +85 -0
- package/src/modules/checkout/tests/coupons.js +82 -0
- package/src/modules/checkout/tests/products.js +67 -0
- package/src/modules/checkout/tests/taxRates.js +3 -0
- package/src/modules/checkout/tests/unit/discountAmount.test.js +60 -0
- package/src/modules/checkout/tests/unit/grandTotal.test.js +83 -0
- package/src/modules/checkout/tests/unit/lineTotal.test.js +92 -0
- package/src/modules/checkout/tests/unit/lineTotalWithDiscount.test.js +103 -0
- package/src/modules/checkout/tests/unit/productPrice.test.js +69 -0
- package/src/modules/checkout/tests/unit/subTotal.test.js +85 -0
- package/src/modules/checkout/tests/unit/subTotalWithDiscount.test.js +117 -0
- package/src/modules/checkout/tests/unit/taxAmount.test.js +68 -0
- package/src/modules/checkout/tests/unit/taxAmountRounding.test.js +277 -0
- package/src/modules/cms/api/createWidget/[context]bodyParser[auth].js +5 -0
- package/src/modules/cms/api/createWidget/createWidget[finish].js +17 -0
- package/src/modules/cms/api/createWidget/finish[apiResponse].js +27 -0
- package/src/modules/cms/api/createWidget/payloadSchema.json +18 -0
- package/src/modules/cms/api/createWidget/route.json +5 -0
- package/src/modules/cms/api/deleteWidget/deleteWidget.js +27 -0
- package/src/modules/cms/api/deleteWidget/route.json +5 -0
- package/src/modules/cms/api/updateWidget/[context]bodyParser[auth].js +5 -0
- package/src/modules/cms/api/updateWidget/finish[apiResponse].js +27 -0
- package/src/modules/cms/api/updateWidget/payloadSchema.json +18 -0
- package/src/modules/cms/api/updateWidget/route.json +5 -0
- package/src/modules/cms/api/updateWidget/updateWidget[finish].js +17 -0
- package/src/modules/cms/bootstrap.js +223 -3
- package/src/modules/cms/graphql/types/CmsPage/CmsPage.graphql +1 -2
- package/src/modules/cms/graphql/types/CmsPage/CmsPage.resolvers.js +35 -1
- package/src/modules/cms/graphql/types/Widget/Widget.graphql +91 -0
- package/src/modules/cms/graphql/types/Widget/Widget.resolvers.js +142 -0
- package/src/modules/cms/migration/Version-1.1.0.js +22 -0
- package/src/modules/cms/migration/Version-1.1.1.js +103 -0
- package/src/modules/cms/pages/admin/adminNotFound/NotFound.jsx +4 -4
- package/src/modules/cms/pages/admin/all/CmsMenuGroup.jsx +12 -4
- package/src/modules/cms/pages/admin/all/Notification.scss +1 -1
- package/src/modules/cms/pages/admin/all/search/NoResult.jsx +2 -2
- package/src/modules/cms/pages/admin/all/search/Results.jsx +3 -3
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/FormContent.jsx +7 -9
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/General.jsx +3 -3
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/Seo.jsx +1 -1
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/Status.jsx +40 -0
- package/src/modules/cms/pages/admin/cmsPageGrid/Grid.jsx +3 -4
- package/src/modules/cms/pages/admin/dashboard/Layout.jsx +3 -3
- package/src/modules/cms/pages/admin/widgetEdit/WidgetForm.jsx +52 -0
- package/src/modules/cms/pages/admin/widgetEdit/index.js +36 -0
- package/src/modules/cms/pages/admin/widgetEdit/route.json +4 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/FormContent.jsx +69 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/FormContent.scss +7 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/General.jsx +185 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/PageHeading.jsx +37 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/Setting.jsx +55 -0
- package/src/modules/cms/pages/admin/widgetGrid/Grid.jsx +415 -0
- package/src/modules/cms/pages/admin/widgetGrid/Heading.jsx +11 -0
- package/src/modules/cms/pages/admin/widgetGrid/NewWidgetButton.jsx +52 -0
- package/src/modules/cms/pages/admin/widgetGrid/index.js +15 -0
- package/src/modules/cms/pages/admin/widgetGrid/route.json +4 -0
- package/src/modules/cms/pages/admin/widgetNew/WidgetNewForm.jsx +60 -0
- package/src/modules/cms/pages/admin/widgetNew/index.js +11 -0
- package/src/modules/cms/pages/admin/widgetNew/route.json +4 -0
- package/src/modules/cms/pages/admin/widgetNew/typeValidate.js +21 -0
- package/src/modules/cms/pages/frontStore/all/Breadcrumb.jsx +1 -1
- package/src/modules/cms/pages/frontStore/all/Footer.jsx +2 -2
- package/src/modules/cms/pages/frontStore/all/Layout.jsx +3 -3
- package/src/modules/cms/pages/frontStore/all/Layout.scss +13 -0
- package/src/modules/cms/pages/frontStore/all/Logo.jsx +2 -2
- package/src/modules/cms/pages/frontStore/all/Logo.scss +2 -4
- package/src/modules/cms/pages/frontStore/all/Notification.scss +1 -1
- package/src/modules/cms/pages/frontStore/cmsPageView/Layout.jsx +2 -2
- package/src/modules/cms/pages/frontStore/cmsPageView/View.jsx +5 -3
- package/src/modules/cms/pages/frontStore/cmsPageView/index.js +6 -12
- package/src/modules/cms/pages/frontStore/cmsPageView/route.json +2 -1
- package/src/modules/cms/pages/frontStore/homepage/route.json +2 -1
- package/src/modules/cms/pages/frontStore/notFound/NotFound.jsx +4 -4
- package/src/modules/cms/pages/frontStore/notFound/route.json +2 -1
- package/src/modules/cms/pages/frontStore/staticAsset/[context]staticAssets[auth].js +1 -1
- package/src/modules/cms/services/CMSPageCollection.js +10 -10
- package/src/modules/cms/services/WidgetCollection.js +62 -0
- package/src/modules/cms/services/getWidgetsBaseQuery.js +7 -0
- package/src/modules/cms/services/page/createPage.js +1 -2
- package/src/modules/cms/services/page/pageDataSchema.json +0 -4
- package/src/modules/cms/services/registerDefaultWidgetCollectionFilters.js +62 -0
- package/src/modules/cms/services/tailwind.admin.config.js +22 -107
- package/src/modules/cms/services/tailwind.frontStore.config.js +23 -108
- package/src/modules/cms/services/widget/createWidget.js +73 -0
- package/src/modules/cms/services/widget/deleteWidget.js +49 -0
- package/src/modules/cms/services/widget/loadWidgetInstances.js +54 -0
- package/src/modules/cms/services/widget/updateWidget.js +86 -0
- package/src/modules/cms/services/widget/widgetDataSchema.json +29 -0
- package/src/modules/cod/pages/admin/paymentSetting/CODSetting.jsx +2 -2
- package/src/modules/cod/pages/frontStore/checkout/CashOnDelivery.jsx +1 -1
- package/src/modules/customer/bootstrap.js +21 -4
- package/src/modules/customer/pages/admin/customerEdit/CustomerEditForm.jsx +3 -3
- package/src/modules/customer/pages/admin/customerEdit+customerNew/OrderHistory.jsx +1 -1
- package/src/modules/customer/pages/admin/customerGrid/Grid.jsx +3 -3
- package/src/modules/customer/pages/frontStore/account/AccountDetails.jsx +3 -3
- package/src/modules/customer/pages/frontStore/account/Layout.jsx +3 -3
- package/src/modules/customer/pages/frontStore/account/OrderHistory.jsx +1 -1
- package/src/modules/customer/pages/frontStore/account/route.json +2 -1
- package/src/modules/customer/pages/frontStore/login/LoginForm.jsx +2 -2
- package/src/modules/customer/pages/frontStore/login/route.json +2 -1
- package/src/modules/customer/pages/frontStore/register/RegisterForm.jsx +2 -2
- package/src/modules/customer/pages/frontStore/register/route.json +2 -1
- package/src/modules/customer/pages/frontStore/resetPasswordPage/ResetPasswordForm.jsx +2 -2
- package/src/modules/customer/pages/frontStore/resetPasswordPage/route.json +2 -1
- package/src/modules/customer/pages/frontStore/updatePasswordPage/UpdatePasswordForm.jsx +3 -3
- package/src/modules/customer/pages/frontStore/updatePasswordPage/route.json +2 -1
- package/src/modules/customer/services/CustomerCollection.js +10 -10
- package/src/modules/customer/services/CustomerGroupCollection.js +10 -10
- package/src/modules/graphql/pages/global/[bodyParser]buildQuery[graphql].js +241 -6
- package/src/modules/graphql/pages/global/[buildQuery]graphql[notification].js +12 -8
- package/src/modules/oms/bootstrap.js +87 -3
- package/src/modules/oms/graphql/types/Order/Order.graphql +11 -2
- package/src/modules/oms/graphql/types/Order/Order.resolvers.js +7 -1
- package/src/modules/oms/pages/admin/dashboard/Bestsellers.jsx +2 -2
- package/src/modules/oms/pages/admin/dashboard/Lifetimesales.jsx +5 -5
- package/src/modules/oms/pages/admin/orderEdit/AddTrackingButton.jsx +1 -1
- package/src/modules/oms/pages/admin/orderEdit/Items.jsx +7 -7
- package/src/modules/oms/pages/admin/orderEdit/Layout.jsx +3 -3
- package/src/modules/oms/pages/admin/orderEdit/Payment.jsx +6 -6
- package/src/modules/oms/pages/admin/orderEdit/ShipButton.jsx +1 -1
- package/src/modules/oms/pages/admin/orderGrid/Grid.jsx +3 -3
- package/src/modules/oms/services/OrderCollection.js +10 -10
- package/src/modules/paypal/api/paypalCreateOrder/[bodyParser]createOrder.js +55 -24
- package/src/modules/paypal/pages/admin/paymentSetting/PaypalSetting.jsx +6 -6
- package/src/modules/paypal/pages/frontStore/checkout/Paypal.jsx +3 -4
- package/src/modules/promotion/bootstrap.js +19 -101
- package/src/modules/promotion/pages/admin/couponEdit+couponNew/DiscountType.jsx +1 -1
- package/src/modules/promotion/pages/admin/couponEdit+couponNew/FormContent.jsx +5 -5
- package/src/modules/promotion/pages/admin/couponGrid/Grid.jsx +3 -3
- package/src/modules/promotion/pages/frontStore/cart/Coupon.jsx +2 -2
- package/src/modules/promotion/services/CouponCollection.js +10 -10
- package/src/modules/promotion/services/couponValidator.js +4 -7
- package/src/modules/promotion/services/discountCalculator.js +2 -7
- package/src/modules/promotion/services/registerCartItemPromotionFields.js +80 -0
- package/src/modules/promotion/services/registerCartPromotionFields.js +128 -0
- package/src/modules/promotion/services/registerDefaultCalculators.js +48 -20
- package/src/modules/promotion/services/registerDefaultValidators.js +16 -4
- package/src/modules/setting/pages/admin/paymentSetting/PaymentSetting.jsx +2 -2
- package/src/modules/setting/pages/admin/storeSetting/StoreSetting.jsx +98 -35
- package/src/modules/stripe/pages/admin/paymentSetting/StripePayment.jsx +5 -5
- package/src/modules/stripe/pages/frontStore/checkout/Stripe.jsx +1 -1
- package/src/modules/tax/bootstrap.js +40 -5
- package/src/modules/tax/graphql/types/Product/Price/ProductPrice.resolvers.js +6 -39
- package/src/modules/tax/graphql/types/TaxSetting/TaxSetting.graphql +1 -2
- package/src/modules/tax/graphql/types/TaxSetting/TaxSetting.resolvers.js +1 -8
- package/src/modules/tax/pages/admin/taxSetting/TaxSetting.jsx +4 -4
- package/src/modules/tax/services/TaxClassCollection.js +10 -10
- package/src/modules/tax/services/calculateTaxAmount.js +12 -9
- package/src/modules/tax/services/registerCartItemTaxPercentField.js +76 -0
- package/src/modules/auth/services/adminSessionMiddleware.js +0 -0
- package/src/modules/catalog/pages/frontStore/homepage/FeaturedCategories.jsx +0 -58
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/StatusAndLayout.jsx +0 -61
- package/src/modules/cms/pages/frontStore/all/Menu.jsx +0 -46
- package/src/modules/cms/pages/frontStore/all/Menu.scss +0 -7
- package/src/modules/cms/pages/frontStore/all/MobileMenu.jsx +0 -73
- package/src/modules/cms/pages/frontStore/all/MobileMenu.scss +0 -35
- package/src/modules/cms/pages/frontStore/homepage/MainBanner.jsx +0 -31
- package/src/modules/cms/pages/frontStore/homepage/MainBanner.scss +0 -48
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* eslint-disable no-undef, global-require */
|
|
2
|
+
process.env.ALLOW_CONFIG_MUTATIONS = 'true';
|
|
3
|
+
const config = require('config');
|
|
4
|
+
require('../basicSetup');
|
|
5
|
+
const { Cart } = require('../../services/cart/Cart');
|
|
6
|
+
// Default tax configuration
|
|
7
|
+
config.util.setModuleDefaults('pricing', {
|
|
8
|
+
tax: {
|
|
9
|
+
price_including_tax: false
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('Test sub total calculation', () => {
|
|
14
|
+
it('Sub total should equal to the sum of line total of all items when tax is not included', async () => {
|
|
15
|
+
const cart = new Cart({
|
|
16
|
+
status: 1
|
|
17
|
+
});
|
|
18
|
+
const priceConfig = config.get('pricing');
|
|
19
|
+
priceConfig.tax.price_including_tax = false;
|
|
20
|
+
const item = await cart.addItem(1, 1);
|
|
21
|
+
expect(cart.getData('sub_total')).toEqual(100);
|
|
22
|
+
const item2 = await cart.addItem(5, 1);
|
|
23
|
+
expect(cart.getData('sub_total')).toEqual(223.45);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('Sub total including tax should be calculated with tax amount added', async () => {
|
|
27
|
+
const cart = new Cart({
|
|
28
|
+
status: 1
|
|
29
|
+
});
|
|
30
|
+
const priceConfig = config.get('pricing');
|
|
31
|
+
priceConfig.tax.price_including_tax = false;
|
|
32
|
+
const item = await cart.addItem(1, 1);
|
|
33
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(110);
|
|
34
|
+
const item2 = await cart.addItem(5, 1);
|
|
35
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(242.4);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('Sub total should be calculated with tax amount deducted when tax is included', async () => {
|
|
39
|
+
const cart = new Cart({
|
|
40
|
+
status: 1
|
|
41
|
+
});
|
|
42
|
+
const priceConfig = config.get('pricing');
|
|
43
|
+
priceConfig.tax.price_including_tax = true;
|
|
44
|
+
const item = await cart.addItem(1, 1);
|
|
45
|
+
expect(cart.getData('sub_total')).toEqual(90.91);
|
|
46
|
+
const item2 = await cart.addItem(5, 1);
|
|
47
|
+
expect(cart.getData('sub_total')).toEqual(206.01);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('Sub total including tax should be equal to the sum of line total including tax of all items when tax is included', async () => {
|
|
51
|
+
const cart = new Cart({
|
|
52
|
+
status: 1
|
|
53
|
+
});
|
|
54
|
+
const priceConfig = config.get('pricing');
|
|
55
|
+
priceConfig.tax.price_including_tax = true;
|
|
56
|
+
const item = await cart.addItem(1, 1);
|
|
57
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(100);
|
|
58
|
+
const item2 = await cart.addItem(5, 1);
|
|
59
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(223.45);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('Sub total should not be affected by discount amount', async () => {
|
|
63
|
+
const cart = new Cart({
|
|
64
|
+
status: 1
|
|
65
|
+
});
|
|
66
|
+
const priceConfig = config.get('pricing');
|
|
67
|
+
priceConfig.tax.price_including_tax = false;
|
|
68
|
+
await cart.addItem(1, 1);
|
|
69
|
+
expect(cart.getData('sub_total')).toEqual(100);
|
|
70
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
71
|
+
expect(cart.getData('sub_total')).toEqual(100);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('Sub total including tax should not be affected by discount amount', async () => {
|
|
75
|
+
const cart = new Cart({
|
|
76
|
+
status: 1
|
|
77
|
+
});
|
|
78
|
+
const priceConfig = config.get('pricing');
|
|
79
|
+
priceConfig.tax.price_including_tax = false;
|
|
80
|
+
await cart.addItem(1, 1);
|
|
81
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(110);
|
|
82
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
83
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(110);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* eslint-disable no-undef, global-require */
|
|
2
|
+
process.env.ALLOW_CONFIG_MUTATIONS = 'true';
|
|
3
|
+
const config = require('config');
|
|
4
|
+
require('../basicSetup');
|
|
5
|
+
const { Cart } = require('../../services/cart/Cart');
|
|
6
|
+
// Default tax configuration
|
|
7
|
+
config.util.setModuleDefaults('pricing', {
|
|
8
|
+
tax: {
|
|
9
|
+
price_including_tax: false
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('Test sub total with discount calculation', () => {
|
|
14
|
+
it('Sub total with discount should equal to the sub total when discount is not applied', async () => {
|
|
15
|
+
const cart = new Cart({
|
|
16
|
+
status: 1
|
|
17
|
+
});
|
|
18
|
+
const priceConfig = config.get('pricing');
|
|
19
|
+
priceConfig.tax.price_including_tax = false;
|
|
20
|
+
const item = await cart.addItem(1, 1);
|
|
21
|
+
expect(cart.getData('sub_total')).toEqual(100);
|
|
22
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(100);
|
|
23
|
+
const item2 = await cart.addItem(5, 1);
|
|
24
|
+
expect(cart.getData('sub_total')).toEqual(223.45);
|
|
25
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(223.45);
|
|
26
|
+
|
|
27
|
+
priceConfig.tax.price_including_tax = true;
|
|
28
|
+
await item.build();
|
|
29
|
+
await item2.build();
|
|
30
|
+
await cart.build();
|
|
31
|
+
expect(cart.getData('sub_total')).toEqual(206.01);
|
|
32
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(206.01);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('Sub total with discount including tax should be equal to the sub total including tax when discount is not applied', async () => {
|
|
36
|
+
const cart = new Cart({
|
|
37
|
+
status: 1
|
|
38
|
+
});
|
|
39
|
+
const priceConfig = config.get('pricing');
|
|
40
|
+
priceConfig.tax.price_including_tax = false;
|
|
41
|
+
const item = await cart.addItem(1, 1);
|
|
42
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(110);
|
|
43
|
+
expect(cart.getData('sub_total_with_discount_incl_tax')).toEqual(110);
|
|
44
|
+
const item2 = await cart.addItem(5, 1);
|
|
45
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(242.4);
|
|
46
|
+
expect(cart.getData('sub_total_with_discount_incl_tax')).toEqual(242.4);
|
|
47
|
+
|
|
48
|
+
priceConfig.tax.price_including_tax = true;
|
|
49
|
+
await item.build();
|
|
50
|
+
await item2.build();
|
|
51
|
+
await cart.build();
|
|
52
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(223.45);
|
|
53
|
+
expect(cart.getData('sub_total_with_discount_incl_tax')).toEqual(223.45);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Sub total with discount should be calculated with discount amount deducted', async () => {
|
|
57
|
+
const cart = new Cart({
|
|
58
|
+
status: 1
|
|
59
|
+
});
|
|
60
|
+
const priceConfig = config.get('pricing');
|
|
61
|
+
priceConfig.tax.price_including_tax = false;
|
|
62
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
63
|
+
const item = await cart.addItem(1, 1);
|
|
64
|
+
expect(cart.getData('sub_total')).toEqual(100);
|
|
65
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(90);
|
|
66
|
+
const item2 = await cart.addItem(5, 1);
|
|
67
|
+
expect(cart.getData('sub_total')).toEqual(223.45);
|
|
68
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(201.1);
|
|
69
|
+
|
|
70
|
+
priceConfig.tax.price_including_tax = true;
|
|
71
|
+
await item.build();
|
|
72
|
+
await item2.build();
|
|
73
|
+
await cart.build();
|
|
74
|
+
expect(cart.getData('sub_total')).toEqual(206.01);
|
|
75
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(185.41);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('Sub total with discount including tax should be calculated with tax amount added', async () => {
|
|
79
|
+
const cart = new Cart({
|
|
80
|
+
status: 1
|
|
81
|
+
});
|
|
82
|
+
const priceConfig = config.get('pricing');
|
|
83
|
+
priceConfig.tax.price_including_tax = false;
|
|
84
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
85
|
+
const item = await cart.addItem(1, 1);
|
|
86
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(110);
|
|
87
|
+
expect(cart.getData('sub_total_with_discount_incl_tax')).toEqual(99);
|
|
88
|
+
const item2 = await cart.addItem(5, 1);
|
|
89
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(242.4);
|
|
90
|
+
expect(cart.getData('sub_total_with_discount_incl_tax')).toEqual(218.15);
|
|
91
|
+
|
|
92
|
+
priceConfig.tax.price_including_tax = true;
|
|
93
|
+
await item.build();
|
|
94
|
+
await item2.build();
|
|
95
|
+
await cart.build();
|
|
96
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(223.45);
|
|
97
|
+
expect(cart.getData('sub_total_with_discount_incl_tax')).toEqual(201.1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('Sub total with discount should be equal to the sum of line total with discount of all items when discount is not applied', async () => {
|
|
101
|
+
const cart = new Cart({
|
|
102
|
+
status: 1
|
|
103
|
+
});
|
|
104
|
+
const priceConfig = config.get('pricing');
|
|
105
|
+
priceConfig.tax.price_including_tax = false;
|
|
106
|
+
const item = await cart.addItem(1, 1);
|
|
107
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(100);
|
|
108
|
+
const item2 = await cart.addItem(5, 1);
|
|
109
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(223.45);
|
|
110
|
+
|
|
111
|
+
priceConfig.tax.price_including_tax = true;
|
|
112
|
+
await item.build();
|
|
113
|
+
await item2.build();
|
|
114
|
+
await cart.build();
|
|
115
|
+
expect(cart.getData('sub_total_with_discount')).toEqual(206.01);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable no-undef, global-require */
|
|
2
|
+
process.env.ALLOW_CONFIG_MUTATIONS = 'true';
|
|
3
|
+
const config = require('config');
|
|
4
|
+
require('../basicSetup');
|
|
5
|
+
const { Cart } = require('../../services/cart/Cart');
|
|
6
|
+
// Default tax configuration
|
|
7
|
+
config.util.setModuleDefaults('pricing', {
|
|
8
|
+
tax: {
|
|
9
|
+
price_including_tax: false
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('Test tax amount calculation', () => {
|
|
14
|
+
it('Tax amount should be calculated correctly when tax is not included', async () => {
|
|
15
|
+
const cart = new Cart({
|
|
16
|
+
status: 1
|
|
17
|
+
});
|
|
18
|
+
const priceConfig = config.get('pricing');
|
|
19
|
+
priceConfig.tax.price_including_tax = false;
|
|
20
|
+
const item = await cart.addItem(1, 1);
|
|
21
|
+
expect(item.getData('tax_amount')).toEqual(10);
|
|
22
|
+
const item2 = await cart.addItem(2, 2);
|
|
23
|
+
expect(item2.getData('tax_amount')).toEqual(40);
|
|
24
|
+
const noTaxItem = await cart.addItem(4, 1);
|
|
25
|
+
expect(noTaxItem.getData('tax_amount')).toEqual(0);
|
|
26
|
+
expect(cart.getData('tax_amount')).toEqual(50);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('Tax amount should be calculated correctly when tax is included', async () => {
|
|
30
|
+
const cart = new Cart({
|
|
31
|
+
status: 1
|
|
32
|
+
});
|
|
33
|
+
const priceConfig = config.get('pricing');
|
|
34
|
+
priceConfig.tax.price_including_tax = true;
|
|
35
|
+
const item = await cart.addItem(1, 1);
|
|
36
|
+
expect(item.getData('tax_amount')).toEqual(9.09);
|
|
37
|
+
const item2 = await cart.addItem(2, 2);
|
|
38
|
+
expect(item2.getData('tax_amount')).toEqual(36.36);
|
|
39
|
+
const noTaxItem = await cart.addItem(4, 1);
|
|
40
|
+
expect(noTaxItem.getData('tax_amount')).toEqual(0);
|
|
41
|
+
expect(cart.getData('tax_amount')).toEqual(45.45);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('Tax amount should be calculated correctly when tax is included and discount is applied', async () => {
|
|
45
|
+
const cart = new Cart({
|
|
46
|
+
status: 1
|
|
47
|
+
});
|
|
48
|
+
const priceConfig = config.get('pricing');
|
|
49
|
+
priceConfig.tax.price_including_tax = false;
|
|
50
|
+
priceConfig.tax.rounding = 'round';
|
|
51
|
+
priceConfig.tax.round_level = 'unit';
|
|
52
|
+
priceConfig.tax.precision = 2;
|
|
53
|
+
const item = await cart.addItem(1, 1);
|
|
54
|
+
expect(item.getData('tax_amount')).toEqual(10);
|
|
55
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
56
|
+
expect(cart.getData('tax_amount')).toEqual(9);
|
|
57
|
+
const item2 = await cart.addItem(2, 2);
|
|
58
|
+
expect(item2.getData('tax_amount')).toEqual(36);
|
|
59
|
+
await cart.build();
|
|
60
|
+
expect(cart.getData('tax_amount')).toEqual(45);
|
|
61
|
+
priceConfig.tax.price_including_tax = true;
|
|
62
|
+
await item.build();
|
|
63
|
+
await item2.build();
|
|
64
|
+
await cart.build();
|
|
65
|
+
expect(item.getData('tax_amount')).toEqual(8.18);
|
|
66
|
+
expect(item2.getData('tax_amount')).toEqual(32.72);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/* eslint-disable no-undef, global-require */
|
|
2
|
+
process.env.ALLOW_CONFIG_MUTATIONS = 'true';
|
|
3
|
+
const config = require('config');
|
|
4
|
+
require('../basicSetup');
|
|
5
|
+
const { Cart } = require('../../services/cart/Cart');
|
|
6
|
+
// Default tax configuration
|
|
7
|
+
config.util.setModuleDefaults('pricing', {
|
|
8
|
+
tax: {
|
|
9
|
+
rounding: 'round',
|
|
10
|
+
precision: 2,
|
|
11
|
+
round_level: 'unit',
|
|
12
|
+
price_including_tax: false
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('Test tax amount calculation rounding', () => {
|
|
17
|
+
it('Tax amount should be calculated correctly when tax is not included', async () => {
|
|
18
|
+
const cart = new Cart({
|
|
19
|
+
status: 1
|
|
20
|
+
});
|
|
21
|
+
const priceConfig = config.get('pricing');
|
|
22
|
+
// Round
|
|
23
|
+
/// Level: unit
|
|
24
|
+
priceConfig.tax.precision = 2;
|
|
25
|
+
priceConfig.tax.round_level = 'unit';
|
|
26
|
+
priceConfig.tax.price_including_tax = false;
|
|
27
|
+
const item = await cart.addItem(5, 1);
|
|
28
|
+
expect(item.getData('tax_amount')).toEqual(8.95);
|
|
29
|
+
await item.setData('qty', 2);
|
|
30
|
+
expect(item.getData('tax_amount')).toEqual(17.9);
|
|
31
|
+
await item.setData('qty', 3);
|
|
32
|
+
expect(item.getData('tax_amount')).toEqual(26.85);
|
|
33
|
+
const item2 = await cart.addItem(1, 2);
|
|
34
|
+
expect(item2.getData('tax_amount')).toEqual(20);
|
|
35
|
+
|
|
36
|
+
priceConfig.tax.precision = 1;
|
|
37
|
+
await item.setData('qty', 1);
|
|
38
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
39
|
+
await item.setData('qty', 2);
|
|
40
|
+
expect(item.getData('tax_amount')).toEqual(18);
|
|
41
|
+
await item.setData('qty', 3);
|
|
42
|
+
expect(item.getData('tax_amount')).toEqual(27);
|
|
43
|
+
|
|
44
|
+
priceConfig.tax.precision = 0;
|
|
45
|
+
await item.setData('qty', 1);
|
|
46
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
47
|
+
await item.setData('qty', 2);
|
|
48
|
+
expect(item.getData('tax_amount')).toEqual(18);
|
|
49
|
+
await item.setData('qty', 3);
|
|
50
|
+
expect(item.getData('tax_amount')).toEqual(27);
|
|
51
|
+
|
|
52
|
+
/// Level: line
|
|
53
|
+
priceConfig.tax.precision = 2;
|
|
54
|
+
priceConfig.tax.round_level = 'line';
|
|
55
|
+
await item.setData('qty', 1);
|
|
56
|
+
expect(item.getData('tax_amount')).toEqual(8.95);
|
|
57
|
+
await item.setData('qty', 2);
|
|
58
|
+
expect(item.getData('tax_amount')).toEqual(17.9);
|
|
59
|
+
await item.setData('qty', 3);
|
|
60
|
+
expect(item.getData('tax_amount')).toEqual(26.85);
|
|
61
|
+
|
|
62
|
+
priceConfig.tax.precision = 1;
|
|
63
|
+
await item.setData('qty', 1);
|
|
64
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
65
|
+
await item.setData('qty', 2);
|
|
66
|
+
expect(item.getData('tax_amount')).toEqual(17.9);
|
|
67
|
+
await item.setData('qty', 3);
|
|
68
|
+
expect(item.getData('tax_amount')).toEqual(26.9);
|
|
69
|
+
|
|
70
|
+
priceConfig.tax.precision = 0;
|
|
71
|
+
await item.setData('qty', 1);
|
|
72
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
73
|
+
await item.setData('qty', 2);
|
|
74
|
+
expect(item.getData('tax_amount')).toEqual(18);
|
|
75
|
+
await item.setData('qty', 3);
|
|
76
|
+
expect(item.getData('tax_amount')).toEqual(27);
|
|
77
|
+
|
|
78
|
+
/// Level: total
|
|
79
|
+
priceConfig.tax.round_level = 'total';
|
|
80
|
+
priceConfig.tax.precision = 2;
|
|
81
|
+
await item.setData('qty', 1);
|
|
82
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
83
|
+
await item.setData('qty', 2);
|
|
84
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
85
|
+
await item.setData('qty', 3);
|
|
86
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
87
|
+
|
|
88
|
+
priceConfig.tax.precision = 1;
|
|
89
|
+
await item.setData('qty', 1);
|
|
90
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
91
|
+
await item.setData('qty', 2);
|
|
92
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
93
|
+
await item.setData('qty', 3);
|
|
94
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
95
|
+
|
|
96
|
+
priceConfig.tax.precision = 0;
|
|
97
|
+
await item.setData('qty', 1);
|
|
98
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
99
|
+
await item.setData('qty', 2);
|
|
100
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
101
|
+
await item.setData('qty', 3);
|
|
102
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
103
|
+
|
|
104
|
+
// Ceil
|
|
105
|
+
/// Level: unit
|
|
106
|
+
priceConfig.tax.rounding = 'up';
|
|
107
|
+
priceConfig.tax.round_level = 'unit';
|
|
108
|
+
priceConfig.tax.precision = 2;
|
|
109
|
+
await item.setData('qty', 1);
|
|
110
|
+
expect(item.getData('tax_amount')).toEqual(8.96);
|
|
111
|
+
await item.setData('qty', 2);
|
|
112
|
+
expect(item.getData('tax_amount')).toEqual(17.92);
|
|
113
|
+
await item.setData('qty', 3);
|
|
114
|
+
expect(item.getData('tax_amount')).toEqual(26.88);
|
|
115
|
+
|
|
116
|
+
priceConfig.tax.precision = 1;
|
|
117
|
+
await item.setData('qty', 1);
|
|
118
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
119
|
+
await item.setData('qty', 2);
|
|
120
|
+
expect(item.getData('tax_amount')).toEqual(18);
|
|
121
|
+
await item.setData('qty', 3);
|
|
122
|
+
expect(item.getData('tax_amount')).toEqual(27);
|
|
123
|
+
|
|
124
|
+
priceConfig.tax.precision = 0;
|
|
125
|
+
await item.setData('qty', 1);
|
|
126
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
127
|
+
await item.setData('qty', 2);
|
|
128
|
+
expect(item.getData('tax_amount')).toEqual(18);
|
|
129
|
+
await item.setData('qty', 3);
|
|
130
|
+
expect(item.getData('tax_amount')).toEqual(27);
|
|
131
|
+
|
|
132
|
+
/// Level: line
|
|
133
|
+
priceConfig.tax.precision = 2;
|
|
134
|
+
priceConfig.tax.round_level = 'line';
|
|
135
|
+
await item.setData('qty', 1);
|
|
136
|
+
expect(item.getData('tax_amount')).toEqual(8.96);
|
|
137
|
+
await item.setData('qty', 2);
|
|
138
|
+
expect(item.getData('tax_amount')).toEqual(17.91);
|
|
139
|
+
await item.setData('qty', 3);
|
|
140
|
+
expect(item.getData('tax_amount')).toEqual(26.86);
|
|
141
|
+
|
|
142
|
+
priceConfig.tax.precision = 1;
|
|
143
|
+
await item.setData('qty', 1);
|
|
144
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
145
|
+
await item.setData('qty', 2);
|
|
146
|
+
expect(item.getData('tax_amount')).toEqual(18);
|
|
147
|
+
await item.setData('qty', 3);
|
|
148
|
+
expect(item.getData('tax_amount')).toEqual(26.9);
|
|
149
|
+
|
|
150
|
+
priceConfig.tax.precision = 0;
|
|
151
|
+
await item.setData('qty', 1);
|
|
152
|
+
expect(item.getData('tax_amount')).toEqual(9);
|
|
153
|
+
await item.setData('qty', 2);
|
|
154
|
+
expect(item.getData('tax_amount')).toEqual(18);
|
|
155
|
+
await item.setData('qty', 3);
|
|
156
|
+
expect(item.getData('tax_amount')).toEqual(27);
|
|
157
|
+
|
|
158
|
+
/// Level: total
|
|
159
|
+
priceConfig.tax.round_level = 'total';
|
|
160
|
+
priceConfig.tax.precision = 2;
|
|
161
|
+
await item.setData('qty', 1);
|
|
162
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
163
|
+
await item.setData('qty', 2);
|
|
164
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
165
|
+
await item.setData('qty', 3);
|
|
166
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
167
|
+
|
|
168
|
+
priceConfig.tax.precision = 1;
|
|
169
|
+
await item.setData('qty', 1);
|
|
170
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
171
|
+
await item.setData('qty', 2);
|
|
172
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
173
|
+
await item.setData('qty', 3);
|
|
174
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
175
|
+
|
|
176
|
+
priceConfig.tax.precision = 0;
|
|
177
|
+
await item.setData('qty', 1);
|
|
178
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
179
|
+
await item.setData('qty', 2);
|
|
180
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
181
|
+
await item.setData('qty', 3);
|
|
182
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
183
|
+
|
|
184
|
+
// Floor
|
|
185
|
+
/// Level: unit
|
|
186
|
+
priceConfig.tax.rounding = 'down';
|
|
187
|
+
priceConfig.tax.round_level = 'unit';
|
|
188
|
+
priceConfig.tax.precision = 2;
|
|
189
|
+
await item.setData('qty', 1);
|
|
190
|
+
expect(item.getData('tax_amount')).toEqual(8.95);
|
|
191
|
+
await item.setData('qty', 2);
|
|
192
|
+
expect(item.getData('tax_amount')).toEqual(17.9);
|
|
193
|
+
await item.setData('qty', 3);
|
|
194
|
+
expect(item.getData('tax_amount')).toEqual(26.85);
|
|
195
|
+
|
|
196
|
+
priceConfig.tax.precision = 1;
|
|
197
|
+
await item.setData('qty', 1);
|
|
198
|
+
expect(item.getData('tax_amount')).toEqual(8.9);
|
|
199
|
+
await item.setData('qty', 2);
|
|
200
|
+
expect(item.getData('tax_amount')).toEqual(17.8);
|
|
201
|
+
await item.setData('qty', 3);
|
|
202
|
+
expect(item.getData('tax_amount')).toEqual(26.7);
|
|
203
|
+
|
|
204
|
+
priceConfig.tax.precision = 0;
|
|
205
|
+
await item.setData('qty', 1);
|
|
206
|
+
expect(item.getData('tax_amount')).toEqual(8);
|
|
207
|
+
await item.setData('qty', 2);
|
|
208
|
+
expect(item.getData('tax_amount')).toEqual(16);
|
|
209
|
+
await item.setData('qty', 3);
|
|
210
|
+
expect(item.getData('tax_amount')).toEqual(24);
|
|
211
|
+
|
|
212
|
+
/// Level: line
|
|
213
|
+
priceConfig.tax.precision = 2;
|
|
214
|
+
priceConfig.tax.round_level = 'line';
|
|
215
|
+
await item.setData('qty', 1);
|
|
216
|
+
expect(item.getData('tax_amount')).toEqual(8.95);
|
|
217
|
+
await item.setData('qty', 2);
|
|
218
|
+
expect(item.getData('tax_amount')).toEqual(17.9);
|
|
219
|
+
await item.setData('qty', 3);
|
|
220
|
+
expect(item.getData('tax_amount')).toEqual(26.85);
|
|
221
|
+
|
|
222
|
+
priceConfig.tax.precision = 1;
|
|
223
|
+
await item.setData('qty', 1);
|
|
224
|
+
expect(item.getData('tax_amount')).toEqual(8.9);
|
|
225
|
+
await item.setData('qty', 2);
|
|
226
|
+
expect(item.getData('tax_amount')).toEqual(17.9);
|
|
227
|
+
await item.setData('qty', 3);
|
|
228
|
+
expect(item.getData('tax_amount')).toEqual(26.8);
|
|
229
|
+
|
|
230
|
+
priceConfig.tax.precision = 0;
|
|
231
|
+
await item.setData('qty', 1);
|
|
232
|
+
expect(item.getData('tax_amount')).toEqual(8);
|
|
233
|
+
await item.setData('qty', 2);
|
|
234
|
+
expect(item.getData('tax_amount')).toEqual(17);
|
|
235
|
+
await item.setData('qty', 3);
|
|
236
|
+
expect(item.getData('tax_amount')).toEqual(26);
|
|
237
|
+
|
|
238
|
+
/// Level: total
|
|
239
|
+
priceConfig.tax.round_level = 'total';
|
|
240
|
+
priceConfig.tax.precision = 2;
|
|
241
|
+
await item.setData('qty', 1);
|
|
242
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
243
|
+
await item.setData('qty', 2);
|
|
244
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
245
|
+
await item.setData('qty', 3);
|
|
246
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
247
|
+
|
|
248
|
+
priceConfig.tax.precision = 1;
|
|
249
|
+
await item.setData('qty', 1);
|
|
250
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
251
|
+
await item.setData('qty', 2);
|
|
252
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
253
|
+
await item.setData('qty', 3);
|
|
254
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
255
|
+
|
|
256
|
+
priceConfig.tax.precision = 0;
|
|
257
|
+
await item.setData('qty', 1);
|
|
258
|
+
expect(item.getData('tax_amount')).toEqual(8.950125);
|
|
259
|
+
await item.setData('qty', 2);
|
|
260
|
+
expect(item.getData('tax_amount')).toEqual(17.90025);
|
|
261
|
+
await item.setData('qty', 3);
|
|
262
|
+
expect(item.getData('tax_amount')).toEqual(26.850375);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// it('Tax amount should be calculated correctly when tax is included', async () => {
|
|
266
|
+
// const cart = new Cart({
|
|
267
|
+
// status: 1
|
|
268
|
+
// });
|
|
269
|
+
// const priceConfig = config.get('pricing');
|
|
270
|
+
// priceConfig.tax.price_including_tax = true;
|
|
271
|
+
// const item = await cart.addItem(5, 1);
|
|
272
|
+
// expect(item.getData('tax_amount')).toEqual(8.35);
|
|
273
|
+
// priceConfig.tax.precision = 1;
|
|
274
|
+
// await item.build();
|
|
275
|
+
// expect(item.getData('tax_amount')).toEqual(8.3);
|
|
276
|
+
// });
|
|
277
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const createWidget = require('../../services/widget/createWidget');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
module.exports = async (request, response, delegate) => {
|
|
5
|
+
const data = request.body;
|
|
6
|
+
if (!data.route || (data.route.length === 1 && data.route[0] === '')) {
|
|
7
|
+
data.route = [];
|
|
8
|
+
}
|
|
9
|
+
if (!data.area || (data.area.length === 1 && data.area[0] === '')) {
|
|
10
|
+
data.area = [];
|
|
11
|
+
}
|
|
12
|
+
const result = await createWidget(data, {
|
|
13
|
+
routeId: request.currentRoute.id
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
|
|
2
|
+
const { OK } = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
module.exports = async (request, response, delegate, next) => {
|
|
6
|
+
const widget = await delegate.createWidget;
|
|
7
|
+
response.status(OK);
|
|
8
|
+
response.json({
|
|
9
|
+
data: {
|
|
10
|
+
...widget,
|
|
11
|
+
links: [
|
|
12
|
+
{
|
|
13
|
+
rel: 'widgetGrid',
|
|
14
|
+
href: buildUrl('widgetGrid'),
|
|
15
|
+
action: 'GET',
|
|
16
|
+
types: ['text/xml']
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
rel: 'edit',
|
|
20
|
+
href: buildUrl('widgetEdit', { id: widget.uuid }),
|
|
21
|
+
action: 'GET',
|
|
22
|
+
types: ['text/xml']
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const {
|
|
2
|
+
OK,
|
|
3
|
+
INTERNAL_SERVER_ERROR
|
|
4
|
+
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
5
|
+
const deleteWidget = require('../../services/widget/deleteWidget');
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line no-unused-vars
|
|
8
|
+
module.exports = async (request, response, delegate, next) => {
|
|
9
|
+
try {
|
|
10
|
+
const { id } = request.params;
|
|
11
|
+
const widget = await deleteWidget(id, {
|
|
12
|
+
routeId: request.currentRoute.id
|
|
13
|
+
});
|
|
14
|
+
response.status(OK);
|
|
15
|
+
response.json({
|
|
16
|
+
data: widget
|
|
17
|
+
});
|
|
18
|
+
} catch (e) {
|
|
19
|
+
response.status(INTERNAL_SERVER_ERROR);
|
|
20
|
+
response.json({
|
|
21
|
+
error: {
|
|
22
|
+
status: INTERNAL_SERVER_ERROR,
|
|
23
|
+
message: e.message
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|