File size: 925 Bytes
9218640
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from __future__ import annotations

from datetime import date, timedelta

from .datetime_utils import NO_EXPIRY_DATE, today_in_config_timezone


CATEGORY_RULES = {
    "fresco_preparado": 4,
    "verdura_entera": 30,
    "snack_seco": 180,
    "dulce_sellado": 180,
    "gaseosa_botella": 90,
    "congelado": 120,
    "abarrote_seco": 365,
    "mayonesa_cerrada": 120,
    "sin_caducidad": None,
    "bebida_alcoholica": 270,
}


def list_supported_categories() -> list[str]:
    return sorted(CATEGORY_RULES.keys())


def estimate_expiry_for_category(category: str, base_date: date | None = None) -> str:
    category = (category or "").strip().lower()
    if category not in CATEGORY_RULES:
        return ""

    days = CATEGORY_RULES[category]
    if days is None:
        return NO_EXPIRY_DATE

    base = base_date or date.fromisoformat(today_in_config_timezone())
    return (base + timedelta(days=days)).isoformat()