Page tree
Skip to end of metadata
Go to start of metadata

This function creates an Invoice

Parameters

Used to call the function

  1. invoice - TInvoice
  2. doPost - boolean

Returns

Returns the following

  • integer

 

if doPost is set as false the invoice has not been booked and will not get a invoice number and the function return 0

            IItemServiceservice service = new IItemServiceservice()
            {
                BasicSecurityValue = new BasicSecurity() { Username = "ws.demo", Password = "1234" },
            };
            var invoice = new TInvoice()
            {
                SalePerson = "WEB",
                InvoiceDate = DateTime.Now,
                CurrencyCode = "ISK",
                Options = new TInvoiceOptions()
                {
                    Customer = TActionMethod._ActionInsertMerge //If customer already exists merge information sent to the existing customer
                },                
                Customer = new TCustomer() {
                    Number = "EXT-ID-223",
                    Name = "Sr. Nikolas Cage",
                    Address1 = "Hollywood 98210",
                    ZipCode = "124-588",
                    CountryCode = "USA",
                    Gender = TGender._consMale,
                    Email = "cage@hollywood"
                },
                Lines = new TInvoiceLine[]
                {
                    new TInvoiceLine()
                    {
                        ItemCode = "A12345",
                        Quantity = 5,
                        UnitPriceWithTax = 10000,
                        Text = "Double Size room",
                        Text2 = "NOTE: Vegan",
                        TotalAmountWithTax = 50000
                    },
                    new TInvoiceLine()
                    {
                        ItemCode = "A12345_EX",
                        Quantity = 5,
                        UnitPriceWithTax = 7000,
                        Text = "Special Cage",
                        Text2 = "NOTE: Sanitized",
                        TotalAmountWithTax = 35000
                    }
                },
                Payments = new TPayment[]
                {
                    new TPayment()
                    {
                        PaymentTypeId = 10,
                        Amount = 85000
                    }
                }
            };
            service.CreateInvoice(invoice, true);