def get_chart(self): aggregate_data = group_by_period( Order.objects.valid().since(days=365), "order_date", "month", sum=Sum("taxful_total_price") ) locale = get_current_babel_locale() bar_chart = BarChart(title=_("Sales per Month (last year)"), labels=[ format_date(k, format=get_year_and_month_format(locale), locale=locale) for k in aggregate_data ]) bar_chart.add_data( _("Sales (%(currency)s)") % {"currency": settings.SHOOP_HOME_CURRENCY}, [bankers_round(v["sum"], settings.SHOOP_ORDER_TOTAL_DECIMALS) for v in aggregate_data.values()] ) return bar_chart
def get_chart(self): orders = get_orders_by_currency(self.currency) aggregate_data = group_by_period( orders.valid().since(days=365), "order_date", "month", sum=Sum("taxful_total_price_value") ) locale = get_current_babel_locale() bar_chart = BarChart(title=_("Sales per Month (last year)"), labels=[ format_date(k, format=get_year_and_month_format(locale), locale=locale) for k in aggregate_data ]) bar_chart.add_data( _("Sales (%(currency)s)") % {"currency": self.currency}, [ bankers_round(v["sum"], 2) # TODO: To be fixed in SHOOP-1912 for v in aggregate_data.values() ] ) return bar_chart