Extensible Libraries Example

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

This 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:

See the database structure (excerpted above):

    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 full logic (six rules) is shown here:

The full payments event logic (summarized above) is shown here:

Explore allocation using the REST Lab.

For more information about exploring allocation, see Explore Allocation Example.

Business Logic Pattern

Study this example carefully. Allocation is a prevalent pattern.

For more information about allocation, see Logic Patterns.