zoukankan      html  css  js  c++  java
  • 自动生成损益单

    --select profitloss_bi from profitloss_m where memo like '库存结转自动生成损益单-201305%'
    --603100000134
    --begin tran
    declare @dt varchar(8)
    select @dt='20130501'

    declare @memo varchar(50),
    @profit_bi varchar(12),
    @outlet_id varchar(8)

    select @memo='调整4月份结存历史误差-'+@dt


    select @outlet_id=ltrim(rtrim(run_values)) from setting where name='outlet_id'
    select @profit_bi = '6'+@outlet_id+ RIGHT('00000000' + CONVERT(VARCHAR(8),CONVERT(NUMERIC(8,0),NUMBER)+1),8)
    from number where number_id ='pftloss'

    update number set number = CONVERT(VARCHAR(8),CONVERT(NUMERIC(8,0),NUMBER)+1) where number_id = 'pftloss'
    insert into profitloss_m(profitloss_bi, outlet_id,headquarters_id,folio_ref, input_dt, inputter, audite_dt, auditer, status, memo)
    values(@profit_bi,@outlet_id,'H01', '',@dt,
    '系统生成',@dt,'系统生成','1',@memo)



    insert into profitloss_d(profitloss_bi,aid,storespace_id,q,entry_a,memo)
    select @profit_bi,aa.aid,'00',0,-(a1-a2) as entry_a,''
    from
    (
    select a.aid,sum(tax_entry_a) as a1
    ,sum(stock_q) q1
    from article_storespace b,article a
    where a.aid=b.aid and left(a.segregate_id,2)='01'
    group by a.aid
    )aa,
    (
    select sum(q) q2,
    a.aid,
    sum(ea) as a2 from dbo.uf_get_stock_da_curr('20130527') a,article b
    where a.aid=b.aid and left(b.segregate_id,2)='01'
    group by a.aid
    )bb,article c
    where aa.aid=bb.aid and aa.aid=c.aid and abs(a1-a2)>0
    order by abs(a1-a2) desc

    print @profit_bi


    --rollback

    select * from profitloss_m where profitloss_bi='603100000137'
    select * from profitloss_d where profitloss_bi='603100000137'

  • 相关阅读:
    hive函数之~字符串函数
    hive函数之~条件函数
    JSONP使用及注意事项小结
    css命名管理混乱?不妨试试BEM
    【移动端debug-6】如何做一个App里的web调试小工具
    ES6学习笔记(五):Class和Module
    ES6学习笔记(三):与迭代相关的新东东
    ES6学习笔记(四):异步操作
    ES6学习笔记(二):引用数据类型
    CORS跨域资源共享简述
  • 原文地址:https://www.cnblogs.com/kuailewangzi1212/p/3101618.html
Copyright © 2011-2022 走看看