用友软件首页

用友U8 销售系统中进销存统计表与销售毛利分析不一致。正常时进销存统计表中的销售数量、销售金额应分别与销售毛利分析中的本期数量、毛利变动扩影响分析售价影响一致,但在用户处11月份不一致

2015-12-31 0:0:0 用友T1小编

用友U8 销售系统中进销存统计表与销售毛利分析不一致。正常时进销存统计表中的销售数量、销售金额应分别与销售毛利分析中的本期数量、毛利变动扩影响分析售价影响一致,但在用户处11月份不一致

用友U8 销售系统中进销存统计表与销售毛利分析不一致。正常时进销存统计表中的销售数量、销售金额应分别与销售毛利分析中的本期数量、毛利变动扩影响分析/售价影响一致,但在用户处11月份不一致。 问题原因:软件设计问题,Sa_moveSRMDetail存储过程其日期过滤条件的判断为大于起始日期。 解决方法:查询其他账表并与此两张表对比,发现销售毛利分析中数据是正确的,而进销存统计表数据不对。用SQL跟踪发现进销存统计表是调用存储过程Sa_moveSRMDetail进行数据查询的,仔细分析Sa_moveSRMDetail存储过程,发现其日期过滤条件的判断为大于起始日期,小于等于结束日期,也就是起始日期这一天给舍弃了,导致统计数据不对,改成大于等于起始日期后查询正确。if exists(select * from sysobjects where name='sa_MoveSRMDetail' and type='P')drop PROCEDURE sa_MoveSRMDetailgo-- U821版-- 2003.12.5-- 南京用友 丁德安-- 销售系统中进销存统计表的销售数量、销售收入不等于销售毛利分析中的本期数量和售价影响-- 经分析后发现是起始日期判断条件为'>',应为'>='CREATE PROCEDURE sa_MoveSRMDetail ( @chrtablename varchar (50) = null , @chrWhere varchar (255 ) = null , @chrStartDate varchar(20) = null , @chrendDate varchar(20) = null , @chrChecker varchar(40) = null , @chrDep varchar(50) = null , @chrWareHouse varchar(20) ) ASdeclare @chrsql varchar(4000) declare @chrCost varchar(40) declare @chrSaleDate varchar (50)-- 删除临时表 if exists (select name from tempdb..sysobjects where name ='tmp_srm') drop table tempdb..tmp_srm --删除进销存明细账--1 组织期初数据 --1.1 计算所有发出成本 if exists (select name from tempdb..sysobjects where name ='tmp_srmcost' ) drop table tempdb..tmp_srmcost --删除成本明细 --从成本明细账中取得销售成本和其他出库成本 set @chrsql= ' Select dkeepdate as ddate , cVouType AS cvoutype,cInvcode, cAccDep ,ia_subsidiary.cDepCode, bMoneyFlag, bSale, iMonth , Warehouse.cWhValueStyle AS cWhValueStyle , ia_subsidiary.cWhcode , iAOutQuantity , case when (cWhvaluestyle=''计划价法''or cWhvalueStyle=''售价法'') and bMoneyFlag=1 then isnull(iAOutPrice,0)- isnull(iDebitDifCost,0) + isnull(iCreditDifCost,0) else isnull ( iAOutPrice,0 ) end as iAOutPrice into tempdb..tmp_srmcost from ia_subsidiary inner join warehouse on ia_subsidiary.cwhcode = warehouse.cwhcodewhere brdflag = 0 ' if ltrim(rtrim(@chrwhere )) <> '' and not ( @chrwhere is null ) set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cAccdep ' + @chrdep if ltrim(rtrim(@chrenddate )) <> '' and not (@chrenddate is null ) set @chrsql = @chrsql + ' and dkeepdate<='''+ @chrenddate +''''if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and ia_subsidiary.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec (@chrsql )--计算非自填成本 set @chrCost=(SELECT cValue FROM AccInformation WHERE (cSysID = 'ia') AND (cName = 'cvaluestyle')) if @chrCost ='按部门核算'begin update tempdb..tmp_srmcost set tempdb..tmp_srmcost.iAOutPrice=case when (tempdb..tmp_srmcost.cWhvalueStyle='售价法' ) then tempdb..tmp_srmcost.iAoutPrice*(1 - isnull(ia_summary.iDifRate,0)) else tempdb..tmp_srmcost.iAoutPrice*(1 + isnull(ia_summary.iDifRate,0)) end from tempdb..tmp_srmcost inner join ia_summary on tempdb..tmp_srmcost.iMonth = ia_summary.iMonth and tempdb..tmp_srmcost.cDepCode = ia_summary.cDepCode and tempdb..tmp_srmcost.cInvCode = ia_summary.cInvCode where (tempdb..tmp_srmcost.cWhvaluestyle='计划价法'or tempdb..tmp_srmcost.cWhvalueStyle='售价法') and tempdb..tmp_srmcost.bMoneyFlag=0 and tempdb..tmp_srmcost.bSale<> 1 endelse begin update tempdb..tmp_srmcost set tempdb..tmp_srmcost.iAOutPrice=case when (tempdb..tmp_srmcost.cWhvalueStyle='售价法' ) then tempdb..tmp_srmcost.iAoutPrice*(1 - isnull(ia_summary.iDifRate,0)) else tempdb..tmp_srmcost.iAoutPrice*(1 + isnull(ia_summary.iDifRate,0)) end from tempdb..tmp_srmcost inner join ia_summary on tempdb..tmp_srmcost.iMonth = ia_summary.iMonth and tempdb..tmp_srmcost.cWhCode = ia_summary.cWhCode and tempdb..tmp_srmcost.cInvCode = ia_summary.cInvCode where (tempdb..tmp_srmcost.cWhvaluestyle='计划价法'or tempdb..tmp_srmcost.cWhvalueStyle='售价法') and tempdb..tmp_srmcost.bMoneyFlag=0 and tempdb..tmp_srmcost.bSale<> 1 end--完成成本计算所有的出库成本保存在临时文件 tempdb..tmp_srccost中 --1.3计算期初入库金额 --创建临时表tmp_srm保存查询统计的临时结果 --临时表结构 存货编号 ,部门编号 ,期初数量,期初金额,采购数量,采购金额 -- 暂诂数量,暂诂金额,其他入库数量,其他入库金额,销售数量 -- 销售金额,其他出库数量,其他出库金额,调拨数量,调拨金额 -- 收入金额,出库数量,成本 set @chrsql = 'Select cInvCode , caccdep ,iAinQuantity as qc_iQuantity , (iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) ) as qc_imoney ,(iAinPrice - iAinPrice) as iQuantityCG , (iAinPrice - iAinPrice) as iMoneyCG , (iAinPrice - iAinPrice) as iQuantityZG, (iAinPrice - iAinPrice) as iMoneyZG , (iAinPrice - iAinPrice) as iQuantityQTRK , (iAinPrice - iAinPrice) as iMoneyQTRK , (iAinPrice - iAinPrice) as iQuantityXS , (iAinPrice - iAinPrice) as iMoneyXS , (iAinPrice - iAinPrice) as iQuantityQTCK , (iAinPrice - iAinPrice) as iMoneyQTCK , (iAinPrice - iAinPrice) as iQuantityDB , (iAinPrice - iAinPrice) as iMoneyDB ,(iAinPrice - iAinPrice) as iMoneySR , (iAinPrice - iAinPrice) as iQuantityCK , (iAinPrice - iAinPrice) as iMoneyCB ,cwhcode into tempdb..tmp_srm from ia_subsidiary 'if ltrim(rtrim(@chrstartdate)) = '' or @chrstartdate is null begin --无期初日期时只计算上年结转 set @chrsql = @chrsql + ' where iMonth=0 and brdflag = 1 and cVoutype <>''33'' 'end else begin--有期初日期时的情况 set @chrsql = @chrsql + ' where brdflag = 1 and ( (iMonth = 0 and cVoutype <>''33'' ) or dkeepdate <='''+@chrstartdate +''' and ( cVoutype in (''01'',''24'',''30'',''08'',''20'',''22'',''10'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) ) ) 'end --加入日期和部门条件 if ltrim(rtrim(@chrwhere )) <> '' and not (@chrwhere is null ) set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cAccdep ' + @chrdep --加入仓库条件 if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and ia_subsidiary.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec ( @chrsql )--1.2 生成期初出库成本 if ltrim(rtrim(@chrstartdate)) <> '' and not ( @chrstartdate is null ) begin --如果无期初日期不应该计算期初发出内容 set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , caccdep ,- iAoutQuantity as qc_iQuantity , - iAoutPrice as qc_imoney ,0 as iQuantityCG , 0 as iMoneyCG , 0 as iQuantityZG, 0 as iMoneyZG , 0 as iQuantityQTRK , 0 as iMoneyQTRK , 0 as iQuantityXS , 0 as iMoneyXS , 0 as iQuantityQTCK , 0 as iMoneyQTCK , 0 as iQuantityDB , 0 as iMoneyDB ,0 as iMoneySR , 0 as iQuantityCK , 0 as iMoneyCB , cWhcode from tempdb..tmp_srmcost where cvoutype in (''09'',''11'',''21'',''26'',''27'',''28'',''29'',''32'') 'set @chrsql = @chrsql + ' and ddate <=''' + @chrstartdate + '''' exec(@chrsql )end --完成期初数据的准备 --2 组织本期数据 --2.1 统计本期采购入库数据:采购入库数量,采购入库金额,暂诂入库数量,暂诂入库金额,其它入库数量,其他入库金额set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , caccdep ,0 as qc_iQuantity ,0 as qc_imoney ,case when cvoutype in(''01'',''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinQuantity else 0end iQuantityCG , case when cvoutype in(''01'',''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) else 0end as iMoneyCG , case when ( cvoutype = ''01'' and bflag = 1 ) or cvoutype in(''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinQuantity else 0end as iQuantityZG, case when ( cvoutype = ''01'' and bflag = 1 ) or cvoutype in(''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) else 0end as iMoneyZG , case when cVoutype in (''08'',''20'',''22'',''10'') then iAinQuantity else 0 end as iQuantityQTRK , case when cVoutype in (''08'',''20'',''22'',''10'') then iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) else 0 end as iMoneyQTRK , 0 as iQuantityXS , 0 as iMoneyXS , 0 as iQuantityQTCK , 0 as iMoneyQTCK , 0 as iQuantityDB , 0 as iMoneyDB ,0 as iMoneySR , 0 as iQuantityCK , 0 as iMoneyCB , cWhcode from ia_subsidiary Where bRdflag = 1 and iMonth > 0 and ( cVoutype in (''01'',''24'',''30'',''08'',''20'',''22'',''10'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) ) '--追加开始日期条件 if ltrim(rtrim(@chrstartdate)) <> '' and not ( @chrstartdate is null ) set @chrsql = @chrsql + ' and dkeepdate>''' + @chrstartdate + ''''--追加结束日期条件 if ltrim(rtrim(@chrenddate)) <> ''and not ( @chrenddate is null ) set @chrsql = @chrsql + ' and dkeepdate<=''' + @chrenddate + ''''--追加其他条件 if ltrim(rtrim(@chrwhere)) <> '' and not @chrwhere is null set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cAccdep ' + @chrdep --加入仓库条件 if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and ia_subsidiary.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec(@chrsql ) --end 本期采购部分计算结束 --2.3 统计本期销售数量,销售金额,销售调拨数量,销售调拨金额 -- 取得销售系统启用日期 set @chrsaledate = (select isnull(cValue,'1900-01-01') from accinformation where cSysid='Sa' and cName='dStartDate' ) if @chrsaledate <> '' begin if len(ltrim(rtrim(@chrsaledate))) <= 8 set @chrsaledate = convert(varchar(10),convert(smalldatetime,@chrsaledate,2),121)set @chrsaleDate = ' and SalebillVouch.dDate>=''' + @chrsaledate + ''''end --计算本期销售数据 set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , cdepcode as caccdep ,0 as qc_iQuantity , 0 as qc_imoney ,0 as iQuantityCG , 0 as iMoneyCG , 0 as iQuantityZG, 0 as iMoneyZG , 0 as iQuantityQTRK , 0 as iMoneyQTRK , iQuantity as iQuantityXS , iNatSum as iMoneyXS , 0 as iQuantityQTCK , 0 as iMoneyQTCK , case when cvouchtype = ''28'' then iQuantity else 0 end as iQuantityDB , case when cvouchtype =''28'' then iNatMoney else 0 end as iMoneyDB ,iNatMoney as iMoneySR , 0 as iQuantityCK , 0 as iMoneyCB , Salebillvouchs.cWhcode From Salebillvouchs inner join Salebillvouch on salebillvouchs.sbvid = salebillvouch.sbvid where isnull(Salebillvouch.cinvalider ,'''')='''' ' + @chrsaledate --增加审核条件 if ltrim(rtrim(@chrchecker)) <> '' and not (@chrchecker is null ) set @chrsql = @chrsql + ' and ' + @chrchecker --增加开始日期条件 if ltrim(rtrim(@chrstartdate)) <> '' and not (@chrstartdate is null ) -- 2003.12.5 丁德安--set @chrsql = @chrsql + ' and ddate >''' + @chrstartdate + ''''set @chrsql = @chrsql + ' and ddate >=''' + @chrstartdate + ''''--增加结束日期条件 if ltrim(rtrim(@chrenddate )) <> '' and not (@chrenddate is null )set @chrsql = @chrsql + ' and ddate <=''' + @chrenddate + '''' --增加一般条件 if ltrim(rtrim(@chrwhere)) <> '' and not (@chrwhere is null )set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cdepCode ' + @chrdep --加入仓库条件 if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and Salebillvouchs.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec (@chrsql )--本期收入计算终止 --2.4 统计本期销售成本,销售收入,出库数量 set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , caccdep ,0 as qc_iQuantity , 0 as qc_imoney ,0 as iQuantityCG , 0 as iMoneyCG , 0 as iQuantityZG, 0 as iMoneyZG , 0 as iQuantityQTRK , 0 as iMoneyQTRK , 0 as iQuantityXS , 0 as iMoneyXS , case when cvoutype =''09'' or cvoutype =''11'' or (cvoutype = ''21'' and bSale = 0 ) then iAoutQuantity else 0 end as iQuantityQTCK , case when cvoutype =''09'' or cvoutype =''11'' or (cVoutype =''21'' and bSale = 0 ) then iAoutPrice else 0 end as iMoneyQTCK , 0 as iQuantityDB , 0 as iMoneyDB , 0 as iMoneySR ,case when cvoutype in (''26'',''27'',''28'',''29'',''32'') or ( cvoutype =''21'' and bsale=1) then iAoutQuantity else 0 end as iQuantityCK , case when cvoutype in (''26'',''27'',''28'',''29'',''32'') or ( cvoutype =''21'' and bsale=1) then iAoutPrice else 0 end as iMoneyCB , cwhcode from tempdb..tmp_srmcost Where iMonth > 0 and cvoutype in (''09'',''11'',''21'',''26'',''27'',''28'',''29'',''32'') ' if ltrim(rtrim(@chrstartdate)) <> '' and not (@chrstartdate is null ) set @chrsql = @chrsql + ' and ddate >'''+ @chrstartdate + '''' exec( @chrsql )--3 按存货分类展开处理 /*存货分类按编码级次展开 */declare @chrfieldlist varchar(4000)declare @chrInner varchar (4000)declare @chrbmjc varchar(20)declare @i int declare @n int /*存货分类按编码级次展开 *//*取得存货分类编码级次 */set @chrbmjc = ''set @chrbmjc = (select cValue from accInformation where cName ='cGoodClass')/*连接展开字符串*/set @chrfieldlist = ''set @chrInner = '' set @i =1 set @n = 0 while (@i <= 8 )begin set @n = @n + substring(@chrbmjc,@i,1) /* 分解级次 *//* 组合字段列表 */set @chrfieldlist = @chrfieldlist +'c'+ ltrim(rtrim(str(@i))) + '.cInvCName as cInvCName' + ltrim(rtrim(@i)) +','/* 组合关联 */if (@i <= len(@chrbmjc))begin set @chrinner = @chrinner + ' left join inventoryClass c'+ ltrim(rtrim(str(@i)))+ ' on c'+ ltrim(rtrim(str(@i)))+'.cInvCCode = left( b.cInvCCode,'+ltrim(rtrim(str(@n)))+')'end else begin set @chrinner = @chrinner + ' left join inventoryClass c' + ltrim(rtrim(str(@i)))+ ' on b.cInvCCode = c'+ ltrim(rtrim(str(@i)))+ '.cInvCCode 'end set @i = @i +1 end --4 生成最终的临时表if exists(select name from tempdb..sysobjects where name = @chrtablename ) exec ('drop table tempdb..' + @chrtablename )set @chrsql = 'Select a.* ,Department.cDepName , b.cinvname , b.cinvStd , b.cinvM_Unit ,'+@chrfieldlist +'b.cInvDefine1 , b.cInvDefine2 ,b.cInvDefine3 , 0 as iProfit , 0 as iProfittax, 0 as qm_iQuantity ,0 as qm_iMoney , 0 as iPrice , 0 as iPriceTax ,vendor.cvenname , warehouse.cWhname into tempdb..'+@chrtablename+'from tempdb..tmp_srm a left join inventory b on a.cInvCode = b.cInvCode left join Department on a.caccdep = department.cDepcode left join vendor on b.cvencode = vendor.cvencode left join warehouse on a.cwhcode = warehouse.cwhcode ' + @chrInner exec(@chrsql)
解决方案:
问题原因:软件设计问题,Sa_moveSRMDetail存储过程其日期过滤条件的判断为大于起始日期。 解决方法:查询其他账表并与此两张表对比,发现销售毛利分析中数据是正确的,而进销存统计表数据不对。用SQL跟踪发现进销存统计表是调用存储过程Sa_moveSRMDetail进行数据查询的,仔细分析Sa_moveSRMDetail存储过程,发现其日期过滤条件的判断为大于起始日期,小于等于结束日期,也就是起始日期这一天给舍弃了,导致统计数据不对,改成大于等于起始日期后查询正确。if exists(select * from sysobjects where name='sa_MoveSRMDetail' and type='P')drop PROCEDURE sa_MoveSRMDetailgo-- U821版-- 2003.12.5-- 南京用友 丁德安-- 销售系统中进销存统计表的销售数量、销售收入不等于销售毛利分析中的本期数量和售价影响-- 经分析后发现是起始日期判断条件为'>',应为'>='CREATE PROCEDURE sa_MoveSRMDetail ( @chrtablename varchar (50) = null , @chrWhere varchar (255 ) = null , @chrStartDate varchar(20) = null , @chrendDate varchar(20) = null , @chrChecker varchar(40) = null , @chrDep varchar(50) = null , @chrWareHouse varchar(20) ) ASdeclare @chrsql varchar(4000) declare @chrCost varchar(40) declare @chrSaleDate varchar (50)-- 删除临时表 if exists (select name from tempdb..sysobjects where name ='tmp_srm') drop table tempdb..tmp_srm --删除进销存明细账--1 组织期初数据 --1.1 计算所有发出成本 if exists (select name from tempdb..sysobjects where name ='tmp_srmcost' ) drop table tempdb..tmp_srmcost --删除成本明细 --从成本明细账中取得销售成本和其他出库成本 set @chrsql= ' Select dkeepdate as ddate , cVouType AS cvoutype,cInvcode, cAccDep ,ia_subsidiary.cDepCode, bMoneyFlag, bSale, iMonth , Warehouse.cWhValueStyle AS cWhValueStyle , ia_subsidiary.cWhcode , iAOutQuantity , case when (cWhvaluestyle=''计划价法''or cWhvalueStyle=''售价法'') and bMoneyFlag=1 then isnull(iAOutPrice,0)- isnull(iDebitDifCost,0) + isnull(iCreditDifCost,0) else isnull ( iAOutPrice,0 ) end as iAOutPrice into tempdb..tmp_srmcost from ia_subsidiary inner join warehouse on ia_subsidiary.cwhcode = warehouse.cwhcodewhere brdflag = 0 ' if ltrim(rtrim(@chrwhere )) <> '' and not ( @chrwhere is null ) set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cAccdep ' + @chrdep if ltrim(rtrim(@chrenddate )) <> '' and not (@chrenddate is null ) set @chrsql = @chrsql + ' and dkeepdate<='''+ @chrenddate +''''if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and ia_subsidiary.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec (@chrsql )--计算非自填成本 set @chrCost=(SELECT cValue FROM AccInformation WHERE (cSysID = 'ia') AND (cName = 'cvaluestyle')) if @chrCost ='按部门核算'begin update tempdb..tmp_srmcost set tempdb..tmp_srmcost.iAOutPrice=case when (tempdb..tmp_srmcost.cWhvalueStyle='售价法' ) then tempdb..tmp_srmcost.iAoutPrice*(1 - isnull(ia_summary.iDifRate,0)) else tempdb..tmp_srmcost.iAoutPrice*(1 + isnull(ia_summary.iDifRate,0)) end from tempdb..tmp_srmcost inner join ia_summary on tempdb..tmp_srmcost.iMonth = ia_summary.iMonth and tempdb..tmp_srmcost.cDepCode = ia_summary.cDepCode and tempdb..tmp_srmcost.cInvCode = ia_summary.cInvCode where (tempdb..tmp_srmcost.cWhvaluestyle='计划价法'or tempdb..tmp_srmcost.cWhvalueStyle='售价法') and tempdb..tmp_srmcost.bMoneyFlag=0 and tempdb..tmp_srmcost.bSale<> 1 endelse begin update tempdb..tmp_srmcost set tempdb..tmp_srmcost.iAOutPrice=case when (tempdb..tmp_srmcost.cWhvalueStyle='售价法' ) then tempdb..tmp_srmcost.iAoutPrice*(1 - isnull(ia_summary.iDifRate,0)) else tempdb..tmp_srmcost.iAoutPrice*(1 + isnull(ia_summary.iDifRate,0)) end from tempdb..tmp_srmcost inner join ia_summary on tempdb..tmp_srmcost.iMonth = ia_summary.iMonth and tempdb..tmp_srmcost.cWhCode = ia_summary.cWhCode and tempdb..tmp_srmcost.cInvCode = ia_summary.cInvCode where (tempdb..tmp_srmcost.cWhvaluestyle='计划价法'or tempdb..tmp_srmcost.cWhvalueStyle='售价法') and tempdb..tmp_srmcost.bMoneyFlag=0 and tempdb..tmp_srmcost.bSale<> 1 end--完成成本计算所有的出库成本保存在临时文件 tempdb..tmp_srccost中 --1.3计算期初入库金额 --创建临时表tmp_srm保存查询统计的临时结果 --临时表结构 存货编号 ,部门编号 ,期初数量,期初金额,采购数量,采购金额 -- 暂诂数量,暂诂金额,其他入库数量,其他入库金额,销售数量 -- 销售金额,其他出库数量,其他出库金额,调拨数量,调拨金额 -- 收入金额,出库数量,成本 set @chrsql = 'Select cInvCode , caccdep ,iAinQuantity as qc_iQuantity , (iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) ) as qc_imoney ,(iAinPrice - iAinPrice) as iQuantityCG , (iAinPrice - iAinPrice) as iMoneyCG , (iAinPrice - iAinPrice) as iQuantityZG, (iAinPrice - iAinPrice) as iMoneyZG , (iAinPrice - iAinPrice) as iQuantityQTRK , (iAinPrice - iAinPrice) as iMoneyQTRK , (iAinPrice - iAinPrice) as iQuantityXS , (iAinPrice - iAinPrice) as iMoneyXS , (iAinPrice - iAinPrice) as iQuantityQTCK , (iAinPrice - iAinPrice) as iMoneyQTCK , (iAinPrice - iAinPrice) as iQuantityDB , (iAinPrice - iAinPrice) as iMoneyDB ,(iAinPrice - iAinPrice) as iMoneySR , (iAinPrice - iAinPrice) as iQuantityCK , (iAinPrice - iAinPrice) as iMoneyCB ,cwhcode into tempdb..tmp_srm from ia_subsidiary 'if ltrim(rtrim(@chrstartdate)) = '' or @chrstartdate is null begin --无期初日期时只计算上年结转 set @chrsql = @chrsql + ' where iMonth=0 and brdflag = 1 and cVoutype <>''33'' 'end else begin--有期初日期时的情况 set @chrsql = @chrsql + ' where brdflag = 1 and ( (iMonth = 0 and cVoutype <>''33'' ) or dkeepdate <='''+@chrstartdate +''' and ( cVoutype in (''01'',''24'',''30'',''08'',''20'',''22'',''10'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) ) ) 'end --加入日期和部门条件 if ltrim(rtrim(@chrwhere )) <> '' and not (@chrwhere is null ) set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cAccdep ' + @chrdep --加入仓库条件 if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and ia_subsidiary.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec ( @chrsql )--1.2 生成期初出库成本 if ltrim(rtrim(@chrstartdate)) <> '' and not ( @chrstartdate is null ) begin --如果无期初日期不应该计算期初发出内容 set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , caccdep ,- iAoutQuantity as qc_iQuantity , - iAoutPrice as qc_imoney ,0 as iQuantityCG , 0 as iMoneyCG , 0 as iQuantityZG, 0 as iMoneyZG , 0 as iQuantityQTRK , 0 as iMoneyQTRK , 0 as iQuantityXS , 0 as iMoneyXS , 0 as iQuantityQTCK , 0 as iMoneyQTCK , 0 as iQuantityDB , 0 as iMoneyDB ,0 as iMoneySR , 0 as iQuantityCK , 0 as iMoneyCB , cWhcode from tempdb..tmp_srmcost where cvoutype in (''09'',''11'',''21'',''26'',''27'',''28'',''29'',''32'') 'set @chrsql = @chrsql + ' and ddate <=''' + @chrstartdate + '''' exec(@chrsql )end --完成期初数据的准备 --2 组织本期数据 --2.1 统计本期采购入库数据:采购入库数量,采购入库金额,暂诂入库数量,暂诂入库金额,其它入库数量,其他入库金额set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , caccdep ,0 as qc_iQuantity ,0 as qc_imoney ,case when cvoutype in(''01'',''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinQuantity else 0end iQuantityCG , case when cvoutype in(''01'',''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) else 0end as iMoneyCG , case when ( cvoutype = ''01'' and bflag = 1 ) or cvoutype in(''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinQuantity else 0end as iQuantityZG, case when ( cvoutype = ''01'' and bflag = 1 ) or cvoutype in(''24'',''30'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) then iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) else 0end as iMoneyZG , case when cVoutype in (''08'',''20'',''22'',''10'') then iAinQuantity else 0 end as iQuantityQTRK , case when cVoutype in (''08'',''20'',''22'',''10'') then iAinPrice + isnull( iDebitDifCost,0) -isnull(iCreditDifCost,0) else 0 end as iMoneyQTRK , 0 as iQuantityXS , 0 as iMoneyXS , 0 as iQuantityQTCK , 0 as iMoneyQTCK , 0 as iQuantityDB , 0 as iMoneyDB ,0 as iMoneySR , 0 as iQuantityCK , 0 as iMoneyCB , cWhcode from ia_subsidiary Where bRdflag = 1 and iMonth > 0 and ( cVoutype in (''01'',''24'',''30'',''08'',''20'',''22'',''10'') or (cvoutype =''20'' and cbustype=''暂估报销'' ) ) '--追加开始日期条件 if ltrim(rtrim(@chrstartdate)) <> '' and not ( @chrstartdate is null ) set @chrsql = @chrsql + ' and dkeepdate>''' + @chrstartdate + ''''--追加结束日期条件 if ltrim(rtrim(@chrenddate)) <> ''and not ( @chrenddate is null ) set @chrsql = @chrsql + ' and dkeepdate<=''' + @chrenddate + ''''--追加其他条件 if ltrim(rtrim(@chrwhere)) <> '' and not @chrwhere is null set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cAccdep ' + @chrdep --加入仓库条件 if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and ia_subsidiary.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec(@chrsql ) --end 本期采购部分计算结束 --2.3 统计本期销售数量,销售金额,销售调拨数量,销售调拨金额 -- 取得销售系统启用日期 set @chrsaledate = (select isnull(cValue,'1900-01-01') from accinformation where cSysid='Sa' and cName='dStartDate' ) if @chrsaledate <> '' begin if len(ltrim(rtrim(@chrsaledate))) <= 8 set @chrsaledate = convert(varchar(10),convert(smalldatetime,@chrsaledate,2),121)set @chrsaleDate = ' and SalebillVouch.dDate>=''' + @chrsaledate + ''''end --计算本期销售数据 set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , cdepcode as caccdep ,0 as qc_iQuantity , 0 as qc_imoney ,0 as iQuantityCG , 0 as iMoneyCG , 0 as iQuantityZG, 0 as iMoneyZG , 0 as iQuantityQTRK , 0 as iMoneyQTRK , iQuantity as iQuantityXS , iNatSum as iMoneyXS , 0 as iQuantityQTCK , 0 as iMoneyQTCK , case when cvouchtype = ''28'' then iQuantity else 0 end as iQuantityDB , case when cvouchtype =''28'' then iNatMoney else 0 end as iMoneyDB ,iNatMoney as iMoneySR , 0 as iQuantityCK , 0 as iMoneyCB , Salebillvouchs.cWhcode From Salebillvouchs inner join Salebillvouch on salebillvouchs.sbvid = salebillvouch.sbvid where isnull(Salebillvouch.cinvalider ,'''')='''' ' + @chrsaledate --增加审核条件 if ltrim(rtrim(@chrchecker)) <> '' and not (@chrchecker is null ) set @chrsql = @chrsql + ' and ' + @chrchecker --增加开始日期条件 if ltrim(rtrim(@chrstartdate)) <> '' and not (@chrstartdate is null ) -- 2003.12.5 丁德安--set @chrsql = @chrsql + ' and ddate >''' + @chrstartdate + ''''set @chrsql = @chrsql + ' and ddate >=''' + @chrstartdate + ''''--增加结束日期条件 if ltrim(rtrim(@chrenddate )) <> '' and not (@chrenddate is null )set @chrsql = @chrsql + ' and ddate <=''' + @chrenddate + '''' --增加一般条件 if ltrim(rtrim(@chrwhere)) <> '' and not (@chrwhere is null )set @chrsql = @chrsql + ' and ' + @chrwhere if ltrim(rtrim(@chrdep )) <> '' and not ( @chrdep is null ) set @chrsql = @chrsql + ' and cdepCode ' + @chrdep --加入仓库条件 if ltrim(rtrim(@chrWareHouse)) <> '' and not (@chrWareHouse is null ) set @chrsql = @chrsql +' and Salebillvouchs.cwhcode='''+ ltrim(rtrim(@chrWareHouse)) +''''exec (@chrsql )--本期收入计算终止 --2.4 统计本期销售成本,销售收入,出库数量 set @chrsql = 'insert into tempdb..tmp_srm Select cInvCode , caccdep ,0 as qc_iQuantity , 0 as qc_imoney ,0 as iQuantityCG , 0 as iMoneyCG , 0 as iQuantityZG, 0 as iMoneyZG , 0 as iQuantityQTRK , 0 as iMoneyQTRK , 0 as iQuantityXS , 0 as iMoneyXS , case when cvoutype =''09'' or cvoutype =''11'' or (cvoutype = ''21'' and bSale = 0 ) then iAoutQuantity else 0 end as iQuantityQTCK , case when cvoutype =''09'' or cvoutype =''11'' or (cVoutype =''21'' and bSale = 0 ) then iAoutPrice else 0 end as iMoneyQTCK , 0 as iQuantityDB , 0 as iMoneyDB , 0 as iMoneySR ,case when cvoutype in (''26'',''27'',''28'',''29'',''32'') or ( cvoutype =''21'' and bsale=1) then iAoutQuantity else 0 end as iQuantityCK , case when cvoutype in (''26'',''27'',''28'',''29'',''32'') or ( cvoutype =''21'' and bsale=1) then iAoutPrice else 0 end as iMoneyCB , cwhcode from tempdb..tmp_srmcost Where iMonth > 0 and cvoutype in (''09'',''11'',''21'',''26'',''27'',''28'',''29'',''32'') ' if ltrim(rtrim(@chrstartdate)) <> '' and not (@chrstartdate is null ) set @chrsql = @chrsql + ' and ddate >'''+ @chrstartdate + '''' exec( @chrsql )--3 按存货分类展开处理 /*存货分类按编码级次展开 */declare @chrfieldlist varchar(4000)declare @chrInner varchar (4000)declare @chrbmjc varchar(20)declare @i int declare @n int /*存货分类按编码级次展开 *//*取得存货分类编码级次 */set @chrbmjc = ''set @chrbmjc = (select cValue from accInformation where cName ='cGoodClass')/*连接展开字符串*/set @chrfieldlist = ''set @chrInner = '' set @i =1 set @n = 0 while (@i <= 8 )begin set @n = @n + substring(@chrbmjc,@i,1) /* 分解级次 *//* 组合字段列表 */set @chrfieldlist = @chrfieldlist +'c'+ ltrim(rtrim(str(@i))) + '.cInvCName as cInvCName' + ltrim(rtrim(@i)) +','/* 组合关联 */if (@i <= len(@chrbmjc))begin set @chrinner = @chrinner + ' left join inventoryClass c'+ ltrim(rtrim(str(@i)))+ ' on c'+ ltrim(rtrim(str(@i)))+'.cInvCCode = left( b.cInvCCode,'+ltrim(rtrim(str(@n)))+')'end else begin set @chrinner = @chrinner + ' left join inventoryClass c' + ltrim(rtrim(str(@i)))+ ' on b.cInvCCode = c'+ ltrim(rtrim(str(@i)))+ '.cInvCCode 'end set @i = @i +1 end --4 生成最终的临时表if exists(select name from tempdb..sysobjects where name = @chrtablename ) exec ('drop table tempdb..' + @chrtablename )set @chrsql = 'Select a.* ,Department.cDepName , b.cinvname , b.cinvStd , b.cinvM_Unit ,'+@chrfieldlist +'b.cInvDefine1 , b.cInvDefine2 ,b.cInvDefine3 , 0 as iProfit , 0 as iProfittax, 0 as qm_iQuantity ,0 as qm_iMoney , 0 as iPrice , 0 as iPriceTax ,vendor.cvenname , warehouse.cWhname into tempdb..'+@chrtablename+'from tempdb..tmp_srm a left join inventory b on a.cInvCode = b.cInvCode left join Department on a.caccdep = department.cDepcode left join vendor on b.cvencode = vendor.cvencode left join warehouse on a.cwhcode = warehouse.cwhcode ' + @chrInner exec(@chrsql)

如果您的问题还没有解决,可以到 T+搜索>>上找一下答案

分享到:

微博关注

bj用友软件

最新信息

T+ 报表上面的自定义 能不能复制到其他操作员上 ,自定义项目太多

T+ 报表上面的自定义 能不能复制到其他操作员上 ,自定义项目太多 T+ 报表上面的自定义 能不能复制到其他操作员上 ,自定义项目太多[]

那个T+报表的自定义,能截图过来吗
您好,具体是哪张表
基本每张表都改 销货明细表 统计表 收发存汇总表 等等
因为使用了 很多自定义项
没有办法复制的
谢谢
客气[/握手]

请问公司租赁厂房要开发票,我们要承担哪些税金?税率多少?以及流程?

请问公司租赁厂房要开发票,我们要承担哪些税金?税率多少?以及流程? 请问公司租赁厂房要开发票,我们要承担哪些税金?税率多少?以及流程?[]

承租方不需要承担税金啊
@曹倩:可是现在承租方让我们承担19%的税金是怎么回事
@梦1473735262:[/龇牙]他欺负你

使用技巧

  • 经常出现账套年度演示期限已到期,怎么办?

    经常出现账套年度演示期限已到期,怎么办?

         最近经常有用户在使用用友财务管理软件的时候提示“演示期限已到期”,如下图。特别是T3用户,T+、T6和U8用户也会出现类似问题。越是报税期越出现的频繁,越是着急越是出问题,出现这种问题, 不能做账填制会计凭证了,也出不了财务报表,很多会计都非常的着急。该怎么办呢?别着急啦,本文会详细讲解决方案。全心全意为用户排忧解难是用友天龙瑞德公司的服务宗旨。

     image


  • 麻烦问下,T3升级T6,是不是要先安装6.1,用工具升级,再导出帐套,安装6.5,再升级到6.5?

    麻烦问下,T3升级T6,是不是要先安装6.1,用工具升级,再导出帐套,安装6.5,再升级到6.5?

    麻烦问下,T3升级T6,是不是要先安装6.1,用工具升级,再导出帐套,安装6.5,再升级到6.5? 麻烦问下,T3升级T6,是不是要先安装6.1,用工具升级,再导出帐套,安装6.5,再升级到6.5?[]

    [/强]
    您好!您理解的是对的,要在T6 6.1环境下使用T3升级T6的工具,升级完成后,恢复到6.1环境,备份出6.1的数据,安装6.5,再升级到6.5

知 识 库

  • 最新文章排行
  • 热门文章排行

培训教程

  • 还没开票的做到预收科目,那成本可以先做进去吗?

    还没开票的做到预收科目,那成本可以先做进去吗?

    还没开票的做到预收科目,那成本可以先做进去吗? 还没开票的做到预收科目,那成本可以先做进去吗?[]

    有收入才能结转成本的
    那成本挂哪个科目啊?
    其他应收款吗?
    @若只如初见520:要是销售的产品的话,产品本来做在库存里啊,要是人工施工的话,做在工程施工里,等有了收入在结转成本的
    成本与收入相对应,确认收入才能结转成本
    我们是人力资源公司,签了一份人事代理协议,代缴五险一金。之前收到他们的钱做了预收账款,还没给开票,现在给他们缴纳了五险一金,这些费用是入到成本吗?
    @若只如初见520:代付代缴应该走其他应收款/其他应付款
    @口袋的天空焕:那我做到其他应收款,等到开票了,有收入后,把预收的转入主营业务收入,其他应收款转入主营业务成本,,这样对吗
    @若只如初见520:代缴的五险一金你们也给开票么?
    @口袋的天空焕:开在一张发票上面,昨天还一直纠结这个问题,受累帮忙看看
    代缴的五险一金你们不是已经说到客户的款项了么,那个不应该作为你们的成本吧?
    @口袋的天空焕:我现在也纠结是做成本还是其他应收款冲了,税务局说这张发票的开票金额都要入营业额,那我支出的是不是成本
    @若只如初见520:。。。那要是代缴的五险一金都算是收入的话,那你们为客户缴纳五险一金的时候也走的是管理费用啊

  • 进入总账提示所选行业性质与科目不相符,去检查表提示数据库严重损坏,修复数据提示成功,再去检测又是严重错误

    进入总账提示所选行业性质与科目不相符,去检查表提示数据库严重损坏,修复数据提示成功,再去检测又是严重错误

    进入总账提示所选行业性质与科目不相符,去检查表提示数据库严重损坏,修复数据提示成功,再去检测又是严重错误 进入总账提示所选行业性质与科目不相符,去检查表提示数据库严重损坏,修复数据提示成功,再去检测又是严重错误[]

    反复执行修复工具,直到修复到没有错误为止。建议备份好之前数据,损坏严重的情况下,也有可能修复不好,无限报错。
    use ufdata_071_2015
    select * from code执行这语句时报上述错误
    @廖深根:构架损坏可能很难修复。尝试使用工具下载中的数据库修复工具,进行修复。
    然后还有个账套也是提示所选行业性质与科目不相符,经检查无误,但是进入账套还是提示不符
    @廖深根:根据您的描述,一致性错误导致的行业性质与科目不相符,您先修复成功,再来解决这个问题吧。
    修复数据库?
    @廖深根:请参考之前给您的回复。尝试使用工具下载中的数据库修复工具,进行修复。但是结构错误很难修复,工具只能修正一些简单错误。不保证工具一定管用。如果持续报错,建议您寻求专业的数据修复公司尝试修复。
    @服务社区窦佳:工具使用前,请注意备份账套。

关于我们 | 公司动态 | 获奖记录 | 联系我们 | 招聘信息 | 用友产品中心 | 用友云基地
Copyright ©  www.kuaiji66.com  All Rights Reserved 天龙瑞德
京ICP备11046295号-1 技术支持 北京天龙瑞德信息技术有限责任公司   北京海淀上地十街辉煌国际大厦3号楼6层 总机:010-59798025   售后:4009908488
北京天龙瑞德信息技术有限责任公司