There are 2 entities: Order and OrderItem (one-to-many, composition)
In OrderEdit it is possible to edit OrderItems as well.
The Order has an attribute “sum” which is the sum of all OrderItem prices.
When an OrderItem is changed the sum is updated in the editor.
Steps to reproduce the issue:
Open existing order (example with 2 items)
Edit 1st item (“Cup”) and set price to 100 (and save)
Sum in table is 130, but sum in field is 200
Analysis:
The order items table is sorted by the "Product" column - that's why the order of elements in the order items collection in order.items collection and in the collection container are different (sorting affects only collection container)
CollectionContainerImpl.replaceItem() evaluates the modified element index inside the CollectionPropertyContainer collection and then replaces the element with this index in the order.items property master collection, but elements order in both collections is different because of sorting
Environment
Description of the bug or enhancement
Sample project: dc-sort-demo.zip
Given:
Order
andOrderItem
(one-to-many, composition)OrderEdit
it is possible to editOrderItems
as well.Steps to reproduce the issue:
Analysis:
The order items table is sorted by the "Product" column - that's why the order of elements in the order items collection in order.items collection and in the collection container are different (sorting affects only collection container)
CollectionContainerImpl.replaceItem()
evaluates the modified element index inside the CollectionPropertyContainer collection and then replaces the element with this index in the order.items property master collection, but elements order in both collections is different because of sortingForum topic: https://forum.cuba-platform.com/t/merge-compostion-in-editor-overrides-wrong-item/15588