增加价格

This commit is contained in:
gongxh
2021-03-26 09:48:36 +08:00
parent 8e10c99fe6
commit 494f5bda7c
2 changed files with 110 additions and 4 deletions

View File

@@ -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<Material> 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<Material> GetList(IEnumerable<string> 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
/// <summary>
/// 获取库存单价
/// </summary>
/// <param name="cInvCode"></param>
/// <param name="iInout"></param>
/// <param name="iInvCost"></param>
/// <param name="iImpTaxRate"></param>
/// <returns></returns>
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<string>(strSQL, null, null, 10, System.Data.CommandType.Text);
strSQL = "SELECT iInvNCost,iInvSPrice,iInvRCost,iImpTaxRate FROM Inventory WITH(NOLOCK) WHERE cInvCode = '" + cInvCode + "'";
cost = conn.Query<InvCost>(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<double>(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
{
}
}
/// <summary>
/// 获取成本
/// </summary>

View File

@@ -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);