Skip to content

aleksey-stukalov/synchronous-clientside-calculations

Repository files navigation

synchronous-clientside-calculations

The sample shows how to calculate fields like "total amount", depending on the changes of the other fields, including sub-collections like items in an order.

Created in response to the "total amount" qestion on the CUBA support forum.

Short Project Overview

The Order entity contains two sets of order items:

The total price field of an order is calculated in the OrderEdit controller of the order-edit screen as sum of amount values of all order items, products and services.

Amounts of each line of the order items are calculated in the OrderProductItemEdit and OrderServiceItemEdit controllers of the product-item-edit and service-item-edit screens accordingly, using the following logic:

  • For product order items: the product price (defined in the Product entity) is multiplied by the quantity field (defined in the OrderProductItem entity)
  • For service order items: the service hourly price (defined in the Service entity) is multiplied by the hours field (defined in the OrderServiceItem entity)

About

The sample shows how to calculate fields like "total amount" depending on the changes in other fields, including sub-collections like OrderItems

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages