|
@@ -30,7 +30,7 @@ namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
fields = fields ?? @"softbed_id,softbed_code,softbed_relcode,softbed_name,deptid,create_date,create_emp,mtrlmode,mtrltype,has_headboard,has_nightstand,has_bedframe,is_template,
|
|
|
template_id,template_code,template_name,commission,taxes,taxrate,other_rate,extras_cost,money_type,moneyrate,dscrp,costamt,nottax_factory_cost,nottax_dept_cost,
|
|
|
- dept_cost,foreign_cost,total_mtrl_cost,total_hr_cost,total_cost,version";
|
|
|
+ dept_cost,foreign_cost,total_mtrl_cost,total_hr_cost,total_cost,version,flag,audit_date,audit_emp,update_date,update_emp";
|
|
|
var bill = new u_softbed() { softbed_id = billid };
|
|
|
if (DbSqlHelper.SelectOne(cmd, bill, fields) == 0) return null;
|
|
|
return bill;
|
|
@@ -45,7 +45,7 @@ namespace JLHHJSvr.Helper
|
|
|
public List<u_softbed_mx> GetSoftBedMxList(int billid,string fields = null)
|
|
|
{
|
|
|
fields = fields ?? @"softbed_id,printid,formulaid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
|
- useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,pzmxname";
|
|
|
+ useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,formulaname";
|
|
|
var mxlist = new List<u_softbed_mx>();
|
|
|
|
|
|
var selectStr = @"SELECT u_softbed_mx.softbed_id
|
|
@@ -72,9 +72,11 @@ namespace JLHHJSvr.Helper
|
|
|
,u_softbed_mx.price_formula_str
|
|
|
,u_softbed_mx.cost_price
|
|
|
,u_softbed_mx.cost_amt
|
|
|
- ,u_configure_code.name AS pzname
|
|
|
+ ,ISNULL(u_configure_code.name,'') AS pzname
|
|
|
+ ,ISNULL(u_softbed_formula.formulaname,'') AS formulaname
|
|
|
FROM u_softbed_mx
|
|
|
LEFT JOIN u_configure_code ON u_softbed_mx.pzid = u_configure_code.pzid
|
|
|
+ LEFT JOIN u_softbed_formula ON u_softbed_mx.formulaid = u_softbed_formula.formulaid
|
|
|
";
|
|
|
|
|
|
DbSqlHelper.SelectJoin(cmd, selectStr, "softbed_id = @billid", new Dictionary<string, object>() { { "@billid", billid } }, "has_type,printid", fields, 0, 0, mxlist);
|
|
@@ -306,8 +308,8 @@ namespace JLHHJSvr.Helper
|
|
|
template_id,template_code,template_name,commission,taxes,taxrate,other_rate,extras_cost,money_type,moneyrate,dscrp,costamt,nottax_factory_cost,nottax_dept_cost,
|
|
|
dept_cost,foreign_cost,total_mtrl_cost,total_hr_cost,total_cost,version";
|
|
|
|
|
|
- var mx_fields = @"softbed_id,printid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
|
- useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,pzmxname";
|
|
|
+ var mx_fields = @"softbed_id,printid,pzid,formulaid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
|
+ useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt";
|
|
|
|
|
|
if(softbed.softbed_id == 0)
|
|
|
{
|
|
@@ -438,15 +440,17 @@ namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
if (codeMx.pzid == 0) continue;
|
|
|
// 判断是否有标准
|
|
|
- cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_codemx WHERE pzid = @pzid AND ifdft = 1";
|
|
|
+ cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_codemx WHERE pzid = @pzid AND printid = @printid AND ifdft = 1";
|
|
|
cmd.Parameters.Clear();
|
|
|
cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
|
|
|
+ cmd.Parameters.AddWithValue("@printid", codeMx.printid);
|
|
|
if(Convert.ToInt32(cmd.ExecuteScalar()) > 0)
|
|
|
{
|
|
|
- cmd.CommandText = @"UPDATE u_configure_codemx SET ifdft = 0 WHERE pzid = @pzid AND ifdft = 1";
|
|
|
+ cmd.CommandText = @"UPDATE u_configure_codemx SET ifdft = 0 WHERE pzid = @pzid AND printid = @printid AND ifdft = 1";
|
|
|
cmd.Parameters.Clear();
|
|
|
cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
|
|
|
- cmd.ExecuteNonQuery();
|
|
|
+ cmd.Parameters.AddWithValue("@printid", codeMx.printid);
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
}
|
|
|
|
|
|
codeMx.ifdft = 1;
|
|
@@ -473,6 +477,7 @@ namespace JLHHJSvr.Helper
|
|
|
,u_configure_code.inputtype
|
|
|
,LTRIM(RTRIM(u_configure_type.contfigtypename)) AS contfigtypename
|
|
|
,u_configure_code.typeid
|
|
|
+ ,u_configure_codemx.ifdft
|
|
|
FROM u_configure_codemx
|
|
|
INNER JOIN u_configure_code ON u_configure_codemx.pzid = u_configure_code.pzid
|
|
|
INNER JOIN u_configure_type ON u_configure_code.typeid = u_configure_type.contfigtypeid";
|
|
@@ -509,7 +514,7 @@ namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
whereList.AddRange(extraWheres);
|
|
|
}
|
|
|
- DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), null, "typeid,pzid,printid", "typeid,pzid,printid,pzcodemx,namemx,pzname,pzcode,contfigtypename", 0, 0, codeMxList);
|
|
|
+ DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), null, "typeid,pzid,printid", "typeid,pzid,printid,pzcodemx,namemx,pzname,pzcode,contfigtypename,ifdft", 0, 0, codeMxList);
|
|
|
|
|
|
// 部件选配项
|
|
|
var codeMap = new Dictionary<int, u_configure_code>();
|
|
@@ -524,7 +529,7 @@ namespace JLHHJSvr.Helper
|
|
|
name = codeMx.pzname,
|
|
|
contfigtypename = codeMx.contfigtypename,
|
|
|
pzcode = codeMx.pzcode,
|
|
|
- typeid = codeMx.pzid,
|
|
|
+ typeid = codeMx.typeid,
|
|
|
codeMxList = new List<u_configure_codemx>()
|
|
|
};
|
|
|
|
|
@@ -640,34 +645,50 @@ namespace JLHHJSvr.Helper
|
|
|
public void CalCulateFormula(u_softbed softbed)
|
|
|
{
|
|
|
InitSoftBed(softbed);
|
|
|
-
|
|
|
InitReplaceMents(softbed);
|
|
|
|
|
|
+ decimal total_mtrl_cost = 0, total_hr_cost = 0;
|
|
|
foreach (var mx in softbed.mxList)
|
|
|
{
|
|
|
- InitMxReplaceMents(softbed, mx);
|
|
|
+ InitMxReplaceMents(softbed, mx);
|
|
|
|
|
|
formula.CalculateAll();
|
|
|
|
|
|
- // 成本单价
|
|
|
- mx.cost_price = formula.GetFormulaItem("【成本单价】").value;
|
|
|
+ // 转换后的文本公式
|
|
|
+ mx.use_formula_str = formula.GetFormulaItem("【实际用量】").formula_transform;
|
|
|
+ mx.price_formula_str = formula.GetFormulaItem("【成本单价】").formula_transform;
|
|
|
+
|
|
|
+ // 成本单价
|
|
|
+ mx.cost_price = formula.GetFormulaItem("【成本单价】").value;
|
|
|
// 实际用量
|
|
|
mx.actual_useqty = formula.GetFormulaItem("【实际用量】").value;
|
|
|
// 成本金额
|
|
|
mx.cost_amt = formula.GetFormulaItem("【成本金额】").value;
|
|
|
// 总材料成本
|
|
|
- softbed.total_mtrl_cost += mx.cost_amt;
|
|
|
+ total_mtrl_cost += mx.cost_amt;
|
|
|
// 总人力成本
|
|
|
- softbed.total_hr_cost += 0;
|
|
|
+ total_hr_cost += 0;
|
|
|
}
|
|
|
-
|
|
|
+ softbed.total_mtrl_cost = total_mtrl_cost;
|
|
|
+ softbed.total_hr_cost = total_hr_cost;
|
|
|
softbed.total_cost = formula.GetFormulaItem("【车间成本】").value;
|
|
|
+
|
|
|
+ softbed.nottax_factory_cost = formula.GetFormulaItem("【不含税出厂价】").value;
|
|
|
+ softbed.nottax_dept_cost = formula.GetFormulaItem("【部门不含税价】").value;
|
|
|
+ softbed.dept_cost = formula.GetFormulaItem("【部门含税价】").value;
|
|
|
+ softbed.taxes = formula.GetFormulaItem("【税金】").value;
|
|
|
+ softbed.foreign_cost = formula.GetFormulaItem("【外币价】").value;
|
|
|
+ //formula.CalculateAll();
|
|
|
}
|
|
|
|
|
|
private void InitSoftBed(u_softbed softbed)
|
|
|
{
|
|
|
var dept = Cache.GetData<int, u_dept, DeptMapping>(softbed.deptid);
|
|
|
|
|
|
+ //
|
|
|
+ softbed.dept_profitrate = dept.profitrate;
|
|
|
+
|
|
|
+ //
|
|
|
softbed.moneyrate = softbed.moneyrate <= 0 ? 1 : softbed.moneyrate;
|
|
|
softbed.commission = softbed.commission <= 0 ? 1 : softbed.commission;
|
|
|
softbed.taxrate = softbed.taxrate <= 0 ? 1 : softbed.taxrate;
|
|
@@ -708,35 +729,32 @@ namespace JLHHJSvr.Helper
|
|
|
}
|
|
|
|
|
|
private void InitReplaceMents(u_softbed softbed)
|
|
|
- {
|
|
|
- // 公式变量
|
|
|
- formula.AddFormulaItem("【不含税出厂价】", "【车间成本】*(【工厂利润率】+【外销加点】)");
|
|
|
- formula.AddFormulaItem("【部门不含税价】", "【不含税出厂价】/【部门利润率】/( 1 - (【佣金点数】- 1))*【额外点数】+【FOB】");
|
|
|
- formula.AddFormulaItem("【部门含税价】", "【部门不含税价】*【税率】");
|
|
|
- formula.AddFormulaItem("【税金】", "【部门不含税价】* (【税率】-1)");
|
|
|
- formula.AddFormulaItem("【外币价】", "【部门含税价】/【汇率】");
|
|
|
-
|
|
|
- // 常量变量
|
|
|
- formula.AddFormulaItem("【部门利润率】", softbed.dept_profitrate);
|
|
|
+ {
|
|
|
+ // 常量变量
|
|
|
+ formula.AddFormulaItem("【部门利润率】", softbed.dept_profitrate);
|
|
|
formula.AddFormulaItem("【佣金点数】", softbed.commission);
|
|
|
formula.AddFormulaItem("【额外点数】", softbed.other_rate);
|
|
|
formula.AddFormulaItem("【额外费用】", softbed.extras_cost);
|
|
|
formula.AddFormulaItem("【汇率】", softbed.moneyrate);
|
|
|
formula.AddFormulaItem("【税率】", softbed.taxrate);
|
|
|
- formula.AddFormulaItem("【FOB】", 0);
|
|
|
+ formula.AddFormulaItem("【工厂利润率】", 1);
|
|
|
+ formula.AddFormulaItem("【FOB】", 0);
|
|
|
formula.AddFormulaItem("【外销加点】", 0);
|
|
|
formula.AddFormulaItem("【总材料成本】", softbed.total_mtrl_cost);
|
|
|
formula.AddFormulaItem("【总人力成本】", softbed.total_hr_cost);
|
|
|
- formula.AddFormulaItem("【车间成本】", softbed.total_cost);
|
|
|
+
|
|
|
+ // 公式变量
|
|
|
+ formula.AddFormulaItem("【不含税出厂价】", "【车间成本】*(【工厂利润率】+【外销加点】)");
|
|
|
+ formula.AddFormulaItem("【部门不含税价】", "【不含税出厂价】/【部门利润率】/( 1 - (【佣金点数】- 1))*【额外点数】+【FOB】");
|
|
|
+ formula.AddFormulaItem("【部门含税价】", "【部门不含税价】*【税率】");
|
|
|
+ formula.AddFormulaItem("【税金】", "【部门不含税价】* (【税率】-1)");
|
|
|
+ formula.AddFormulaItem("【外币价】", "【部门含税价】/【汇率】");
|
|
|
}
|
|
|
|
|
|
private void InitMxReplaceMents(u_softbed softbed,u_softbed_mx mx)
|
|
|
{
|
|
|
// 默认公式变量
|
|
|
- formula.AddFormulaItem("【总材料成本】", 0);
|
|
|
- formula.AddFormulaItem("【总人力费用】",0);
|
|
|
- formula.AddFormulaItem("【额外费用】", 0);
|
|
|
- formula.AddFormulaItem("【车间成本】", "【总材料成本】 + 【总人力费用】 + 【额外费用】");
|
|
|
+ formula.AddFormulaItem("【车间成本】", "【总材料成本】 + 【总人力成本】 + 【额外费用】");
|
|
|
formula.AddFormulaItem("【成本单价】", "【材料单价】*1");
|
|
|
formula.AddFormulaItem("【实际用量】", "【用料量】*(1 + 【损耗率】)");
|
|
|
formula.AddFormulaItem("【成本金额】", "【实际用量】 * 【成本单价】");
|