Search in sources :

Example 1 with BandedPriceFulfillmentOptionImpl

use of org.broadleafcommerce.core.order.fulfillment.domain.BandedPriceFulfillmentOptionImpl in project BroadleafCommerce by BroadleafCommerce.

the class BandedPriceFulfillmentTest method createPriceBands.

/**
 * Creates price bands with the given minimum amounts, results and result types. All of the lists should be the same size
 * @param minimumAmounts
 * @param resultAmounts
 * @param resultAmountTypes
 * @return
 */
protected BandedPriceFulfillmentOption createPriceBands(String[] minimumAmounts, String[] resultAmounts, FulfillmentBandResultAmountType[] resultAmountTypes) {
    if ((minimumAmounts.length != resultAmounts.length) || (resultAmounts.length != resultAmountTypes.length)) {
        throw new IllegalStateException("All lists should be the same length");
    }
    List<FulfillmentPriceBand> bands = new ArrayList<FulfillmentPriceBand>();
    for (int i = 0; i < minimumAmounts.length; i++) {
        FulfillmentPriceBand band = new FulfillmentPriceBandImpl();
        band.setRetailPriceMinimumAmount(new BigDecimal(minimumAmounts[i]));
        band.setResultAmount(new BigDecimal(resultAmounts[i]));
        band.setResultAmountType(resultAmountTypes[i]);
        bands.add(band);
    }
    BandedPriceFulfillmentOption option = new BandedPriceFulfillmentOptionImpl();
    option.setBands(bands);
    return option;
}
Also used : FulfillmentPriceBand(org.broadleafcommerce.core.order.fulfillment.domain.FulfillmentPriceBand) ArrayList(java.util.ArrayList) BandedPriceFulfillmentOption(org.broadleafcommerce.core.order.fulfillment.domain.BandedPriceFulfillmentOption) BandedPriceFulfillmentOptionImpl(org.broadleafcommerce.core.order.fulfillment.domain.BandedPriceFulfillmentOptionImpl) FulfillmentPriceBandImpl(org.broadleafcommerce.core.order.fulfillment.domain.FulfillmentPriceBandImpl) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 BandedPriceFulfillmentOption (org.broadleafcommerce.core.order.fulfillment.domain.BandedPriceFulfillmentOption)1 BandedPriceFulfillmentOptionImpl (org.broadleafcommerce.core.order.fulfillment.domain.BandedPriceFulfillmentOptionImpl)1 FulfillmentPriceBand (org.broadleafcommerce.core.order.fulfillment.domain.FulfillmentPriceBand)1 FulfillmentPriceBandImpl (org.broadleafcommerce.core.order.fulfillment.domain.FulfillmentPriceBandImpl)1