You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/word/新协航_设计文档/数据库建表文档/20131120/打印格式:费用通知单.sql

43 lines
2.5 KiB
Transact-SQL

/****** Object: View [dbo].[vImprot_Print_FYTZ] Script Date: 12/10/2013 10:21:22 ******/
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/10/2013 10:21:22 ******/
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,'βżî',1) RMBbalance,dbo.get_Fee(m.contractno,'βżî',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,'ĘÖĐřˇŃ',1) shouxu,dbo.get_Fee(m.contractno,'ľçťăˇŃ',1) dianhui,
(select sum(c1.gettaxamount*c1.exchangerate_customs) from vImportcargo 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 from import_cargo c1 where c1.contractno=m.contractno) tax_zz,
(select sum(c1.gettaxamount*c1.exchangerate_customs*c1.tax) from vImportcargo c1 where c1.contractno=m.contractno) tax_1,
(select sum(c1.gettaxamount*c1.exchangerate_customs*(1+c1.tax)*c1.tax_zz) from vImportcargo 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='´úŔíˇŃ') daili,
(select sum(c1.[weight]) from import_cargo c1 where c1.contractno=m.contractno)/1000 [weight],
dbo.get_Fee(m.contractno,'´úŔíˇŃ',1) daili_1,dbo.get_Fee(m.contractno,'ÍĎłľˇŃ',1) tuoche,dbo.get_Fee(m.contractno,'THC',1) THC
from import_main m --where m.contractno='"+ContractNo+"'
) T1
GO