Search

getPurchaseReport

Retrieve a purchase report.

API returns a link to CSV file that contains the report.

Sales and Inventory Transfers are also available in report format. See getSalesReport and getInventoryTransferReport.

Input parameters

Parameter nameDescriptionPossible valueRequired
reportTypeReport type. Possible values are "PURCHASE_BY_PRODUCT", "PURCHASE_BY_PRODUCT_GROUP", "PURCHASE_BY_BRAND", "PURCHASE_BY_SUPPLIER", "PURCHASE_BY_SUPPLIER_GROUP", "PURCHASE_BY_INVOICE", "PURCHASE_BY_INVOICE_ROWS". The last option returns all purchase invoice rows, all others aggregate the data by some parameter.String yes
dateStartDate range filter.ISO date (yyyy-mm-dd) yes
dateEndDate range filter.ISO date (yyyy-mm-dd) yes
currencyCodeCurrency code: EUR, USD.

Setting this parameter will return a report where all sums have been re-calculated into specified currency. In other words, this is NOT a filter (for retrieving EUR, USD, etc. purchase invoices separately). In almost all cases, you will want the report in your account default currency, so it is recommended to omit this parameter.

The specified currency must be defined in Erply. If omitted, or an unknown currency code is provided, API uses your default currency.
String (3)
warehouseIDFilter purchase invoices by warehouse (store, location).Integer
productIDFilter the report down to one specific product.Integer
productTypeFilter purchased items by product type. Possible values are "ALL" (all products), "STOCK" (stock products), "NON_STOCK" (non-stock products). By default "ALL".String
productGroupIDFilter purchased items by product group. (Items in subgroups are also included.)Integer
categoryIDFilter purchased items by product category.Integer
priorityGroupIDFilter purchased items by product priority group.Integer
supplierIDFilter purchase invoices by supplier.Integer
brandIDFilter purchased items by brand.Integer
includeServicesSet to 1 if you want to include purchased services. By default, the report will only include products.

To further filter down the report only to items that go into inventory (ie. to exclude non-stock-products, too), set filter productType = "STOCK".
Integer (0 or 1)
getAccountsPayableReportThis setting only makes a difference if you have enabled document types "Purchase invoice-waybill" and "Purchase waybill".

Setting getAccountsPayableReport = 1 will return a report of payable documents (purchase invoice-waybills and purchase invoices). Leaving it to default value will produce a report of documents that change inventory (purchase invoice-waybills and purchase waybills). If you do not have these extra fields, changing the flag will not make any difference.
Integer (0 or 1)

Response

Field nameTypeDescription
reportLinkStringLink to report file.

The report is a CSV file in "latin1" encoding. Fields are separated by semicolons and quoted with double quotes. The file has a header line (with standard column headers, for identifying which field contains which data) and a footer line (with totals). Here is a sample (this is a report by supplier):

"LINE_NUMBER";"SUPPLIER_ID";"NAME";"PURCHASED_QUANTITY";"PURCHASE_VALUE";
"PURCHASE_TAX";"PURCHASE_TOTAL_WITH_TAX";"WAREHOUSE_VALUE"
"1";"4";"Chamberlin Marketing 2";"125301";"418127.61";"83622.68";"501750.29";"418127.61"
"2";"85";"China Imports";"17";"89.2";"17.84";"107.04";"89.2"
"TOTAL";"";"";"125318";"418216.81";"83640.52";"501857.32";"418216.81"


The escape character for literal quote characters is ", like in Microsoft Excel: "This ""word"" is quoted".

First line is a header line. Each column has a specific header identifier and you can use the headers to parse data out of the file. The last line in file is a total line, identified by the word "TOTAL" in line number column.

All reports have the following columns. (Columns are not necessarily in this specific order - here we have adjusted the order for clarity.)
  • LINE_NUMBER
  • PURCHASED_QUANTITY
  • PURCHASE_VALUE
  • PURCHASE_TAX
  • PURCHASE_TOTAL_WITH_TAX
  • WAREHOUSE_VALUE


The rest of the columns depend on selected report type (ie. how data is grouped). In PURCHASE_BY_PRODUCT, each report line corresponds to one product. IN PURCHASE_BY_SUPPLIER, each report line corresponds to one supplier.

Report PURCHASE_BY_PRODUCT additionally has the following columns:
  • PRODUCT_ID
  • CODE
  • NAME

In reports PURCHASE_BY_PRODUCT_GROUP, PURCHASE_BY_BRAND, PURCHASE_BY_SUPPLIER, PURCHASE_BY_SUPPLIER_GROUP, the additional columns are:
  • GROUP_ID, or BRAND_ID, or SUPPLIER_ID, or SUPPLIER_GROUP_ID
  • NAME

Report PURCHASE_BY_INVOICE has the following additional columns:
  • PURCHASE_DOCUMENT_ID
  • SUPPLIER_ID
  • DATE
  • WAREHOUSE_ID
  • INVOICE
  • SUPPLIER

Report PURCHASE_BY_INVOICE_ROWS has the following additional columns:
  • PURCHASE_DOCUMENT_ID
  • SUPPLIER_ID
  • PRODUCT_ID
  • DATE
  • WAREHOUSE_ID
  • INVOICE
  • SUPPLIER
  • CODE
  • NAME