This is archived as of 12.08.2024. You can find the newest version here
.NET library for the accounting software lexoffice
Lexoffice.NET does currently support the following lexoffice API endpoints:
- Invoices Endpoint
- Vouchers Endpoint
- Filter and group functionality for invoices
To use this library you have to generate an API Key for your lexoffice Account.
You can generate an API Key here. If you have any problems getting the key you can follow the steps in these instructions by lexoffice.
First you have to create a new instance of LexofficeService with your API token like this:
var token = "Your-Api-Token";
var lexofficeService = new LexofficeService(token);
var vouchers = await lexOfficeService.GetAllInvoiceVouchersAsync();
To get all invoices all vouchers have to be loaded first. Then the invoice can be queried for each voucher like this:
var vouchers = await lexOfficeService.GetAllInvoiceVouchersAsync();
var invoices = await lexOfficeService.GetInvoicesAsync(vouchers);
Lexoffice.NET also provides filter and group functionality to allow for easy statistical analysis of invoices. The following code examples assume that you have already loaded all invoices.
The following code will sum the revenue for each employee for a given customer in a given year
// Extract all the lines from each invoice
var invoiceItems = invoices.GetInvoiceItems();
// Group each line by year, customer and employee. Sum the revenue
var customerEmployeeRevenueData = CustomerEmployeeRevenueData.FromInvoiceItems(invoiceItems.ToList());
var groupedCustomerEmployeeRevenueData = customerEmployeeRevenueData.GroupByCustomerAndEmployee();
The library offers 3 filters to more easily work with CustomerEmployeeRevenueData:
- YearFilter
- EmployeeFilter
- CustomerFilter
You can use and combine these filters for detailed analyzations. In this example we want the revenue John
made for Example Ltd.
in 2020
:
var filters = new List<IFilterCustomerEmployeeRevenueData>
{
new EmployeeFilter("John"),
new CustomerFilter("Example Ltd."),
new YearFilter("2020")
};
var filteredData = groupedCustomerEmployeeRevenueData.ApplyAllFilters(filters);