Skip to main content

International Invoices

The system generates two types of invoices based on client classification: local (Uzbekistan) and international. The detection, template, delivery, and amount source all differ between the two.

Detection Logic

A client is classified as international if either condition is true:

isInternational = (swift_bic?.length > 2) || (currency !== 'UZS')
FieldLocalInternational
swift_bicEmpty or ≤2 charsHas SWIFT/BIC code
currencyUZSUSD, EUR, or other

Both conditions are checked because some clients may have a SWIFT code without a foreign currency, or vice versa.

Template Differences

Local Invoice (UZS)

  • Title: "Акт выполненных работ" (Act of Completed Works)
  • Language: Russian
  • Legal header: Full preamble with agreement number, date, parties, and signer details
  • Company details: Full legal info (TIN, bank account, MFO) for both parties
  • Table: Description, hours, rate, total in UZS
  • Footer: Signatures block for both parties
  • Delivery: Didox.uz e-invoicing system (Phase 4)

International Invoice (USD/EUR)

  • Title: "INVOICE"
  • Language: English
  • Preamble: "ITSM tasks completed under the Contract for the period [period]:" before the line items table
  • Header: Invoice number, date, period, billing/shipping addresses
  • Company details: ProximaOps with SWIFT/BIC, client with their SWIFT/BIC
  • Table: Description, quantity, unit price, amount in foreign currency
  • Footer: Payment terms, bank details for wire transfer
  • Delivery: PDF attachment via email (Phase 4)

Base Amount Source

The base amount for financial calculations depends on client type:

if isInternational && application.InvoiceAmount > 0 {
baseAmount = application.InvoiceAmount // Foreign currency amount
} else {
baseAmount = application.DealAmount // UZS amount (or fallback)
}

Why two fields?

  • deal_amount: The contract value, typically in UZS
  • invoice_amount: The billing amount in the client's currency (USD/EUR)

For international clients, the invoice_amount is the actual amount billed in their currency. The deal_amount may represent the UZS equivalent for internal accounting.

Currency Handling

CurrencySymbolDecimal PlacesUsed For
UZSсум2Local Uzbekistan clients
USD$2International clients (primary)
EUR2International clients (European)

All amounts are stored as DECIMAL(15,2) in PostgreSQL and use shopspring/decimal in Go for exact arithmetic.

ClickHouse Fields Used

From cdm.jira_customers:

  • swift_bic — SWIFT/BIC code for international detection
  • country — Client country
  • company_name — Used in invoice header

From cdm.jira_applications:

  • currency — Deal currency
  • deal_amount — UZS contract value
  • invoice_amount — Foreign currency billing amount
  • agreement_number — Referenced in local invoice header
  • agreement_date — Referenced in local invoice header

Delivery Path (Phase 4)