Skip to main content

External Integrations

Proxima Invoice integrates with several external services across different phases.

Integration Map

Green = implemented, Gray = planned.

Gotenberg (Phase 1)

PDF generation service based on Chromium headless browser.

SettingValue
Endpointconvert.prxm.uz
ProtocolHTTPS
APIPOST /forms/chromium/convert/html
Timeout30 seconds
RetryMax 3 attempts
InputHTML file (multipart/form-data)
OutputPDF binary

Configuration

INVOICE_PDF_CONVERTER_URL=https://convert.prxm.uz
INVOICE_PDF_CONVERTER_TIMEOUT=30s

Usage

The backend renders an HTML invoice template using Go's html/template, then sends it to Gotenberg:

POST /forms/chromium/convert/html
Content-Type: multipart/form-data

file=index.html
paperWidth=8.27
paperHeight=11.69
marginTop=0.5
marginBottom=0.5
marginLeft=0.5
marginRight=0.5

PlanFact (Phase 3) ✅

Accounting and financial planning platform. Invoices are synced as "shipments" after approval.

SettingValue
API Basehttps://api.planfact.io/api/v1
AuthX-ApiKey header
Timeout10 seconds
Company ID146673
Packageinternal/services/planfact/

Configuration

INVOICE_PLANFACT_API_KEY=your-api-key
INVOICE_PLANFACT_COMPANY_ID=146673 # default

Sync Flow

On invoice approval, an async goroutine (30s timeout) performs:

Item Building by Deal Type

Deal TypeItems
SUP1x support_product (base fee) + Nx hourly_product (if overtime)
HRNx hourly_product (count=total_hours, value=total_amount)
FPNx hourly_product (count=total_hours, value=total_amount)

Product IDs

ProductIDUsage
Hourly Rateb78ac753-0bbb-41aa-9408-b23700c9f2b4HR, FP, SUP overtime
Monthly Supportd9c144af-dd05-4f68-b136-b37100f12f8aSUP base fee

Manual Retry

If async sync fails (e.g., PlanFact is down), retry manually:

POST /api/v1/invoices/:id/sync-planfact

Only works on approved or sent invoices. Frontend shows a "Retry" button in the Integrations card.

Failure Handling

  • Sync failures are recorded as planfact_sync_failed events in invoice_events
  • Failures do not affect the approval result (async, fire-and-forget)
  • Nil-safe: service disabled when INVOICE_PLANFACT_API_KEY is empty

Cloudflare R2 (Phase 3) ✅

S3-compatible object storage for permanent PDF archival with public URL access.

SettingValue
Bucketproxima-invoices
Domaininvoices.prxm.uz
Key formatinvoices/{year}/{application_key}/Act_{display_number}.pdf
SDKAWS SDK v2 (S3-compatible)
Timeout10 seconds
Packageinternal/services/r2/

Configuration

INVOICE_R2_ACCOUNT_ID=your-cloudflare-account-id
INVOICE_R2_ACCESS_KEY=your-r2-access-key
INVOICE_R2_SECRET_KEY=your-r2-secret-key
INVOICE_R2_BUCKET=proxima-invoices # default
INVOICE_R2_PUBLIC_DOMAIN=invoices.prxm.uz # default

Upload Flow

On invoice approval, before the status transition transaction (best-effort):

  1. Fetch PDF data from the invoice record
  2. Build key: invoices/{year}/{application_key}/Act_{display_number}.pdf
  3. Upload via S3 PutObject to https://{accountID}.r2.cloudflarestorage.com
  4. Store r2_storage_key and r2_public_url on the invoice record
  5. If upload fails: log warning, continue with approval (PDF stays in DB)

Failure Handling

  • R2 upload is best-effort — failures don't block approval
  • PDF remains available from the database (GET /invoices/:id/pdf)
  • Nil-safe: service disabled when R2 credentials are not set
  • Frontend shows "Not uploaded" in the Integrations card when r2_public_url is empty

Didox.uz (Phase 4)

Uzbekistan's e-invoicing platform for B2B transactions. Required for local (UZS) invoices.

SettingValue
PurposeLegal e-invoicing in Uzbekistan
Seller TIN309630523 (ProximaOps)
Document typeService act

Configuration

INVOICE_DIDOX_API_URL=https://api.didox.uz
INVOICE_DIDOX_API_KEY=your-api-key
INVOICE_DIDOX_SELLER_TIN=309630523

Flow

  1. Submit invoice document to Didox API
  2. Receive didox_document_id
  3. Track status via didox_status (pending → accepted/rejected)
  4. Receive webhook callbacks for status updates

Telegram (Phase 2) ✅

Optional notification bot for approval workflow events. Implemented and active.

SettingValue
PurposeNotify managers when invoices are approved
DefaultDisabled (enabled when both env vars are set)
APITelegram Bot API (api.telegram.org)
Timeout15 seconds

Configuration

INVOICE_TELEGRAM_BOT_TOKEN=your-bot-token
INVOICE_TELEGRAM_CHAT_ID=your-chat-id

When both variables are set, the Notifier is initialized at startup and injected into the invoice service. When either is empty, notifications are silently disabled.

Notifications

Currently implemented:

  • Invoice approved: Sends PDF as a document attachment with caption "✅ Invoice APP-001 #42 approved by admin". Falls back to text message if PDF is unavailable or document send fails.

Notification is sent in a background goroutine after approval succeeds — failures are logged but never affect the approval result.

API Methods

MethodTelegram APIContent-Type
SendMessage/bot{token}/sendMessageapplication/json
SendDocument/bot{token}/sendDocumentmultipart/form-data

Timeout and Retry Policy

IntegrationTimeoutMax RetriesRetry On
Gotenberg30s3Network errors, 5xx
PlanFact10s3Network errors, 5xx
R210s3Network errors, 5xx
Didox10s3Network errors, 5xx
Telegram5s2Network errors

Never retry: Validation errors (4xx), authentication errors (401/403).