/// <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="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> public void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_ScrapBill bill) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); var result = from r in dataContext.S_ScrapGoods where r.Bill_ID == bill.Bill_ID select r; if (result == null || result.Count() == 0) { throw new Exception("获取单据信息失败"); } foreach (var item in result) { S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, bill, item); if (detailInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, null); } }
/// <summary> /// 操作账务信息与库存信息_出 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="lnqOutPut">单据信息</param> void OperationDetailAndStock_Out(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_FetchGoodsDetailBill detailInfo = AssignDetailInfo_Out(dataContext, lnqInPut, detail1); S_Stock stockInfo = AssignStockInfo(dataContext, lnqInPut, detail1); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, stockInfo); } }
/// <summary> /// 根据单据信息操作账务信息与库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> public void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_MaterialReturnedInTheDepot bill) { MaterialListReturnedInTheDepot listService = new MaterialListReturnedInTheDepot(); IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); var result = from r in dataContext.S_MaterialListReturnedInTheDepot where r.Bill_ID == bill.Bill_ID select r; if (result == null || result.Count() == 0) { throw new Exception("获取单据信息失败"); } foreach (var item in result) { S_FetchGoodsDetailBill detailInfo = listService.AssignDetailInfo(dataContext, bill, item); S_Stock stockInfo = listService.AssignStockInfo(dataContext, bill, item); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, stockInfo); } IStoreServer serviceStore = ServerModuleFactory.GetServerModule <IStoreServer>(); serviceStore.Operation_MES_InProduction(dataContext, bill.Bill_ID); }
/// <summary> /// 根据单据信息操作账务信息与库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="dataTable">明细信息集合</param> void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_ProductLendBill bill, DataTable dataTable) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); foreach (DataRow dr in dataTable.Rows) { S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, bill, dr); if (detailInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, null); } }
/// <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="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="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="operationType">操作类型</param> void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_CannibalizeBill bill, CE_SubsidiaryOperationType operationType) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); var result = from r in dataContext.S_CannibalizeList where r.DJ_ID == bill.ID select r; foreach (var item in result) { S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, bill, item, operationType); S_Stock stockInfo = AssignStockInfo(dataContext, bill, item, operationType); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, stockInfo); } }
/// <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="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); } }