|
|
|
|
@ -46,11 +46,13 @@ public class TransactionService {
|
|
|
|
|
.dmpProdcode(transactionRequest.getDmpProdCode())
|
|
|
|
|
.drmbmBkmstitle(transactionRequest.getDrMbmBkmstitle())
|
|
|
|
|
.drpcrCurrdesc(transactionRequest.getDrPcrCurrdesc())
|
|
|
|
|
.drPcrCurrshort(transactionRequest.getDrPcrCurrshort())
|
|
|
|
|
.cmpCustcode(transactionRequest.getCmpCustcode())
|
|
|
|
|
.drPcrCurrcode(transactionRequest.getDrPcrCurrcode())
|
|
|
|
|
.crMbmBkmstitle(transactionRequest.getCrMbmBkmstitle())
|
|
|
|
|
.crPcrCurrdesc(transactionRequest.getCrPcrCurrdesc())
|
|
|
|
|
.crPcrCurrcode(transactionRequest.getCrPcrCurrcode())
|
|
|
|
|
.crPcrCurrshort(transactionRequest.getCrPcrCurrshort())
|
|
|
|
|
.sgtSentGntrnumber(null)
|
|
|
|
|
.drSgtGntrdate(LocalDate.now())
|
|
|
|
|
.sgtGntramt(BigDecimal.valueOf(transactionRequest.getSgtGntramtfc()))
|
|
|
|
|
@ -98,8 +100,9 @@ public class TransactionService {
|
|
|
|
|
Map<String, Object> response = new HashMap<>();
|
|
|
|
|
Optional<TransactionTrail> transactionTrail = transactionTrailRepository.findById(Math.toIntExact(cashOutTransactionRequest.getId()));
|
|
|
|
|
if (transactionTrail.isPresent()) {
|
|
|
|
|
|
|
|
|
|
CoreCashOutTransaction cashOutTransaction = CoreCashOutTransaction.builder()
|
|
|
|
|
.crPcrCurrcode("123")
|
|
|
|
|
.crPcrCurrcode(transactionTrail.get().getCrPcrCurrcode())
|
|
|
|
|
.crMbmBkmsnumber(transactionTrail.get().getCrMbmBkmsnumber())
|
|
|
|
|
.porOrgacode(cashOutTransactionRequest.getPorOrgacode())
|
|
|
|
|
.otdTrancomment(cashOutTransactionRequest.getId() + "_Received")
|
|
|
|
|
@ -157,21 +160,20 @@ public class TransactionService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double convertCurrency(String baseCurrencyCode, String targetCurrencyCode, double amount, Map<String, Double> exchangeRates) {
|
|
|
|
|
if (baseCurrencyCode.equals(targetCurrencyCode)) {
|
|
|
|
|
return amount;
|
|
|
|
|
}
|
|
|
|
|
if (baseCurrencyCode.equals("default")) {
|
|
|
|
|
return exchangeRates.get(targetCurrencyCode) * amount;
|
|
|
|
|
} else if (targetCurrencyCode.equals("default")) {
|
|
|
|
|
return exchangeRates.get(baseCurrencyCode) * amount;
|
|
|
|
|
}
|
|
|
|
|
if (baseCurrencyCode.equals(targetCurrencyCode)) {
|
|
|
|
|
return amount;
|
|
|
|
|
}
|
|
|
|
|
if (!exchangeRates.containsKey(baseCurrencyCode) || !exchangeRates.containsKey(targetCurrencyCode)) {
|
|
|
|
|
throw new IllegalArgumentException("Unsupported currency code");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double amountInPKR = amount * exchangeRates.get(baseCurrencyCode);
|
|
|
|
|
double amountInTargetCurrency = amountInPKR / exchangeRates.get(targetCurrencyCode);
|
|
|
|
|
|
|
|
|
|
return amountInTargetCurrency;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|