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

get_categories_sale – returns turnover data grouped by categories.

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

Parameters:

  • categories: int,list

    id of the category 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 "sum" column with a sum of the corresponding indicator.

  • 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 the 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.

  • window: days qty that need to calculate turnover rate and availability. {default: date_to - date_from (but not less than 30)}
  • by: str, list
    • {"turnover": turnover,

      "qty": quantity of sold products,

      "profit": profit,

      "sold_product_value": self cost of sold products,

      "receipts_qty": quantity of receipts,

      "turnover_rate": оборотність грошових одиниць,

      "availability_stock": доступність залишків,

      "availability_sale": доступність продажів,

      default:"turnover"}:

      characteristics that will be used for receiving results of selection.

  • 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 represantation.

    Returns:

    if view_type: raw, than formed table:

    date category qty ...N
    1 by by by by
    2 by by by by
    ...N by by by by

    if view_type: represent, than formed table:

    category 1 category 2 category N
    date 1 by by by
    date 2 by by by
    date N by by by

    Examples:

    dw = datawiz.DW()
    dw.get_categories_sale(categories = [50599, 50600, "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 [50599, 50600], from 9-8-2015 till 9-9-2015 for shops [305, 306, 318, 321], grouped by weeks.

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