Browse Source

代宰结算的逻辑

master
luanhui 8 years ago
parent
commit
29d217a145
5 changed files with 144 additions and 2 deletions
  1. +1
    -0
      B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs
  2. +7
    -0
      B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs
  3. +128
    -0
      B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs
  4. +5
    -2
      B3SubstituteKill/BO/Bills/StatPay/StatPay.cs
  5. +3
    -0
      B3SubstituteKill/BO/Bills/StatPay/StatPay_CostDetail.cs

+ 1
- 0
B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs View File

@ -108,6 +108,7 @@ __DFContainer.setValue('PriceBill_ID','');
_costDetail = titlePanel.EAdd(new DFEditGrid(editor) { Width = Unit.Percentage(100) });
_costDetail.Columns.Add(new DFEditGridColumn("SubKillProductLine_Name"));
_costDetail.Columns.Add(new DFEditGridColumn("GenerationCostItem_Name"));
_costDetail.Columns.Add(new DFEditGridColumn("Number"));
_costDetail.Columns.Add(new DFEditGridColumn("Price"));
_costDetail.Columns.EAdd(new DFEditGridColumn("Money"));
var section = mPageLayoutManager.AddSection("CostDetail", "代宰费用");


+ 7
- 0
B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs View File

@ -16,5 +16,12 @@ namespace BWP.B3SubstituteKill.BL
public class StatPayBL : DepartmentWorkFlowBillBL<StatPay>, IStatPayBL
{
protected override void beforeSave(StatPay dmo)
{
dmo.CostMoney = dmo.CostDetails.Sum(x => (x.Money ?? 0).Value);
dmo.CallbackPayMoney = dmo.CallbackPayDetails.Sum(x => (x.Money ?? 0).Value);
dmo.ReceiveMoney = (dmo.CostMoney ?? 0) - (dmo.CallbackPayMoney ?? 0);
base.beforeSave(dmo);
}
}
}

+ 128
- 0
B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs View File

