Accounting Providers
The AI Accountant supports multiple accounting systems through a provider abstraction. Each provider implements IAccountingProvider, allowing the Core API to work identically regardless of the underlying system.
Architecture
Core API (AgentManager)
│
├── IAccountingProvider
│ ├── TripletexProvider ──REST──→ Tripletex API v2
│ └── FikenProvider ──REST──→ Fiken API v2
│
└── Provider resolved per company at runtime
IAccountingProvider Interface
The interface defines all accounting operations the system needs. Each provider implements what it can; unsupported operations return a structured NotSupported result.
Customer Management
| Method | Description | Parameters |
|---|---|---|
CreateCustomer |
Create a new customer | name, organizationNumber?, email?, phoneNumber?, postalAddress? |
UpdateCustomer |
Update customer fields | id, fields to update |
SearchCustomers |
Search by name or org number | query, limit? |
Invoice Operations
| Method | Description | Parameters |
|---|---|---|
CreateInvoice |
Create a customer invoice | customerId, invoiceDate, dueDate, lines[] |
SendInvoice |
Send invoice via email/EHF | invoiceId, sendType |
CreateCreditNote |
Credit an existing invoice | invoiceId, comment |
GetInvoice |
Get invoice by ID | id |
SearchInvoices |
Search invoices | customerId?, isSent?, isOverdue?, dateFrom?, dateTo? |
Supplier Invoice Operations
| Method | Description | Parameters |
|---|---|---|
CreateSupplierInvoice |
Register a supplier invoice | supplierId, invoiceNumber, invoiceDate, dueDate, postings[] |
RegisterPayment |
Register payment on supplier invoice | id, paymentDate, bankAccountId |
SearchSupplierInvoices |
Search supplier invoices | supplierId?, isDue?, isPaid?, dateFrom?, dateTo? |
Supplier Management
| Method | Description | Parameters |
|---|---|---|
CreateSupplier |
Create a new supplier | name, organizationNumber?, bankAccount?, email? |
SearchSuppliers |
Search suppliers | query, organizationNumber? |
Voucher / Journal Entry Operations
| Method | Description | Parameters |
|---|---|---|
CreateVoucher |
Create a general ledger voucher | date, description, postings[] |
SearchVouchers |
Search vouchers | dateFrom, dateTo, description? |
Employee and Salary
| Method | Description | Parameters |
|---|---|---|
GetEmployees |
List active employees | departmentId? |
CreateTravelExpense |
Create a travel expense | employeeId, travelDetails, costs[] |
CreatePayslip |
Create a salary payslip | employeeId, year, month, specifications[] |
GetTimesheetEntries |
Get timesheet data | employeeId?, dateFrom, dateTo |
Ledger Queries
| Method | Description | Parameters |
|---|---|---|
GetLedgerPostings |
Query general ledger | accountFrom?, accountTo?, dateFrom, dateTo |
GetTrialBalance |
Get trial balance | dateFrom, dateTo, departmentId? |
Bank Operations
| Method | Description | Parameters |
|---|---|---|
CreateBankReconciliation |
Reconcile a bank transaction | bankStatementId, matchedInvoiceId?, amount |
GetBankStatements |
Get bank statements | dateFrom, dateTo |
Context / Reference Data
| Method | Description |
|---|---|
GetCompanyInfo |
Company name, org number, fiscal year |
GetChartOfAccounts |
Active accounts with number, name, VAT type |
GetDepartments |
Department list with IDs |
GetVatTypes |
VAT codes and percentages |
Provider Comparison
| Feature | Tripletex | Fiken |
|---|---|---|
| Customer CRUD | Yes | Yes |
| Invoice create/send | Yes | Yes |
| Supplier invoice | Yes | Yes |
| Register payment | Yes | Yes |
| Voucher / journal entry | Yes | Yes |
| Employee management | Yes | No |
| Travel expense | Yes | No |
| Salary / payroll | Yes | No |
| Bank reconciliation | Yes | Limited |
| Ledger queries | Yes | Yes |
| Trial balance | Yes | Yes |
| Department filtering | Yes | No |
| Project tracking | Yes | No |
| EHF (e-invoice) | Yes | Yes |
| Multi-currency | Yes | Limited |
| Auth method | OAuth2 + session tokens | OAuth2 (bearer token) |
| Rate limit | 100 req/s per company | 120 req/min per token |
| Base URL | https://tripletex.no/v2 |
https://api.fiken.no/api/v2 |
| Pricing | Varies by plan | 99 NOK/month |
TripletexProvider
Implements the full IAccountingProvider interface. Tripletex is a comprehensive ERP with deep support for salary, travel expenses, project tracking, and departments.
Authentication: OAuth2 consumer token + employee token, exchanged for session tokens (1-hour TTL, auto-refresh). All API calls use Basic Auth with the session token.
Rate limiting: Token bucket at 80 req/s (below the 100 req/s hard limit), retry with exponential backoff on 429.
Key endpoints: See Tripletex API reference.
FikenProvider
Implements core accounting operations from IAccountingProvider. Fiken is a simpler system focused on invoicing, bookkeeping, and VAT reporting for small businesses.
Authentication: OAuth2 with bearer tokens. Standard authorization code flow.
Rate limiting: 120 requests per minute per access token. Retry with backoff on 429.
Unsupported operations: Employee management, travel expenses, salary/payroll, department filtering, project tracking. These methods return NotSupported and the agent informs the user.
Key endpoints:
| Category | Endpoints |
|---|---|
| Contacts | GET/POST /companies/{companySlug}/contacts |
| Invoices | GET/POST /companies/{companySlug}/invoices |
| Credit Notes | POST /companies/{companySlug}/credit-notes |
| Purchases | GET/POST /companies/{companySlug}/purchases |
| Payments | POST /companies/{companySlug}/payments |
| Journal Entries | GET/POST /companies/{companySlug}/journal-entries |
| Accounts | GET /companies/{companySlug}/accounts |
| Bank Accounts | GET /companies/{companySlug}/bank-accounts |
Error Handling
Both providers translate API errors into structured results:
| Condition | Result | Agent Action |
|---|---|---|
| Validation error (400) | ValidationError with field details |
Fix fields and retry |
| Auth error (401) | AuthError |
Refresh token, retry |
| Not found (404) | NotFound with entity type |
Search for correct entity |
| Business rule violation (422) | BusinessError with message |
Interpret error, adjust approach |
| Rate limited (429) | RateLimited with retry-after |
Wait and retry |
| Unsupported operation | NotSupported with explanation |
Inform user, suggest alternative |
Configuration
Provider selection is per-company, stored in the company configuration:
// Resolved at runtime based on company settings
IAccountingProvider provider = providerFactory.GetProvider(companyId);
// Returns TripletexProvider or FikenProvider