Overview
TheInvoiceLine class represents a single line item in an invoice. Each line contains information about the invoiced item, quantity, pricing, applicable taxes, and optional delivery and payment terms. An invoice typically contains multiple invoice lines representing different products or services.
Class Definition
Constructor Parameters
An identifier for this invoice line (e.g., “1”, “2”, “3”)
The quantity of items on this invoice line
The total amount for this invoice line, including allowance charges but net of taxes
The item associated with this invoice line
The price of the item associated with this invoice line
A universally unique identifier for this invoice line
Free-form text conveying information that is not contained explicitly in other structures
The date of this invoice line, used to indicate the point at which tax becomes applicable
The buyer’s accounting cost centre for this invoice line, expressed as a code
The buyer’s accounting cost centre for this invoice line, expressed as text
A code signifying the business purpose for this payment
An indicator that this invoice line is free of charge (true) or not (false). Default is false.
Invoice periods to which this invoice line applies
References to order lines associated with this invoice line
Delivery information associated with this invoice line
Payment terms associated with this invoice line
Tax totals applicable to this invoice line
Terms and conditions of the delivery associated with this invoice line
Methods
setId()
Sets the line identifier.The line ID
setLineExtensionAmount()
Sets the line extension amount (line total before taxes).The line extension amount
The currency code (e.g., “USD”, “EUR”)
getLineExtensionAmount()
Gets the line extension amount.If true, returns the raw string value. If false, returns the UdtAmount instance.
The line extension amount
setTaxTotals()
Sets the array of tax totals for this line.Array of TaxTotal instances
getTaxTotals()
Returns the array of tax totals.Array of tax totals
getPrice()
Returns the price object for this line.The Price object
Usage Examples
The
lineExtensionAmount should be calculated as invoicedQuantity * priceAmount (minus any line-level allowances/charges, before taxes). Always ensure this calculation is accurate to avoid validation errors.Calculation Formula
For a basic invoice line:Related Components
- Item - Item information and classification
- Price - Price per unit
- TaxTotal - Tax calculations for the line
- Delivery - Delivery information
- Invoice - Parent document containing invoice lines
Best Practices
- Sequential IDs: Use sequential line IDs (“1”, “2”, “3”) for clarity
- Currency Consistency: Ensure all amounts use the same currency as the parent invoice
- Quantity Units: Use appropriate unit codes in UdtQuantity (e.g., “EA” for each, “HUR” for hours)
- Tax Calculation: Always validate that tax amounts match the declared tax rates
- Line Totals: Verify that the sum of all line extension amounts equals the invoice’s LegalMonetaryTotal.LineExtensionAmount