Skip to content

Query Sales

Keep in mind that in Veri*Factu, deferred delivery is performed, which makes it useful to query the status of the invoice delivery to the administration.
This does not apply to TicketBAI, as delivery is immediate.

Through this entry point, SDH will perform the query of a list of up to 1,000 invoices to obtain information about the status of the invoice both in SDH and in the administration.

Call

The required data for this entry point is the list of invoice series and numbers.

InvoicingClient client = new InvoicingClient();

...
List<IdSalesInvoice> idSalesInvoiceList = new List<IdSalesInvoice>();
idSalesInvoiceList.Add(new IdSalesInvoice() { Series = series, Number = number });
...

Solmicro.DigitalHub.Global.Dtos.SalesInvoiceQueryGroupResult results = client.QuerySales(idSalesInvoiceList);
curl -X POST https://apitest.solmicrosdh.com/v2.0/Invoicing/QuerySales \
--cert /ruta/al/certificado.pfx \
--cert-type P12 \
--pass mypfxpassword \
-H "Content-Type: application/json" \
-H "CompanyId: guid-unico-empresa" \
-H "InstallationId: guid-unico-instalacion" \
-d '[
        {
        "series": "string",
        "number": "string"
        }
    ]'

Result

The endpoint returns an object of type SalesInvoiceQueryGroupResult, which will contain the following information:

  • ResultList: List with the following information:
    • Key corresponding to the Series + Number of the queried invoice.
    • List of SalesInvoiceQueryGroup objects containing the following information:
      • VeriFactuConsultaResult: Status information in Veri*Factu.
      • InvoiceStatusResults: List of InvoiceStatus objects in B2B.

VeriFactuConsultaResult includes the following information:

  • Series: Invoice series.
  • Number: Invoice number.
  • SalesInvoiceId: Unique identifier of the invoice in SDH’s database.
  • DateAndTime: Invoice issue date.
  • Type: Type of invoice.
  • DestinationStateState: If the invoice has been submitted to the administration, the current status of the record for the administration.
  • DestinationStateResponse: If the invoice was submitted to the administration with an error, the error message returned by the administration.
  • DestinationStateErrorCode: If the invoice was submitted to the administration with an error, the error code returned by the administration.
  • DestinationStateDateAndTime:
  • If submitted to the administration → date of the administration’s response.
  • If not submitted → date when SDH processed the invoice.
  • PreviousSeries: Series of the invoice used for chaining.
  • PreviousNumber: Number of the invoice used for chaining.
  • PreviousDateAndTime: Date of the invoice used for chaining.
  • HashType: Invoice fingerprint type.
  • Hash: Invoice fingerprint.
  • UrlQR: Text with the information required to generate the QR.
  • QRBase64: Base64‑encoded text containing the QR image.
  • For the remaining fields, see the response administration services.
if (result is not null)
{
    foreach (var item in result.ResultList)
    {
        string key = item.Key; // Series+Number
        var vf = item.Value.VeriFactuConsultaResult;
        var b2bStatuses = item.Value.InvoiceStatusResults;

        vf.Series
        vf.Number
        vf.SalesInvoiceId
        vf.DateAndTime
        vf.Type
        vf.DestinationStateState
        vf.DestinationStateResponse
        vf.DestinationStateErrorCode
        vf.DestinationStateDateAndTime
        vf.HashType
        vf.Hash
        vf.PreviousSeries
        vf.PreviousNumber
        vf.PreviousDateAndTime
        vf.UrlQR
        vf.QRBase64
        ...

        foreach (var status in b2bStatuses)
        {
            status.Id
            status.StatusType
            ...
        }
    }
}
{
    "resultList": {
        "serie1numero1": {
            "veriFactuConsultaResult": {
                "series": "string",
                "number": "string",
                "salesInvoiceId": "guid",
                "dateAndTime": "datetime",
                "type": integer,
                "destinationStateState": integer,
                "destinationStateResponse": "string",
                "destinationStateErrorCode": "string",
                "destinationStateDateAndTime": "datetime",
                "hashType": "string",
                "hash": "string",
                "previousSeries": "string",
                "previousNumber": "string",
                "previousDateAndTime": "datetime",
                "urlQR": "string",
                "qrBase64": "string"
                ...
            },
            "invoiceStatusResults": [
                {
                    "id": "guid",
                    "statusType": integer,
                    "action": integer,
                    "statusDate": "datetime"
                    ...
                }
            ]
        }
    }
}