Class StatementCalculator


  • public final class StatementCalculator
    extends java.lang.Object
    Stateless utility class for calculating financial totals from a Statement. All methods operate purely on the provided statement and have no side effects. Results are rounded to two decimal places using RoundingMode.HALF_UP.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigDecimal cashAdvancesTotal​(Statement stmt)
      Calculates the total for all selected cash advance items using their entered amounts.
      static java.math.BigDecimal finalTotal​(Statement stmt)
      Calculates the final total as the subtotal minus any down payment.
      static java.math.BigDecimal merchandiseTotal​(Statement stmt)
      Calculates the total for all selected merchandise items using their effective prices.
      static java.math.BigDecimal salesTax​(Statement stmt)
      Calculates the sales tax on selected merchandise items that are marked as taxable, using the statement's configured sales tax rate.
      static java.math.BigDecimal servicesTotal​(Statement stmt)
      Calculates the total for services and facilities: the selected package cost plus the sum of individually selected services that are not covered by the package.
      static java.math.BigDecimal specialChargesTotal​(Statement stmt)
      Calculates the total for all selected special charges using their effective prices.
      static java.math.BigDecimal subtotal​(Statement stmt)
      Calculates the subtotal as the sum of services, merchandise, special charges, cash advances, and sales tax.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • servicesTotal

        public static java.math.BigDecimal servicesTotal​(Statement stmt)
        Calculates the total for services and facilities: the selected package cost plus the sum of individually selected services that are not covered by the package. Services with inPackage == true are excluded from the individual sum because their cost is already included in the package price.
        Parameters:
        stmt - the statement to calculate from
        Returns:
        the services total, never null
      • merchandiseTotal

        public static java.math.BigDecimal merchandiseTotal​(Statement stmt)
        Calculates the total for all selected merchandise items using their effective prices.
        Parameters:
        stmt - the statement to calculate from
        Returns:
        the merchandise total, never null
      • specialChargesTotal

        public static java.math.BigDecimal specialChargesTotal​(Statement stmt)
        Calculates the total for all selected special charges using their effective prices.
        Parameters:
        stmt - the statement to calculate from
        Returns:
        the special charges total, never null
      • cashAdvancesTotal

        public static java.math.BigDecimal cashAdvancesTotal​(Statement stmt)
        Calculates the total for all selected cash advance items using their entered amounts.
        Parameters:
        stmt - the statement to calculate from
        Returns:
        the cash advances total, never null
      • salesTax

        public static java.math.BigDecimal salesTax​(Statement stmt)
        Calculates the sales tax on selected merchandise items that are marked as taxable, using the statement's configured sales tax rate.
        Parameters:
        stmt - the statement to calculate from
        Returns:
        the sales tax amount, never null
      • subtotal

        public static java.math.BigDecimal subtotal​(Statement stmt)
        Calculates the subtotal as the sum of services, merchandise, special charges, cash advances, and sales tax.
        Parameters:
        stmt - the statement to calculate from
        Returns:
        the subtotal, never null
      • finalTotal

        public static java.math.BigDecimal finalTotal​(Statement stmt)
        Calculates the final total as the subtotal minus any down payment.
        Parameters:
        stmt - the statement to calculate from
        Returns:
        the final total, never null