|
Documentation Programming With Andromeda Defining a Database
|
Previous: Fetching a Price
Next: Summing an Order
Calculating Extended PriceOne of the basic automations that Andromeda provides is taking two or more columns in a row and calculating a new value. The standard example is taking price and quantity and multiplying out extended price. The syntax may appear more complex than is really needed, but the reason is explained in our reference on a column.chain. table order_lines:
module: Orders
description: Order Lines
nomenu: Y
foreign_key items:
column price:
automation_id: FETCH
auto_formula: order_lines.price
column qty:
column price_ext:
suffix: _ext
chain calc:
test 00:
return: @qty * @price
The complexity of the syntax is there to allow conditional expressions. Let's improve our order system by allowing the operator to manually enter a price that would override the price from the items table. Then we want the extended value to reflect that. table order_lines:
module: Orders
description: Order Lines
nomenu: Y
foreign_key items:
column price:
automation_id: FETCH
auto_formula: order_lines.price
column price_man:
suffix: _man
description: Manual Price
automation_id: BLANK
column qty:
column price_ext:
suffix: _ext
chain calc:
test 00:
compare: @price_man = 0
return: @qty * @price
test 01:
return: @qty * @price_man
Previous: Fetching a Price
Next: Summing an Order
|
