For each line item on the sales order where the material has the same material pricing group (VBAP-KONDM = MVKE-KONDM) and the item category (VBAP-PSTYV) is relevant for pricing (TVAP where TVAP-PSTYV = VBAP-PSTYV and TVAP-PRSFD = X).
Add up the order quanity (VBAP-KWMENG) of all matching line items into total order quantity.
Get the contract line item for the material (VBAP where VBAP-VBELN = VBAP-VGBEL and VBAP-POSNR = VGPOS).
Calculate net agreed quanity from contract quanity (VBAP-UMVKN) less underdelivery tolerance percentage (VBAP-UNTTO).
The condition type has to be applied if the total order quantity is less than the net agreed quanity