Docs‎ > ‎Reactive Logic Tutorial‎ > ‎

Validation (Place new order)

This page explores the solution to the Behavior: Check Credit.

Problem

Using the process described on the Rules page, solves: 

 Step  In the example  Notes
 Epic  Order Processing  
 User Story  Place Order  
 Behavior  Check Credit  Ensure that the balance does not exceed the credit limit


Solution

Context

The relevant Domain Objects:

How to Run

To explore Place Order:
  1. Open the Sample API project.
  2. Navigate to the REST Lab.
  3. For the endpoint, select Resource and PartnerOrder.
  4. Enter the following request body in the Request Body:
    Request Body
    {
        "is_ready": false,
        "approving_officer": "G PO.1",
        "salesrep_name": "A. Lincoln",
        "customer_name": "Gloria's Garden",
        "LineItems": [
         {   "product_name": "Hammer",
    "quantity_ordered": 1
         }
        ]
    }
  5. Click POST.
    The following response is expected:

Operation

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 

For more information:

Concepts Illustrated

For more information about viewing the most common business logic pattern, Constraining Chained Derivations, see Logic Patterns. This business logic pattern also illustrates the Replicate Junction Pattern.