Skip to main content

Invoices

Invoices are the primary billing documents issued to customers in the system. Each invoice represents a finalized billing record that contains customer information, line items with detailed charges, tax calculations, and accounting references. Invoices are immutable once issued, ensuring data integrity and providing an accurate historical record of all billing transactions.

Invoice Properties

PropertyTypeDescription
idGUIDUnique identifier
invoiceNumberstringHuman-readable number
invoiceDatedatetimeCreation date
dueDatedatetimePayment due date
statusenumCurrent status
customerIdGUIDCustomer reference
customerNamestringCustomer name (snapshot)
customerEmailstringEmail (snapshot)
billingAddressstringAddress (snapshot)
studyIdGUIDStudy reference
contractIdGUIDContract reference
netAmountdecimalTotal before tax
taxAmountdecimalTotal tax
discountAmountdecimalTotal discounts
grossAmountdecimalFinal amount
receivableAccountIdGUIDReceivable account
notesstringOptional notes
externalReferencestringExternal system reference
createdAtdatetimeCreation timestamp
createdByIdGUIDUser who created (null if system)
updatedAtdatetimeLast update timestamp
updatedByIdGUIDUser who last updated

Invoice Status Values

The invoice status indicates the current state of the invoice in its lifecycle. Draft status means the invoice is being prepared and can still be modified. Issued status indicates the invoice has been finalized and sent to the customer. Canceled status is used when an invoice is voided and should not be paid. Credited status means a reversal invoice has been created to cancel out the original charges.

StatusValueDescription
Draft1Being prepared
Issued2Finalized and sent
Canceled3Voided
Credited4Reversed

Line Item Properties

Each invoice contains one or more line items representing individual charges. Line items include the article being charged, quantity, pricing, tax calculations, and accounting references for proper financial posting.

PropertyTypeDescription
idGUIDUnique identifier
lineNumberintDisplay order
articleIdGUIDArticle reference
articleCodestringArticle code (snapshot)
descriptionstringItem description
quantitydecimalQuantity
unitPricedecimalPrice per unit
netAmountdecimalQuantity × Unit Price
taxAmountdecimalCalculated tax
grossAmountdecimalNet + Tax
taxCodeIdGUIDTax code reference
taxRatedecimalTax rate applied
revenueAccountIdGUIDRevenue account
costCenterIdGUIDCost center

API Endpoints

GET /invoices
GET /invoices/{id}

Response Example

{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"invoiceNumber": "INV-2024-00123",
"invoiceDate": "2024-09-01T00:00:00Z",
"dueDate": "2024-09-30T00:00:00Z",
"status": 2,
"customerId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"customerName": "John Doe",
"customerEmail": "[email protected]",
"billingAddress": "123 Main St, City, 12345",
"studyId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"contractId": "d4e5f6a7-b8c9-0123-def1-234567890123",
"netAmount": 5000.00,
"taxAmount": 950.00,
"discountAmount": 0.00,
"grossAmount": 5950.00,
"receivableAccountId": "e5f6a7b8-c9d0-1234-ef12-345678901234",
"notes": null,
"externalReference": null,
"createdAt": "2024-09-01T10:30:00Z",
"createdById": null,
"updatedAt": null,
"updatedById": null,
"lineItems": [
{
"id": "f6a7b8c9-d0e1-2345-f123-456789012345",
"lineNumber": 1,
"articleId": "a7b8c9d0-e1f2-3456-1234-567890123456",
"articleCode": "TUI-001",
"description": "Tuition Fee - Winter Semester 2024",
"quantity": 1,
"unitPrice": 5000.00,
"netAmount": 5000.00,
"taxAmount": 950.00,
"grossAmount": 5950.00,
"taxCodeId": "b8c9d0e1-f2a3-4567-2345-678901234567",
"taxRate": 19.00,
"revenueAccountId": "c9d0e1f2-a3b4-5678-3456-789012345678",
"costCenterId": "d0e1f2a3-b4c5-6789-4567-890123456789"
}
]
}

Amount Calculations

The invoice system calculates amounts at both the line item and invoice levels using consistent formulas. For each line item, the net amount is calculated by multiplying quantity by unit price. Tax amount is then calculated by applying the tax rate to the net amount using the formula: netAmount × (taxRate / 100). The gross amount for the line item is the sum of net amount and tax amount. At the invoice level, the total net amount is the sum of all line item net amounts, total tax amount is the sum of all line item tax amounts, and the final gross amount is calculated as: netAmount + taxAmount - discountAmount.

Data Snapshots

Invoice data includes snapshots of customer information to ensure historical accuracy. When an invoice is created, the customer's name, email, and billing address are copied to the invoice record. This means that even if the customer's information changes later in the system, the invoice retains the information that was current at the time of billing. The same principle applies to article codes and tax rates, which are stored as snapshots on line items to maintain accurate historical records.