Exemple #1
0
        public Invoice(SalesOrder salesOrder)
        {
            this.invoice = new com.netsuite.webservices.Invoice();

            RecordRef salesOrderID = new RecordRef();
            salesOrderID.type = RecordType.salesOrder;
            salesOrderID.typeSpecified = true;

            salesOrderID.internalId = salesOrder.salesOrder.internalId;

            this.invoice.createdFrom = salesOrderID;

            this.invoice.billAddress = salesOrder.salesOrder.billAddress;
            //this.invoice.shipAddress = salesOrder.salesOrder.shipAddress;
            this.invoice.entity = salesOrder.salesOrder.entity;
            this.invoice.subTotal = salesOrder.salesOrder.subTotal;

            InvoiceItemList invoiceItemList = new InvoiceItemList();
            this.invoice.itemList = addItemList(salesOrder.salesOrder.itemList);

            this.invoice.memo = salesOrder.salesOrder.memo;
            this.invoice.location = salesOrder.salesOrder.location;
            //this.invoice.fob = salesOrder.salesOrder.fob;
        }
        public ItemFulfillment(SalesOrder salesOrder)
        {
            itemFulfillment = new com.netsuite.webservices.ItemFulfillment();
            RecordRef salesOrderID = new RecordRef();
            salesOrderID.type = RecordType.salesOrder;
            salesOrderID.typeSpecified = true;
            salesOrderID.internalId = salesOrder.salesOrder.internalId;

            itemFulfillment.createdFrom = salesOrderID;

            ItemFulfillmentItemList itemFulItemList = new ItemFulfillmentItemList();
            int i = 0;
            ItemFulfillmentItem[] Items = new ItemFulfillmentItem[salesOrder.salesOrder.itemList.item.Count()];

            Dictionary<string, double> binQuantities = new Dictionary<string, double>();

            foreach (var itemLine in salesOrder.salesOrder.itemList.item)
            {
                Items[i] = new ItemFulfillmentItem();
                RecordRef item = new RecordRef();
                item.type = RecordType.inventoryItem;
                item.typeSpecified = true;
                item.internalId = itemLine.item.internalId;
                Items[i].item = item;
                Items[i].quantity = itemLine.quantity;
                Items[i].quantitySpecified = true;
                Items[i].orderLine = itemLine.line;
                Items[i].orderLineSpecified = true;

                binQuantities = getBins(itemLine.item.name);

                string[] bins = new string[binQuantities.Count];
                int j = 0;
                foreach (var key in binQuantities)
                {
                    bins[j] = key.Key;
                    j++;
                }

                Array.Sort(bins, new AlphanumComparatorFast());
                bins = bins.Where(x => !string.IsNullOrEmpty(x)).ToArray();

                List<string> notPreferredBins = new List<string>();
                List<string> preferredBins = new List<string>();
                List<string> orderedBins = new List<string>();

                Regex regex = new Regex("[0-9]+[A-Z]");
                string C = "C";

                foreach (var bin in bins)
                {
                    Match match = regex.Match(bin);
                    if (match.Success)
                    {
                        string letter = (match.Value[match.Value.Length - 1]).ToString();
                        int compare = string.Compare(letter, C);
                        if (compare < 0)
                        {
                            notPreferredBins.Add(bin);
                        }
                        else preferredBins.Add(bin);
                    }
                }

                foreach (var bin in preferredBins)
                {
                    orderedBins.Add(bin);
                }
                orderedBins.Add("Stock");
                foreach (var bin in notPreferredBins)
                {
                    orderedBins.Add(bin);
                }

                foreach (var bin in orderedBins)
                {
                    double availQuantity = binQuantities[bin];
                    if (availQuantity >= Items[i].quantity)
                    {
                        Items[i].binNumbers = bin;
                        break;
                    }
                }
                i++;
            }
            itemFulItemList.item = Items;
            this.itemFulfillment.itemList = itemFulItemList;
        }
Exemple #3
0
        public string approveOrder()
        {
            SalesOrder updatedOrder = new SalesOrder();
            updatedOrder.salesOrder = new com.netsuite.webservices.SalesOrder();
            updatedOrder.salesOrder.internalId = this.salesOrder.internalId;
            updatedOrder.salesOrder.itemList = new SalesOrderItemList();
            updatedOrder.salesOrder.orderStatus = SalesOrderOrderStatus._pendingFulfillment;
            updatedOrder.salesOrder.orderStatusSpecified = true;

            List<SalesOrderLine> newItemList = new List<SalesOrderLine>();
            newItemList = createNewSalesOrderLines(this.salesOrder.itemList);
            updatedOrder.addItemList(newItemList);

            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            WriteResponse writeResponse = service.update(updatedOrder.salesOrder);
            if (writeResponse.status.isSuccess == true)
            {
                Console.WriteLine("Approved Sales Order success");
            }
            if (writeResponse.status.isSuccess == false)
            {
                Console.WriteLine(writeResponse.status.statusDetail[0].message);
            }

            return this.salesOrder.tranId;
        }
