Capture annual fee due date at charge creation time
This commit is contained in:
+5
-1
@@ -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) {
|
||||
|
||||
+7
-2
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user