解决方案: |
先备份数据,再在查询分析器中执行如下脚本。
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[P_SetMoneyList]
@Bill_ID int,
@Bill_ID_Old int,
@BillType int
AS
declare
@Act_ID int,
@Act_Money numeric(28,10),
@Card_Money numeric(28,10),
@YH_Money numeric(28,10),
@PCMoney numeric(28,10)
declare
@CostMoney numeric(28,10),
@DisMoney numeric(28,10),
@DisMoney0 numeric(28,10),
@TaxMoney numeric(28,10),
@TaxMoney0 numeric(28,10),
@CostMoney_1 numeric(28,10),
@DisMoney_1 numeric(28,10),
@TaxMoney_1 numeric(28,10),
@TaxMoney0_1 numeric(28,10)
declare
@CostMoney_1_out numeric(28,10),
@DisMoney_1_out numeric(28,10),
@TaxMoney_1_out numeric(28,10),
@TaxMoney0_1_out numeric(28,10),
@CostMoney_2_in numeric(28,10),
@DisMoney_2_in numeric(28,10),
@TaxMoney_2_in numeric(28,10),
@TaxMoney0_2_in numeric(28,10)
declare
@PD_Money numeric(28,10),
@LS_Money_DJJ numeric(28,10),
@LS_Money_Other_Tmp numeric(28,10),
@LS_Money_DJJ_Tmp numeric(28,10),
@Tmp_Money numeric(28,10)
declare
@Unit_ID_List int,
@Act_ID_List int,
@Act_Money_List numeric(28,10),
@Act_Money_List1 numeric(28,10),
@Act_Money_List_Tot numeric(28,10),
@Act_Money_List1_Tot numeric(28,10)
declare
@s_Syb int,
@BillDate varchar(10) ,
@BillSN varchar(100),
@Unit_ID int,
@User_ID int,
@Audit_ID int,
@Oper_ID int,
@Period int
declare
@ActFullID_ZZ varchar(30),
@Money_JF numeric(28,10),
@Money_DF numeric(28,10),
@Tmp_ZC numeric(28,10),
@Tmp_FZ numeric(28,10),
@Tmp_QY numeric(28,10)
declare
@JSMoney numeric(28,10),
@Writejsbill int,
@TmpWLBill_ID varchar(50),
@TmpQLBill_ID int,
@BillType_QL int,
@YSDate varchar(20),
@YU_Money numeric(28,10),
@YU_Money_JS numeric(28,10),
@YU_Money_JS_List numeric(28,10),
@RecPayDate varchar(10)
declare
@OrderId int,
@YUS_YUF_Money numeric(28,10),
@YUS_YUF_Money_List numeric(28,10)
declare
@BillID_O int,
@OrderId_O int,
@NotMoney_O numeric(28,10),
@CurrMoney_O numeric(28,10),
@SelMoney_O numeric(28,10),
@VIP_SwapIntegralM numeric(28,10)
declare
@Money_XS int
declare
@Thirdpayment int,
@ThirdPaymentMoney numeric(28,10),
@ItemBillNo varchar(30),
@SumShippingMoney numeric(28,10),
@SumShippingMoney_List_P numeric(28,10),
@SumShippingMoney_List_Z numeric(28,10),
@SRUnit int,
@SRAcount_ID int,
@SRAcount_Money numeric(28,10),
@SRJSMoney numeric(28,10)
declare
@ysyf_id int,@BackMoney numeric(28,10),@order_id int,@BackYsyfMoney numeric(28,10)
set nocount on
if @BillType>=0 and @BillType<=300
begin
select @s_Syb=s_Syb, @BillDate=BillDate, @BillSN=BillSN, @Unit_ID=isnull(Unit_ID,-1), @User_ID=Emp_ID, @Audit_ID=Audit_ID,
@Oper_ID=Oper_ID, @Period=Period, @Act_ID=Act_ID, @Act_Money=case when Act_ID>1 then isnull(Act_Money,0) else 0 end,
@Card_Money=isnull(Card_Money,0), @YH_Money=isnull(YH_Money,0), @PCMoney=abs(isnull(PCMoney,0)),@PD_Money=isnull(SumTaxMoney,0),
@YUS_YUF_Money=isnull(YUS_YUF_Money,0),@VIP_SwapIntegralM=isnull(VIP_SwapIntegralM,0)
,@Thirdpayment=isnull(Thirdpayment,0), @ThirdPaymentMoney=isnull(ThirdPaymentMoney,0),@ItemBillNo=ItemBillNo,@SumShippingMoney=isnull(SumShippingMoney,0),
@SRUnit=isnull(SRUnit,-1),@SRAcount_ID=isnull(SRAcount_ID,-1),@SRAcount_Money=isnull(SRAcount_Money,0), @SRJSMoney=isnull(SRJSMoney,0)
from MasterBill where AutoID=@Bill_ID
end
if @BillType in (1,4,14,15,16,51,52,53,54,59)
begin
if @billtype in (59)
begin
select @PD_Money=sum(costmoney) from dbo.ListProdCheck where Bill_ID=@Bill_ID
end
else
if @BillType in (1,4,15,16)
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney =Isnull(Sum((DisMoney)),0),
@TaxMoney =Isnull(Sum((TaxMoney)),0), @TaxMoney0=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and ZS_Syb=0
select @CostMoney_1=Isnull(Sum((CostMoney)),0), @DisMoney_1 =Isnull(Sum((DisMoney)),0),
@TaxMoney_1 =Isnull(Sum((TaxMoney)),0), @TaxMoney0_1=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and ZS_Syb=1
end
else
if @BillType=14
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney =Isnull(Sum((DisMoney)),0),
@TaxMoney =Isnull(Sum((TaxMoney)),0), @TaxMoney0=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and InorOut=1 and ZS_Syb=0
select @CostMoney_1_out=Isnull(Sum((CostMoney)),0), @DisMoney_1_out =Isnull(Sum((DisMoney)),0),
@TaxMoney_1_out =Isnull(Sum((TaxMoney)),0), @TaxMoney0_1_out=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and InorOut=1 and ZS_Syb=1
select @CostMoney_1=Isnull(Sum((CostMoney)),0), @DisMoney_1 =Isnull(Sum((DisMoney)),0),
@TaxMoney_1 =Isnull(Sum((TaxMoney)),0), @TaxMoney0_1=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and InorOut=2 and ZS_Syb=0
select @CostMoney_2_in=Isnull(Sum((CostMoney)),0), @DisMoney_2_in =Isnull(Sum((DisMoney)),0),
@TaxMoney_2_in =Isnull(Sum((TaxMoney)),0), @TaxMoney0_2_in=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and InorOut=2 and ZS_Syb=1
end
else
if @BillType=53
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney =Isnull(Sum((DisMoney)),0),
@TaxMoney =Isnull(Sum((TaxMoney)),0), @TaxMoney0=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and ZS_Syb=0
select @CostMoney_1=Isnull(Sum((CostMoney)),0), @DisMoney_1 =Isnull(Sum((DisMoney)),0),
@TaxMoney_1 =Isnull(Sum((TaxMoney)),0), @TaxMoney0_1=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID and ZS_Syb=1
end
else
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney =Isnull(Sum((DisMoney)),0),
@TaxMoney =Isnull(Sum((TaxMoney)),0), @TaxMoney0=Isnull(Sum((TaxMoney0)),0) from ListSale where Bill_ID=@Bill_ID
end
end
else
if @BillType in (0,3,55,56,57,58,61)
begin
if @BillType in (0,3)
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney =Isnull(Sum((DisMoney)),0),@SumShippingMoney_List_P=isnull(sum(ShippingMoney),0),
@TaxMoney =Isnull(Sum((TaxMoney)),0), @TaxMoney0 =Isnull(Sum((TaxMoney0)),0) from ListBuy where Bill_ID=@Bill_ID and ZS_Syb=0
select @CostMoney_1=Isnull(Sum((CostMoney)),0), @DisMoney_1 =Isnull(Sum((DisMoney)),0),@SumShippingMoney_List_Z=isnull(sum(ShippingMoney),0),
@TaxMoney_1 =Isnull(Sum((TaxMoney)),0), @TaxMoney0_1 =Isnull(Sum((TaxMoney0)),0) from ListBuy where Bill_ID=@Bill_ID and ZS_Syb=1
end
else
if @BillType=61
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney=Isnull(Sum((DisMoney)),0),
@TaxMoney=Isnull(Sum((TaxMoney)),0), @TaxMoney0=Isnull(Sum((TaxMoney0)),0) from ListBuy where Bill_ID=@Bill_ID and InorOut=1 and ZS_Syb=0
select @CostMoney_1_out=Isnull(Sum((CostMoney)),0), @DisMoney_1_out=Isnull(Sum((DisMoney)),0),
@TaxMoney_1_out=Isnull(Sum((TaxMoney)),0), @TaxMoney0_1_out=Isnull(Sum((TaxMoney0)),0) from ListBuy where Bill_ID=@Bill_ID and InorOut=1 and ZS_Syb=1
select @CostMoney_1=Isnull(Sum(CostMoney),0), @DisMoney_1=Isnull(Sum((DisMoney)),0),
@TaxMoney_1=Isnull(Sum((TaxMoney)),0), @TaxMoney0_1=Isnull(Sum((TaxMoney0)),0) from ListBuy where Bill_ID=@Bill_ID and InorOut=2 and ZS_Syb=0
select @CostMoney_2_in=Isnull(Sum(CostMoney),0), @DisMoney_2_in=Isnull(Sum((DisMoney)),0),
@TaxMoney_2_in=Isnull(Sum((TaxMoney)),0), @TaxMoney0_2_in=Isnull(Sum((TaxMoney0)),0) from ListBuy where Bill_ID=@Bill_ID and InorOut=2 and ZS_Syb=1
end
else
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney=Isnull(Sum((DisMoney)),0),
@TaxMoney=Isnull(Sum(TaxMoney),0), @TaxMoney0=Isnull(Sum((TaxMoney0)),0) from ListBuy where Bill_ID=@Bill_ID
end
end
else
if @BillType in (2,7,8,9,10,11,12,13,17,18,242,243,244,245,251,252)
begin
if @BillType=13
begin
select @CostMoney=Isnull(Sum((CostMoney)),0), @DisMoney =Isnull(Sum((DisMoney)),0) from ListOther where Bill_ID=@Bill_ID and InorOut=1
select @CostMoney_1=Isnull(Sum((CostMoney)),0),@DisMoney_1 =Isnull(Sum((DisMoney)),0) from ListOther where Bill_ID=@Bill_ID and InorOut=2
end
else
if @BillType=251
begin
select @DisMoney0=Isnull(Sum((DisMoney0)),0), @TaxMoney0 =Isnull(Sum((TaxMoney0)),0),@CostMoney=isnull(sum(Isnull((DisMoney0),0)-Isnull((TaxMoney0),0)),0) from ListOther where Bill_ID=@Bill_ID
end
else
if @BillType=252
begin
select @DisMoney0=Isnull(Sum((DisMoney0)),0), @TaxMoney0 =Isnull(Sum((TaxMoney0)),0),@CostMoney=isnull(sum(Isnull((DisMoney0),0)-Isnull((TaxMoney0),0)),0) from ListOther where Bill_ID=@Bill_ID
end
else
begin
select @CostMoney=Isnull(Sum((CostMoney)),0),@DisMoney =Isnull(Sum((DisMoney)),0) from ListOther where Bill_ID=@Bill_ID
end
end
if (@BillType >=0 and @BillType<=59) or (@BillType>=242 and @BillType<=245) or (@BillType=61) or (@BillType=251) or (@BillType=252)
begin
if @s_Syb<>0 and @Bill_ID_Old<>-100 and @BillType=251
begin
Declare Cur_Red Cursor Local Scroll
for
SELECT BillDate, BillSN, BillType, Unit_ID, User_ID, Audit_ID,Oper_ID, Period,Act_ID, -Act_Money FROM MoneyList where Bill_ID=@Bill_ID_Old and Act_ID not in(3,100)
Open Cur_Red
Fetch next from Cur_Red into @BillDate,@BillSN,@BillType,@Unit_ID,@User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money
while @@Fetch_Status=0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
select @s_Syb,@BillDate,@Bill_ID,@BillSN,@BillType,@Unit_ID,@User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money
if @@error<>0 goto Error
Fetch next from Cur_Red into @BillDate,@BillSN,@BillType,@Unit_ID,@User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money
end
Close Cur_Red
deallocate Cur_Red
if @CostMoney<>0
begin
if @CostMoney>0
set @Tmp_Money=-abs(@CostMoney)
if @CostMoney<0
set @Tmp_Money=abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
if @TaxMoney0<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,100,@TaxMoney0)
if @@error<>0 goto Error
end
update MoneyList set s_Syb=-2 where Bill_ID=@Bill_ID_Old and @Bill_ID_Old<>-100 and s_Syb=0
if @@error<>0
goto Error
goto Success
end
if @BillType=251 and @s_Syb=0
begin
if @DisMoney0>0
begin
if @Act_Money<=@DisMoney0
begin
set @Tmp_Money=abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
if @Act_Money<@DisMoney0
begin
set @Tmp_Money=-abs(@DisMoney0-@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @Act_Money>@DisMoney0
begin
set @Tmp_Money=abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
if @Act_Money>@DisMoney0
begin
set @Tmp_Money=abs(@DisMoney0-@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
end
end
if @DisMoney0<=0
begin
if @Act_Money>0
begin
set @Tmp_Money=abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(abs(@DisMoney0)+abs(@Act_Money))>0
begin
set @Tmp_Money=abs(abs(@DisMoney0)+abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @CostMoney<>0
begin
if @CostMoney>0
set @Tmp_Money=-abs(@CostMoney)
if @CostMoney<0
set @Tmp_Money=abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
if @TaxMoney0<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,100,@TaxMoney0)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=252 and @s_Syb=0
begin
if @DisMoney0>0
begin
if @Act_Money<=@DisMoney0
begin
set @Tmp_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
if @Act_Money<@DisMoney0
begin
set @Tmp_Money=-abs(@DisMoney0-@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,11,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @Act_Money>@DisMoney0
begin
set @Tmp_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
if @Act_Money>@DisMoney0
begin
set @Tmp_Money=abs(@DisMoney0-@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,11,@Tmp_Money)
if @@error<>0 goto Error
end
end
end
if @DisMoney0<=0
begin
if @Act_Money>0
begin
set @Tmp_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(abs(@DisMoney0)+abs(@Act_Money))>0
begin
set @Tmp_Money=abs(abs(@DisMoney0)+abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,11,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @TaxMoney0<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,101,@TaxMoney0)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=1 and @s_Syb=0
begin
if @YH_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@YH_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money)
if @@error<>0 goto Error
end
if @YUS_YUF_Money<>0
begin
set @Tmp_Money=-@YUS_YUF_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,57,@Tmp_Money)
if @@error<>0 goto Error
end
if @VIP_SwapIntegralM<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,54,@VIP_SwapIntegralM)
if @@error<>0 goto Error
end
if @Card_Money<>0
begin
set @Tmp_Money=-abs(@Card_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,52,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @Tmp_Money=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if abs(@TaxMoney)-abs(@TaxMoney0)<>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,24,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@CostMoney)
if @@error<>0 goto Error
end
if @TaxMoney0<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@TaxMoney0)
if @@error<>0 goto Error
end
if isnull(@Thirdpayment,0)>0 and isnull(@ThirdPaymentMoney,0)>0
Begin
set @Tmp_Money=@ThirdPaymentMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Thirdpayment, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-(abs(@Act_Money)+@YH_Money+@Card_Money+@YUS_YUF_Money+@VIP_SwapIntegralM+@ThirdPaymentMoney)>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@Act_Money)-@YH_Money-@Card_Money-@YUS_YUF_Money-@VIP_SwapIntegralM-@ThirdPaymentMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-(abs(@Act_Money)+@YH_Money+@Card_Money+@YUS_YUF_Money+@VIP_SwapIntegralM+@ThirdPaymentMoney)<0
Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@Act_Money)-@YH_Money-@Card_Money-@YUS_YUF_Money-@VIP_SwapIntegralM-@ThirdPaymentMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@CostMoney_1)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @CostMoney_1=-abs(@CostMoney_1)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney_1)
if @@error<>0 goto Error
set @CostMoney_1=abs(@CostMoney_1)
end
goto Success
end
if @BillType=4 and @s_Syb=0
begin
if @YH_Money<>0
begin
set @Tmp_Money=-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@Tmp_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
begin
set @Act_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money)
if @@error<>0 goto Error
set @Act_Money=abs(@Act_Money)
end
if @VIP_SwapIntegralM<>0
begin
set @Tmp_Money=-@VIP_SwapIntegralM
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,54,@Tmp_Money)
if @@error<>0 goto Error
end
if @Card_Money<>0
begin
set @Tmp_Money=@Card_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,52,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-abs(@TaxMoney0)<>0
Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@TaxMoney0))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,24,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @Bill, Date, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if @TaxMoney0<>0
begin
set @TaxMoney0=-Abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@TaxMoney0)
if @@error<>0 goto Error
set @TaxMoney0=Abs(@TaxMoney0)
end
if abs(@TaxMoney)-(abs(@Act_Money)+abs(@VIP_SwapIntegralM)+@Card_Money+@YH_Money)>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@Act_Money)-abs(@VIP_SwapIntegralM)-@Card_Money-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-(abs(@Act_Money)+abs(@VIP_SwapIntegralM)+@YH_Money+@Card_Money)<0
Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@Act_Money)-abs(@VIP_SwapIntegralM)-@YH_Money-@Card_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @Tmp_Money=-@CostMoney_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @Tmp_Money=@CostMoney_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=14 and @s_Syb=0
begin
if @YH_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@YH_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money)
if @@error<>0 goto Error
end
if @CostMoney_1-@CostMoney<>0
begin
set @Tmp_Money=@CostMoney_1-@CostMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney-@CostMoney_1<>0
begin
set @Tmp_Money=@CostMoney-@CostMoney_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@DisMoney)-abs(@DisMoney_1)<>0
Begin
set @Tmp_Money=abs(@DisMoney)-abs(@DisMoney_1)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,24,@Tmp_Money)
if @@error<>0 goto Error
end
if @TaxMoney0-@TaxMoney0_1<>0
begin
set @Tmp_Money=@TaxMoney0-@TaxMoney0_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@Tmp_Money)
if @@error<>0 goto Error
end
if (abs(@TaxMoney)-abs(@TaxMoney_1))-(@Act_Money+@YH_Money)>0
Begin
set @Tmp_Money=(abs(@TaxMoney)-abs(@TaxMoney_1))-(@Act_Money+@YH_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if (abs(@TaxMoney)-abs(@TaxMoney_1))-(@Act_Money+@YH_Money)<0
Begin
set @Tmp_Money=-((abs(@TaxMoney)-abs(@TaxMoney_1))-(@Act_Money+@YH_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1_out<>0
begin
set @Tmp_Money=@CostMoney_1_out
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1_out<>0
begin
set @Tmp_Money=-@CostMoney_1_out
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_2_in<>0
begin
set @Tmp_Money=-@CostMoney_2_in
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_2_in<>0
begin
set @Tmp_Money=@CostMoney_2_in
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=0 and @s_Syb=0
begin
if @YH_Money<>0
begin
set @Tmp_Money=-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@Tmp_Money)
if @@error<>0 goto Error
end
if @YUS_YUF_Money<>0
begin
set @Tmp_Money=-@YUS_YUF_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,56,@Tmp_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
begin
set @Tmp_Money=-@Act_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if @TaxMoney0<>0
begin
set @TaxMoney0=-Abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@TaxMoney0)
if @@error<>0 goto Error
set @TaxMoney0=Abs(@TaxMoney0)
end
if abs(@TaxMoney)-(abs(@Act_Money)+@YH_Money+@YUS_YUF_Money)>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@Act_Money)-@YH_Money-@YUS_YUF_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-(abs(@Act_Money)+@YH_Money+@YUS_YUF_Money)<0 Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@Act_Money)-@YH_Money-@YUS_YUF_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,11,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1-@SumShippingMoney_List_Z<>0
begin
set @Tmp_Money=@CostMoney_1-@SumShippingMoney_List_Z
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,27,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney_1)
if @@error<>0 goto Error
end
if @SRAcount_ID>0 and @SRAcount_Money>0
begin
set @Tmp_Money=-@SRAcount_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@SRAcount_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if @SumShippingMoney-@SRAcount_Money>0
Begin
set @Tmp_Money=@SumShippingMoney-@SRAcount_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @SRUnit, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=3 and @s_Syb=0
begin
if @YH_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@YH_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if abs(@TaxMoney)-abs(@CostMoney)-abs(@TaxMoney0)<>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@CostMoney)-abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,29,@Tmp_Money)
if @@error<>0 goto Error
end
if @TaxMoney0<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@TaxMoney0)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-(abs(@Act_Money)+@YH_Money)>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@Act_Money)-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-(abs(@Act_Money)+@YH_Money)<0
Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@Act_Money)-@YH_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @Tmp_Money=-@CostMoney_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,27,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @Tmp_Money=-@CostMoney_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=61 and @s_Syb=0
begin
if @YH_Money<>0
begin
set @Tmp_Money=-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@Tmp_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
begin
set @Tmp_Money=-(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1-@CostMoney<>0
begin
set @Tmp_Money=@CostMoney_1-@CostMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-abs(@CostMoney)-abs(@TaxMoney0)<>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@CostMoney)-abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,29,@Tmp_Money)
if @@error<>0 goto Error
end
if @TaxMoney0_1-@TaxMoney0<>0
begin
set @Tmp_Money=-(@TaxMoney0_1-@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@Tmp_Money)
if @@error<>0 goto Error
end
if (@TaxMoney_1-@TaxMoney)-(@Act_Money+@YH_Money)>0
Begin
set @Tmp_Money=(@TaxMoney_1-@TaxMoney)-@Act_Money-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
if (@TaxMoney_1-@TaxMoney)-(@Act_Money+@YH_Money)<0
Begin
set @Tmp_Money=-((@TaxMoney_1-@TaxMoney)-@Act_Money-@YH_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,11,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1_out<>0
begin
set @Tmp_Money=-@CostMoney_1_out
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,27,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1_out<>0
begin
set @Tmp_Money=-@CostMoney_1_out
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_2_in<>0
begin
set @Tmp_Money=@CostMoney_2_in
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,27,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_2_in<>0
begin
set @Tmp_Money=@CostMoney_2_in
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=55 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,22,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=56 and @s_Syb=0
begin
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if @DisMoney<>0
begin
set @Tmp_Money=-@DisMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,22,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney-@DisMoney<>0
begin
set @Tmp_Money=@CostMoney-@DisMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=57 and @s_Syb=0
begin
if @Act_Money<>0
begin
set @Act_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money)
if @@error<>0 goto Error
set @Act_Money=abs(@Act_Money)
end
if @TaxMoney0<>0
begin
set @Tmp_Money=-Abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@Tmp_Money)
if @@error<>0 goto Error
end
if @TaxMoney-@TaxMoney0<>0
begin
set @Tmp_Money=-(abs(@TaxMoney)-@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,22,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-abs(@Act_Money)>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-abs(@Act_Money)<0
Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=58 and @s_Syb=0
begin
if @DisMoney-@CostMoney<>0
begin
set @Tmp_Money=(@DisMoney)-(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@Tmp_Money)
if @@error<>0 goto Error
end
if @DisMoney-@CostMoney<>0
begin
set @Tmp_Money=(@DisMoney)-(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,22,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=59 and @s_Syb=0
begin
if @PD_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_, Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@PD_Money)
if @@error<>0 goto Error
end
if @PD_Money>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,26,@PD_Money)
if @@error<>0 goto Error
end
else
if @PD_Money<0
begin
set @Tmp_Money=abs(@PD_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,42,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=15 and @s_Syb=0
begin
set @LS_Money_Other_Tmp=0
set @LS_Money_DJJ_Tmp=0
if @YH_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@YH_Money)
if @@error<>0 goto Error
end
Declare curMoney Cursor Local Scroll for select Act_ID,isnull(PayMoney,0) from ListSaleAcount where Bill_ID=@Bill_ID Open curMoney
Fetch next from CurMoney into @Act_ID_List,@Act_Money_List
while @@Fetch_Status=0
begin
if @Act_ID_List<>17
set @LS_Money_Other_Tmp=isnull(@LS_Money_Other_Tmp,0)+@Act_Money_List
else
set @LS_Money_DJJ_Tmp=isnull(@LS_Money_DJJ_Tmp,0)+@Act_Money_List
if @Act_ID_List=52
set @Tmp_Money=-(@Act_Money_List)
else
set @Tmp_Money=@Act_Money_List
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID_List,@Tmp_Money)
if @@error<>0 goto Error
Fetch next from CurMoney into @Act_ID_List,@Act_Money_List
end
Close curMoney deallocate curMoney
if @LS_Money_DJJ_Tmp-@TaxMoney+@YH_Money+@LS_Money_Other_Tmp>0
begin
set @Tmp_Money=@LS_Money_DJJ_Tmp-@TaxMoney+@YH_Money+@LS_Money_Other_Tmp
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,34,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if abs(@TaxMoney)-abs(@TaxMoney0)<>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,24,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@CostMoney)
if @@error<>0 goto Error
end
if @TaxMoney0<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@TaxMoney0)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@CostMoney_1)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @CostMoney_1=-abs(@CostMoney_1)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney_1)
if @@error<>0 goto Error
set @CostMoney_1=abs(@CostMoney_1)
end
goto Success
end
if @BillType=16 and @s_Syb=0
begin
set @LS_Money_Other_Tmp=0
set @LS_Money_DJJ_Tmp=0
if @YH_Money<>0
begin
set @Tmp_Money=-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@Tmp_Money)
if @@error<>0 goto Error
end
Declare curMoney Cursor Local Scroll for select Act_ID,isnull(PayMoney,0) from ListSaleAcount where Bill_ID=@Bill_ID Open curMoney
Fetch next from CurMoney into @Act_ID_List,@Act_Money_List
while @@Fetch_Status=0
begin
if @Act_ID_List<>17
set @LS_Money_Other_Tmp=@LS_Money_Other_Tmp+@Act_Money_List
else
set @LS_Money_DJJ_Tmp=@LS_Money_DJJ_Tmp+@Act_Money_List
if @Act_ID_List=52
set @Tmp_Money=@Act_Money_List
else
set @Tmp_Money=-@Act_Money_List
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID_List,@Tmp_Money)
if @@error<>0 goto Error
Fetch next from CurMoney into @Act_ID_List,@Act_Money_List
end
Close curMoney
deallocate curMoney
if @LS_Money_DJJ_Tmp-@TaxMoney+@YH_Money+@LS_Money_Other_Tmp>0
begin
set @Tmp_Money=-(@LS_Money_DJJ_Tmp-@TaxMoney+@YH_Money+@LS_Money_Other_Tmp)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,34,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-abs(@TaxMoney0)<>0
Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@TaxMoney0))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,24,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if @TaxMoney0<>0
begin
set @TaxMoney0=-Abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@TaxMoney0)
if @@error<>0 goto Error
set @TaxMoney0=Abs(@TaxMoney0)
end
if @CostMoney_1<>0
begin
set @Tmp_Money=-@CostMoney_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @Tmp_Money=@CostMoney_1
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=51 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,15,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
goto Success
end
if @BillType=52 and @s_Syb=0
begin
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,15,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=53 and @s_Syb=0
begin
if @CostMoney_1<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@CostMoney_1)
if @@error<>0 goto Error
end
if @CostMoney_1<>0
begin
set @CostMoney_1=-abs(@CostMoney_1)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,15,@CostMoney_1)
if @@error<>0 goto Error
set @CostMoney_1=abs(@CostMoney_1)
end
if @Act_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,15,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
if abs(@TaxMoney)-abs(@TaxMoney0)<>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@TaxMoney0)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,24,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,40,@CostMoney)
if @@error<>0 goto Error
end
if @TaxMoney0<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,21,@TaxMoney0)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-abs(@Act_Money)>0
Begin
set @Tmp_Money=abs(@TaxMoney)-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)-abs(@Act_Money)<0
Begin
set @Tmp_Money=-(abs(@TaxMoney)-abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,19,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=2 and @s_Syb=0
begin
if Abs(@DisMoney)-Abs(@CostMoney)<>0
begin
set @Tmp_Money= Abs(@DisMoney)-Abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,28,@Tmp_Money)
if @@error<>0 goto Error
end
if Abs(@DisMoney)-Abs(@CostMoney)<>0
begin
set @Tmp_Money= Abs(@DisMoney)-Abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=8 and @s_Syb=0
begin
set @TaxMoney=@DisMoney
if abs(@TaxMoney)>abs(@CostMoney)
Begin
set @Tmp_Money=abs(@TaxMoney-@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,30,@Tmp_Money)
if @@error<>0 goto Error
end
else
Begin
set @Tmp_Money=-abs(@TaxMoney-@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,30,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@TaxMoney)>abs(@CostMoney)
Begin
set @Tmp_Money=abs(@TaxMoney-@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
else
Begin
set @Tmp_Money=-abs(@TaxMoney-@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=9 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,42,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
goto Success
end
if @BillType=10 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,26,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=11 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,43,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
goto Success
end
if @BillType=12 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,27,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=13 and @s_Syb=0
begin
if abs(@CostMoney_1)-abs(@CostMoney)<>0
begin
set @Tmp_Money=abs(@CostMoney_1)-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,31,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@CostMoney_1)-abs(@CostMoney)<>0
begin
set @Tmp_Money=abs(@CostMoney_1)-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
goto Success end
if @BillType=17 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=18 and @s_Syb=0
begin
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@CostMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
set @CostMoney=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
set @CostMoney=abs(@CostMoney)
end
goto Success
end
if @BillType=242 and @s_Syb=0
begin
if @CostMoney<>0
begin
set @Tmp_Money=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,16,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=243 and @s_Syb=0
begin
if @CostMoney<>0
begin
set @Tmp_Money=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,16,@Tmp_Money)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,3,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=244 and @s_Syb=0
begin
if @CostMoney<>0
begin
set @Tmp_Money=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,16,@Tmp_Money)
if @@error<>0 goto E, rror
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,44,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @BillType=245 and @s_Syb=0
begin
if @CostMoney<>0
begin
set @Tmp_Money=-abs(@CostMoney)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,16,@Tmp_Money)
if @@error<>0 goto Error
end
if @PCMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,33,@PCMoney)
if @@error<>0 goto Error
end
if @PCMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,6,@PCMoney)
if @@error<>0 goto Error
end
if @CostMoney<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,44,@CostMoney)
if @@error<>0 goto Error
end
goto Success
end
if @s_Syb<>0 and @Bill_ID_Old not in(-100,-200,-300) and @BillType<>251
begin
Declare curMoney Cursor Local Scroll for SELECT BillDate, BillSN, BillType, Unit_ID, User_ID, Audit_ID,Oper_ID, Period,Act_ID, -Act_Money FROM MoneyList where Bill_ID=@Bill_ID_Old
Open curMoney
Fetch next from curMoney into @BillDate,@BillSN,@BillType,@Unit_ID,@User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money
while @@Fetch_Status=0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
select @s_Syb,@BillDate,@Bill_ID,@BillSN,@BillType,@Unit_ID,@User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money
if @@error<>0 goto Error_Cur
Fetch next from curMoney into @BillDate,@BillSN,@BillType,@Unit_ID,@User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID,@Act_Money
end
Close curMoney
deallocate curMoney
update MoneyList set s_Syb=-2 where Bill_ID=@Bill_ID_Old and @Bill_ID_Old<>-100 and s_Syb=0
if @@error<>0
goto Error
goto Success
end
end
if (@BillType>=100 and @BillType<=121)
begin
select @Act_Money_List_Tot=Isnull(Sum((Money)),0), @Act_Money_List1_Tot=Isnull(Sum((Money1)),0) from ListMoney where Bill_ID=@Bill_ID and Act_ID>1
if @Bill_ID_Old not in (-100,-200,-300)
update MoneyList set s_Syb=-2 where Bill_ID=@Bill_ID_Old and s_Syb=0
if @Bill_ID_Old in(-100,-200,-300) and @s_Syb=0
begin
if @BillType=118
begin
if @Bill_ID_Old in(-100,-200)
begin
Select @JSMoney=isnull(sum(Money_JS),0) from JS_Bill where QL_BillID_Gat=@Bill_ID and WL_Red=0 and QL_Red=0 and IfGZ=0
if @JSMoney<>0
Begin
set @Tmp_Money=-@JSMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money],[GL_JS_YUSYUF] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 57,@Tmp_Money,1)
if @@error<>0 goto Error
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] ,[GL_JS_YUSYUF])
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money,1)
if @@error<>0 goto Error
end
end
if @Bill_ID_Old in(-300)
begin
Select @JSMoney=isnull(sum(Money_JS),0) from JS_Bill where QL_BillID_Gat=@Bill_ID and WL_Red=0 and QL_Red=0 and IfGZ=1 and IfJH_XS_CD=0
if @JSMoney<>0
Begin
set @Tmp_Money=@JSMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money],[GL_JS_YUSYUF] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 57,@Tmp_Money,-1)
if @@error<>0 goto Error
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money],[GL_JS_YUSYUF] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money,-1)
if @@error<>0 goto Error
end
update moneylist set GL_JS_YUSYUF=-1 where Bill_ID=@Bill_ID and GL_JS_YUSYUF=1
if @@error<>0 goto Error
end
end
if @BillType=119
begin
if @Bill_ID_Old in(-100,-200)
begin
Select @JSMoney=isnull(sum(Money_JS),0) from JS_Bill where QL_BillID_Pay=@Bill_ID and WL_Red=0 and QL_Red=0 and IfGZ=0
if @JSMoney<>0
Begin
set @Tmp_Money=-@JSMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money],[GL_JS_YUSYUF] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 56,@Tmp_Money,1)
if @@error<>0 goto Error
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money],[GL_JS_YUSYUF] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money,1)
if @@error<>0 goto Error
end
end
if @Bill_ID_Old in(-300)
begin
Select @JSMoney=isnull(sum(Money_JS),0) from JS_Bill where QL_BillID_Pay=@Bill_ID and WL_Red=0 and QL_Red=0 and IfGZ=1 and IfJH_XS_CD=0
if @JSMoney<>0
Begin
set @Tmp_Money=@JSMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money],[GL_JS_YUSYUF] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 56,@Tmp_Money,-1)
if @@error<>0 goto Error
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money],[GL_JS_YUSYUF] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money,-1)
if @@error<>0 goto Error
end
update moneylist set GL_JS_YUSYUF=-1 where Bill_ID=@Bill_ID and GL_JS_YUSYUF=1
if @@error<>0 goto Error
end
end
end
if @s_Syb in(0,-1,-2) and @Bill_ID_Old<>-200 and @Bill_ID_Old<>-300
begin
if @BillType=100
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot+@YH_Money else set @Tmp_Money=(@Act_Money_List_Tot+@YH_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if @YH_Money<>0
begin
set @YH_Money=-@YH_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@YH_Money)
if @@error<>0 goto Error
set @YH_Money=-@YH_Money
end
end
if @BillType=101
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot+@YH_Money else set @Tmp_Money=(@Act_Money_List_Tot+@YH_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
if @YH_Money<>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,48,@YH_Money)
if @@error<>0 goto Error
end
end
if @BillType=102
begin
if @Act_Money_List_Tot<>0
Begin
if isnull(@Act_ID,0)=0 set @Act_ID=6
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money_List_Tot) else set @Tmp_Money=abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=103
begin
if @Act_Money<>0
Begin
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money) else set @Tmp_Money=abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money)>abs(@Act_Money_List_Tot)
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money-@Act_Money_List_Tot else set @Tmp_Money=-(Abs(@Act_Money)-Abs(@Act_Money_List_Tot))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money)<abs(@Act_Money_List_Tot)
begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot-@Act_Money else set @Tmp_Money=-(Abs(@Act_Money_List_Tot)-Abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=104
begin
if @Act_Money<>0
Begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money) else set @Tmp_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money_List_Tot)>abs(@Act_Money)
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot-@Act_Money else set @Tmp_Money=-(Abs(@Act_Money_List_Tot)-Abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money_List_Tot)<abs(@Act_Money)
begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money_List_Tot-@Act_Money) else set @Tmp_Money=-abs(@Act_Money_List_Tot-@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=105
begin
if @Act_Money<>0 and @Act_Money=@Act_Money_List_Tot
Begin
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money) else set @Tmp_Money=abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=106
begin
if @Act_Money<>0
Begin
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money) else set @Tmp_Money=abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money_List_Tot)>abs(@Act_Money)
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot-@Act_Money else set @Tmp_Money=-(Abs(@Act_Money_List_Tot)-Abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money_List_Tot)<abs(@Act_Money)
begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money_List_Tot-@Act_Money) else set @Tmp_Money=-abs(@Act_Money_List_Tot-@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=107
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money_List_Tot) else set @Tmp_Money=-abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 47,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=108
begin
if @Act_Money<>0
Begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money) else set @Tmp_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money_List_Tot)>abs(@Act_Money)
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot-@Act_Money else set @Tmp_Money=-(Abs(@Act_Money_List_Tot)-Abs(@Act_Money))
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
if abs(@Act_Money_List_Tot)<abs(@Act_Money)
begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money_List_Tot-@Act_Money) else set @Tmp_Money=-abs(@Act_Money_List_Tot-@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=109
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot else set @Tmp_Money=-abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=110
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money_List_Tot) else set @Tmp_Money=abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=111
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money_List_Tot) else set @Tmp_Money=-abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=112
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money_List_Tot) else set @Tmp_Money=abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=113
begin
if @Act_Money<>0 and @Act_Money=@Act_Money_List_Tot
Begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money) else set @Tmp_Money=-abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=114
begin
if @Act_Money<>0 and @Act_Money=@Act_Money_List_Tot
Begin
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money) else set @Tmp_Money=abs(@Act_Money)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=115
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=abs(@Act_Money_List_Tot) else set @Tmp_Money=-abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 13,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=116
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=-abs(@Act_Money_List_Tot) else set @Tmp_Money=abs(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 13,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=118
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot else set @Tmp_Money=(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 57,@Tmp_Money)
if @@error<>0 goto Error
if @s_Syb<>0
begin
select @OrderId=isnull(Order_ID,-1) from Masterbill where AutoID=@Bill_ID_Old
if @OrderId>0
begin
update MasterOrder set JSMoney=0,Act_ID=-1,Act_Money=0 where s_ID=@OrderId
if @@error<>0 goto Error
end
end
end
end
if @BillType=119
begin
if @Act_Money_List_Tot<>0
Begin
if @s_Syb=0 set @Tmp_Money=@Act_Money_List_Tot else set @Tmp_Money=(@Act_Money_List_Tot)
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 56,@Tmp_Money)
if @@error<>0 goto Error
if @s_Syb<>0
begin
select @OrderId=isnull(Order_ID,-1) from Masterbill where AutoID=@Bill_ID_Old
if @OrderId>0
begin
update MasterOrder set JSMoney=0,Act_ID=-1,Act_Money=0 where s_ID=@OrderId
if @@error<>0 goto Error
end
end
end
end
if @BillType=120
begin
select @Act_Money_List_Tot=-sum(isnull(BackMoney,0)) from ListYsyf where bill_ID=@Bill_ID
if @Act_Money_List_Tot<>0
Begin
set @Tmp_Money=@Act_Money_List_Tot
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 57,@Tmp_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
Begin
set @Tmp_Money=-@Act_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=121
begin
select @Act_Money_List_Tot=-sum(isnull(BackMoney,0)) from ListYsyf where bill_ID=@Bill_ID
if @Act_Money_List_Tot<>0
Begin
set @Tmp_Money=@Act_Money_List_Tot
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 56,@Tmp_Money)
if @@error<>0 goto Error
end
if @Act_Money<>0
Begin
set @Tmp_Money=@Act_Money
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, @Act_ID,@Tmp_Money)
if @@error<>0 goto Error
end
end
if (@BillType>=100 and @BillType<=116) or (@BillType in (118,119))
begin
Declare curMoney Cursor Local Scroll for select Act_ID,Money from ListMoney where Bill_ID=@Bill_ID Open curMoney
Fetch next from CurMoney into @Act_ID_List,@Act_Money_List
while @@Fetch_Status=0
begin
if @BillType in (100,115,107,108,119) set @Act_Money_List=-@Act_Money_List
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID_List,@Act_Money_List)
if @@Error<>0 goto Error_Cur
Fetch next from CurMoney into @Act_ID_List,@Act_Money_List
end
Close curMoney
deallocate curMoney
end
else
if @BillType=117
begin
Declare curMoney Cursor Local Scroll
for
select substring(a.s_FullId,1,5) as Sys_FullId,isnull(b.Act_ID,0) as Act_ID,isnull(b.Unit_ID,0) as Unit_ID ,isnull(b.Money,0) as Money,isnull(b.Money1,0) as , Money1
from MoneyAccount a,ListMoney b where a.s_id=b.Act_ID and b.Bill_ID=@Bill_ID
Open curMoney
Fetch next from curMoney into @ActFullID_ZZ,@Act_ID_List,@Unit_ID_List,@Money_JF,@Money_DF
while @@Fetch_Status=0
begin
if (@ActFullID_ZZ='00001' or @ActFullID_ZZ='00004')
begin
if @Money_JF>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID_List, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID_List,@Money_JF)
if @@error<>0 goto Error_Cur
end
if @Money_DF>0
begin
set @Money_DF=-@Money_DF
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID_List, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID_List,@Money_DF)
if @@error<>0 goto Error_Cur
set @Money_DF=-@Money_DF
end
end
if @ActFullID_ZZ='00002' or @ActFullID_ZZ='00003'
begin
if @Money_JF>0
begin
set @Money_JF=-@Money_JF
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID_List, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID_List,@Money_JF)
if @@error<>0 goto Error_Cur
set @Money_JF=-@Money_JF
end
if @Money_DF>0
begin
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN], [BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID,@BillSN,@BillType, @Unit_ID_List, @User_ID,@Audit_ID,@Oper_ID,@Period,@Act_ID_List,@Money_DF)
if @@error<>0 goto Error_Cur
end
end
Fetch next from curMoney into @ActFullID_ZZ,@Act_ID_List,@Unit_ID_List,@Money_JF,@Money_DF
end
Close curMoney
deallocate curMoney
end
else if @BillType in (120,121)
begin
Declare curMoney Cursor Local Scroll for
Select a.ysyf_id,a.BackMoney,b.order_id from ListYsyf a
inner join masterbill b on a.ysyf_ID=b.autoid
where Bill_ID=@Bill_ID
Open curMoney
Fetch next from CurMoney into @ysyf_id ,@BackMoney,@order_id
while @@Fetch_Status=0
begin
select @Act_Money=isnull(sumtaxmoney,0),@JSMoney=isnull(JSMoney,0),@BackYsyfMoney=isnull(BackYsyfMoney,0)
from masterbill where autoid=@ysyf_id
if @BackYsyfMoney+@JSMoney+@BackMoney>@Act_Money
return -907
update masterbill set BackYsyfMoney=isnull(BackYsyfMoney,0)+@BackMoney
where autoid=@ysyf_id
if @@Error<>0 goto Error_Cur
update masterorder set BackYsyfMoney=isnull(BackYsyfMoney,0)+@BackMoney
where s_ID=@order_id
if @@Error<>0 goto Error_Cur
Fetch next from CurMoney into @ysyf_id ,@BackMoney,@order_id
end
Close curMoney
deallocate curMoney
end
end
if @s_Syb <>0 and @Bill_ID_Old not in(-100,-200,-300 ) and @BillType in(103,106,104,108,118,119,120,121)
begin
--预收、预付被核销的单据红冲时需要更新账户,收付款单据核销的不影响账户,直接在结算存储过程里修改。此处是核销的钱流单据。
if @BillType in(103,106,104,108) and exists(select * from JS_Bill where WL_BillID=@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1 and BillType_QL in (118,119))
begin
Declare curMoney Cursor Local Scroll for Select WL_BillID,isnull(Money_JS,0) as Money_JS,BillType,QL_BillID,BillType_QL from JS_Bill where WL_BillID=@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1 and BillType_QL in (118,119)
Open curMoney
Fetch next from curMoney into @TmpWLBill_ID,@JSMoney,@BillType,@TmpQLBill_ID,@BillType_QL
while @@Fetch_Status=0
begin
set @YU_Money_JS_List=0
if @BillType_QL=118
begin
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@TmpWLBill_ID and JSMoney<>0
if @@error<>0 goto Error_Cur
if exists(select * from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Gat<>@TmpQLBill_ID and WL_Red=0 and QL_Red=0 and IfGZ=1 )
begin
select @RecPayDate=min(QL_Date) from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Gat<>@TmpQLBill_ID and WL_Red=0 and QL_Red=0 and IfGZ=1
update MasterBill set FirstDate=@RecPayDate where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error_Cur
end
else
begin
update MasterBill set FirstDate=null where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error_Cur
end
if @JSMoney<>0
Begin
select @s_Syb=s_Syb, @BillDate=BillDate, @BillSN=BillSN, @Unit_ID=isnull(Unit_ID,-1), @User_ID=Emp_ID, @Audit_ID=Audit_ID,
@Oper_ID=Oper_ID, @Period=Period, @Act_ID=Act_ID, @Act_Money=case when Act_ID>1 then isnull(Act_Money,0) else 0 end,
@Card_Money=isnull(Card_Money,0), @YH_Money=isnull(YH_Money,0), @PCMoney=abs(PCMoney),@PD_Money=isnull(SumTaxMoney,0)
from MasterBill where AutoID=@TmpQLBill_ID
set @Tmp_Money=@JSMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @TmpQLBill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 57,@Tmp_Money)
if @@error<>0 goto Error_Cur
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @TmpQLBill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error_Cur
end
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@TmpQLBill_ID
if @@error<>0 goto Error_Cur
select @OrderId=isnull(Order_ID,-1) from Masterbill where AutoID=@TmpQLBill_ID
if @OrderId>0
begin
update MasterOrder set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0) where s_ID=@OrderId
if @@error<>0 goto Error_Cur
end
update JS_Bill set WL_Red=1 where WL_BillID=@Bill_ID_Old
if @@error<>0 goto Error_Cur
end
if @BillType_QL=119
begin
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@TmpWLBill_ID and JSMoney<>0
if @@error<>0 goto Error_Cur
if exists(select * from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Pay<>@TmpQLBill_ID and WL_Red=0 and QL_Red=0 and IfGZ=1)
begin
select @RecPayDate=min(QL_Date) from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Pay<>@TmpQLBill_ID and WL_Red=0 and QL_Red=0 and IfGZ=1
update MasterBill set FirstDate=@RecPayDate where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error
end
else
begin
update MasterBill set FirstDate=null where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error_Cur
end
if @JSMoney<>0
Begin
select @s_Syb=s_Syb, @BillDate=BillDate, @BillSN=BillSN, @Unit_ID=isnull(Unit_ID,-1), @User_ID=Emp_ID, @Audit_ID=Audit_ID,
@Oper_ID=Oper_ID, @Period=Period, @Act_ID=Act_ID, @Act_Money=case when Act_ID>1 then isnull(Act_Money,0) else 0 end,
@Card_Money=isnull(Card_Money,0), @YH_Money=isnull(YH_Money,0), @PCMoney=abs(PCMoney),@PD_Money=isnull(SumTaxMoney,0)
from MasterBill where AutoID=@TmpQLBill_ID
set @Tmp_Money=@JSMoney
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @TmpQLBill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 56,@Tmp_Money)
if @@error<>0 goto Error
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @TmpQLBill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@TmpQLBill_ID
if @@error<>0 goto Error_Cur
select @OrderId=isnull(Order_ID,-1) from Masterbill where AutoID=@TmpQLBill_ID
if @OrderId>0
begin
update MasterOrder set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0) where s_ID=@OrderId
if @@error<>0 goto Error_Cur
end
update JS_Bill set WL_Red=1 where WL_BillID=@Bill_ID_Old
if @@error<>0 goto Error_Cur
end Fetch next from curMoney into @TmpWLBill_ID,@JSMoney,@BillType,@TmpQLBill_ID,@BillType_QL
end
Close curMoney
deallocate curMoney
end
if @BillType=118 and exists(select * from JS_Bill where QL_BillID_Gat=@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1)
begin
Declare curMoney Cursor Local Scroll for Select WL_BillID,isnull(Money_JS,0),BillType from JS_Bill where QL_BillID_Gat=@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1
Open curMoney
Fetch next from curMoney into @TmpWLBill_ID,@JSMoney,@BillType
while @@Fetch_Status=0
begin
set @YU_Money_JS_List=isnull(@YU_Money_JS_List,0)+isnull(@JSMoney,0)
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@TmpWLBill_ID and JSMoney<>0
if @@error<>0 goto Error_Cur
if exists(select * from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Gat<>@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1)
begin
select @RecPayDate=min(QL_Date) from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Gat<>@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1
update MasterBill set FirstDate=@RecPayDate where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error_Cur
end
else
begin
update MasterBill set FirstDate=null where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error_Cur
end
Fetch next from curMoney into @TmpWLBill_ID,@JSMoney,@BillType
end
Close curMoney
deallocate curMoney
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@YU_Money_JS_List,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@Bill_ID_Old and @s_Syb=-2
if @@error<>0 goto Error
update JS_Bill set WL_Red=1, QL_Red=1 where QL_BillID_Gat=@Bill_ID_Old
if @@error<>0 goto Error
if @YU_Money_JS_List<>0
Begin
set @Tmp_Money=@YU_Money_JS_List
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 57,@Tmp_Money)
if @@error<>0 goto Error
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 11,@Tmp_Money)
if @@error<>0 goto Error
end
end
if @BillType=119 and exists(select * from JS_Bill where QL_BillID_Pay=@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1)
begin
Declare curMoney Cursor Local Scroll for Select WL_BillID,isnull(Money_JS,0),BillType from JS_Bill where QL_BillID_Pay=@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1
Open curMoney
Fetch next from curMoney into @TmpWLBill_ID,@JSMoney,@BillType
while @@Fetch_Status=0
begin
set @YU_Money_JS_List=isnull(@YU_Money_JS_List,0)+isnull(@JSMoney,0)
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@JSMoney,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@TmpWLBill_ID and JSMoney<>0
if @@error<>0 goto Error_Cur
if exists(select * from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Pay<>@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1)
begin
select @RecPayDate=min(QL_Date) from JS_Bill where WL_BillID=@TmpWLBill_ID and QL_BillID_Pay<>@Bill_ID_Old and WL_Red=0 and QL_Red=0 and IfGZ=1
update MasterBill set FirstDate=@RecPayDate where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error
end
else
begin
update MasterBill set FirstDate=null where AutoID=@TmpWLBill_ID
if @@error<>0 goto Error_Cur
end
Fetch next from curMoney into @TmpWLBill_ID,@JSMoney,@BillType
end
Close curMoney
deallocate curMoney
update MasterBill set JSMoney=isnull(JSMoney,0)-isnull(@YU_Money_JS_List,0), WriteJSBill=isnull(WriteJSBill,0)-1 where AutoID=@Bill_ID_Old and @s_Syb=-2
if @@error<>0 goto Error
update JS_Bill set WL_Red=1, QL_Red=1 where QL_BillID_Pay=@Bill_ID_Old
if @@error<>0 goto Error
if @YU_Money_JS_List<>0
Begin
set @Tmp_Money=@YU_Money_JS_List
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 56,@Tmp_Money)
if @@error<>0 goto Error
insert into MoneyList ([s_Syb], [BillDate], [Bill_ID], [BillSN],[BillType], [Unit_ID], [User_ID], [Audit_ID], [Oper_ID], [Period], [Act_ID], [Act_Money] )
values (@s_Syb, @BillDate, @Bill_ID, @BillSN,@BillType, @Unit_ID, @User_ID,@Audit_ID,@Oper_ID,@Period, 19,@Tmp_Money)
if @@error<>0 goto Error
end
end
end
goto Success
end
Success:
select @Tmp_ZC=isnull(Sum(Act_Tot),0) from MoneyAccount where s_FullID like '00001%'
select @Tmp_FZ=isnull(Sum(Act_Tot),0) from MoneyAccount where s_FullID like '00002%'
select @Tmp_QY=isnull(Sum(Act_Tot),0) from MoneyAccount where s_FullID like '00005%'
select @Money_XS= convert(int, isnull(IfAllow,8)) from setsysteminfo where s_FullID='0000600003'
-- if ROUND(@Tmp_ZC,@Money_XS, 0)= ROUND(@Tmp_FZ+@Tmp_QY,@Money_XS, 0) return 0 else return -999
return 0
Error:
return -1
Error_Cur:
Close curMoney
deallocate curMoney
return -1
|