/// <summary> /// 赋值账务信息 /// </summary> /// <param name="context">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息</returns> public S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialRejectBill bill, S_MaterialListRejectBill item) { IBillTypeServer server = ServerModuleFactory.GetServerModule <IBillTypeServer>(); BASE_BillType billType = server.GetBillTypeFromName("采购退货单"); if (billType == null) { throw new Exception("获取不到单据类型信息"); } S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); detailBill.ID = Guid.NewGuid(); detailBill.BillTime = (DateTime)bill.OutDepotDate; detailBill.FillInPersonnel = bill.FillInPersonnel; detailBill.Department = UniversalFunction.GetDeptInfo(context, bill.Department).部门名称; detailBill.FactPrice = -Math.Round(item.UnitPrice * item.Amount, 2); detailBill.FactUnitPrice = item.UnitPrice; detailBill.GoodsID = item.GoodsID; detailBill.BatchNo = item.BatchNo; detailBill.Provider = item.Provider; detailBill.InDepotBillID = bill.Bill_ID; detailBill.InDepotCount = -item.Amount; detailBill.UnitPrice = item.UnitPrice; detailBill.Price = -Math.Round(item.UnitPrice * item.Amount, 2); detailBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.采购退货; detailBill.StorageID = bill.StorageID; detailBill.Remark = "退货原因:" + bill.Reason + " 备注:" + bill.Remark; detailBill.AffrimPersonnel = bill.DepotManager; detailBill.FillInDate = bill.Bill_Time; return(detailBill); }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息</returns> S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext dataContxt, S_HomemadeRejectBill bill, S_HomemadeRejectList item) { S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); detailBill.ID = Guid.NewGuid(); detailBill.BillTime = (DateTime)bill.OutDepotDate; detailBill.FillInPersonnel = bill.FillInPersonnel; detailBill.Department = bill.Department; detailBill.FactPrice = -Math.Round(item.UnitPrice * item.Amount, 2); detailBill.FactUnitPrice = item.UnitPrice; detailBill.GoodsID = item.GoodsID; detailBill.BatchNo = item.BatchNo; detailBill.Provider = item.Provider; detailBill.InDepotBillID = bill.Bill_ID; detailBill.InDepotCount = -item.Amount; detailBill.UnitPrice = item.UnitPrice; detailBill.Price = -Math.Round(item.UnitPrice * item.Amount, 2); detailBill.OperationType = (int)CE_SubsidiaryOperationType.自制件退货; detailBill.StorageID = bill.StorageID; detailBill.Remark = bill.Remark + "(根据自制件退货单自动生成)"; detailBill.AffrimPersonnel = bill.DepotManager; detailBill.FillInDate = bill.Bill_Time; return(detailBill); }
/// <summary> /// 操作账务信息与库存信息_入 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="lnqOutPut">单据信息</param> void OperationDetailAndStock_In(DepotManagementDataContext dataContext, Business_WarehouseInPut_InPut lnqInPut) { string error = ""; IProductCodeServer productCodeService = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IProductCodeServer>(); CE_MarketingType marketingType = GlobalObject.EnumOperation.OutPutBusinessTypeConvertToMarketingType( GlobalObject.GeneralFunction.StringConvertToEnum <CE_OutPutBusinessType>(lnqInPut.BillType)); IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); List <View_Business_WarehouseInPut_InPutDetail> listDetail = GetListViewDetailInfo(lnqInPut.BillNo); foreach (View_Business_WarehouseInPut_InPutDetail detail1 in listDetail) { if (!productCodeService.UpdateProductStock(dataContext, lnqInPut.BillNo, marketingType.ToString(), lnqInPut.StorageID, (lnqInPut.StorageID == "05" && marketingType == CE_MarketingType.入库) ? true : false, detail1.物品ID, out error)) { throw new Exception(error); } S_InDepotDetailBill detailInfo = AssignDetailInfo_In(dataContext, lnqInPut, detail1); S_Stock stockInfo = AssignStockInfo(dataContext, lnqInPut, detail1); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessInDepotDetail(dataContext, detailInfo, stockInfo); } }
/// <summary> /// 根据单据信息操作账务信息与库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> public void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_FrockInDepotBill bill) { MaterialRequisitionGoodsServer goodsService = new MaterialRequisitionGoodsServer(); IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); var result = from r in dataContext.S_FrockInDepotGoodsBill where r.Bill_ID == bill.Bill_ID select r; if (result == null || result.Count() == 0) { throw new Exception("获取单据信息失败"); } foreach (var item in result) { S_InDepotDetailBill detailInfo = AssignDetailInfo(dataContext, bill, item); S_Stock stockInfo = AssignStockInfo(dataContext, bill, item); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessInDepotDetail(dataContext, detailInfo, stockInfo); } }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息</returns> S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext ctx, S_FrockInDepotBill bill, S_FrockInDepotGoodsBill item) { IPersonnelInfoServer serverPersonnelInfo = ServerModuleFactory.GetServerModule <IPersonnelInfoServer>(); View_HR_Personnel lnqPersonnel = UniversalFunction.GetPersonnelInfo(ctx, bill.JJRYID); S_InDepotDetailBill lnqDetailBill = new S_InDepotDetailBill(); View_F_GoodsPlanCost lnqBasicGoodsInfo = UniversalFunction.GetGoodsInfo(ctx, item.GoodsID); lnqDetailBill.ID = Guid.NewGuid(); lnqDetailBill.BillTime = (DateTime)bill.InDepotDate; lnqDetailBill.FillInPersonnel = lnqPersonnel.姓名; lnqDetailBill.Department = lnqPersonnel.部门名称; lnqDetailBill.FactPrice = 0; lnqDetailBill.FactUnitPrice = 0; lnqDetailBill.GoodsID = item.GoodsID; lnqDetailBill.BatchNo = item.BatchNo; lnqDetailBill.InDepotBillID = bill.Bill_ID; lnqDetailBill.InDepotCount = item.Amount; lnqDetailBill.Price = 0; lnqDetailBill.UnitPrice = 0; lnqDetailBill.OperationType = (int)CE_SubsidiaryOperationType.自制件工装入库; lnqDetailBill.Provider = bill.Provider; lnqDetailBill.StorageID = bill.StorageID; lnqDetailBill.AffrimPersonnel = bill.DepotManager; lnqDetailBill.FillInDate = bill.Bill_Time; return(lnqDetailBill); }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <returns>返回账务信息对象</returns> public S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext dataContext, S_CheckOutInDepotBill bill) { View_HR_Personnel personnel = UniversalFunction.GetPersonnelInfo(dataContext, bill.DeclarePersonnelCode); S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); detailBill.ID = Guid.NewGuid(); detailBill.BillTime = (DateTime)bill.InDepotTime; detailBill.FillInPersonnel = bill.DeclarePersonnel; detailBill.Department = personnel.部门名称; detailBill.FactPrice = Math.Round(Convert.ToDecimal(bill.InDepotCount) * bill.UnitPrice, 2); detailBill.FactUnitPrice = bill.UnitPrice; detailBill.GoodsID = bill.GoodsID; detailBill.BatchNo = bill.BatchNo; detailBill.InDepotBillID = bill.Bill_ID; detailBill.InDepotCount = bill.InDepotCount; detailBill.Price = Math.Round(Convert.ToDecimal(bill.InDepotCount) * bill.UnitPrice, 2); detailBill.UnitPrice = bill.UnitPrice; detailBill.OperationType = (int)CE_SubsidiaryOperationType.报检入库; detailBill.Provider = bill.Provider; detailBill.StorageID = bill.StorageID; detailBill.FillInDate = bill.Bill_Time; detailBill.AffrimPersonnel = bill.DepotManager; return(detailBill); }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息</returns> public S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext dataContext, S_OrdinaryInDepotBill bill, S_OrdinaryInDepotGoodsBill item) { IPersonnelInfoServer personnelServer = ServerModuleFactory.GetServerModule <IPersonnelInfoServer>(); S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); View_HR_Personnel personnel = UniversalFunction.GetPersonnelInfo(dataContext, bill.BuyerCode); View_F_GoodsPlanCost basicGoodsInfo = UniversalFunction.GetGoodsInfo(dataContext, item.GoodsID); detailBill.ID = Guid.NewGuid(); detailBill.BillTime = (DateTime)bill.InDepotDate; detailBill.FillInPersonnel = personnel.姓名; detailBill.Department = personnel.部门名称; detailBill.FactPrice = Math.Round((item.UnitPrice * (decimal)item.Amount), 2); detailBill.FactUnitPrice = item.UnitPrice; detailBill.GoodsID = item.GoodsID; detailBill.BatchNo = item.BatchNo; detailBill.InDepotBillID = bill.Bill_ID; detailBill.InDepotCount = item.Amount; detailBill.Price = Math.Round((item.UnitPrice * (decimal)item.Amount), 2); detailBill.UnitPrice = item.UnitPrice; detailBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.普通入库; detailBill.Provider = bill.Provider; detailBill.StorageID = bill.StorageID; detailBill.AffrimPersonnel = UniversalFunction.GetPersonnelInfo(bill.DepotManager).姓名; detailBill.FillInDate = bill.Bill_Time; return(detailBill); }
/// <summary> /// 插入提交入库明细表 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="detailInfo">明细信息</param> void InsertOnSubmitInDepotDetailBill(DepotManagementDataContext ctx, S_InDepotDetailBill detailInfo) { if (detailInfo == null) { return; } if (GlobalObject.GeneralFunction.IsNullOrEmpty(detailInfo.InDepotBillID)) { throw new Exception("【单据号】获取失败,请重新再试"); } ctx.S_InDepotDetailBill.InsertOnSubmit(detailInfo); }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="outSourcing">单据信息</param> /// <returns>返回账务信息</returns> S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext ctx, S_CheckOutInDepotForOutsourcingBill outSourcing) { S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); var varData = from a in ctx.S_InDepotDetailBill where a.InDepotBillID == outSourcing.Bill_ID select a; if (varData.Count() != 0) { throw new Exception("数据不唯一"); } else { IBillTypeServer server = ServerModuleFactory.GetServerModule <IBillTypeServer>(); BASE_BillType billType = server.GetBillTypeFromName("委外报检入库单"); if (billType == null) { throw new Exception("获取不到单据类型信息"); } detailBill.ID = Guid.NewGuid(); detailBill.BillTime = ServerTime.Time; detailBill.FillInPersonnel = outSourcing.DeclarePersonnel; detailBill.Department = UniversalFunction.GetPersonnelInfo(ctx, outSourcing.DeclarePersonnel).部门名称; detailBill.FactPrice = Math.Round(outSourcing.UnitPrice * outSourcing.InDepotCount, 2); detailBill.FactUnitPrice = outSourcing.UnitPrice; detailBill.GoodsID = outSourcing.GoodsID; detailBill.BatchNo = outSourcing.BatchNo; detailBill.InDepotBillID = outSourcing.Bill_ID; detailBill.InDepotCount = outSourcing.InDepotCount; detailBill.Price = Math.Round(outSourcing.UnitPrice * outSourcing.InDepotCount, 2); detailBill.UnitPrice = outSourcing.UnitPrice; detailBill.OperationType = (int)CE_SubsidiaryOperationType.委外报检入库; detailBill.Provider = outSourcing.Provider; detailBill.StorageID = outSourcing.StorageID; detailBill.AffrimPersonnel = outSourcing.ManagerPersonnel; detailBill.FillInDate = outSourcing.DeclareTime; } return(detailBill); }
/// <summary> /// 根据单据信息操作账务信息与库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> public void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_HomemadePartBill bill) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); S_InDepotDetailBill detailInfo = AssignDetailInfo(dataContext, bill); S_Stock stockInfo = AssignStockInfo(dataContext, bill); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } if (bill.DeclareCount < bill.InDepotCount) { throw new Exception("入库数不能大于报检数"); } serverDetail.ProcessInDepotDetail(dataContext, detailInfo, stockInfo); }
/// <summary> /// 赋值账务信息_入 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="lnqOutPut">单据信息</param> /// <param name="detail1">明细信息</param> /// <returns>返回账务信息对象</returns> S_InDepotDetailBill AssignDetailInfo_In(DepotManagementDataContext ctx, Business_WarehouseOutPut_OutPut lnqOutPut, View_Business_WarehouseOutPut_OutPutDetail detail1) { IFlowServer serverFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); CommonProcessInfo processInfo = new CommonProcessInfo(); CE_OutPutBusinessType OutPutType = GlobalObject.GeneralFunction.StringConvertToEnum <CE_OutPutBusinessType>(lnqOutPut.BillType); S_InDepotDetailBill inDepotDetail = new S_InDepotDetailBill(); inDepotDetail.AffrimPersonnel = BasicInfo.LoginName; inDepotDetail.BatchNo = detail1.批次号; inDepotDetail.BillTime = ServerTime.Time; inDepotDetail.Department = UniversalFunction.GetDeptName(lnqOutPut.ApplyingDepartment); inDepotDetail.Depot = UniversalFunction.GetGoodsInfo(detail1.物品ID).物品类别名称; inDepotDetail.FactPrice = 0; //Math.Round(detail1.单价 * detail1.数量, 2); inDepotDetail.FactUnitPrice = 0; //detail1.单价; inDepotDetail.Price = inDepotDetail.FactPrice; inDepotDetail.UnitPrice = inDepotDetail.FactUnitPrice; inDepotDetail.InvoicePrice = null; inDepotDetail.InvoiceUnitPrice = null; processInfo = serverFlow.GetFlowData(detail1.关联业务).First(); inDepotDetail.FillInDate = Convert.ToDateTime(processInfo.时间); inDepotDetail.FillInPersonnel = processInfo.人员; inDepotDetail.InDepotBillID = lnqOutPut.BillNo; inDepotDetail.InDepotCount = -detail1.数量; inDepotDetail.GoodsID = detail1.物品ID; inDepotDetail.OperationType = (int)GlobalObject.EnumOperation.OutPutBusinessTypeConvertToSubsidiaryOperationType(OutPutType); inDepotDetail.Provider = detail1.供应商; inDepotDetail.Remark = detail1.备注; inDepotDetail.StorageID = lnqOutPut.StorageID; return(inDepotDetail); }
/// <summary> /// 根据单据信息操作账务信息与库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_HomemadeRejectBill bill) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); var result = from r in dataContext.S_HomemadeRejectList where r.Bill_ID == bill.Bill_ID select r; foreach (var item in result) { S_InDepotDetailBill detailInfo = AssignDetailInfo(dataContext, bill, item); S_Stock stockInfo = AssignStockInfo(dataContext, bill, item); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessInDepotDetail(dataContext, detailInfo, stockInfo); } }
/// <summary> /// 工具入库业务的处理 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="indepotDetailInfo">入库业务对象</param> void InDepotToolsInfo(DepotManagementDataContext ctx, S_InDepotDetailBill indepotDetailInfo) { if (indepotDetailInfo == null) { return; } IToolsManage serverTools = ServerModule.ServerModuleFactory.GetServerModule <IToolsManage>(); if (serverTools.IsTools(indepotDetailInfo.GoodsID)) { S_MachineAccount_Tools toolsInfo = new S_MachineAccount_Tools(); toolsInfo.GoodsID = indepotDetailInfo.GoodsID; toolsInfo.Provider = indepotDetailInfo.Provider; toolsInfo.StockCount = (decimal)indepotDetailInfo.InDepotCount; toolsInfo.StorageCode = indepotDetailInfo.StorageID; serverTools.OpertionInfo(ctx, toolsInfo); serverTools.DayToDayAccount(ctx, toolsInfo, indepotDetailInfo.InDepotBillID); } }
/// <summary> /// 车间入库业务的处理 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="indepotDetailInfo">入库业务对象</param> void InDepotWorkShop(DepotManagementDataContext ctx, S_InDepotDetailBill indepotDetailInfo) { if (indepotDetailInfo == null) { return; } Service_Manufacture_WorkShop.IWorkShopBasic serverWSBasic = Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopBasic>(); WS_WorkShopCode tempWSCode = serverWSBasic.GetPersonnelWorkShop(ctx, indepotDetailInfo.FillInPersonnel); if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启车间管理模块]) && tempWSCode != null) { WS_Subsidiary tempSubsidiary = new WS_Subsidiary(); tempSubsidiary.BillTime = ServerTime.Time; tempSubsidiary.Applicant = UniversalFunction.GetStorageName(ctx, indepotDetailInfo.StorageID); tempSubsidiary.Affirm = indepotDetailInfo.AffrimPersonnel; tempSubsidiary.AffirmDate = ServerTime.Time; tempSubsidiary.BatchNo = indepotDetailInfo.BatchNo; tempSubsidiary.BillNo = indepotDetailInfo.InDepotBillID; tempSubsidiary.GoodsID = indepotDetailInfo.GoodsID; tempSubsidiary.Provider = indepotDetailInfo.Provider; tempSubsidiary.OperationCount = (decimal)indepotDetailInfo.InDepotCount < 0 ? -(decimal)indepotDetailInfo.InDepotCount : (decimal)indepotDetailInfo.InDepotCount; tempSubsidiary.OperationType = indepotDetailInfo.OperationType; tempSubsidiary.Proposer = indepotDetailInfo.FillInPersonnel; tempSubsidiary.ProposerDate = indepotDetailInfo.FillInDate == null ? ServerTime.Time : Convert.ToDateTime(indepotDetailInfo.FillInDate); tempSubsidiary.UnitPrice = indepotDetailInfo.FactUnitPrice; tempSubsidiary.WSCode = tempWSCode.WSCode; tempSubsidiary.Remark = indepotDetailInfo.Remark; Service_Manufacture_WorkShop.IWorkShopStock serverWSStock = Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopStock>(); serverWSStock.OperationSubsidiary(ctx, tempSubsidiary); } }
/// <summary> /// 更新出入库的金额 /// </summary> /// <param name="invoiceTable">需要更新的数据集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>更新成功True,更新失败False</returns> public bool UpdatePrice(DataTable invoiceTable, out string error) { error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; OrdinaryInDepotBillServer serverOrdinaryBill = new OrdinaryInDepotBillServer(); MaterialRejectBill serverMaterialRejectBill = new MaterialRejectBill(); DateTime dtStart = new DateTime(); DateTime dtEnd = new DateTime(); //获得当前日期的月结起始日期与结束日期 ServerTime.GetMonthlyBalance(ServerTime.Time, out dtStart, out dtEnd); for (int i = 0; i <= invoiceTable.Rows.Count - 1; i++) { string code = invoiceTable.Rows[i]["GoodsCode"].ToString(); string name = invoiceTable.Rows[i]["GoodsName"].ToString(); string spec = invoiceTable.Rows[i]["Spec"].ToString(); View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(code, name, spec, out error); if (!GlobalObject.GeneralFunction.IsNullOrEmpty(error)) { return(false); } #region 改变入库表的单价(普通入库或者报检入库) var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == basicGoods.序号 && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; //报检入库单单价修改 if (varCheckOutInDepot.Count() != 0) { S_CheckOutInDepotBill lnqCheckOutInDepotBill = varCheckOutInDepot.Single(); lnqCheckOutInDepotBill.UnitInvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqCheckOutInDepotBill.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqCheckOutInDepotBill.HavingInvoice = true; dataContxt.SubmitChanges(); } else { int intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(), invoiceTable.Rows[i]["GoodsName"].ToString(), invoiceTable.Rows[i]["Spec"].ToString()); var varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == intGoodsID && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; //普通入库单单价修改 if (varOrdinaryGoods.Count() != 0) { S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single(); lnqOrdinaryGoods.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqOrdinaryGoods.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqOrdinaryGoods.HavingInvoice = true; dataContxt.SubmitChanges(); int intFlag = serverOrdinaryBill.GetHavingInvoice(invoiceTable.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() select a; if (varOrdinaryBill.Count() != 0) { S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single(); lnqOrdinaryBill.InvoiceStatus = intFlag; dataContxt.SubmitChanges(); } } }//采购退货单单价修改 else { intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(), invoiceTable.Rows[i]["GoodsName"].ToString(), invoiceTable.Rows[i]["Spec"].ToString()); var varRejectList = from a in dataContxt.S_MaterialListRejectBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == intGoodsID && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; if (varRejectList.Count() != 0) { S_MaterialListRejectBill lnqMaterialList = varRejectList.Single(); lnqMaterialList.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqMaterialList.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqMaterialList.HavingInvoice = true; dataContxt.SubmitChanges(); int intFlag = serverMaterialRejectBill.SetHavingInvoiceReturn(invoiceTable.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varReject = from a in dataContxt.S_MaterialRejectBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() select a; if (varReject.Count() != 0) { S_MaterialRejectBill lnqMaterialBill = varReject.Single(); lnqMaterialBill.InvoiceFlag = intFlag; dataContxt.SubmitChanges(); } } } else { intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(), invoiceTable.Rows[i]["GoodsName"].ToString(), invoiceTable.Rows[i]["Spec"].ToString()); var varOutsourcing = from a in dataContxt.S_CheckOutInDepotForOutsourcingBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == intGoodsID && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; //委外报检入库单单价修改 if (varOutsourcing.Count() != 0) { S_CheckOutInDepotForOutsourcingBill lnqOutsourcing = varOutsourcing.Single(); lnqOutsourcing.UnitInvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqOutsourcing.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqOutsourcing.HavingInvoice = true; dataContxt.SubmitChanges(); } } } } #endregion #region 改变入库明细表金额 var varInDepotBill = from b in dataContxt.S_InDepotDetailBill where b.GoodsID == basicGoods.序号 && b.InDepotBillID == invoiceTable.Rows[i]["Bill_ID"].ToString() && b.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select b; if (varInDepotBill.Count() == 1) { S_InDepotDetailBill lnqInDepotBill = varInDepotBill.Single(); lnqInDepotBill.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqInDepotBill.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); if (lnqInDepotBill.FactPrice != Convert.ToDecimal(invoiceTable.Rows[i]["Price"])) { //当查询的记录不在当月的结算日期范围内,插入红冲单据与对冲单据 if (lnqInDepotBill.BillTime < dtStart || lnqInDepotBill.BillTime > dtEnd) { var varDetail = from d in dataContxt.S_InDepotDetailBill where d.GoodsID == basicGoods.序号 && d.InDepotBillID.Contains(invoiceTable.Rows[i]["Bill_ID"].ToString()) && d.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() && d.BillTime >= dtStart && d.BillTime <= dtEnd select d; //判断是否已经在当前结算日期范围内插入了红冲与对冲数据 if (varDetail.Count() != 0) { foreach (var item in varDetail) { //针对已经插入的对冲数据进行修改 if (item.InDepotBillID.Contains("(对冲单据)")) { item.FactPrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); item.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); } } }//对没有插入的红冲与对冲的记录进行插入 else { //插一条原始的负记录(红冲单据) S_InDepotDetailBill lnqOldInDepotBill = new S_InDepotDetailBill(); lnqOldInDepotBill.ID = Guid.NewGuid(); lnqOldInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(红冲单据)"; lnqOldInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqOldInDepotBill.BillTime = ServerTime.Time; lnqOldInDepotBill.Department = lnqInDepotBill.Department; lnqOldInDepotBill.FactUnitPrice = lnqInDepotBill.FactUnitPrice; lnqOldInDepotBill.FactPrice = -lnqInDepotBill.FactPrice; lnqOldInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqOldInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqOldInDepotBill.InDepotCount = -lnqInDepotBill.InDepotCount; lnqOldInDepotBill.Price = -lnqInDepotBill.Price; lnqOldInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务红冲; lnqOldInDepotBill.Provider = lnqInDepotBill.Provider; lnqOldInDepotBill.Remark = lnqInDepotBill.Remark; lnqOldInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqOldInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqOldInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqOldInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); serverDetail.ProcessInDepotDetail(dataContxt, lnqOldInDepotBill, null); //插一条新的正记录(对冲单据) S_InDepotDetailBill lnqNewInDepotBill = new S_InDepotDetailBill(); lnqNewInDepotBill.ID = Guid.NewGuid(); lnqNewInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(对冲单据)"; lnqNewInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqNewInDepotBill.BillTime = ServerTime.Time; lnqNewInDepotBill.Department = lnqInDepotBill.Department; lnqNewInDepotBill.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqNewInDepotBill.FactPrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqNewInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqNewInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqNewInDepotBill.InDepotCount = lnqInDepotBill.InDepotCount; lnqNewInDepotBill.Price = lnqInDepotBill.Price; lnqNewInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务对冲; lnqNewInDepotBill.Provider = lnqInDepotBill.Provider; lnqNewInDepotBill.Remark = lnqInDepotBill.Remark; lnqNewInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqNewInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqNewInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqNewInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; serverDetail.ProcessInDepotDetail(dataContxt, lnqNewInDepotBill, null); } } else { lnqInDepotBill.FactPrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqInDepotBill.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); } } dataContxt.SubmitChanges(); } #endregion } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 删除发票记录 /// </summary> /// <param name="invoiceCode">发票号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>删除成功返回True,删除失败返回False</returns> public bool DeleteInvoiceInfo(string invoiceCode, out string error) { error = null; string str = "0"; int count = 0; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; OrdinaryInDepotBillServer serverOrdinaryBill = new OrdinaryInDepotBillServer(); MaterialRejectBill serverMaterialRejectBill = new MaterialRejectBill(); string strSql = "select * from B_Invoice where InvoiceCode = '" + invoiceCode + "'"; DataTable dtInvoice = GlobalObject.DatabaseServer.QueryInfo(strSql); for (int i = 0; i <= dtInvoice.Rows.Count - 1; i++) { count = i; decimal dcOldUnitPrice = 0; if (!GlobalObject.GeneralFunction.IsNullOrEmpty(error)) { return(false); } str = "1"; #region 改变入库表的单价(普通入库或者报检入库) var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varCheckOutInDepot.Count() != 0) { S_CheckOutInDepotBill lnqCheckOutInDepot = varCheckOutInDepot.Single(); lnqCheckOutInDepot.UnitInvoicePrice = 0; lnqCheckOutInDepot.InvoicePrice = 0; lnqCheckOutInDepot.HavingInvoice = false; dcOldUnitPrice = lnqCheckOutInDepot.UnitPrice; dataContxt.SubmitChanges(); } else { var varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varOrdinaryGoods.Count() != 0) { S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single(); lnqOrdinaryGoods.InvoiceUnitPrice = 0; lnqOrdinaryGoods.InvoicePrice = 0; lnqOrdinaryGoods.HavingInvoice = false; dcOldUnitPrice = lnqOrdinaryGoods.UnitPrice; dataContxt.SubmitChanges(); int intFlag = serverOrdinaryBill.GetHavingInvoice(dtInvoice.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() select a; if (varOrdinaryBill.Count() != 0) { S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single(); lnqOrdinaryBill.InvoiceStatus = intFlag; dataContxt.SubmitChanges(); } } } else { var varRejectList = from a in dataContxt.S_MaterialListRejectBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varRejectList.Count() != 0) { S_MaterialListRejectBill lnqMaterialList = varRejectList.Single(); lnqMaterialList.InvoiceUnitPrice = 0; lnqMaterialList.InvoicePrice = 0; lnqMaterialList.HavingInvoice = false; dcOldUnitPrice = lnqMaterialList.UnitPrice; dataContxt.SubmitChanges(); int intFlag = serverMaterialRejectBill.SetHavingInvoiceReturn(dtInvoice.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varRejectBill = from a in dataContxt.S_MaterialRejectBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() select a; if (varRejectBill.Count() != 0) { S_MaterialRejectBill lnqMaterialBill = varRejectBill.Single(); lnqMaterialBill.InvoiceFlag = intFlag; dataContxt.SubmitChanges(); } } } else { var varOutsourcing = from a in dataContxt.S_CheckOutInDepotForOutsourcingBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varOutsourcing.Count() != 0) { S_CheckOutInDepotForOutsourcingBill lnqOutsourcing = varOutsourcing.Single(); lnqOutsourcing.UnitInvoicePrice = 0; lnqOutsourcing.InvoicePrice = 0; lnqOutsourcing.HavingInvoice = false; dcOldUnitPrice = lnqOutsourcing.UnitPrice; dataContxt.SubmitChanges(); } } } } #endregion str = "2"; #region 改变入库明细表金额 var varInDepotDetail = from b in dataContxt.S_InDepotDetailBill where b.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && b.InDepotBillID.Contains(dtInvoice.Rows[i]["Bill_ID"].ToString()) && b.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select b; if (varInDepotDetail.Count() != 0) { if (varInDepotDetail.Count() == 1) { S_InDepotDetailBill lnqInDepotDetailSingle = varInDepotDetail.Single(); lnqInDepotDetailSingle.InvoiceUnitPrice = 0; lnqInDepotDetailSingle.InvoicePrice = 0; lnqInDepotDetailSingle.FactUnitPrice = dcOldUnitPrice; lnqInDepotDetailSingle.FactPrice = Math.Round(dcOldUnitPrice * Convert.ToDecimal(lnqInDepotDetailSingle.InDepotCount), 2); } else { var varInDepotDetailList = from a in varInDepotDetail where a.InDepotBillID == dtInvoice.Rows[i]["Bill_ID"].ToString() select a; S_InDepotDetailBill lnqInDepotDetailData = varInDepotDetailList.Single(); lnqInDepotDetailData.InvoiceUnitPrice = 0; lnqInDepotDetailData.InvoicePrice = 0; lnqInDepotDetailData.FactUnitPrice = dcOldUnitPrice; lnqInDepotDetailData.FactPrice = Math.Round(dcOldUnitPrice * Convert.ToDecimal(lnqInDepotDetailData.InDepotCount), 2); var varData7 = from a in varInDepotDetail where a.InDepotBillID != dtInvoice.Rows[i]["Bill_ID"].ToString() select a; dataContxt.S_InDepotDetailBill.DeleteAllOnSubmit(varData7); } dataContxt.SubmitChanges(); } #endregion } var varInvoice = from a in dataContxt.B_Invoice where a.InvoiceCode == invoiceCode select a; if (varInvoice.Count() > 0) { dataContxt.B_Invoice.DeleteAllOnSubmit(varInvoice); dataContxt.SubmitChanges(); } return(true); } catch (Exception ex) { error = ex.Message + str + count.ToString(); return(false); } }
/// <summary> /// 处理入库明细业务信息 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="indepotDetailInfo">入库明细信息</param> /// <param name="stockInfo">库存信息</param> public void ProcessInDepotDetail(DepotManagementDataContext ctx, S_InDepotDetailBill indepotDetailInfo, S_Stock stockInfo) { try { CE_SubsidiaryOperationType operationType = (CE_SubsidiaryOperationType)Enum.ToObject(typeof(CE_SubsidiaryOperationType), indepotDetailInfo.OperationType); IStoreServer storeService = ServerModule.ServerModuleFactory.GetServerModule <IStoreServer>(); switch (operationType) { case CE_SubsidiaryOperationType.报检入库: case CE_SubsidiaryOperationType.委外报检入库: InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo); InDepotToolsInfo(ctx, indepotDetailInfo); InDepotGuagesInfo(ctx, indepotDetailInfo); storeService.InStore(ctx, stockInfo, operationType); break; case CE_SubsidiaryOperationType.采购退货: InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo); InDepotToolsInfo(ctx, indepotDetailInfo); FetchGaugeInfo(ctx, indepotDetailInfo); storeService.OutStore(ctx, stockInfo, operationType); break; case CE_SubsidiaryOperationType.普通入库: InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo); InDepotToolsInfo(ctx, indepotDetailInfo); InDepotGuagesInfo(ctx, indepotDetailInfo); storeService.InStore(ctx, stockInfo, operationType); storeService.UpdateAging(ctx, stockInfo, false); break; case CE_SubsidiaryOperationType.营销入库: case CE_SubsidiaryOperationType.自制件入库: case CE_SubsidiaryOperationType.自制件工装入库: InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo); InDepotToolsInfo(ctx, indepotDetailInfo); InDepotGuagesInfo(ctx, indepotDetailInfo); InDepotWorkShop(ctx, indepotDetailInfo); storeService.InStore(ctx, stockInfo, operationType); break; case CE_SubsidiaryOperationType.营销退货: case CE_SubsidiaryOperationType.自制件退货: InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo); InDepotToolsInfo(ctx, indepotDetailInfo); FetchGaugeInfo(ctx, indepotDetailInfo); InDepotWorkShop(ctx, indepotDetailInfo); storeService.OutStore(ctx, stockInfo, operationType); break; case CE_SubsidiaryOperationType.财务对冲: case CE_SubsidiaryOperationType.财务红冲: InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo); break; default: break; } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 变更金额_入库明细 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="detailInfo">结算单明细</param> void ChangePrice_S_InDepotDetailBill(DepotManagementDataContext dataContxt, View_Business_Settlement_ProcurementStatementDetail detailInfo) { DateTime dtStart = new DateTime(); DateTime dtEnd = new DateTime(); Business_Settlement_ProcurementStatement statement = GetSingleBillInfo(detailInfo.单据号); //获得当前日期的月结起始日期与结束日期 ServerTime.GetMonthlyBalance(ServerTime.Time, out dtStart, out dtEnd); var varInDepotBill = from b in dataContxt.S_InDepotDetailBill where b.GoodsID == detailInfo.物品ID && b.InDepotBillID == detailInfo.入库单号 && b.BatchNo == detailInfo.批次号 select b; if (varInDepotBill.Count() == 1) { S_InDepotDetailBill lnqInDepotBill = varInDepotBill.Single(); var varData1 = from a in dataContxt.BASE_Storage where a.StorageID == lnqInDepotBill.StorageID select a; if (varData1.Count() == 1) { BASE_Storage storageInfo = varData1.Single(); if (!storageInfo.FinancialAccountingFlag) { throw new Exception("单据号【" + lnqInDepotBill.InDepotBillID + "】的入库库房不在财务核算范围之内"); } } else { throw new Exception("单据号【" + lnqInDepotBill.InDepotBillID + "】的入库库房不存在或者重复"); } if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { lnqInDepotBill.InvoiceUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; lnqInDepotBill.InvoicePrice = Math.Round((decimal)lnqInDepotBill.InvoiceUnitPrice * (decimal)lnqInDepotBill.InDepotCount, 2); } else { lnqInDepotBill.InvoiceUnitPrice = detailInfo.发票单价; lnqInDepotBill.InvoicePrice = detailInfo.发票金额; } if (lnqInDepotBill.FactPrice != detailInfo.发票金额) { //当查询的记录不在当月的结算日期范围内,插入红冲单据与对冲单据 if (lnqInDepotBill.BillTime < dtStart || lnqInDepotBill.BillTime > dtEnd) { var varDetail = from d in dataContxt.S_InDepotDetailBill where d.GoodsID == detailInfo.物品ID && d.InDepotBillID.Contains(detailInfo.入库单号) && d.BatchNo == detailInfo.批次号 && d.BillTime >= dtStart && d.BillTime <= dtEnd select d; //判断是否已经在当前结算日期范围内插入了红冲与对冲数据 if (varDetail.Count() != 0) { foreach (var item in varDetail) { //针对已经插入的对冲数据进行修改 if (item.InDepotBillID.Contains("(对冲单据)")) { if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { item.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; item.FactPrice = Math.Round((decimal)item.FactUnitPrice * (decimal)item.InDepotCount, 2); } else { item.FactUnitPrice = detailInfo.发票单价; item.FactPrice = detailInfo.发票金额; } } } }//对没有插入的红冲与对冲的记录进行插入 else { //插一条原始的负记录(红冲单据) S_InDepotDetailBill lnqOldInDepotBill = new S_InDepotDetailBill(); lnqOldInDepotBill.ID = Guid.NewGuid(); lnqOldInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(红冲单据)"; lnqOldInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqOldInDepotBill.BillTime = ServerTime.Time; lnqOldInDepotBill.Department = lnqInDepotBill.Department; lnqOldInDepotBill.FactUnitPrice = lnqInDepotBill.FactUnitPrice; lnqOldInDepotBill.FactPrice = -lnqInDepotBill.FactPrice; lnqOldInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqOldInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqOldInDepotBill.InDepotCount = -lnqInDepotBill.InDepotCount; lnqOldInDepotBill.Price = -lnqInDepotBill.Price; lnqOldInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务红冲; lnqOldInDepotBill.Provider = lnqInDepotBill.Provider; lnqOldInDepotBill.Remark = lnqInDepotBill.Remark; lnqOldInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqOldInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqOldInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqOldInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); serverDetail.ProcessInDepotDetail(dataContxt, lnqOldInDepotBill, null); //插一条新的正记录(对冲单据) S_InDepotDetailBill lnqNewInDepotBill = new S_InDepotDetailBill(); lnqNewInDepotBill.ID = Guid.NewGuid(); lnqNewInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(对冲单据)"; lnqNewInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqNewInDepotBill.BillTime = ServerTime.Time; lnqNewInDepotBill.Department = lnqInDepotBill.Department; lnqNewInDepotBill.InDepotCount = lnqInDepotBill.InDepotCount; if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { lnqNewInDepotBill.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; lnqNewInDepotBill.FactPrice = Math.Round((decimal)lnqNewInDepotBill.FactUnitPrice * (decimal)lnqNewInDepotBill.InDepotCount, 2); } else { lnqNewInDepotBill.FactUnitPrice = detailInfo.发票单价; lnqNewInDepotBill.FactPrice = detailInfo.发票金额; } lnqNewInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqNewInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqNewInDepotBill.Price = lnqInDepotBill.Price; lnqNewInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务对冲; lnqNewInDepotBill.Provider = lnqInDepotBill.Provider; lnqNewInDepotBill.Remark = lnqInDepotBill.Remark; lnqNewInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqNewInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqNewInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqNewInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; serverDetail.ProcessInDepotDetail(dataContxt, lnqNewInDepotBill, null); } } else { if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { lnqInDepotBill.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; lnqInDepotBill.FactPrice = Math.Round((decimal)lnqInDepotBill.InvoiceUnitPrice * (decimal)lnqInDepotBill.InDepotCount, 2); } else { lnqInDepotBill.FactUnitPrice = detailInfo.发票单价; lnqInDepotBill.FactPrice = detailInfo.发票金额; } } } dataContxt.SubmitChanges(); } }
/// <summary> /// 操作流程以外的业务 /// </summary> /// <param name="billNo">单据号</param> public void OperatarUnFlowBusiness(string billNo) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); string billStatus = serviceFlow.GetNextBillStatus(billNo); if (billStatus == null) { throw new Exception("单据状态为空,请重新确认"); } if (billStatus != CE_CommonBillStatus.单据完成.ToString()) { return; } DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; dataContxt.Connection.Open(); dataContxt.Transaction = dataContxt.Connection.BeginTransaction(); try { List <View_Bus_PurchasingMG_AccountBill_Detail> lstDetail = GetListViewDetailInfo(billNo); Bus_PurchasingMG_AccountBill billInfo = GetSingleBillInfo(billNo); foreach (View_Bus_PurchasingMG_AccountBill_Detail detailInfo in lstDetail) { //插一条原始的负记录(红冲单据) S_InDepotDetailBill lnqRedInDepotBill = new S_InDepotDetailBill(); lnqRedInDepotBill.ID = Guid.NewGuid(); lnqRedInDepotBill.InDepotBillID = detailInfo.单据号 + "(红冲单据)"; lnqRedInDepotBill.BatchNo = detailInfo.挂账年月; lnqRedInDepotBill.BillTime = (DateTime)billInfo.FinanceTime; lnqRedInDepotBill.Department = ""; lnqRedInDepotBill.FactUnitPrice = Math.Round((decimal)detailInfo.协议单价 / (1 + (decimal)detailInfo.税率 / 100), 6); lnqRedInDepotBill.FactPrice = -Math.Round(lnqRedInDepotBill.FactUnitPrice * (decimal)detailInfo.实付数量, 2); lnqRedInDepotBill.InDepotCount = -detailInfo.实付数量; lnqRedInDepotBill.FillInPersonnel = BasicInfo.LoginID; lnqRedInDepotBill.GoodsID = (int)detailInfo.GoodsID; lnqRedInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务红冲; lnqRedInDepotBill.Provider = billInfo.Provider; lnqRedInDepotBill.Remark = billInfo.Remark + " " + detailInfo.备注; lnqRedInDepotBill.StorageID = "00"; lnqRedInDepotBill.UnitPrice = lnqRedInDepotBill.FactUnitPrice; lnqRedInDepotBill.Price = lnqRedInDepotBill.FactPrice; lnqRedInDepotBill.FillInDate = ServerTime.Time; lnqRedInDepotBill.AffrimPersonnel = BasicInfo.LoginID; serverDetail.ProcessInDepotDetail(dataContxt, lnqRedInDepotBill, null); //插一条新的正记录(对冲单据) S_InDepotDetailBill lnqHedgeInDepotBill = new S_InDepotDetailBill(); lnqHedgeInDepotBill.ID = Guid.NewGuid(); lnqHedgeInDepotBill.InDepotBillID = detailInfo.单据号 + "(对冲单据)"; lnqHedgeInDepotBill.BatchNo = detailInfo.挂账年月; lnqHedgeInDepotBill.BillTime = (DateTime)billInfo.FinanceTime; lnqHedgeInDepotBill.Department = ""; lnqHedgeInDepotBill.FactUnitPrice = (decimal)detailInfo.发票金额 / (decimal)detailInfo.实付数量; lnqHedgeInDepotBill.FactPrice = (decimal)detailInfo.发票金额; lnqHedgeInDepotBill.InDepotCount = detailInfo.实付数量; lnqHedgeInDepotBill.FillInPersonnel = BasicInfo.LoginID; lnqHedgeInDepotBill.GoodsID = (int)detailInfo.GoodsID; lnqHedgeInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务对冲; lnqHedgeInDepotBill.Provider = billInfo.Provider; lnqHedgeInDepotBill.Remark = billInfo.Remark + " " + detailInfo.备注; lnqHedgeInDepotBill.StorageID = "00"; lnqHedgeInDepotBill.UnitPrice = lnqHedgeInDepotBill.FactUnitPrice; lnqHedgeInDepotBill.Price = lnqHedgeInDepotBill.FactPrice; lnqHedgeInDepotBill.FillInDate = ServerTime.Time; lnqHedgeInDepotBill.AffrimPersonnel = BasicInfo.LoginID; serverDetail.ProcessInDepotDetail(dataContxt, lnqHedgeInDepotBill, null); var varAccountInfo = from a in dataContxt.Bus_PurchasingMG_Account where a.Provider == billInfo.Provider && a.YearMonth == detailInfo.挂账年月 && a.GoodsID == Convert.ToInt32(detailInfo.GoodsID) select a; if (varAccountInfo.Count() != 1) { throw new Exception("找不到对应的【挂账单】"); } varAccountInfo.Single().InvoiceCount += (decimal)detailInfo.实付数量; varAccountInfo.Single().InvoicePrice += (decimal)detailInfo.发票金额; dataContxt.SubmitChanges(); } dataContxt.Transaction.Commit(); } catch (Exception ex) { dataContxt.Transaction.Rollback(); throw new Exception(ex.Message); } }