|
|
|
@ -2,11 +2,17 @@ package com.mfsys.aconnect.client.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.dto.DepositCancellationDTO;
|
|
|
|
import com.mfsys.aconnect.client.dto.DepositCancellationDTO;
|
|
|
|
import com.mfsys.aconnect.client.dto.GLCancellationDTO;
|
|
|
|
import com.mfsys.aconnect.client.dto.GLCancellationDTO;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.exception.PreviousDayCancellationException;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.exception.TransactionNotFoundException;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.model.TransactionLog;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.repository.TransactionLogRepository;
|
|
|
|
import com.mfsys.aconnect.configuration.config.WebClientConfig;
|
|
|
|
import com.mfsys.aconnect.configuration.config.WebClientConfig;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.http.*;
|
|
|
|
import org.springframework.http.*;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.mfsys.common.configuration.constant.AconnectURI.ACONNECT;
|
|
|
|
import static com.mfsys.common.configuration.constant.AconnectURI.ACONNECT;
|
|
|
|
import static com.mfsys.common.configuration.constant.AconnectURI.GENERALLEDGER;
|
|
|
|
import static com.mfsys.common.configuration.constant.AconnectURI.GENERALLEDGER;
|
|
|
|
|
|
|
|
|
|
|
|
@ -20,12 +26,23 @@ public class CancellationTransactionService {
|
|
|
|
private String generalledgerURI;
|
|
|
|
private String generalledgerURI;
|
|
|
|
|
|
|
|
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
public CancellationTransactionService(WebClientConfig webClientConfig) {
|
|
|
|
private final TransactionLogRepository transactionLogRepository;
|
|
|
|
|
|
|
|
public CancellationTransactionService(WebClientConfig webClientConfig, TransactionLogRepository transactionLogRepository) {
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
|
|
|
|
this.transactionLogRepository = transactionLogRepository;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ResponseEntity<Object> processDepositCancellationTransaction(DepositCancellationDTO depositCancellationDTO, String tokenHeader) {
|
|
|
|
public ResponseEntity<Object> processDepositCancellationTransaction(DepositCancellationDTO depositCancellationDTO, String tokenHeader) {
|
|
|
|
String porOrgacode = depositCancellationDTO.getPorOrgacode();
|
|
|
|
String porOrgacode = depositCancellationDTO.getPorOrgacode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TransactionLog log = transactionLogRepository
|
|
|
|
|
|
|
|
.findByTransactionIDAndPorOrgacode(depositCancellationDTO.getNodeId()+depositCancellationDTO.getSgtGntrtranlink(), porOrgacode)
|
|
|
|
|
|
|
|
.orElseThrow(() -> new TransactionNotFoundException(porOrgacode));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!log.getSgtGntrdate().isEqual(LocalDate.now())) {
|
|
|
|
|
|
|
|
throw new PreviousDayCancellationException(porOrgacode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String url = depositURI + "/deposit" + "/organizations/" + depositCancellationDTO.getPorOrgacode() +
|
|
|
|
String url = depositURI + "/deposit" + "/organizations/" + depositCancellationDTO.getPorOrgacode() +
|
|
|
|
"/transactions" + ACONNECT + "/cancel/nodes/" + depositCancellationDTO.getNodeId() +
|
|
|
|
"/transactions" + ACONNECT + "/cancel/nodes/" + depositCancellationDTO.getNodeId() +
|
|
|
|
"/trannums/" + depositCancellationDTO.getSgtGntrtranlink();
|
|
|
|
"/trannums/" + depositCancellationDTO.getSgtGntrtranlink();
|
|
|
|
@ -46,6 +63,15 @@ public class CancellationTransactionService {
|
|
|
|
|
|
|
|
|
|
|
|
public ResponseEntity<Object> processGLCancellationTransaction(GLCancellationDTO glCancellationDTO, String tokenHeader) {
|
|
|
|
public ResponseEntity<Object> processGLCancellationTransaction(GLCancellationDTO glCancellationDTO, String tokenHeader) {
|
|
|
|
String porOrgacode = glCancellationDTO.getPorOrgacode();
|
|
|
|
String porOrgacode = glCancellationDTO.getPorOrgacode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TransactionLog log = transactionLogRepository
|
|
|
|
|
|
|
|
.findByTransactionIDAndPorOrgacode(glCancellationDTO.getNodeId()+glCancellationDTO.getSgtGntrtranlink(), porOrgacode)
|
|
|
|
|
|
|
|
.orElseThrow(() -> new TransactionNotFoundException(porOrgacode));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!log.getSgtGntrdate().isEqual(LocalDate.now())) {
|
|
|
|
|
|
|
|
throw new PreviousDayCancellationException(porOrgacode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String url = generalledgerURI + GENERALLEDGER + "/organizations/" + glCancellationDTO.getPorOrgacode() +
|
|
|
|
String url = generalledgerURI + GENERALLEDGER + "/organizations/" + glCancellationDTO.getPorOrgacode() +
|
|
|
|
"/transactions" + ACONNECT + "/cancel/nodes/" + glCancellationDTO.getNodeId() +
|
|
|
|
"/transactions" + ACONNECT + "/cancel/nodes/" + glCancellationDTO.getNodeId() +
|
|
|
|
"/trannums/" + glCancellationDTO.getSgtGntrtranlink();
|
|
|
|
"/trannums/" + glCancellationDTO.getSgtGntrtranlink();
|
|
|
|
|