JSFiddle - React, Tailwind, and code Playground

by schantanu

HTML

<p>Python Allocation Script</p>

JavaScript

/* #!/usr/bin/env python3
"""
Constrained Cabinet Automation - Inventory Allocation System
Converts Google Apps Script functionality to Python for inventory allocation processing.
"""

import pandas as pd
import json
from datetime import datetime, timedelta
from typing import List, Dict, Any, Tuple
import logging
from dataclasses import dataclass, asdict
from pathlib import Path

# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

@dataclass
class ForecastRecord:
    """Data structure for forecast records"""
    common_id: str
    forecasted_s4_mmid: str
    forecasted_as_item_id: str
    market: str
    market_l3: str
    validity_date: str
    forecast_month_date: str
    quantity: int
    inventory_allocation_quantity: int
    rdc: str
    plant_id: str

@dataclass
class InventoryRecord:
    """Data structure for inventory records"""
    common_id: str
    material_id: str
    plant_id: str
    quantity: int
    quantity_remaining: int

@dataclass
class AllocationRecord:
    """Data structure for flattened allocation records"""
    market: str
    market_l3: str
    plant_id: str
    rdc: str
    common_id: str
    month_to_allocate: str
    total_need_qty: int
    total_allocated_qty: int
    
    # Original forecast quantities for P1, P2, P3
    original_forecast_qty_p1: int
    original_forecast_qty_p2: int
    original_forecast_qty_p3: int
    
    # Accuracy adjusted quantities
    accuracy_adjusted_qty_p1: int
    accuracy_adjusted_qty_p2: int
    accuracy_adjusted_qty_p3: int
    
    # Final adjusted quantities (after constraints)
    final_adjusted_qty_p1: int
    final_adjusted_qty_p2: int
    final_adjusted_qty_p3: int
    
    # Actually allocated quantities
    allocated_qty_p1: int
    allocated_qty_p2: int
    allocated_qty_p3: int
    
    # Validity dates for each period
  ...