Capture annual fee due date at charge creation time

This commit is contained in:
ashok-conflux
2013-10-10 14:54:50 +05:30
parent 00bbc70623
commit 4f4da1d507
2 changed files with 12 additions and 3 deletions
@@ -116,7 +116,7 @@ public class Charge extends AbstractPersistable<Long> {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("charges");
if (isMonthlyFee()) {
if (isMonthlyFee() || isAnnualFee()) {
this.feeOnMonth = feeOnMonthDay.getMonthOfYear();
this.feeOnDay = feeOnMonthDay.getDayOfMonth();
this.feeInterval = feeInterval;
@@ -402,6 +402,10 @@ public class Charge extends AbstractPersistable<Long> {
return ChargeTimeType.fromInt(this.chargeTime).isMonthlyFee();
}
public boolean isAnnualFee() {
return ChargeTimeType.fromInt(this.chargeTime).isAnnualFee();
}
public MonthDay getFeeOnMonthDay(){
MonthDay feeOnMonthDay = null;
if (feeOnDay != null && feeOnMonth != null) {
@@ -92,14 +92,19 @@ public final class ChargeDefinitionCommandFromApiJsonDeserializer {
baseDataValidator.reset().parameter("active").value(active).notNull();
}
boolean isMonthlyFee = ChargeTimeType.fromInt(chargeTimeType).isMonthlyFee();
if(isMonthlyFee){
final ChargeTimeType ctt = ChargeTimeType.fromInt(chargeTimeType);
if(ctt.isMonthlyFee()){
final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed("feeOnMonthDay", element);
baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull();
final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed("feeInterval", element, Locale.getDefault());
baseDataValidator.reset().parameter("feeInterval").value(feeInterval).notNull().inMinMaxRange(1, 12);
}
if(ctt.isAnnualFee()){
final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed("feeOnMonthDay", element);
baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull();
}
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}