|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.mfsys.aconnect.client.service;
|
|
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.dto.*;
|
|
|
|
|
import com.mfsys.aconnect.client.exception.*;
|
|
|
|
|
import com.mfsys.aconnect.client.model.TransactionLog;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
|
@ -60,21 +61,15 @@ public class TransactionService {
|
|
|
|
|
Double debitAmount = accountGLTransactionRequest.getDebitAcc().getSgtGntramtfc();
|
|
|
|
|
|
|
|
|
|
if (creditAmount == null || debitAmount == null) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts are required");
|
|
|
|
|
throw new MissingTransactionAmountException(accountGLTransactionRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creditAmount <= 0 || debitAmount <= 0) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be greater than 0");
|
|
|
|
|
throw new InvalidTransactionAmountException(accountGLTransactionRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!creditAmount.equals(debitAmount)) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be equal");
|
|
|
|
|
throw new MismatchTransactionAmtException(accountGLTransactionRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String porOrgacode = accountGLTransactionRequest.getPorOrgacode();
|
|
|
|
|
@ -114,33 +109,23 @@ public class TransactionService {
|
|
|
|
|
String crLocation = gLtoGLRequest.getCreditGl().getPlcLocacode();
|
|
|
|
|
|
|
|
|
|
if(crGL == null || drGL == null) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit GL codes are required");
|
|
|
|
|
throw new MissingGLCodeException(gLtoGLRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(crGL.equals(drGL) && drLocation.equals(crLocation)) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit GL codes cannot be same");
|
|
|
|
|
throw new MismatchGLException(gLtoGLRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creditAmount == null || debitAmount == null) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts are required");
|
|
|
|
|
throw new MissingTransactionAmountException(gLtoGLRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creditAmount <= 0 || debitAmount <= 0) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be greater than 0");
|
|
|
|
|
throw new InvalidTransactionAmountException(gLtoGLRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!creditAmount.equals(debitAmount)) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be equal");
|
|
|
|
|
throw new TransactionAmountException(gLtoGLRequest.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String porOrgacode = gLtoGLRequest.getPorOrgacode();
|
|
|
|
|
@ -176,34 +161,24 @@ public class TransactionService {
|
|
|
|
|
String drAcc = accountToAccountDTO.getDebitAcc().getMbmBkmsnumber();
|
|
|
|
|
|
|
|
|
|
if(crAcc == null || drAcc == null) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit account numbers are required");
|
|
|
|
|
throw new MissingAccountException(accountToAccountDTO.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(crAcc.equals(drAcc)) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Debit Account Number and Credit Account Number shouldn't be same");
|
|
|
|
|
throw new SameTransactionAccountException(accountToAccountDTO.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creditAmount == null || debitAmount == null) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts are required");
|
|
|
|
|
throw new MissingTransactionAmountException(accountToAccountDTO.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creditAmount.compareTo(BigDecimal.ZERO) <= 0 ||
|
|
|
|
|
debitAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be greater than 0");
|
|
|
|
|
throw new InvalidTransactionAmountException(accountToAccountDTO.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!creditAmount.equals(debitAmount)) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be equal");
|
|
|
|
|
throw new TransactionAmountException(accountToAccountDTO.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String porOrgacode = accountToAccountDTO.getPorOrgacode();
|
|
|
|
|
@ -237,16 +212,12 @@ public class TransactionService {
|
|
|
|
|
BigDecimal debitAmount = glToAccountDTO.getDebitGl().getSgtGntramtfc();
|
|
|
|
|
|
|
|
|
|
if (!creditAmount.equals(debitAmount)) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be equal");
|
|
|
|
|
throw new TransactionAmountException(glToAccountDTO.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creditAmount.compareTo(BigDecimal.ZERO) <= 0 ||
|
|
|
|
|
debitAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
return ResponseEntity
|
|
|
|
|
.badRequest()
|
|
|
|
|
.body("Credit and Debit amounts must be greater than 0");
|
|
|
|
|
throw new InvalidTransactionAmountException(glToAccountDTO.getPorOrgacode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String porOrgacode = glToAccountDTO.getPorOrgacode();
|
|
|
|
|
|