Class DefaultCheckoutProcess

java.lang.Object
com.skava.cart.checkout.process.DefaultCheckoutValidateProcess
com.skava.cart.checkout.process.DefaultCheckoutProcess
Direct Known Subclasses:
DefaultCheckoutStrategyServiceImpl

@Service public class DefaultCheckoutProcess extends DefaultCheckoutValidateProcess
The Class DefaultCheckoutProcess. Provides the default checkout process for calculate and validate services.
Since:
2019-02-14
Version:
8.2.0
Author:
Infosys Equinox
  • Field Details

  • Constructor Details

    • DefaultCheckoutProcess

      public DefaultCheckoutProcess()
  • Method Details

    • setPaymentValue

      public static void setPaymentValue(CartCheckoutDomain cartCheckoutDomain, CartCheckoutDataRequest request)
      This method is used to update cart payment value.
      Parameters:
      cartCheckoutDomain - Indicates a CartCheckoutDomain ,contains the entire cart of the customer.
      request - a CartCheckoutDataRequest object.
    • getTotalItemsDeliveredWithCart

      public static BigDecimal getTotalItemsDeliveredWithCart(CartCheckoutDomain cartCheckoutDomain, boolean isCartWithFullDiscountItems)
    • getTotalCartDeliveryTax

      public static BigDecimal getTotalCartDeliveryTax(CartCheckoutDomain cartCheckoutDomain)
    • getTotalCartRegionalTax

      public static BigDecimal getTotalCartRegionalTax(CartCheckoutDomain cartCheckoutDomain)
      This method is used to get total regional tax in cart
      Parameters:
      cartCheckoutDomain - cartCheckoutDomain
      Returns:
      totalCartRegionalTax
    • doItemLevelProration

      public void doItemLevelProration(CartCheckoutDomain cartCheckoutDomain, CartCheckoutDataRequest request, int itemsToReturn, BigDecimal salesItemPriceSum, int skipSubscriptionItemsCount)
      This method is used to update proration for delivery details of the orchestration cart response Cartlevel Delivery Charges / Discount
      Parameters:
      cartCheckoutDomain - Indicates aCartCheckoutDomain, contains the entire cart of the customer.
      request - a CartCheckoutDataRequest object.
      itemsToReturn - holds number of items to return
      salesItemPriceSum - holds sum of sales items.
      skipSubscriptionItemsCount - number of subscription items to skip.
    • doItemLevelProration

      public void doItemLevelProration(CartCheckoutDomain cartCheckoutDomain, CartCheckoutDataRequest request, int itemsToReturn, BigDecimal salesItemPriceSum, int skipSubscriptionItemsCount, Map<String,Object> requestMap)
      This method is used to update proration for delivery details of the orchestration cart response Cartlevel Delivery Charges / Discount
      Parameters:
      cartCheckoutDomain - Indicates aCartCheckoutDomain, contains the entire cart of the customer.
      request - a CartCheckoutDataRequest object.
      itemsToReturn - holds number of items to return
      salesItemPriceSum - holds sum of sales items.
      skipSubscriptionItemsCount - number of subscription items to skip.
      requestMap - holds the cartMath info
    • setDeliveryCharge

      protected Map<String,BigDecimal> setDeliveryCharge(DeliveryDetails deliveryDetails, Map<String,BigDecimal> deliveryMap, BigDecimal deliveryCharge)
      This method used to group the delivery charge based on the type
      Parameters:
      deliveryDetails -
      deliveryMap -
      deliveryCharge -
      Returns:
    • calculateTotalItemDeliveryCharge

      protected BigDecimal calculateTotalItemDeliveryCharge(BigDecimal totalDeliveryCharge, BigDecimal totalQuantity, BigDecimal totalItemDeliveryCharge, CheckoutItem checkoutItemDomain, boolean isLastItem)
      This method is used to calculate totalDeliveryCharge.
      Parameters:
      totalDeliveryCharge - value of totalDeliveryCharge.
      totalQuantity - to get totalDeliveryCharge.
      totalItemDeliveryCharge - value to be calculated.
      checkoutItemDomain - domain object of checkoutItem.
      isLastItem - boolean parameter indicates whether the item is last.
      Returns:
      totalItemDeliveryCharge
    • prorateCartDeliveryTax

      protected static BigDecimal prorateCartDeliveryTax(BigDecimal proratedItemLevelTax, BigDecimal totalCartDeliveryTax, BigDecimal totalItemsDeliveredWithCart, CheckoutItem checkoutItemDomain, boolean isLastItem)
      This method is used to calculate prorateCartDeliveryTax.
      Parameters:
      proratedItemLevelTax - proratedItemLevelTax to added with totalCartDeliveryTax.
      totalCartDeliveryTax - value of totalCartDeliveryTax.
      totalItemsDeliveredWithCart - value of totalItemsDeliveredWithCart.
      checkoutItemDomain - domain object of checkoutItem.
      isLastItem - boolean paremeter indicates whether the item is last.
      Returns:
      proratedItemLevelTax
    • prorateCartRegionalTax

      protected static BigDecimal prorateCartRegionalTax(BigDecimal proratedItemLevelRegionalTax, BigDecimal totalCartRegionalTax, BigDecimal totalItemsDeliveredWithCart, CheckoutItem checkoutItemDomain, boolean isLastItem)
      This method is used to prorate cart regional tax
      Parameters:
      proratedItemLevelRegionalTax - proratedItemLevelRegionalTax
      totalCartRegionalTax - totalCartRegionalTax
      totalItemsDeliveredWithCart - totalItemsDeliveredWithCart
      checkoutItemDomain - checkoutItemDomain
      isLastItem - isLastItem
      Returns:
      prorated regional tax
    • calculateItem

      protected static ItemMathDomain calculateItem(CheckoutItem checkoutItemDomain, BigDecimal quantity, boolean isUnitLevel, CartCheckoutDataRequest request)
      This method is used to calculate price for cart item.
      Parameters:
      checkoutItemDomain - Indicates a CheckoutItem.
      quantity - Indicates the quantity of the cart items
      isUnitLevel - Indicates the flag to denote unit or total level.
      request - a CartCheckoutDataRequest object.
      Returns:
      Returns ItemMathDomain, contains calculated result for the item.
    • calculatePriceFacetsDiscount

      protected static void calculatePriceFacetsDiscount(PromotionDetails promotionDetails, ItemMathDomain itemMath, PromotionBreakUpType type, CartCheckoutDataRequest request, BigDecimal qty)
      This method is used to calculate priceFacetDiscount for the item
      Parameters:
      promotionDetails - Indicates a PromotionDetails , contains all promotion details of the item or the cart.
      itemMath - Indicates a ItemMathDomain.
      type - Indicates a PromotionBreakUpType.
      request - a CartCheckoutDataRequest object.
      qty - quantity to set unitlevel or totallevel priceFacet values.
    • calculateDiscount

      protected static BigDecimal calculateDiscount(PromotionDetails promotionDetails, PromotionBreakUpType type, BigDecimal quantity, CartCheckoutDataRequest request)
      This method is used to calculate promotion for the cart
      Parameters:
      promotionDetails - Indicates a PromotionDetails , contains all promotion details of the item or the cart.
      type - Indicates a PromotionBreakUpType , contains the promotion break up type.
      quantity - Indicates the quantity of the cart.
      request - a CartCheckoutDataRequest object.
      Returns:
      Returns the discount value.
    • calculateLoyaltyDiscount

      protected static BigDecimal calculateLoyaltyDiscount(PromotionDetails promotionDetails, List<LoyaltyDetails> loyaltyDetails, BigDecimal quantity, CartCheckoutDataRequest request, String type)
      This method is used to calculate loyalty promotion for the cart
      Parameters:
      promotionDetails - Indicates a PromotionDetails , contains all promotion details of the item or the cart.
      loyaltyDetails - a LoyaltyDetails , contains the loyalty details.
      quantity - Indicates the quantity of the cart.
      request - a CartCheckoutDataRequest object.
      type - contains the type like LOYALTY / VOUCHER.
      Returns:
      Returns the discount value.
    • calculateTaxForUnitValue

      protected static BigDecimal calculateTaxForUnitValue(CheckoutItem checkoutItemDomain, CartCheckoutDataRequest request)
      This method is used to calculate tax for the Unit value for the cart item.
      Parameters:
      checkoutItemDomain - Indicates a CheckoutItem, contains the item details that can be placed in a cart.
      request - a CartCheckoutDataRequest object.
      Returns:
      Returns the calculated tax unit price value.
    • calculateRegionalTaxForUnitValue

      protected static BigDecimal calculateRegionalTaxForUnitValue(CheckoutItem checkoutItemDomain, CartCheckoutDataRequest request)
      This method is used to calculate regionl tax for unit value
      Parameters:
      checkoutItemDomain - checkoutItemDomain
      request - request
      Returns:
      regional tax for unit value
    • calculateTaxForTotalValue

      protected static BigDecimal calculateTaxForTotalValue(CheckoutItem checkoutItemDomain, CartCheckoutDataRequest request)
      This method is used to calculate tax for total Value for the cart item.
      Parameters:
      checkoutItemDomain - Indicates a CheckoutItem, contains the item details that can be placed in a cart.
      request - a CartCheckoutDataRequest object.
      Returns:
      Returns the calculated tax value for total item price.
    • calculateRegionalTaxForTotalValue

      protected static BigDecimal calculateRegionalTaxForTotalValue(CheckoutItem checkoutItemDomain, CartCheckoutDataRequest request)
      This method is used to calculate regional tax for total value
      Parameters:
      checkoutItemDomain - checkoutItemDomain
      request - request
      Returns:
      regional tax for total value
    • calculateDeliveryCharge

      protected static BigDecimal calculateDeliveryCharge(DeliveryDetails deliveryDetails, CartCheckoutDataRequest request)
      This method is used to calculate delivery charge details of the cart or cart item.
      Parameters:
      deliveryDetails - Indicates a DeliveryDetails, contains delivery details of the item or the items in the cart.
      request - a CartCheckoutDataRequest object.
      Returns:
      Returns the calculated delivery charge of the cart or cart item.
    • doProration

      protected static boolean doProration(BigDecimal quantity, BigDecimal ratio, PromotionBreakUp breakup, PromotionBreakUp promotionBreakup, boolean isLastItem)
      This method is used to do prorate calculation based on the ration and quantity of the item for promotion. This will return true once prorated calculation has been done else false.
      Parameters:
      quantity - Indicates the quantity of discount item.
      ratio - Indicates the ratio which used to calculate the unit and total discount.
      breakup - Indicates a PromotionBreakUp, contains the different promotions that are applied to an item or the cart.
      promotionBreakup - Indicates a PromotionBreakUp, contains the different promotions that are applied to an item or the cart.
      isLastItem - flag to validate is last item.
      Returns:
      returns true, if Prorated.
    • createItemLoyaltyDetailsDTO

      public static List<LoyaltyDetails> createItemLoyaltyDetailsDTO(List<LoyaltyDetails> loyaltyDetails, Map<String,BigDecimal> discountRatio, Boolean skipLoyaltyProration, CheckoutItem checkoutItemDomain, Map<String,Boolean> isLastItemList)
      Parameters:
      loyaltyDetails - Indicates a LoyaltyDetails, contains all loyalty details of the item or the cart.
      discountRatio - Indicates the ratio which used to calculate the unit and total discount.
      skipLoyaltyProration - holds the boolean value.
      checkoutItemDomain - Indicates a CheckoutItem, contains all loyalty details of the item or the cart.
      isLastItemList - holds the flag to validate is last item.
      Returns:
      LoyaltyDetails
    • createDiscountDTO

      public static PromotionDetails createDiscountDTO(Map<String,PromotionDetails> promoDetails, List<String> loyaltyTypeList, BigDecimal quantity, Map<String,BigDecimal> discountRatio, Map<String,Boolean> skipProrationList, Map<String,Boolean> isLastItemList, Map<String,Map<String,BigDecimal>> ratioList)
      Parameters:
      promoDetails - Indicates a PromotionDetails, contains all promotion details of the item or the cart.
      loyaltyTypeList - contains the type of loyaltydetails.
      quantity - Indicates the quantity of discount item.
      discountRatio - Indicates the ratio which used to calculate the unit and total discount.
      skipProrationList - indicates proration eligibility of item contains all promotion details of the item or the cart.
      isLastItemList - holds the flag to validate is last item.
      ratioList - contains price facets ratio list
      Returns:
      PromotionDetails
    • createTaxationDTO

      public static TaxationDetails createTaxationDTO(Map<String,TaxationDetails> taxationDetails, BigDecimal quantity, Map<String,BigDecimal> taxationRatio, Map<String,Boolean> isLastItemList, Map<String,BigDecimal> otherTaxCharges)
      Parameters:
      taxationDetails - holds taxationDetails details of the cart.
      quantity - Indicates the quantity of discount item.
      taxationRatio - Indicates the ratio which used to calculate the unit and total discount.
      isLastItemList - holds the flag to validate is last item.
      otherTaxCharges - holds otherTaxCharges of cart.
      Returns:
      TaxationDetails
    • prorateOtherTaxCharges

      public static void prorateOtherTaxCharges(BigDecimal quantity, Map<String,Boolean> isLastItemList, Map<String,BigDecimal> otherTaxCharges, TaxationDetails itemTaxationDetail, Map<String,TaxationDetails> taxationDetails)
      Parameters:
      quantity - Indicates the quantity of discount item.
      isLastItemList - holds the flag to validate is last item.
      otherTaxCharges - holds otherTaxCharges of cart.
      taxationDetails - holds taxationDetails details of the cart.
      itemTaxationDetail - holds taxationDetails details of the item.
    • setSkuTaxationDetails

      public static TaxationDetails setSkuTaxationDetails(Map<String,TaxationDetails> taxationDetails, BigDecimal quantity, String key, BigDecimal value, Map<String,Boolean> isLastItemList, TaxationDetails itemTaxationDetail)
      Parameters:
      taxationDetails - holds taxationDetails details of the cart.
      quantity - holds the quantity of discount item.
      key - holds holds String value of the tax price discount.
      value - holds BigDecimal ratio value which used to calculate the unit and total discount
      isLastItemList - holds the flag to validate is last item.
      itemTaxationDetail - holds taxationDetails details of the item.
      Returns:
      TaxationDetails
    • updateLastUnitAndTotalTaxPriceValue

      public static BigDecimal updateLastUnitAndTotalTaxPriceValue(BigDecimal lastTaxPrice, BigDecimal taxPrice)
      This method is used to update tax pricevalue.
      Parameters:
      lastTaxPrice - Holds lastTaxPrice value.
      taxPrice - Holds taxPrice value.
      Returns:
      BigDecimal value.
    • initializeSummazations

      protected static void initializeSummazations(PromotionBreakUp breakup)
      Initialize summazations.
      Parameters:
      breakup - indicates a PromotionBreakUp
    • setPromotionsForPromotionItem

      protected static PromotionDetails setPromotionsForPromotionItem(PromotionBreakUp breakupDomain, PromotionDetails itemPromotionDetails, PromotionBreakUpType breakUpType)
      Parameters:
      breakupDomain - Indicates a PromotionBreakUpDomain, contains the different promotions that are applied to an item or the cart.
      itemPromotionDetails - Indicates a PromotionBreakUpDomain, contains the different promotions that are applied to an item or the cart item.
      breakUpType - indicates type of the promotion break up.
      Returns:
      promotion details
    • validateBundle

      public static boolean validateBundle(CheckoutItem checkoutItemDomain, SkuType type)
      This method is used to validate sku type.
      Parameters:
      checkoutItemDomain - Indicates a CheckoutPromotion, contains promotion details.
      type - Indicates a SkuType, applied to an item or the cart.
      Returns:
      boolean .
    • validateGiftItem

      public static boolean validateGiftItem(CheckoutItem checkoutItemDomain)
      This method is used to check if the product id Gift product or not.
      Parameters:
      checkoutItemDomain - a CheckoutItem, contains item details
      Returns:
      boolean .
    • countGiftItems

      public static int countGiftItems(CartCheckoutDomain cartCheckoutDomainProration)
      This method is used to count gift Items.
      Parameters:
      cartCheckoutDomainProration - a CartCheckoutDomain, contains item details
      Returns:
      giftItems .
    • isLastItemForDiscountProartionItem

      public static boolean isLastItemForDiscountProartionItem(CartCheckoutDomain cartCheckoutDomain, CheckoutItem checkoutItemDomain, boolean skipProration)
      This method is used to check if the item is last item eligible for cart discount proration
      Parameters:
      cartCheckoutDomain - a CartCheckoutDomain contains cartCheckout object
      checkoutItemDomain - a CheckoutItem, contains item details
      skipProration - indicates proration eligibility of item
      Returns:
      boolean indicates the if item is last item for discount proration
    • isLastItemForLoyaltyDiscountProartionItem

      public static boolean isLastItemForLoyaltyDiscountProartionItem(CartCheckoutDomain cartCheckoutDomain, CheckoutItem checkoutItemDomain, boolean skipLoyaltyProration)
      This method is used to check if the item is last item eligible for cart discount proration
      Parameters:
      cartCheckoutDomain - a CartCheckoutDomain contains cartCheckout object
      checkoutItemDomain - a CheckoutItem, contains item details
      skipLoyaltyProration - indicates proration eligibility of loyalty item
      Returns:
      boolean indicates the if item is last item for discount proration
    • isLastItemForDeliveryProration

      protected static boolean isLastItemForDeliveryProration(CartCheckoutDomain cartCheckoutDomain, CheckoutItem checkoutItemDomain, boolean isFullDiscountItem, boolean isCartWithFullDiscountItems, boolean isLastItem)
      This method is used to check if the item last item to prorate delivery charge.
      Parameters:
      cartCheckoutDomain - a CartCheckoutDomain contains cartCheckout object.
      checkoutItemDomain - a CheckoutItem, contains item details.
      isFullDiscountItem - indicates if the item is having full discount.
      isCartWithFullDiscountItems - indicates if the cart contains only item with full discount.
      isLastItem - indicates if the item is last for proration.
      Returns:
      isLastItemForDeliveryProration
    • validateFullDiscountItem

      protected static boolean validateFullDiscountItem(boolean isCartWithFullDiscountItems, boolean isGift, CheckoutItem item)
      This method is used to check if the item contains full discount.
      Parameters:
      isCartWithFullDiscountItems - indicates if the cart contains only item with full discount.
      isGift - indicates if the item is gift.
      item - a CheckoutItem, contains item details.
      Returns:
      validateFullDiscountItem
    • checkIfAllItemsWithFullDiscount

      protected static boolean checkIfAllItemsWithFullDiscount(CartCheckoutDomain cartCheckoutDomain)
      This method is used to check if the cart contains only item with full discount.
      Parameters:
      cartCheckoutDomain - a CartCheckoutDomain contains cartCheckout object.
      Returns:
      checkIfAllItemsWithFullDiscount