csq39 发表于 2017-6-6 10:05:57

月结库存流水修正过程

<p>月结库存流水修正过程</p><p>首先根据物资是否有barcode分为两部分进行修正。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;有barcode:&nbsp; &nbsp;</p><p>&nbsp; &nbsp;a)有barcode的物资按照仓库,barcode进行对5月流水进行汇总统计,取数量等于1的为5月新增barcode,数量等于-1的为5月消耗barcode,忽略数量等于0的。</p><p>&nbsp; &nbsp;b)在4月结存库存的基础上,按照第一个的结果进行增加和删除记录</p><p>&nbsp; &nbsp; 无barcode的:</p><p>&nbsp; &nbsp; a)根据仓库,物料,批次以及单位对5月流水进行汇总,取数量大于0的为5月新增的物资,小于0的为出库/消耗物资</p><p>&nbsp; &nbsp; b)在4月结存库存的基础,按照计算结果,增加或者减少物资数量,如果物资数量为0则进行删除</p><p>&nbsp; &nbsp; 特殊物资处理:</p><p>&nbsp; &nbsp; 文具库5月有对非贴签物资进行处理,但是没有增加对应流水,造成在系统内部,流水和库存不符合的问题。</p><p>&nbsp; &nbsp; 处理方式:按照物资实际出入量,在4月的基础上修正这部分物资的库存</p><p>相关sql:<img src="http://bbs.cs126.cn/ueditor/dialogs/attachment/fileTypeImages/icon_txt.gif"/><a href="/ueditor/php/upload/file/20170606/1496714722482887.txt" title="月结库存处理sql.txt" style="line-height: 16px; font-size: 12px; color: rgb(0, 102, 204);">月结库存处理sql.txt</a></p><p>&nbsp;<br/></p>

csq39 发表于 2017-6-14 12:37:35

<p>确认sql:</p><p>select * from ( &nbsp;&nbsp;</p><p>&nbsp;select material_id,sum(jit.jit_stock_sum_qty * jit.unite_price) a,&#39;201705&#39;</p><p>&nbsp; &nbsp; &nbsp; from tb_usc_monthly_balance_dtl_jit jit</p><p>&nbsp; &nbsp; &nbsp;where jit.account_period = &#39;201705&#39;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;and jit.wh_id = &#39;100109&#39;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;group by material_id</p><p>&nbsp; &nbsp; &nbsp; union &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select material_id,sum(jit.jit_stock_sum_qty * jit.unite_price),&#39;201704&#39;</p><p>&nbsp; &nbsp; &nbsp; from tb_usc_monthly_balance_dtl_jit jit</p><p>&nbsp; &nbsp; &nbsp;where jit.account_period = &#39;201704&#39;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;and jit.wh_id = &#39;100109&#39;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;group by material_id</p><p>&nbsp; &nbsp; &nbsp; &nbsp;union&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select material_id,sum(t.quantity*t.trade_price),&#39;flow&#39;</p><p>&nbsp; &nbsp;from tb_usc_monthly_balance_dtl_flw t</p><p>&nbsp; where t.account_period=&#39;201705&#39;&nbsp;</p><p>&nbsp; and &nbsp;t.wh_to_id=&#39;100109&#39;</p><p>&nbsp;group by material_id) t</p><p>&nbsp;where t.a!=0</p><p>&nbsp;order by 1,3</p><p><br/></p>
页: [1]
查看完整版本: 月结库存流水修正过程