public void Notify(params object[] args) { if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) { return; } BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey; if (key == null) { return; } SO so = key.GetEntity() as UFIDA.U9.SM.SO.SO;//销售订单实体 if (so == null) { return; } //if (UFIDA.U9.Base.Context.LoginOrg.Code != "J002") return;//组织必须等于贸易中心 if (!PubHelperExtend.IsTradeCenterOrg()) { return; //组织必须等于贸易中心 } if (string.IsNullOrEmpty(so.DescFlexField.PrivateDescSeg14)) { throw new Exception("接单组织不能为空!"); } #region 根据接单组织改变记账期间、币种、法人组织 UFIDA.U9.Base.Organization.Organization org = UFIDA.U9.Base.Organization.Organization.Finder.Find("Code='" + so.DescFlexField.PrivateDescSeg14 + "'");//组织机构 if (org == null) { throw new Exception("无效的接单组织!"); } so.LegacyOrg = org;// 法人组织 foreach (SOLine line in so.SOLines) { foreach (SOShipline subLine in line.SOShiplines) { subLine.ShiperOrg = org; Session.Current.InList(subLine); } } UFIDA.U9.Base.SOB.SetofBooks setofBooks = UFIDA.U9.Base.SOB.SetofBooks.Finder.Find("SOBType=0 and Org.Code='" + so.DescFlexField.PrivateDescSeg14 + "'");//主账簿 if (setofBooks == null) { throw new Exception("接单组织:" + org.Name + "未设置主账簿!"); } UFIDA.U9.Base.SOB.SOBAccountingPeriod sob = UFIDA.U9.CBO.SCM.Util.BusinessHelper.GetNotClosedSOBAccountingPeriodBySOB(setofBooks, org.Key, so.BusinessDate, false); if (sob != null) { //记账期间赋值 so.KeepAccountPeriod = sob; so.FC = setofBooks.FunctionalCurrency; } #endregion }
/// <summary> /// 给单头赋值 /// </summary> /// <param name="headDto"></param> /// <param name="doc"></param> private void SetPrePaymentHead(PrePaymentHeadDTO headDto, UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePayment doc) { doc.DocumentTypeKey = headDto.DocumentType; doc.SrcDocType = EnumBE.PrePaySrcDocTypeEnum.PO; doc.CurrencyKey = headDto.Currency; doc.SupplierKey = headDto.Supplier; doc.POOrgKey = headDto.POOrg; doc.BusinessDate = DateTime.Today; doc.DeptKey = headDto.Dept; doc.BuyerKey = headDto.Buyer; doc.PrePayDate = doc.BusinessDate; if (headDto.POOrg != null) { doc.AccountPeriod = PubHelperExtend.GetSOBAccountingPeriod(doc.BusinessDate, headDto.POOrg.GetEntity().ID); } }
/// <summary> /// 创建红字的预付款通知单 /// </summary> /// <param name="doc"></param> /// <param name="headDto"></param> private long CreatePrePayment(UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePayment doc, PrePaymentHeadDTO headDto) { UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePayment head = UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePayment.Create(); head.DocumentTypeKey = headDto.DocumentType; head.SrcDocType = EnumBE.PrePaySrcDocTypeEnum.PO; head.CurrencyKey = doc.CurrencyKey; head.SupplierKey = doc.SupplierKey; head.POOrgKey = doc.POOrgKey; head.BusinessDate = DateTime.Today; head.DeptKey = doc.DeptKey; head.BuyerKey = doc.BuyerKey; head.PrePayDate = head.BusinessDate; if (doc.POOrg != null) { head.AccountPeriod = PubHelperExtend.GetSOBAccountingPeriod(head.BusinessDate, doc.POOrg.ID); } head.SrcPrePayDocID = doc.ID; head.SrcPrePayDocNo = doc.DocNo; int lineNum = 10;//行号 foreach (PrePaymentLineDTO lineDto in headDto.PrePaymentLineDTOs) { UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePaymentLine line = UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePaymentLine.Create(head); line.LineNum = lineNum; line.SrcPOKey = lineDto.PurchaseOrder; line.PrePayMoney = lineDto.ThisRedMoney; line.ActualMoeny = lineDto.ThisRedMoney; UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePaymentLine oldLine = UFIDA.U9.Cust.GS.FI.PrePaymentBE.PrePaymentLine.Finder.FindByID(lineDto.SrcPrePayLineID); if (oldLine != null) { oldLine.SumRedFlushMoney = oldLine.SumRedFlushMoney + lineDto.ThisRedMoney; if (oldLine.SrcPO != null) { UpdatePORedMoney(oldLine.SrcPO.ID, lineDto.ThisRedMoney); } } } return(head.ID); }
public void Notify(params object[] args) { if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) { return; } BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey; if (key == null) { return; } UFIDA.U9.SM.SO.SO so = key.GetEntity() as UFIDA.U9.SM.SO.SO;//销售订单实体 if (so == null) { return; } //if (UFIDA.U9.Base.Context.LoginOrg.Code != "J002") return;//组织必须等于贸易中心 if (!UFIDA.U9.Cust.GS.FT.PlugInBE.PubHelper.PubHelperExtend.IsTradeCenterOrg()) { return; //组织必须等于贸易中心 } List <UFIDA.U9.SM.SO.SOLine> sssessTypeList = new List <SM.SO.SOLine>(); //需要创建大货评估的订单行 List <UFIDA.U9.SM.SO.SOLine> adjustPriceList = new List <UFIDA.U9.SM.SO.SOLine>(); //需要创建的调价单集合 List <long> specilPriceList = new List <long>(); ////需要创建的特价申请单集合 UFIDA.U9.CBO.SCM.ProjectTask.Project project = null; foreach (UFIDA.U9.SM.SO.SOLine soLine in so.SOLines) { #region 校验 //提交时校验 if (so.OriginalData.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Open && so.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approving) { } //审核时校验 if (so.OriginalData.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approving && so.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approved) { if (!soLine.DescFlexField.PrivateDescSeg6.ToUpper().Contains("TRUE")) { throw new Exception("第" + soLine.DocLineNo.ToString() + "行还未生成佣金!"); } } //弃审时校验 if (so.OriginalData.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approved && so.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Open) { } #endregion if (project == null) { project = PubHelperExtend.GetProject(so);//创建或者查找已存在的项目号 } if (soLine.Project == null) { soLine.Project = project;//如果项目号为空,给项目号赋值 } #region 判断是否需要创建大货评估 bool isAssess = CreateSOAssessTypeExtend.CheckAssessType(soLine); if (isAssess) { sssessTypeList.Add(soLine); } #endregion #region 判断是否需要创建特价申请单 if (string.IsNullOrEmpty(soLine.DescFlexField.PrivateDescSeg5)) { throw new Exception("外销价不能为空!"); } decimal ePrice = decimal.Parse(soLine.DescFlexField.PrivateDescSeg5); if (ePrice <= 0) { throw new Exception("外销价必须大于0!"); } if (ePrice < soLine.OrderPriceTC && soLine.DescFlexField.PrivateDescSeg1.ToUpper().Contains("TRUE") == false) { throw new Exception("当特价未勾选时,外销价必须大于等于定价!"); } if (ePrice > soLine.OrderPriceTC && soLine.DescFlexField.PrivateDescSeg1.ToUpper().Contains("TRUE") == true) { throw new Exception("当特价勾选时,外销价不能高于定价!"); } if (ePrice < soLine.OrderPriceTC && soLine.DescFlexField.PrivateDescSeg1.ToUpper().Contains("TRUE") == true) { specilPriceList.Add(soLine.ID); } #endregion #region 判断是否已做成本预测 //销售订单如果修改或者变更外销价,如果是将价格改低,则需要检查销售订单是否已做订单成本预测, //如果已做,则必须先手工删除该订单的成本预测后才允许进行修改或者变更 if (soLine.OriginalData.DescFlexField.PrivateDescSeg5 != "" && ePrice < decimal.Parse(soLine.OriginalData.DescFlexField.PrivateDescSeg5)) { UFIDA.U9.Cust.GS.FT.CostForecastBE.CostForecast costForecast = UFIDA.U9.Cust.GS.FT.CostForecastBE.CostForecast.Finder.Find("SOLine= " + soLine.ID + ""); if (costForecast != null) { throw new Exception("销售订单" + so.DocNo + "行" + soLine.DocLineNo + "已做成本预测,请删除成本预测结果"); } } //如果销售订单已做成本预测,订单发生更改,则预测状态变为M if (soLine.DescFlexField.PrivateDescSeg18 == "Y") { soLine.DescFlexField.PrivateDescSeg18 = "M"; } #endregion #region 判断是否需要创建调价单 if (soLine.SO.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approved && ePrice > soLine.OrderPriceTC && soLine.PriceListID > 0L) { adjustPriceList.Add(soLine); } #endregion } //非审核的情况下 if (so.Status != UFIDA.U9.SM.SO.SODocStatusEnum.Approved) { CreateSOFeeExtend.CreateSOFee(so);//创建费用项目 if (sssessTypeList.Count > 0) { CreateSOAssessTypeExtend.CreateAssessType(sssessTypeList);//创建评估类型子表-大货评估 } } #region 提交、审核、弃审 //提交 if (so.OriginalData.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Open && so.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approving) { //创建特价申请单 if (specilPriceList.Count > 0) { PubHelperExtend.CreateSoOrderSale(specilPriceList); } } //审核 if (so.OriginalData.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approving && so.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approved) { //校验特价申请单是否已审核 SOValidateExtend.ValidateSOSalePriceForApproved(so.ID); //创建调价单 if (adjustPriceList.Count > 0) { PubHelperExtend.CreateAdjustPrice(adjustPriceList); } //销售订单类型为标准订单、预告订单/客户备库、巨星自备、汇总订单时,并且业务类型是普通订单,审核时产生供应计划 if ((so.DocType.Code == "SO1" || so.DocType.Code == "SO2" || so.DocType.Code == "SO3" || so.DocType.Code == "SO4") && so.DescFlexField.PrivateDescSeg2 == "03") { PubHelperExtend.CreateSupplyPlan(so);//创建供应计划 } } //弃审 if (so.OriginalData.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Approved && so.Status == UFIDA.U9.SM.SO.SODocStatusEnum.Open) { SOValidateExtend.ValidateSOSupply(so.DocNo); SOValidateExtend.ValidateSOPrice(so.ID); } #endregion }