Beispiel #1
0
        private static Import CreateAndSaveImport(Go api)
        {
            // Set up a journal for import
            Console.WriteLine("Creating Sales Order import");

            // Create the import "header"
            var import = new Import
            {
                Description = "Sample Sales Order Import",
                Date        = DateTime.Now
            };

            Console.WriteLine("Adding sales orders");

            //Creating a sales order
            var salesOrder = new SalesOrder(1234, DateTime.Now, 12345)
            {
                Reference    = "Sales order reference",
                PaymentTerms = 14,
                Currency     = "NOK"
            };

            //Creating a sales order line for 5x product 240 with 10% discount
            var firstOrderLine = new SalesOrderLine("240", 5, 10);

            //By setting SalesOrderLineUnitPrice we can override product price for this sales order line
            firstOrderLine.SalesOrderLineUnitPrice = 1000;

            salesOrder.AddSalesOrderLine(firstOrderLine);

            //Optional: Creating a sales order description line
            var firstDescriptionLine = new SalesOrderLine("This is a description that will appear on the order");

            salesOrder.AddSalesOrderLine(firstDescriptionLine);

            //Adding Sales order to import object
            import.SalesOrders.Add(salesOrder);

            // Save the journal to the server. When this call has finished, the order import will
            // appear in the Journal Import list in PowerOffice Go.
            Console.WriteLine("Saving journal...");

            //Saves the import
            api.Import.Save(import);

            Console.WriteLine("Journal was saved and assign the Id: " + import.Id);
            return(import);
        }