File size: 562 Bytes
b64d2eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Excel sales aggregation."""
from __future__ import annotations

from pathlib import Path
from typing import Optional

import pandas as pd

DRINK_COLS = {"soda", "drink", "drinks", "beverage", "beverages", "coffee", "tea"}


def total_food_sales_usd(path: Path) -> Optional[str]:
    df = pd.read_excel(path)
    numeric = df.select_dtypes(include="number")
    food_cols = [c for c in numeric.columns if str(c).strip().lower() not in DRINK_COLS]
    if not food_cols:
        return None
    total = float(df[food_cols].sum().sum())
    return f"{total:.2f}"