minor improvements
This commit is contained in:
@@ -237,8 +237,8 @@ public class TransactionWorkflow extends WorkflowDefinition {
|
|||||||
execution.setVariable("body", Utils.toJson(transaction));
|
execution.setVariable("body", Utils.toJson(transaction));
|
||||||
return NextAction.moveToState(PURCHASE_INVOICE_PAYMENT, "Integration request successful");
|
return NextAction.moveToState(PURCHASE_INVOICE_PAYMENT, "Integration request successful");
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.info(e.getCause().getMessage());
|
||||||
return NextAction.moveToState(FAILED, e.getMessage());
|
return NextAction.moveToState(FAILED, e.getCause().getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ public class TransactionWorkflow extends WorkflowDefinition {
|
|||||||
transaction = process(transaction, "purchaseInvoicePayment");
|
transaction = process(transaction, "purchaseInvoicePayment");
|
||||||
execution.setVariable("body", Utils.toJson(transaction));
|
execution.setVariable("body", Utils.toJson(transaction));
|
||||||
return NextAction.moveToState(DONE,
|
return NextAction.moveToState(DONE,
|
||||||
"Purchase invoice payment generated - id: " + transaction.getErpPurchaseRef());
|
"Purchase invoice payment generated - id: " + transaction.getErpPurchasePaymentRef());
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return NextAction.retryAfter(new DateTime().plusMinutes(1), e.getMessage());
|
return NextAction.retryAfter(new DateTime().plusMinutes(1), e.getMessage());
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ public class IntegrationHandler implements HandlerInterface {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
transactionProcessorInterface.process(transaction);
|
transactionProcessorInterface.process(transaction);
|
||||||
transaction.setIntegrationStatus(transaction.getStatus());
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.getCause().printStackTrace();
|
e.getCause().printStackTrace();
|
||||||
transaction.setStatus(Status.FAILED);
|
transaction.setStatus(Status.FAILED);
|
||||||
@@ -70,6 +69,12 @@ public class IntegrationHandler implements HandlerInterface {
|
|||||||
transactionEvent.setMessage(transaction.getErrorMessage());
|
transactionEvent.setMessage(transaction.getErrorMessage());
|
||||||
transactionEventService.save(transactionEvent);
|
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);
|
Transaction t1 = Utils.deepCopy(transaction, Transaction.class);
|
||||||
transactionService.save(transaction);
|
transactionService.save(transaction);
|
||||||
return t1;
|
return t1;
|
||||||
|
|||||||
@@ -53,12 +53,13 @@ public class PollStatusHandler implements HandlerInterface {
|
|||||||
transactionEventService.save(transactionEvent);
|
transactionEventService.save(transactionEvent);
|
||||||
|
|
||||||
transaction.setPollingStatus(transaction.getStatus());
|
transaction.setPollingStatus(transaction.getStatus());
|
||||||
|
transaction.setPaymentStatus(transaction.getStatus());
|
||||||
|
|
||||||
// if transaction wasn't successful, throw and halt workflow
|
// if transaction wasn't successful, throw and halt workflow
|
||||||
if(transaction.getStatus() != Status.SUCCESS){
|
if(transaction.getStatus() != Status.SUCCESS){
|
||||||
|
transactionService.save(transaction);
|
||||||
throw new ApiException("Transaction failed: " + transaction.getErrorMessage() );
|
throw new ApiException("Transaction failed: " + transaction.getErrorMessage() );
|
||||||
}else {
|
}else {
|
||||||
transaction.setPaymentStatus(transaction.getStatus());
|
|
||||||
transaction.setErrorMessage(null);
|
transaction.setErrorMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ public class JournalEntryHandler implements HandlerInterface {
|
|||||||
@Override
|
@Override
|
||||||
public Transaction process(Transaction transaction) {
|
public Transaction process(Transaction transaction) {
|
||||||
logger.info("Processing journal entry for transaction: {}", transaction.getReference());
|
logger.info("Processing journal entry for transaction: {}", transaction.getReference());
|
||||||
|
|
||||||
|
if(transaction.getErpJournalRef() != null)
|
||||||
|
return transaction;
|
||||||
|
|
||||||
TransactionEvent transactionEvent = TransactionEvent.builder()
|
TransactionEvent transactionEvent = TransactionEvent.builder()
|
||||||
.transactionId(transaction.getId().toString())
|
.transactionId(transaction.getId().toString())
|
||||||
.event(RequestType.JOURNAL_ENTRY.name())
|
.event(RequestType.JOURNAL_ENTRY.name())
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ public class PaymentEntryHandler implements HandlerInterface {
|
|||||||
@Override
|
@Override
|
||||||
public Transaction process(Transaction transaction) {
|
public Transaction process(Transaction transaction) {
|
||||||
logger.info("Processing payment entry for transaction: {}", transaction.getReference());
|
logger.info("Processing payment entry for transaction: {}", transaction.getReference());
|
||||||
|
|
||||||
|
if(transaction.getErpSalesPaymentRef() != null)
|
||||||
|
return transaction;
|
||||||
|
|
||||||
TransactionEvent transactionEvent = TransactionEvent.builder()
|
TransactionEvent transactionEvent = TransactionEvent.builder()
|
||||||
.transactionId(transaction.getId().toString())
|
.transactionId(transaction.getId().toString())
|
||||||
.event(RequestType.SALES_PAYMENT.name())
|
.event(RequestType.SALES_PAYMENT.name())
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ public class PurchaseInvoiceHandler implements HandlerInterface {
|
|||||||
@Override
|
@Override
|
||||||
public Transaction process(Transaction transaction) {
|
public Transaction process(Transaction transaction) {
|
||||||
logger.info("Processing purchase invoice for transaction: {}", transaction.getReference());
|
logger.info("Processing purchase invoice for transaction: {}", transaction.getReference());
|
||||||
|
|
||||||
|
if(transaction.getErpPurchaseRef() != null)
|
||||||
|
return transaction;
|
||||||
|
|
||||||
TransactionEvent transactionEvent = TransactionEvent.builder()
|
TransactionEvent transactionEvent = TransactionEvent.builder()
|
||||||
.transactionId(transaction.getId().toString())
|
.transactionId(transaction.getId().toString())
|
||||||
.event(RequestType.PURCHASE_INVOICE.name())
|
.event(RequestType.PURCHASE_INVOICE.name())
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ public class PurchasePaymentEntryHandler implements HandlerInterface {
|
|||||||
@Override
|
@Override
|
||||||
public Transaction process(Transaction transaction) {
|
public Transaction process(Transaction transaction) {
|
||||||
logger.info("Processing purchase payment entry for transaction: {}", transaction.getReference());
|
logger.info("Processing purchase payment entry for transaction: {}", transaction.getReference());
|
||||||
|
|
||||||
|
if(transaction.getErpPurchasePaymentRef() != null)
|
||||||
|
return transaction;
|
||||||
|
|
||||||
TransactionEvent transactionEvent = TransactionEvent.builder()
|
TransactionEvent transactionEvent = TransactionEvent.builder()
|
||||||
.transactionId(transaction.getId().toString())
|
.transactionId(transaction.getId().toString())
|
||||||
.event(RequestType.PURCHASE_PAYMENT.name())
|
.event(RequestType.PURCHASE_PAYMENT.name())
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ public class SalesInvoiceHandler implements HandlerInterface {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public Transaction process(Transaction transaction) {
|
public Transaction process(Transaction transaction) {
|
||||||
logger.info("Processing sales invoice for transaction: {}", transaction.getReference());
|
logger.info("Processing sales invoice for transaction: {}", transaction.getReference());
|
||||||
|
|
||||||
|
if(transaction.getErpSalesRef() != null)
|
||||||
|
return transaction;
|
||||||
|
|
||||||
TransactionEvent transactionEvent = TransactionEvent.builder()
|
TransactionEvent transactionEvent = TransactionEvent.builder()
|
||||||
.transactionId(transaction.getId().toString())
|
.transactionId(transaction.getId().toString())
|
||||||
.event(RequestType.SALES_INVOICE.name())
|
.event(RequestType.SALES_INVOICE.name())
|
||||||
|
|||||||
Reference in New Issue
Block a user