Skip to content

Commit

Permalink
Release v1.0.17-alpha-fb
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMuhimbura committed Nov 16, 2023
2 parents 92d88c7 + f2d2410 commit 11abb63
Show file tree
Hide file tree
Showing 111 changed files with 5,024 additions and 591 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3982,4 +3982,12 @@ public CommandWrapperBuilder deleteCommittee(Long committeeId) {
this.href = "/committees" + committeeId;
return this;
}

public CommandWrapperBuilder assigntoPrequalificationSelf(Long prequalificationId) {
this.actionName = "ASSIGN";
this.entityName = "PREQUALIFICATIONS";
this.entityId = prequalificationId;
this.href = "/prequalification/assign/" + prequalificationId;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private OfficeConstants() {
public static final int PARENT_OFFICE_ID_COL = 2;
public static final int OPENED_ON_COL = 3;
public static final int EXTERNAL_ID_COL = 4;
public static final int OFFICE_CODE_COL = 5;
public static final int LOOKUP_OFFICE_COL = 7;
public static final int LOOKUP_OFFICE_ID_COL = 8;
public static final int STATUS_COL = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ private OfficeData readOffice(Row row, final String locale, final String dateFor
Long parentId = ImportHandlerUtils.readAsLong(OfficeConstants.PARENT_OFFICE_ID_COL, row);
LocalDate openedDate = ImportHandlerUtils.readAsDate(OfficeConstants.OPENED_ON_COL, row);
String externalId = ImportHandlerUtils.readAsString(OfficeConstants.EXTERNAL_ID_COL, row);
OfficeData office = OfficeData.importInstance(officeName, parentId, openedDate, externalId);
String officeCode = ImportHandlerUtils.readAsString(OfficeConstants.OFFICE_CODE_COL, row);
OfficeData office = OfficeData.importInstance(officeName, parentId, openedDate, externalId, officeCode);
office.setImportFields(row.getRowNum(), locale, dateFormat);
return office;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private void setLayout(final Sheet worksheet) {
worksheet.setColumnWidth(OfficeConstants.PARENT_OFFICE_ID_COL, TemplatePopulateImportConstants.SMALL_COL_SIZE);
worksheet.setColumnWidth(OfficeConstants.OPENED_ON_COL, TemplatePopulateImportConstants.SMALL_COL_SIZE);
worksheet.setColumnWidth(OfficeConstants.EXTERNAL_ID_COL, TemplatePopulateImportConstants.SMALL_COL_SIZE);
worksheet.setColumnWidth(OfficeConstants.OFFICE_CODE_COL, TemplatePopulateImportConstants.SMALL_COL_SIZE);
worksheet.setColumnWidth(OfficeConstants.LOOKUP_OFFICE_COL, TemplatePopulateImportConstants.SMALL_COL_SIZE);
worksheet.setColumnWidth(OfficeConstants.LOOKUP_OFFICE_ID_COL, TemplatePopulateImportConstants.SMALL_COL_SIZE);

Expand All @@ -77,6 +78,7 @@ private void setLayout(final Sheet worksheet) {
writeString(OfficeConstants.PARENT_OFFICE_ID_COL, rowHeader, "Parent OfficeId*");
writeString(OfficeConstants.OPENED_ON_COL, rowHeader, "Opened On Date*");
writeString(OfficeConstants.EXTERNAL_ID_COL, rowHeader, "External Id*");
writeString(OfficeConstants.OFFICE_CODE_COL, rowHeader, "Office Code*");
writeString(OfficeConstants.LOOKUP_OFFICE_COL, rowHeader, "Lookup Offices");
writeString(OfficeConstants.LOOKUP_OFFICE_ID_COL, rowHeader, "Lookup OfficeId*");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public final class SearchParameters {
private final String type;
private final String groupName;
private final String centerName;
private final String groupingType;

private final String accountNumber;
private final String bankName;
Expand Down Expand Up @@ -127,7 +128,8 @@ public static SearchParameters forBlacklist(final String displayName, final Stri
}

public static SearchParameters forPrequalification(final String displayName, final String status, final Integer offset,
final Integer limit, final String orderBy, final String sortOrder, final String type, String searchText) {
final Integer limit, final String orderBy, final String sortOrder, final String type, String searchText,
final String groupingType) {

final Integer maxLimitAllowed = getCheckedLimit(limit);
final Long staffId = null;
Expand All @@ -136,7 +138,7 @@ public static SearchParameters forPrequalification(final String displayName, fin
final Long savingsId = null;

return new SearchParameters(searchText, null, null, displayName, null, null, null, status, offset, maxLimitAllowed, orderBy,
sortOrder, staffId, accountNo, loanId, savingsId, null, false, null, type, null, null, null);
sortOrder, staffId, accountNo, loanId, savingsId, null, false, null, type, null, null, null, groupingType);
}

public static SearchParameters forBankCheques(final Long agencyId, final String chequeNo, final String bankAccNo, final Long batchId,
Expand Down Expand Up @@ -512,6 +514,7 @@ private SearchParameters(final String sqlSearch, final Long officeId, final Stri
this.centerId = centerId;
this.facilitatorId = facilitatorId;
this.isIndividualBusinessLoan = isIndividualBusinessLoan;
this.groupingType = null;
}

private SearchParameters(final String sqlSearch, final Long officeId, final String externalId, final String name,
Expand Down Expand Up @@ -560,6 +563,7 @@ private SearchParameters(final String sqlSearch, final Long officeId, final Stri
this.centerId = null;
this.facilitatorId = null;
this.isIndividualBusinessLoan = null;
this.groupingType = null;
}

private SearchParameters(final String sqlSearch, final Long officeId, final String externalId, final String name,
Expand Down Expand Up @@ -609,13 +613,14 @@ private SearchParameters(final String sqlSearch, final Long officeId, final Stri
this.centerId = null;
this.facilitatorId = null;
this.isIndividualBusinessLoan = null;
this.groupingType = null;
}

private SearchParameters(final String sqlSearch, final Long officeId, final String externalId, final String name,
final String hierarchy, final String firstname, final String lastname, final String status, final Integer offset,
final Integer limit, final String orderBy, final String sortOrder, final Long staffId, final String accountNo,
final Long loanId, final Long savingsId, final Boolean orphansOnly, boolean isSelfUser, final String dpiNumber,
final String type, final String groupName, final String groupNumber, final String centerName) {
final String type, final String groupName, final String groupNumber, final String centerName, final String groupingType) {
this.sqlSearch = sqlSearch;
this.officeId = officeId;
this.externalId = externalId;
Expand Down Expand Up @@ -658,6 +663,7 @@ private SearchParameters(final String sqlSearch, final Long officeId, final Stri
this.centerId = null;
this.facilitatorId = null;
this.isIndividualBusinessLoan = null;
this.groupingType = groupingType;
}

private SearchParameters(final Long officeId, final String externalId, final String name, final String hierarchy,
Expand Down Expand Up @@ -707,6 +713,7 @@ private SearchParameters(final Long officeId, final String externalId, final Str
this.centerId = null;
this.facilitatorId = null;
this.isIndividualBusinessLoan = null;
this.groupingType = null;
}

private SearchParameters(final Long provisioningEntryId, final Long officeId, final Long productId, final Long categoryId,
Expand Down Expand Up @@ -753,6 +760,7 @@ private SearchParameters(final Long provisioningEntryId, final Long officeId, fi
this.centerId = null;
this.facilitatorId = null;
this.isIndividualBusinessLoan = null;
this.groupingType = null;
}

public SearchParameters(final String sqlSearch, final Long officeId, final String externalId, final String name, final String hierarchy,
Expand Down Expand Up @@ -801,6 +809,7 @@ public SearchParameters(final String sqlSearch, final Long officeId, final Strin
this.centerId = null;
this.facilitatorId = null;
this.isIndividualBusinessLoan = null;
this.groupingType = null;
}

public boolean isOrderByRequested() {
Expand Down Expand Up @@ -1112,4 +1121,9 @@ public Long getFacilitatorId() {
public Boolean getIndividualBusinessLoan() {
return isIndividualBusinessLoan;
}

public String getGroupingType() {
return groupingType;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ public interface AgencyReadPlatformService {
AgencyData retrieveNewAgencyTemplate();

Collection<AgencyData> retrieveAllByUser();

Collection<AgencyData> retrieveByOfficeHierarchy(final String hierarchy);
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,24 @@ public AgencyData mapRow(final ResultSet rs, @SuppressWarnings("unused") final i
public String schema() {
return this.schema;
}

}

@Override
public Collection<AgencyData> retrieveByOfficeHierarchy(final String hierarchy) {
final String sql = """
SELECT
ma.id AS id,
ma.name AS name
FROM
m_office mo
INNER JOIN m_office office_under ON
office_under.hierarchy LIKE CONCAT(mo.hierarchy, '%')AND office_under.hierarchy LIKE CONCAT(?, '%')
INNER JOIN m_appuser agency_responsible_user ON agency_responsible_user.office_id = office_under.id
INNER JOIN m_office agency_responsible_user_office ON agency_responsible_user_office.id = agency_responsible_user.office_id
INNER JOIN m_agency ma ON ma.responsible_user_id = agency_responsible_user.id
GROUP BY ma.id
""";
return this.jdbcTemplate.query(sql, (rs, rowNum) -> AgencyData.instance(rs.getLong("id"), rs.getString("name")),
new Object[] { hierarchy });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void validateForCreate(final String json) {

final String code = this.fromApiJsonHelper.extractStringNamed(BankConstants.BankSupportedParameters.CODE.getValue(), element);
baseDataValidator.reset().parameter(BankConstants.BankSupportedParameters.CODE.getValue()).value(code).notBlank()
.notExceedingLengthOf(2);
.notExceedingLengthOf(5);

final String name = this.fromApiJsonHelper.extractStringNamed(BankConstants.BankSupportedParameters.NAME.getValue(), element);
baseDataValidator.reset().parameter(BankConstants.BankSupportedParameters.NAME.getValue()).value(name).notBlank()
Expand All @@ -94,7 +94,7 @@ public void validateForUpdate(final String json) {

final String code = this.fromApiJsonHelper.extractStringNamed(BankConstants.BankSupportedParameters.CODE.getValue(), element);
baseDataValidator.reset().parameter(BankConstants.BankSupportedParameters.CODE.getValue()).value(code).notBlank()
.notExceedingLengthOf(2);
.notExceedingLengthOf(5);

final String name = this.fromApiJsonHelper.extractStringNamed(BankConstants.BankSupportedParameters.NAME.getValue(), element);
baseDataValidator.reset().parameter(BankConstants.BankSupportedParameters.NAME.getValue()).value(name).notBlank()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,12 @@ public List<GuaranteeData> retrieveGuarantees(String caseId, final String locale
for (int i = 0; i < jsonArray.size(); i++) {
final JsonElement element = jsonArray.get(i);
final Long id = this.fromApiJsonHelper.extractLongNamed("id", element);
final String status = ObjectUtils.defaultIfNull(this.fromApiJsonHelper.extractStringNamed("estado", element),
"Nueva Solicitud");
final JsonElement data = this.fromApiJsonHelper.extractJsonObjectNamed("datos", element);
final String clientNo = this.fromApiJsonHelper.extractStringNamed("numero_cliente", data);
final String clientName = this.fromApiJsonHelper.extractStringNamed("name", data);
final String withdrawalReason = this.fromApiJsonHelper.extractStringNamed("razon_retiro", data);
final String status = this.fromApiJsonHelper.extractStringNamed("razon_retiro", data);
final BigDecimal requestedAmount = this.fromApiJsonHelper.extractBigDecimalNamed("monto", data, reqLocale);
final GuaranteeData guarantee = GuaranteeData.builder().id(id).caseId(caseId).clientNo(clientNo).clientName(clientName)
.withdrawalReason(withdrawalReason).requestedAmount(requestedAmount).status(status).build();
Expand All @@ -429,7 +430,8 @@ public List<GuaranteeData> retrieveGuarantees(String caseId, final String locale
int index = 0;
for (final GuaranteeData data : List.copyOf(guaranteeDataList)) {
for (final ChequeData chequeData : chequeDataList) {
if (chequeData.getGuaranteeId().equals(data.getId())) {
if (!(chequeData.getStatus().getId().equals(BankChequeStatus.VOIDED.getValue().longValue())
&& chequeData.getGuaranteeId().equals(data.getId()))) {
guaranteeDataList.remove(index);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.core.data.PaginationParameters;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.agency.domain.Agency;
import org.apache.fineract.organisation.bankAccount.domain.BankAccount;
Expand All @@ -45,6 +47,7 @@
import org.apache.fineract.organisation.bankcheque.command.UpdateChequeCommand;
import org.apache.fineract.organisation.bankcheque.command.VoidChequeCommand;
import org.apache.fineract.organisation.bankcheque.data.ChequeData;
import org.apache.fineract.organisation.bankcheque.data.ChequeSearchParams;
import org.apache.fineract.organisation.bankcheque.domain.BankChequeStatus;
import org.apache.fineract.organisation.bankcheque.domain.Batch;
import org.apache.fineract.organisation.bankcheque.domain.Cheque;
Expand All @@ -60,11 +63,14 @@
import org.apache.fineract.organisation.bankcheque.serialization.UpdateChequeCommandFromApiJsonDeserializer;
import org.apache.fineract.organisation.bankcheque.serialization.VoidChequeCommandFromApiJsonDeserializer;
import org.apache.fineract.organisation.monetary.domain.NumberToWordsConverter;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.service.LoanWritePlatformService;
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

@Service
@Slf4j
Expand All @@ -86,6 +92,8 @@ public class ChequeWritePlatformServiceImpl implements ChequeWritePlatformServic
private final PrintChequeCommandFromApiJsonDeserializer printChequeCommandFromApiJsonDeserializer;
private final ChequeReadPlatformServiceImpl.ChequeMapper chequeMapper = new ChequeReadPlatformServiceImpl.ChequeMapper();
private final LoanWritePlatformService loanWritePlatformService;
private final LoanRepositoryWrapper loanRepositoryWrapper;
private final ChequeReadPlatformService chequeReadPlatformService;

@Override
public CommandProcessingResult createBatch(JsonCommand command) {
Expand Down Expand Up @@ -179,6 +187,22 @@ public CommandProcessingResult reassignCheque(final Long chequeId, JsonCommand c
ReassignChequeCommand reassignChequeCommand = reassignChequeCommandFromApiJsonDeserializer.commandFromApiJson(command.json());
Cheque newCheque = chequeBatchRepositoryWrapper.findOneChequeWithNotFoundDetection(reassignChequeCommand.getChequeId());
Cheque oldCheque = chequeBatchRepositoryWrapper.findOneChequeWithNotFoundDetection(reassignChequeCommand.getOldChequeId());
if (!BankChequeStatus.AVAILABLE.getValue().equals(newCheque.getStatus())) {
throw new BankChequeException("status", "invalid.loan.status.for.cheque.reassignment");
}

final PaginationParameters parameters = PaginationParameters.instance(null, null, null, null, null);
final ChequeSearchParams chequeSearchParams = ChequeSearchParams.builder().chequeId(reassignChequeCommand.getOldChequeId()).build();
final Page<ChequeData> cheques = this.chequeReadPlatformService.retrieveAll(chequeSearchParams, parameters);
if (!CollectionUtils.isEmpty(cheques.getPageItems())) {
final ChequeData chequeData = cheques.getPageItems().get(0);
if (chequeData.getId().equals(reassignChequeCommand.getOldChequeId()) && chequeData.getLoanAccId() != null) {
final Long loanId = chequeData.getLoanAccId();
final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId);
loan.setCheque(newCheque);
this.loanRepositoryWrapper.saveAndFlush(loan);
}
}
final String newChequeDescription = "Emitido por sustitución de Desembolso cheque " + oldCheque.getChequeNo();
final String oldChequeDescription = "Cheque anulado por proceso de Reasignación, cheque nuevo " + newCheque.getChequeNo();
final LocalDateTime localDateTime = DateUtils.getLocalDateTimeOfSystem();
Expand All @@ -194,7 +218,14 @@ public CommandProcessingResult reassignCheque(final Long chequeId, JsonCommand c
newCheque.stampAudit(currentUserId, localDateTime);
newCheque.setPrintedDate(localDate);
newCheque.setPrintedBy(currentUser);
chequeJpaRepository.saveAll(List.of(oldCheque, newCheque));
newCheque.setGuaranteeAmount(oldCheque.getGuaranteeAmount());
newCheque.setRequiredGuaranteeAmount(oldCheque.getRequiredGuaranteeAmount());
newCheque.setDepositGuaranteeNo(oldCheque.getDepositGuaranteeNo());
newCheque.setCaseId(oldCheque.getCaseId());
newCheque.setGuaranteeId(oldCheque.getGuaranteeId());
newCheque.setGuaranteeName(oldCheque.getGuaranteeName());
newCheque.setAmountInWords(oldCheque.getAmountInWords());
this.chequeJpaRepository.saveAll(List.of(oldCheque, newCheque));
return new CommandProcessingResultBuilder().withCommandId(command.commandId())
.withResourceIdAsString(reassignChequeCommand.getOldChequeId().toString())
.withEntityId(reassignChequeCommand.getOldChequeId()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public class OfficeData implements Serializable {
private String locale;
private String dateFormat;

public static OfficeData importInstance(final String name, final Long parentId, final LocalDate openingDate, final String externalId) {
return new OfficeData(null, name, null, externalId, openingDate, null, parentId, null, null, null);
public static OfficeData importInstance(final String name, final Long parentId, final LocalDate openingDate, final String externalId,
final String officeCode) {
return new OfficeData(null, name, null, externalId, openingDate, null, parentId, null, null, officeCode);
}

public void setImportFields(final Integer rowIndex, final String locale, final String dateFormat) {
Expand Down
Loading

0 comments on commit 11abb63

Please sign in to comment.