---
title: Preview consolidated invoice
slug: import-test-pdf/preview-consolidated-invoice
createdAt: 2025-10-28T16:28:34.272Z
---

{
  "id": "RFW1HyADBInxZ8b6Mv2It",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "/api/v1/sale/consolidate/preview/{consolidatingSale}",
    "servers": [],
    "name": "Preview consolidated invoice",
    "description": "<p>Preview consolidated invoice</p>\n<ul>\n<li>This end point is used to preview the consolidated invoice for selected sales, if no sale is selected all customer sales eligible for consolidation are used - create flow.</li>\n<li>If ID of a already consoliated sale is provided (in body an in path also!!!)then preview of existing consolidated invoice is returned - update flow.</li>\n<li>property notConsolidatedSalesDetails from response Contains details for all customer sales eligibe for consolidation process.</li>\n<li>property selectedSalesDetails from response Contains details of selected sales for consolidation process. null - if the request is made with empty sales_ids parameter</li>\n</ul>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "optional",
          "name": "consolidatingSale",
          "type": "integer",
          "description": "<p>Consolidating sale for with the preview is requested -on preview update</p>"
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "schema": [
            {
              "name": "customer_id",
              "kind": "required",
              "type": "integer",
              "description": "",
              "example": 0
            },
            {
              "name": "consolidating_sale_id",
              "kind": "optional",
              "type": "integer",
              "description": "Required for a existing consolidated invoice preview - on update flow",
              "example": 0
            },
            {
              "name": "invoice_date",
              "kind": "required",
              "type": "string",
              "description": "",
              "example": ""
            },
            {
              "name": "sales_ids",
              "kind": "optional",
              "type": "array",
              "description": "",
              "example": "",
              "itemType": "integer",
              "customType": "integer[]",
              "itemExample": "",
              "itemDefault": ""
            }
          ],
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "successful operation",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "consolidatingSaleId",
                "kind": "optional",
                "type": "integer",
                "description": "Consolidating sale id for existing consolidated invoice preview - on update flow",
                "example": 0
              },
              {
                "name": "invoicePreview",
                "kind": "optional",
                "type": "string",
                "description": "HTML string of invoice",
                "example": ""
              },
              {
                "name": "notConsolidatedSalesDetails",
                "kind": "optional",
                "type": "array",
                "description": "Contains details for all customer sales eligibe for consolidation process",
                "example": "",
                "itemType": "object",
                "customType": "object[]",
                "schema": [
                  {
                    "name": "date",
                    "kind": "optional",
                    "type": "string",
                    "description": "Sale date",
                    "example": ""
                  },
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "Sale record or counter sale id",
                    "example": 0
                  },
                  {
                    "name": "number",
                    "kind": "optional",
                    "type": "string",
                    "description": "Sale record number, null for counter sale",
                    "example": ""
                  },
                  {
                    "name": "pet",
                    "kind": "optional",
                    "type": "object",
                    "description": "Pet details - if sale is from a pet record",
                    "example": "",
                    "schema": []
                  },
                  {
                    "name": "sale",
                    "kind": "optional",
                    "type": "object",
                    "description": "Sale details",
                    "example": "",
                    "schema": []
                  },
                  {
                    "name": "sale_id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "Sale id",
                    "example": 0
                  }
                ]
              },
              {
                "name": "selectedSalesDetails",
                "kind": "optional",
                "type": "array",
                "description": "Contains details of selected sales for consolidation process. null - if the request is made with empty sales_ids parameter",
                "example": "",
                "itemType": "object",
                "customType": "object[]",
                "schema": [
                  {
                    "name": "date",
                    "kind": "optional",
                    "type": "string",
                    "description": "Sale date",
                    "example": ""
                  },
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "Sale record or counter sale id",
                    "example": 0
                  },
                  {
                    "name": "number",
                    "kind": "optional",
                    "type": "string",
                    "description": "Sale record number, null for counter sale",
                    "example": ""
                  },
                  {
                    "name": "pet",
                    "kind": "optional",
                    "type": "object",
                    "description": "Pet details - if sale is from a pet record",
                    "example": "",
                    "schema": []
                  },
                  {
                    "name": "sale",
                    "kind": "optional",
                    "type": "object",
                    "description": "Sale details",
                    "example": "",
                    "schema": []
                  },
                  {
                    "name": "sale_id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "Sale id",
                    "example": 0
                  }
                ]
              }
            ],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "422",
        "description": "Bad request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "undefined",
            "example": "{\"key\":\"labels.consolidate_invoice.errors.sales_have_payments\",\"message\":\"exceptions.labels.consolidate_invoice.errors.sales_have_payments\",\"meta\":[]}",
            "description": "",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url /api/v1/sale/consolidate/preview/{consolidatingSale} \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"customer_id\": 0,\n     \"invoice_date\": \"\"\n     }'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"customer_id\": 0,\n   \"invoice_date\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"/api/v1/sale/consolidate/preview/{consolidatingSale}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/api/v1/sale/consolidate/preview/{consolidatingSale}\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"customer_id\": 0,\n   \"invoice_date\": \"\"\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/api/v1/sale/consolidate/preview/{consolidatingSale}\"\n\npayload = json.dumps({\n   \"customer_id\": 0,\n   \"invoice_date\": \"\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// successful operation\n{\n  \"consolidatingSaleId\": 0,\n  \"invoicePreview\": \"\",\n  \"notConsolidatedSalesDetails\": [\n    {\n      \"date\": \"\",\n      \"id\": 0,\n      \"number\": \"\",\n      \"pet\": {},\n      \"sale\": {},\n      \"sale_id\": 0\n    }\n  ],\n  \"selectedSalesDetails\": [\n    {\n      \"date\": \"\",\n      \"id\": 0,\n      \"number\": \"\",\n      \"pet\": {},\n      \"sale\": {},\n      \"sale_id\": 0\n    }\n  ]\n}"
        },
        {
          "id": "response-1-422",
          "language": "422",
          "code": "// Bad request\n\"{\\\"key\\\":\\\"labels.consolidate_invoice.errors.sales_have_payments\\\",\\\"message\\\":\\\"exceptions.labels.consolidate_invoice.errors.sales_have_payments\\\",\\\"meta\\\":[]}\""
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}