Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FSF-56 #1206

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public CommandProcessingResult reassignCheque(final Long chequeId, JsonCommand c
newCheque.setIssuanceApprovedBy(oldCheque.getIssuanceApprovedBy());
newCheque.setIssuanceAuthorizeBy(oldCheque.getIssuanceAuthorizeBy());
newCheque.setIssuanceAuthorizeOnDate(oldCheque.getIssuanceAuthorizeOnDate());
newCheque.setNumeroCliente(oldCheque.getNumeroCliente());
newCheque.setIsReassigned(true);
this.chequeJpaRepository.saveAll(List.of(oldCheque, newCheque));
return new CommandProcessingResultBuilder().withCommandId(command.commandId())
Expand Down Expand Up @@ -482,49 +483,52 @@ public CommandProcessingResult printCheques(JsonCommand command) {
throw new BankChequeException("guarantee.savings.account.not.found",
"Guarantee savings is not found for client ID" + numeroCliente);
}
BigDecimal availableBalance = BigDecimal.ZERO;
final SavingsAccountData savingsAccountData = savingsAccountDataOptional.get();
final Long savingsAccountId = savingsAccountData.getId();
if (savingsAccountData.getSummary() != null) {
availableBalance = savingsAccountData.getSummary().getAvailableBalance();
}
if (guaranteeAmount.compareTo(availableBalance) > 0) {
throw new BankChequeException("guarantee.amount.greater.than.available.savings.account.balance",
"Guarantee amount is greater than savings account balance of" + availableBalance);
}
final String localeAsString = "en";
final String dateFormat = "dd MMMM yyyy";
final JsonObject jsonObject = new JsonObject();
final LocalDate localDate = DateUtils.getBusinessLocalDate();
Locale locale = JsonParserHelper.localeFromString(localeAsString);
final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dateFormat).withLocale(locale);
final String localDateString = localDate.format(dateTimeFormatter);
jsonObject.addProperty("locale", localeAsString);
jsonObject.addProperty("dateFormat", dateFormat);
jsonObject.addProperty("transactionAmount", guaranteeAmount);
jsonObject.addProperty("transactionDate", localDateString);
if (!CollectionUtils.isEmpty(paymentTypeOptions)) {
Optional<PaymentTypeData> paymentTypeOptional = new ArrayList<>(paymentTypeOptions).stream()
.filter(pt -> BankChequeApiConstants.BANK_CHEQUE_PAYMENT_TYPE.equalsIgnoreCase(pt.getName())).findFirst();
if (paymentTypeOptional.isPresent()) {
PaymentTypeData paymentType = paymentTypeOptional.get();
jsonObject.addProperty("paymentTypeId", paymentType.getId());

if (!chequeData.getReassingedCheque()){
BigDecimal availableBalance = BigDecimal.ZERO;
final SavingsAccountData savingsAccountData = savingsAccountDataOptional.get();
final Long savingsAccountId = savingsAccountData.getId();
if (savingsAccountData.getSummary() != null) {
availableBalance = savingsAccountData.getSummary().getAvailableBalance();
}
if (guaranteeAmount.compareTo(availableBalance) > 0) {
throw new BankChequeException("guarantee.amount.greater.than.available.savings.account.balance",
"Guarantee amount is greater than savings account balance of" + availableBalance);
}
final String localeAsString = "en";
final String dateFormat = "dd MMMM yyyy";
final JsonObject jsonObject = new JsonObject();
final LocalDate localDate = DateUtils.getBusinessLocalDate();
Locale locale = JsonParserHelper.localeFromString(localeAsString);
final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dateFormat).withLocale(locale);
final String localDateString = localDate.format(dateTimeFormatter);
jsonObject.addProperty("locale", localeAsString);
jsonObject.addProperty("dateFormat", dateFormat);
jsonObject.addProperty("transactionAmount", guaranteeAmount);
jsonObject.addProperty("transactionDate", localDateString);
if (!CollectionUtils.isEmpty(paymentTypeOptions)) {
Optional<PaymentTypeData> paymentTypeOptional = new ArrayList<>(paymentTypeOptions).stream()
.filter(pt -> BankChequeApiConstants.BANK_CHEQUE_PAYMENT_TYPE.equalsIgnoreCase(pt.getName())).findFirst();
if (paymentTypeOptional.isPresent()) {
PaymentTypeData paymentType = paymentTypeOptional.get();
jsonObject.addProperty("paymentTypeId", paymentType.getId());
}
}
jsonObject.addProperty("accountNumber", bankAccNo);
jsonObject.addProperty("checkNumber", chequeData.getChequeNo());
jsonObject.addProperty("receiptNumber", chequeData.getGuaranteeId());
jsonObject.addProperty("bankNumber", chequeData.getBankName());
jsonObject.addProperty("glAccountId", chequeData.getGlAccountId());
jsonObject.addProperty("routingCode", "");
final String note = "Retiro de garantía por ID de garantía " + guaranteeId;
jsonObject.addProperty("note", note);
final JsonCommand withdrawalJsonCommand = JsonCommand.fromJsonElement(savingsAccountId, jsonObject, this.fromApiJsonHelper);
withdrawalJsonCommand.setJsonCommand(jsonObject.toString());
CommandProcessingResult result = this.savingsAccountWritePlatformService.withdrawal(savingsAccountId,
withdrawalJsonCommand);
if (result != null) {
log.info("Guarantee withdrawal is successful for savings account ID {}", result.getSavingsId());
}
}
jsonObject.addProperty("accountNumber", bankAccNo);
jsonObject.addProperty("checkNumber", chequeData.getChequeNo());
jsonObject.addProperty("receiptNumber", chequeData.getGuaranteeId());
jsonObject.addProperty("bankNumber", chequeData.getBankName());
jsonObject.addProperty("glAccountId", chequeData.getGlAccountId());
jsonObject.addProperty("routingCode", "");
final String note = "Retiro de garantía por ID de garantía " + guaranteeId;
jsonObject.addProperty("note", note);
final JsonCommand withdrawalJsonCommand = JsonCommand.fromJsonElement(savingsAccountId, jsonObject, this.fromApiJsonHelper);
withdrawalJsonCommand.setJsonCommand(jsonObject.toString());
CommandProcessingResult result = this.savingsAccountWritePlatformService.withdrawal(savingsAccountId,
withdrawalJsonCommand);
if (result != null) {
log.info("Guarantee withdrawal is successful for savings account ID {}", result.getSavingsId());
}
}
if (chequeAmount != null) {
Expand Down
Loading