public interface RateTypeHandler<T,R extends RateParameters,D extends RateParametersDTO>
| Modifier and Type | Field and Description |
|---|---|
static int |
RATE_SCALE
This scale is used for calculations; it is not used for storage.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyIncomingTransfer(org.cyclos.impl.banking.RatesData accountRates,
Transfer transfer)
Applies the incoming transfer.
|
void |
calculateFromRates(org.cyclos.impl.banking.FromRatesData rates,
Account fromAccount,
TransferType transferType,
java.math.BigDecimal amount)
Adapts the from account rates after it has been retrieved from the account, and adapts the fields to
specific additional rate rules.
|
void |
complete(org.cyclos.impl.banking.RatesData rates)
Completes the ratesData by calculating all missing fields of the rate (aRate, raw rate field).
|
T |
convert(java.math.BigDecimal rate,
java.util.Date date)
Converts the nominal rate (as a BigDecimal) to the raw value
|
java.math.BigDecimal |
convert(T rawRate,
java.util.Date date)
Converts the stored rawRate to the actual rate as a BigDecimal.
|
void |
copy(HasRates source,
HasRates destination)
Copies the rate field from source to destination
|
java.math.BigDecimal |
getCreationValue(Currency currency,
java.util.Date date)
Gets the creation value of the rate, that is, the value which is assigned for this rate at unit creation.
|
java.util.Date |
getEnableDate(Currency currency,
java.util.Date requestedDate)
Gets the earliest date of first enabling the rate.
|
T |
getNullSafeRawRate(RatedEntity entity,
Currency currency,
java.util.Date date)
Gets the rawRate from the entity in a null-safe way.
|
R |
getRateParameters(Currency currency)
Gets the RateParameters from the Currency by simply calling the getter.
|
R |
getRateParameters(java.lang.Long currencyId,
java.util.Date date)
Gets the RateParameters at a certain time by querying the db.
|
D |
getRateParametersDTO(CurrencyDTO currencyDTO)
Gets the RateParametersDTO of the CurrencyDTO
|
RateType |
getRateType()
Returns the rate type being handled
|
boolean |
isEnabled(java.lang.Long currencyId,
java.util.Date date)
Checks if the rate is enabled on the given date
|
boolean |
isVisible(Account account,
java.util.Date date,
RateVisibility visibility)
Determines if the rate is visible, depending on the visibility param.
|
boolean |
isVisibleToUser(java.lang.Long currencyId,
java.util.Date date)
Returns true if the rate is visible to the user on the given date.
|
void |
nullAllAccountRates(Currency currency)
Sets all rates on all accounts explicitly to null
(for the actual rate type belonging to this RateTypeHandler).
|
void |
resolveValidator(org.cyclos.impl.utils.validation.Validator validator,
CurrencyDTO dto)
Resolves the validator for the RateParameters as nested validator for CurrencyDTO.
|
void |
setRate(HasRates destination,
java.math.BigDecimal rate)
Sets the rate to the destination object
|
void |
setRawRate(RatedEntity destination,
T rawRate)
Sets the rawRate to the desitnation object.
|
void |
toEntity(Currency entity,
D dto)
Sets the rateParameters from the dto to the entity.
|
static final int RATE_SCALE
void applyIncomingTransfer(org.cyclos.impl.banking.RatesData accountRates,
Transfer transfer)
accountRates - a RatesVO with the present rates of the account on which the transfer is received. Also
the virtualRatedBalance must be set on this. This parameter will be updated with the new merged rate value.transfer - The transfer which should be merged.void calculateFromRates(org.cyclos.impl.banking.FromRatesData rates,
Account fromAccount,
TransferType transferType,
java.math.BigDecimal amount)
rates - - the rates as retrieved by requesting the rates from the from account, without considering the
balance or
the transfer type.fromAccount - transferType - amount - void complete(org.cyclos.impl.banking.RatesData rates)
T convert(java.math.BigDecimal rate, java.util.Date date)
rate - the input rate as a BigDecimaldate - the date at which this rate is valid. If null, current date/time is used.java.math.BigDecimal convert(T rawRate, java.util.Date date)
rawRate - the raw rate as a java.util.Datedate - The java.util.Date at which this actual rate is requested. If null, now() is used.void copy(HasRates source, HasRates destination)
java.math.BigDecimal getCreationValue(Currency currency, java.util.Date date)
java.util.Date getEnableDate(Currency currency, java.util.Date requestedDate)
currency - - rates are set on this currencyrequestedDate - - the returned date and the requestedDate belong to the same rate enabling period without
interrupt.
However, rateParameters may have changed during that period.T getNullSafeRawRate(RatedEntity entity, Currency currency, java.util.Date date)
entity - the entity from which the raw rate is readcurrency - is only used in case the entity has a null rate. In that
case the init value is looked up on the entity.date - is only used in case the entity has a null rate. If null, the
present date is used (now).R getRateParameters(Currency currency)
R getRateParameters(java.lang.Long currencyId, java.util.Date date)
currencyId - date - if null, present datetime is used.D getRateParametersDTO(CurrencyDTO currencyDTO)
RateType getRateType()
boolean isEnabled(java.lang.Long currencyId,
java.util.Date date)
boolean isVisible(Account account, java.util.Date date, RateVisibility visibility)
boolean isVisibleToUser(java.lang.Long currencyId,
java.util.Date date)
void nullAllAccountRates(Currency currency)
currency - void resolveValidator(org.cyclos.impl.utils.validation.Validator validator,
CurrencyDTO dto)
validator - the resolved validator is assigned as nested validator to this parameters.dto - void setRate(HasRates destination, java.math.BigDecimal rate)
void setRawRate(RatedEntity destination, T rawRate)