private static async Task CreateInvoice(IPeaApi api, string clientForeignId) { var clients = await api.GetClientsAsync(); var client = clients.First(x => x.ForeignId == clientForeignId); var now = DateTime.UtcNow; var firstDayOfMonth = new DateTime(now.Year, now.Month, 1); var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); var invoice = new ClientInvoiceCreate { ClientId = client.Id, InvoiceDate = firstDayOfMonth, DueDate = lastDayOfMonth, Currency = CurrencyConstants.Sek, DeliveryDate = firstDayOfMonth, DeliveryType = ClientDeliveryTypeConstants.Email, InvoiceAddress = client.Address, InvoiceEmail = client.Email, YourReference = client.Contact, Notes = "Generated by API", Rows = { new ClientInvoiceRowCreate() { } } }; var result = await api.CreateClientInvoiceAsync(invoice); Console.WriteLine($"Client invoice created: {result.Id}"); }
public async Task <ItemCreated> CreateClientInvoiceAsync(ClientInvoiceCreate item, ClientInvoiceCreateOptions options) { var url = QueryStringUrl.GetUrl("/client/invoice", options.ToQueryStringDictionary()); return(await _httpClient.PutAsync <clientinvoice, ItemCreated>(url, item.ToNative())); }
public Task <ItemCreated> CreateClientInvoiceAsync(ClientInvoiceCreate item) { return(CreateClientInvoiceAsync(item, new ClientInvoiceCreateOptions())); }