Place Order (Validation) Example

Place Order (Validation) Example
lac52
This article explores the solution to the Behavior: Check Credit.
In this article:
Problem
Using the process described in the rules, the solution solves the following:
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
The following image shows the solution in the Sample API:
Context
The following image shows the relevant domain objects:
CA Technologies
Run this Example
  1. Open the Sample API.
  2. In the Tools section, click
    REST Lab
    .
  3. For
    Endpoint
    , select 
    Resource
     as the endpoint on which you want to operate and
    PartnerOrder
     as the named resource.
  4. Copy and paste the following JSON into the Request body:
    {
        "isReady": false,
        "approving_officer": "G PO.1",
        "salesrep_name": "A. Lincoln",
        "customer": "Gloria's Garden",
        "LineItems": [
         {   "productName": "Hammer",
    "quantityOrdered": 1
         }
        ]
    }
  5. Click
    POST
    .
  6. In the Create section, click
    Rules
    .
  7. 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
    Computing the amount
    Orders.amount_un_paid
    Orders.amount_un_paid
    attribute amount
    adjusting amount_un_paid 
    Customer.balance
    Customer.balance
    amount_un_paid
    adjusting the balance
    Validation checkCredit
    Validation checkCredit
    balance
    accepting or rejecting the 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.