/// <summary> /// 确认订舱 /// </summary> /// <param name="bpObj"></param> /// <returns></returns> private int ComSpace(AllocationBillNo bpObj) { if (bpObj.ShipPlanList == null || bpObj.ShipPlanList.Count == 0) { throw new Exception("没有可以订舱的出运明细单"); } ShipPlanDetailHead shipPlan = null; using (ISession session = Session.Open()) { foreach (ShipPlanDetailHead.EntityKey shipPlankey in bpObj.ShipPlanList) { shipPlan = shipPlankey.GetEntity(); if (shipPlan.IsSpace) { throw new Exception("出运明细单" + shipPlan.DocNo + "已订舱"); } if (shipPlan.Status == DocumnetSate.ApprovedSate) { shipPlan.ComSpaceAssessor = UFIDA.U9.Base.Context.LoginUser; shipPlan.ComSpaceDate = DateTime.Now; shipPlan.IsSpace = true; } else { throw new Exception("只有审核状态的出运明细单才可以确认订舱"); } } session.Commit(); } return(1); }
/// <summary> /// 取消订舱 /// </summary> /// <param name="bpObj"></param> /// <returns></returns> private int CancelSpace(AllocationBillNo bpObj) { if (bpObj.ShipPlanList == null || bpObj.ShipPlanList.Count == 0) { throw new Exception("没有可以订舱的出运明细单"); } ShipPlanDetailHead shipPlan = null; using (ISession session = Session.Open()) { foreach (ShipPlanDetailHead.EntityKey shipPlankey in bpObj.ShipPlanList) { shipPlan = shipPlankey.GetEntity(); if (!shipPlan.IsSpace) { throw new Exception("未订舱,无需取消订舱"); } if (shipPlan.IsSpace) { shipPlan.ComSpaceAssessor = ""; shipPlan.ComSpaceDate = DateTime.MinValue; shipPlan.IsSpace = false; } } session.Commit(); } return(1); }
/// <summary> /// 取消明细发票号分配 /// </summary> /// <param name="bpObj"></param> /// <returns></returns> private int CancelAllocationBill(AllocationBillNo bpObj) { using (ISession session = Session.Open()) { foreach (ShipPlanDetailHead.EntityKey head in bpObj.ShipPlanList) { ShipPlanDetailHead shipPlan = head.GetEntity(); if (shipPlan != null) { if (shipPlan.ShipPlanState == AllEnumBE.ShipPlanStateEnum.ShipPlan) { //throw new Exception("出运明细单" + shipPlan.DocNo + "已出运不能取消发票号分配"); } if (shipPlan.ShipPlanState == AllEnumBE.ShipPlanStateEnum.IssuedStorage) { throw new Exception("出运明细单" + shipPlan.DocNo + "已下发仓库不能取消发票号分配"); } foreach (ShipPlanDetailLine line in shipPlan.ShipPlanDetailLine) { if (line.IsShipping) { //throw new Exception("出运明细单" + shipPlan.DocNo + "已预装柜不能取消发票号分配"); } if (line.IsWms) { throw new Exception("出运明细单" + shipPlan.DocNo + "已同步WMS不能取消发票号分配"); } } if (shipPlan.IsSpace) { //throw new Exception("出运明细单" + shipPlan.DocNo + "已订舱不能取消发票号分配"); } if (shipPlan.IsAgvFee) { throw new Exception("出运明细单" + shipPlan.DocNo + "已费用分摊不能取消发票号分配"); } shipPlan.IsAllocation = false; shipPlan.BillNoItemKey = null; } } session.Commit(); } return(1); }
/// <summary> /// 出运明细发票号分配 /// </summary> /// <param name="bpObj"></param> /// <returns></returns> private int AllocationBill(AllocationBillNo bpObj) { ShipPlanDetailHead.EntityList headList = null; if (bpObj.BillNoItemHead.ID <= 0) { //默认加载出运明细单.单据状态=审核中 and 出运明细单.已分配发票号=false的所有出运明细单; headList = ShipPlanDetailHead.Finder.FindAll("Status=1 and IsAllocation=0"); } else { headList = ShipPlanDetailHead.Finder.FindAll("BillNoItem=" + bpObj.BillNoItemHead.ID + ""); } using (ISession session = Session.Open()) { //foreach (ShipPlanDetailHead head in headList) //{ // head.IsAllocation = false; // head.BillNoItemKey = null; //} PackagingTypeEnum parkEnum = null; int count = 0; long currenty = 0, org = 0, saleMan = 0; DateTime shipPlanDate = DateTime.Now; foreach (ShipPlanDetailHead.EntityKey head in bpObj.ShipPlanList) { ShipPlanDetailHead shipPlan = head.GetEntity(); if (count > 0) { if (parkEnum != null && parkEnum != shipPlan.PackagingType) //出运明细单必须是同一种装柜方式; { throw new Exception("出运明细单" + shipPlan.DocNo + "不为同一种装柜方式"); } //不同币种、接单组织、外销员、出运日期的出运明细单不允许分配同一个发票号组; if (shipPlan.Currency != null && currenty != shipPlan.Currency.ID) { throw new Exception("出运明细单" + shipPlan.DocNo + "与其他明细单不为同一种币种"); } if (shipPlan.GetOrderOrg != null && org != shipPlan.GetOrderOrg.ID) { throw new Exception("出运明细单" + shipPlan.DocNo + "与其他明细单不为相同接单组织"); } if (shipPlan.SaleMan != null && saleMan != shipPlan.SaleMan.ID) { throw new Exception("出运明细单" + shipPlan.DocNo + "与其他明细单不为同一个业务员"); } if (shipPlanDate.ToString("yyyy-MM-dd") != shipPlan.ShipPlanDate.ToString("yyyy-MM-dd")) { throw new Exception("出运明细单" + shipPlan.DocNo + "与其他明细单出运日期不同"); } } //判断条件赋值 parkEnum = shipPlan.PackagingType; if (shipPlan.Currency != null) { currenty = shipPlan.Currency.ID; } if (shipPlan.GetOrderOrg != null) { org = shipPlan.GetOrderOrg.ID; } if (shipPlan.SaleMan != null) { saleMan = shipPlan.SaleMan.ID; } shipPlanDate = shipPlan.ShipPlanDate; shipPlan.IsAllocation = true; shipPlan.BillNoItemKey = bpObj.BillNoItemHead; count++; //出运明细单审核 if (shipPlan.Status == AllEnumBE.DocumnetSate.ApprovingState) { shipPlan.Status = AllEnumBE.DocumnetSate.ApprovedSate; shipPlan.AuditDate = DateTime.Now; shipPlan.Assessor = UFIDA.U9.Base.Context.LoginUser; } } //审核出运明细单 // 确认分配后,修改发票号组状态为“已分配”,记录写到BE里面 //BillNoItemHead heand = BillNoItemHead.Finder.FindByID(bpObj.BillNoItemHead.ID); //if(heand != null) // heand.BillNoItemStates = BillNoItemEnum.IsAllot; session.Commit(); } return(1); }