DW.get_products_sale (eng) - datawizio/pythonAPI GitHub Wiki

get_products_sale – returns sales by products.

Returns data about sales of chosen products during a given period. Shows the turnover of products during the given period, quantity of sold products, stock, self-cost. The results are grouped by days, weeks, months, and years.

Parameters:

  • products: int,list

    id of the product or a list of ids that will be used for selection.

  • Passing the parameter "sum" as the last element of the list, you'll get an additional column with a sum of the corresponding indicator.

  • categories: int,list

    id of the category or a list of ids that will be used for selection.

  • shops: int,list

    id of the shop or a list of ids that will be used for selection.

  • weekday: int {monday - 0, sunday - 6}

    day of week that will be used for selection.

  • date_from: datetime, str {%Y-%m-%d}

    starting date of selection.

  • date_to: datetime, str {%Y-%m-%d}

    ending date of selection.

If the interval [date_from, date_to] has not been set, last 30 client's days will be used for selection.

If only one parameter has been set, then 30 client's days from selected parameter will be used for selection.

interval: str,{"days","months","weeks","years", default: "days" } depending on the parameter, the results will be grouped by days, weeks, months or years.

  • by: str, list
  •                      {"turnover": turnover,
                         "qty": quantity of sold products,
                         "receipts_qty": quantity of receipts,
                         "profit": profit,
                         "sold_product_value": self cost of sold products,
                         "self_price_per_product":price without extra charge per one unit of product,
                         "price": average price per one unit of product,
                         default:"turnover"}
    
    characteristics that will be used for receiving selection results.
  • show: str,
  •             {"name": <category_name> for names of columns,
                "id": <category_id> for names of columns,
                "both": <category_id>_<category_name> for names of columns,
                default: "name".
  • view_type: raw, represent
  • format of table representation.

    Returns:

    if view_type: raw, than formed table:

    date product qty ...N
    1 by by by by
    2 by by by by
    ...N by by by by

    if view_type: represent, than formed table:

    product 1 product 2 ...product N
    date 1 by by by
    date 2 by by by
    ...date N by by by

    Examples:

    dw = datawiz.DW()
    dw.get_products_sale(products = [2833024, 2286946, 'sum'],by='turnover',
                                  shops = [305, 306, 318, 321], 
                                  date_from = datetime.date(2015, 8, 9), 
                                  date_to = datetime.date(2015, 9, 9),
                                  interval = datawiz.WEEKS)

    Returns turnover data for categories with id [2833024, 2286946], from 9.8.2015 till 9.9.2015 for shops [305, 306, 318, 321], grouped by weeks.

    ⚠️ **GitHub.com Fallback** ⚠️