请问 T+ 12.1程序在哪下载。
2018-2-14 0:0:0 用友T6小编请问 T+ 12.1程序在哪下载。
请问 T+ 12.1程序在哪下载。[]你好,服务社区产品下载中可以下载的。
如果您的问题还没有解决,可以到 T+搜索>>上找一下
相关阅读
- 您好。请问现金流量项目怎么设置?2018-11-23 13:46:7
- 期初余额录入注意事项2018-11-23 6:36:18
- 如何录入期初数据2018-11-22 15:38:28
- 你好,T+怎样反结账,反记账,反审核2018-11-22 8:19:54
- 用友T6软件用友T3录入期初余额时提示科目正在被机器上的进行期初余额录入操作锁定,请稍后再试2018-11-12 16:27:56
- 用友T6软件如何建立新的会计年度,并且将上一年度数据结转下一年度2018-11-9 13:21:48
- 用友T6软件如何增加操作员和设置操作员权限?2018-7-3 18:11:55
- 预收账面在什么情况下调帐,调帐的分录是什么,可以调到其他应付款吗 _02018-2-18 0:0:0
- 预测投资项目现金流量要遵循现金流量原则,一般需要考虑的成本有?2018-2-18 0:0:0
- 预算执行与收支业务、采购业务、资产管理、建设项目管理、合同管理并不相关联对吗2018-2-18 0:0:0
最新信息
U8.52销售单据上下翻页都往下走U8.52销售单据上下翻页都往下走
U8.52-销售单据上下翻页都往下走
自动编号: | 17560 | 产品版本: | U8.52 |
产品模块: | 销售管理 | 所属行业: | 通用 |
适用产品: | u861 | 关 键 字: | 翻页 |
问题名称: | 销售单据上下翻页都往下走 | ||
问题现象: | 数据从8.52升级上来,但是升级到861的时候销售单据(如销售订单\销售发货单\销售发票)上下翻页都往下走. | ||
原因分析: | 经过跟踪发现上下翻页的语句多了一个日期的判断条件,与正常帐套不同.后来发现在accinformation中有一条记录csysid='sa' and cname='bVouOrderByDate'(单据按日期排序)值为ture. | ||
解决方案: | 改这条记录的值为false即可. 温馨提示:如果您的问题还没有解决,欢迎进入用友云基地。 |
购入固定资产是否可以取得增值税专用发票? 购入固定资产是否可以取得增值税专用发票?
[问题]如果购销各方都是增值税一般纳税人,购入固定资产是否可以取得增值税专用发票?
[解答]《国家税务总局关于严格控制增值税专用发票使用范围的通知》(国税发[1995]88号)规定,各地要严格控制专用发票的使用范围,对生产经营机器、机车、汽车、轮船、锅炉等大型机械电子设备的工商企业,凡直接销售给使用单位的,不再开具专用发票,改用普通发票。根据这一规定,增值税一般纳税人销售生产经营机器、机车、汽车、轮船、锅炉等(对于购买方来说属于固定资产),直接销售给使用单位的,不开具专用发票,因此购买方取得的发票为普通发票。
建筑企业所得税汇缴:计税收入确认是关键 建筑企业所得税汇缴:计税收入确认是关键
税收案例
某建筑企业2010年2月承接了一房地产开发项目的主体建造工程,合同总造价1亿元,合同工期为2年。企业当年开具建安发票收取价款4000万元并记入“营业收入”,实际发生各项工程成本、费用、税金及附加等共计4870万元,企业在年度所得税汇算申报时,计税所得额为亏损870万元。2011年8月,主管税务机关在纳税检查过程中,通过对该企业工程部与项目业主单位共同确认的工程施工情况表核实,该工程的完工进度已达到50%。对此,主管税务机关作出了调整计税收入、补缴各项税款并依法加收滞纳金的决定。企业财务负责人在陈述中认为,由于没有收到款项,因而没有确认为计税收入。
法理分析
关于建筑企业计税收入的确认问题,有关法律法规和规范性文件中都有明确规定。
营业税暂行条例第十二条规定,营业税纳税义务发生时间为纳税人提供应税劳务、转让无形资产或者销售不动产并收讫营业收入款项或者取得索取营业收入款项凭据的当天。从实际征管来看,建筑企业所签订的建造合同,在价款支付方面,大多是按工程进度付款。笔者认为,只要双方确认了工程进度情况,就属于上述规定的情形,应当按期确认为计税收入。
企业所得税法第二十一条规定,在计算应纳税所得额时,企业财务、会计处理办法与税收法律、行政法规的规定不一致的,应当依照税收法律、行政法规的规定计算。企业财务核算上注重谨慎性原则,而税收法律法规上坚持的是权责发生制原则。即属于当期的收入和费用,不论款项是否收付,均作为当期的收入和费用;不属于当期的收入和费用,即使款项已经在当期收付,均不作为当期的收入和费用。因此,建筑企业必须严格依照税收法律和行政法规的规定确认计税收入,不能人为地想当然进行处理。
企业所得税法实施条例第二十三条第二款规定,企业受托加工制造大型机械设备、船舶、飞机,以及从事建筑、安装、装配工程业务或者提供其他劳务等,持续时间超过12个月的,按照纳税年度内完工进度或者完成的工作量确认收入的实现。同时,《国家税务总局关于确认企业所得税收入若干问题的通知》(国税函[2008]875号)第二条规定,企业在各个纳税期末,提供劳务交易的结果能够可靠估计的,应采用完工进度(完工百分比)法确认提供劳务收入。
在每年的企业所得税汇算清缴工作中,建筑企业计税收入的确定上存在不少问题。不少中小型企业都不严格按照企业所得税法和有关行政法规、部门规章关于收入确认的原则来处理,造成了纳税申报不实。一是不按建造工程的完工进度或完成的工作量来确认计税收入,而是按是否实际收到款项来确认收入;二是对建造完工并投入使用的项目,按照合同约定而扣留的质量保证金,既不挂账,也不作收入处理;三是对建造完工并投入使用的项目,长期不办理工程决算,影响计税收入的正确核算。
通过上述法理分析,建筑企业按工程进度或完成的工作量来确认计税收入是一个最重要、最基本的税收处理原则。在实际征管工作中,不管工程持续期是否超过12个月,只要跨过1个纳税年度的,建筑企业均应在年末根据完工进度确认该年度的计税收入,依法申报纳税。否则,补税、罚款、加收滞纳金等法律责任对建筑企业来讲只是时间问题,这样的涉税风险必须关注。
征管建议
建筑企业涉税风险多,这给基层税务机关的日常税收征管带来了一定的难度,也给企业埋下了不少税务法律责任风险,必须引起税企双方高度重视。从税收征管的角度来说,税务机关必须加强以下几个方面的管理。
第一,建立合同登记备案制度。建立合同登记备案制度对于强化税收征管十分必要,一方面可以掌握建筑企业的工程量,另一方面也可以清楚地了解企业税源增减变化状况。
第二,进一步加强发票管理,搞好跟踪比对。强化对付款单位的核查比对,一方面验证发票填开的真实性,另一方面通过与合同、工程进度的核查,核实计税收入确认的准确性,做到管理与征收到位。
第三,严格执行外出经营活动税收管理证明制度。经营地税务机关和注册地税务机关要加强协调配合,严格按照规定开具、缴销外出经营活动税收管理证明,真正形成齐抓共管的合力,避免征管漏洞,强化监管力度,保证税收政策落实到位,管理到位。
第四,加强纳税辅导和日常检查。根据建筑企业的行业特点和涉税风险点,基层税务机关要加强纳税辅导和日常检查工作,对违法违规行为要依法处理,进一步提高纳税申报质量和财务核算水平。同时,要采取各种方法和途径,加强涉税知识和涉税风险的教育培训,努力提高纳税企业对税法的自觉遵从度。
工行中欧精选定期开放混(001117)昨天的净值怎么和东方财富的不一样 工行中欧精选定期开放混(001117)昨天的净值怎么和东方财富的不一样我是4月1号在工行购的中欧精选定期开放混(001117),但昨天工行显示的单位净值只有1.024,而我在东方财富上查到的是1.0520,这是怎么回事
请问建立年度账出这个错误提示应该怎么解决? 请问建立年度账出这个错误提示应该怎么解决?
建立年度账,中途出现对象名报错问题,请参考服务社区-知识库上的方案来处理:
http://service.chanjet.com/zhi ... d5e33
- 我们公司有一个采购人员,她会每个月从财务部借一笔款用于平时的购买原材料和办公用品或者交话费等之处,像这样的话,在现金流量表内怎么反应呢,是不是都记载购买商品及接受劳务支付的现金呢,还是归集到支付其他与经营活动有关的现金呢
- 进项税,销项税可以隔月结转吗?我上个月做账的时候没有结转,可以在这个月结转吗?
- 有人能给我讲讲递延所得税到底是怎么回事吗?它要把我逼死了
- @曾雪峰 曾老师,经济法中为什么有形动产租赁的进项税额不得抵扣呢?一直不能理解
- 今年公司利润正数三十万,不做分红,要直接转做实收资本,要怎么做?实收资本还未达到注册资本的情况,有三个股东的。
- 请教老师,筹建期的业务招待费应计入当期损益还是长期待摊费用?
- 易代帐工作台怎么使用?
- 赵老师,我想问一下事业单位年底有事业结余,要弥补以前年度亏损怎么做?@赵树峰
- 销项税大于进项税怎么结转,新手求指教
- #东莞同城会#:新人加入,请多多指教
U8.5112月结帐时提示‘本月有已暂估报销但未处理单据,不能结帐’U8.5112月结帐时提示‘本月有已暂估报销但未处理单据,不能结帐’
U8.51-12月结帐时提示‘本月有已暂估报销但未处理单据,不能结帐’
自动编号: | 12984 | 产品版本: | U8.51 |
产品模块: | 存货核算 | 所属行业: | 通用 |
适用产品: | 851 | 关 键 字: | 12月结帐时提示‘本月有已暂估报销但未处理单据,不能 |
问题名称: | 12月结帐时提示‘本月有已暂估报销但未处理单据,不能结帐’ | ||
问题现象: | 12月结帐时提示‘本月有已暂估报销但未处理单据,不能结帐’ | ||
原因分析: | 数据库问题 | ||
解决方案: | 检查PurSettleVouchs 采购结算单子表中是否存在iSVCost(结算单价),iSVNum(结算件数),iSVPrice(结算金额),iSVQuantity(结算数量)均为0的数据记录,如果存在可修改记帐人标志字段bAccount为1即可 温馨提示:如果您的问题还没有解决,欢迎进入用友云基地。 |
财务通标准版2005委托出库单登记哪些账?财务通标准版2005委托出库单登记哪些账?
财务通标准版2005-委托出库单登记哪些账?
自动编号: | 444 | 产品版本: | 财务通标准版2005 |
产品模块: | 总账 | 所属行业: | 通用 |
适用产品: | 关 键 字: | 委托受托管理 | |
问题名称: | 委托出库单登记哪些账? | ||
问题现象: | 委托出库单登记哪些账? | ||
原因分析: | 参见答案 | ||
解决方案: | ● 委托代销出库登记委托代销商品账、仓库货位商品账。 温馨提示:如果您的问题还没有解决,欢迎进入用友云基地。 |
- 进货单辅计量数量大于订单辅计量数量无法保存,如何设置
- 进货订单有三项数量金额都打错了,并且已经入库付款了,请问怎么办
- 进销存统计表里面怎么有个出库数量他的来源是拿来。在帮助里也没有看到
- 远程通发布T3标准版 提示只能使用畅捷通的远程产品 如何解决?
- 连接T1的大华电子秤 能分开下载商品吗 比如商品1-10,大华电子秤A AND 大华电子秤B 商品1-5要下载到大花电子秤A 6-10要下载到大花电子秤B
- 连接不到本地数据库是什么情况?软件为G3.xp系统.2000数据库
- 连续打印凭证,凭证间距不断变大,怎么解决
- 送货单抬头单位名称怎样修改如何修改
- 选哪个?
- 通过销货单生成的凭证删除不了,提示"相关记录查不到,或信息已发生修改……”
怎么回事 怎么回事[]
美国枪击案14人遇难?两名被击毙嫌犯身份确认@畅捷支持侯椿寳:你是我大哥啊对的。@畅捷支持侯椿寳:终于找到你了[/流泪],求收留啊,我在新道学院二楼新道学院二楼已搬空,目前是个鬼楼。
贴主确定还在目前现世这个位面。楼主已封楼,
贴主如果被困在虚空位面,
需要紧急与一层大厅镜前,
使用灵力,集中意念穿越回来,
否则永久困顿新道二层翡翠梦境中。@畅捷支持侯椿寳:你执念太深,还没走出来啊已定居。
T3出纳管理模块,‘显示历史帐套’打勾,才能看到出纳帐套,现在进去出纳系统管理中,帐套管理也能看到出纳帐套,但是点击帐套—年度结账中看不到 T3出纳管理模块,‘显示历史帐套’打勾,才能看到出纳帐套,现在进去出纳系统管理中,帐套管理也能看到出纳帐套,但是点击帐套—年度结账中看不到
建议用户及时提交T3 产品线问题支持。
用友T6软件零售单过账提示数据不正确资产负债表不平零售单过账提示数据不正确资产负债表不平
零售单过账提示数据不正确资产负债表不平原因分析: 当软件计算金额与电子称打印金额不一致时,就会出现“数据不正确,资产负债表不平”的提示。例如:商品的电子秤识别码为1200011011106,单价为后5位,11106,金额代表11.106,输入该商品后,用11.106除以该商品的单价35.00反算数量,最后在该商品行会显示一个合计金额11.10000010,这个合计金额不等于11.106,过账就会发生错误。问题解答: 先备份数据,再在查询分析器中执行如下脚本。set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER 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 endelse 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