Пример #1
0
    public InventoryItem[] getSupplierInventory(GetSupplierInventoryRequest request)
    {
        DetachedCriteria criteria = DetachedCriteria.For <SupllierLocationView>();


        if (request.supplierCode != null && request.supplierCode != string.Empty)
        {
            criteria.Add(Expression.Like("PartyFrom.Code", request.supplierCode));
        }

        if (request.company != null && request.company != string.Empty)
        {
            criteria.Add(Expression.Like("PartyFrom.Name", request.company));
        }

        IList <SupllierLocationView> supplierLocationList = TheCriteriaMgr.FindAll <SupllierLocationView>(criteria, request.beginRowIndex, request.beginRowIndex + request.rowSize);
        List <InventoryItem>         iItemList            = new List <InventoryItem>();

        foreach (SupllierLocationView supplierLocation in supplierLocationList)
        {
            //set region
            com.Sconit.Entity.Svp.Party party = new com.Sconit.Entity.Svp.Party();
            party.code        = supplierLocation.PartyTo.Code;
            party.id          = supplierLocation.PartyTo.Code;
            party.description = supplierLocation.PartyTo.Name;
            party.type        = supplierLocation.PartyTo.Type;

            //set supplier
            com.Sconit.Entity.Svp.Party supplier = new com.Sconit.Entity.Svp.Party();
            supplier.id          = supplierLocation.PartyFrom.Code;
            supplier.code        = supplierLocation.PartyFrom.Code;
            supplier.description = supplierLocation.PartyFrom.Name;
            supplier.type        = supplierLocation.PartyFrom.Type;

            //set unit of messure
            UOM uom = new UOM();
            uom.id           = supplierLocation.Item.Code;
            uom.abbreviation = supplierLocation.Item.Code;
            uom.description  = supplierLocation.Item.Description;

            //set supplier Item
            string   refItemCode = TheItemReferenceMgr.GetItemReferenceByItem(supplierLocation.Item.Code, supplierLocation.PartyFrom.Code, supplierLocation.PartyTo.Code);
            Material suppItem    = new Material();
            suppItem.id          = refItemCode;
            suppItem.no          = refItemCode;
            suppItem.description = refItemCode;
            suppItem.quantityUOM = uom;

            //set Item
            Material material = new Material();
            material.id          = supplierLocation.Item.Code;
            material.no          = supplierLocation.Item.Code;
            material.name        = supplierLocation.Item.Description;
            material.description = supplierLocation.Item.Description;
            suppItem.quantityUOM = uom;

            //set supplier material
            string2MaterialMapEntry[] suppItemMap = new string2MaterialMapEntry[1];
            suppItemMap[0]             = new string2MaterialMapEntry();
            suppItemMap[0].key         = supplier.code;
            suppItemMap[0].value       = suppItem;
            material.supplierMaterials = suppItemMap;

            //set location
            com.Sconit.Entity.Svp.Location location = new com.Sconit.Entity.Svp.Location();
            location.id   = supplierLocation.Location.Code;
            location.name = supplierLocation.Location.Name;

            //set inventory
            InventoryItem iItem = new InventoryItem();
            iItem.ownerParty              = party;
            iItem.supplier                = supplier;
            iItem.material                = material;
            iItem.location                = location;
            iItem.quantityOnHand          = Convert.ToDouble(supplierLocation.Qty);
            iItem.quantityOnHandSpecified = true;
            iItem.unitCount               = Convert.ToDouble(supplierLocation.Item.UnitCount);
            iItem.unitCountSpecified      = true;

            iItemList.Add(iItem);
        }

        return(iItemList.ToArray());
    }
