Current section
Files
Jump to
Current section
Files
README.md
# ExCius
An Elixir library for generating UBL 2.1 (Universal Business Language) invoices compliant with the Croatian e-Invoice specification (CIUS-2025).
## Features
- Generate UBL 2.1 compliant XML invoices
- Croatian e-Invoice (e-Račun) support
- Comprehensive input validation
- Support for VAT calculations and tax categories
## Installation
Add `ex_cius` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:ex_cius, git: "https://github.com/sa-hr/ex_cius.git", tag: "v0.3.10"}
]
end
```
## Usage
```elixir
params = %{
id: "INV-001",
issue_datetime: "2025-05-01T12:00:00",
currency_code: "EUR",
supplier: %{
oib: "12345678901",
registration_name: "Company A d.o.o.",
postal_address: %{
street_name: "Street 1",
city_name: "Zagreb",
postal_zone: "10000",
country_code: "HR"
},
party_tax_scheme: %{
company_id: "HR12345678901",
tax_scheme_id: "vat"
},
seller_contact: %{
id: "12345678901", # Operator's OIB (HR-BT-5)
name: "Operator1" # Operator's name (HR-BT-4)
}
},
customer: %{
oib: "11111111119",
registration_name: "Company B d.o.o.",
postal_address: %{
street_name: "Street 2",
city_name: "Rijeka",
postal_zone: "51000",
country_code: "HR"
},
party_tax_scheme: %{
company_id: "HR11111111119",
tax_scheme_id: "vat"
}
},
tax_total: %{
tax_amount: "25.00",
tax_subtotals: [
%{
taxable_amount: "100.00",
tax_amount: "25.00",
tax_category: %{
id: "standard_rate",
percent: 25,
tax_scheme_id: "vat"
}
}
]
},
legal_monetary_total: %{
line_extension_amount: "100.00",
tax_exclusive_amount: "100.00",
tax_inclusive_amount: "125.00",
payable_amount: "125.00"
},
invoice_lines: [
%{
id: "1",
quantity: 1.0,
unit_code: "piece",
line_extension_amount: "100.00",
item: %{
name: "Product",
classified_tax_category: %{
id: "standard_rate",
percent: 25,
tax_scheme_id: "vat"
},
commodity_classification: %{
item_classification_code: "73211200",
list_id: "CG"
}
},
price: %{
price_amount: "100.00"
}
}
],
notes: ["Payment due within 30 days"]
}
{:ok, validated_params} = ExCius.RequestParams.new(params)
```
## Supported Enums
### Invoice Type Codes
- `:commercial_invoice` (380)
- `:credit_note` (381)
- `:corrected_invoice` (384)
- `:self_billed_invoice` (389)
- `:invoice_information` (751)
### Tax Categories
- `:standard_rate` (S)
- `:zero_rate` (Z)
- `:exempt` (E)
- `:reverse_charge` (AE)
- `:intra_community` (K)
- `:export` (G)
- `:outside_scope` (O)
Note: The reduced Croatian VAT rates of 13% and 5% should use the `:standard_rate` category with the appropriate percentage.
### Tax Schemes
- `:vat` (VAT)
### Unit Codes
- `:piece` (H87)
### Business Process
- `:billing` (P1)
### Currency
- `:EUR` (EUR)
## License
Copyright (C) 2025 Pametno računovodstvo d.o.o.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
See the [LICENSE](LICENSE) file for details.
## Card payments and already-paid invoices
Card payment codes `48` (bank card), `54` (credit card), and `55` (debit card)
do not require a bank account:
```elixir
payment_method: %{
payment_means_code: "48",
instruction_note: "Plaćeno karticom"
}
```
ExCius does not generate or parse card details (BG-18): no card number,
last digits, holder name, or network identifier is needed. A supplied
`card_account` is rejected rather than silently ignored during generation.
FINA's [BR-51 technical guidance](https://www.fina.hr/ngsite/content/download/3287/85151/1)
requires trailing digits only when BG-18 is supplied. The
[Croatian CIUS specification](https://porezna.gov.hr/fiskalizacija/api/dokumenti/196)
marks that group as optional (0..1).
The card branch emits neither `CardAccount` nor `PayeeFinancialAccount`.
Supplying a bank account alongside a card code is rejected to avoid ambiguous
instructions. Existing non-card payment validation and bank-transfer XML remain
unchanged.
For a normal invoice fully paid before issuance, retain the normal invoice type
and supply consistent totals:
```elixir
legal_monetary_total: %{
line_extension_amount: "100.00",
tax_exclusive_amount: "100.00",
tax_inclusive_amount: "125.00",
prepaid_amount: "125.00",
payable_amount: "0.00"
}
```
`prepaid_amount` is the amount already paid; it does not automatically select
the advance-invoice business process. Partial payment can instead use, for
example, `prepaid_amount: "50.00"` and `payable_amount: "75.00"`.
The payment code and both amounts survive `ExCius.parse_invoice/1`.
The caller remains responsible for correct totals, payment evidence,
fiscalization/eReporting, and choosing the appropriate business process.
This library does not charge cards or mark application invoices paid.