To post an invoice you must use the InvoiceAPI’s PostInvoice method.
Below is an example of invoicing an order with order number 55.
// Goal: Invoice an order with order number: 55
// Smart way to get a specific order
var order = new DebtorOrderClient { OrderNumber = 55 };
await crud.Read(order);
// Get all orderlines on the order using a master query
var orderLines = await crud.Query<DebtorOrderLineClient>(order);
// Initialize invoice api
var iapi = new InvoiceAPI(crud);
// Post Invoice
var result = await iapi.PostInvoice(
order, // The order
orderLines, // The order lines of the order
DateTime.Now, // The DateTime of the invoice
0, // The invoice number. 0 means auto generate invoice number
false); // Simulation false. Actually invoice the orderNote that in order to post/create an invoice, you must do it from an order with order lines.
In a scenario where you must import invoices from a CSV file (or similar), you must create orders with order lines first and then invoice them.