From 53f9a53888458135e639c87161eebc08199500f6 Mon Sep 17 00:00:00 2001 From: Naeem Ullah Date: Tue, 27 Jan 2026 14:34:13 +0500 Subject: [PATCH] Add null and empty checks for GL code and account number Introduced validation to ensure GL code and account number are not null or empty in transaction processing. Throws specific exceptions when required fields are missing to prevent invalid transactions. --- .../client/service/TransactionService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/aconnect/src/main/java/com/mfsys/aconnect/client/service/TransactionService.java b/aconnect/src/main/java/com/mfsys/aconnect/client/service/TransactionService.java index 18f8631..0d9927d 100644 --- a/aconnect/src/main/java/com/mfsys/aconnect/client/service/TransactionService.java +++ b/aconnect/src/main/java/com/mfsys/aconnect/client/service/TransactionService.java @@ -60,6 +60,15 @@ public class TransactionService { Double creditAmount = accountGLTransactionRequest.getCreditGl().getSgtGntramtfc(); Double debitAmount = accountGLTransactionRequest.getDebitAcc().getSgtGntramtfc(); + + if (accountGLTransactionRequest.getCreditGl().getPcaGlaccode() == null || accountGLTransactionRequest.getCreditGl().getPcaGlaccode().isEmpty()) { + throw new MissingGLCodeException(accountGLTransactionRequest.getPorOrgacode()); + } + + if (accountGLTransactionRequest.getDebitAcc().getMbmBkmsnumber() == null || accountGLTransactionRequest.getDebitAcc().getMbmBkmsnumber().isEmpty()) { + throw new MissingAccountException(accountGLTransactionRequest.getPorOrgacode()); + } + if (creditAmount == null || debitAmount == null) { throw new MissingTransactionAmountException(accountGLTransactionRequest.getPorOrgacode()); } @@ -211,6 +220,14 @@ public class TransactionService { BigDecimal creditAmount = glToAccountDTO.getCreditAcc().getSgtGntramtfc(); BigDecimal debitAmount = glToAccountDTO.getDebitGl().getSgtGntramtfc(); + if (glToAccountDTO.getDebitGl().getPcaGlaccode() == null || glToAccountDTO.getDebitGl().getPcaGlaccode().isEmpty()) { + throw new MissingGLCodeException(glToAccountDTO.getPorOrgacode()); + } + + if (glToAccountDTO.getCreditAcc().getMbmBkmsnumber() == null || glToAccountDTO.getCreditAcc().getMbmBkmsnumber().isEmpty()) { + throw new MissingAccountException(glToAccountDTO.getPorOrgacode()); + } + if (!creditAmount.equals(debitAmount)) { throw new TransactionAmountException(glToAccountDTO.getPorOrgacode()); }