Initial commit: EIB processor tool with new landing page preview
Single-tool Flask app (Equals Money -> Workday EIB conversion + audit) plus a new /home-preview landing page in preparation for turning this into a multi-tool platform. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
commit
e4cef1faec
|
|
@ -0,0 +1,9 @@
|
|||
uploads/
|
||||
outputs/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.env
|
||||
*.xlsx
|
||||
*.csv
|
||||
*.pdf
|
||||
.claude/settings.local.json
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN mkdir -p /app/uploads /app/outputs
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["python", "app/main.py"]
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# EIB Processor
|
||||
|
||||
Equals Money → Workday EIB transformer and statement auditor.
|
||||
Built by Undo Designs for Planeterra International Foundation.
|
||||
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
Then open http://localhost:5000
|
||||
|
||||
## What it does
|
||||
|
||||
1. Upload a raw Equals Money export (.xlsx)
|
||||
2. Optionally upload a combined card statement CSV for per-person audit
|
||||
3. Download the processed EIB Excel file
|
||||
|
||||
The audit table appears in the output file four columns after the last EIB column.
|
||||
Each person gets a single MATCHED / REVIEW REQUIRED status based on:
|
||||
|
||||
```
|
||||
sum(EIB Converted Amount) == sum(statement Total debited for rows in EIB)
|
||||
```
|
||||
|
||||
## PDF statement audit (Docling)
|
||||
|
||||
The Docling container starts automatically with Docker Compose.
|
||||
Once it's healthy (check the badge in the top-right of the UI),
|
||||
you can upload a PDF statement instead of the CSV.
|
||||
|
||||
PDF parsing extracts the opening/closing balance summary from page 1
|
||||
of the Equals statement. The Docling health check takes ~60s on first start.
|
||||
|
||||
## Adding new merchants
|
||||
|
||||
If the processor reports unmapped merchants, add them to `MERCHANT_LOOKUP`
|
||||
in `app/main.py` and restart:
|
||||
|
||||
```bash
|
||||
docker compose restart app
|
||||
```
|
||||
|
||||
## Services
|
||||
|
||||
| Service | Port | Description |
|
||||
|----------|-------|------------------------------------|
|
||||
| app | 5000 | Flask web app |
|
||||
| docling | 5001 | Docling PDF parsing service |
|
||||
|
||||
## Volumes
|
||||
|
||||
- `./uploads/` — temporary uploaded files
|
||||
- `./outputs/` — generated EIB Excel files
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,37 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
docling:
|
||||
image: quay.io/docling-project/docling-serve:latest
|
||||
container_name: eib_docling
|
||||
ports:
|
||||
- "127.0.0.1:5001:5001"
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5001/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 60s
|
||||
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: eib_app
|
||||
ports:
|
||||
- "127.0.0.1:8081:8080"
|
||||
volumes:
|
||||
- ./uploads:/app/uploads
|
||||
- ./outputs:/app/outputs
|
||||
environment:
|
||||
- FLASK_ENV=production
|
||||
- DOCLING_URL=http://docling:5001
|
||||
- UPLOAD_FOLDER=/app/uploads
|
||||
- OUTPUT_FOLDER=/app/outputs
|
||||
- PORT=8080
|
||||
- PYTHONUNBUFFERED=1
|
||||
depends_on:
|
||||
docling:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# EIB Processor — How It Works
|
||||
|
||||
**EIB Processor** — a small internal tool built by "Undo Designs" for **Planeterra International Foundation**. It converts a raw **Equals Money** card-spend export into a **Workday EIB** (Expense Import Batch) Excel file, and can cross-check the result against bank/card statements to flag discrepancies before finance re-keys the numbers.
|
||||
|
||||
## Stack & architecture
|
||||
|
||||
- **Backend**: Python 3.11 + Flask (`app/main.py`, single ~1000-line file), pandas/openpyxl for data wrangling and Excel generation.
|
||||
- **Frontend**: one static page (`templates/index.html`, ~800 lines) — a dark navy/cyan-themed single-page UI with drag-and-drop upload zones, no JS framework, plain `fetch()` calls polling a status endpoint for progress.
|
||||
- **PDF parsing**: a second container running **Docling** (`quay.io/docling-project/docling-serve`), called over HTTP to OCR/convert PDF bank statements into markdown.
|
||||
- **Deployment**: `docker-compose.yml` runs two services — `docling` (port 5001, healthchecked) and `app` (Flask, port 8080→8081 on host), the app depends on Docling being healthy first. Uploads/outputs are bind-mounted host volumes.
|
||||
- **Storage**: no database — everything is stateless, file-based (`/uploads`, `/outputs`), single-job global status dict (explicitly documented as a "single-user tool" assumption).
|
||||
|
||||
## Core workflow (`app/main.py`)
|
||||
|
||||
1. **Upload** a raw Equals Money `.xlsx` export.
|
||||
2. **`process_raw()`** classifies each transaction row (Card, Exchange, Cash withdrawal, Fee, Credit, Refund, etc.) using a fairly intricate rules engine that:
|
||||
- Drops non-expense rows (credits, refunds, internal FX "From" legs, auto-exchange).
|
||||
- Collapses ATM cash-withdrawal + FX-exchange + fee row groups into a single clean "Cash withdrawal" / "Cash withdrawal fee" line.
|
||||
- Maps raw merchant description strings to clean names via a hardcoded `MERCHANT_LOOKUP` dict (~50 entries); anything unmapped halts processing and reports back to the UI for the merchant to be added manually.
|
||||
3. **Optional audit**, two modes:
|
||||
- **CSV mode** (`run_audit`): upload a combined card-statement CSV; per cardholder, checks `sum(EIB Converted Amount) == sum(statement Total debited)`.
|
||||
- **PDF mode** (`run_audit_pdf`): upload per-person PDF statements; Docling converts each to markdown, `extract_balances_from_markdown()` parses the opening/credit/debit/closing balance table, and a 4-layer audit runs (raw-vs-PDF totals → EIB value fidelity → structural "every excluded row is zero-impact" check → statement arithmetic identity), producing a much more detailed reconciliation with human-readable failure explanations.
|
||||
4. **`build_excel()`** writes the final `EIB_Processed_<date>.xlsx`, with the audit table appended 4 columns to the right of the EIB columns, color-coded green (MATCHED) / red (REVIEW REQUIRED).
|
||||
5. Frontend polls `/api/process/status` for live progress text/log while processing runs, then offers a download link.
|
||||
|
||||
There's also a diagnostic-only `/api/debug/probe-pdf` endpoint that dumps raw Docling responses to `outputs/_debug_markdown/*.PROBE.json` for troubleshooting extraction logic, unrelated to the main flow.
|
||||
|
||||
## Notable characteristics
|
||||
|
||||
- Heavily domain-specific: the transaction-classification logic encodes many real-world Equals Money quirks (ATM fee/exchange grouping, FX top-up over/under-funding detection, refund matching by description+amount+currency tuples).
|
||||
- No auth, no database — designed as a trusted, local/single-user tool.
|
||||
- `uploads/` currently has dozens of leftover UUID-prefixed files from prior runs (PDFs, CSVs, xlsx) — this is working/scratch data, not part of the app itself.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
flask==3.0.3
|
||||
pandas==2.2.2
|
||||
openpyxl==3.1.2
|
||||
requests==2.32.3
|
||||
werkzeug==3.0.3
|
||||
|
|
@ -0,0 +1,257 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Internal Tools — Undo Designs</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--navy: #0C1A3A;
|
||||
--navy-2: #12244C;
|
||||
--navy-3: #1a2f5e;
|
||||
--navy-4: #0a1428;
|
||||
--cyan: #00D4FF;
|
||||
--cyan-dim: rgba(0,212,255,.12);
|
||||
--cyan-glow: rgba(0,212,255,.06);
|
||||
--blue: #1B8EF8;
|
||||
--blue-dim: rgba(27,142,248,.12);
|
||||
--green: #10D98A;
|
||||
--green-dim: rgba(16,217,138,.12);
|
||||
--red: #F04438;
|
||||
--red-dim: rgba(240,68,56,.12);
|
||||
--amber: #F79009;
|
||||
--w1: rgba(255,255,255,.95);
|
||||
--w2: rgba(255,255,255,.65);
|
||||
--w3: rgba(255,255,255,.35);
|
||||
--w4: rgba(255,255,255,.10);
|
||||
--w5: rgba(255,255,255,.05);
|
||||
--border: rgba(255,255,255,.07);
|
||||
--border-c: rgba(0,212,255,.18);
|
||||
--mono: 'JetBrains Mono', monospace;
|
||||
--disp: 'Space Grotesk', sans-serif;
|
||||
--body: 'Inter', sans-serif;
|
||||
--radius: 10px;
|
||||
}
|
||||
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: var(--body);
|
||||
background: var(--navy-4);
|
||||
color: var(--w1);
|
||||
min-height: 100vh;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: '';
|
||||
position: fixed; inset: 0; pointer-events: none; z-index: 0;
|
||||
background-image: radial-gradient(circle, rgba(0,212,255,.07) 1px, transparent 1px);
|
||||
background-size: 28px 28px;
|
||||
}
|
||||
|
||||
header {
|
||||
position: sticky; top: 0; z-index: 100;
|
||||
background: rgba(12,26,58,.85);
|
||||
backdrop-filter: blur(12px);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0 32px;
|
||||
height: 60px;
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
font-family: var(--disp); font-size: 15px; font-weight: 600;
|
||||
color: var(--w1); text-decoration: none;
|
||||
}
|
||||
.logo-icon {
|
||||
width: 30px; height: 30px;
|
||||
background: linear-gradient(135deg, var(--navy-3), var(--navy-2));
|
||||
border: 1px solid var(--border-c);
|
||||
border-radius: 7px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.logo-icon svg { width: 16px; height: 16px; }
|
||||
.logo span { color: var(--cyan); }
|
||||
|
||||
.header-right { display: flex; align-items: center; gap: 14px; }
|
||||
.tool-count {
|
||||
font-family: var(--mono); font-size: 10px; color: var(--w3);
|
||||
background: var(--w5); border: 1px solid var(--border);
|
||||
padding: 4px 10px; border-radius: 20px;
|
||||
}
|
||||
|
||||
main {
|
||||
position: relative; z-index: 1;
|
||||
flex: 1;
|
||||
max-width: 980px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 56px 24px 80px;
|
||||
}
|
||||
|
||||
.page-title { margin-bottom: 44px; }
|
||||
.eyebrow {
|
||||
font-family: var(--mono); font-size: 10px;
|
||||
letter-spacing: .16em; text-transform: uppercase;
|
||||
color: var(--cyan); margin-bottom: 10px;
|
||||
}
|
||||
.page-title h1 {
|
||||
font-family: var(--disp); font-size: 32px; font-weight: 700;
|
||||
color: var(--w1); line-height: 1.2; margin-bottom: 10px;
|
||||
}
|
||||
.page-title p { font-size: 14px; color: var(--w2); line-height: 1.6; max-width: 560px; }
|
||||
|
||||
.tool-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.tool-card {
|
||||
background: var(--navy-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: border-color .2s, transform .2s, background .2s;
|
||||
}
|
||||
.tool-card:hover {
|
||||
border-color: var(--border-c);
|
||||
background: var(--navy-3);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.tool-card-top { display: flex; align-items: center; gap: 12px; }
|
||||
.tool-icon {
|
||||
width: 40px; height: 40px; flex-shrink: 0;
|
||||
background: linear-gradient(135deg, var(--navy-3), var(--navy-2));
|
||||
border: 1px solid var(--border-c);
|
||||
border-radius: 9px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.tool-icon svg { width: 19px; height: 19px; color: var(--cyan); }
|
||||
.tool-name { font-family: var(--disp); font-size: 15px; font-weight: 600; color: var(--w1); }
|
||||
.tool-tagline { font-family: var(--mono); font-size: 10.5px; color: var(--cyan); margin-top: 2px; }
|
||||
|
||||
.tool-desc { font-size: 12.5px; color: var(--w2); line-height: 1.6; flex: 1; }
|
||||
|
||||
.tool-card-foot {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding-top: 14px; border-top: 1px solid var(--border);
|
||||
}
|
||||
.tool-status { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10px; color: var(--w3); }
|
||||
.status-dot-sm { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }
|
||||
.tool-open {
|
||||
font-family: var(--disp); font-size: 12px; font-weight: 600; color: var(--cyan);
|
||||
display: flex; align-items: center; gap: 4px;
|
||||
}
|
||||
.tool-open svg { width: 12px; height: 12px; transition: transform .2s; }
|
||||
.tool-card:hover .tool-open svg { transform: translateX(2px); }
|
||||
|
||||
.placeholder-card {
|
||||
border-style: dashed;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
color: var(--w3);
|
||||
cursor: default;
|
||||
}
|
||||
.placeholder-card:hover { border-color: var(--border); background: var(--navy-2); transform: none; }
|
||||
.placeholder-card .tool-icon { background: var(--w5); border-color: var(--border); }
|
||||
.placeholder-card .tool-icon svg { color: var(--w3); }
|
||||
.placeholder-card .tool-name { color: var(--w3); }
|
||||
.placeholder-card .tool-desc { font-size: 12px; }
|
||||
|
||||
footer { position: relative; z-index: 1; text-align: center; padding: 20px; font-size: 11px; color: var(--w3); border-top: 1px solid var(--border); }
|
||||
footer a { color: var(--cyan); text-decoration: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<a class="logo" href="/">
|
||||
<div class="logo-icon">
|
||||
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="2" y="2" width="5" height="5" rx="1" stroke="#00D4FF" stroke-width="1.3"/>
|
||||
<rect x="9" y="2" width="5" height="5" rx="1" stroke="#00D4FF" stroke-width="1.3"/>
|
||||
<rect x="2" y="9" width="5" height="5" rx="1" stroke="#00D4FF" stroke-width="1.3"/>
|
||||
<rect x="9" y="9" width="5" height="5" rx="1" stroke="#00D4FF" stroke-width="1.3"/>
|
||||
</svg>
|
||||
</div>
|
||||
Undo <span>Tools</span>
|
||||
</a>
|
||||
<div class="header-right">
|
||||
<div class="tool-count" id="toolCount">1 tool</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="page-title">
|
||||
<div class="eyebrow">Planeterra International Foundation</div>
|
||||
<h1>Internal Tools</h1>
|
||||
<p>A small collection of internal utilities. Pick one to get started.</p>
|
||||
</div>
|
||||
|
||||
<div class="tool-grid">
|
||||
|
||||
<a class="tool-card" href="/">
|
||||
<div class="tool-card-top">
|
||||
<div class="tool-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<path d="M2 4h12M2 8h8M2 12h5"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<div class="tool-name">EIB Processor</div>
|
||||
<div class="tool-tagline">Equals Money → Workday EIB</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tool-desc">
|
||||
Converts raw Equals Money card-spend exports into clean Workday EIB
|
||||
files, with an optional per-cardholder statement audit against CSV
|
||||
or PDF statements.
|
||||
</div>
|
||||
<div class="tool-card-foot">
|
||||
<div class="tool-status"><div class="status-dot-sm"></div>Available</div>
|
||||
<div class="tool-open">
|
||||
Open
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<polyline points="9,6 15,12 9,18"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="tool-card placeholder-card">
|
||||
<div class="tool-card-top">
|
||||
<div class="tool-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<line x1="12" y1="5" x2="12" y2="19"/>
|
||||
<line x1="5" y1="12" x2="19" y2="12"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<div class="tool-name">More tools soon</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tool-desc">New tools will show up here as they're added.</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
Built by <a href="https://undodesigns.com" target="_blank">Undo Designs</a> · Internal Tools
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,788 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>EIB Processor — Undo Designs</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--navy: #0C1A3A;
|
||||
--navy-2: #12244C;
|
||||
--navy-3: #1a2f5e;
|
||||
--navy-4: #0a1428;
|
||||
--cyan: #00D4FF;
|
||||
--cyan-dim: rgba(0,212,255,.12);
|
||||
--cyan-glow: rgba(0,212,255,.06);
|
||||
--blue: #1B8EF8;
|
||||
--blue-dim: rgba(27,142,248,.12);
|
||||
--green: #10D98A;
|
||||
--green-dim: rgba(16,217,138,.12);
|
||||
--red: #F04438;
|
||||
--red-dim: rgba(240,68,56,.12);
|
||||
--amber: #F79009;
|
||||
--w1: rgba(255,255,255,.95);
|
||||
--w2: rgba(255,255,255,.65);
|
||||
--w3: rgba(255,255,255,.35);
|
||||
--w4: rgba(255,255,255,.10);
|
||||
--w5: rgba(255,255,255,.05);
|
||||
--border: rgba(255,255,255,.07);
|
||||
--border-c: rgba(0,212,255,.18);
|
||||
--mono: 'JetBrains Mono', monospace;
|
||||
--disp: 'Space Grotesk', sans-serif;
|
||||
--body: 'Inter', sans-serif;
|
||||
--radius: 10px;
|
||||
}
|
||||
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: var(--body);
|
||||
background: var(--navy-4);
|
||||
color: var(--w1);
|
||||
min-height: 100vh;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: '';
|
||||
position: fixed; inset: 0; pointer-events: none; z-index: 0;
|
||||
background-image: radial-gradient(circle, rgba(0,212,255,.07) 1px, transparent 1px);
|
||||
background-size: 28px 28px;
|
||||
}
|
||||
|
||||
header {
|
||||
position: sticky; top: 0; z-index: 100;
|
||||
background: rgba(12,26,58,.85);
|
||||
backdrop-filter: blur(12px);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0 32px;
|
||||
height: 60px;
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
font-family: var(--disp); font-size: 15px; font-weight: 600;
|
||||
color: var(--w1); text-decoration: none;
|
||||
}
|
||||
.logo-icon {
|
||||
width: 30px; height: 30px;
|
||||
background: linear-gradient(135deg, var(--navy-3), var(--navy-2));
|
||||
border: 1px solid var(--border-c);
|
||||
border-radius: 7px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.logo-icon svg { width: 16px; height: 16px; }
|
||||
.logo span { color: var(--cyan); }
|
||||
|
||||
.header-right { display: flex; align-items: center; gap: 14px; }
|
||||
|
||||
.docling-badge {
|
||||
display: flex; align-items: center; gap: 6px;
|
||||
font-family: var(--mono); font-size: 10px; color: var(--w3);
|
||||
background: var(--w5); border: 1px solid var(--border);
|
||||
padding: 4px 10px; border-radius: 20px;
|
||||
}
|
||||
.docling-dot {
|
||||
width: 6px; height: 6px; border-radius: 50%;
|
||||
background: var(--w3); transition: background .3s;
|
||||
}
|
||||
.docling-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
|
||||
|
||||
main {
|
||||
position: relative; z-index: 1;
|
||||
flex: 1;
|
||||
max-width: 860px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 48px 24px 80px;
|
||||
}
|
||||
|
||||
.page-title { margin-bottom: 40px; }
|
||||
.eyebrow {
|
||||
font-family: var(--mono); font-size: 10px;
|
||||
letter-spacing: .16em; text-transform: uppercase;
|
||||
color: var(--cyan); margin-bottom: 10px;
|
||||
}
|
||||
.page-title h1 {
|
||||
font-family: var(--disp); font-size: 28px; font-weight: 700;
|
||||
color: var(--w1); line-height: 1.2; margin-bottom: 8px;
|
||||
}
|
||||
.page-title p { font-size: 14px; color: var(--w2); line-height: 1.6; max-width: 520px; }
|
||||
|
||||
.step-card {
|
||||
background: var(--navy-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 24px;
|
||||
margin-bottom: 16px;
|
||||
transition: border-color .2s;
|
||||
}
|
||||
.step-card.active { border-color: var(--border-c); }
|
||||
.step-card.complete { border-color: rgba(16,217,138,.2); }
|
||||
.step-card.disabled { opacity: .45; pointer-events: none; }
|
||||
|
||||
.step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
|
||||
.step-num {
|
||||
width: 26px; height: 26px; border-radius: 50%;
|
||||
background: var(--w5); border: 1px solid var(--border);
|
||||
font-family: var(--mono); font-size: 11px; font-weight: 500;
|
||||
color: var(--w3);
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
flex-shrink: 0; transition: all .2s;
|
||||
}
|
||||
.step-card.active .step-num { background: var(--cyan-dim); border-color: var(--border-c); color: var(--cyan); }
|
||||
.step-card.complete .step-num { background: var(--green-dim); border-color: rgba(16,217,138,.3); color: var(--green); }
|
||||
.step-title { font-family: var(--disp); font-size: 14px; font-weight: 600; color: var(--w1); }
|
||||
.step-desc { font-size: 12px; color: var(--w3); margin-top: 1px; }
|
||||
|
||||
.file-zone {
|
||||
border: 1.5px dashed var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: all .2s;
|
||||
position: relative;
|
||||
}
|
||||
.file-zone:hover, .file-zone.drag-over { border-color: var(--cyan); background: var(--cyan-glow); }
|
||||
.file-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
|
||||
.file-zone-icon {
|
||||
width: 36px; height: 36px; margin: 0 auto 10px;
|
||||
background: var(--w5); border-radius: 8px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.file-zone-icon svg { width: 18px; height: 18px; color: var(--w3); }
|
||||
.file-zone-label { font-size: 13px; color: var(--w2); }
|
||||
.file-zone-label strong { color: var(--cyan); }
|
||||
.file-zone-sub { font-size: 11px; color: var(--w3); margin-top: 4px; }
|
||||
.file-chosen { font-family: var(--mono); font-size: 11px; color: var(--green); margin-top: 8px; }
|
||||
|
||||
.audit-toggle { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; cursor: pointer; }
|
||||
.toggle-switch {
|
||||
width: 36px; height: 20px; border-radius: 10px;
|
||||
background: var(--w4); border: 1px solid var(--border);
|
||||
position: relative; transition: background .2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.toggle-switch.on { background: var(--cyan-dim); border-color: var(--border-c); }
|
||||
.toggle-knob {
|
||||
width: 14px; height: 14px; border-radius: 50%;
|
||||
background: var(--w3); position: absolute; top: 2px; left: 2px;
|
||||
transition: all .2s;
|
||||
}
|
||||
.toggle-switch.on .toggle-knob { left: 18px; background: var(--cyan); }
|
||||
.toggle-label { font-size: 13px; color: var(--w2); }
|
||||
|
||||
.audit-options { display: none; }
|
||||
.audit-options.visible { display: block; }
|
||||
|
||||
.radio-group { display: flex; gap: 10px; margin-bottom: 14px; }
|
||||
.radio-opt {
|
||||
flex: 1;
|
||||
border: 1px solid var(--border); border-radius: 8px; padding: 12px;
|
||||
cursor: pointer; transition: all .2s; text-align: center;
|
||||
}
|
||||
.radio-opt.selected { border-color: var(--border-c); background: var(--cyan-dim); }
|
||||
.radio-opt input { display: none; }
|
||||
.radio-opt-label { font-size: 12px; font-weight: 500; color: var(--w2); }
|
||||
.radio-opt.selected .radio-opt-label { color: var(--cyan); }
|
||||
.radio-opt-desc { font-size: 11px; color: var(--w3); margin-top: 3px; }
|
||||
|
||||
.pdf-file-list { list-style: none; margin-top: 10px; }
|
||||
.pdf-file-list li {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 8px 12px; border: 1px solid var(--border);
|
||||
border-radius: 6px; margin-bottom: 6px;
|
||||
font-family: var(--mono); font-size: 11px; color: var(--w2);
|
||||
background: var(--w5);
|
||||
}
|
||||
.pdf-file-list li span { color: var(--cyan); margin-right: 8px; }
|
||||
.pdf-remove { background: none; border: none; cursor: pointer; color: var(--w3); font-size: 14px; padding: 0 4px; transition: color .15s; }
|
||||
.pdf-remove:hover { color: var(--red); }
|
||||
|
||||
.btn {
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
||||
padding: 11px 22px; border-radius: 8px; border: none;
|
||||
font-family: var(--disp); font-size: 13px; font-weight: 600;
|
||||
cursor: pointer; transition: all .2s; text-decoration: none;
|
||||
}
|
||||
.btn-primary { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: var(--navy); }
|
||||
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
|
||||
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; filter: none; }
|
||||
.btn-ghost { background: var(--w5); border: 1px solid var(--border); color: var(--w2); }
|
||||
.btn-ghost:hover { border-color: var(--border-c); color: var(--w1); background: var(--cyan-dim); }
|
||||
.btn-full { width: 100%; }
|
||||
|
||||
/* ── PROGRESS ── */
|
||||
.progress-wrap { display: none; margin-top: 16px; }
|
||||
.progress-wrap.visible { display: block; }
|
||||
.progress-bar-track { height: 3px; background: var(--w5); border-radius: 2px; overflow: hidden; }
|
||||
.progress-bar-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, var(--cyan), var(--blue));
|
||||
border-radius: 2px;
|
||||
width: 0%; transition: width .4s ease;
|
||||
animation: shimmer 1.5s infinite;
|
||||
}
|
||||
@keyframes shimmer { 0% { filter: brightness(1); } 50% { filter: brightness(1.3); } 100% { filter: brightness(1); } }
|
||||
.progress-label-row {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.progress-label { font-family: var(--mono); font-size: 10px; color: var(--w3); }
|
||||
|
||||
.details-toggle {
|
||||
display: flex; align-items: center; gap: 5px;
|
||||
font-family: var(--mono); font-size: 10px; color: var(--cyan);
|
||||
cursor: pointer; user-select: none; background: none; border: none;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
.details-toggle svg { width: 10px; height: 10px; transition: transform .2s; }
|
||||
.details-toggle.open svg { transform: rotate(90deg); }
|
||||
|
||||
.progress-details {
|
||||
display: none;
|
||||
margin-top: 10px;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
background: var(--navy-4);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.progress-details.visible { display: block; }
|
||||
.progress-details::-webkit-scrollbar { width: 6px; }
|
||||
.progress-details::-webkit-scrollbar-thumb { background: var(--w4); border-radius: 3px; }
|
||||
.progress-detail-line {
|
||||
font-family: var(--mono); font-size: 10.5px; color: var(--w2);
|
||||
padding: 3px 0; border-bottom: 1px solid var(--w5);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.progress-detail-line:last-child { border-bottom: none; }
|
||||
.progress-detail-line.ok { color: var(--green); }
|
||||
.progress-detail-line.fail { color: var(--red); }
|
||||
|
||||
/* ── RESULT PANEL ── */
|
||||
.result-panel { display: none; }
|
||||
.result-panel.visible { display: block; }
|
||||
|
||||
.result-card { background: var(--navy-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
|
||||
.result-card.success { border-color: rgba(16,217,138,.25); }
|
||||
.result-card.error { border-color: rgba(240,68,56,.25); }
|
||||
|
||||
.result-header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
|
||||
.result-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
|
||||
.result-icon.ok { background: var(--green-dim); }
|
||||
.result-icon.err { background: var(--red-dim); }
|
||||
.result-icon svg { width: 16px; height: 16px; }
|
||||
.result-title { font-family: var(--disp); font-size: 15px; font-weight: 600; color: var(--w1); }
|
||||
.result-sub { font-size: 12px; color: var(--w3); margin-top: 2px; }
|
||||
|
||||
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
|
||||
.stat-box { background: var(--w5); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
|
||||
.stat-value { font-family: var(--mono); font-size: 18px; font-weight: 500; color: var(--cyan); line-height: 1; }
|
||||
.stat-label { font-size: 10px; color: var(--w3); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; }
|
||||
|
||||
.audit-table-wrap { margin-bottom: 20px; }
|
||||
.section-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--w3); margin-bottom: 10px; }
|
||||
table.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||||
.audit-table th {
|
||||
text-align: left; padding: 8px 12px;
|
||||
font-family: var(--mono); font-size: 9px; letter-spacing: .1em;
|
||||
text-transform: uppercase; color: var(--w3);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.audit-table td { padding: 10px 12px; border-bottom: 1px solid var(--w5); color: var(--w2); }
|
||||
.audit-table tr:last-child td { border-bottom: none; }
|
||||
.audit-table tr:nth-child(even) td { background: var(--w5); }
|
||||
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-family: var(--mono); font-size: 10px; font-weight: 500; }
|
||||
.status-matched { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,217,138,.2); }
|
||||
.status-review { background: var(--red-dim); color: var(--red); border: 1px solid rgba(240,68,56,.2); }
|
||||
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
|
||||
|
||||
.unmapped-panel {
|
||||
background: rgba(247,144,9,.06); border: 1px solid rgba(247,144,9,.2);
|
||||
border-radius: var(--radius); padding: 20px; display: none;
|
||||
}
|
||||
.unmapped-panel.visible { display: block; }
|
||||
.unmapped-title { font-family: var(--disp); font-size: 13px; font-weight: 600; color: var(--amber); margin-bottom: 10px; }
|
||||
.unmapped-list { list-style: none; margin-bottom: 16px; }
|
||||
.unmapped-list li { font-family: var(--mono); font-size: 11px; color: var(--w2); padding: 6px 0; border-bottom: 1px solid var(--w5); }
|
||||
.unmapped-list li:last-child { border-bottom: none; }
|
||||
|
||||
footer { position: relative; z-index: 1; text-align: center; padding: 20px; font-size: 11px; color: var(--w3); border-top: 1px solid var(--border); }
|
||||
footer a { color: var(--cyan); text-decoration: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<a class="logo" href="/">
|
||||
<div class="logo-icon">
|
||||
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2 4h12M2 8h8M2 12h5" stroke="#00D4FF" stroke-width="1.5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
EIB <span>Processor</span>
|
||||
</a>
|
||||
<div class="header-right">
|
||||
<div class="docling-badge">
|
||||
<div class="docling-dot" id="doclingDot"></div>
|
||||
<span id="doclingLabel">Docling</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="page-title">
|
||||
<div class="eyebrow">Planeterra International Foundation</div>
|
||||
<h1>Equals Money → Workday EIB</h1>
|
||||
<p>Upload a raw Equals Money export to generate a clean EIB file. Optionally upload a card statement to run a per-person audit.</p>
|
||||
</div>
|
||||
|
||||
<!-- Step 1: Raw file -->
|
||||
<div class="step-card active" id="step1">
|
||||
<div class="step-header">
|
||||
<div class="step-num">1</div>
|
||||
<div>
|
||||
<div class="step-title">Upload Equals Money Export</div>
|
||||
<div class="step-desc">The raw Excel export from the Equals Money platform</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-zone" id="rawZone">
|
||||
<input type="file" id="rawFile" accept=".xlsx,.xls">
|
||||
<div class="file-zone-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
||||
<polyline points="14,2 14,8 20,8"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="file-zone-label"><strong>Click to browse</strong> or drag & drop</div>
|
||||
<div class="file-zone-sub">Excel file (.xlsx)</div>
|
||||
<div class="file-chosen" id="rawChosen"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 2: Audit -->
|
||||
<div class="step-card disabled" id="step2">
|
||||
<div class="step-header">
|
||||
<div class="step-num">2</div>
|
||||
<div>
|
||||
<div class="step-title">Statement Audit</div>
|
||||
<div class="step-desc">Optional — verify the output against card statements</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="audit-toggle" id="auditToggle">
|
||||
<div class="toggle-switch" id="auditSwitch">
|
||||
<div class="toggle-knob"></div>
|
||||
</div>
|
||||
<div class="toggle-label">Include statement audit</div>
|
||||
</div>
|
||||
|
||||
<div class="audit-options" id="auditOptions">
|
||||
<div class="radio-group">
|
||||
<label class="radio-opt selected" id="optCsv">
|
||||
<input type="radio" name="stmtType" value="csv" checked>
|
||||
<div class="radio-opt-label">CSV Statement</div>
|
||||
<div class="radio-opt-desc">Equals CSV export per person</div>
|
||||
</label>
|
||||
<label class="radio-opt" id="optPdf">
|
||||
<input type="radio" name="stmtType" value="pdf">
|
||||
<div class="radio-opt-label">PDF Statement</div>
|
||||
<div class="radio-opt-desc">Requires Docling container</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="csvUpload">
|
||||
<div class="file-zone" id="stmtZone">
|
||||
<input type="file" id="stmtFile" accept=".csv">
|
||||
<div class="file-zone-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
||||
<polyline points="14,2 14,8 20,8"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="file-zone-label"><strong>Click to browse</strong> or drag & drop</div>
|
||||
<div class="file-zone-sub">Combined CSV statement (all cardholders)</div>
|
||||
<div class="file-chosen" id="stmtChosen"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="pdfUpload" style="display:none">
|
||||
<div class="file-zone" id="pdfZone" style="cursor:default">
|
||||
<input type="file" id="pdfFileInput" accept=".pdf" multiple style="display:none">
|
||||
<div class="file-zone-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
||||
<polyline points="14,2 14,8 20,8"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="file-zone-label" id="pdfDropLabel"><strong>Drop PDF files here</strong> or <span style="color:var(--cyan);cursor:pointer" id="pdfBrowseBtn">browse</span></div>
|
||||
<div class="file-zone-sub">One PDF per cardholder — Docling must be running</div>
|
||||
</div>
|
||||
<ul class="pdf-file-list" id="pdfFileList"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: Process -->
|
||||
<div class="step-card disabled" id="step3">
|
||||
<div class="step-header">
|
||||
<div class="step-num">3</div>
|
||||
<div>
|
||||
<div class="step-title">Process & Download</div>
|
||||
<div class="step-desc">Generate the EIB output file</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-full" id="processBtn" disabled>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<polyline points="13,2 3,14 12,14 11,22 21,10 12,10"/>
|
||||
</svg>
|
||||
Process
|
||||
</button>
|
||||
|
||||
<div class="progress-wrap" id="progressWrap">
|
||||
<div class="progress-bar-track">
|
||||
<div class="progress-bar-fill" id="progressFill"></div>
|
||||
</div>
|
||||
<div class="progress-label-row">
|
||||
<div class="progress-label" id="progressLabel">Processing transactions…</div>
|
||||
<button class="details-toggle" id="detailsToggle">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
|
||||
<polyline points="9,6 15,12 9,18"/>
|
||||
</svg>
|
||||
Details
|
||||
</button>
|
||||
</div>
|
||||
<div class="progress-details" id="progressDetails"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Unmapped merchants -->
|
||||
<div class="unmapped-panel" id="unmappedPanel">
|
||||
<div class="unmapped-title">⚠ Unmapped Merchants</div>
|
||||
<ul class="unmapped-list" id="unmappedList"></ul>
|
||||
<p style="font-size:12px;color:var(--w3)">Add these to <code style="font-family:var(--mono);font-size:11px;color:var(--cyan)">MERCHANT_LOOKUP</code> in <code style="font-family:var(--mono);font-size:11px;color:var(--cyan)">app/main.py</code> and reprocess.</p>
|
||||
</div>
|
||||
|
||||
<!-- Result -->
|
||||
<div class="result-panel" id="resultPanel">
|
||||
<div class="result-card success" id="resultCard">
|
||||
<div class="result-header">
|
||||
<div class="result-icon ok">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="#10D98A" stroke-width="2.5">
|
||||
<polyline points="20,6 9,17 4,12"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<div class="result-title" id="resultTitle">Processing complete</div>
|
||||
<div class="result-sub" id="resultSub"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-box">
|
||||
<div class="stat-value" id="statRows">—</div>
|
||||
<div class="stat-label">EIB Rows</div>
|
||||
</div>
|
||||
<div class="stat-box">
|
||||
<div class="stat-value" id="statUsd">—</div>
|
||||
<div class="stat-label">USD Total</div>
|
||||
</div>
|
||||
<div class="stat-box">
|
||||
<div class="stat-value" id="statPeople">—</div>
|
||||
<div class="stat-label">Cardholders</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="audit-table-wrap" id="auditTableWrap" style="display:none">
|
||||
<div class="section-label">Audit Results</div>
|
||||
<table class="audit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Cardholder</th>
|
||||
<th>Details</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="auditTableBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary btn-full" id="downloadBtn">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
||||
<polyline points="7,10 12,15 17,10"/>
|
||||
<line x1="12" y1="15" x2="12" y2="3"/>
|
||||
</svg>
|
||||
Download EIB File
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
Built by <a href="https://undodesigns.com" target="_blank">Undo Designs</a> · EIB Processor v3
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
const $ = id => document.getElementById(id);
|
||||
|
||||
// ── Docling status ────────────────────────────────────────────────────────────
|
||||
async function checkDocling() {
|
||||
try {
|
||||
const r = await fetch('/api/docling/status');
|
||||
const d = await r.json();
|
||||
$('doclingDot').className = 'docling-dot' + (d.available ? ' online' : '');
|
||||
$('doclingLabel').textContent = d.available ? 'Docling · online' : 'Docling · offline';
|
||||
} catch { $('doclingLabel').textContent = 'Docling · offline'; }
|
||||
}
|
||||
checkDocling();
|
||||
setInterval(checkDocling, 30000);
|
||||
|
||||
// ── File upload handling ──────────────────────────────────────────────────────
|
||||
function setupFileZone(zoneId, inputId, chosenId) {
|
||||
const zone = $(zoneId), input = $(inputId), chosen = $(chosenId);
|
||||
zone.addEventListener('dragover', e => { e.preventDefault(); zone.classList.add('drag-over'); });
|
||||
zone.addEventListener('dragleave', () => zone.classList.remove('drag-over'));
|
||||
zone.addEventListener('drop', e => {
|
||||
e.preventDefault(); zone.classList.remove('drag-over');
|
||||
if (e.dataTransfer.files[0]) {
|
||||
input.files = e.dataTransfer.files;
|
||||
chosen.textContent = e.dataTransfer.files[0].name;
|
||||
onFileChange();
|
||||
}
|
||||
});
|
||||
input.addEventListener('change', () => {
|
||||
if (input.files[0]) chosen.textContent = input.files[0].name;
|
||||
onFileChange();
|
||||
});
|
||||
}
|
||||
|
||||
setupFileZone('rawZone', 'rawFile', 'rawChosen');
|
||||
setupFileZone('stmtZone', 'stmtFile', 'stmtChosen');
|
||||
|
||||
// ── Multi-PDF upload ──────────────────────────────────────────────────────────
|
||||
const pdfFiles = [];
|
||||
|
||||
function renderPdfList() {
|
||||
const list = $('pdfFileList');
|
||||
list.innerHTML = '';
|
||||
pdfFiles.forEach((file, idx) => {
|
||||
const li = document.createElement('li');
|
||||
li.innerHTML = `<span>PDF ${idx + 1}</span>${file.name}
|
||||
<button class="pdf-remove" data-idx="${idx}" title="Remove">✕</button>`;
|
||||
list.appendChild(li);
|
||||
});
|
||||
list.querySelectorAll('.pdf-remove').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
pdfFiles.splice(+btn.dataset.idx, 1);
|
||||
renderPdfList();
|
||||
});
|
||||
});
|
||||
$('pdfDropLabel').innerHTML = pdfFiles.length
|
||||
? `<strong>${pdfFiles.length} PDF${pdfFiles.length > 1 ? 's' : ''} selected</strong> — <span style="color:var(--cyan);cursor:pointer" id="pdfBrowseBtn">add more</span>`
|
||||
: `<strong>Drop PDF files here</strong> or <span style="color:var(--cyan);cursor:pointer" id="pdfBrowseBtn">browse</span>`;
|
||||
document.getElementById('pdfBrowseBtn')?.addEventListener('click', () => $('pdfFileInput').click());
|
||||
}
|
||||
|
||||
$('pdfBrowseBtn').addEventListener('click', () => $('pdfFileInput').click());
|
||||
$('pdfFileInput').addEventListener('change', () => {
|
||||
Array.from($('pdfFileInput').files).forEach(f => {
|
||||
if (!pdfFiles.find(x => x.name === f.name)) pdfFiles.push(f);
|
||||
});
|
||||
$('pdfFileInput').value = '';
|
||||
renderPdfList();
|
||||
});
|
||||
|
||||
const pdfZone = $('pdfZone');
|
||||
pdfZone.addEventListener('dragover', e => { e.preventDefault(); pdfZone.classList.add('drag-over'); });
|
||||
pdfZone.addEventListener('dragleave', () => pdfZone.classList.remove('drag-over'));
|
||||
pdfZone.addEventListener('drop', e => {
|
||||
e.preventDefault(); pdfZone.classList.remove('drag-over');
|
||||
Array.from(e.dataTransfer.files)
|
||||
.filter(f => f.name.endsWith('.pdf'))
|
||||
.forEach(f => { if (!pdfFiles.find(x => x.name === f.name)) pdfFiles.push(f); });
|
||||
renderPdfList();
|
||||
});
|
||||
|
||||
function onFileChange() {
|
||||
const hasRaw = !!$('rawFile').files[0];
|
||||
$('step2').classList.toggle('disabled', !hasRaw);
|
||||
$('step3').classList.toggle('disabled', !hasRaw);
|
||||
$('processBtn').disabled = !hasRaw;
|
||||
if (hasRaw) {
|
||||
$('step1').classList.add('complete');
|
||||
$('step2').classList.add('active');
|
||||
$('step3').classList.add('active');
|
||||
}
|
||||
}
|
||||
|
||||
// ── Audit toggle ──────────────────────────────────────────────────────────────
|
||||
let auditOn = false;
|
||||
$('auditToggle').addEventListener('click', () => {
|
||||
auditOn = !auditOn;
|
||||
$('auditSwitch').classList.toggle('on', auditOn);
|
||||
$('auditOptions').classList.toggle('visible', auditOn);
|
||||
});
|
||||
|
||||
// ── Statement type radio ──────────────────────────────────────────────────────
|
||||
let stmtType = 'csv';
|
||||
$('optCsv').addEventListener('click', () => {
|
||||
stmtType = 'csv';
|
||||
$('optCsv').classList.add('selected');
|
||||
$('optPdf').classList.remove('selected');
|
||||
$('csvUpload').style.display = '';
|
||||
$('pdfUpload').style.display = 'none';
|
||||
});
|
||||
$('optPdf').addEventListener('click', () => {
|
||||
stmtType = 'pdf';
|
||||
$('optPdf').classList.add('selected');
|
||||
$('optCsv').classList.remove('selected');
|
||||
$('pdfUpload').style.display = '';
|
||||
$('csvUpload').style.display = 'none';
|
||||
});
|
||||
|
||||
// ── Collapsible details toggle ────────────────────────────────────────────────
|
||||
let detailsOpen = false;
|
||||
$('detailsToggle').addEventListener('click', () => {
|
||||
detailsOpen = !detailsOpen;
|
||||
$('detailsToggle').classList.toggle('open', detailsOpen);
|
||||
$('progressDetails').classList.toggle('visible', detailsOpen);
|
||||
});
|
||||
|
||||
// ── Progress + live status polling ────────────────────────────────────────────
|
||||
let progressInterval, statusPollInterval;
|
||||
let renderedLogCount = 0;
|
||||
|
||||
function startProgress() {
|
||||
$('progressWrap').classList.add('visible');
|
||||
$('progressDetails').innerHTML = '';
|
||||
renderedLogCount = 0;
|
||||
|
||||
let pct = 0;
|
||||
$('progressFill').style.width = '2%';
|
||||
$('progressLabel').textContent = 'Starting…';
|
||||
|
||||
progressInterval = setInterval(() => {
|
||||
if (pct < 92) {
|
||||
pct += 0.4;
|
||||
$('progressFill').style.width = pct + '%';
|
||||
}
|
||||
}, 150);
|
||||
|
||||
statusPollInterval = setInterval(async () => {
|
||||
try {
|
||||
const r = await fetch('/api/process/status');
|
||||
const d = await r.json();
|
||||
if (d.current) $('progressLabel').textContent = d.current;
|
||||
if (d.log && d.log.length > renderedLogCount) {
|
||||
for (let i = renderedLogCount; i < d.log.length; i++) {
|
||||
const line = document.createElement('div');
|
||||
const text = d.log[i];
|
||||
line.className = 'progress-detail-line' +
|
||||
(text.startsWith('✓') ? ' ok' : text.startsWith('✕') ? ' fail' : '');
|
||||
line.textContent = text;
|
||||
$('progressDetails').appendChild(line);
|
||||
}
|
||||
renderedLogCount = d.log.length;
|
||||
$('progressDetails').scrollTop = $('progressDetails').scrollHeight;
|
||||
}
|
||||
} catch { /* ignore transient poll errors */ }
|
||||
}, 600);
|
||||
}
|
||||
|
||||
function finishProgress() {
|
||||
clearInterval(progressInterval);
|
||||
clearInterval(statusPollInterval);
|
||||
$('progressFill').style.width = '100%';
|
||||
$('progressLabel').textContent = 'Done.';
|
||||
setTimeout(() => $('progressWrap').classList.remove('visible'), 800);
|
||||
}
|
||||
|
||||
// ── Process ───────────────────────────────────────────────────────────────────
|
||||
let lastFilename = '';
|
||||
|
||||
$('processBtn').addEventListener('click', async () => {
|
||||
const raw = $('rawFile').files[0];
|
||||
if (!raw) return;
|
||||
|
||||
$('processBtn').disabled = true;
|
||||
$('resultPanel').classList.remove('visible');
|
||||
$('unmappedPanel').classList.remove('visible');
|
||||
startProgress();
|
||||
|
||||
const fd = new FormData();
|
||||
fd.append('raw_file', raw);
|
||||
|
||||
if (auditOn) {
|
||||
if (stmtType === 'csv' && $('stmtFile').files[0]) {
|
||||
fd.append('stmt_file', $('stmtFile').files[0]);
|
||||
} else if (stmtType === 'pdf' && pdfFiles.length > 0) {
|
||||
pdfFiles.forEach((f, i) => fd.append(`pdf_file_${i}`, f));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const r = await fetch('/api/process', { method: 'POST', body: fd });
|
||||
const d = await r.json();
|
||||
finishProgress();
|
||||
|
||||
if (d.status === 'unmapped') {
|
||||
$('unmappedList').innerHTML = d.unmapped.map(m => `<li>${m}</li>`).join('');
|
||||
$('unmappedPanel').classList.add('visible');
|
||||
$('processBtn').disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.status === 'pdf_parse_failed') {
|
||||
alert(d.message);
|
||||
$('processBtn').disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.status === 'ok') {
|
||||
lastFilename = d.filename;
|
||||
$('statRows').textContent = d.rows;
|
||||
$('statUsd').textContent = '$' + d.totals_usd.toLocaleString('en-US', {minimumFractionDigits:2});
|
||||
$('statPeople').textContent = d.people.length;
|
||||
$('resultSub').textContent = d.people.join(' · ');
|
||||
|
||||
if (d.audit) {
|
||||
$('auditTableWrap').style.display = '';
|
||||
$('auditTableBody').innerHTML = d.audit.map(a => `
|
||||
<tr>
|
||||
<td>${a['Cardholder']}</td>
|
||||
<td style="font-family:var(--mono);font-size:10.5px">${a['Currency Checks'] || ''}</td>
|
||||
<td><span class="status-badge ${a['Audit Status']==='MATCHED'?'status-matched':'status-review'}">
|
||||
<span class="status-dot"></span>${a['Audit Status']}
|
||||
</span></td>
|
||||
</tr>`).join('');
|
||||
} else {
|
||||
$('auditTableWrap').style.display = 'none';
|
||||
}
|
||||
|
||||
$('resultPanel').classList.add('visible');
|
||||
$('step3').classList.add('complete');
|
||||
} else {
|
||||
alert(d.message || d.error || 'Unexpected error');
|
||||
}
|
||||
} catch (e) {
|
||||
finishProgress();
|
||||
alert('Network error: ' + e.message);
|
||||
}
|
||||
$('processBtn').disabled = false;
|
||||
});
|
||||
|
||||
// ── Download ──────────────────────────────────────────────────────────────────
|
||||
$('downloadBtn').addEventListener('click', () => {
|
||||
if (lastFilename) window.location.href = '/api/download/' + encodeURIComponent(lastFilename);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue