CoolFace
Apppublic

Frknrg/RgReport

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
utils.py65 linesDownload Raw Back to root
1"""2Utility functions shared across the Delivery Report application.3Prevents code duplication and ensures consistency.4"""5 6def normalize_channel(name):7    """8    Normalizes channel names to standard format.9    Used by both Firebase data processing and PostgreSQL queries.10    11    Args:12        name: Channel name string (can be order ID, marketplace ID, etc.)13        14    Returns:15        str: One of 'Eternate', 'Vianisa', or 'Marketplace'16    """17    if not name or name == '' or str(name).strip() == '': 18        return 'Marketplace'19    20    name_str = str(name).strip()21    name_lower = name_str.lower()22    23    # Eternate: E101-xxxxx formatted order numbers or contains 'eternate'24    if name_str.startswith('E101') or 'eternate' in name_lower:25        return 'Eternate'26    27    # Vianisa: Starts with V or contains 'vianisa'28    if name_str.startswith('V') or 'vianisa' in name_lower:29        return 'Vianisa'30    31    # Everything else is Marketplace (Etsy, Amazon, etc.)32    return 'Marketplace'33 34 35def get_category_from_sku(sku):36    """37    Maps product SKU to category.38    39    Args:40        sku: Product SKU string41        42    Returns:43        str: Product category name44    """45    if not sku:46        return "Other"47    48    sku_upper = str(sku).upper()49    50    # Category mappings based on SKU prefix51    if sku_upper.startswith("EG") or sku_upper.startswith("KET"):52        return "Engagement Rings"53    if sku_upper.startswith("WB"):54        return "Wedding Bands"55    if sku_upper.startswith("NK"):56        return "Necklaces"57    if sku_upper.startswith("BR"):58        return "Bracelets"59    if sku_upper.startswith("ER"):60        return "Earrings"61    if sku_upper.startswith("CH"):62        return "Charms"63    64    return "Other Rings"65