81 lines
3.4 KiB
Markdown
81 lines
3.4 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
Sunbury Textile Mills (STM) enterprise data integration platform. Handles inventory synchronization between AS400 and Jomar ERP, EDI document processing (850/810/856/997) with multiple trading partners, and financial integrations.
|
|
|
|
**This is a legacy Python 2 codebase.** Use Python 2 conventions (print statements, `basestring`, `ConfigParser`, etc.).
|
|
|
|
## Running Tests
|
|
|
|
```bash
|
|
python FTP/tests.py
|
|
# or
|
|
python -m unittest FTP.tests
|
|
```
|
|
|
|
Tests cover FTP credential loading, Kravet data processing, and item lookup.
|
|
|
|
## Dependencies
|
|
|
|
Install manually (no requirements.txt):
|
|
```bash
|
|
pip install schedule paramiko SQLAlchemy
|
|
```
|
|
Also requires: pyodbc (with appropriate ODBC drivers for MS SQL Server and IBM AS400).
|
|
|
|
## Production Deployment
|
|
|
|
1. Stop `scheduler.py` running under SUNBURYTEXTILE\Administrator
|
|
2. Delete all `.pyc` files in `\FTP`
|
|
3. `git pull`
|
|
4. Restart `scheduler.py`
|
|
|
|
Failing to stop the scheduler before pulling means old compiled code continues running.
|
|
|
|
## Environment Variables
|
|
|
|
The following environment variables must be set for the scripts to connect to backend systems:
|
|
|
|
| Variable | Used by | Purpose |
|
|
|---|---|---|
|
|
| `AS400_UID` | 8 files (AS400_Invoice_Interface, Jomar_SO_Auto_Close, FTP/ACF_process, dt_cut, mg_418, mg_810, mg_856, mg_997) | AS400/iSeries login username |
|
|
| `AS400_PWD` | same files | AS400/iSeries login password |
|
|
| `JOMAR_DB_UID` | Finished_Goods_Interface.py | SQL Server username for Jomar ERP |
|
|
| `JOMAR_DB_PWD` | Finished_Goods_Interface.py | SQL Server password for Jomar ERP |
|
|
|
|
Additional credentials (FTP/SFTP, email) are loaded at runtime from the SQLite vault at `D:\FTP\ftp.db`.
|
|
|
|
## Architecture
|
|
|
|
### Root-level interfaces
|
|
- **Finished_Goods_Interface.py** — Processes CSV files from AS400 (D:\INTERFACE) into Jomar inventory transactions. Triggered by PowerShell file watcher (`finishedGoodsStart.ps1`).
|
|
- **AS400_Invoice_Interface.py** — Auto-closes invoices in AS400 based on Jomar data. Uses pyodbc (AS400) + SQLAlchemy (Jomar).
|
|
- **Jomar_SO_Auto_Close.py** — Weekly sales order closure automation.
|
|
|
|
### FTP package (`/FTP`)
|
|
Central EDI processing system orchestrated by `scheduler.py` (runs continuously as a scheduled job).
|
|
|
|
**Trading partner modules follow a naming convention: `{partner_code}_{document_type}.py`**
|
|
- **KF** = Kravet, **MF** = Maharam, **MG** = Momentum, **GR** = Glenraven
|
|
- **850** = Purchase Orders (inbound), **810** = Invoices (outbound), **856** = ASN/Ship Notices, **997** = Functional Acknowledgments
|
|
|
|
**Shared utilities:**
|
|
- `download_transmissions.py` — FTP/SFTP credential management and file transfer operations. Credentials stored in SQLite DB (`D:\FTP\ftp.db`, table `ftp_auth`).
|
|
- `alert.py` — HTML email notifications with attachment support.
|
|
- `wf_assignments.py` — Wells Fargo invoice assignment via SFTP to spscommerce.net.
|
|
|
|
### Database connections
|
|
- **Jomar ERP:** `mssql+pyodbc://jsisbprod` (SQLAlchemy)
|
|
- **AS400:** iSeries Access ODBC Driver (pyodbc)
|
|
- **Credentials vault:** SQLite at `D:\FTP\ftp.db`
|
|
|
|
### File system layout (production)
|
|
The codebase assumes `D:` as root. Key paths:
|
|
- `D:\INTERFACE` (+ `\ERRORS`, `\PROCESSED`) — Finished goods CSV staging
|
|
- `D:\FTP\INCOMING` — Inbound EDI documents
|
|
- `D:\FTP\SEND_{KF,MF,MG,WF}` (+ `\SENT`) — Outbound EDI staging per partner
|
|
- `D:\FTP\OLD\{KF,MF,MG,GR}` — Processed document archive
|