Class OrderCalc


  • public class OrderCalc
    extends Object
    Interfaces with Calc to calculate total, discount, and tax of an Order.
    • Constructor Detail

      • OrderCalc

        public OrderCalc​(Order order)
        Constructs a new instance to calculate values for the given order. Does not make a copy of the provided order.
    • Method Detail

      • getTax

        public long getTax()
      • getTip

        public long getTip()
      • getTotal

        public long getTotal​(Collection<LineItem> lines)
        Returns:
        The order total for the specified line items, which includes the discounted subtotal, service charge, and tax. Note that tip is not included in the total. If an item was refunded or exchanged, then it does not appear in the total.
      • getTotalBeforeRefunds

        public long getTotalBeforeRefunds​(Collection<LineItem> lines)
        Returns:
        the order total, which includes the discounted subtotal, service charge, and tax. Note that tip is not included in the total. If an item was refunded, then it DOES appear in the total. If an item was exchanged, then it does not appear in the total.
      • getDiscountedSubtotal

        public long getDiscountedSubtotal​(Collection<LineItem> lines)
      • getLineSubtotalBeforeRefunds

        public long getLineSubtotalBeforeRefunds​(Collection<LineItem> lines)
      • getLineSubtotalWithoutDiscounts

        public long getLineSubtotalWithoutDiscounts​(Collection<LineItem> lines)
      • getLineExtendedPrice

        public long getLineExtendedPrice​(LineItem line)
        Returns:
        the line item price without discounts and modifiers.
      • getServiceCharge

        public long getServiceCharge()
      • getTaxSummaries

        public List<com.clover.core.internal.calc.Calc.TaxSummary> getTaxSummaries​(Collection<LineItem> lines)
      • getTaxSummariesBeforeRefunds

        public List<com.clover.core.internal.calc.Calc.TaxSummary> getTaxSummariesBeforeRefunds​(Collection<LineItem> lines,
                                                                                                com.clover.core.internal.calc.Decimal overrideSplitPercent)
        Summarize the taxes for the given line items. If an item was refunded, still include it. If an item was exchanged, then ignore it.
        Parameters:
        lines - for this subset of line items
        overrideSplitPercent - optional. if specified, then assume we're computing a partial payment and this percent is the amount of a partial payment.
        Returns:
        summary of the given line items at, optionally, the given partial payment percentage
      • getDiscountMultiplier

        public com.clover.core.internal.calc.Decimal getDiscountMultiplier()
      • getPaymentDetails

        public com.clover.core.internal.calc.Calc.PaymentDetails getPaymentDetails​(long paymentAmount)
      • getPaymentDetails

        public com.clover.core.internal.calc.Calc.PaymentDetails getPaymentDetails​(long paymentAmount,
                                                                                   Collection<LineItem> lines)
      • getPriceWithoutVAT

        public long getPriceWithoutVAT​(LineItem lineItem)
        Pass VAT inclusive price Line Item and get back VAT exclusive price
        Parameters:
        lineItem - input Line Item whose VAT exclusive price needs to find out
        Returns:
        VAT exclusive price
        Throws:
        IllegalArgumentException - if price on Line item is negative or Flat tax rate on line Item is grater than item itself
      • getPriceWithVAT

        public long getPriceWithVAT​(LineItem lineItem)
        Pass VAT exclusive price Line Item and get back VAT inclusive price
        Parameters:
        lineItem - input Line Item whose VAT inclusive price needs to find out
        Returns:
        VAT inclusive price
        Throws:
        IllegalArgumentException - if price on Line Item is negative
      • getAdditionalChargeSummaries

        public List<com.clover.core.internal.calc.Calc.AdditionalChargeSummary> getAdditionalChargeSummaries​(Collection<LineItem> lines)
        Get the Additional charges calculated for passed in line items
        Parameters:
        lines - line items to be considered while calculating charges
        Returns:
        summary of additional charges with final charge value or empty list if additional charges were not present
      • getOrderFeePrice

        public long getOrderFeePrice​(LineItem orderFeeLineItem)
        Get an orderFee price based on passed orderFeeLineItem's percentage
        Parameters:
        orderFeeLineItem - order fee line item for which price needs to be calculated
        Returns:
        long price for given orderFeeLineItem
      • getTotalOrderFees

        public long getTotalOrderFees()
        Get the total orderFee amount for given order
        Returns:
        long total of order fees applied to given order