|
|
|
|
/****** Object: View [dbo].[vImprot_Print_FYTZ] Script Date: 12/30/2013 13:24:47 ******/
|
|
|
|
|
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vImprot_Print_FYTZ]'))
|
|
|
|
|
DROP VIEW [dbo].[vImprot_Print_FYTZ]
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
/****** Object: View [dbo].[vImprot_Print_FYTZ] Script Date: 12/30/2013 13:24:47 ******/
|
|
|
|
|
SET ANSI_NULLS ON
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
SET QUOTED_IDENTIFIER ON
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE VIEW [dbo].[vImprot_Print_FYTZ]
|
|
|
|
|
AS
|
|
|
|
|
select *,convert(numeric(18,2),(T1.RMBbalance+T1.shouxu+T1.dianhui+T1.tax_1+T1.tax_zz_1
|
|
|
|
|
+T1.daili_1+T1.tuoche+T1.THC)) total from
|
|
|
|
|
(select m.contractno,m.buyer,(select u.showname from [user] u where u.codename=m.creator) creatorref,
|
|
|
|
|
dbo.f_factoryno(m.contractno) factoryno,
|
|
|
|
|
case [ArrivalDate] when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar,[ArrivalDate],120) end as ArrivalDate ,
|
|
|
|
|
(select cc.codename from code_currency cc where cc.gid=(select top 1 c1.currid from import_cargo c1 where c1.contractno=m.contractno)) currency,
|
|
|
|
|
(select sum(c1.amount) from import_cargo c1 where c1.contractno=m.contractno) amount,m.billno,m.containerno,m.sealno,
|
|
|
|
|
(select sum(c1.prepayments) from import_cargo c1 where c1.contractno=m.contractno) prepayments,
|
|
|
|
|
(select sum(c1.balance) from import_cargo c1 where c1.contractno=m.contractno) balance,
|
|
|
|
|
dbo.get_Fee(m.contractno,'β<EFBFBD><EFBFBD>',1) RMBbalance,dbo.get_Fee(m.contractno,'β<EFBFBD><EFBFBD>',1) /
|
|
|
|
|
(case (select sum(c1.balance) from import_cargo c1 where c1.contractno=m.contractno) when null then 1 when 0 then 1 else
|
|
|
|
|
(select sum(c1.balance) from import_cargo c1 where c1.contractno=m.contractno) end) exchange,
|
|
|
|
|
dbo.get_Fee(m.contractno,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1) shouxu,dbo.get_Fee(m.contractno,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1) dianhui,
|
|
|
|
|
(select sum(c1.tax_amount*c1.exchangerate_customs) from import_cargo c1 where c1.contractno=m.contractno) tax_amount,
|
|
|
|
|
(select top 1 c1.tax from import_cargo c1 where c1.contractno=m.contractno) tax,
|
|
|
|
|
(select top 1 c1.tax_zz from import_cargo c1 where c1.contractno=m.contractno) tax_zz,
|
|
|
|
|
(select sum(c1.tax_amount*c1.exchangerate_customs) from import_cargo c1 where c1.contractno=m.contractno)*(
|
|
|
|
|
(select top 1 c1.tax from import_cargo c1 where c1.contractno=m.contractno)) tax_1,
|
|
|
|
|
(select sum(c1.tax_amount*c1.exchangerate_customs) from import_cargo c1 where c1.contractno=m.contractno)*(
|
|
|
|
|
1+(select top 1 c1.tax from import_cargo c1 where c1.contractno=m.contractno))*
|
|
|
|
|
(select top 1 c1.tax_zz from import_cargo c1 where c1.contractno=m.contractno) tax_zz_1,
|
|
|
|
|
(select top 1 c1.unitprice from ch_fee c1 where c1.bsno=m.contractno and c1.feename='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>') daili,
|
|
|
|
|
(select sum(c1.[weight]) from import_cargo c1 where c1.contractno=m.contractno)/1000 [weight],
|
|
|
|
|
dbo.get_Fee(m.contractno,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1) daili_1,dbo.get_Fee(m.contractno,'<EFBFBD>ϳ<EFBFBD><EFBFBD><EFBFBD>',1) tuoche,dbo.get_Fee(m.contractno,'THC',1) THC
|
|
|
|
|
,case paydate when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar,paydate,23) end as paydate
|
|
|
|
|
|
|
|
|
|
from import_main m --where m.contractno='"+ContractNo+"'
|
|
|
|
|
) T1
|
|
|
|
|
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|