Extensible Libraries Example

Extensible Libraries Example
lac42
The Extensible Libraries example processes and allocates payments by including custom Java and JavaScript code.
Allocate Payment to Orders
The patterns illustrate the most common patterns we see in logic design. The following sections describe the more complicated cases we have seen through extensive experience. The solutions are short. The coding to deliver complex problems is small. The solutions, on the other hand, are dense. This illustrates the power of logic to address complexity, and also that the real job centers on the design and approach instead of low level coding. Exactly where it should be.
Add Payment - allocate to orders
 
The Add
 Payment - allocate to orders is a classic example of the providing an allocation re-usable service by way of business logic extensibility. In the following example, a Payment is added to a Customer, and its amount is allocated to that Customers' outstanding unpaid orders:
  CA Technologies.png  
See the Sample Database (excerpted previously):
  1. The 
    allocateFromTo
     rule creates 
    payment_order_allocation
     rows that represent the amount of the payment disbursed to each recipient order.
  2.  
    payment_order_allocation
     logic determines the exact amount allocated.
  3. The 
    orders.amount_paid
     is incremented.
  4. The 
    orders.amount_un_paid
     adjusts the 
    customers.balance
    .
The following image shows the full logic (six rules):
  CA Technologies.png  
The following image shows the full payments event logic (previously summarized):
CA Technologies.png
Explore allocation using the REST Lab. Allocation is an prevalent pattern. Study the Explore Allocation example carefully.
For more information about exploring allocation, see Allocation Example.