public class Helper
extends java.lang.Object
| Constructor and Description |
|---|
Helper() |
| Modifier and Type | Method and Description |
|---|---|
protected static java.text.DecimalFormat |
adjustDigits(java.text.DecimalFormat format,
Currency currency)
Adjusts
DecimalFormat's fraction digits according to given Currency. |
protected static java.text.DecimalFormat |
adjustSymbol(java.text.DecimalFormat format,
Currency currency)
Adjusts
DecimalFormat's symbol according to given Currency. |
static void |
adjustUnitPrices(SessionContext ctx,
PromotionEvaluationContext promoContext,
java.util.List<PromotionOrderEntryConsumed> consumedEntries,
double targetTotal,
double originalTotal)
Adjust the unit prices of the PromotionOrderEntryConsumed items specified to match the target total
Applies unit price adjustments to the PromotionOrderEntryConsumed items to take the total value of the items from
the originalTotal to the targetTotal specified.
|
static java.util.Date |
buildDateForYear(int year)
Create a Date for the first day of the specified year.
|
protected static java.math.BigDecimal |
calculateOrderEntryAdjustedTotal(SessionContext ctx,
Currency currency,
java.util.List<PromotionOrderEntryConsumed> entries)
Helper method to calculate the sum of the AdjustedEntryPrice for each of the PromotionOrderEntryConsumed items.
|
static java.lang.String |
dumpOrder(SessionContext ctx,
AbstractOrder order)
Method to dump an order and its entries into a string.
|
protected static void |
dumpOrder(SessionContext ctx,
AbstractOrder order,
java.lang.StringBuilder builder) |
protected static void |
dumpOrderEntry(SessionContext ctx,
AbstractOrderEntry orderEntry,
java.lang.StringBuilder builder) |
static DiscountValue |
findGlobalDiscountValue(SessionContext ctx,
AbstractOrder order,
java.lang.String discountValueCode)
Find a global discount value with specified Code
|
static java.lang.String |
formatCurrencyAmount(SessionContext ctx,
java.util.Locale locale,
Currency currency,
double amount)
Format an amount in a currency for a locale.
|
static Product |
getBaseProduct(SessionContext ctx,
Product product)
Return the base product for the product specified.
|
static java.util.List<Product> |
getBaseProducts(SessionContext ctx,
Product product)
This is a recursive variant of the method above.
|
protected static void |
getBaseProducts(SessionContext ctx,
Product product,
java.util.List<Product> result)
Internal recursive method to get all base products of a given product.
|
static java.util.Date |
getDateNowRoundedToMinute()
returns a
Date of the current minute to assure that queries can be cached for up to 1 minute. |
protected static java.math.BigDecimal |
getSmallestCurrencyUnit(SessionContext ctx,
Currency currency)
Get the smallest value that can be represented as a whole unit in the specified currency.
|
static java.lang.String |
join(java.util.Collection items)
Join collection of objects together to form a delimited string
|
static java.lang.String |
join(java.util.Collection items,
java.lang.String delimiter)
Join collection of objects together to form a delimited string
|
static java.math.BigDecimal |
roundCurrencyValue(SessionContext ctx,
Currency currency,
java.math.BigDecimal amount)
Round the specified amount to the nearest whole unit in the specified currency.
|
static java.math.BigDecimal |
roundCurrencyValue(SessionContext ctx,
Currency currency,
double amount)
Round the specified amount to the nearest whole unit in the specified currency.
|
public static java.util.Date buildDateForYear(int year)
year - the yearpublic static java.lang.String formatCurrencyAmount(SessionContext ctx, java.util.Locale locale, Currency currency, double amount)
ctx - the hybris contextlocale - the java locale that the amount should be rendered incurrency - the hybris currency for the amountamount - the valueprotected static java.text.DecimalFormat adjustDigits(java.text.DecimalFormat format,
Currency currency)
DecimalFormat's fraction digits according to given Currency.protected static java.text.DecimalFormat adjustSymbol(java.text.DecimalFormat format,
Currency currency)
DecimalFormat's symbol according to given Currency.protected static java.math.BigDecimal getSmallestCurrencyUnit(SessionContext ctx, Currency currency)
ctx - the hybris contextcurrency - the hybris currencypublic static java.math.BigDecimal roundCurrencyValue(SessionContext ctx, Currency currency, java.math.BigDecimal amount)
ctx - the hybris contextcurrency - the hybris currencyamount - the amountpublic static java.math.BigDecimal roundCurrencyValue(SessionContext ctx, Currency currency, double amount)
ctx - the hybris contextcurrency - the hybris currencyamount - the amountpublic static void adjustUnitPrices(SessionContext ctx, PromotionEvaluationContext promoContext, java.util.List<PromotionOrderEntryConsumed> consumedEntries, double targetTotal, double originalTotal)
ctx - the hybris contextpromoContext - the promotion evaluation contextconsumedEntries - the list of consumed entriestargetTotal - the target total value for the consumed entriesoriginalTotal - the current total value for the consumed entriesprotected static java.math.BigDecimal calculateOrderEntryAdjustedTotal(SessionContext ctx, Currency currency, java.util.List<PromotionOrderEntryConsumed> entries)
ctx - the hybris contextcurrency - the hybris currencyentries - the list of PromotionOrderEntryConsumed items to sumpublic static Product getBaseProduct(SessionContext ctx, Product product)
VariantProduct and the result of
GeneratedVariantProduct.getBaseProduct() if it is.ctx - The hybris contextproduct - The product to get the base product forpublic static java.util.List<Product> getBaseProducts(SessionContext ctx, Product product)
protected static void getBaseProducts(SessionContext ctx, Product product, java.util.List<Product> result)
ctx - product - result - public static DiscountValue findGlobalDiscountValue(SessionContext ctx, AbstractOrder order, java.lang.String discountValueCode)
ctx - the hybris contextorder - the order to lookup the discounts ondiscountValueCode - the code for the discount to findpublic static java.lang.String dumpOrder(SessionContext ctx, AbstractOrder order)
ctx - the hybris contextorder - the order to dumpprotected static void dumpOrder(SessionContext ctx, AbstractOrder order, java.lang.StringBuilder builder)
protected static void dumpOrderEntry(SessionContext ctx, AbstractOrderEntry orderEntry, java.lang.StringBuilder builder)
public static java.lang.String join(java.util.Collection items)
items - the collection of items to join togetherpublic static java.lang.String join(java.util.Collection items,
java.lang.String delimiter)
items - the collection of items to join togetherdelimiter - the delimiter to place between the itemspublic static java.util.Date getDateNowRoundedToMinute()
Date of the current minute to assure that queries can be cached for up to 1 minute.Copyright © 2018 SAP SE. All Rights Reserved.