Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void validateForCreate(final String json) {
}

private DataValidatorBuilder getDataValidator(final List<ApiParameterError> dataValidationErrors) {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("financialactivityaccount");
return baseDataValidator;
return new DataValidatorBuilder(dataValidationErrors).resource("financialactivityaccount");
}

public void validateForUpdate(final String json) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
Expand Down Expand Up @@ -66,34 +68,41 @@ public class Charge extends AbstractPersistableCustom<Long> {
public static final String LOCALE_PARAM_NAME = "locale";
public static final String FEE_FREQUENCY_PARAM_NAME = "feeFrequency";

@Getter
@Column(name = "name", length = 100)
private String name;

@Getter
@Column(name = "amount", scale = 6, precision = 19, nullable = false)
private BigDecimal amount;

@Getter
@Column(name = "currency_code", length = 3)
private String currencyCode;

@Column(name = "charge_applies_to_enum", nullable = false)
private Integer chargeAppliesTo;

@Getter
@Column(name = "charge_time_enum", nullable = false)
private Integer chargeTimeType;

@Getter
@Column(name = "charge_calculation_enum")
private Integer chargeCalculation;

@Column(name = "charge_payment_mode_enum", nullable = true)
@Getter
@Column(name = "charge_payment_mode_enum")
private Integer chargePaymentMode;

@Column(name = "fee_on_day", nullable = true)
@Column(name = "fee_on_day")
private Integer feeOnDay;

@Column(name = "fee_interval", nullable = true)
@Getter
@Column(name = "fee_interval")
private Integer feeInterval;

@Column(name = "fee_on_month", nullable = true)
@Column(name = "fee_on_month")
private Integer feeOnMonth;

@Column(name = "is_penalty", nullable = false)
Expand All @@ -105,10 +114,12 @@ public class Charge extends AbstractPersistableCustom<Long> {
@Column(name = "is_deleted", nullable = false)
private boolean deleted = false;

@Column(name = "min_cap", scale = 6, precision = 19, nullable = true)
@Getter
@Column(name = "min_cap", scale = 6, precision = 19)
private BigDecimal minCap;

@Column(name = "max_cap", scale = 6, precision = 19, nullable = true)
@Getter
@Column(name = "max_cap", scale = 6, precision = 19)
private BigDecimal maxCap;

@Column(name = "fee_frequency", nullable = true)
Expand All @@ -117,26 +128,35 @@ public class Charge extends AbstractPersistableCustom<Long> {
@Column(name = "is_free_withdrawal", nullable = false)
private boolean enableFreeWithdrawal;

@Column(name = "free_withdrawal_charge_frequency", nullable = true)
@Column(name = "free_withdrawal_charge_frequency")
private Integer freeWithdrawalFrequency;

@Column(name = "restart_frequency", nullable = true)
@Getter
@Column(name = "restart_frequency")
private Integer restartFrequency;

@Column(name = "restart_frequency_enum", nullable = true)
@Getter
@Column(name = "restart_frequency_enum")
private Integer restartFrequencyEnum;

@Getter
@Column(name = "is_payment_type", nullable = false)
private boolean enablePaymentType;

@Setter
@Getter
@ManyToOne
@JoinColumn(name = "payment_type_id", nullable = false)
private PaymentType paymentType;

@Getter
@Setter
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "income_or_liability_account_id")
private GLAccount account;

@Getter
@Setter
@ManyToOne
@JoinColumn(name = "tax_group_id")
private TaxGroup taxGroup;
Expand Down Expand Up @@ -245,12 +265,9 @@ private Charge(final String name, final BigDecimal amount, final String currency
this.restartFrequencyEnum = restartFrequencyEnum.getValue();
}

if (enablePaymentType) {
if (paymentType != null) {

this.enablePaymentType = true;
this.paymentType = paymentType;
}
if (enablePaymentType && paymentType != null) {
this.enablePaymentType = true;
this.paymentType = paymentType;
}

} else if (isLoanCharge()) {
Expand Down Expand Up @@ -279,26 +296,6 @@ private Charge(final String name, final BigDecimal amount, final String currency
}
}

public String getName() {
return this.name;
}

public BigDecimal getAmount() {
return this.amount;
}

public String getCurrencyCode() {
return this.currencyCode;
}

public Integer getChargeTimeType() {
return this.chargeTimeType;
}

public Integer getChargeCalculation() {
return this.chargeCalculation;
}

public boolean isActive() {
return this.active;
}
Expand Down Expand Up @@ -351,14 +348,6 @@ public boolean isPercentageOfDisbursementAmount() {
return ChargeCalculationType.fromInt(this.chargeCalculation).isPercentageOfDisbursementAmount();
}

public BigDecimal getMinCap() {
return this.minCap;
}

public BigDecimal getMaxCap() {
return this.maxCap;
}

public boolean isEnableFreeWithdrawal() {
return this.enableFreeWithdrawal;
}
Expand All @@ -371,22 +360,6 @@ public Integer getFrequencyFreeWithdrawalCharge() {
return this.freeWithdrawalFrequency;
}

public Integer getRestartFrequency() {
return this.restartFrequency;
}

public Integer getRestartFrequencyEnum() {
return this.restartFrequencyEnum;
}

public PaymentType getPaymentType() {
return this.paymentType;
}

public void setPaymentType(PaymentType paymentType) {
this.paymentType = paymentType;
}

private Long getPaymentTypeId() {
Long paymentTypeId = null;
if (this.paymentType != null) {
Expand Down Expand Up @@ -450,11 +423,9 @@ public Map<String, Object> update(final JsonCommand command) {
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.loan");
}
} else if (isClientCharge()) {
if (!isAllowedLoanChargeTime()) {
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.client");
}
} else if (isClientCharge() && !isAllowedLoanChargeTime()) {
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.client");
}
}

Expand Down Expand Up @@ -647,7 +618,7 @@ public Map<String, Object> update(final JsonCommand command) {
}

/**
* Delete is a <i>soft delete</i>. Updates flag on charge so it wont appear in query/report results.
* Delete is a <i>soft delete</i>. Updates flag on charge so it won't appear in query/report results.
*
* Any fields with unique constraints and prepended with id of record.
*/
Expand Down Expand Up @@ -690,14 +661,6 @@ public ChargeData toData() {

}

public Integer getChargePaymentMode() {
return this.chargePaymentMode;
}

public Integer getFeeInterval() {
return this.feeInterval;
}

public boolean isMonthlyFee() {
return ChargeTimeType.fromInt(this.chargeTimeType).isMonthlyFee();
}
Expand Down Expand Up @@ -726,14 +689,6 @@ public Integer feeFrequency() {
return this.feeFrequency;
}

public GLAccount getAccount() {
return this.account;
}

public void setAccount(GLAccount account) {
this.account = account;
}

public Long getIncomeAccountId() {
Long incomeAccountId = null;
if (this.account != null) {
Expand All @@ -755,14 +710,6 @@ public boolean isDisbursementCharge() {
|| ChargeTimeType.fromInt(this.chargeTimeType).equals(ChargeTimeType.TRANCHE_DISBURSEMENT);
}

public TaxGroup getTaxGroup() {
return this.taxGroup;
}

public void setTaxGroup(TaxGroup taxGroup) {
this.taxGroup = taxGroup;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private String extractField(JsonNode node, String fieldName) {

private String extractValidationErrors(JsonNode rootNode) {
JsonNode errorsNode = rootNode.get("errors");
if (errorsNode != null && errorsNode.isArray() && errorsNode.size() > 0) {
if (errorsNode != null && errorsNode.isArray() && !errorsNode.isEmpty()) {
StringBuilder errors = new StringBuilder("Validation errors: ");
for (JsonNode error : errorsNode) {
String parameterName = extractField(error, "parameterName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,13 @@ private static String detectMediaType(String fileName) {
}
String ext = fileName.substring(dotPos + 1).toLowerCase();

switch (ext) {
case "jpg":
case "jpeg":
return "image/jpeg";
case "png":
return "image/png";
case "gif":
return "image/gif";
case "tif":
case "tiff":
return "image/tiff";
case "pdf":
return "application/pdf";
default:
return "application/octet-stream";
}
return switch (ext) {
case "jpg", "jpeg" -> "image/jpeg";
case "png" -> "image/png";
case "gif" -> "image/gif";
case "tif", "tiff" -> "image/tiff";
case "pdf" -> "application/pdf";
default -> "application/octet-stream";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,15 @@ public Object decode(Response response, Type type) throws IOException {
}

private boolean isApiResponseType(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType paramType = (ParameterizedType) type;
if (type instanceof ParameterizedType paramType) {
Type rawType = paramType.getRawType();
return rawType == ApiResponse.class;
}
return type == ApiResponse.class;
}

private Type getApiResponseInnerType(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType paramType = (ParameterizedType) type;
if (type instanceof ParameterizedType paramType) {
Type[] typeArgs = paramType.getActualTypeArguments();
if (typeArgs.length > 0) {
return typeArgs[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import java.util.HashMap;
import java.util.Map;
import lombok.Getter;

@Getter
public enum CacheType {

INVALID(0, "cacheType.invalid"), //
Expand Down Expand Up @@ -54,15 +56,7 @@ public static CacheType fromInt(final Integer value) {

@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}

public Integer getValue() {
return this.value;
}

public String getCode() {
return this.code;
return name().replace("_", " ");
}

public boolean isNoCache() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.HashSet;
import java.util.Set;
import lombok.Getter;

public final class CalendarConstants {

Expand All @@ -29,6 +30,7 @@ private CalendarConstants() {

public static final String CALENDAR_RESOURCE_NAME = "calendar";

@Getter
public enum CalendarSupportedParameters {

CALENDAR_ID("id"), //
Expand Down Expand Up @@ -80,12 +82,9 @@ public static Set<String> getAllValues() {

@Override
public String toString() {
return name().toString().replaceAll("_", " ");
return name().replace("_", " ");
}

public String getValue() {
return this.value;
}
}

}
Loading
Loading