Class StatementCalculator
- java.lang.Object
-
- com.palmer.billingstatementgenerator.models.statement.StatementCalculator
-
public final class StatementCalculator extends java.lang.ObjectStateless utility class for calculating financial totals from aStatement. All methods operate purely on the provided statement and have no side effects. Results are rounded to two decimal places usingRoundingMode.HALF_UP.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.math.BigDecimalcashAdvancesTotal(Statement stmt)Calculates the total for all selected cash advance items using their entered amounts.static java.math.BigDecimalfinalTotal(Statement stmt)Calculates the final total as the subtotal minus any down payment.static java.math.BigDecimalmerchandiseTotal(Statement stmt)Calculates the total for all selected merchandise items using their effective prices.static java.math.BigDecimalsalesTax(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.BigDecimalservicesTotal(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.BigDecimalspecialChargesTotal(Statement stmt)Calculates the total for all selected special charges using their effective prices.static java.math.BigDecimalsubtotal(Statement stmt)Calculates the subtotal as the sum of services, merchandise, special charges, cash advances, and sales tax.
-
-
-
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 withinPackage == trueare 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
-
-