跳至主要內容

预付款申请单:限制不能超过来源订单总价

五六零网校小于 1 分钟

示例代码

--预付款不能超订单总价
IF @object_type='204'
 begin
 if @transaction_type='A' OR @transaction_type = 'U'
 begin
if exists(
SELECT 1 FROM OPOR T0 INNER JOIN
 (
SELECT T1.[BaseEntry],SUM(T0.[DocTotal]) as 'yf' FROM ODPO T0  INNER JOIN DPO1 T1 ON T0.[DocEntry] = T1.[DocEntry] GROUP BY T1.[BaseEntry]
) TA ON ta.baseentry=t0.docentry INNER JOIN DPO1 T2 ON T2.[BaseEntry]=t0.docentry WHERE T0.[DocTotal]-ta.yf<0

 AND t2.DocEntry=@list_of_cols_val_tab_del
)
begin
 select @error=1
 select @error_message='预付款不能超订单总价'
 
 end
 end
 end