库存单位数量换算成库存辅助单位数量原创
金蝶云社区-果果01
果果01
2人赞赏了该文章 16次浏览 未经作者许可,禁止转载编辑于2024年08月24日 08:26:25

    通过插件将库存单位数量换算成辅助单位数量,具体代码如下:

                    DynamicObjectCollection materialStock = material["MaterialStock"] as DynamicObjectCollection;

                    DynamicObject auxUnitID = materialStock[0]["AuxUnitID"] as DynamicObject;//库存单位

                    decimal appQty = Convert.ToDecimal(item["MustQty"]);

                    if (auxUnitID != null)

                    {

                        newRow["SecUnitId"] = auxUnitID;

                        newRow["SecUnitId_Id"] = auxUnitID["Id"];

                        //获取单位换算率

                        GetUnitConvertRateArgs getUnitConvertRateArgs = new GetUnitConvertRateArgs();

                        getUnitConvertRateArgs.MasterId = Convert.ToInt32(material["Id"]);

                        getUnitConvertRateArgs.SourceUnitId = Convert.ToInt32(unitID["Id"]);

                        getUnitConvertRateArgs.DestUnitId = Convert.ToInt32(auxUnitID["Id"]);

                        GetUnitConvertRateArgs param = getUnitConvertRateArgs;

                        var rate = AppServiceContext.BDService.GetUnitConvertRate(this.Context, param);

                        var secQty = rate.ConvertQty(appQty);//换算辅助数量

                        newRow["FStockSecAppQty"] = secQty;

                    }


赞 2