Docs‎ > ‎Reactive Logic Tutorial‎ > ‎

Make Ready

Under construction

Placed Orders are often placed in a "Shopping Cart" state (order.is_ready == false), where they do not affect Customer balance and Product quantities until a subsequent Make Order Ready transaction is executed.  


Requirements: Adjust Balance and Product Quantities

We need to devise logic that, when an Order is "made ready" (PUT a purchase order, setting order.is_ready = true)...

  1. increases the customer's balance and 
  2. adjusts Product quantities, and 
  3. if reorderQuantity is exceeded, set reorderRequired
 We don't want to reduce Product inventory, and set reorder flags, until Purchaseorders are marked as ready. So, we need to define logic to make this happen.

This is a bit more challenging, since the Product is not directly related to Ordersso that the qualification condition cannot reference orders.is_ready.

 Step  In the example  Notes
 Epic  Order Processing  
 User Story  Make Order Ready  
 Behavior Adjust customer balance when order.is_ready=true  
 Behavior Adjust product total_qty_ordered when order.is_ready=true 
  Set is_reorder_required iff (onHand - qtyOrdered) < reorderQty


We solve this transaction by declaring the following logic:

Since the Customer has a Sum:

Derive customers.balance as sum(ordersList.amount_un_paid) where is_ready = true

The Balance is increased due to the Qualification Condition Change (is_ready) now being met.

We introduce Lineitem.is_ready, enabling us to define the following logic:

Implementation Notes:
  1. The LineItems.isReady Lineitems.is_ready Formula is a Parent Reference, so changes are Forward Chain altered Parent References to Children to each Lineitem
  2. That activates Lineitem logic, where the change to the Qualification Condition adjusts the Product.totalQtyOrdered
  3. That activates Product Logic, which computes products.is_reorder_required


The relevant Domain Objects:

How to Run

Request Body


Next, you define one or more rules that solve the identified behavior, Check Credit. The logic triggered by each LineItems insertion is summarized as follows:

 Object  Watches for  Reacts by  Which chains to
 LineItems.amount  inserts, deletes or changes to quantity or partPrice  Computes amount  Orders.amount_un_paid
 Orders.amount_un_paid  attribute amount  adjusts amount_un_paid   Customer.balance
 Customer.balance  amount_un_paid  adjusts balance  Validation checkCredit
 Validation checkCredit  balance  accept or reject transaction  

Concepts Illustrated


Business Logic Pattern

This illustrates a highly recommended and common Business Logic Pattern: the Ready Flag.

Integration Example

RESTful APIs are an excellent mechanism for interacting with other systems, both as a receiver and as a sender.  To understand how this example operates, please review this Integration Example, based on JavaScript Extensibility.

The following business logic builds on the MakeOrder logic (above) to send the Regulatory Reporting Message:

It operates in conjunction with the following Request Event, using SysUtility.getResource to retrieve the JSON for the designated Resource.

Resources for partner mapping

This illustrates a useful logic patterns: Resources to define partner column mappings.

Resources provide column projection and aliasing.

You can define Resources that map to partner names, which can be used to receive or send REST/JSON messages.