Skip to main content

Overview

The Details types represent the line items in an invoice, including product/service information, quantities, prices, discounts, and applicable taxes.

Details

Container for all invoice line items.
export type Details = {
  detalle: Detail[];
};
detalle
Detail[]
required
Array of invoice line items. Each item represents a product or service sold

Detail

Individual line item with product/service information.
export type Detail = {
  codigoPrincipal: string;
  codigoAuxiliar: string;
  descripcion: string;
  unidadMedida?: string;
  cantidad: string;
  precioUnitario: string;
  precioSinSubsidio?: string;
  descuento: string;
  precioTotalSinImpuesto: string;
  detallesAdicionales?: AdditionalDetails;
  impuestos: Taxes;
};

Fields

codigoPrincipal
string
required
Primary product/service code. This is typically your internal SKU or product identifier
codigoAuxiliar
string
required
Auxiliary product code. Can be a barcode, alternative SKU, or secondary identifier
descripcion
string
required
Product or service description. This is the text that appears on the invoice
unidadMedida
string
Unit of measure (e.g., "UND" for units, "KG" for kilograms, "M" for meters)
cantidad
string
required
Quantity. Format with up to 6 decimal places (e.g., "50.000000")
precioUnitario
string
required
Unit price. Format with up to 6 decimal places (e.g., "10.500000")
precioSinSubsidio
string
Price without subsidy (for subsidized products)
descuento
string
required
Discount amount for this line item. Use "0.00" if no discount
precioTotalSinImpuesto
string
required
Total price before taxes for this line item. Formula: (cantidad × precioUnitario) - descuento
detallesAdicionales
AdditionalDetails
Additional custom details for this line item. See AdditionalDetails
impuestos
Taxes
required
Taxes applicable to this line item. See Taxes

AdditionalDetail

Custom key-value pair for additional line item information.
export type AdditionalDetail = {
  "@nombre": string;
  "@valor": string;
};
@nombre
string
required
Name/key of the additional detail field (e.g., "Color", "Size", "Warranty")
@valor
string
required
Value of the additional detail field (e.g., "Red", "Large", "1 year")

AdditionalDetails

Container for additional line item details.
export type AdditionalDetails = {
  detAdicional: AdditionalDetail[];
};
detAdicional
AdditionalDetail[]
required
Array of additional detail key-value pairs

Tax

Individual tax applied to a line item.
export type Tax = {
  codigo: string;
  codigoPorcentaje: string;
  tarifa: string;
  baseImponible: string;
  valor: string;
};
codigo
string
required
Tax code:
  • "2" - IVA (VAT)
  • "3" - ICE (Special consumption tax)
  • "5" - IRBPNR (Tax on non-renewable natural resources)
codigoPorcentaje
string
required
Tax rate code. For IVA:
  • "0" - 0% IVA
  • "2" - 12% IVA
  • "3" - 14% IVA
  • "6" - No Objeto de Impuesto (Not subject to tax)
  • "7" - Exento de IVA (Exempt from VAT)
  • "8" - IVA diferenciado (Differentiated VAT)
For ICE, see table 18 of the electronic receipts technical sheet
tarifa
string
required
Tax rate percentage (e.g., "12" for 12% VAT, "0" for 0% VAT)
baseImponible
string
required
Taxable base amount (usually the precioTotalSinImpuesto)
valor
string
required
Tax amount. Formula: baseImponible × (tarifa / 100)

Taxes

Container for all taxes on a line item.
export type Taxes = {
  impuesto: Tax[];
};
impuesto
Tax[]
required
Array of taxes. Most line items will have at least one tax (IVA). Some items may have multiple taxes (e.g., IVA + ICE)

Usage Example

import { Details, Detail } from 'open-factura';

const details: Details = {
  detalle: [
    {
      codigoPrincipal: "PROD-001",
      codigoAuxiliar: "7890123456789",
      descripcion: "Laptop Dell Inspiron 15",
      unidadMedida: "UND",
      cantidad: "2.000000",
      precioUnitario: "500.000000",
      descuento: "50.00",
      precioTotalSinImpuesto: "950.00", // (2 × 500) - 50
      detallesAdicionales: {
        detAdicional: [
          { "@nombre": "Color", "@valor": "Negro" },
          { "@nombre": "RAM", "@valor": "16GB" },
          { "@nombre": "Almacenamiento", "@valor": "512GB SSD" }
        ]
      },
      impuestos: {
        impuesto: [
          {
            codigo: "2", // IVA
            codigoPorcentaje: "2", // 12%
            tarifa: "12",
            baseImponible: "950.00",
            valor: "114.00" // 950 × 0.12
          }
        ]
      }
    },
    {
      codigoPrincipal: "SVC-001",
      codigoAuxiliar: "SVC-INSTALL",
      descripcion: "Servicio de instalación y configuración",
      unidadMedida: "SRV",
      cantidad: "1.000000",
      precioUnitario: "50.000000",
      descuento: "0.00",
      precioTotalSinImpuesto: "50.00",
      impuestos: {
        impuesto: [
          {
            codigo: "2",
            codigoPorcentaje: "2",
            tarifa: "12",
            baseImponible: "50.00",
            valor: "6.00"
          }
        ]
      }
    }
  ]
};

Notes

  • Each line item must have at least one tax defined in the impuestos array
  • The precioTotalSinImpuesto should equal (cantidad × precioUnitario) - descuento
  • Quantity and unit price support up to 6 decimal places for precision
  • Additional details are optional but useful for providing extra product information
  • The sum of all precioTotalSinImpuesto values should equal the totalSinImpuestos in InvoiceInfo

Build docs developers (and LLMs) love