Overview
TheTaxTotal class represents the total tax amount for a particular taxation scheme (e.g., VAT, Sales Tax). It contains the aggregated tax amount and detailed breakdowns through tax subtotals. This component is essential in invoices and other commercial documents for calculating and reporting tax obligations.
Class Definition
Constructor Parameters
The total tax amount for a particular taxation scheme (e.g., VAT). This is the sum of all tax subtotals for each tax category within the taxation scheme.
An array of tax subtotals, where each subtotal represents a different tax category or rate. The sum of these subtotals equals the taxAmount.
The rounding amount (positive or negative) added to the calculated tax total to produce the rounded taxAmount
An indicator that this total is recognized as legal evidence for taxation purposes (true) or not (false)
Methods
setTaxAmount()
Sets the total tax amount.The tax amount. Can be a string (e.g., “19.00”) or a UdtAmount instance.
getTaxAmount()
Gets the total tax amount.If true, returns the raw string value. If false, returns the UdtAmount instance.
The tax amount as a string (if raw=true) or UdtAmount instance (if raw=false)
getTaxSubtotals()
Returns the array of tax subtotals.Array of tax subtotals
setTaxSubtotals()
Sets the array of tax subtotals.Array of TaxSubtotal instances. All items must be instances of the TaxSubtotal class.
calculateTotalTaxAmount()
Calculates the total tax amount by summing all tax subtotals.The calculated total tax amount as a number
Usage Examples
The
TaxTotal class is also exported as WithholdingTaxTotal for representing withholding taxes. Both exports reference the same class implementation.Tax Calculation Notes
-
Tax Subtotals: Each
TaxSubtotalrepresents a different tax category or rate. The sum of all subtotal tax amounts should equal thetaxAmountin theTaxTotal. -
Rounding: Use the
roundingAmountfield when you need to adjust for rounding differences between the sum of subtotals and the final tax amount. -
Multiple Tax Rates: When an invoice contains items with different tax rates, create separate
TaxSubtotalinstances for each rate. - Document vs Line Level: Tax totals can appear at both the document level (total taxes for the entire invoice) and at the line level (taxes for individual invoice lines).
Related Components
- TaxSubtotal - Individual tax category breakdowns
- TaxCategory - Tax category information (rate, type)
- TaxScheme - Taxation scheme identifier (VAT, GST, etc.)
- InvoiceLine - Uses tax totals at the line level
- Invoice - Uses tax totals at the document level