跳至主要內容

日记账分录:供应商应付

五六零网校大约 1 分钟

日记账分录:供应商应付

取值日记账分录OJDT

代码示例

SELECT CASE 
		WHEN T2.[CardName] IS NULL
		AND T0.[TransType] = '18' THEN TA.[Cardcode]
		WHEN T2.[CardName] IS NULL
		AND T0.[TransType] = '21' THEN TB.[Cardcode]
		WHEN T2.[CardName] IS NULL
		AND T0.[TransType] = '20' THEN TC.[Cardcode]
		WHEN T2.[CardName] IS NOT NULL THEN T1.ShortName
	END AS '业务伙伴代码'
	, CASE 
		WHEN T2.[CardName] IS NULL
		AND T0.[TransType] = '18' THEN TA.[CardName]
		WHEN T2.[CardName] IS NULL
		AND T0.[TransType] = '21' THEN TB.[CardName]
		WHEN T2.[CardName] IS NULL
		AND T0.[TransType] = '20' THEN TC.[CardName]
		WHEN T2.[CardName] IS NOT NULL THEN T2.[CardName]
	END AS '业务伙伴名称', T0.[RefDate]
	, CASE 
		WHEN T0.[Series] = '17' THEN '主'
	END AS '序列'
	, CASE 
		WHEN T0.[TransType] = '20' THEN 'PD'
		WHEN T0.[TransType] = '18' THEN 'PU'
		WHEN T0.[TransType] = '21' THEN 'PR'
		WHEN T0.[TransType] = '30' THEN 'JE'
		WHEN T0.[TransType] = '46' THEN 'PS'
		WHEN T0.[TransType] = '19' THEN 'PC'
	END AS'类' , T0.[BaseRef] AS'单据编号',T0.[TransId], T0.[Memo],  LEFT(T1.[ContraAct],4) AS'抵消科目一级' , T5.[AcctName] AS '一级科目名称',T1.[ContraAct], T4.[AcctName] AS 抵消科目名称
	, T1.[Debit], T1.[Credit], T1.[Account], T3.[AcctName] AS 科目名称
FROM OJDT T0
	INNER JOIN JDT1 T1 ON T0.[TransId] = T1.[TransId]
	INNER JOIN OACT T3 ON T1.Account = T3.AcctCode
	INNER JOIN OACT T4 ON T1.[ContraAct] = T4.AcctCode
	INNER JOIN OACT T5 ON LEFT(T1.[ContraAct],4) = T5.AcctCode
	LEFT JOIN OCRD T2 ON T2.CardCode = T1.ShortName
	LEFT JOIN (
		SELECT T0.[Docentry], T0.[CardCode], T0.[CardName]
		FROM OPCH T0
	) TA
	ON TA.[Docentry] = T0.[BaseRef]
		AND T0.[TransType] = '18'
	LEFT JOIN (
		SELECT T0.[Docentry], T0.[CardCode], T0.[CardName]
		FROM ORPD T0
	) TB
	ON TB.[Docentry] = T0.[BaseRef]
		AND T0.[TransType] = '21'
	LEFT JOIN (
		SELECT T0.[Docentry], T0.[CardCode], T0.[CardName]
		FROM OPDN T0
	) TC
	ON TC.[Docentry] = T0.[BaseRef]
		AND T0.[TransType] = '20'
WHERE T1.[Account] IN ('220201', '220202', '220203', '220204')
	AND T0.[RefDate] >= [%0]
	AND T0.[RefDate] <= [%1]
ORDER BY T0.[BatchNum]