- 1、本文档共8页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
金蝶K3实现自动核算(供应商管理单价)
原金蝶K3的存货核算都是手动核算,比较麻烦!HOHO!现编写SQL语句搞定自动核算!因金蝶K3实现自动核算(物料单价)一文只对物料里面的采购单价获取价格,对于一个物料有多个供应商后有多个采购价格,上文不能实现,因此重新编写SQL语句。 (想尽办法偷懒,HOHO!)? ?? ???if exists (select * from sysobjects where name = icstockbill_jade01) drop trigger icstockbill_jade01gocreate trigger icstockbill_jade01 on icstockbillfor insert,updateasdeclare @frob int,@finterid int,@ftrantype int,@fstatus intselect??@frob = frob,@finterid = finterid,@ftrantype = ftrantype,@fstatus = fstatus from inserted--更新蓝字,未审核状态的 销售出库单,领料单,委外出库单,其他出库单的单价和金额--更新步骤:供应商供货信息,以前月份的期末单价,以前月份的发出单价--供应商供货信息只取RMB的平均单价if @frob = 1 and @fstatus = 0 and (@ftrantype = 21 or @ftrantype = 24 or @ftrantype = 28 or @ftrantype = 29)? ? begin? ?? ???--更新供应商供货信息平均单价? ???update a set fprice = isnull(b.fprice,0),famount = isnull(b.fprice,0) * fqty,fauxprice = isnull(b.fprice,0)? ???from icstockbillentry a ,(select fitemid,convert(decimal(18,2),avg(fprice)) as fprice from t_supplyentry where fcyid = 1 group by fitemid) bwhere a.fitemid = b.fitemid and a.finterid = @finteridif @ftrantype = 24? ???--更新以前月的平均单价? ???update x set fprice = y.fprice,famount = y.fprice * fqty,fauxprice = y.fprice? ???from icstockbillentry x,? ???(select fstockid,fitemid,fyear * 100 + fperiod as fperiods,? ???convert(decimal(18,2),avg(case when fendqty = 0 then case when fsend??0 then fcredit/fsend end else fendbal / fendqty end)) as fprice? ???from icinvbal ? ???where fsend??0 or fendqty??0? ???group by fstockid,fitemid,fyear * 100 + fperiod) y,? ???(select fstockid,fitemid,max(fyear * 100 + fperiod) as fperiods from icinvbal? ???where fsend??0 or fendqty??0 ? ???group by fstockid,fitemid) z? ???where y.fstockid = z.fstockid and y.fitemid = z.fitemid and y.fperiods = z.fperiods? ???and x.fscstockid = y.fstockid and x.fitemid = y.fitemid and x.finterid = @finteridelse? ???--更新以前月的平均单价? ???update x set fprice = y.fprice,famount = y.fprice * fqty,fauxprice = y.fprice? ???from icstockbillentry x,? ???(select fstockid,
您可能关注的文档
- 几个常用DOS网络命令.doc
- 几个单片机应用实例.doc
- 几个实用网络DOS命令.doc
- 几何画板课件制作教程.doc
- 几条使用率最高的SQL语句.doc
- 几种常见恶性电脑病毒清除方法.doc
- 几种最常见的Ghost系统安装图解.doc
- 计09面向对象程序设计 考试试卷(A卷).doc
- 计量泵快速安装指南.doc
- 计量管理和合同管理的探讨.doc
- 2023年通化市公务员考试行测真题及答案详解(各地真题).docx
- 2023年泰安市公务员考试行测真题(含答案详解).docx
- 2023年葫芦岛市公务员考试行测真题及答案详解(夺冠系列).docx
- 2023年海口市公务员考试行测真题及参考答案详解一套.docx
- 2023年钦州市公务员考试行测真题有完整答案详解.docx
- 2023年衡阳市公务员考试行测真题及答案详解(考点梳理).docx
- 2023年百色市公务员考试行测真题及一套参考答案详解.docx
- 2023年赤峰市公务员考试行测真题含答案详解.docx
- 2023年绥化市公务员考试行测真题完整参考答案详解.docx
- 2023年西安市公务员考试行测真题及一套参考答案详解.docx
文档评论(0)