# Romania e-Factura Generator (UBL CIUS-RO + ANAF data) (`switchertheone/efactura-generator`) Actor

Turn simple JSON into ANAF-ready e-Factura XML (UBL 2.1, CIUS-RO): parties filled from ANAF by CUI, totals and VAT computed, BNR exchange rate for EUR/USD invoices, every invoice validated before it is returned.

- **URL**: https://apify.com/switchertheone/efactura-generator.md
- **Developed by:** [Alex Constantin](https://apify.com/switchertheone) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $50.00 / 1,000 invoice generateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Romania e-Factura Generator (UBL CIUS-RO + ANAF data)

Create **ANAF-ready e-Factura XML** (UBL 2.1, CIUS-RO 1.0.9) from simple JSON. For the seller and buyer a CUI is
enough: name, Trade Register number, address, ISO county code, Bucharest sector and VAT status come from ANAF.
Totals and VAT are computed, and **every invoice passes the official validation before it is returned**.

For developers, ERP integrations and AI agents that need to issue Romanian e-invoices without learning UBL.

### What it does

- Parties from ANAF by CUI (PlatitorTvaRest), any field you give overrides ANAF
- Lines: name, quantity, unit (`buc`, `ore`, `kg`… mapped to UN/ECE codes), price without VAT, VAT rate
- Net per line, VAT per rate, rounding as the rules expect (BR-CO-10…17)
- `TVA la încasare` note added automatically when the seller is registered for VAT on collection
- Warning when a party is **inactive** at ANAF (VAT may not be deductible)
- Non-RON invoices (`currency: "EUR"`): BNR exchange rate of the issue date (or your `exchange_rate`), VAT also
  declared in RON (BR-RO-030)
- VAT categories S, Z, E, AE, K, G, O (non-VAT seller → O)

### Input

```json
{
  "invoices": [{
    "number": "FCT-0001",
    "issue_date": "2026-11-01",
    "due_date": "2026-12-01",
    "seller": {"cui": "RO12345678"},
    "buyer": {"cui": "RO14399840"},
    "payment": {"iban": "RO49AAAA1B31007593840000"},
    "lines": [{"name": "Servicii consultanta", "quantity": 10, "unit": "ore", "price": 150, "vat_rate": 21}]
  }]
}
```

### Output

One dataset row per invoice with `valid`, `xml`, `totals` (`without_vat`, `with_vat`, `payable`), `warnings`,
the filled-in `seller` and `buyer`; each XML is also saved in the run's key-value store (`xml_key`), ready to
upload to SPV.

### Pricing (pay per event)

| Event | Price | When |
|---|---|---|
| Invoice generated | $0.05 | a valid e-Factura XML was returned |

Not charged: bad input (the row says what is missing), unknown CUIs without explicit data, outages.

### Use it from an AI agent

With Apify's MCP server (`https://mcp.apify.com`) in Claude, Cursor or VS Code, ask *"make an e-Factura from
RO… to RO… for 10 hours of consulting at 150 lei + VAT"*: the agent fills the JSON and runs this Actor.

### Data

Invoice data is sent over HTTPS to the author's service in the EU, used to build the XML and not stored. Company
data is public ANAF data, cached up to 24 hours.

**Related:** e-Factura Validator (check and auto-fix existing XML), Romanian Company Lookup by CUI (ANAF).

# Actor input Schema

## `invoices` (type: `array`):

Each invoice: number, issue_date (YYYY-MM-DD), due_date, seller and buyer ({"cui": "RO…"} or name, vat_id, reg_com, street, city, county as RO-XX, postal_code), lines (name, quantity, unit such as buc/ore/kg, price without VAT, vat_rate such as 21 or 11), optional payment.iban, note, currency (RON default; EUR/USD use the BNR rate of the issue date unless exchange_rate is given), type_code (380 invoice, default; 384 corrected invoice; 389 self-billed; 751 accounting information).

## Actor input object example

```json
{
  "invoices": [
    {
      "number": "FCT-0001",
      "issue_date": "2026-11-01",
      "due_date": "2026-12-01",
      "seller": {
        "name": "Furnizor Test SRL",
        "vat_id": "RO1234567",
        "reg_com": "J12/1234/2020",
        "street": "Strada Exemplu 1",
        "city": "Cluj-Napoca",
        "county": "RO-CJ"
      },
      "buyer": {
        "cui": "RO14399840"
      },
      "payment": {
        "iban": "RO49AAAA1B31007593840000"
      },
      "lines": [
        {
          "name": "Servicii consultanta",
          "quantity": 10,
          "unit": "ore",
          "price": 150,
          "vat_rate": 21
        }
      ]
    }
  ]
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "invoices": [
        {
            "number": "FCT-0001",
            "issue_date": "2026-11-01",
            "due_date": "2026-12-01",
            "seller": {
                "name": "Furnizor Test SRL",
                "vat_id": "RO1234567",
                "reg_com": "J12/1234/2020",
                "street": "Strada Exemplu 1",
                "city": "Cluj-Napoca",
                "county": "RO-CJ"
            },
            "buyer": {
                "cui": "RO14399840"
            },
            "payment": {
                "iban": "RO49AAAA1B31007593840000"
            },
            "lines": [
                {
                    "name": "Servicii consultanta",
                    "quantity": 10,
                    "unit": "ore",
                    "price": 150,
                    "vat_rate": 21
                }
            ]
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("switchertheone/efactura-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "invoices": [{
            "number": "FCT-0001",
            "issue_date": "2026-11-01",
            "due_date": "2026-12-01",
            "seller": {
                "name": "Furnizor Test SRL",
                "vat_id": "RO1234567",
                "reg_com": "J12/1234/2020",
                "street": "Strada Exemplu 1",
                "city": "Cluj-Napoca",
                "county": "RO-CJ",
            },
            "buyer": { "cui": "RO14399840" },
            "payment": { "iban": "RO49AAAA1B31007593840000" },
            "lines": [{
                    "name": "Servicii consultanta",
                    "quantity": 10,
                    "unit": "ore",
                    "price": 150,
                    "vat_rate": 21,
                }],
        }] }

# Run the Actor and wait for it to finish
run = client.actor("switchertheone/efactura-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "invoices": [
    {
      "number": "FCT-0001",
      "issue_date": "2026-11-01",
      "due_date": "2026-12-01",
      "seller": {
        "name": "Furnizor Test SRL",
        "vat_id": "RO1234567",
        "reg_com": "J12/1234/2020",
        "street": "Strada Exemplu 1",
        "city": "Cluj-Napoca",
        "county": "RO-CJ"
      },
      "buyer": {
        "cui": "RO14399840"
      },
      "payment": {
        "iban": "RO49AAAA1B31007593840000"
      },
      "lines": [
        {
          "name": "Servicii consultanta",
          "quantity": 10,
          "unit": "ore",
          "price": 150,
          "vat_rate": 21
        }
      ]
    }
  ]
}' |
apify call switchertheone/efactura-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,switchertheone/efactura-generator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/I9Z6mqs9GiCqPjsZO/builds/Q4LpovQ3nJlLn6cUL/openapi.json
