Exemplo n.º 1
0
    private decimal GetTotalOutQty(LocationDetail locationDetail)
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationTransactionView));
        //criteria.CreateAlias("Location", "l");

        #region Customize
        //SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限
        CriteriaHelper.SetStartDateCriteria(criteria, "EffDate", _criteriaParam);
        CriteriaHelper.SetEndDateCriteria(criteria, "EffDate", _criteriaParam);

        #endregion

        #region Select Parameters
        string[] regionCode = locationDetail.Region != null ? new string[] { locationDetail.Region.Code } : null;
        string[] locationCode = locationDetail.Location != null ? new string[] { locationDetail.Location.Code } : null;
        string itemCode = locationDetail.Item != null ? locationDetail.Item.Code : null;
        //CriteriaHelper.SetPartyCriteria(criteria, "l.Region.Code", regionCode);
        CriteriaHelper.SetLocationCriteria(criteria, "Loc", locationCode);
        CriteriaHelper.SetItemCriteria(criteria, "Item", itemCode, MatchMode.Exact);
        criteria.Add(Expression.In("TransType", GetTransType()));
        #endregion

        criteria.SetProjection(Projections.Sum("Qty"));

        IList result = CriteriaMgr.FindAll(criteria);
        if (result[0] != null)
        {
            return (decimal)result[0];
        }
        else
        {
            return 0;
        }
    }
 public virtual void UpdateLocationDetail(LocationDetail entity)
 {
     entityDao.UpdateLocationDetail(entity);
 }
 public virtual void DeleteLocationDetail(LocationDetail entity)
 {
     entityDao.DeleteLocationDetail(entity);
 }
 public virtual void CreateLocationDetail(LocationDetail entity)
 {
     entityDao.CreateLocationDetail(entity);
 }
Exemplo n.º 5
0
        public IList<LocationDetail> GetInvVisualBoard(string locCode, string itemCode, string flow, DateTime? date, User user)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(FlowDetail));
            criteria.CreateAlias("Flow", "f");
            if (flow != null && flow.Trim() != string.Empty)
                criteria.Add(Expression.Eq("Flow.Code", flow));
            if (itemCode != null && itemCode.Trim() != string.Empty)
                criteria.Add(Expression.Eq("Item.Code", itemCode));
            if (locCode != null && locCode != string.Empty)
            {
                criteria.Add(Expression.Or(Expression.And(Expression.IsNull("LocationTo"), Expression.Eq("f.LocationTo.Code", locCode)),
                    Expression.Eq("LocationTo.Code", locCode)));
            }
            IList<FlowDetail> flowDetailList = CriteriaMgr.FindAll<FlowDetail>(criteria);

            //����Ȩ��
            if (locCode == null || locCode == string.Empty)
                flowDetailList = this.FilterFlowDetail(flowDetailList, user);

            IList<LocationDetail> ldList = new List<LocationDetail>();
            if (flowDetailList != null && flowDetailList.Count > 0)
            {
                foreach (FlowDetail fd in flowDetailList)
                {
                    LocationDetail ld = new LocationDetail();
                    if (fd.DefaultLocationTo == null)
                        continue;

                    ld = this.FindLocationDetail(fd.DefaultLocationTo, fd.Item, date, true);
                    if (ld != null)
                    {
                        ld.FlowDetail = fd;

                        //�����
                        if (!ld.FlowDetail.Item.Uom.Equals(ld.FlowDetail.Uom))
                        {
                            ld.InTransitQty = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.InTransitQty);
                            ld.QtyToBeIn = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.QtyToBeIn);
                            ld.QtyToBeOut = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.QtyToBeOut);
                            ld.InvQty = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.InvQty);
                            ld.PAB = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.PAB);
                        }

                        ldList.Add(ld);
                    }
                }
            }

            return ldList;
        }
Exemplo n.º 6
0
        public LocationDetail FindLocationDetail(Location location, Item item, DateTime? effectiveDate, bool includeActiveOrder)
        {
            //��ȷ������
            DateTime effDate = effectiveDate.HasValue ? ((DateTime)effectiveDate).Date : DateTime.MaxValue;

            LocationDetail ld = this.GetLocationDetail(location.Code, item.Code);
            if (ld == null)
            {
                if (!includeActiveOrder)
                    return null;

                ld = new LocationDetail();
                ld.Location = location;
                ld.Item = item;
                ld.InvQty = 0;
            }
            ld.InvQty = ld.Qty;

            //History inventory
            IList<LocationTransaction> locTransList = LocTransMgr.GetLocationTransactionAfterEffDate(item.Code, location.Code, effDate);
            decimal transQty = 0;
            if (locTransList != null && locTransList.Count > 0)
            {
                foreach (LocationTransaction locTrans in locTransList)
                {
                    transQty += locTrans.Qty;
                }
            }
            ld.InvQty = ld.InvQty - transQty;

            if (includeActiveOrder)
            {
                IList<OrderLocationTransaction> outOrderLocTransList = OrderLocTransMgr.GetOpenOrderLocTransOut(item.Code, location.Code, BusinessConstants.IO_TYPE_OUT, effDate);
                decimal qtyOut = 0;
                if (outOrderLocTransList != null && outOrderLocTransList.Count > 0)
                {
                    foreach (OrderLocationTransaction orderLocTrans in outOrderLocTransList)
                    {
                        //����
                        qtyOut += orderLocTrans.RemainQty;
                    }
                }

                IList<OrderLocationTransaction> inOrderLocTransList = OrderLocTransMgr.GetOpenOrderLocTransIn(item.Code, location.Code, BusinessConstants.IO_TYPE_IN, effDate);
                decimal qtyIn = 0;
                decimal qtyInTransit = 0;
                if (inOrderLocTransList != null && inOrderLocTransList.Count > 0)
                {
                    foreach (OrderLocationTransaction orderLocTrans in inOrderLocTransList)
                    {
                        IList<InProcessLocationDetail> inTransitList = IPLocDetMgr.GetInProcessLocationDetail(orderLocTrans.OrderDetail);
                        decimal totalQtyInTransit = 0;
                        if (inTransitList != null && inTransitList.Count > 0)
                        {
                            foreach (InProcessLocationDetail ipld in inTransitList)
                            {
                                if (ipld.InProcessLocation.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)
                                {
                                    //ֻ��δ�ջ��IJż�����;
                                    totalQtyInTransit += ipld.Qty * ipld.OrderLocationTransaction.UnitQty;
                                }
                                else if (ipld.InProcessLocation.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)
                                {
                                    if (ipld.ReceivedQty.HasValue)
                                    {
                                        totalQtyInTransit += (ipld.Qty - ipld.ReceivedQty.Value) * ipld.OrderLocationTransaction.UnitQty;
                                    }
                                    else
                                    {
                                        totalQtyInTransit += ipld.Qty * ipld.OrderLocationTransaction.UnitQty;
                                    }
                                }
                            }
                        }

                        //��;
                        qtyInTransit += totalQtyInTransit;

                        //����
                        qtyIn += orderLocTrans.RemainQty - totalQtyInTransit;
                    }
                }

                ld.QtyToBeOut = qtyOut;
                ld.QtyToBeIn = qtyIn;
                ld.InTransitQty = qtyInTransit;

                //Ԥ�ƿ��ÿ�� = ��ǰ��� + ����(ʣ��) + ��; - ����
                ld.PAB = ld.InvQty + qtyIn + qtyInTransit - qtyOut;
            }

            return ld;
        }