Skip to main content

Financial

The financial model represents the structure of invoices, billing accounts, and payment information in the system. This model enables tracking of financial transactions and customer billing.

Invoice Service

The InvoiceService provides methods to interact with invoice data.

getInvoiceList

Retrieves a paginated list of invoices with optional filtering.

getInvoiceList(
query: GetInvoiceListQuery
): Observable<Invoices.Model.Invoices>

Parameters

ParameterTypeDescription
queryGetInvoiceListQueryQuery parameters for filtering and pagination

Query Parameters

ParameterTypeDescription
offsetnumberNumber of items to skip
limitnumberMaximum number of items to return
paymentStatusPaymentStatusTypeFilter by payment status
typeInvoiceTypeFilter by invoice type
dateFromDateFilter by issued date (from)
dateToDateFilter by issued date (to)
sortstringSorting criteria

Returns

An Observable that emits a paginated list of invoices.

Usage Example

invoiceService
.getInvoiceList({
offset: 0,
limit: 10,
paymentStatus: 'PAYMENT_DUE',
dateFrom: new Date('2023-01-01'),
dateTo: new Date('2023-12-31'),
sort: 'issuedDate:desc',
})
.subscribe((invoices) => {
console.log(`Found ${invoices.total} invoices`);
console.log(`Showing ${invoices.data.length} invoices`);
invoices.data.forEach((invoice) => console.log(invoice.id));
});

getInvoice

Retrieves a specific invoice by ID.

getInvoice(
params: GetInvoiceParams
): Observable<Invoices.Model.Invoice>

Parameters

ParameterTypeDescription
paramsGetInvoiceParamsParameters containing the invoice ID

Returns

An Observable that emits the requested invoice.

Usage Example

invoiceService
.getInvoice({
id: 'inv-123',
})
.subscribe((invoice) => {
console.log(`Invoice ID: ${invoice.id}`);
console.log(`Status: ${invoice.paymentStatus}`);
console.log(`Amount Due: ${invoice.totalAmountDue.value} ${invoice.currency}`);
console.log(`Due Date: ${invoice.paymentDueDate}`);
});

getInvoicePdf

Retrieves a PDF document for a specific invoice.

getInvoicePdf(
params: GetInvoiceParams
): Observable<Buffer>

Parameters

ParameterTypeDescription
paramsGetInvoiceParamsParameters containing the invoice ID

Returns

An Observable that emits a Buffer containing the PDF document.

Usage Example

invoiceService
.getInvoicePdf({
id: 'inv-123',
})
.subscribe((pdfBuffer) => {
// Handle the PDF buffer
// For example, in a controller:
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', `attachment; filename="invoice-${params.id}.pdf"`);
res.setHeader('Content-Length', pdfBuffer.byteLength);
res.end(pdfBuffer);
});

Data Model Structure

The financial model is designed to support invoice management and billing:

  1. Invoices are associated with billing accounts
  2. Invoices have different types and payment statuses
  3. Invoices contain monetary values in specific currencies

This structure allows for:

  • Tracking invoice payment status
  • Supporting different types of financial documents
  • Managing billing accounts for customers
  • Handling multiple currencies and monetary values

The pagination utility allows for efficient retrieval of large collections of invoices, supporting standard pagination parameters like offset and limit, as well as filtering by date range, payment status, and invoice type.

Types

Invoice

Represents a financial document issued to a customer.

FieldTypeDescription
idstringUnique identifier
externalIdstringExternal system identifier
billingAccountIdstringAssociated billing account ID
billingPeriodstringPeriod covered by the invoice
paymentMethodIdstringPayment method identifier
typeInvoiceTypeType of invoice document
paymentStatusPaymentStatusTypeCurrent payment status
issuedDatestringDate when invoice was issued
paymentDueDatestringDate when payment is due
currencyCurrencyCurrency used for the invoice
totalAmountDueMoneyTotal amount due including taxes
totalNetAmountDueMoneyNet amount due excluding taxes
totalAmountPaidMoneyAmount already paid
totalToBePaidMoneyRemaining amount to be paid

InvoiceType

Enumeration of invoice document types.

ValueDescription
STANDARDRegular invoice
PROFORMAPreliminary invoice before final billing
CREDIT_NOTEDocument for refunds or reductions
DEBIT_NOTEDocument for additional charges

PaymentStatusType

Enumeration of payment status values.

ValueDescription
PAYMENT_COMPLETEPayment has been completed
PAYMENT_DECLINEDPayment was declined
PAYMENT_DUEPayment is due but not yet late
PAYMENT_PAST_DUEPayment is overdue

Money

Represents a monetary value.

FieldTypeDescription
valuenumberNumeric value of the amount

Currency

Enumeration of supported currencies.

ValueDescription
USDUnited States Dollar
EUREuro
GBPBritish Pound
PLNPolish Złoty

Invoices

Paginated list of invoices.

type Invoices = Pagination.Paginated<Invoice>;