之前客户遇到过收款单不能删除的情况,总部老师远程协助修复了问题,顺便记录下分享给大家。
备份账套,执行以下脚本修复!
declare @fid int
DECLARE @fbillid int
DECLARE contact_cursor CURSOR FOR
select FBillID from t_RP_NewReceiveBill where FBillID not in
(select FBillID from t_RP_Contact where FType=5 ) and FRP=1
OPEN contact_cursor
FETCH NEXT FROM contact_cursor into @fbillid
WHILE @@FETCH_STATUS = 0
BEGIN
select @fid=fnext from t_identity where fname='t_rp_contact'
insert into t_rp_contact (fid,FYear,FPeriod,FRP,FType,FDate,FFincDate,FNumber,FCustomer,FDepartment,FEmployee,FCurrencyID,FExchangeRate,
FAmount,FAmountFor,FRemainAmount,FRemainAmountFor,FContractNo,FInvoiceID,FRPBillID,FBillID,FBegID,FExpenseID,FBussinessDiscount,
FCashDiscount,FRPDate,FSuperDays,FDirectSale,FSaleBackAmount,FSaleBackAmountFor,FDue,FIsBad,FBadReason,FVoucherID,FGroupID,FAccountID,
FIsInit,FStatus,FPost,FToBal,FPre,FK3Import,FInterestRate,FCheckType,FBillType,FInvoiceType,FItemClassID,FExplanation,FSmInvID,FPreparer)
select
@fid,FYear,FPeriod,1 as FRP, 5 as FType,FDate,FFincDate,FNumber,FCustomer,FDepartment,FEmployee,
FCurrencyID,FExchangeRate,FAmount,FAmountFor,
FAmount,FAmountFor,'' as FContractNo,0 as FInvoiceID,0 as FRPBillID,FBillID,0 as FBegID,0 as FExpenseID,0 as FBussinessDiscount,
0 as FCashDiscount,fdate as FRPDate,0 as FSuperDays,0 as FDirectSale,0.0000 as FSaleBackAmount,0.0000 as FSaleBackAmountFor,fcheckstatus as FDue,
0 as FIsBad,null as FBadReason,FVoucherID,0 as FGroupID,0 as FAccountID,0 as FIsInit,FStatus as FStatus,
0 as FPost,1 as FToBal,0 as FPre,.0 as FK3Import,0 as FInterestRate,3 as FCheckType,1000 as FBillType,
0 as FInvoiceType,FItemClassID,FExplanation,0 as FSmInvID,FPreparer
from t_RP_NewReceiveBill
where FBillID not in (select FBillID from t_RP_Contact where FType=5 ) and FRP=1
and FBillID=@fbillid
FETCH NEXT FROM contact_cursor into @fbillid
END
CLOSE contact_cursor
DEALLOCATE contact_cursor
go

