Kindly check on my script below:
SELECT Distinct 'TRUE' FROM OCRD T0
inner join OCRD t1 on t1.CardCode=t0.FatherCard
WHERE T0.CardCode =$[ORDR.CardCode] AND (t1.[Balance]+$[ORDR.DocTotal])>T1.[CreditLine]
AND ((T1.[Balance]+$[ORDR.DocTotal]) - T1.[CreditLine]) > T1.[CreditLine] *0.2
I have a business partner with multiple consolidated accounts. How I can I block it when creating sales order. the query should check all balances of all consolidated accounts for this business partners and block its Sales Order when the total balances is greater than the shared credit limit.