Added some more documentation to ETL scripts
This commit is contained in:
@@ -1,9 +1,44 @@
|
||||
'''
|
||||
Attempting to automatically close invoices in the AS400 using data from Jomar.. weee...
|
||||
AS400 Invoice Interface - Jomar to AS400 Invoice Synchronization
|
||||
|
||||
Created on: 2017-11-20
|
||||
|
||||
@author: Wes
|
||||
|
||||
PURPOSE:
|
||||
Pushes invoice data from Jomar ERP into the AS400 so that invoices can be
|
||||
automatically closed on the AS400 side without manual entry.
|
||||
|
||||
USAGE:
|
||||
python AS400_Invoice_Interface.py <date>
|
||||
|
||||
The date argument (format matching Jomar's RDATLS field) selects which
|
||||
invoices to extract. Typically run daily for the current invoice date.
|
||||
|
||||
PROCESSING LOGIC:
|
||||
1. Extract from Jomar (MSSQL via SQLAlchemy):
|
||||
- Query joins invoice rolls (txuyre01), roll/tag master (TXRYRT00),
|
||||
order header (TXUYUV00), and shipment table (TXUYLS00) to build a
|
||||
row set of: invoice number, invoice line, ticket, AS400 order number,
|
||||
invoiced yards, finished yards, ship date, and invoice date.
|
||||
- Only pulls invoices matching the supplied date.
|
||||
- Excludes FREIGHT items and sales return (SR) lines.
|
||||
|
||||
2. Load into AS400 (pyodbc via iSeries ODBC):
|
||||
- Backs up existing rows from STMDATA.JSIINV to WES.JSIINV_BAK
|
||||
(only when running against production library).
|
||||
- Deletes all current rows from STMDATA.JSIINV (staging table).
|
||||
- Inserts each extracted row into STMDATA.JSIINV.
|
||||
- Rows missing a ticket number, order number, or with non-numeric
|
||||
tickets (e.g. credits) are skipped and collected as exceptions.
|
||||
|
||||
3. Exception handling:
|
||||
- Exception rows are written to a temporary CSV (AII_ERRORS_{date}.csv).
|
||||
- CSV is emailed to RECIPIENTS, then deleted from disk.
|
||||
|
||||
OUTPUT:
|
||||
- STMDATA.JSIINV populated on the AS400 for downstream invoice closure.
|
||||
- Log file at D:\AS400_Invoice_Interface.log
|
||||
- Email alert with exception CSV if any rows were skipped.
|
||||
'''
|
||||
import pyodbc, time, logging, sys, os, StringIO, csv, sqlite3
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
Reference in New Issue
Block a user