SELECT dbo.FEE_IN.ID ,
cast(0 as bit) as choice,
'应收' as class,
dbo.JOB_SE.JOBNO,
dbo.PD_FEEITEM.FEEITEM_CNAME,
dbo.PD_COMPANY.COMP_C_CNAME,
dbo.FEE_IN.CURRENCY,
dbo.FEE_IN.AMOUNT,
dbo.FEE_IN.PRICE,
dbo.FEE_IN.NUMERIC,
dbo.FEE_IN.FLAG_SH,
dbo.FEE_IN.FLAG_KP,
dbo.FEE_IN.INVOICE_NO,
dbo.FEE_IN.JSMODE
FROM
dbo.FEE_IN LEFT OUTER JOIN dbo.PD_COMPANY
ON dbo.FEE_IN.COMPANY_ID = dbo.PD_COMPANY.ID
LEFT OUTER JOIN dbo.PD_FEEITEM
ON dbo.FEE_IN.FEEITEM_ID = dbo.PD_FEEITEM.ID
LEFT OUTER JOIN dbo.JOB_SE
ON dbo.FEE_IN.PARENTID=dbo.JOB_SE.ID
where dbo.FEE_IN.FLAG_SH = '1' and isnull(FLAG_KP,'')='0'
union all
SELECT dbo.FEE_OUT.ID ,
cast(0 as bit) as choice,
'应付' as class,
dbo.JOB_SE.JOBNO,
dbo.PD_FEEITEM.FEEITEM_CNAME,
dbo.PD_COMPANY.COMP_C_CNAME,
dbo.FEE_OUT.CURRENCY,
dbo.FEE_OUT.AMOUNT,
dbo.FEE_OUT.PRICE,
dbo.FEE_OUT.NUMERIC,
dbo.FEE_OUT.FLAG_SH,
dbo.FEE_OUT.FLAG_KP,
dbo.FEE_OUT.INVOICE_NO,
dbo.FEE_OUT.JSMODE
FROM
dbo.FEE_OUT LEFT OUTER JOIN dbo.PD_COMPANY
ON dbo.FEE_OUT.COMPANY_ID = dbo.PD_COMPANY.ID
LEFT OUTER JOIN dbo.PD_FEEITEM
ON dbo.FEE_OUT.FEEITEM_ID = dbo.PD_FEEITEM.ID
LEFT OUTER JOIN dbo.JOB_SE
ON dbo.FEE_OUT.PARENTID=dbo.JOB_SE.ID
where dbo.FEE_out.FLAG_SH = '1' and isnull(FLAG_KP,'')='0'
";