@ -7,6 +7,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BWP.B3Frameworks;
using BWP.B3Frameworks.BO.NamedValueTemplate;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using Forks.Utils;
using TSingSoft.WebPluginFramework;
namespace BWP.B3SubstituteKill.BL
@ -32,5 +38,127 @@ namespace BWP.B3SubstituteKill.BL
dmo.Weight = dmo.Details.Sum(x => x.Weight.EToDecimal() ?? 0);
base.beforeSave(dmo);
}
protected override void doUnCheck(SubKillWeightBill dmo)
{
DeleteNotCheckedStatPay(dmo);
base.doUnCheck(dmo);
}
private void DeleteNotCheckedStatPay(SubKillWeightBill dmo)
{
var queryDom = new DQueryDom(new JoinAlias(typeof(StatPay)));
queryDom.Columns.Add(DQSelectColumn.Field("ID"));
queryDom.Where.Conditions.Add(DQCondition.EQ("Weigh_ID", dmo.ID));
var id = (long?)Session.ExecuteScalar(queryDom);
if (id == null)
{
return;
}
var statPayBL = BIFactory.Create<IStatPayBL>(Session);
var statPay = statPayBL.Load(id.Value);
if (statPay != null)
{
if (statPay.BillState != .)
{
throw new ApplicationException("结算单 No." + statPay.ID + statPay.BillState + ",不能执行此操作。");
}
statPayBL.Delete(statPay);
AppendMessage("删除结算单No." + statPay.ID);
}
}
protected override void doCheck(SubKillWeightBill dmo)
{
CreateStatPay(dmo);
base.doCheck(dmo);
}
private void CreateStatPay(SubKillWeightBill dmo)
{
var statPay = new StatPay();
statPay.AccountingUnit_ID = dmo.AccountingUnit_ID;
statPay.Domain_ID = dmo.Domain_ID;
statPay.Department_ID = dmo.Department_ID;
statPay.Employee_ID = dmo.Employee_ID;
statPay.Date = dmo.Date;
statPay.Weigh_ID = dmo.ID;
statPay.Supplier_ID = dmo.Supplier_ID;
statPay.Number = dmo.Number;
statPay.Weight = dmo.Weight;
statPay.PriceBill_ID = dmo.PriceBill_ID;
var subKillPriceBill = GetSubKillPriceBill(dmo);
if (subKillPriceBill != null)
{
foreach (SubKillWeightBill_Detail wdetail in dmo.Details)
{
foreach (SubKillPriceBill_CostItemDetail costItemDetail in subKillPriceBill.CostItemDetails)
{
var detail = new StatPay_CostDetail();
detail.SubKillProductLine_ID = wdetail.SubKillProductLine_ID;
detail.GenerationCostItem_ID = costItemDetail.GenerationCostItem_ID;
detail.Price = costItemDetail.Price;
detail.Number = wdetail.Number;
detail.Money = detail.Price * detail.Number;
statPay.CostDetails.Add(detail);
}
foreach (SubKillPriceBill_CallBackDetail callBackDetail in subKillPriceBill.CallBackDetails)
{
var detail = new StatPay_CallbackPayDetail();
detail.SubKillCallBack_ID = callBackDetail.SubKillCallBack_ID;
detail.Price = callBackDetail.Price;
detail.Money = callBackDetail.Price * wdetail.Number;
statPay.CallbackPayDetails.Add(detail);
}
}
}
else
{
foreach (SubKillWeightBill_Detail wdetail in dmo.Details)
{
var detail = new StatPay_CostDetail();
detail.SubKillProductLine_ID = wdetail.SubKillProductLine_ID;
detail.Number = wdetail.Number;
detail.Money = detail.Price * detail.Number;
statPay.CostDetails.Add(detail);
}
}
BIFactory.Create<IStatPayBL>(Session).Insert(statPay);
AppendMessage("生成代宰结算单:" + statPay.ID);
}
private SubKillPriceBill GetSubKillPriceBill(SubKillWeightBill dmo)
{
var pricebillid = GetSubKillPriceBillID(dmo);
if (pricebillid == null)
{
return null;
}
var pricebill = BIFactory.Create<ISubKillPriceBillBL>(Session).Load(pricebillid.Value);
return pricebill;
}
private long? GetSubKillPriceBillID(SubKillWeightBill dmo)
{
var bill = new JoinAlias(typeof(SubKillPriceBill));
var detail = new JoinAlias(typeof(SubKillPriceBill_SupplierDetail));
var query = new DQueryDom(bill);
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "SubKillPriceBill_ID"));
query.Where.Conditions.Add(DQCondition.EQ(bill, "Domain_ID", DomainContext.Current.ID));
query.Where.Conditions.Add(DQCondition.LessThanOrEqual("Date", dmo.Date));
query.Where.Conditions.Add(DQCondition.EQ(bill, "AccountingUnit_ID", dmo.AccountingUnit_ID));
query.Where.Conditions.Add(DQCondition.EQ(bill, "Department_ID", dmo.Department_ID));
query.Where.Conditions.Add(DQCondition.EQ("BillState", .));
query.Where.Conditions.Add(DQCondition.EQ(detail, "Supplier_ID", dmo.Supplier_ID));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
query.Columns.Add(DQSelectColumn.Field("ID", bill));
return query.EExecuteScalar<long?>(Session);
}
}
}

+ 5
- 2
B3SubstituteKill/BO/Bills/StatPay/StatPay.cs View File

@ -63,11 +63,11 @@ namespace BWP.B3SubstituteKill.BO
[LogicName("代宰头数")]
[DFExtProperty("WebControlType", DFEditControl.StaticText)]
public int Number { get; set; }
public int? Number { get; set; }
[LogicName("代宰重量")]
[DFExtProperty("WebControlType", DFEditControl.StaticText)]
public Money<decimal> Weight { get; set; }
public Money<decimal>? Weight { get; set; }
[LogicName("价格单号")]
[DFExtProperty("WebControlType", DFEditControl.StaticText)]
@ -91,6 +91,9 @@ namespace BWP.B3SubstituteKill.BO
public DateTime? WeighTime { get; set; }
public Money<>? CostMoney { get; set; }
public Money<>? CallbackPayMoney { get; set; }
private StatPay_CostDetailCollection _mCostDetails = new StatPay_CostDetailCollection();
[OneToMany(typeof(StatPay_CostDetail), "ID")]
[Join("ID", "StatPay_ID")]


+ 3
- 0
B3SubstituteKill/BO/Bills/StatPay/StatPay_CostDetail.cs View File

@ -25,6 +25,9 @@ namespace BWP.B3SubstituteKill.BO
[LogicName("单价")]
public Money<decimal>? Price { get; set; }
[LogicName("头数")]
public int? Number { get; set; }
[LogicName("金额")]
public Money<>? Money { get; set; }


Loading…
Cancel
Save