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