class ReportsController < ApplicationController
def monthly_sales
year = params.fetch(:year, Date.current.year).to_i
rows = Order.monthly_sales(year: year)
@report = MonthlySalesReport.new(rows, year: year)
import threading
class MinuteRingBuffer:
def __init__(self, window_minutes=15):
if window_minutes < 1:
-- ROLLUP for hierarchical subtotals
SELECT
COALESCE(category, 'ALL CATEGORIES') AS category,
COALESCE(subcategory, 'ALL SUBCATEGORIES') AS subcategory,
SUM(revenue) AS total_revenue,
COUNT(*) AS order_count
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import Transaction.Category;
from decimal import Decimal
from django.db import models
from django.db.models import F, ExpressionWrapper, DecimalField