Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mdiago/VeriFactu/llms.txt
Use this file to discover all available pages before exploring further.
InvoiceQuery queries the AEAT’s VERI*FACTU invoice registry (ConsultaFactuSistemaFacturacion). You can retrieve issued invoices (sales) or received invoices (purchases) filtered by year and month, with optional pagination. Results are returned as RespuestaConsultaFactuSistemaFacturacion objects that can be converted into a list of Invoice instances.
Namespace
VeriFactu.Business.Operations
Constructor
InvoiceQuery(string partyID, string partyName)
Creates a new query context for a specific tax party.
The seller’s (or buyer’s) NIF / tax identifier. Used as
ObligadoEmision.NIF for sales queries and as Destinatario.NIF for purchase queries.The name corresponding to
partyID. Used as ObligadoEmision.NombreRazon or Destinatario.NombreRazon in the SOAP request header.Propiedades
The NIF / tax identifier provided at construction.
The name provided at construction.
Filtros disponibles
Filters are applied by building aConsultaFactuSistemaFacturacion object with a FiltroConsulta block. The two main query methods (GetSales / GetPurchases) handle the common year + month + pagination pattern. For advanced filtering, use GetRegistro() to obtain a base query object, configure its FiltroConsulta manually, and then call GetDocuments().
| Filter | Source field | How to set |
|---|---|---|
| Year | FiltroConsulta.PeriodoImputacion.Ejercicio | year parameter on GetSales / GetPurchases |
| Month | FiltroConsulta.PeriodoImputacion.Periodo | month parameter (zero-padded to 2 digits) |
| Pagination offset | FiltroConsulta.ClavePaginacion | offset parameter (ClavePaginacion object) |
| Direction (sales/purchases) | Cabecera.ObligadoEmision vs Cabecera.Destinatario | isSales flag on GetRegistro() |
Métodos
GetSales(string year, string month, ClavePaginacion offset = null, X509Certificate2 certificate = null) → RespuestaConsultaFactuSistemaFacturacion
Queries the AEAT for invoices issued by PartyID in the given year and month.
Four-digit year string, e.g.
"2024".Month as a 1- or 2-digit string (e.g.
"1" or "11"). Automatically zero-padded to 2 digits.Optional pagination key returned in a previous response. When provided,
IDEmisorFactura is set to PartyID automatically if it is null.Optional certificate for the HTTPS request. Falls back to the configured system certificate when omitted.
RespuestaConsultaFactuSistemaFacturacion AEAT response object.Throws
FaultException if the AEAT returns a SOAP Fault.
GetPurchases(string year, string month, ClavePaginacion offset = null, X509Certificate2 certificate = null) → RespuestaConsultaFactuSistemaFacturacion
Queries the AEAT for invoices received by PartyID (i.e. where PartyID is the buyer / Destinatario).
Parameters and return value are identical to GetSales.
GetDocuments(ConsultaFactuSistemaFacturacion registro, X509Certificate2 certificate = null) → RespuestaConsultaFactuSistemaFacturacion
Sends a fully custom ConsultaFactuSistemaFacturacion request. Use this when you need to apply filters beyond year/month (e.g. filter by invoice number, buyer NIF, or invoice type) by constructing the FiltroConsulta block manually.
A fully configured
VeriFactu.Xml.Factu.Consulta.ConsultaFactuSistemaFacturacion object. Build one from scratch or start from GetRegistro().Optional certificate for the HTTPS request.
GetRegistro(bool isSales = true) → ConsultaFactuSistemaFacturacion
Returns a base ConsultaFactuSistemaFacturacion object pre-populated with the party header. Use this as a starting point for custom queries passed to GetDocuments().
true (default) places PartyID / PartyName in the ObligadoEmision (issuer / seller) header slot. false places them in Destinatario (recipient / buyer).GetInvoices(RespuestaConsultaFactuSistemaFacturacion queryAeatResponse) → List<Invoice> (static)
Converts a raw AEAT query response into a list of Invoice objects. Each RegistroRespuestaConsultaFactuSistemaFacturacion record is mapped to an Invoice, including type, buyer details, tax breakdown, and rectification information.
A response object returned by
GetSales(), GetPurchases(), or GetDocuments().NotImplementedException if any record in the response has more than one Destinatario (multi-buyer invoices are not yet supported in this conversion helper).
Ejemplo
The AEAT returns results in pages of up to 500 records. If the response includes a non-null
ClavePaginacion, pass it as the offset parameter in a subsequent call to retrieve the next page.