diff --git a/NX.ERP.U8/Base/MaterielDAL.cs b/NX.ERP.U8/Base/MaterielDAL.cs index f0917bc..928f38f 100644 --- a/NX.ERP.U8/Base/MaterielDAL.cs +++ b/NX.ERP.U8/Base/MaterielDAL.cs @@ -7,16 +7,28 @@ using NX.ERP.Model; namespace NX.ERP.U8 { + + + public class InvCost + { + + public double iInvNCost { get; set; } + public double iInvSPrice { get; set; } + public double iInvRCost { get; set; } + public double iImpTaxRate { get; set; } + } + + public class MaterialDAL { public IEnumerable GetList(string strWhere = "", object Param = null) { - + using (var conn = U8LoginContext.Instance.Connection) { - + var sql = @"select cInvCode AS MaterialCode , cInvAddCode AS 存货代码, @@ -283,7 +295,7 @@ namespace NX.ERP.U8 public IEnumerable GetList(IEnumerable codes) { - return this.GetList(" cInvCode in @codes ",new { codes }); + return this.GetList(" cInvCode in @codes ", new { codes }); } @@ -327,6 +339,75 @@ namespace NX.ERP.U8 + /// + /// 获取库存单价 + /// + /// + /// + /// + /// + /// + public bool GetInvPrice(string cInvCode, int iInout, string whCode, out double iInvCost) + { + + try + { + + string empty = string.Empty; + empty = ((iInout != 0) ? "cOutPrice" : "cInPrice"); + string strSQL = "SELECT cValue FROM Accinformation WITH(NOLOCK) WHERE cSysID = 'ST' AND cName = '" + empty + "'"; + string cType; + InvCost cost; + double _cost; + using (var conn = U8LoginContext.Instance.Connection) + { + cType = conn.ExecuteScalar(strSQL, null, null, 10, System.Data.CommandType.Text); + strSQL = "SELECT iInvNCost,iInvSPrice,iInvRCost,iImpTaxRate FROM Inventory WITH(NOLOCK) WHERE cInvCode = '" + cInvCode + "'"; + cost = conn.Query(strSQL, null).FirstOrDefault(); + + strSQL = $@" SELECT (CASE WHEN convert(decimal(36,3),isnull(inum,0))=0 then 0 else iMoney / iNum END) AS iPrice + from IA_Summary WHERE cWhCode='{whCode}' AND cInvCode='{cInvCode}' AND iMonth={DateTime.Today.Month - 1} and iyear ={DateTime.Today.Year}"; + _cost = conn.ExecuteScalar(strSQL, null, null, 10, System.Data.CommandType.Text); + } + + switch (cType) + { + case "按计价方式取单价": + iInvCost = _cost; + break; + case "计划单价": + + iInvCost = cost.iInvRCost; + break; + case "参考成本": + iInvCost = cost.iInvSPrice; + break; + + case "最新成本": + iInvCost = cost.iInvNCost; + break; + + default: + { + throw new Exception("取得U8存货档案价格失败!"); + } + } + + return true; + } + catch (Exception) + { + throw; + } + finally + { + + } + } + + + + /// /// 获取成本 /// diff --git a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs index f495c7a..23a721d 100644 --- a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs +++ b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs @@ -51,6 +51,10 @@ namespace NX.ERP.U8.Store headXml.setAttribute("cwhcode", storeOut.Whcode); headXml.setAttribute("csource", storeOut.Source); + + + + if (storeOut.Source == "生产订单") { headXml.setAttribute("cbustype", "领料"); @@ -104,6 +108,17 @@ namespace NX.ERP.U8.Store #region 明细 bodyXml = domBody.createElement("z:row"); + var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost); + + + + + + bodyXml.setAttribute("iunitcost", _cost); + var info = new Account.Accinformation(); + bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity)); + + //bodyXml.setAttribute("autoid", n); bodyXml.setAttribute("cinvcode", detail.InvCode); bodyXml.setAttribute("iquantity", detail.Quantity); @@ -216,7 +231,17 @@ namespace NX.ERP.U8.Store } #region 明细 - bodyXml = domBody.createElement("z:row"); //bodyXml.setAttribute("autoid", n); + bodyXml = domBody.createElement("z:row"); + var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost); + + + + + + bodyXml.setAttribute("iunitcost", _cost); + var info = new Account.Accinformation(); + bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity)); + bodyXml.setAttribute("cinvcode", detail.InvCode); bodyXml.setAttribute("iquantity", detail.Quantity); bodyXml.setAttribute("irowno", n + 1);