Place Order (Validation) Example

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

Problem

Using the process described on the Manage, Rules page, solves:

StepIn the ExampleNotes
EpicOrder Processing 
User storyPlace Order 
BehaviorCheck CreditEnsure that the balance does not exceed the credit limit.

Solution

The following image shows the solution on the Manage, Rules, By topic tab:

Context

The following image shows the relevant domain objects:

Run this Example

  1. Open the Sample API project.
  2. Go to the REST Lab.
  3. For the endpoint, select Resource and PartnerOrder.
  4. Copy and paste the following JSON into 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:
  6. 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 about chaining and adjustments, see Logic Execution.

Concepts Illustrated

The most common business logic pattern is Constraining Chained Derivations. This business logic pattern also illustrates the Replicate Junction pattern.

For more information about the Constraining Chained Derivations and Replicate Junction patterns, see Logic Patterns.