Skip to content

Query Purchases

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<Guid> idPurchasesInvoiceList = new List<Guid>();
idPurchasesInvoiceList.Add(externalReference1);
...
idPurchasesInvoiceList.Add(externalReferencen);
...

Solmicro.DigitalHub.Global.Dtos.InvoiceStatusQueryResult results = client.QueryPurchases(idPurchasesInvoiceList);
curl -X POST https://apitest.solmicrosdh.com/v2.0/Invoicing/QueryPurchases \
--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 '[
        "externalReference1",
        "externalReferencen"
    ]'

Result

B2B

The result will be an object of type InvoiceStatusQueryResult, which will contain the following information:

  • InvoiceStatusResults: List with the following information:
    • External invoice reference.
    • List of objects of type InvoiceStatus.
  • NotFoundExternalReferences: List of identifiers that do not exist in SDH.
foreach (var result in results.InvoiceStatusResults)
{
   string externalReference = item.Key;
   List<InvoiceStatus> statuses = item.Value;

   foreach (var status in statuses)
   {
       status.Id
       status.StatusType
       ...
   }
}
foreach (Guid id_notfound in result.NotFoundExternalReferences)
{
    ...
}
{
    "invoiceStatusResults":
     {
        "referenciaexterna1": [ 
           {
              "id": "guid",
              "statusType": integer,
              "action": integer,
              "statusDate": "datetime",
              ...
           }
        ],
        "referenciaexterna2": [...] 
    },
    "notFoundExternalReferences": [
        "referenciaexterna3",
         ...
    ]
}