FINERACT-1971: Minor bug-fixes and enhancements

This commit is contained in:
jmarta
2023-09-28 18:11:29 +02:00
committed by Adam Saghy
parent 3f088e9c2a
commit f7f41d3e3c
20 changed files with 228 additions and 327 deletions
@@ -177,11 +177,11 @@ public class CommandStrategyProvider {
commandStrategies.put( commandStrategies.put(
CommandContext.resource("v1\\/loans\\/" + NUMBER_REGEX + "\\/transactions\\/" + NUMBER_REGEX + OPTIONAL_COMMAND_PARAM_REGEX) CommandContext.resource("v1\\/loans\\/" + NUMBER_REGEX + "\\/transactions\\/" + NUMBER_REGEX + OPTIONAL_COMMAND_PARAM_REGEX)
.method(POST).build(), .method(POST).build(),
"adjustTransactionCommandStrategy"); "adjustLoanTransactionCommandStrategy");
commandStrategies.put( commandStrategies.put(
CommandContext.resource("v1\\/loans\\/external-id\\/" + UUID_PARAM_REGEX + "\\/transactions\\/external-id\\/" CommandContext.resource("v1\\/loans\\/external-id\\/" + UUID_PARAM_REGEX + "\\/transactions\\/external-id\\/"
+ UUID_PARAM_REGEX + OPTIONAL_COMMAND_PARAM_REGEX).method(POST).build(), + UUID_PARAM_REGEX + OPTIONAL_COMMAND_PARAM_REGEX).method(POST).build(),
"adjustTransactionByExternalIdCommandStrategy"); "adjustLoanTransactionByExternalIdCommandStrategy");
commandStrategies.put(CommandContext.resource("v1\\/clients\\/" + NUMBER_REGEX + "\\?command=activate").method(POST).build(), commandStrategies.put(CommandContext.resource("v1\\/clients\\/" + NUMBER_REGEX + "\\?command=activate").method(POST).build(),
"activateClientCommandStrategy"); "activateClientCommandStrategy");
commandStrategies.put(CommandContext.resource("v1\\/loans\\/" + NUMBER_REGEX + "\\?command=approve").method(POST).build(), commandStrategies.put(CommandContext.resource("v1\\/loans\\/" + NUMBER_REGEX + "\\?command=approve").method(POST).build(),
@@ -196,9 +196,11 @@ public class CommandStrategyProvider {
"approveLoanRescheduleCommandStrategy"); "approveLoanRescheduleCommandStrategy");
commandStrategies.put( commandStrategies.put(
CommandContext.resource("v1\\/loans\\/" + NUMBER_REGEX + "\\/transactions\\/" + NUMBER_REGEX).method(GET).build(), CommandContext.resource("v1\\/loans\\/" + NUMBER_REGEX + "\\/transactions\\/" + NUMBER_REGEX).method(GET).build(),
"getTransactionByIdCommandStrategy"); "getLoanTransactionByIdCommandStrategy");
commandStrategies.put(CommandContext.resource("v1\\/loans\\/external-id\\/" + UUID_PARAM_REGEX + "\\/transactions\\/external-id\\/" commandStrategies.put(
+ UUID_PARAM_REGEX + OPTIONAL_QUERY_PARAM_REGEX).method(GET).build(), "getTransactionByExternalIdCommandStrategy"); CommandContext.resource("v1\\/loans\\/external-id\\/" + UUID_PARAM_REGEX + "\\/transactions\\/external-id\\/"
+ UUID_PARAM_REGEX + OPTIONAL_QUERY_PARAM_REGEX).method(GET).build(),
"getLoanTransactionByExternalIdCommandStrategy");
commandStrategies.put(CommandContext.resource("v1\\/datatables\\/" + ALPHANUMBERIC_WITH_UNDERSCORE_REGEX + "\\/" + NUMBER_REGEX) commandStrategies.put(CommandContext.resource("v1\\/datatables\\/" + ALPHANUMBERIC_WITH_UNDERSCORE_REGEX + "\\/" + NUMBER_REGEX)
.method(POST).build(), "createDatatableEntryCommandStrategy"); .method(POST).build(), "createDatatableEntryCommandStrategy");
commandStrategies.put(CommandContext commandStrategies.put(CommandContext
@@ -18,6 +18,8 @@
*/ */
package org.apache.fineract.batch.command.internal; package org.apache.fineract.batch.command.internal;
import static org.apache.http.HttpStatus.SC_NOT_IMPLEMENTED;
import jakarta.ws.rs.core.UriInfo; import jakarta.ws.rs.core.UriInfo;
import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.command.CommandStrategy;
import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchRequest;
@@ -35,15 +37,8 @@ public class UnknownCommandStrategy implements CommandStrategy {
@Override @Override
public BatchResponse execute(BatchRequest batchRequest, @SuppressWarnings("unused") UriInfo uriInfo) { public BatchResponse execute(BatchRequest batchRequest, @SuppressWarnings("unused") UriInfo uriInfo) {
return new BatchResponse().setRequestId(batchRequest.getRequestId()).setStatusCode(SC_NOT_IMPLEMENTED)
final BatchResponse batchResponse = new BatchResponse(); .setBody("Resource with method " + batchRequest.getMethod() + " and relativeUrl " + batchRequest.getRelativeUrl()
+ " doesn't exist");
batchResponse.setRequestId(batchRequest.getRequestId());
batchResponse.setStatusCode(501);
batchResponse.setBody("Resource with method " + batchRequest.getMethod() + " and relativeUrl " + batchRequest.getRelativeUrl()
+ " doesn't exist");
return batchResponse;
} }
} }
@@ -128,7 +128,7 @@ public class CommandProcessingResultBuilder {
} }
public CommandProcessingResultBuilder setRollbackTransaction(final boolean rollbackTransaction) { public CommandProcessingResultBuilder setRollbackTransaction(final boolean rollbackTransaction) {
this.rollbackTransaction = this.rollbackTransaction || rollbackTransaction; this.rollbackTransaction |= rollbackTransaction;
return this; return this;
} }
File diff suppressed because it is too large Load Diff
@@ -25,6 +25,7 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.time.LocalDate; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.staff.domain.Staff; import org.apache.fineract.organisation.staff.domain.Staff;
@Entity @Entity
@@ -72,16 +73,16 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
this.endDate = endDate; this.endDate = endDate;
} }
public boolean matchesStartDateOf(final LocalDate matchingDate) {
return getStartDate().isEqual(matchingDate);
}
public LocalDate getStartDate() { public LocalDate getStartDate() {
return this.startDate; return this.startDate;
} }
public boolean hasStartDateBefore(final LocalDate matchingDate) { public boolean matchesStartDateOf(final LocalDate matchingDate) {
return matchingDate.isBefore(getStartDate()); return DateUtils.isEqual(matchingDate, getStartDate());
}
public boolean isBeforeStartDate(final LocalDate matchingDate) {
return DateUtils.isBefore(matchingDate, getStartDate());
} }
public boolean isCurrentRecord() { public boolean isCurrentRecord() {
@@ -95,7 +96,7 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
* @return * @return
*/ */
public boolean isEndDateAfter(final LocalDate compareDate) { public boolean isEndDateAfter(final LocalDate compareDate) {
return this.endDate.isAfter(compareDate); return DateUtils.isAfter(this.endDate, compareDate);
} }
public LocalDate getEndDate() { public LocalDate getEndDate() {
@@ -31,6 +31,7 @@ import java.time.LocalDate;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom; import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks;
@@ -625,7 +626,7 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
} }
public boolean isOverdueOn(final LocalDate date) { public boolean isOverdueOn(final LocalDate date) {
return getDueDate().isBefore(date); return DateUtils.isAfter(date, getDueDate());
} }
public void updateChargePortion(final Money feeChargesDue, final Money feeChargesWaived, final Money feeChargesWrittenOff, public void updateChargePortion(final Money feeChargesDue, final Money feeChargesWaived, final Money feeChargesWrittenOff,
@@ -665,11 +666,11 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
} }
private boolean isInAdvance(final LocalDate transactionDate) { private boolean isInAdvance(final LocalDate transactionDate) {
return transactionDate.isBefore(getDueDate()); return DateUtils.isBefore(transactionDate, getDueDate());
} }
private boolean isLatePayment(final LocalDate transactionDate) { private boolean isLatePayment(final LocalDate transactionDate) {
return transactionDate.isAfter(getDueDate()); return DateUtils.isAfter(transactionDate, getDueDate());
} }
private void checkIfRepaymentPeriodObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) { private void checkIfRepaymentPeriodObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) {
@@ -928,6 +929,11 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
return (this.installmentNumber == 1); return (this.installmentNumber == 1);
} }
public boolean isInPeriod(LocalDate date) {
return (isFirstPeriod() ? !DateUtils.isBefore(date, getFromDate()) : DateUtils.isAfter(date, getFromDate()))
&& !DateUtils.isAfter(date, getDueDate());
}
public Set<LoanTransactionToRepaymentScheduleMapping> getLoanTransactionToRepaymentScheduleMappings() { public Set<LoanTransactionToRepaymentScheduleMapping> getLoanTransactionToRepaymentScheduleMappings() {
return this.loanTransactionToRepaymentScheduleMappings; return this.loanTransactionToRepaymentScheduleMappings;
} }
@@ -45,7 +45,7 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class AdjustTransactionByExternalIdCommandStrategy implements CommandStrategy { public class AdjustLoanTransactionByExternalIdCommandStrategy implements CommandStrategy {
/** /**
* Loan transactions api resource {@link LoanTransactionsApiResource}. * Loan transactions api resource {@link LoanTransactionsApiResource}.
@@ -44,7 +44,7 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class AdjustTransactionCommandStrategy implements CommandStrategy { public class AdjustLoanTransactionCommandStrategy implements CommandStrategy {
/** /**
* Loan transactions api resource {@link LoanTransactionsApiResource}. * Loan transactions api resource {@link LoanTransactionsApiResource}.
@@ -48,7 +48,7 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class GetTransactionByExternalIdCommandStrategy implements CommandStrategy { public class GetLoanTransactionByExternalIdCommandStrategy implements CommandStrategy {
/** /**
* Loan transactions api resource {@link LoanTransactionsApiResource}. * Loan transactions api resource {@link LoanTransactionsApiResource}.
@@ -47,7 +47,7 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class GetTransactionByIdCommandStrategy implements CommandStrategy { public class GetLoanTransactionByIdCommandStrategy implements CommandStrategy {
/** /**
* Loan transactions api resource {@link LoanTransactionsApiResource}. * Loan transactions api resource {@link LoanTransactionsApiResource}.
@@ -42,6 +42,7 @@ import java.util.Map;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.savings.DepositAccountOnClosureType; import org.apache.fineract.portfolio.savings.DepositAccountOnClosureType;
import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType; import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType;
import org.apache.fineract.portfolio.savings.service.SavingsEnumerations; import org.apache.fineract.portfolio.savings.service.SavingsEnumerations;
@@ -315,11 +316,7 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom {
} }
public boolean isAfterExpectedFirstDepositDate(final LocalDate compareDate) { public boolean isAfterExpectedFirstDepositDate(final LocalDate compareDate) {
boolean isAfterExpectedFirstDepositDate = false; return this.expectedFirstDepositOnDate != null && DateUtils.isAfter(compareDate, getExpectedFirstDepositOnDate());
if (this.expectedFirstDepositOnDate != null) {
isAfterExpectedFirstDepositDate = compareDate.isAfter(getExpectedFirstDepositOnDate());
}
return isAfterExpectedFirstDepositDate;
} }
public Integer getOnAccountClosureType() { public Integer getOnAccountClosureType() {
@@ -144,7 +144,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Transactional @Transactional
@Override @Override
public CommandProcessingResult activateFDAccount(final Long savingsId, final JsonCommand command) { public CommandProcessingResult activateFDAccount(final Long savingsId, final JsonCommand command) {
final AppUser user = this.context.authenticatedUser(); final AppUser user = this.context.authenticatedUser();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
@@ -621,7 +620,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public CommandProcessingResult adjustRDTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) { public CommandProcessingResult adjustRDTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) {
AppUser user = getAppUserIfPresent(); AppUser user = getAppUserIfPresent();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
@@ -894,7 +892,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate, public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate,
final DepositAccountType depositAccountType) { final DepositAccountType depositAccountType) {
AppUser user = getAppUserIfPresent(); AppUser user = getAppUserIfPresent();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
@@ -927,7 +924,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate, public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate,
final DepositAccountType depositAccountType) { final DepositAccountType depositAccountType) {
AppUser user = getAppUserIfPresent(); AppUser user = getAppUserIfPresent();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
@@ -969,7 +965,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate, public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate,
final Office acceptedInOffice, final Staff fieldOfficer, final DepositAccountType depositAccountType) { final Office acceptedInOffice, final Staff fieldOfficer, final DepositAccountType depositAccountType) {
AppUser user = getAppUserIfPresent(); AppUser user = getAppUserIfPresent();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
@@ -1125,7 +1120,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public CommandProcessingResult waiveCharge(final Long savingsAccountId, final Long savingsAccountChargeId, public CommandProcessingResult waiveCharge(final Long savingsAccountId, final Long savingsAccountChargeId,
@SuppressWarnings("unused") final DepositAccountType depositAccountType) { @SuppressWarnings("unused") final DepositAccountType depositAccountType) {
AppUser user = getAppUserIfPresent(); AppUser user = getAppUserIfPresent();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
@@ -1261,7 +1255,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
.findOneWithNotFoundDetection(savingsAccountChargeId, accountId); .findOneWithNotFoundDetection(savingsAccountChargeId, accountId);
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern("dd MM yyyy"); final DateTimeFormatter fmt = DateTimeFormatter.ofPattern("dd MM yyyy");
while (transactionDate.isAfter(savingsAccountCharge.getDueLocalDate())) { while (transactionDate.isAfter(savingsAccountCharge.getDueLocalDate())) {
payCharge(savingsAccountCharge, transactionDate, savingsAccountCharge.amoutOutstanding(), fmt); payCharge(savingsAccountCharge, transactionDate, savingsAccountCharge.amoutOutstanding(), fmt);
} }
@@ -1270,7 +1263,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Transactional @Transactional
private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid, private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid,
final DateTimeFormatter formatter) { final DateTimeFormatter formatter) {
AppUser user = getAppUserIfPresent(); AppUser user = getAppUserIfPresent();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
@@ -1314,7 +1306,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Transactional @Transactional
@Override @Override
public void updateMaturityDetails(Long depositAccountId, DepositAccountType depositAccountType) { public void updateMaturityDetails(Long depositAccountId, DepositAccountType depositAccountType) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth(); final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
@@ -27,8 +27,8 @@ import java.util.stream.Stream;
import org.apache.fineract.batch.command.internal.ActivateClientCommandStrategy; import org.apache.fineract.batch.command.internal.ActivateClientCommandStrategy;
import org.apache.fineract.batch.command.internal.AdjustChargeByChargeExternalIdCommandStrategy; import org.apache.fineract.batch.command.internal.AdjustChargeByChargeExternalIdCommandStrategy;
import org.apache.fineract.batch.command.internal.AdjustChargeCommandStrategy; import org.apache.fineract.batch.command.internal.AdjustChargeCommandStrategy;
import org.apache.fineract.batch.command.internal.AdjustTransactionByExternalIdCommandStrategy; import org.apache.fineract.batch.command.internal.AdjustLoanTransactionByExternalIdCommandStrategy;
import org.apache.fineract.batch.command.internal.AdjustTransactionCommandStrategy; import org.apache.fineract.batch.command.internal.AdjustLoanTransactionCommandStrategy;
import org.apache.fineract.batch.command.internal.ApplyLoanCommandStrategy; import org.apache.fineract.batch.command.internal.ApplyLoanCommandStrategy;
import org.apache.fineract.batch.command.internal.ApplySavingsCommandStrategy; import org.apache.fineract.batch.command.internal.ApplySavingsCommandStrategy;
import org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy; import org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy;
@@ -50,8 +50,8 @@ import org.apache.fineract.batch.command.internal.GetDatatableEntryByAppTableIdC
import org.apache.fineract.batch.command.internal.GetDatatableEntryByQueryCommandStrategy; import org.apache.fineract.batch.command.internal.GetDatatableEntryByQueryCommandStrategy;
import org.apache.fineract.batch.command.internal.GetLoanByExternalIdCommandStrategy; import org.apache.fineract.batch.command.internal.GetLoanByExternalIdCommandStrategy;
import org.apache.fineract.batch.command.internal.GetLoanByIdCommandStrategy; import org.apache.fineract.batch.command.internal.GetLoanByIdCommandStrategy;
import org.apache.fineract.batch.command.internal.GetTransactionByExternalIdCommandStrategy; import org.apache.fineract.batch.command.internal.GetLoanTransactionByExternalIdCommandStrategy;
import org.apache.fineract.batch.command.internal.GetTransactionByIdCommandStrategy; import org.apache.fineract.batch.command.internal.GetLoanTransactionByIdCommandStrategy;
import org.apache.fineract.batch.command.internal.LoanStateTransistionsByExternalIdCommandStrategy; import org.apache.fineract.batch.command.internal.LoanStateTransistionsByExternalIdCommandStrategy;
import org.apache.fineract.batch.command.internal.ModifyLoanApplicationCommandStrategy; import org.apache.fineract.batch.command.internal.ModifyLoanApplicationCommandStrategy;
import org.apache.fineract.batch.command.internal.UnknownCommandStrategy; import org.apache.fineract.batch.command.internal.UnknownCommandStrategy;
@@ -140,18 +140,18 @@ public class CommandStrategyProviderTest {
mock(CreateTransactionLoanCommandStrategy.class)), mock(CreateTransactionLoanCommandStrategy.class)),
Arguments.of("loans/123/transactions?command=chargeRefund", HttpMethod.POST, "createTransactionLoanCommandStrategy", Arguments.of("loans/123/transactions?command=chargeRefund", HttpMethod.POST, "createTransactionLoanCommandStrategy",
mock(CreateTransactionLoanCommandStrategy.class)), mock(CreateTransactionLoanCommandStrategy.class)),
Arguments.of("loans/123/transactions/123", HttpMethod.POST, "adjustTransactionCommandStrategy", Arguments.of("loans/123/transactions/123", HttpMethod.POST, "adjustLoanTransactionCommandStrategy",
mock(AdjustTransactionCommandStrategy.class)), mock(AdjustLoanTransactionCommandStrategy.class)),
Arguments.of("loans/123/transactions/123?command=chargeback", HttpMethod.POST, "adjustTransactionCommandStrategy", Arguments.of("loans/123/transactions/123?command=chargeback", HttpMethod.POST, "adjustLoanTransactionCommandStrategy",
mock(AdjustTransactionCommandStrategy.class)), mock(AdjustLoanTransactionCommandStrategy.class)),
Arguments.of( Arguments.of(
"loans/external-id/8dfad438-2319-48ce-8520-10a62801e9a1/transactions/external-id/7dfad438-2319-48ce-8520-10a62801e9ab", "loans/external-id/8dfad438-2319-48ce-8520-10a62801e9a1/transactions/external-id/7dfad438-2319-48ce-8520-10a62801e9ab",
HttpMethod.POST, "adjustTransactionByExternalIdCommandStrategy", HttpMethod.POST, "adjustLoanTransactionByExternalIdCommandStrategy",
mock(AdjustTransactionByExternalIdCommandStrategy.class)), mock(AdjustLoanTransactionByExternalIdCommandStrategy.class)),
Arguments.of( Arguments.of(
"loans/external-id/8dfad438-2319-48ce-8520-10a62801e9a1/transactions/external-id/7dfad438-2319-48ce-8520-10a62801e9ab?command=chargeback", "loans/external-id/8dfad438-2319-48ce-8520-10a62801e9a1/transactions/external-id/7dfad438-2319-48ce-8520-10a62801e9ab?command=chargeback",
HttpMethod.POST, "adjustTransactionByExternalIdCommandStrategy", HttpMethod.POST, "adjustLoanTransactionByExternalIdCommandStrategy",
mock(AdjustTransactionByExternalIdCommandStrategy.class)), mock(AdjustLoanTransactionByExternalIdCommandStrategy.class)),
Arguments.of("clients/456?command=activate", HttpMethod.POST, "activateClientCommandStrategy", Arguments.of("clients/456?command=activate", HttpMethod.POST, "activateClientCommandStrategy",
mock(ActivateClientCommandStrategy.class)), mock(ActivateClientCommandStrategy.class)),
Arguments.of("loans/123?command=approve", HttpMethod.POST, "approveLoanCommandStrategy", Arguments.of("loans/123?command=approve", HttpMethod.POST, "approveLoanCommandStrategy",
@@ -166,11 +166,12 @@ public class CommandStrategyProviderTest {
mock(CreateLoanRescheduleRequestCommandStrategy.class)), mock(CreateLoanRescheduleRequestCommandStrategy.class)),
Arguments.of("rescheduleloans/123?command=approve", HttpMethod.POST, "approveLoanRescheduleCommandStrategy", Arguments.of("rescheduleloans/123?command=approve", HttpMethod.POST, "approveLoanRescheduleCommandStrategy",
mock(ApproveLoanRescheduleCommandStrategy.class)), mock(ApproveLoanRescheduleCommandStrategy.class)),
Arguments.of("loans/123/transactions/123", HttpMethod.GET, "getTransactionByIdCommandStrategy", Arguments.of("loans/123/transactions/123", HttpMethod.GET, "getLoanTransactionByIdCommandStrategy",
mock(GetTransactionByIdCommandStrategy.class)), mock(GetLoanTransactionByIdCommandStrategy.class)),
Arguments.of( Arguments.of(
"loans/external-id/8dfad438-2319-48ce-8520-10a62801e9a1/transactions/external-id/7dfad438-2319-48ce-8520-10a62801e9ab?fields=id", "loans/external-id/8dfad438-2319-48ce-8520-10a62801e9a1/transactions/external-id/7dfad438-2319-48ce-8520-10a62801e9ab?fields=id",
HttpMethod.GET, "getTransactionByExternalIdCommandStrategy", mock(GetTransactionByExternalIdCommandStrategy.class)), HttpMethod.GET, "getLoanTransactionByExternalIdCommandStrategy",
mock(GetLoanTransactionByExternalIdCommandStrategy.class)),
Arguments.of("datatables/test_dt_table/123", HttpMethod.GET, "getDatatableEntryByAppTableIdCommandStrategy", Arguments.of("datatables/test_dt_table/123", HttpMethod.GET, "getDatatableEntryByAppTableIdCommandStrategy",
mock(GetDatatableEntryByAppTableIdCommandStrategy.class)), mock(GetDatatableEntryByAppTableIdCommandStrategy.class)),
Arguments.of("datatables/test_dt_table/123?genericResultSet=true", HttpMethod.GET, Arguments.of("datatables/test_dt_table/123?genericResultSet=true", HttpMethod.GET,
@@ -38,12 +38,12 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
/** /**
* Test class for {@link AdjustTransactionByExternalIdCommandStrategy}. * Test class for {@link AdjustLoanTransactionByExternalIdCommandStrategy}.
*/ */
public class AdjustTransactionByExternalIdCommandStrategyTest { public class AdjustLoanTransactionByExternalIdCommandStrategyTest {
/** /**
* Test {@link AdjustTransactionByExternalIdCommandStrategy#execute} happy path scenario. * Test {@link AdjustLoanTransactionByExternalIdCommandStrategy#execute} happy path scenario.
*/ */
@Test @Test
public void testExecuteWithoutCommandSuccessScenario() { public void testExecuteWithoutCommandSuccessScenario() {
@@ -73,7 +73,7 @@ public class AdjustTransactionByExternalIdCommandStrategyTest {
} }
/** /**
* Test {@link AdjustTransactionByExternalIdCommandStrategy#execute} happy path scenario. * Test {@link AdjustLoanTransactionByExternalIdCommandStrategy#execute} happy path scenario.
*/ */
@Test @Test
public void testExecuteWithCommandSuccessScenario() { public void testExecuteWithCommandSuccessScenario() {
@@ -150,14 +150,14 @@ public class AdjustTransactionByExternalIdCommandStrategyTest {
/** /**
* The class under test. * The class under test.
*/ */
private final AdjustTransactionByExternalIdCommandStrategy subjectToTest; private final AdjustLoanTransactionByExternalIdCommandStrategy subjectToTest;
/** /**
* Constructor. * Constructor.
*/ */
TestContext() { TestContext() {
MockitoAnnotations.openMocks(this); MockitoAnnotations.openMocks(this);
subjectToTest = new AdjustTransactionByExternalIdCommandStrategy(loanTransactionsApiResource); subjectToTest = new AdjustLoanTransactionByExternalIdCommandStrategy(loanTransactionsApiResource);
} }
} }
} }
@@ -36,12 +36,12 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
/** /**
* Test class for {@link AdjustTransactionCommandStrategy}. * Test class for {@link AdjustLoanTransactionCommandStrategy}.
*/ */
public class AdjustTransactionCommandStrategyTest { public class AdjustLoanTransactionCommandStrategyTest {
/** /**
* Test {@link AdjustTransactionCommandStrategy#execute} happy path scenario. * Test {@link AdjustLoanTransactionCommandStrategy#execute} happy path scenario.
*/ */
@Test @Test
public void testExecuteWithoutCommandSuccessScenario() { public void testExecuteWithoutCommandSuccessScenario() {
@@ -71,7 +71,7 @@ public class AdjustTransactionCommandStrategyTest {
} }
/** /**
* Test {@link AdjustTransactionCommandStrategy#execute} happy path scenario. * Test {@link AdjustLoanTransactionCommandStrategy#execute} happy path scenario.
*/ */
@Test @Test
public void testExecuteWithCommandSuccessScenario() { public void testExecuteWithCommandSuccessScenario() {
@@ -148,14 +148,14 @@ public class AdjustTransactionCommandStrategyTest {
/** /**
* The class under test. * The class under test.
*/ */
private final AdjustTransactionCommandStrategy subjectToTest; private final AdjustLoanTransactionCommandStrategy subjectToTest;
/** /**
* Constructor. * Constructor.
*/ */
TestContext() { TestContext() {
MockitoAnnotations.openMocks(this); MockitoAnnotations.openMocks(this);
subjectToTest = new AdjustTransactionCommandStrategy(loanTransactionsApiResource); subjectToTest = new AdjustLoanTransactionCommandStrategy(loanTransactionsApiResource);
} }
} }
} }
@@ -40,16 +40,16 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
/** /**
* Test class for {@link GetTransactionByExternalIdCommandStrategy}. * Test class for {@link GetLoanTransactionByExternalIdCommandStrategy}.
*/ */
public class GetTransactionByExternalIdCommandStrategyTest { public class GetLoanTransactionByExternalIdCommandStrategyTest {
private static Stream<Arguments> provideQueryParameters() { private static Stream<Arguments> provideQueryParameters() {
return Stream.of(Arguments.of(null, 0), Arguments.of("id,date,amount", 1)); return Stream.of(Arguments.of(null, 0), Arguments.of("id,date,amount", 1));
} }
/** /**
* Test {@link GetTransactionByExternalIdCommandStrategy#execute} happy path scenario. * Test {@link GetLoanTransactionByExternalIdCommandStrategy#execute} happy path scenario.
*/ */
@ParameterizedTest @ParameterizedTest
@MethodSource("provideQueryParameters") @MethodSource("provideQueryParameters")
@@ -132,7 +132,7 @@ public class GetTransactionByExternalIdCommandStrategyTest {
/** /**
* The class under test. * The class under test.
*/ */
private final GetTransactionByExternalIdCommandStrategy subjectToTest; private final GetLoanTransactionByExternalIdCommandStrategy subjectToTest;
/** /**
* Constructor. * Constructor.
@@ -140,7 +140,7 @@ public class GetTransactionByExternalIdCommandStrategyTest {
TestContext() { TestContext() {
MockitoAnnotations.openMocks(this); MockitoAnnotations.openMocks(this);
subjectToTest = new GetTransactionByExternalIdCommandStrategy(loanTransactionsApiResource); subjectToTest = new GetLoanTransactionByExternalIdCommandStrategy(loanTransactionsApiResource);
} }
} }
} }
@@ -38,16 +38,16 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
/** /**
* Test class for {@link GetTransactionByIdCommandStrategy}. * Test class for {@link GetLoanTransactionByIdCommandStrategy}.
*/ */
public class GetTransactionByIdCommandStrategyTest { public class GetLoanTransactionByIdCommandStrategyTest {
private static Stream<Arguments> provideQueryParameters() { private static Stream<Arguments> provideQueryParameters() {
return Stream.of(Arguments.of(null, 0), Arguments.of("id,date,amount", 1)); return Stream.of(Arguments.of(null, 0), Arguments.of("id,date,amount", 1));
} }
/** /**
* Test {@link GetTransactionByIdCommandStrategy#execute} happy path scenario. * Test {@link GetLoanTransactionByIdCommandStrategy#execute} happy path scenario.
*/ */
@ParameterizedTest @ParameterizedTest
@MethodSource("provideQueryParameters") @MethodSource("provideQueryParameters")
@@ -128,7 +128,7 @@ public class GetTransactionByIdCommandStrategyTest {
/** /**
* The class under test. * The class under test.
*/ */
private final GetTransactionByIdCommandStrategy subjectToTest; private final GetLoanTransactionByIdCommandStrategy subjectToTest;
/** /**
* Constructor. * Constructor.
@@ -136,7 +136,7 @@ public class GetTransactionByIdCommandStrategyTest {
TestContext() { TestContext() {
MockitoAnnotations.openMocks(this); MockitoAnnotations.openMocks(this);
subjectToTest = new GetTransactionByIdCommandStrategy(loanTransactionsApiResource); subjectToTest = new GetLoanTransactionByIdCommandStrategy(loanTransactionsApiResource);
} }
} }
} }
@@ -43,10 +43,9 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.apache.fineract.batch.command.internal.AdjustTransactionCommandStrategy; import org.apache.fineract.batch.command.internal.AdjustLoanTransactionCommandStrategy;
import org.apache.fineract.batch.command.internal.CreateTransactionLoanCommandStrategy; import org.apache.fineract.batch.command.internal.CreateTransactionLoanCommandStrategy;
import org.apache.fineract.batch.command.internal.GetDatatableEntryByAppTableIdAndDataTableIdCommandStrategy; import org.apache.fineract.batch.command.internal.GetDatatableEntryByAppTableIdAndDataTableIdCommandStrategy;
import org.apache.fineract.batch.command.internal.GetTransactionByIdCommandStrategy;
import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchRequest;
import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.domain.BatchResponse;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
@@ -471,7 +470,7 @@ public class BatchApiTest {
/** /**
* Test for a successful charge adjustment. A '200' status code is expected on successful responses. * Test for a successful charge adjustment. A '200' status code is expected on successful responses.
* *
* @see AdjustTransactionCommandStrategy * @see AdjustLoanTransactionCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusOnSuccessfulChargeAdjustment() { public void shouldReturnOkStatusOnSuccessfulChargeAdjustment() {
@@ -1076,7 +1075,7 @@ public class BatchApiTest {
* Test for the successful disbursement and get loan. A '200' status code is expected on successful responses. * Test for the successful disbursement and get loan. A '200' status code is expected on successful responses.
* *
* @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy * @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy
* @see GetTransactionByIdCommandStrategy * @see org.apache.fineract.batch.command.internal.GetLoanTransactionByIdCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusOnSuccessfulDisbursementAndGetTransaction() { public void shouldReturnOkStatusOnSuccessfulDisbursementAndGetTransaction() {
@@ -1591,7 +1590,7 @@ public class BatchApiTest {
/** /**
* Test for the successful repayment reversal transaction. A '200' status code is expected on successful responses. * Test for the successful repayment reversal transaction. A '200' status code is expected on successful responses.
* *
* @see AdjustTransactionCommandStrategy * @see AdjustLoanTransactionCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusForBatchRepaymentReversal() { public void shouldReturnOkStatusForBatchRepaymentReversal() {
@@ -1664,7 +1663,7 @@ public class BatchApiTest {
* Test for the successful repayment reversal transaction using loan external id and transaction external id. A * Test for the successful repayment reversal transaction using loan external id and transaction external id. A
* '200' status code is expected on successful responses. * '200' status code is expected on successful responses.
* *
* @see AdjustTransactionCommandStrategy * @see AdjustLoanTransactionCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusForBatchRepaymentReversalUsingExternalId() { public void shouldReturnOkStatusForBatchRepaymentReversalUsingExternalId() {
@@ -1769,7 +1768,7 @@ public class BatchApiTest {
* Test for the successful repayment chargeback transaction. A '200' status code is expected on successful * Test for the successful repayment chargeback transaction. A '200' status code is expected on successful
* responses. * responses.
* *
* @see AdjustTransactionCommandStrategy * @see AdjustLoanTransactionCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusForBatchRepaymentChargeback() { public void shouldReturnOkStatusForBatchRepaymentChargeback() {
@@ -1840,7 +1839,7 @@ public class BatchApiTest {
* Tests successful run of batch goodwill credit reversal for loans. A '200' status code is expected on successful * Tests successful run of batch goodwill credit reversal for loans. A '200' status code is expected on successful
* responses. * responses.
* *
* @see AdjustTransactionCommandStrategy * @see AdjustLoanTransactionCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusForBatchGoodwillCreditReversal() { public void shouldReturnOkStatusForBatchGoodwillCreditReversal() {
@@ -1914,7 +1913,7 @@ public class BatchApiTest {
* Test for the successful merchant issued refund and payout refund reversal transaction. A '200' status code is * Test for the successful merchant issued refund and payout refund reversal transaction. A '200' status code is
* expected on successful responses. * expected on successful responses.
* *
* @see AdjustTransactionCommandStrategy * @see AdjustLoanTransactionCommandStrategy
*/ */
@Test @Test
public void shouldReturnOkStatusOnSuccessfulTransactionMerchantIssuedAndPayoutRefundReversal() { public void shouldReturnOkStatusOnSuccessfulTransactionMerchantIssuedAndPayoutRefundReversal() {
@@ -34,8 +34,6 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.fineract.batch.command.internal.CreateTransactionLoanCommandStrategy; import org.apache.fineract.batch.command.internal.CreateTransactionLoanCommandStrategy;
import org.apache.fineract.batch.command.internal.GetTransactionByExternalIdCommandStrategy;
import org.apache.fineract.batch.command.internal.GetTransactionByIdCommandStrategy;
import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchRequest;
import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.domain.BatchResponse;
import org.apache.fineract.integrationtests.common.savings.SavingsTransactionData; import org.apache.fineract.integrationtests.common.savings.SavingsTransactionData;
@@ -326,5 +326,4 @@ public class SavingsProductHelper {
this.daysToEscheat = "90"; this.daysToEscheat = "90";
return this; return this;
} }
} }