minor improvements

This commit is contained in:
2025-10-28 22:09:37 +02:00
parent 40221f9db5
commit 2cf54c36d1
8 changed files with 31 additions and 5 deletions

View File

@@ -237,8 +237,8 @@ public class TransactionWorkflow extends WorkflowDefinition {
execution.setVariable("body", Utils.toJson(transaction));
return NextAction.moveToState(PURCHASE_INVOICE_PAYMENT, "Integration request successful");
}catch (Exception e) {
e.printStackTrace();
return NextAction.moveToState(FAILED, e.getMessage());
log.info(e.getCause().getMessage());
return NextAction.moveToState(FAILED, e.getCause().getMessage());
}
}
@@ -251,7 +251,7 @@ public class TransactionWorkflow extends WorkflowDefinition {
transaction = process(transaction, "purchaseInvoicePayment");
execution.setVariable("body", Utils.toJson(transaction));
return NextAction.moveToState(DONE,
"Purchase invoice payment generated - id: " + transaction.getErpPurchaseRef());
"Purchase invoice payment generated - id: " + transaction.getErpPurchasePaymentRef());
}catch (Exception e) {
e.printStackTrace();
return NextAction.retryAfter(new DateTime().plusMinutes(1), e.getMessage());

View File

@@ -57,7 +57,6 @@ public class IntegrationHandler implements HandlerInterface {
try {
transactionProcessorInterface.process(transaction);
transaction.setIntegrationStatus(transaction.getStatus());
}catch (Exception e){
e.getCause().printStackTrace();
transaction.setStatus(Status.FAILED);
@@ -70,6 +69,12 @@ public class IntegrationHandler implements HandlerInterface {
transactionEvent.setMessage(transaction.getErrorMessage());
transactionEventService.save(transactionEvent);
if(transaction.getStatus() != Status.SUCCESS){
throw new ApiException("Transaction failed: " + transaction.getErrorMessage() );
}else {
transaction.setIntegrationStatus(transaction.getStatus());
}
Transaction t1 = Utils.deepCopy(transaction, Transaction.class);
transactionService.save(transaction);
return t1;

View File

@@ -53,12 +53,13 @@ public class PollStatusHandler implements HandlerInterface {
transactionEventService.save(transactionEvent);
transaction.setPollingStatus(transaction.getStatus());
transaction.setPaymentStatus(transaction.getStatus());
// if transaction wasn't successful, throw and halt workflow
if(transaction.getStatus() != Status.SUCCESS){
transactionService.save(transaction);
throw new ApiException("Transaction failed: " + transaction.getErrorMessage() );
}else {
transaction.setPaymentStatus(transaction.getStatus());
transaction.setErrorMessage(null);
}

View File

@@ -59,6 +59,10 @@ public class JournalEntryHandler implements HandlerInterface {
@Override
public Transaction process(Transaction transaction) {
logger.info("Processing journal entry for transaction: {}", transaction.getReference());
if(transaction.getErpJournalRef() != null)
return transaction;
TransactionEvent transactionEvent = TransactionEvent.builder()
.transactionId(transaction.getId().toString())
.event(RequestType.JOURNAL_ENTRY.name())

View File

@@ -56,6 +56,10 @@ public class PaymentEntryHandler implements HandlerInterface {
@Override
public Transaction process(Transaction transaction) {
logger.info("Processing payment entry for transaction: {}", transaction.getReference());
if(transaction.getErpSalesPaymentRef() != null)
return transaction;
TransactionEvent transactionEvent = TransactionEvent.builder()
.transactionId(transaction.getId().toString())
.event(RequestType.SALES_PAYMENT.name())

View File

@@ -61,6 +61,10 @@ public class PurchaseInvoiceHandler implements HandlerInterface {
@Override
public Transaction process(Transaction transaction) {
logger.info("Processing purchase invoice for transaction: {}", transaction.getReference());
if(transaction.getErpPurchaseRef() != null)
return transaction;
TransactionEvent transactionEvent = TransactionEvent.builder()
.transactionId(transaction.getId().toString())
.event(RequestType.PURCHASE_INVOICE.name())

View File

@@ -62,6 +62,10 @@ public class PurchasePaymentEntryHandler implements HandlerInterface {
@Override
public Transaction process(Transaction transaction) {
logger.info("Processing purchase payment entry for transaction: {}", transaction.getReference());
if(transaction.getErpPurchasePaymentRef() != null)
return transaction;
TransactionEvent transactionEvent = TransactionEvent.builder()
.transactionId(transaction.getId().toString())
.event(RequestType.PURCHASE_PAYMENT.name())

View File

@@ -56,6 +56,10 @@ public class SalesInvoiceHandler implements HandlerInterface {
@Transactional
public Transaction process(Transaction transaction) {
logger.info("Processing sales invoice for transaction: {}", transaction.getReference());
if(transaction.getErpSalesRef() != null)
return transaction;
TransactionEvent transactionEvent = TransactionEvent.builder()
.transactionId(transaction.getId().toString())
.event(RequestType.SALES_INVOICE.name())