示例#1
0
        /// <summary>
        /// 借还货出库业务的处理
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fetchGoodsDetailInfo">出库业务对象</param>
        void FetchLendReturn_MaterialRequisition(DepotManagementDataContext ctx, S_FetchGoodsDetailBill fetchGoodsDetailInfo)
        {
            if (fetchGoodsDetailInfo == null)
            {
                return;
            }

            if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启借还货账务管理]))
            {
                BASE_SubsidiaryOperationType operationType = UniversalFunction.GetSubsidiaryOperationType(ctx, fetchGoodsDetailInfo.OperationType);

                if (operationType.LendReturnType != null)
                {
                    IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();

                    var varData = from a in ctx.View_S_MaterialRequisitionProductReturnList
                                  where a.单据号 == fetchGoodsDetailInfo.FetchBIllID &&
                                  a.还账物品ID == fetchGoodsDetailInfo.GoodsID &&
                                  a.还账物品批次号 == fetchGoodsDetailInfo.BatchNo &&
                                  a.还账物品供应商 == fetchGoodsDetailInfo.Provider
                                  select a;

                    if (varData.Count() > 0)
                    {
                        foreach (var item1 in varData)
                        {
                            S_ProductLendRecord tempRecord =
                                serverLendReturn.GetStockSingleInfo(ctx, BasicInfo.DeptCode, fetchGoodsDetailInfo.StorageID, item1.账物品ID,
                                                                    item1.账物品批次号, item1.账物品供应商);

                            if (tempRecord != null)
                            {
                                S_ProductLendReturnDetail tempDetail = new S_ProductLendReturnDetail();

                                tempDetail.Affirm         = fetchGoodsDetailInfo.DepotManager;
                                tempDetail.AffirmDate     = ServerTime.Time;
                                tempDetail.BatchNo        = item1.账物品批次号;
                                tempDetail.Provider       = item1.账物品供应商;
                                tempDetail.BillNo         = fetchGoodsDetailInfo.FetchBIllID;
                                tempDetail.BillTime       = ServerTime.Time;
                                tempDetail.Credit         = fetchGoodsDetailInfo.StorageID;
                                tempDetail.Debtor         = BasicInfo.DeptCode;
                                tempDetail.GoodsID        = item1.账物品ID;
                                tempDetail.OperationCount = item1.还账数量;
                                tempDetail.OperationType  = fetchGoodsDetailInfo.OperationType;
                                tempDetail.Proposer       = fetchGoodsDetailInfo.FillInPersonnel;
                                tempDetail.ProposerDate   =
                                    fetchGoodsDetailInfo.FillInDate == null ? ServerTime.Time : Convert.ToDateTime(fetchGoodsDetailInfo.FillInDate);
                                tempDetail.UnitPrice = 0;

                                serverLendReturn.OperationDetailRecord(ctx, tempDetail);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 借还货出库业务的处理
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fetchGoodsDetailInfo">出库业务对象</param>
        void FetchLendReturn(DepotManagementDataContext ctx, S_FetchGoodsDetailBill fetchGoodsDetailInfo)
        {
            if (fetchGoodsDetailInfo == null)
            {
                return;
            }

            if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启借还货账务管理]))
            {
                BASE_SubsidiaryOperationType operationType = UniversalFunction.GetSubsidiaryOperationType(ctx, fetchGoodsDetailInfo.OperationType);

                if (operationType.LendReturnType != null)
                {
                    S_ProductLendReturnDetail tempDetail = new S_ProductLendReturnDetail();

                    tempDetail.Affirm         = fetchGoodsDetailInfo.DepotManager;
                    tempDetail.AffirmDate     = fetchGoodsDetailInfo.BillTime;
                    tempDetail.BatchNo        = fetchGoodsDetailInfo.BatchNo;
                    tempDetail.Provider       = fetchGoodsDetailInfo.Provider;
                    tempDetail.BillNo         = fetchGoodsDetailInfo.FetchBIllID;
                    tempDetail.BillTime       = fetchGoodsDetailInfo.BillTime;
                    tempDetail.Credit         = fetchGoodsDetailInfo.StorageID;
                    tempDetail.Debtor         = UniversalFunction.GetPersonnelInfo(ctx, fetchGoodsDetailInfo.FillInPersonnel).部门编码;
                    tempDetail.GoodsID        = fetchGoodsDetailInfo.GoodsID;
                    tempDetail.OperationCount = fetchGoodsDetailInfo.FetchCount < 0 ? -(decimal)fetchGoodsDetailInfo.FetchCount : (decimal)fetchGoodsDetailInfo.FetchCount;
                    tempDetail.OperationType  = fetchGoodsDetailInfo.OperationType;
                    tempDetail.Proposer       = fetchGoodsDetailInfo.FillInPersonnel;
                    tempDetail.ProposerDate   = fetchGoodsDetailInfo.FillInDate == null ? ServerTime.Time : Convert.ToDateTime(fetchGoodsDetailInfo.FillInDate);
                    tempDetail.Remark         = fetchGoodsDetailInfo.Remark;
                    tempDetail.UnitPrice      = fetchGoodsDetailInfo.UnitPrice;

                    IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();
                    serverLendReturn.OperationDetailRecord(ctx, tempDetail);
                }
            }
        }
示例#3
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialRequisition bill,
                                                       S_MaterialRequisitionGoods item)
        {
            IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   billType = server.GetBillTypeFromName("领料单");

            if (billType == null)
            {
                throw new Exception("获取不到单据类型信息");
            }

            View_Department           department       = UniversalFunction.GetDeptInfo(context, bill.Department);
            IStoreServer              storeServer      = ServerModuleFactory.GetServerModule <IStoreServer>();
            IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();
            F_GoodsPlanCost           basicGoods       = m_basicGoodsServer.GetGoodsInfo(context, item.GoodsID);

            if (basicGoods == null)
            {
                throw new Exception(string.Format("物品ID [{0}] 的物品在基础物品表中没有查到,请与系统管理员联系!", item.GoodsID));
            }

            StoreQueryCondition condition = new StoreQueryCondition();

            condition.GoodsID   = item.GoodsID;
            condition.Provider  = item.ProviderCode;
            condition.BatchNo   = item.BatchNo;
            condition.StorageID = bill.StorageID;

            S_Stock stock = storeServer.GetStockInfoOverLoad(context, condition);

            if (stock == null && GlobalObject.GeneralFunction.IsNullOrEmpty(basicGoods.GoodsType))
            {
                throw new Exception(string.Format("图号:{0}, 名称:{1}, 规格:{2}, 供应商:{3}, 批次号:{4} 的物品在库存中没有查到相关物品,请仓管员核实!",
                                                  basicGoods.GoodsCode, basicGoods.GoodsName, basicGoods.Spec, item.ProviderCode, item.BatchNo));
            }

            //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息
            decimal dcRealCount = item.RealCount;
            decimal dcSumCount  = 0;

            var varData = from a in context.View_S_MaterialRequisitionProductReturnList
                          where a.单据号 == item.Bill_ID &&
                          a.还账物品ID == item.GoodsID &&
                          a.还账物品批次号 == item.BatchNo &&
                          a.还账物品供应商 == item.ProviderCode
                          select a;

            if (varData.Count() > 0)
            {
                dcSumCount = varData.Sum(a => a.还账数量);

                if (dcRealCount < dcSumCount)
                {
                    throw new Exception("实际领用数量不能大于还货数量,请重新核对");
                }
            }

            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            detailBill.ID                 = Guid.NewGuid();
            detailBill.FetchBIllID        = bill.Bill_ID;
            detailBill.BillTime           = (DateTime)bill.OutDepotDate;
            detailBill.AssociatedBillType = bill.AssociatedBillType;
            detailBill.AssociatedBillNo   = bill.AssociatedBillNo;
            detailBill.Department         = department.部门名称;
            detailBill.FetchCount         = item.RealCount;
            detailBill.GoodsID            = item.GoodsID;
            detailBill.StorageID          = bill.StorageID;
            detailBill.Price              = dcSumCount;
            detailBill.UnitPrice          = stock == null ? 0 : stock.UnitPrice;
            detailBill.OperationType      = (int)CE_SubsidiaryOperationType.领料;
            detailBill.Provider           = item.ProviderCode;

            if (stock != null)
            {
                detailBill.ProviderBatchNo = stock.ProviderBatchNo;
            }
            else
            {
                detailBill.ProviderBatchNo = "";
            }

            detailBill.BatchNo = item.BatchNo;

            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.Remark           = (bill.Remark == null ? "" : bill.Remark.Trim()) + (item.Remark == null ? "" : item.Remark.Trim());
            detailBill.FillInDate       = bill.Bill_Time;

            IMaterialRequisitionPurposeServer purposeServer =
                ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>();

            detailBill.Using = purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose;

            return(detailBill);
        }