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')
| Field | Local | International |
|---|---|---|
swift_bic | Empty or ≤2 chars | Has SWIFT/BIC code |
currency | UZS | USD, 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 UZSinvoice_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
| Currency | Symbol | Decimal Places | Used For |
|---|---|---|---|
| UZS | сум | 2 | Local Uzbekistan clients |
| USD | $ | 2 | International clients (primary) |
| EUR | € | 2 | International 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 detectioncountry— Client countrycompany_name— Used in invoice header
From cdm.jira_applications:
currency— Deal currencydeal_amount— UZS contract valueinvoice_amount— Foreign currency billing amountagreement_number— Referenced in local invoice headeragreement_date— Referenced in local invoice header