处理结转新帐套后往来业务数据丢失

来源:www.nbjxsoft.cn   发布时间:2011/6/2 9:54:31   浏览次数:0


处理结转新帐套后往来业务数据丢失

-----在源帐套中执行

select * into aaa from (
select b.fnumber,b.fdc,a.faccountid,a.fcurrencyid,a.fdetailid,a.ftransno,a.ftransdate,a.fbeginbalancefor as famountfor,
       a.fbeginbalance as famount,fbeginqty as fquantity
from t_transinitbalance a join t_account b on a.faccountid=b.faccountid
where a.fcurrencyid<>0 and b.fcontact=1
union
select c.fnumber,c.fdc,b.faccountid,b.fcurrencyid,b.fdetailid,isnull(b.ftransno,'') as ftransno,a.fdate,
       case when b.fdc=0 then -b.famountfor else b.famountfor end as famountfor,
       case when b.fdc=0 then -b.famount else b.famount end as famount,
       case when b.fdc=0 then -b.fquantity else b.fquantity end as fquantity
from t_voucher a join t_voucherentry b on a.fvoucherid=b.fvoucherid join t_account c on b.faccountid=c.faccountid
where c.fcontact=1 ) tmp

select a.*,b.ftransdate into bbb from
(select faccountid,fcurrencyid,fdetailid,ftransno,sum(famountfor) as famountfor,sum(famount) as famount,sum(fquantity) as fquantity
from aaa group by faccountid,fcurrencyid,fdetailid,ftransno) a
left join (select faccountid,fcurrencyid,fdetailid,ftransno,max(ftransdate) as ftransdate
from aaa group by faccountid,fcurrencyid,fdetailid,ftransno)
 b on a.faccountid=b.faccountid and a.fdetailid=b.fdetailid and a.ftransno=b.ftransno

delete from bbb where famountfor=0 and famount=0


----在新帐套中执行

delete from t_transinitbalance

insert into t_transinitbalance
select faccountid,fcurrencyid,fdetailid,ftransno,ftransdate,famountfor,famount,0,0,0,0,fquantity,0,0,0,0 from ais200302.dbo.bbb
insert into t_transinitbalance
select faccountid,0,fdetailid,ftransno,ftransdate,famount,famount,0,0,0,0,0,0,0,0,0 from ais200302.dbo.bbb

  其中ais200302表示源帐套的数据库实体名.


-----在源帐套中执行

drop table aaa
drop table bbb


 上一条新闻:名称或代码在系统中已被使用
 下一条新闻:账套版本:KIS专业版8.1结转损益后损益类科目还有余额
[打印本文]  [返回服务中心]  [关闭窗口]
友情链接:

宁波金蝶软件有限公司 2006 版权所有 浙ICP备16034465号-2 销售服务电话:15957871790
地址(ADD):浙江省宁波市 网址:www.nbjxsoft.cn
Copyright 2006 Auto Parts All Right Reserved