You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
2.2 KiB

1 year ago
if exists (select * from sysobjects where id = OBJECT_ID(N'tAcpJsRcpBody') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view tAcpJsRcpBody
go
create view tAcpJsRcpBody as
select b.BillNo,b.orgcode as YwOrgCode,(select orgname from t_shop where orgcode = b.orgcode) as YwOrgName,
YwBillNo,billtype as YwType,
case billtype when '0' then '<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>' when '1' then '<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>' when '2' then '<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' when '3' then 'ֱ<EFBFBD>͵<EFBFBD>' when '4' then 'ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>' when '5' then 'ֱ<EFBFBD>ͽ<EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' when '6' then '<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>' when '7' then '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>' when '8' then '<EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' end as YwTypeName,
(CASE ISNULL(Rzdate,'') WHEN '' THEN NULL ELSE CONVERT(datetime,Rzdate + ' ' + RzTime,120) END) as JzDate,
case when billtype = '0' or billtype = '3' then (select cost from t_accept_head where billno = b.YwBillNo)
when billtype = '1' or billtype = '4' then (select cost from t_return_head where billno = b.YwBillNo)
when billtype = '2' or billtype = '5' or billtype = '8' then (select cjcost from t_adjbuyprice_head where billno = b.YwBillNo)
when billtype = '6' or billtype = '7' then (select zpamount from t_dist_head where billno = b.YwBillNo)
end as HJTotal,
case when billtype = '0' or billtype = '3' then (select netcost from t_accept_head where billno = b.YwBillNo)
when billtype = '1' or billtype = '4' then (select netcost from t_return_head where billno = b.YwBillNo)
when billtype = '2' or billtype = '5' or billtype = '8' then (select netcjcost from t_adjbuyprice_head where billno = b.YwBillNo)
when billtype = '6' or billtype = '7' then (select zpnetamount from t_dist_head where billno = b.YwBillNo)
end as WJTotal,
case when billtype = '0' or billtype = '3' then (select cost-netcost from t_accept_head where billno = b.YwBillNo)
when billtype = '1' or billtype = '4' then (select cost-netcost from t_return_head where billno = b.YwBillNo)
when billtype = '2' or billtype = '5' or billtype = '8' then (select netcost-netcjcost from t_adjbuyprice_head where billno = b.YwBillNo)
when billtype = '6' or billtype = '7' then (select zpamount-zpnetamount from t_dist_head where billno = b.YwBillNo)
end as JTaxTotal
from t_paysoa_body b, t_paysoa_head h where h.billno = b.billno
go