When an order is initiated, it is possible to select an agreement that will govern the orders (OrderTerms are cloned from AgreementTerms, if the agreement has a price list then the agreement prices are used in place of ProductPrice); however the agreementId is only added to the cart but it is lost when the order is saved. This causes issues if the order is edited: the agreement is lost and the system is unable to apply the agreement prices to the edited order.
The solution I am proposing is to add the agreementId field to OrderHeader entity. What do you think? Jacopo