Beispiel #1
0
        public GoodsReceiptItem[] CreateGoodsReceiptItemsFromZeroBatchLineNums()
        {
            var grItems = new List <GoodsReceiptItem>();

            if (ZeroBatchLineNums.Count > 0)
            {
                var ZeroBatchLineNumsArray = ZeroBatchLineNums.ToArray();
                var line = oDraft.Lines;

                for (int i = 0; i < ZeroBatchLineNumsArray.Length; i++)
                {
                    line.SetCurrentLine(ZeroBatchLineNumsArray[i]);

                    // Direct goods in
                    var grItem = new GoodsReceiptItem();
                    grItem.ItemCode    = line.ItemCode;
                    grItem.InvQuantity = line.InventoryQuantity;
                    grItem.ShopWhscode = line.WarehouseCode;

                    grItem.Quantity = line.Quantity;
                    grItem.UomCode  = line.UoMCode;
                    grItem.UomEntry = line.UoMEntry;

                    grItems.Add(grItem);
                }
            }

            return(grItems.ToArray());
        }
Beispiel #2
0
        public void SortNonBatchItems(SAP sap)
        {
            if (NonBatchLineNums.Count > 0)
            {
                var NonBatchLineNumsArray = NonBatchLineNums.ToArray();
                var line = oDraft.Lines;
                var allocatorNonbatch = new NonBatchAllocation();

                for (int i = 0; i < NonBatchLineNumsArray.Length; i++)
                {
                    line.SetCurrentLine(NonBatchLineNumsArray[i]);

                    // Any stock in the shop?
                    double qty = allocatorNonbatch.AllocateNonBatchStock(line.ItemCode, line.WarehouseCode, line.InventoryQuantity);


                    if (qty == 0)
                    {
                        decimal dInventoryQuantity = Convert.ToDecimal(line.InventoryQuantity);
                        var     fromwhs            = StockInfo.WarehouseStockCheck(line.ItemCode, dInventoryQuantity);

                        if (fromwhs != null)
                        {
                            //  Get from warehouses.

                            var invuom = new Item(sap, line.ItemCode).oItem.InventoryUoMEntry;
                            WarehouseTransferItems.Add(new StockTransferItem
                            {
                                LineNum       = line.LineNum,
                                ItemCode      = line.ItemCode,
                                InvQuantity   = line.InventoryQuantity,
                                FromWarehouse = fromwhs.WhsCode,
                                ToWarehouse   = line.WarehouseCode,
                                InvUomEntry   = invuom
                            });
                        }
                        else
                        {
                            // Goods in
                            GoodsReceiptItem gitem = new GoodsReceiptItem();
                            gitem.ItemCode    = line.ItemCode;
                            gitem.InvQuantity = line.InventoryQuantity;
                            gitem.Quantity    = line.Quantity;
                            gitem.UomCode     = line.UoMCode;
                            gitem.UomEntry    = line.UoMEntry;
                            gitem.ShopWhscode = line.WarehouseCode;

                            GoodsReceiptItems.Add(gitem);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public GoodsReceiptItem[] CopyDeliveryXferItems2GRPO()
        {
            if (WarehouseTransferItems.Count > 0)
            {
                // Which price mode
                var lines =
                    WarehouseTransferItems
                    .Where(x => x.IsSameBranch == false).ToArray();


                if (lines.Length > 0)
                {
                    // Create draft in SAP

                    //Documents deliveryDraft = (Documents)sap.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
                    List <GoodsReceiptItem> goodsitems = new List <GoodsReceiptItem>();

                    var items = WarehouseTransferItems.ToArray();

                    for (int i = 0; i < items.Count(); i++)
                    {
                        // Items
                        GoodsReceiptItem item = new GoodsReceiptItem();
                        item.ItemCode    = items[i].ItemCode;
                        item.InvQuantity = items[i].InvQuantity;
                        item.ShopWhscode = items[i].ToWarehouse;

                        goodsitems.Add(item);
                    }

                    return(goodsitems.ToArray());
                }
            }

            return(null);
        }
Beispiel #4
0
        public void SortUnallocatedItems(SAP sap)
        {
            if (ZeroBatchLineNums.Count > 0)
            {
                var ZeroBatchLineNumsArray = ZeroBatchLineNums.ToArray();
                var line = oDraft.Lines;
                using (var ctx = new DevEntities())
                {
                    for (int i = 0; i < ZeroBatchLineNumsArray.Length; i++)
                    {
                        line.SetCurrentLine(ZeroBatchLineNumsArray[i]);

                        double requiredQty = line.InventoryQuantity - line.BatchNumbers.TotalBatchQuantity();
                        //decimal dInventoryQuantity = Convert.ToDecimal(line.InventoryQuantity);
                        decimal dReqInventoryQuantity = Convert.ToDecimal(requiredQty);

                        var fromwhs = StockInfo.WarehouseStockCheck(line.ItemCode, dReqInventoryQuantity);

                        if (fromwhs != null)
                        {
                            //  Get from warehouses.


                            var invuom = new Item(sap, line.ItemCode).oItem.InventoryUoMEntry;
                            WarehouseTransferItems.Add(new StockTransferItem
                            {
                                LineNum  = line.LineNum,
                                ItemCode = line.ItemCode,
                                //InvQuantity = line.InventoryQuantity,
                                InvQuantity   = Convert.ToDouble(dReqInventoryQuantity),
                                FromWarehouse = fromwhs.WhsCode,
                                ToWarehouse   = line.WarehouseCode,
                                InvUomEntry   = invuom
                            });
                        }
                        else
                        {
                            // Check KIMSON
                            string owner = StockInfo.IsItemLongdanKimson(sap, line.ItemCode);


                            switch (owner)
                            {
                            case "LONGDAN":

                                // Direct goods in
                                var grItem = new GoodsReceiptItem();
                                grItem.ItemCode = line.ItemCode;
                                //grItem.InvQuantity = line.InventoryQuantity;
                                grItem.InvQuantity = Convert.ToDouble(dReqInventoryQuantity);
                                grItem.ShopWhscode = line.WarehouseCode;

                                grItem.Quantity = line.Quantity;
                                grItem.UomCode  = line.UoMCode;
                                grItem.UomEntry = line.UoMEntry;

                                GoodsReceiptItems.Add(grItem);

                                break;


                            case "KIMSON":

                                var k_item = new KimsonDeliveryItem();
                                k_item.ItemCode = line.ItemCode;
                                k_item.Quantity = line.Quantity;
                                k_item.UoMEntry = line.UoMEntry;

                                KimsonDeliveryItems.Add(k_item);

                                break;
                            }

                            // Not KIMSON then GOODS IN
                        }
                    }
                }
            }
        }