Пример #2
0
    public FlowDetailProxy GenerateFlowDetailProxy(string flowCode, string itemCode, string moduleType, string partyFromCode, string partyToCode, bool changeRef, DateTime startTime)
    {
        IList <FlowDetail> flowDetailList = TheFlowDetailMgr.GetFlowDetail(flowCode, true);

        if (flowDetailList != null && flowDetailList.Count > 0)
        {
            foreach (FlowDetail fd in flowDetailList)
            {
                if (fd.Item.Code == itemCode)
                {
                    FlowDetailProxy flowDetailProxy = new FlowDetailProxy();
                    flowDetailProxy.ItemCode        = fd.Item.Code;
                    flowDetailProxy.ItemDescription = fd.Item.Description;
                    if (changeRef)
                    {
                        flowDetailProxy.ItemReferenceCode = fd.ReferenceItemCode;
                    }
                    flowDetailProxy.UomCode   = fd.Uom.Code;
                    flowDetailProxy.UnitCount = fd.UnitCount;
                    flowDetailProxy.HuLotSize = fd.HuLotSize == null?Convert.ToInt32(fd.UnitCount) : fd.HuLotSize;

                    if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                    {
                        if (fd.DefaultPriceListFrom != null)
                        {
                            flowDetailProxy.PriceListCode = fd.DefaultPriceListFrom.Code;
                            PriceListDetail priceListDetailFrom = ThePriceListDetailMgr.GetLastestPriceListDetail(fd.DefaultPriceListFrom, fd.Item, startTime, fd.Flow.Currency, fd.Uom);
                            if (priceListDetailFrom != null)
                            {
                                flowDetailProxy.UnitPrice         = priceListDetailFrom.UnitPrice;
                                flowDetailProxy.PriceListDetailId = priceListDetailFrom.Id;
                            }
                        }
                    }
                    else if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                    {
                        if (fd.DefaultPriceListTo != null)
                        {
                            flowDetailProxy.PriceListCode = fd.DefaultPriceListTo.Code;
                            PriceListDetail priceListDetailTo = ThePriceListDetailMgr.GetLastestPriceListDetail(fd.DefaultPriceListTo, fd.Item, startTime, fd.Flow.Currency, fd.Uom);
                            if (priceListDetailTo != null)
                            {
                                flowDetailProxy.UnitPrice         = priceListDetailTo.UnitPrice;
                                flowDetailProxy.PriceListDetailId = priceListDetailTo.Id;
                            }
                        }
                        flowDetailProxy.PackageVolumn = fd.PackageVolumn;
                    }

                    if (changeRef)
                    {
                        if (fd.ReferenceItemCode != null && fd.ReferenceItemCode != string.Empty)
                        {
                            flowDetailProxy.ItemReferenceCode = fd.ReferenceItemCode;
                        }
                        else
                        {
                            flowDetailProxy.ItemReferenceCode = TheItemReferenceMgr.GetItemReferenceByItem(itemCode, partyToCode, partyFromCode);
                        }
                    }
                    return(flowDetailProxy);
                }
            }
        }

        Item item = TheItemMgr.LoadItem(itemCode);

        if (item != null)
        {
            Flow            flow            = TheFlowMgr.LoadFlow(flowCode);
            FlowDetailProxy flowDetailProxy = new FlowDetailProxy();
            flowDetailProxy.ItemCode        = item.Code;
            flowDetailProxy.ItemDescription = item.Description;
            flowDetailProxy.UomCode         = item.Uom.Code;

            if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
            {
                if (flow.PriceListFrom != null)
                {
                    flowDetailProxy.PriceListCode = flow.PriceListFrom.Code;
                    PriceListDetail priceListDetailFrom = ThePriceListDetailMgr.GetLastestPriceListDetail(flow.PriceListFrom, item, startTime, flow.Currency, item.Uom);
                    if (priceListDetailFrom != null)
                    {
                        flowDetailProxy.UnitPrice         = priceListDetailFrom.UnitPrice;
                        flowDetailProxy.PriceListDetailId = priceListDetailFrom.Id;
                    }
                }
            }
            else if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
            {
                if (flow.PriceListTo != null)
                {
                    flowDetailProxy.PriceListCode = flow.PriceListTo.Code;
                    PriceListDetail priceListDetailTo = ThePriceListDetailMgr.GetLastestPriceListDetail(flow.PriceListTo, item, startTime, flow.Currency, item.Uom);
                    if (priceListDetailTo != null)
                    {
                        flowDetailProxy.UnitPrice         = priceListDetailTo.UnitPrice;
                        flowDetailProxy.PriceListDetailId = priceListDetailTo.Id;
                    }
                }
            }

            if (changeRef)
            {
                flowDetailProxy.ItemReferenceCode = TheItemReferenceMgr.GetItemReferenceByItem(itemCode, partyToCode, partyFromCode);
            }
            flowDetailProxy.UnitCount = item.UnitCount;
            flowDetailProxy.HuLotSize = Convert.ToInt32(item.UnitCount);
            return(flowDetailProxy);
        }

        return(null);
    }