I am creating an approval procedure for SO, checking balance, due inovices and payment terms. The approval should not be trigger when the SO is cash basic. The payment term cash basic has code -1. This is my query. I got the error Could not commit transaction.
What is wrong?
SELECT CASE WHEN T0.Balance+$[$29.0.NUMBER] > T0.CreditLine AND
$[ORDR.GroupNum] <> (-1 ))
(SELECT COUNT(*) FROM [dbo].[OINV] T1 WHERE T1.DocDueDate<GetDate() AND T1.DocStatus='O' AND T1.CardCode = $[ORDR.CardCode]) > 0
$[ORDR.GroupNum] <> (-1 )
ELSE 'FALSE' END
FROM [dbo].[OCRD] T0
WHERE T0.CardCode = $[ORDR.CardCode]