Exemple #4
0
        public void editOrder(List<SalesOrderLine> orderLines)
        {
            SalesOrder updatedOrder = new SalesOrder();
            updatedOrder.salesOrder = new com.netsuite.webservices.SalesOrder();
            updatedOrder.salesOrder.internalId = this.salesOrder.internalId;
            updatedOrder.salesOrder.itemList = new SalesOrderItemList();
            bool flag = false;
            bool contains = false;
            bool contains1 = false;

            foreach (var line in orderLines)
            {
                foreach (var itemObject in this.salesOrder.itemList.item)
                {
                    //if (itemObject.item.name.Contains(line.item.ItemName))
                    if (itemObject.item.name.Contains(line.item.ItemName) && (line.delete == true))
                    {
                        this.salesOrder.itemList.item = this.salesOrder.itemList.item.Where(val => !val.item.name.Contains(line.item.ItemName)).ToArray();
                    }
                    if (itemObject.item.name.Contains(line.item.ItemName) && (line.delete == false))
                    {
                        itemObject.quantity = line.QuantityRequested;
                        contains1 = true;
                    }
                    if (!itemObject.item.name.Contains(line.item.ItemName) && (line.delete == false))
                    {
                        contains = false;
                    }
                    if (!itemObject.item.name.Contains(line.item.ItemName) && (line.delete == true))
                    {
                        contains = true;
                    }
                }

                if (!(contains || contains1))
                {
                    SalesOrderLine addLine = new SalesOrderLine(line.item.ItemName, line.QuantityRequested, line.UnitPrice, flag);
                    this.salesOrder.itemList = this.addToExistingItemList(this.salesOrder.itemList, addLine);
                }
                contains = false;
                contains1 = false;
            }

            List<SalesOrderLine> newItemList = new List<SalesOrderLine>();
            newItemList = createNewSalesOrderLines(this.salesOrder.itemList);
            updatedOrder.addItemList(newItemList);

            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            WriteResponse writeResponse = service.update(updatedOrder.salesOrder);
            if (writeResponse.status.isSuccess == true)
            {
                Console.WriteLine("Update Sales Order success");
            }
            if (writeResponse.status.isSuccess == false)
            {
                Console.WriteLine(writeResponse.status.statusDetail[0].message);
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            /********************** Create new Bins/Delete Bin
            BinManagement binCreation = new BinManagement();

            List<InventoryBin> listOfBins = new List<InventoryBin>();
            listOfBins = binCreation.GetBinsFromExcel(args[0]);

            InventoryBin ingramMalaysia = new InventoryBin("Consignment","IngramMalaysia");

            foreach (var bin in listOfBins)
            {
               binCreation.createNewBin(ingramMalaysia);
            }

            //InventoryBin testBin = new InventoryBin("Amazon - US","TestBin");
            //binCreation.DeleteBin(testBin);

             */

            /**********************  Add bins to items
            ItemBinUpdate itemBinUpdate = new ItemBinUpdate();
            List<InventoryBin> listOfItemBins = new List<InventoryBin>();
            listOfItemBins = itemBinUpdate.GetItemBinsFromExcel(args[0]);

            foreach (var itemBin in listOfItemBins)
            {
                itemBinUpdate.addBin(itemBin);
            }
            */

            //********************** Create new Sales Order
            /*
            bool noDelete = false;
            SalesOrderInfo salesInfo = new SalesOrderInfo("test address", "test address2", "test order", "FOB");

            SalesOrder testOrder = new SalesOrder(salesInfo);

            List<SalesOrderLine> orderItems = new List<SalesOrderLine>();
            orderItems.Add(new SalesOrderLine("AG-3GS-BK",1,15,noDelete));
            orderItems.Add(new SalesOrderLine("AG-3GS-BL", 1, 12,noDelete));
            orderItems.Add(new SalesOrderLine("AG-3GS-PK", 1, 10,noDelete));

            testOrder.addItemList(orderItems);
            testOrder.setCustomer("Test Celigo Company");
            testOrder.placeSalesOrder();
            */

            SalesOrder findOrder = new SalesOrder();
            findOrder.salesOrderSearch("S39853");
            /*
            foreach (var field in findOrder.salesOrder.customFieldList)
            {
                string intID = field.internalId;
                if(intID == "148")
                {
                    Console.WriteLine(((com.netsuite.webservices.SelectCustomFieldRef)field).value.name);
                }
            }
            */

            //string test = findOrder.approveOrder();

            /*********************** Edit Sales Order

            //bool delete = true;
            bool noDelete = false;
            List<SalesOrderLine> editList = new List<SalesOrderLine>();
            editList.Add(new SalesOrderLine("AG-ALOTC7-TG000", 1, 15, noDelete));

            findOrder.editOrder(editList);
            */

            //****************** Create new Invoice
            //Invoice testInvoice = new Invoice(findOrder);
            //testInvoice.createInvoice();

            //***************** Create new Item Fulfillment
            ItemFulfillment testIF = new ItemFulfillment(findOrder);
            testIF.createItemFulfillment();

            //*
            //ItemFulfillment findFulfillment = new ItemFulfillment();
            //findFulfillment.itemFulfillmentSearch("18011");

               // bool delete = false;
            //List<ItemFulfillmentLine> editLines = new List<ItemFulfillmentLine>();
            //editLines.Add(new ItemFulfillmentLine("AG-3GS-BK", 3,delete));

            //findFulfillment.editFulfillment(editLines);
            //*/

            //testOrder.deleteOrder();

            //Item testItem = new Item("AG-3GS-BK");
               // testItem.addItemRecord();

            //string test = findFulfillment.markAsShipped();

               //Console.WriteLine(test);

            Console.Read();
        }