/// <summary> /// Create a new invoice on the authenticated account. Makes both a POST and a GET request to the Invoices resource. /// </summary> /// <param name="kind">The kind of invoice to create</param> /// <param name="clientId">The client the new invoice is for</param> /// <param name="issuedAt">The date the invoice should be issued</param> /// <param name="dueAt">The date the invoice should be due</param> /// <param name="currency">The currency of the invoice</param> /// <param name="subject">The invoice subject</param> /// <param name="notes">Notes to include on the invoice</param> /// <param name="number">The number for the invoice</param> /// <param name="projectIds">The IDs of projects to include in the invoice (useless for FreeForm invoices)</param> /// <param name="lineItems">A collection of line items for the invoice (only for FreeForm invoices)</param> public Invoice CreateInvoice(InvoiceKind kind, long clientId, DateTime issuedAt, DateTime? dueAt = null, Currency? currency = null, string subject = null, string notes = null, string number = null, long[] projectIds = null, List<InvoiceItem> lineItems = null) { var invoice = new InvoiceOptions() { Kind = kind, ClientId = clientId, IssuedAt = issuedAt, DueAt = dueAt, Currency = currency, Subject = subject, Notes = notes, Number = number, }; if (projectIds != null) invoice.ProjectsToInvoice = string.Join(",", projectIds.Select(id => id.ToString())); invoice.SetInvoiceItems(lineItems); return CreateInvoice(invoice); }
public void CreateInvoice_WithItemsContainsItems() { var client = Api.ListClients().First(); var options = new InvoiceOptions() { ClientId = client.Id, Subject = "Test Items Invoice", Kind = InvoiceKind.FreeForm }; options.SetInvoiceItems(new List<InvoiceItem>() { new InvoiceItem() { Kind = "Product", Description = "Description 1", Quantity = 1, Amount = 10 }, new InvoiceItem() { Kind = "Product", Description = "Description 2", Quantity = 2, Amount = 10 } }); _toDelete = Api.CreateInvoice(options); Assert.Equal(2, _toDelete.ListLineItems().Count()); }