minor adjustments to polling flow
This commit is contained in:
@@ -46,6 +46,7 @@ public class TransactionWorkflow extends WorkflowDefinition {
|
|||||||
public static final State SALES_INVOICE = new State("salesInvoice");
|
public static final State SALES_INVOICE = new State("salesInvoice");
|
||||||
public static final State JOURNAL_ENTRY = new State("journalEntry");
|
public static final State JOURNAL_ENTRY = new State("journalEntry");
|
||||||
public static final State SALES_PAYMENT = new State("salesPayment");
|
public static final State SALES_PAYMENT = new State("salesPayment");
|
||||||
|
public static final State SALES_PAYMENT_SUCCESS = new State("salesPaymentSuccess", WorkflowStateType.manual);
|
||||||
public static final State PURCHASE_INVOICE = new State("purchaseInvoice");
|
public static final State PURCHASE_INVOICE = new State("purchaseInvoice");
|
||||||
public static final State INTEGRATION = new State("integration");
|
public static final State INTEGRATION = new State("integration");
|
||||||
public static final State PURCHASE_INVOICE_PAYMENT = new State("purchaseInvoicePayment");
|
public static final State PURCHASE_INVOICE_PAYMENT = new State("purchaseInvoicePayment");
|
||||||
@@ -71,7 +72,7 @@ public class TransactionWorkflow extends WorkflowDefinition {
|
|||||||
permit(POLL_STATUS, SALES_INVOICE, TRAN_FAILED);
|
permit(POLL_STATUS, SALES_INVOICE, TRAN_FAILED);
|
||||||
permit(SALES_INVOICE, JOURNAL_ENTRY);
|
permit(SALES_INVOICE, JOURNAL_ENTRY);
|
||||||
permit(JOURNAL_ENTRY, SALES_PAYMENT);
|
permit(JOURNAL_ENTRY, SALES_PAYMENT);
|
||||||
permit(SALES_PAYMENT, DONE);
|
permit(SALES_PAYMENT, SALES_PAYMENT_SUCCESS, DONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NextAction calculateCharges(StateExecution execution) {
|
public NextAction calculateCharges(StateExecution execution) {
|
||||||
@@ -308,11 +309,23 @@ public class TransactionWorkflow extends WorkflowDefinition {
|
|||||||
transaction = (Transaction) handlerInterface.process(transaction);
|
transaction = (Transaction) handlerInterface.process(transaction);
|
||||||
|
|
||||||
execution.setVariable("body", Utils.toJson(transaction));
|
execution.setVariable("body", Utils.toJson(transaction));
|
||||||
return NextAction.moveToState(DONE,
|
|
||||||
|
// it's possible to have a flow that ends up here though
|
||||||
|
// integration has already happened
|
||||||
|
if(transaction.getIntegrationStatus() == Status.SUCCESS){
|
||||||
|
return NextAction.moveToState(DONE,
|
||||||
|
"Integration already complete");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextAction.moveToState(SALES_PAYMENT_SUCCESS,
|
||||||
"Sales payment successful - id: " + transaction.getErpSalesPaymentRef());
|
"Sales payment successful - id: " + transaction.getErpSalesPaymentRef());
|
||||||
}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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void salesPaymentSuccess(StateExecution execution) {
|
||||||
|
log.info("Sales payment completed successfully");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user