Invoice Delivery
Phase 3 (PlanFact + R2) is implemented. Phase 4 (Didox + email) is planned.
After approval, invoices are delivered to clients and synced with external systems.
Delivery Flow
Cloudflare R2 Storage (Phase 3) ✅
PDFs are uploaded to Cloudflare R2 on invoice approval (best-effort, before transaction).
| Setting | Value |
|---|---|
| Bucket | proxima-invoices |
| Domain | invoices.prxm.uz |
| Key format | invoices/{year}/{application_key}/Act_{display_number}.pdf |
| SDK | AWS SDK v2 (S3-compatible) |
| Package | internal/services/r2/ |
After upload, the r2_storage_key and r2_public_url fields on the invoice are populated. If upload fails, approval proceeds normally and the PDF remains available from the database.
Frontend shows "Open PDF" link in the Integrations card when r2_public_url is set, or "Not uploaded" otherwise.
PlanFact Sync (Phase 3) ✅
Approved invoices are synced to PlanFact (accounting system) as shipments via an async goroutine (30s timeout):
PlanFact configuration:
- Company ID: 146673 (default)
- API Key: Stored in
INVOICE_PLANFACT_API_KEYenv var - Product IDs:
b78ac753-...(hourly),d9c144af-...(support) — seeded in migration 000007
Manual retry: POST /api/v1/invoices/:id/sync-planfact for approved/sent invoices. Frontend shows "Retry" button in the Integrations card when sync has not completed.
Didox.uz (Phase 4)
Local (UZS) invoices are sent via the Didox.uz e-invoicing platform, required for B2B invoicing in Uzbekistan.
| Field | Value |
|---|---|
| Seller TIN | 309630523 (ProximaOps) |
| Document type | Service act (Акт выполненных работ) |
After submission, the didox_document_id and didox_status fields are populated.
Email Delivery (Phase 4)
International invoices are delivered as PDF email attachments:
- To: Client contact email from ClickHouse (
cdm.jira_contacts) - Subject:
Invoice <display_number> — <period> - Attachment: PDF from R2 storage
- Template: Professional email with payment instructions
Status Updates
| Action | Status Transition |
|---|---|
| Send via Didox | approved → sent |
| Send via email | approved → sent |
| Client accepts (Didox callback) | sent → accepted |
| Client rejects (Didox callback) | sent → rejected |
| Manual acceptance | sent → accepted |
| Payment received | accepted → paid |