예제 #1
0
        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}");
        }
예제 #2
0
        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()));
        }
예제 #3
0
 public Task <ItemCreated> CreateClientInvoiceAsync(ClientInvoiceCreate item)
 {
     return(CreateClientInvoiceAsync(item, new ClientInvoiceCreateOptions()));
 }