FINERACT-2346: Minor SonarQube fixes

This commit is contained in:
Aman-Mittal
2025-10-15 10:05:25 +02:00
committed by Adam Saghy
parent 3b62d562a2
commit c50113a868
17 changed files with 171 additions and 148 deletions
@@ -51,7 +51,7 @@ public class AcmeBusinessStepDefinitions implements En {
});
When("/^The user retrieves the step service with step class (.*) and name (.*)$/", (String stepClass, String stepName) -> {
contextRunner.run((ctx) -> {
contextRunner.run(ctx -> {
this.businessStepService = ctx.getBean(COBBusinessStepService.class);
this.businessStep = ctx.getBean((Class<COBBusinessStep<Loan>>) Class.forName(stepClass));
@@ -64,7 +64,6 @@ public class AcmeBusinessStepDefinitions implements En {
Then("/^The step service should have a result$/", () -> {
assertThat(this.businessStep).isNotNull();
assertThat(this.result).isNotNull();
// log.warn(">>>>>>>>>>>>>>>>>> RESULT: {}", this.result);
});
}
}
@@ -57,10 +57,17 @@ import org.springframework.stereotype.Component;
@Path("/v1/glclosures")
@Component
@Tag(name = "Accounting Closure", description = "An accounting closure indicates that no more journal entries may be logged (or reversed) in the system, either manually or via the portfolio with an entry date prior to the defined closure date\n"
+ "\n" + "Field Descriptions\n" + "closingDate\n" + "The date for which the accounting closure is defined\n" + "officeId\n"
+ "The identifer of the branch for which accounting has been closed\n" + "comments\n"
+ "Description associated with an Accounting closure")
@Tag(name = "Accounting Closure", description = """
An accounting closure indicates that no more journal entries may be logged (or reversed) in the system, either manually or via the portfolio with an entry date prior to the defined closure date
Field Descriptions
closingDate
The date for which the accounting closure is defined
officeId
The identifer of the branch for which accounting has been closed
comments
Description associated with an Accounting closure
""")
@RequiredArgsConstructor
public class GLClosuresApiResource {
@@ -76,9 +83,11 @@ public class GLClosuresApiResource {
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "List Accounting closures", description = "Example Requests:\n" + "\n" + "glclosures")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = GLClosuresApiResourceSwagger.GetGlClosureResponse.class)))) })
@Operation(summary = "List Accounting closures", description = """
Example Requests:
glclosures""")
@ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = GLClosuresApiResourceSwagger.GetGlClosureResponse.class))))
public List<GLClosureData> retrieveAllClosures(@QueryParam("officeId") @Parameter(name = "officeId") final Long officeId) {
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
@@ -89,10 +98,14 @@ public class GLClosuresApiResource {
@Path("{glClosureId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Retrieve an Accounting Closure", description = "Example Requests:\n" + "\n" + "glclosures/1\n" + "\n" + "\n"
+ "/glclosures/1?fields=officeName,closingDate")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.GetGlClosureResponse.class))) })
@Operation(summary = "Retrieve an Accounting Closure", description = """
Example Requests:
glclosures/1
/glclosures/1?fields=officeName,closingDate""")
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.GetGlClosureResponse.class)))
public GLClosureData retreiveClosure(@PathParam("glClosureId") @Parameter(description = "glClosureId") final Long glClosureId,
@Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
@@ -127,8 +140,7 @@ public class GLClosuresApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Update an Accounting closure", description = "Once an accounting closure is created, only the comments associated with it may be edited")
@RequestBody(content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.PutGlClosuresRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.PutGlClosuresResponse.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.PutGlClosuresResponse.class)))
public CommandProcessingResult updateGLClosure(@PathParam("glClosureId") @Parameter(description = "glClosureId") final Long glClosureId,
@Parameter(hidden = true) GLClosureRequest glClosureRequest) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateGLClosure(glClosureId)
@@ -141,8 +153,7 @@ public class GLClosuresApiResource {
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Delete an accounting closure", description = "Note: Only the latest accounting closure associated with a branch may be deleted.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.DeleteGlClosuresResponse.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.DeleteGlClosuresResponse.class)))
public CommandProcessingResult deleteGLClosure(
@PathParam("glClosureId") @Parameter(description = "glclosureId") final Long glClosureId) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteGLClosure(glClosureId).build();
@@ -97,8 +97,11 @@ public class TellerApiResource {
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Create teller", description = "Mandatory Fields\n" + "Teller name, OfficeId, Description, Start Date, Status\n"
+ "Optional Fields\n" + "End Date")
@Operation(summary = "Create teller", description = """
Mandatory Fields
Teller name, OfficeId, Description, Start Date, Status
Optional Fields
End Date""")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersResponse.class))) })
@@ -185,9 +188,14 @@ public class TellerApiResource {
@Path("{tellerId}/cashiers")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Create Cashiers", description = "Mandatory Fields: \n"
+ "Cashier/staff, Fromm Date, To Date, Full Day or From time and To time\n" + "\n\n\n" + "Optional Fields: \n"
+ "Description/Notes")
@Operation(summary = "Create Cashiers", description = """
Mandatory Fields:\s
Cashier/staff, Fromm Date, To Date, Full Day or From time and To time
Optional Fields:\s
Description/Notes""")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersResponse.class))) })
@@ -59,6 +59,13 @@ import org.apache.fineract.portfolio.tax.domain.TaxGroup;
@Table(name = "m_charge", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "name") })
public class Charge extends AbstractPersistableCustom<Long> {
public static final String CHARGE_TIME_PARAM_NAME = "chargeTimeType";
public static final String CHARGE_CALCULATION_TYPE_PARAM_NAME = "chargeCalculationType";
public static final String FEE_ON_MONTH_DAY_PARAM_NAME = "feeOnMonthDay";
public static final String FEE_INTERVAL_PARAM_NAME = "feeInterval";
public static final String LOCALE_PARAM_NAME = "locale";
public static final String FEE_FREQUENCY_PARAM_NAME = "feeFrequency";
@Column(name = "name", length = 100)
private String name;
@@ -142,20 +149,20 @@ public class Charge extends AbstractPersistableCustom<Long> {
final String currencyCode = command.stringValueOfParameterNamed("currencyCode");
final ChargeAppliesTo chargeAppliesTo = ChargeAppliesTo.fromInt(command.integerValueOfParameterNamed("chargeAppliesTo"));
final ChargeTimeType chargeTimeType = ChargeTimeType.fromInt(command.integerValueOfParameterNamed("chargeTimeType"));
final ChargeTimeType chargeTimeType = ChargeTimeType.fromInt(command.integerValueOfParameterNamed(CHARGE_TIME_PARAM_NAME));
final ChargeCalculationType chargeCalculationType = ChargeCalculationType
.fromInt(command.integerValueOfParameterNamed("chargeCalculationType"));
.fromInt(command.integerValueOfParameterNamed(CHARGE_CALCULATION_TYPE_PARAM_NAME));
final Integer chargePaymentMode = command.integerValueOfParameterNamed("chargePaymentMode");
final ChargePaymentMode paymentMode = chargePaymentMode == null ? null : ChargePaymentMode.fromInt(chargePaymentMode);
final boolean penalty = command.booleanPrimitiveValueOfParameterNamed("penalty");
final boolean active = command.booleanPrimitiveValueOfParameterNamed("active");
final MonthDay feeOnMonthDay = command.extractMonthDayNamed("feeOnMonthDay");
final Integer feeInterval = command.integerValueOfParameterNamed("feeInterval");
final MonthDay feeOnMonthDay = command.extractMonthDayNamed(FEE_ON_MONTH_DAY_PARAM_NAME);
final Integer feeInterval = command.integerValueOfParameterNamed(FEE_INTERVAL_PARAM_NAME);
final BigDecimal minCap = command.bigDecimalValueOfParameterNamed("minCap");
final BigDecimal maxCap = command.bigDecimalValueOfParameterNamed("maxCap");
final Integer feeFrequency = command.integerValueOfParameterNamed("feeFrequency");
final Integer feeFrequency = command.integerValueOfParameterNamed(FEE_FREQUENCY_PARAM_NAME);
boolean enableFreeWithdrawalCharge = false;
enableFreeWithdrawalCharge = command.booleanPrimitiveValueOfParameterNamed("enableFreeWithdrawalCharge");
@@ -213,20 +220,20 @@ public class Charge extends AbstractPersistableCustom<Long> {
// TODO vishwas, this validation seems unnecessary as identical
// validation is performed in the write service
if (!isAllowedSavingsChargeTime()) {
baseDataValidator.reset().parameter("chargeTimeType").value(this.chargeTimeType)
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.savings");
}
// TODO vishwas, this validation seems unnecessary as identical
// validation is performed in the writeservice
if (!isAllowedSavingsChargeCalculationType()) {
baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation)
baseDataValidator.reset().parameter(CHARGE_CALCULATION_TYPE_PARAM_NAME).value(this.chargeCalculation)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.calculation.type.for.savings");
}
if (!(ChargeTimeType.fromInt(getChargeTimeType()).isWithdrawalFee()
|| ChargeTimeType.fromInt(getChargeTimeType()).isSavingsNoActivityFee())
&& ChargeCalculationType.fromInt(getChargeCalculation()).isPercentageOfAmount()) {
baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation)
baseDataValidator.reset().parameter(CHARGE_CALCULATION_TYPE_PARAM_NAME).value(this.chargeCalculation)
.failWithCodeNoParameterAddedToErrorCode(
"savings.charge.calculation.type.percentage.allowed.only.for.withdrawal.or.NoActivity");
}
@@ -257,7 +264,7 @@ public class Charge extends AbstractPersistableCustom<Long> {
// TODO vishwas, this validation seems unnecessary as identical
// validation is performed in the write service
if (!isAllowedLoanChargeTime()) {
baseDataValidator.reset().parameter("chargeTimeType").value(this.chargeTimeType)
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.loan");
}
}
@@ -414,39 +421,38 @@ public class Charge extends AbstractPersistableCustom<Long> {
if (command.isChangeInBigDecimalParameterNamed(amountParamName, this.amount)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountParamName, locale);
actualChanges.put(amountParamName, newValue);
actualChanges.put("locale", locale.getLanguage());
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.amount = newValue;
}
final String chargeTimeParamName = "chargeTimeType";
if (command.isChangeInIntegerParameterNamed(chargeTimeParamName, this.chargeTimeType)) {
final Integer newValue = command.integerValueOfParameterNamed(chargeTimeParamName);
actualChanges.put(chargeTimeParamName, newValue);
actualChanges.put("locale", locale.getLanguage());
if (command.isChangeInIntegerParameterNamed(CHARGE_TIME_PARAM_NAME, this.chargeTimeType)) {
final Integer newValue = command.integerValueOfParameterNamed(CHARGE_TIME_PARAM_NAME);
actualChanges.put(CHARGE_TIME_PARAM_NAME, newValue);
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.chargeTimeType = ChargeTimeType.fromInt(newValue).getValue();
if (isSavingsCharge()) {
if (!isAllowedSavingsChargeTime()) {
baseDataValidator.reset().parameter("chargeTimeType").value(this.chargeTimeType)
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.savings");
}
// if charge time is changed to monthly then validate for
// feeOnMonthDay and feeInterval
if (isMonthlyFee()) {
final MonthDay monthDay = command.extractMonthDayNamed("feeOnMonthDay");
baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull();
final MonthDay monthDay = command.extractMonthDayNamed(FEE_ON_MONTH_DAY_PARAM_NAME);
baseDataValidator.reset().parameter(FEE_ON_MONTH_DAY_PARAM_NAME).value(monthDay).notNull();
final Integer feeInterval = command.integerValueOfParameterNamed("feeInterval");
baseDataValidator.reset().parameter("feeInterval").value(feeInterval).notNull().inMinMaxRange(1, 12);
final Integer feeInterval = command.integerValueOfParameterNamed(FEE_INTERVAL_PARAM_NAME);
baseDataValidator.reset().parameter(FEE_INTERVAL_PARAM_NAME).value(feeInterval).notNull().inMinMaxRange(1, 12);
}
} else if (isLoanCharge()) {
if (!isAllowedLoanChargeTime()) {
baseDataValidator.reset().parameter("chargeTimeType").value(this.chargeTimeType)
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("chargeTimeType").value(this.chargeTimeType)
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.client");
}
}
@@ -507,29 +513,28 @@ public class Charge extends AbstractPersistableCustom<Long> {
throw new ChargeParameterUpdateNotSupportedException("charge.applies.to", errorMessage);
}
final String chargeCalculationParamName = "chargeCalculationType";
if (command.isChangeInIntegerParameterNamed(chargeCalculationParamName, this.chargeCalculation)) {
final Integer newValue = command.integerValueOfParameterNamed(chargeCalculationParamName);
actualChanges.put(chargeCalculationParamName, newValue);
actualChanges.put("locale", locale.getLanguage());
if (command.isChangeInIntegerParameterNamed(CHARGE_CALCULATION_TYPE_PARAM_NAME, this.chargeCalculation)) {
final Integer newValue = command.integerValueOfParameterNamed(CHARGE_CALCULATION_TYPE_PARAM_NAME);
actualChanges.put(CHARGE_CALCULATION_TYPE_PARAM_NAME, newValue);
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.chargeCalculation = ChargeCalculationType.fromInt(newValue).getValue();
if (isSavingsCharge()) {
if (!isAllowedSavingsChargeCalculationType()) {
baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation)
baseDataValidator.reset().parameter(CHARGE_CALCULATION_TYPE_PARAM_NAME).value(this.chargeCalculation)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.calculation.type.for.savings");
}
if (!(ChargeTimeType.fromInt(getChargeTimeType()).isWithdrawalFee()
|| ChargeTimeType.fromInt(getChargeTimeType()).isSavingsNoActivityFee())
&& ChargeCalculationType.fromInt(getChargeCalculation()).isPercentageOfAmount()) {
baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation)
baseDataValidator.reset().parameter(CHARGE_CALCULATION_TYPE_PARAM_NAME).value(this.chargeCalculation)
.failWithCodeNoParameterAddedToErrorCode(
"charge.calculation.type.percentage.allowed.only.for.withdrawal.or.noactivity");
}
} else if (isClientCharge()) {
if (!isAllowedClientChargeCalculationType()) {
baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation)
baseDataValidator.reset().parameter(CHARGE_CALCULATION_TYPE_PARAM_NAME).value(this.chargeCalculation)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.calculation.type.for.client");
}
}
@@ -541,47 +546,45 @@ public class Charge extends AbstractPersistableCustom<Long> {
if (command.isChangeInIntegerParameterNamed(paymentModeParamName, this.chargePaymentMode)) {
final Integer newValue = command.integerValueOfParameterNamed(paymentModeParamName);
actualChanges.put(paymentModeParamName, newValue);
actualChanges.put("locale", locale.getLanguage());
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.chargePaymentMode = ChargePaymentMode.fromInt(newValue).getValue();
}
}
if (command.hasParameter("feeOnMonthDay")) {
final MonthDay monthDay = command.extractMonthDayNamed("feeOnMonthDay");
final String actualValueEntered = command.stringValueOfParameterNamed("feeOnMonthDay");
if (command.hasParameter(FEE_ON_MONTH_DAY_PARAM_NAME)) {
final MonthDay monthDay = command.extractMonthDayNamed(FEE_ON_MONTH_DAY_PARAM_NAME);
final String actualValueEntered = command.stringValueOfParameterNamed(FEE_ON_MONTH_DAY_PARAM_NAME);
final Integer dayOfMonthValue = monthDay.getDayOfMonth();
if (!this.feeOnDay.equals(dayOfMonthValue)) {
actualChanges.put("feeOnMonthDay", actualValueEntered);
actualChanges.put("locale", locale.getLanguage());
actualChanges.put(FEE_ON_MONTH_DAY_PARAM_NAME, actualValueEntered);
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.feeOnDay = dayOfMonthValue;
}
final Integer monthOfYear = monthDay.getMonthValue();
if (!this.feeOnMonth.equals(monthOfYear)) {
actualChanges.put("feeOnMonthDay", actualValueEntered);
actualChanges.put("locale", locale.getLanguage());
actualChanges.put(FEE_ON_MONTH_DAY_PARAM_NAME, actualValueEntered);
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.feeOnMonth = monthOfYear;
}
}
final String feeInterval = "feeInterval";
if (command.isChangeInIntegerParameterNamed(feeInterval, this.feeInterval)) {
final Integer newValue = command.integerValueOfParameterNamed(feeInterval);
actualChanges.put(feeInterval, newValue);
actualChanges.put("locale", locale.getLanguage());
if (command.isChangeInIntegerParameterNamed(FEE_INTERVAL_PARAM_NAME, this.feeInterval)) {
final Integer newValue = command.integerValueOfParameterNamed(FEE_INTERVAL_PARAM_NAME);
actualChanges.put(FEE_INTERVAL_PARAM_NAME, newValue);
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.feeInterval = newValue;
}
final String feeFrequency = "feeFrequency";
if (command.isChangeInIntegerParameterNamed(feeFrequency, this.feeFrequency)) {
final Integer newValue = command.integerValueOfParameterNamed(feeFrequency);
actualChanges.put(feeFrequency, newValue);
actualChanges.put("locale", locale.getLanguage());
if (command.isChangeInIntegerParameterNamed(FEE_FREQUENCY_PARAM_NAME, this.feeFrequency)) {
final Integer newValue = command.integerValueOfParameterNamed(FEE_FREQUENCY_PARAM_NAME);
actualChanges.put(FEE_FREQUENCY_PARAM_NAME, newValue);
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.feeFrequency = newValue;
}
if (this.feeFrequency != null) {
baseDataValidator.reset().parameter("feeInterval").value(this.feeInterval).notNull();
baseDataValidator.reset().parameter(FEE_INTERVAL_PARAM_NAME).value(this.feeInterval).notNull();
}
final String penaltyParamName = "penalty";
@@ -603,14 +606,14 @@ public class Charge extends AbstractPersistableCustom<Long> {
if (command.isChangeInBigDecimalParameterNamed(minCapParamName, this.minCap)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(minCapParamName);
actualChanges.put(minCapParamName, newValue);
actualChanges.put("locale", locale.getLanguage());
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.minCap = newValue;
}
final String maxCapParamName = "maxCap";
if (command.isChangeInBigDecimalParameterNamed(maxCapParamName, this.maxCap)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(maxCapParamName);
actualChanges.put(maxCapParamName, newValue);
actualChanges.put("locale", locale.getLanguage());
actualChanges.put(LOCALE_PARAM_NAME, locale.getLanguage());
this.maxCap = newValue;
}
@@ -784,4 +787,5 @@ public class Charge extends AbstractPersistableCustom<Long> {
return Objects.hash(name, amount, currencyCode, chargeAppliesTo, chargeTimeType, chargeCalculation, chargePaymentMode, feeOnDay,
feeInterval, feeOnMonth, penalty, active, deleted, minCap, maxCap, feeFrequency, account, taxGroup);
}
}
@@ -30,25 +30,25 @@ public class LoanChargeCannotBeDeletedException extends AbstractPlatformDomainRu
LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE; //
public String errorMessage() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "This loan charge has been partially/completely paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "This loan charge has already been waived";
} else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
} else if (name().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
return "This charge cannot be deleted as the loan it is associated with is not in submitted and pending approval stage";
}
return name().toString();
return name();
}
public String errorCode() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "error.msg.loan.charge.already.paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "error.msg.loan.charge.already.waived";
} else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
} else if (name().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
return "error.msg.loan.charge.associated.loan.not.in.submitted.and.pending.approval.stage";
}
return name().toString();
return name();
}
}
@@ -32,34 +32,34 @@ public class LoanChargeCannotBePayedException extends AbstractPlatformDomainRule
CHARGE_NOT_PAYABLE; //
public String errorMessage() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "This loan charge has been completely paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "This loan charge has already been waived";
} else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) {
} else if (name().equalsIgnoreCase("LOAN_INACTIVE")) {
return "This loan charge can be payed as the loan associated with it is currently inactive";
} else if (name().toString().equalsIgnoreCase("CHARGE_NOT_ACCOUNT_TRANSFER")) {
} else if (name().equalsIgnoreCase("CHARGE_NOT_ACCOUNT_TRANSFER")) {
return "This loan charge can be payed as the charge payment mode is not account transfer";
} else if (name().toString().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) {
} else if (name().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) {
return "This loan charge is not Payable through account transfer";
}
return name().toString();
return name();
}
public String errorCode() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "error.msg.loan.charge.already.paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "error.msg.loan.charge.already.waived";
} else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) {
} else if (name().equalsIgnoreCase("LOAN_INACTIVE")) {
return "error.msg.loan.charge.associated.loan.inactive";
} else if (name().toString().equalsIgnoreCase("CHARGE_NOT_ACCOUNT_TRANSFER")) {
} else if (name().equalsIgnoreCase("CHARGE_NOT_ACCOUNT_TRANSFER")) {
return "error.msg.loan.charge.payment.mode.not.account.transfer";
} else if (name().toString().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) {
} else if (name().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) {
return "error.msg.loan.charge.payment.not.allowed.account.transfer";
}
return name().toString();
return name();
}
}
@@ -30,25 +30,25 @@ public class LoanChargeCannotBeUpdatedException extends AbstractPlatformDomainRu
LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE; //
public String errorMessage() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "This loan charge has been partially/completely paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "This loan charge has already been waived";
} else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
} else if (name().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
return "This charge cannot be updated as the loan it is associated with is not in submitted and pending approval stage";
}
return name().toString();
return name();
}
public String errorCode() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "error.msg.loan.charge.already.paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "error.msg.loan.charge.already.waived";
} else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
} else if (name().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) {
return "error.msg.loan.charge.associated.loan.not.in.submitted.and.pending.approval.stage";
}
return name().toString();
return name();
}
}
@@ -31,30 +31,30 @@ public class LoanChargeCannotBeWaivedException extends AbstractPlatformDomainRul
WAIVE_NOT_ALLOWED_FOR_CHARGE; //
public String errorMessage() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "This loan charge has been completely paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "This loan charge has already been waived";
} else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) {
} else if (name().equalsIgnoreCase("LOAN_INACTIVE")) {
return "This loan charge can be waived as the loan associated with it is currently inactive";
} else if (name().toString().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")) {
} else if (name().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")) {
return "This loan charge can be waived";
}
return name().toString();
return name();
}
public String errorCode() {
if (name().toString().equalsIgnoreCase("ALREADY_PAID")) {
if (name().equalsIgnoreCase("ALREADY_PAID")) {
return "error.msg.loan.charge.already.paid";
} else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) {
} else if (name().equalsIgnoreCase("ALREADY_WAIVED")) {
return "error.msg.loan.charge.already.waived";
} else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) {
} else if (name().equalsIgnoreCase("LOAN_INACTIVE")) {
return "error.msg.loan.charge.associated.loan.inactive";
} else if (name().toString().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")) {
} else if (name().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")) {
return "error.msg.loan.charge.waive.not.allowed";
}
return name().toString();
return name();
}
}
@@ -65,7 +65,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -126,7 +126,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -202,7 +202,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -249,7 +249,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -281,7 +281,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -330,7 +330,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -386,7 +386,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -424,7 +424,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -464,7 +464,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -529,7 +529,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -568,7 +568,7 @@ public final class AccountingConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -57,7 +57,7 @@ public enum AccountingRuleType {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public EnumOptionData toEnumOptionData() {
@@ -28,6 +28,8 @@ import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
public final class ApiParameterHelper {
private static final String GENERIC_RESULT_SET = "genericResultSet";
private ApiParameterHelper() {
}
@@ -126,14 +128,14 @@ public final class ApiParameterHelper {
public static boolean genericResultSet(final MultivaluedMap<String, String> queryParams) {
boolean genericResultSet = false;
if (queryParams.getFirst("genericResultSet") != null) {
final String genericResultSetValue = queryParams.getFirst("genericResultSet");
if (queryParams.getFirst(GENERIC_RESULT_SET) != null) {
final String genericResultSetValue = queryParams.getFirst(GENERIC_RESULT_SET);
genericResultSet = "true".equalsIgnoreCase(genericResultSetValue);
}
return genericResultSet;
}
public static boolean genericResultSetPassed(final MultivaluedMap<String, String> queryParams) {
return queryParams.getFirst("genericResultSet") != null;
return queryParams.getFirst(GENERIC_RESULT_SET) != null;
}
}
@@ -36,7 +36,7 @@ public enum PortfolioProductType {
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -285,17 +285,17 @@ public final class CalendarUtils {
NumberList nthDays = recur.getSetPosList();
Integer nthDay = null;
if (!nthDays.isEmpty()) {
nthDay = nthDays.get(0);
nthDay = nthDays.getFirst();
}
NumberList monthDays = recur.getMonthDayList();
Integer monthDay = null;
if (!monthDays.isEmpty()) {
monthDay = monthDays.get(0);
monthDay = monthDays.getFirst();
}
WeekDayList weekdays = recur.getDayList();
WeekDay weekDay = null;
if (!weekdays.isEmpty()) {
weekDay = weekdays.get(0);
weekDay = weekdays.getFirst();
}
if (nthDay != null && weekDay != null) {
NthDayType nthDayType = NthDayType.fromInt(nthDay);
@@ -61,11 +61,8 @@ public class InvestorAccountingHelper {
* check if an accounting closure has happened for this branch after the transaction Date
**/
GLClosure gLClosure = getLatestClosureByBranch(officeId);
if (gLClosure != null) {
if (!DateUtils.isAfter(transactionDate, gLClosure.getClosingDate())) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, gLClosure.getClosingDate(), null,
null);
}
if (gLClosure != null && !DateUtils.isAfter(transactionDate, gLClosure.getClosingDate())) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, gLClosure.getClosingDate(), null, null);
}
}
@@ -78,6 +78,8 @@ public class ExternalAssetOwnersApiResource {
private final LoanReadPlatformServiceCommon loanReadPlatformService;
private final ExternalAssetOwnersSearchApiDelegate delegate;
private static final String COMMAND_PARAM = "command";
private static final CommandHandlerRegistry<String, Long, String, CommandWrapper> COMMAND_HANDLER_REGISTRY = new CommandHandlerRegistry<>(
Map.of(CANCEL_COMMAND_VALUE, (id, json) -> new CommandWrapperBuilder().cancelTransactionByIdToExternalAssetOwner(id).build(),
INTERMEDIARY_SALE_COMMAND_VALUE,
@@ -95,12 +97,12 @@ public class ExternalAssetOwnersApiResource {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = ExternalAssetOwnersApiResourceSwagger.PostInitiateTransferResponse.class))),
@ApiResponse(responseCode = "403", description = "Transfer cannot be initiated") })
public CommandProcessingResult transferRequestWithLoanId(@PathParam("loanId") final Long loanId,
@QueryParam("command") @Parameter(description = "command") final String commandParam,
@QueryParam(COMMAND_PARAM) @Parameter(description = COMMAND_PARAM) final String commandParam,
@Parameter(hidden = true) ExternalAssetOwnerRequest assetOwnerReq) {
platformUserRightsContext.isAuthenticated();
final String serializedAssetRequest = postApiJsonSerializerService.serialize(assetOwnerReq);
final CommandWrapper commandRequest = COMMAND_HANDLER_REGISTRY.execute(commandParam, loanId, serializedAssetRequest,
new UnrecognizedQueryParamException("command", commandParam));
new UnrecognizedQueryParamException(COMMAND_PARAM, commandParam));
return this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
}
@@ -113,13 +115,13 @@ public class ExternalAssetOwnersApiResource {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = ExternalAssetOwnersApiResourceSwagger.PostInitiateTransferResponse.class))),
@ApiResponse(responseCode = "403", description = "Transfer cannot be initiated") })
public CommandProcessingResult transferRequestWithLoanExternalId(@PathParam("loanExternalId") final String externalLoanId,
@QueryParam("command") @Parameter(description = "command") final String commandParam,
@QueryParam(COMMAND_PARAM) @Parameter(description = COMMAND_PARAM) final String commandParam,
@Parameter(hidden = true) ExternalAssetOwnerRequest assetOwnerReq) {
platformUserRightsContext.isAuthenticated();
final Long loanId = loanReadPlatformService.getLoanIdByLoanExternalId(externalLoanId);
final String serializedAssetRequest = postApiJsonSerializerService.serialize(assetOwnerReq);
final CommandWrapper commandRequest = COMMAND_HANDLER_REGISTRY.execute(commandParam, loanId, serializedAssetRequest,
new UnrecognizedQueryParamException("command", commandParam));
new UnrecognizedQueryParamException(COMMAND_PARAM, commandParam));
return this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
}
@@ -132,12 +134,12 @@ public class ExternalAssetOwnersApiResource {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = ExternalAssetOwnersApiResourceSwagger.PostInitiateTransferResponse.class))),
@ApiResponse(responseCode = "403", description = "Transfer cannot be initiated") })
public CommandProcessingResult transferRequestWithId(@PathParam("id") final Long id,
@QueryParam("command") @Parameter(description = "command") final String commandParam,
@QueryParam(COMMAND_PARAM) @Parameter(description = COMMAND_PARAM) final String commandParam,
@Parameter(hidden = true) ExternalAssetOwnerRequest assetOwnerReq) {
platformUserRightsContext.isAuthenticated();
final String serializedAssetRequest = postApiJsonSerializerService.serialize(assetOwnerReq);
final CommandWrapper commandRequest = COMMAND_HANDLER_REGISTRY.execute(commandParam, id, serializedAssetRequest,
new UnrecognizedQueryParamException("command", commandParam));
new UnrecognizedQueryParamException(COMMAND_PARAM, commandParam));
return this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
}
@@ -149,13 +151,13 @@ public class ExternalAssetOwnersApiResource {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = ExternalAssetOwnersApiResourceSwagger.PostInitiateTransferResponse.class))),
@ApiResponse(responseCode = "403", description = "Transfer cannot be initiated") })
public CommandProcessingResult transferRequestWithId(@PathParam("externalId") final String externalId,
@QueryParam("command") @Parameter(description = "command") final String commandParam,
@QueryParam(COMMAND_PARAM) @Parameter(description = COMMAND_PARAM) final String commandParam,
@Parameter(hidden = true) ExternalAssetOwnerRequest assetOwnerReq) {
platformUserRightsContext.isAuthenticated();
final Long id = externalAssetOwnersReadService.retrieveLastTransferIdByExternalId(new ExternalId(externalId));
final String serializedAssetRequest = postApiJsonSerializerService.serialize(assetOwnerReq);
final CommandWrapper commandRequest = COMMAND_HANDLER_REGISTRY.execute(commandParam, id, serializedAssetRequest,
new UnrecognizedQueryParamException("command", commandParam));
new UnrecognizedQueryParamException(COMMAND_PARAM, commandParam));
return this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
}
@@ -53,7 +53,7 @@ public final class CollateralApiConstants {
@Override
public String toString() {
return name().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -2826,10 +2826,10 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
private Predicate<LoanRepaymentScheduleInstallment> getFilterPredicate(PaymentAllocationType paymentAllocationType,
MonetaryCurrency currency) {
return switch (paymentAllocationType.getAllocationType()) {
case PENALTY -> (p) -> p.getPenaltyChargesOutstanding(currency).isGreaterThanZero();
case FEE -> (p) -> p.getFeeChargesOutstanding(currency).isGreaterThanZero();
case INTEREST -> (p) -> p.getInterestOutstanding(currency).isGreaterThanZero();
case PRINCIPAL -> (p) -> p.getPrincipalOutstanding(currency).isGreaterThanZero();
case PENALTY -> p -> p.getPenaltyChargesOutstanding(currency).isGreaterThanZero();
case FEE -> p -> p.getFeeChargesOutstanding(currency).isGreaterThanZero();
case INTEREST -> p -> p.getInterestOutstanding(currency).isGreaterThanZero();
case PRINCIPAL -> p -> p.getPrincipalOutstanding(currency).isGreaterThanZero();
};
}