用友U9 ERP-判断付款单是否允许核销SQL

2022/08/16

这篇文章发布于 608 天前,部分信息可能已经发生变化。

SQL如下

SELECT CASE
WHEN A.IsCfmAfterReach = 1
AND A.IsReached = 0 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断1[到账]',
CASE
WHEN A.IsReversed = 1 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断2[是否转回]',
CASE
WHEN A.RecObjType = -1 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断3[收款对象]',
CASE
WHEN A.Cancel_Canceled = 1 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断4[终止状态]',
CASE
WHEN A.IsChecked = 1 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断5[核对]',
CASE
WHEN A.IsFIClose = 1 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断6[财务关闭]',
CASE
WHEN A.DocStatus != 2 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断7[单据状态]',
CASE
WHEN A1.RecNoteTag > 0 THEN
'不允许核销'
ELSE
'允许核销'
END AS '判断8[收款票据标识]',
IsCfmAfterReach,
A.IsReached,
A.IsReversed,
A1.IsReversed,
A.RecObjType,
A.IsChecked,
A.IsFIClose
FROM AR_RecBillHead A
JOIN dbo.AR_RecBillLine A1
ON A.ID = A1.RecBillHead
JOIN AR_RecBillUseLine A2
ON A1.ID = A2.RecBillLine
WHERE A.DocNo = 'RECSZ2022070057';