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.
43 lines
3.2 KiB
43 lines
3.2 KiB
11 months 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,bizdate as JzDate,
|
||
|
case billtype when '0' then '验收单' when '1' then '退货单' when '2' then '进价调整单' when '3' then '直送单' when '4' then '直送退货' when '5' then '直送进价调整单' when '6' then '配送单' when '7' then '配送退货单' when '8' then '配送进价调整单' end as YwTypeName,
|
||
|
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 cjcost-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,
|
||
|
case when billtype = '0' or billtype = '3' then (select orderno from t_accept_head where billno = b.YwBillNo)
|
||
|
end as RefBillNo,
|
||
|
case when billtype = '0' or billtype = '3' then '采购单'
|
||
|
end as RefBillType
|
||
|
from t_paysoa_body b
|
||
|
go
|
||
|
|
||
|
if exists (select * from sysobjects where id = OBJECT_ID(N'tAcpJsKxBody') and OBJECTPROPERTY(id, N'IsView') = 1)
|
||
|
drop view tAcpJsKxBody
|
||
|
go
|
||
|
create view tAcpJsKxBody as
|
||
|
select BillNo,b.orgcode as YwOrgCode,(select orgname from t_shop where orgcode = b.orgcode) as YwOrgName,
|
||
|
itemcode as KxCode, (select feename from t_fee where feecode = b.itemcode) as KxName,
|
||
|
case basetype when '000' then '1' else '0' end as AsnType,basetype as JsBase,
|
||
|
(select valuename from t_enum_value where enumcode='100013' and valuecode=b.basetype ) as JsBaseName,
|
||
|
RateBase,IsInvoice,feetotal as KxTotal,CalMode,CalBgnDate,CalEndDate,ClauseType,
|
||
|
tendcode as ZfCode,(select tendname from t_tend where tendcode=b.tendcode) as ZfName,
|
||
|
PluCode,(select pluname from t_plu where plucode=b.plucode) as PluName,
|
||
|
IsLadderRate,LadderCalType,Ext1,Ext2,Ext3,Ext4,Ext5,Remark
|
||
|
from t_paysoa_clause b
|
||
|
go
|