- Oracle ERP ROA integration with sales analytics and margin analysis - Excel multi-sheet reports with conditional formatting - PDF executive summaries with charts via ReportLab - Optimized SQL queries (no cartesian products) - Docker support for cross-platform deployment - Configurable alert thresholds for business intelligence 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
86 lines
3.6 KiB
Python
86 lines
3.6 KiB
Python
"""
|
|
Configuration module - reads settings from .env file
|
|
"""
|
|
import os
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
|
|
# Load .env file from the same directory as this script
|
|
env_path = Path(__file__).parent / '.env'
|
|
load_dotenv(env_path)
|
|
|
|
# Oracle connection settings
|
|
ORACLE_CONFIG = {
|
|
'host': os.getenv('ORACLE_HOST', '127.0.0.1'),
|
|
'port': os.getenv('ORACLE_PORT', '1521'),
|
|
'service': os.getenv('ORACLE_SERVICE', 'XEPDB1'),
|
|
'user': os.getenv('ORACLE_USER', 'FIRMA'),
|
|
'password': os.getenv('ORACLE_PASSWORD', 'PAROLA'),
|
|
}
|
|
|
|
# Build DSN string
|
|
def get_dsn():
|
|
return f"{ORACLE_CONFIG['host']}:{ORACLE_CONFIG['port']}/{ORACLE_CONFIG['service']}"
|
|
|
|
# Output settings
|
|
OUTPUT_DIR = Path(os.getenv('OUTPUT_DIR', './output'))
|
|
COMPANY_NAME = os.getenv('COMPANY_NAME', 'Data Intelligence Report')
|
|
|
|
# Ensure output directory exists
|
|
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
# Analysis parameters
|
|
ANALYSIS_MONTHS = 12 # Default: last 12 months
|
|
MIN_SALES_FOR_ANALYSIS = 1000 # Minimum RON to include client in analysis
|
|
LOW_MARGIN_THRESHOLD = 15 # Alert if margin below 15%
|
|
PRICE_VARIATION_THRESHOLD = 20 # Alert if price varies > 20% for same product
|
|
|
|
# Recommendation thresholds for business intelligence
|
|
RECOMMENDATION_THRESHOLDS = {
|
|
# Margin thresholds
|
|
'marja_minima': 15, # % - below this = problem
|
|
'marja_tinta': 20, # % - target margin
|
|
|
|
# Client concentration risk
|
|
'concentrare_top5_max': 60, # % - risk if top 5 clients > 60%
|
|
'concentrare_top1_max': 25, # % - risk if single client > 25%
|
|
|
|
# Financial indicators
|
|
'dso_target': 45, # days - DSO target
|
|
'dso_alert': 60, # days - DSO alert threshold
|
|
'dpo_target': 30, # days - DPO target
|
|
|
|
# Stock indicators
|
|
'stoc_zile_max': 90, # days - slow stock threshold
|
|
'rotatie_minima': 4, # minimum annual rotation
|
|
|
|
# Receivables aging
|
|
'restante_90_procent': 10, # % - max receivables > 90 days
|
|
|
|
# ==========================================================================
|
|
# NEW: Indicatori generali de business (PLAN_INDICATORI_LICHIDITATE_YOY)
|
|
# ==========================================================================
|
|
'grad_indatorare_max': 1.0, # Datorii/Capital propriu - OK sub 1
|
|
'grad_indatorare_alert': 2.0, # Alertă peste 2.0
|
|
'autonomie_financiara_min': 0.5, # Capital propriu/Activ total - OK peste 0.5
|
|
'autonomie_financiara_alert': 0.3, # Alertă sub 0.3
|
|
'rata_datoriilor_max': 0.5, # Datorii/Activ total - OK sub 0.5
|
|
'rata_datoriilor_alert': 0.7, # Alertă peste 0.7
|
|
'marja_neta_min': 5, # % - Profit/Vânzări - OK peste 5%
|
|
'marja_neta_alert': 3, # Alertă sub 3%
|
|
'roa_min': 5, # % - Profit/Activ total - OK peste 5%
|
|
'roa_alert': 2, # Alertă sub 2%
|
|
'rotatia_activelor_min': 1.0, # Vânzări/Activ - OK peste 1.0
|
|
|
|
# ==========================================================================
|
|
# NEW: Indicatori de lichiditate
|
|
# ==========================================================================
|
|
'lichiditate_curenta_min': 1.0, # (Cash+Creanțe+Stoc)/Datorii curente - minim
|
|
'lichiditate_curenta_target': 1.5, # Ținta ideală
|
|
'lichiditate_rapida_min': 0.7, # (Cash+Creanțe)/Datorii curente - minim
|
|
'lichiditate_rapida_target': 1.0, # Ținta ideală
|
|
'cash_ratio_min': 0.1, # Cash/Datorii curente - minim
|
|
'cash_ratio_target': 0.2, # Ținta ideală
|
|
'grad_acoperire_min': 1.0, # (Cash+Încasări 30z)/Datorii 30z - minim
|
|
}
|