Changed ChargeCalculationMethod to ChargeCalculationType.
This commit is contained in:
@@ -33,7 +33,7 @@ public class Charge extends AbstractAuditableCustom<AppUser, Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "charge_calculation_enum")
|
||||
private Integer chargeCalculationMethod;
|
||||
private Integer chargeCalculation;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "is_active", nullable = false)
|
||||
@@ -43,8 +43,8 @@ public class Charge extends AbstractAuditableCustom<AppUser, Long> {
|
||||
private boolean deleted = false;
|
||||
|
||||
public static Charge createNew(final String name, final BigDecimal amount, final String currencyCode,
|
||||
final ChargeAppliesTo chargeAppliesTo, final ChargeTimeType chargeTime, final ChargeCalculationMethod chargeCalculationMethod, final boolean active) {
|
||||
return new Charge(name, amount, currencyCode, chargeAppliesTo, chargeTime, chargeCalculationMethod, active);
|
||||
final ChargeAppliesTo chargeAppliesTo, final ChargeTimeType chargeTime, final ChargeCalculationType chargeCalculationType, final boolean active) {
|
||||
return new Charge(name, amount, currencyCode, chargeAppliesTo, chargeTime, chargeCalculationType, active);
|
||||
}
|
||||
|
||||
protected Charge() {
|
||||
@@ -53,13 +53,13 @@ public class Charge extends AbstractAuditableCustom<AppUser, Long> {
|
||||
|
||||
public Charge(final String name, final BigDecimal amount, final String currencyCode,
|
||||
final ChargeAppliesTo chargeAppliesTo, final ChargeTimeType chargeTime,
|
||||
final ChargeCalculationMethod chargeCalculationMethod, final boolean active) {
|
||||
final ChargeCalculationType chargeCalculationType, final boolean active) {
|
||||
this.name = name;
|
||||
this.amount = amount;
|
||||
this.currencyCode = currencyCode;
|
||||
this.chargeAppliesTo = chargeAppliesTo.getValue();
|
||||
this.chargeTime = chargeTime.getValue();
|
||||
this.chargeCalculationMethod = chargeCalculationMethod.getValue();
|
||||
this.chargeCalculation = chargeCalculationType.getValue();
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class Charge extends AbstractAuditableCustom<AppUser, Long> {
|
||||
}
|
||||
|
||||
if (command.isChargeCalculationTypeChanged()){
|
||||
this.chargeCalculationMethod = ChargeCalculationMethod.fromInt(command.getChargeCalculationType()).getValue();
|
||||
this.chargeCalculation = ChargeCalculationType.fromInt(command.getChargeCalculationType()).getValue();
|
||||
}
|
||||
|
||||
if (command.isActiveChanged()){
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
package org.mifosng.platform.charge.domain;
|
||||
|
||||
public enum ChargeCalculationMethod {
|
||||
public enum ChargeCalculationType {
|
||||
|
||||
INVALID(0, "chargeCalculationType.invalid"),
|
||||
FLAT(1, "chargeCalculationType.flat"),
|
||||
@@ -11,7 +11,7 @@ public enum ChargeCalculationMethod {
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private ChargeCalculationMethod(Integer value, String code) {
|
||||
private ChargeCalculationType(Integer value, String code) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
}
|
||||
@@ -24,25 +24,25 @@ public enum ChargeCalculationMethod {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static ChargeCalculationMethod fromInt(final Integer chargeCalculation){
|
||||
ChargeCalculationMethod chargeCalculationMethod = ChargeCalculationMethod.INVALID;
|
||||
public static ChargeCalculationType fromInt(final Integer chargeCalculation){
|
||||
ChargeCalculationType chargeCalculationType = ChargeCalculationType.INVALID;
|
||||
switch(chargeCalculation){
|
||||
case 1:
|
||||
chargeCalculationMethod = FLAT;
|
||||
chargeCalculationType = FLAT;
|
||||
break;
|
||||
case 2:
|
||||
chargeCalculationMethod = PERCENT_OF_AMOUNT;
|
||||
chargeCalculationType = PERCENT_OF_AMOUNT;
|
||||
break;
|
||||
case 3:
|
||||
chargeCalculationMethod = PERCENT_OF_AMOUNT_AND_INTEREST;
|
||||
chargeCalculationType = PERCENT_OF_AMOUNT_AND_INTEREST;
|
||||
break;
|
||||
case 4:
|
||||
chargeCalculationMethod = PERCENT_OF_INTEREST;
|
||||
chargeCalculationType = PERCENT_OF_INTEREST;
|
||||
break;
|
||||
default:
|
||||
chargeCalculationMethod = INVALID;
|
||||
chargeCalculationType = INVALID;
|
||||
break;
|
||||
}
|
||||
return chargeCalculationMethod;
|
||||
return chargeCalculationType;
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -2,7 +2,7 @@ package org.mifosng.platform.charge.service;
|
||||
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.charge.domain.ChargeAppliesTo;
|
||||
import org.mifosng.platform.charge.domain.ChargeCalculationMethod;
|
||||
import org.mifosng.platform.charge.domain.ChargeCalculationType;
|
||||
import org.mifosng.platform.charge.domain.ChargeTimeType;
|
||||
|
||||
public class ChargeEnumerations {
|
||||
@@ -42,26 +42,26 @@ public class ChargeEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData chargeCalculationType(final int id){
|
||||
return chargeCalculationType(ChargeCalculationMethod.fromInt(id));
|
||||
return chargeCalculationType(ChargeCalculationType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData chargeCalculationType(ChargeCalculationMethod type){
|
||||
public static EnumOptionData chargeCalculationType(ChargeCalculationType type){
|
||||
EnumOptionData optionData = null;
|
||||
switch (type){
|
||||
case FLAT:
|
||||
optionData = new EnumOptionData(ChargeCalculationMethod.FLAT.getValue().longValue(), ChargeCalculationMethod.FLAT.getCode(), "Flat");
|
||||
optionData = new EnumOptionData(ChargeCalculationType.FLAT.getValue().longValue(), ChargeCalculationType.FLAT.getCode(), "Flat");
|
||||
break;
|
||||
case PERCENT_OF_AMOUNT:
|
||||
optionData = new EnumOptionData(ChargeCalculationMethod.PERCENT_OF_AMOUNT.getValue().longValue(), ChargeCalculationMethod.PERCENT_OF_AMOUNT.getCode(), "% Amount");
|
||||
optionData = new EnumOptionData(ChargeCalculationType.PERCENT_OF_AMOUNT.getValue().longValue(), ChargeCalculationType.PERCENT_OF_AMOUNT.getCode(), "% Amount");
|
||||
break;
|
||||
case PERCENT_OF_AMOUNT_AND_INTEREST:
|
||||
optionData = new EnumOptionData(ChargeCalculationMethod.PERCENT_OF_AMOUNT_AND_INTEREST.getValue().longValue(),ChargeCalculationMethod.PERCENT_OF_AMOUNT_AND_INTEREST.getCode(), "% Loan Amount + Interest");
|
||||
optionData = new EnumOptionData(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST.getValue().longValue(), ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST.getCode(), "% Loan Amount + Interest");
|
||||
break;
|
||||
case PERCENT_OF_INTEREST:
|
||||
optionData = new EnumOptionData(ChargeCalculationMethod.PERCENT_OF_INTEREST.getValue().longValue(), ChargeCalculationMethod.PERCENT_OF_INTEREST.getCode(), "% Interest");
|
||||
optionData = new EnumOptionData(ChargeCalculationType.PERCENT_OF_INTEREST.getValue().longValue(), ChargeCalculationType.PERCENT_OF_INTEREST.getCode(), "% Interest");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(ChargeCalculationMethod.INVALID.getValue().longValue(), ChargeCalculationMethod.INVALID.getCode(), "Invalid");
|
||||
optionData = new EnumOptionData(ChargeCalculationType.INVALID.getValue().longValue(), ChargeCalculationType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
|
||||
+7
-7
@@ -4,7 +4,7 @@ import org.mifosng.platform.api.data.ChargeData;
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.charge.domain.ChargeAppliesTo;
|
||||
import org.mifosng.platform.charge.domain.ChargeCalculationMethod;
|
||||
import org.mifosng.platform.charge.domain.ChargeCalculationType;
|
||||
import org.mifosng.platform.charge.domain.ChargeTimeType;
|
||||
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
|
||||
import org.mifosng.platform.exceptions.ChargeNotFoundException;
|
||||
@@ -78,18 +78,18 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
||||
|
||||
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
|
||||
|
||||
List<EnumOptionData> allowedChargeCalculationMethodsOptions = Arrays.asList(
|
||||
chargeCalculationType(ChargeCalculationMethod.FLAT),
|
||||
chargeCalculationType(ChargeCalculationMethod.PERCENT_OF_AMOUNT),
|
||||
chargeCalculationType(ChargeCalculationMethod.PERCENT_OF_AMOUNT_AND_INTEREST),
|
||||
chargeCalculationType(ChargeCalculationMethod.PERCENT_OF_INTEREST)
|
||||
List<EnumOptionData> allowedChargeCalculationTypeOptions = Arrays.asList(
|
||||
chargeCalculationType(ChargeCalculationType.FLAT),
|
||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT),
|
||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST),
|
||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST)
|
||||
);
|
||||
|
||||
List<EnumOptionData> allowedChargeAppliesToOptions = Arrays.asList(chargeAppliesTo(ChargeAppliesTo.LOAN));
|
||||
|
||||
List<EnumOptionData> allowedChargeTimeOptions = Arrays.asList(chargeTimeType(ChargeTimeType.DISBURSEMENT));
|
||||
|
||||
return ChargeData.template(currencyOptions, allowedChargeCalculationMethodsOptions,
|
||||
return ChargeData.template(currencyOptions, allowedChargeCalculationTypeOptions,
|
||||
allowedChargeAppliesToOptions, allowedChargeTimeOptions);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -36,10 +36,10 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP
|
||||
|
||||
ChargeAppliesTo chargeAppliesTo = ChargeAppliesTo.fromInt(command.getChargeAppliesTo());
|
||||
ChargeTimeType chargeTimeType = ChargeTimeType.fromInt(command.getChargeTimeType());
|
||||
ChargeCalculationMethod chargeCalculationMethod = ChargeCalculationMethod.fromInt(command.getChargeCalculationType());
|
||||
ChargeCalculationType chargeCalculationType = ChargeCalculationType.fromInt(command.getChargeCalculationType());
|
||||
|
||||
Charge charge = Charge.createNew(command.getName(), command.getAmount(), command.getCurrencyCode(),
|
||||
chargeAppliesTo, chargeTimeType, chargeCalculationMethod, command.isActive());
|
||||
chargeAppliesTo, chargeTimeType, chargeCalculationType, command.isActive());
|
||||
|
||||
this.chargeRepository.saveAndFlush(charge);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user