- 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>
2.9 KiB
2.9 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Data Intelligence Report Generator for ERP ROA (Oracle Database). Generates Excel and PDF business intelligence reports with sales analytics, margin analysis, stock tracking, and alerts.
Commands
Option 1: Virtual Environment (WSL or Windows)
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/WSL
# or: .venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Run report
python main.py
Option 2: Docker (Windows Docker Desktop / Linux)
# Copy and configure environment
cp .env.example .env
# Edit .env with your Oracle credentials
# Run with docker-compose
docker-compose run --rm report-generator
# Or with custom months
docker-compose run --rm report-generator python main.py --months 6
Common Options
# Run with custom period
python main.py --months 6
# Custom output directory
python main.py --output-dir /path/to/output
Oracle Connection from Different Environments
| Environment | ORACLE_HOST value |
|---|---|
| Windows native | 127.0.0.1 |
| WSL | Windows IP (run: cat /etc/resolv.conf | grep nameserver) |
| Docker | host.docker.internal (automatic in docker-compose) |
Architecture
Entry point: main.py - CLI interface, orchestrates query execution and report generation
Data flow:
config.pyloads Oracle connection settings from.envfilequeries.pycontains all SQL queries in aQUERIESdictionary with metadata (title, description, params)main.pyexecutes queries viaOracleConnectioncontext manager, stores results inresultsdictreport_generator.pyreceives dataframes and generates:ExcelReportGenerator: Multi-sheet workbook with conditional formattingPDFReportGenerator: Executive summary with charts via ReportLab
Key patterns:
- Queries use parameterized
:monthsfor configurable analysis period - Sheet order in
main.py:sheet_ordercontrols Excel tab sequence - Charts are generated via matplotlib, converted to images for PDF
Oracle Database Schema
Required views: fact_vfacturi2, fact_vfacturi_detalii, vnom_articole, vnom_parteneri, vstoc, vrul
Filter conventions:
sters = 0excludes deleted recordstip NOT IN (7, 8, 9, 24)excludes returns/credit notes- Account codes:
341,345= own production;301= raw materials
Adding New Reports
- Add SQL query constant in
queries.py - Add entry to
QUERIESdict withsql,params,title,description - Add query name to
sheet_orderlist inmain.py(line ~143) - For PDF inclusion, add rendering logic in
main.py:generate_reports()
Alert Thresholds (in config.py)
- Low margin: < 15%
- Price variation: > 20%
- Slow stock: > 90 days without movement
- Minimum sales for analysis: 1000 RON