@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
|
@@ -10,7 +10,7 @@ exports.toPrice = function toPrice(value, forDisplay = false) {
|
|
|
10
10
|
}
|
|
11
11
|
const rounding = getConfig('pricing.rounding', 'round');
|
|
12
12
|
const precision = getConfig('pricing.precision', 2);
|
|
13
|
-
const precisionFix =
|
|
13
|
+
const precisionFix = 10**precision;
|
|
14
14
|
switch (rounding) {
|
|
15
15
|
case 'up':
|
|
16
16
|
price = Math.ceil(price * precisionFix) / precisionFix;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
process.env.ALLOW_CONFIG_MUTATIONS = true;
|
|
2
|
+
const {
|
|
3
|
+
addProcessor,
|
|
4
|
+
addFinalProcessor
|
|
5
|
+
} = require('@evershop/evershop/src/lib/util/registry');
|
|
6
|
+
const {
|
|
7
|
+
registerCartBaseFields
|
|
8
|
+
} = require('../services/cart/registerCartBaseFields');
|
|
9
|
+
const {
|
|
10
|
+
registerCartItemBaseFields
|
|
11
|
+
} = require('../services/cart/registerCartItemBaseFields');
|
|
12
|
+
const { sortFields } = require('../services/cart/sortFields');
|
|
13
|
+
const { products } = require('./products');
|
|
14
|
+
const { taxRates } = require('./taxRates');
|
|
15
|
+
const {
|
|
16
|
+
registerCartPromotionFields
|
|
17
|
+
} = require('../../promotion/services/registerCartPromotionFields');
|
|
18
|
+
const {
|
|
19
|
+
registerCartItemPromotionFields
|
|
20
|
+
} = require('../../promotion/services/registerCartItemPromotionFields');
|
|
21
|
+
const { coupons } = require('./coupons');
|
|
22
|
+
const {
|
|
23
|
+
registerDefaultValidators
|
|
24
|
+
} = require('../../promotion/services/registerDefaultValidators');
|
|
25
|
+
const {
|
|
26
|
+
registerDefaultCalculators
|
|
27
|
+
} = require('../../promotion/services/registerDefaultCalculators');
|
|
28
|
+
|
|
29
|
+
// Default tax configuration
|
|
30
|
+
addProcessor('cartFields', registerCartBaseFields, 0);
|
|
31
|
+
addProcessor('cartFields', registerCartPromotionFields, 0);
|
|
32
|
+
addProcessor('cartItemFields', registerCartItemBaseFields, 0);
|
|
33
|
+
addProcessor('cartItemFields', registerCartItemPromotionFields, 0);
|
|
34
|
+
addProcessor(
|
|
35
|
+
'cartItemFields',
|
|
36
|
+
(fields) => {
|
|
37
|
+
fields.push({
|
|
38
|
+
key: 'tax_percent',
|
|
39
|
+
resolvers: [
|
|
40
|
+
function resolver() {
|
|
41
|
+
const classId = this.getData('tax_class_id');
|
|
42
|
+
return taxRates[classId] || 0;
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
dependencies: ['tax_class_id']
|
|
46
|
+
});
|
|
47
|
+
return fields;
|
|
48
|
+
},
|
|
49
|
+
0
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
addFinalProcessor('cartFields', (fields) => {
|
|
53
|
+
try {
|
|
54
|
+
const sortedFields = sortFields(fields);
|
|
55
|
+
return sortedFields;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
error(e);
|
|
58
|
+
throw e;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
addFinalProcessor('cartItemFields', (fields) => {
|
|
63
|
+
try {
|
|
64
|
+
const sortedFields = sortFields(fields);
|
|
65
|
+
return sortedFields;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
error(e);
|
|
68
|
+
throw e;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
addProcessor('cartItemProductLoaderFunction', () => {
|
|
73
|
+
return (id) => {
|
|
74
|
+
return products.find((product) => product.product_id === id);
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
addProcessor('couponLoaderFunction', () => {
|
|
79
|
+
return (code) => {
|
|
80
|
+
return coupons.find((coupon) => coupon.coupon === code);
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
addProcessor('couponValidatorFunctions', registerDefaultValidators);
|
|
85
|
+
addProcessor('discountCalculatorFunctions', registerDefaultCalculators);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const coupons = [
|
|
2
|
+
{
|
|
3
|
+
coupon_id: 1,
|
|
4
|
+
uuid: '511b3def-bfe0-4cff-91ce-667586939bdb',
|
|
5
|
+
status: true,
|
|
6
|
+
description: 'percentage_discount_to_entire_order',
|
|
7
|
+
discount_amount: 10,
|
|
8
|
+
free_shipping: false,
|
|
9
|
+
discount_type: 'percentage_discount_to_entire_order',
|
|
10
|
+
coupon: 'ten_percent_discount_to_entire_order',
|
|
11
|
+
used_time: 0,
|
|
12
|
+
target_products: [],
|
|
13
|
+
condition: { order_qty: '', order_total: '' },
|
|
14
|
+
user_condition: { email: '', groups: [''], purchased: '' },
|
|
15
|
+
buyx_gety: [
|
|
16
|
+
{
|
|
17
|
+
sku: 'AT46 8703 9964 4659 4364',
|
|
18
|
+
max_y: 2,
|
|
19
|
+
buy_qty: 3,
|
|
20
|
+
get_qty: 1,
|
|
21
|
+
discount: 70
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
sku: 'LU72 5610 V9CD PSQH XZTE',
|
|
25
|
+
max_y: 3,
|
|
26
|
+
buy_qty: 2,
|
|
27
|
+
get_qty: 1,
|
|
28
|
+
discount: 100
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
max_uses_time_per_coupon: null,
|
|
32
|
+
max_uses_time_per_customer: null,
|
|
33
|
+
start_date: null,
|
|
34
|
+
end_date: null,
|
|
35
|
+
created_at: '2020-04-23 23:22:33+07',
|
|
36
|
+
updated_at: '2020-04-24 00:45:33+07'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
coupon_id: 1,
|
|
40
|
+
uuid: '511b3sef-bfe0-4cff-91ce-667586939bdb',
|
|
41
|
+
status: true,
|
|
42
|
+
description: '100_fixed_discount_to_entire_order',
|
|
43
|
+
discount_amount: 100,
|
|
44
|
+
free_shipping: false,
|
|
45
|
+
discount_type: 'fixed_discount_to_entire_order',
|
|
46
|
+
coupon: '100_fixed_discount_to_entire_order',
|
|
47
|
+
used_time: 0,
|
|
48
|
+
target_products: [],
|
|
49
|
+
condition: { order_qty: '', order_total: '' },
|
|
50
|
+
user_condition: { email: '', groups: [''], purchased: '' },
|
|
51
|
+
buyx_gety: [],
|
|
52
|
+
max_uses_time_per_coupon: null,
|
|
53
|
+
max_uses_time_per_customer: null,
|
|
54
|
+
start_date: null,
|
|
55
|
+
end_date: null,
|
|
56
|
+
created_at: '2020-04-23 23:22:33+07',
|
|
57
|
+
updated_at: '2020-04-24 00:45:33+07'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
coupon_id: 1,
|
|
61
|
+
uuid: '511b3sef-bfe0-4cff-91ce-667586939bdb',
|
|
62
|
+
status: true,
|
|
63
|
+
description: '500_fixed_discount_to_entire_order',
|
|
64
|
+
discount_amount: 500,
|
|
65
|
+
free_shipping: false,
|
|
66
|
+
discount_type: 'fixed_discount_to_entire_order',
|
|
67
|
+
coupon: '500_fixed_discount_to_entire_order',
|
|
68
|
+
used_time: 0,
|
|
69
|
+
target_products: [],
|
|
70
|
+
condition: { order_qty: '', order_total: '' },
|
|
71
|
+
user_condition: { email: '', groups: [''], purchased: '' },
|
|
72
|
+
buyx_gety: [],
|
|
73
|
+
max_uses_time_per_coupon: null,
|
|
74
|
+
max_uses_time_per_customer: null,
|
|
75
|
+
start_date: null,
|
|
76
|
+
end_date: null,
|
|
77
|
+
created_at: '2020-04-23 23:22:33+07',
|
|
78
|
+
updated_at: '2020-04-24 00:45:33+07'
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
module.exports.coupons = coupons;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const products = [
|
|
2
|
+
{
|
|
3
|
+
product_id: 1,
|
|
4
|
+
name: 'Product 1',
|
|
5
|
+
sku: 'SKU1',
|
|
6
|
+
price: 100,
|
|
7
|
+
status: true,
|
|
8
|
+
qty: 100,
|
|
9
|
+
tax_class: 1
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
product_id: 2,
|
|
13
|
+
name: 'Product 2',
|
|
14
|
+
sku: 'SKU2',
|
|
15
|
+
price: 200,
|
|
16
|
+
status: true,
|
|
17
|
+
qty: 100,
|
|
18
|
+
tax_class: 1
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
product_id: 3,
|
|
22
|
+
name: 'Product 3',
|
|
23
|
+
sku: 'SKU3',
|
|
24
|
+
price: 300,
|
|
25
|
+
status: true,
|
|
26
|
+
qty: 100,
|
|
27
|
+
tax_class: 1
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
product_id: 4,
|
|
31
|
+
name: 'No Tax',
|
|
32
|
+
sku: 'SKU4',
|
|
33
|
+
price: 300,
|
|
34
|
+
status: true,
|
|
35
|
+
qty: 100,
|
|
36
|
+
tax_class: null
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
product_id: 5,
|
|
40
|
+
name: 'Tax Exempt',
|
|
41
|
+
sku: 'SKU5',
|
|
42
|
+
price: 123.45,
|
|
43
|
+
status: true,
|
|
44
|
+
qty: 100,
|
|
45
|
+
tax_class: 3
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
product_id: 6,
|
|
49
|
+
name: 'Long decimal tax',
|
|
50
|
+
sku: 'SKU6',
|
|
51
|
+
price: 345.73,
|
|
52
|
+
status: true,
|
|
53
|
+
qty: 100,
|
|
54
|
+
tax_class: 4
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
product_id: 7,
|
|
58
|
+
name: 'Tax 10%',
|
|
59
|
+
sku: 'SKU7',
|
|
60
|
+
price: 819,
|
|
61
|
+
status: true,
|
|
62
|
+
qty: 100,
|
|
63
|
+
tax_class: 1
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
module.exports.products = products;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 discount amount calculation', () => {
|
|
14
|
+
it('Percentage discount to entire order', async () => {
|
|
15
|
+
const cart = new Cart({
|
|
16
|
+
status: 1
|
|
17
|
+
});
|
|
18
|
+
const pricingConfig = config.get('pricing');
|
|
19
|
+
pricingConfig.tax.price_including_tax = false;
|
|
20
|
+
const item = await cart.addItem(1, 1);
|
|
21
|
+
expect(item.getData('discount_amount')).toEqual(0);
|
|
22
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
23
|
+
expect(cart.getData('discount_amount')).toEqual(10);
|
|
24
|
+
pricingConfig.tax.price_including_tax = true;
|
|
25
|
+
await item.build();
|
|
26
|
+
await cart.build();
|
|
27
|
+
expect(cart.getData('discount_amount')).toEqual(10);
|
|
28
|
+
pricingConfig.tax.price_including_tax = false;
|
|
29
|
+
await item.build();
|
|
30
|
+
const item2 = await cart.addItem(2, 2);
|
|
31
|
+
expect(cart.getData('discount_amount')).toEqual(50);
|
|
32
|
+
await cart.setData('coupon', '100_fixed_discount_to_entire_order');
|
|
33
|
+
expect(cart.getData('discount_amount')).toEqual(100);
|
|
34
|
+
pricingConfig.tax.price_including_tax = true;
|
|
35
|
+
await item.build();
|
|
36
|
+
await item2.build();
|
|
37
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
38
|
+
expect(cart.getData('discount_amount')).toEqual(50);
|
|
39
|
+
await cart.setData('coupon', '100_fixed_discount_to_entire_order');
|
|
40
|
+
expect(cart.getData('discount_amount')).toEqual(100);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('It should apply maximum discount amount when discount amount is greater than the total price', async () => {
|
|
44
|
+
const cart = new Cart({
|
|
45
|
+
status: 1
|
|
46
|
+
});
|
|
47
|
+
const pricingConfig = config.get('pricing');
|
|
48
|
+
pricingConfig.tax.price_including_tax = false;
|
|
49
|
+
await cart.setData('coupon', '500_fixed_discount_to_entire_order');
|
|
50
|
+
const item = await cart.addItem(1, 1);
|
|
51
|
+
expect(cart.getData('discount_amount')).toEqual(100);
|
|
52
|
+
const item2 = await cart.addItem(2, 1);
|
|
53
|
+
expect(cart.getData('discount_amount')).toEqual(300);
|
|
54
|
+
pricingConfig.tax.price_including_tax = true;
|
|
55
|
+
await item.build();
|
|
56
|
+
await item2.build();
|
|
57
|
+
await cart.build();
|
|
58
|
+
expect(cart.getData('discount_amount')).toEqual(300);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
// This test assumes there is no additional fee like shipping fee, etc.
|
|
14
|
+
describe('Test grand total calculation', () => {
|
|
15
|
+
it('Grand total should equal to the sum of line total with discount including tax of all items when discount is not applied', async () => {
|
|
16
|
+
const cart = new Cart({
|
|
17
|
+
status: 1
|
|
18
|
+
});
|
|
19
|
+
const priceConfig = config.get('pricing');
|
|
20
|
+
priceConfig.tax.price_including_tax = false;
|
|
21
|
+
const item = await cart.addItem(1, 1); // Tax percent 10%
|
|
22
|
+
expect(cart.getData('grand_total')).toEqual(110);
|
|
23
|
+
const item2 = await cart.addItem(5, 1); // Tax percent 7.25%
|
|
24
|
+
expect(cart.getData('grand_total')).toEqual(242.4);
|
|
25
|
+
const item3 = await cart.addItem(2, 2); // Tax percent 10%
|
|
26
|
+
expect(cart.getData('grand_total')).toEqual(682.4);
|
|
27
|
+
|
|
28
|
+
priceConfig.tax.price_including_tax = true;
|
|
29
|
+
await item.build();
|
|
30
|
+
await item2.build();
|
|
31
|
+
await item3.build();
|
|
32
|
+
await cart.build();
|
|
33
|
+
expect(cart.getData('grand_total')).toEqual(623.45);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('Grand total should alway be equal to the sub total including tax when discount is not applied', async () => {
|
|
37
|
+
const cart = new Cart({
|
|
38
|
+
status: 1
|
|
39
|
+
});
|
|
40
|
+
const priceConfig = config.get('pricing');
|
|
41
|
+
priceConfig.tax.price_including_tax = false;
|
|
42
|
+
const item = await cart.addItem(1, 1);
|
|
43
|
+
expect(cart.getData('grand_total')).toEqual(110);
|
|
44
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(110);
|
|
45
|
+
const item2 = await cart.addItem(5, 1);
|
|
46
|
+
expect(cart.getData('grand_total')).toEqual(242.4);
|
|
47
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(242.4);
|
|
48
|
+
|
|
49
|
+
priceConfig.tax.price_including_tax = true;
|
|
50
|
+
await item.build();
|
|
51
|
+
await item2.build();
|
|
52
|
+
await cart.build();
|
|
53
|
+
expect(cart.getData('grand_total')).toEqual(223.45);
|
|
54
|
+
expect(cart.getData('sub_total_incl_tax')).toEqual(223.45);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('Grand total should be calculated with discount amount deducted', async () => {
|
|
58
|
+
const cart = new Cart({
|
|
59
|
+
status: 1
|
|
60
|
+
});
|
|
61
|
+
const priceConfig = config.get('pricing');
|
|
62
|
+
priceConfig.tax.price_including_tax = false;
|
|
63
|
+
const item = await cart.addItem(1, 1); // Tax percent 10%
|
|
64
|
+
expect(cart.getData('grand_total')).toEqual(110);
|
|
65
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
66
|
+
expect(cart.getData('grand_total')).toEqual(99);
|
|
67
|
+
const item2 = await cart.addItem(5, 1); // Tax percent 7.25%
|
|
68
|
+
// Tax rounding unit level, round to nearest with 2 decimal places
|
|
69
|
+
expect(cart.getData('grand_total')).toEqual(218.15);
|
|
70
|
+
const item3 = await cart.addItem(2, 2); // Tax percent 10%
|
|
71
|
+
expect(cart.getData('grand_total')).toEqual(614.15);
|
|
72
|
+
|
|
73
|
+
await cart.setData('coupon', '100_fixed_discount_to_entire_order');
|
|
74
|
+
expect(cart.getData('grand_total')).toEqual(572.94);
|
|
75
|
+
|
|
76
|
+
priceConfig.tax.price_including_tax = true;
|
|
77
|
+
await item.build();
|
|
78
|
+
await item2.build();
|
|
79
|
+
await item3.build();
|
|
80
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
81
|
+
expect(cart.getData('grand_total')).toEqual(561.1);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
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 line total calculation', () => {
|
|
14
|
+
it('Line total should equal to the product price multiplied by quantity 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('line_total')).toEqual(100);
|
|
22
|
+
const item2 = await cart.addItem(2, 2);
|
|
23
|
+
expect(item2.getData('line_total')).toEqual(400);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('Line 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(item.getData('line_total_incl_tax')).toEqual(110);
|
|
34
|
+
const item2 = await cart.addItem(2, 2);
|
|
35
|
+
expect(item2.getData('line_total_incl_tax')).toEqual(440);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('Line 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(item.getData('line_total')).toEqual(90.91);
|
|
46
|
+
const item2 = await cart.addItem(2, 2);
|
|
47
|
+
expect(item2.getData('line_total')).toEqual(363.64);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('Line total including tax should be equal to product price 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(item.getData('line_total_incl_tax')).toEqual(100);
|
|
58
|
+
const item2 = await cart.addItem(2, 2);
|
|
59
|
+
expect(item2.getData('line_total_incl_tax')).toEqual(400);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('Line 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
|
+
const item = await cart.addItem(1, 1);
|
|
69
|
+
expect(item.getData('line_total')).toEqual(100);
|
|
70
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
71
|
+
expect(item.getData('line_total')).toEqual(100);
|
|
72
|
+
priceConfig.tax.price_including_tax = true;
|
|
73
|
+
await item.build();
|
|
74
|
+
expect(item.getData('line_total')).toEqual(90.91);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('Line total including tax should not be affected by discount amount', async () => {
|
|
78
|
+
const cart = new Cart({
|
|
79
|
+
status: 1
|
|
80
|
+
});
|
|
81
|
+
const priceConfig = config.get('pricing');
|
|
82
|
+
priceConfig.tax.price_including_tax = false;
|
|
83
|
+
const item = await cart.addItem(1, 1);
|
|
84
|
+
expect(item.getData('line_total_incl_tax')).toEqual(110);
|
|
85
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
86
|
+
expect(item.getData('line_total_incl_tax')).toEqual(110);
|
|
87
|
+
priceConfig.tax.price_including_tax = true;
|
|
88
|
+
await item.build();
|
|
89
|
+
expect(item.getData('final_price_incl_tax')).toEqual(100);
|
|
90
|
+
expect(item.getData('line_total_incl_tax')).toEqual(100);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
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 line total with discount calculation', () => {
|
|
14
|
+
it('Line total with discount should equal to the product price multiplied by quantity 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('line_total_with_discount')).toEqual(100);
|
|
22
|
+
const item2 = await cart.addItem(2, 2);
|
|
23
|
+
expect(item2.getData('line_total_with_discount')).toEqual(400);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('Line total with discount 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(item.getData('line_total_with_discount_incl_tax')).toEqual(110);
|
|
34
|
+
const item2 = await cart.addItem(2, 2);
|
|
35
|
+
expect(item2.getData('line_total_with_discount_incl_tax')).toEqual(440);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('Line total with discount 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(item.getData('line_total_with_discount')).toEqual(90.91);
|
|
46
|
+
const item2 = await cart.addItem(2, 2);
|
|
47
|
+
expect(item2.getData('line_total_with_discount')).toEqual(363.64);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('Line total with discount including tax should be equal to product price 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(item.getData('line_total_with_discount_incl_tax')).toEqual(100);
|
|
58
|
+
const item2 = await cart.addItem(2, 2);
|
|
59
|
+
expect(item2.getData('line_total_with_discount_incl_tax')).toEqual(400);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('Line total with discount should 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
|
+
const item = await cart.addItem(1, 1);
|
|
69
|
+
expect(item.getData('line_total_with_discount')).toEqual(100);
|
|
70
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
71
|
+
expect(cart.getData('discount_amount')).toEqual(10);
|
|
72
|
+
expect(item.getData('line_total_with_discount')).toEqual(90);
|
|
73
|
+
const item2 = await cart.addItem(2, 2);
|
|
74
|
+
expect(item2.getData('line_total_with_discount')).toEqual(360);
|
|
75
|
+
priceConfig.tax.price_including_tax = true;
|
|
76
|
+
await item.build();
|
|
77
|
+
await item2.build();
|
|
78
|
+
await cart.build();
|
|
79
|
+
expect(item.getData('line_total_with_discount')).toEqual(81.82);
|
|
80
|
+
expect(item2.getData('line_total_with_discount')).toEqual(327.28);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('Line total with discount including tax should be affected by discount amount', async () => {
|
|
84
|
+
const cart = new Cart({
|
|
85
|
+
status: 1
|
|
86
|
+
});
|
|
87
|
+
const priceConfig = config.get('pricing');
|
|
88
|
+
priceConfig.tax.price_including_tax = false;
|
|
89
|
+
const item = await cart.addItem(1, 1);
|
|
90
|
+
expect(item.getData('line_total_with_discount_incl_tax')).toEqual(110);
|
|
91
|
+
await cart.setData('coupon', 'ten_percent_discount_to_entire_order');
|
|
92
|
+
expect(cart.getData('discount_amount')).toEqual(10);
|
|
93
|
+
expect(item.getData('line_total_with_discount_incl_tax')).toEqual(99);
|
|
94
|
+
const item2 = await cart.addItem(2, 2);
|
|
95
|
+
expect(item2.getData('line_total_with_discount_incl_tax')).toEqual(396);
|
|
96
|
+
priceConfig.tax.price_including_tax = true;
|
|
97
|
+
await item.build();
|
|
98
|
+
await item2.build();
|
|
99
|
+
await cart.build();
|
|
100
|
+
expect(item.getData('line_total_with_discount_incl_tax')).toEqual(90);
|
|
101
|
+
expect(item2.getData('line_total_with_discount_incl_tax')).toEqual(360);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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 product price calculation', () => {
|
|
14
|
+
it('Price should equal to the product price 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('product_price')).toEqual(100);
|
|
22
|
+
expect(item.getData('final_price')).toEqual(100);
|
|
23
|
+
const noTax = await cart.addItem(4, 1);
|
|
24
|
+
expect(noTax.getData('product_price')).toEqual(300);
|
|
25
|
+
expect(noTax.getData('final_price')).toEqual(300);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('Price including tax should be calculated with tax amount added', async () => {
|
|
29
|
+
const cart = new Cart({
|
|
30
|
+
status: 1
|
|
31
|
+
});
|
|
32
|
+
const priceConfig = config.get('pricing');
|
|
33
|
+
priceConfig.tax.price_including_tax = false;
|
|
34
|
+
const item = await cart.addItem(1, 1);
|
|
35
|
+
expect(item.getData('product_price_incl_tax')).toEqual(110);
|
|
36
|
+
expect(item.getData('final_price_incl_tax')).toEqual(110);
|
|
37
|
+
const noTax = await cart.addItem(4, 1);
|
|
38
|
+
expect(noTax.getData('product_price')).toEqual(300);
|
|
39
|
+
expect(noTax.getData('final_price')).toEqual(300);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('Price should be calculated with tax amount deducted when tax is included', async () => {
|
|
43
|
+
const cart = new Cart({
|
|
44
|
+
status: 1
|
|
45
|
+
});
|
|
46
|
+
const priceConfig = config.get('pricing');
|
|
47
|
+
priceConfig.tax.price_including_tax = true;
|
|
48
|
+
const item = await cart.addItem(1, 1);
|
|
49
|
+
expect(item.getData('product_price')).toEqual(90.91);
|
|
50
|
+
expect(item.getData('final_price')).toEqual(90.91);
|
|
51
|
+
const noTax = await cart.addItem(4, 1);
|
|
52
|
+
expect(noTax.getData('product_price')).toEqual(300);
|
|
53
|
+
expect(noTax.getData('final_price')).toEqual(300);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Price including tax should be equal to product price when tax is included', async () => {
|
|
57
|
+
const cart = new Cart({
|
|
58
|
+
status: 1
|
|
59
|
+
});
|
|
60
|
+
const priceConfig = config.get('pricing');
|
|
61
|
+
priceConfig.tax.price_including_tax = true;
|
|
62
|
+
const item = await cart.addItem(1, 1);
|
|
63
|
+
expect(item.getData('product_price_incl_tax')).toEqual(100);
|
|
64
|
+
expect(item.getData('final_price_incl_tax')).toEqual(100);
|
|
65
|
+
const noTax = await cart.addItem(4, 1);
|
|
66
|
+
expect(noTax.getData('product_price')).toEqual(300);
|
|
67
|
+
expect(noTax.getData('final_price')).toEqual(300);
|
|
68
|
+
});
|
|
69
|
+
});
|