# Set up a company in Portugal with Ekwo OS

Ekwo OS is open source software for keeping double-entry books in a database you own. This page is generated from the Portugal pack, version 0.1.0; every code on it is read from the pack.

The Portugal pack is **community**: contributed, and reviewed by nobody.

> Ekwo is software, not an accountant and not tax advice: a pack is a reading of the rules at the date of its version, and it can be wrong for your situation. Have a qualified professional in Portugal check your set-up and your first declarations. See [what Ekwo is, and what it is not](https://ekwo.ai/disclaimer/).

## 1. What you need

- A [Supabase](https://supabase.com) project of your own. The free plan is enough to start; Ekwo does not create it, pay for it or have access to it.
- From its dashboard: the connection string (Connect → **Session pooler**), the Project URL and the `service_role` key (Project Settings → API). The key is used once, to create your first administrator, and is written nowhere. The anon (publishable) key, on the same page, is what you sign in with afterwards.
- Node 20 or later on your machine. Nothing else: no Supabase CLI, no Docker, no clone.

## 2. Install

One command. It asks for the rest as it goes.

```sh
npx ekwo-os init --country PT
```

- One chart of accounts: SNC — Sistema de Normalização Contabilística (seleção para PME), 119 accounts.
- The books can be kept in `pt`, `en`; the installer asks. Without a terminal, pass `--language <code>`.
- The Declaração Periódica do IVA is filed on one of these cadences: `month`, `quarter`. Pass `--vat-period <cadence>` to set yours.
- A financial year follows the calendar unless you pass `--fiscal-year-start YYYY-MM-DD`.

The same, with no question asked — every value your own:

```sh
npx ekwo-os init \
  --country PT \
  --language pt \
  --vat-period <month|quarter> \
  --db-url "postgresql://postgres.<ref>:<password>@<pooler host>:5432/postgres" \
  --supabase-url "https://<ref>.supabase.co" \
  --service-role-key "$SUPABASE_SERVICE_ROLE_KEY" \
  --org "Your Organisation" --company "Your Company" \
  --admin-email "you@example.com" \
  --yes
```

## 3. Before you go live

Four settings of your project no installer can reach: turn off self sign-up, keep two administrators, keep the `service_role` key off every other machine, and read the disclaimer. `init` prints them; [the installation guide](https://ekwo.ai/docs/install/#before-you-go-live-four-things-on-your-project) explains each.

## 4. A first invoice

Sign in as the administrator you just created, pick the company, and write a draft. `--dry-run` shows the entry the database would write, and writes nothing; `post` books it.

```sh
ekwo login --supabase-url https://<ref>.supabase.co --anon-key <publishable key> --email you@example.com
ekwo use "Your Company"
ekwo contact add "First Customer" --country PT --ref customer-1
ekwo doc new --contact "First Customer" --ref invoice-1 --line "name=Consulting,price=1000.00,account=71,tax=PT-S-23"
ekwo post invoice-1 --dry-run
ekwo post invoice-1
```

A line names its account and its tax by code, never by rate. `71` is the account the pack names for sales; the chart may carry a closer one for what you sell — services, a reduced rate — and `list_accounts` lists them.

What the invoice says about your company — its address, its VAT number — comes from the company’s profile, which the MCP tool `update_company_profile` fills; `ekwo init` sets only the name.

The domestic sale taxes the pack carries today. Which one a sale carries is a question about that sale, for you or your accountant: the list is the pack’s, not advice.

| Tax code | Name | Rate |
|---|---|---|
| `PT-S-23` | Vendas e serviços à taxa normal (23 %) | 23 % |
| `PT-S-13` | Vendas e serviços à taxa intermédia (13 %) | 13 % |
| `PT-S-6` | Vendas e serviços à taxa reduzida (6 %) | 6 % |
| `PT-S-AC-16` | Vendas e serviços na Região Autónoma dos Açores, taxa normal (16 %) | 16 % |
| `PT-S-AC-9` | Vendas e serviços na Região Autónoma dos Açores, taxa intermédia (9 %) | 9 % |
| `PT-S-AC-4` | Vendas e serviços na Região Autónoma dos Açores, taxa reduzida (4 %) | 4 % |
| `PT-S-MA-22` | Vendas e serviços na Região Autónoma da Madeira, taxa normal (22 %) | 22 % |
| `PT-S-MA-12` | Vendas e serviços na Região Autónoma da Madeira, taxa intermédia (12 %) | 12 % |
| `PT-S-MA-4` | Vendas e serviços na Região Autónoma da Madeira, taxa reduzida (4 %, desde 01/10/2024) | 4 % |

## 5. With an AI assistant

The MCP server lets an assistant keep the books as you, under your own row level security, and never with the `service_role` key. [Configuring it](https://ekwo.ai/docs/mcp/), and [what an assistant must and must not do](https://ekwo.ai/docs/agents/).

## What the Portugal pack carries

- Charts of accounts: SNC — Sistema de Normalização Contabilística (seleção para PME) (119).
- 25 taxes, at 0 %, 4 %, 5 %, 6 %, 9 %, 12 %, 13 %, 16 %, 22 %, 23 %.
- The Declaração Periódica do IVA (`PT-DP-IVA`), 25 boxes, filed month, quarter.
- Financial statements: Balanço, Demonstração dos Resultados por naturezas.

## What it does not do

- No library of this repository writes the file of the PT-DP-IVA yet: the return is computed and frozen here, and typed on the administration’s portal.
- Nothing is sent to an administration, a Peppol network or a bank by the open source software: transmission is yours, or an operator’s you appoint.
- What the pack leaves out on purpose is in [its README](https://github.com/Ekwo-ai/ekwo-os/tree/main/packs/pt).
