---
name: ptero-cloud-generate-invoice-folder
description: "Use when Patrik invokes /ptero-cloud-generate-invoice-folder. Generate .docx description files for the accountant for a given month's invoice folder. These files explain each transaction on the bank statement so the accountant understands what each payment was for."
---

Generate .docx description files for the accountant for a given month's invoice folder. These files explain each transaction on the bank statement so the accountant understands what each payment was for.

## INPUT

The user may specify a month, e.g.:
- `Březen 2026` -- use that month
- No argument -- use the **previous calendar month** (based on today's date)

Map month numbers to Czech names:
1=Leden, 2=Únor, 3=Březen, 4=Duben, 5=Květen, 6=Červen, 7=Červenec, 8=Srpen, 9=Září, 10=Říjen, 11=Listopad, 12=Prosinec

---

## BASE PATH

```
/Users/patrikkoudelka/Library/Mobile Documents/com~apple~CloudDocs/Ptero-Cloud Výpisy/Účtenky : Faktury/{Month} {Year}/
```

---

## ACCOUNT TYPES

There are 4 Moneta bank accounts. The subfolder names vary between months, so match flexibly:

| Account | Currency | IBAN | Possible folder names |
|---------|----------|------|----------------------|
| CZK Checking | CZK | CZ0406000000000250104646 | `Běžný účet CZK`, `Běžný CZK`, `Moneta CZK`, `CZK` |
| EUR Checking | EUR | CZ8906000000000265290891 | `Běžný účet EUR`, `Běžný EUR`, `Moneta EUR`, `EUR` |
| USD Checking | USD | CZ1306000000000265290998 | `Běžný účet USD`, `Běžný USD`, `Moneta USD`, `USD` |
| CZK Savings | CZK | CZ7006000000000262817539 | `Spořící účet CZK`, `Spořící CZK`, `Moneta Spořící účet CZK`, `Moneta Spořící CZK` |

---

## STEP 1 -- DISCOVER FOLDERS

List the month folder and identify which subfolder corresponds to which account type. Match using the table above. If a folder does not exist, skip that account.

---

## STEP 2 -- FOR EACH ACCOUNT FOLDER

### 2a. Check if a .docx already exists

If a `.docx` description file already exists in the folder, **ask the user** whether to overwrite or skip. Do not silently overwrite.

### 2b. Read the bank statement PDF

Find the `STM_*.pdf` file in the folder. Read it to extract all transactions. For each transaction, note:
- Date
- Description/counterparty
- Amount (debit or credit)
- Any additional info (exchange rates, fees, references)

### 2c. Read invoice PDFs in subfolders

List all subfolders (these are vendor folders like "Claude.ai", "Notion", "Premier Studios", "Alza", "Hostify", etc.). Read the invoice PDFs inside to get:
- Exact date
- What was purchased/paid for
- Amount and currency

### 2d. Cross-reference

Match bank statement transactions with invoice details to build a complete picture of each transaction.

---

## STEP 3 -- GENERATE THE .DOCX

Create a `.docx` file using `python-docx` with the following rules:

### File naming

Use the pattern: `{Account folder name} {month lowercase} {year}.docx`

Examples:
- `Běžný účet USD březen 2026.docx`
- `Běžný účet CZK březen 2026.docx`
- `Běžný účet EUR březen 2026.docx`
- `Spořící účet CZK březen 2026.docx`

Use the actual folder name as the account name prefix.

### Content format

One line per transaction. Use `Normal` style, Calibri 11pt. Separate entries with empty paragraphs.

**For expenses (debits):**
```
{D.M.} – {Vendor/Description} – {amount with currency} – {Czech explanation of what the service/product is}
```

**For income (credits):**
```
{D.M.} – {Description of income source} – +{amount with currency} (poplatek {fee amount})
```

**For currency conversions:**
```
{D.M.} – Převod-konverze měny z {FROM} na {TO} – {amount} (kurz {rate})
```

**For bank fees:**
```
{D.M.} – {Fee description} – {amount}
```

### Explanation rules

The whole point is to explain transactions so the accountant understands them. Follow these rules:

- **Claude.ai / Anthropic** = "měsíční předplatné umělé inteligence Claude, používané pro firemní účely (automatizace, komunikace, vývoj)"
- **Notion** = "měsíční předplatné Notion (aplikace pro správu firemních dokumentů, projektů a úkolů)"
- **Slack** = "měsíční předplatné Slack (firemní komunikační platforma)"
- **OpenAI** = "předplatné OpenAI (umělá inteligence pro firemní účely)"
- **Hostify** = "měsíční poplatek za hosting serverů (Hostify)"
- **Premier Studios** = "platba za vývoj her pro Minecraft Marketplace (Premier Studios)"
- **ThunderAy AB** = "příjem od ThunderAy AB (Švédsko) za práci na Minecraft Marketplace projektech"
- **Alza** = describe the specific product from the invoice
- **Stripe/GoPay income** = "Příjem z Minecraft serveru" with fee noted
- **Twilio** = "poplatek za SMS službu pro připomínky doučování"
- **Marketing invoices** (McZosa / Francisco Zamudio, Panorama, marcv / Mangga, Lugatts, Omar atd.) = "platba za marketingové služby (Marketing materiál; faktura {INV} ze dne D.M.RRRR)". **NEPOUŽÍVAT** ThunderAy-interní produktové pojmy v popiscích pro účetní (Keyart, Panorama, Splash art, Add-On názvy: Minimap, Multipack, VE+, Wilderness, Disasters atd.) — účetní jim nerozumí, jen ji to mate. Jméno dodavatele/studia je OK; konkrétní typ a produkt vynechat.
- **Mzdy / výplaty** (okamžitá úhrada na účet fyzické osoby s VS ve formátu RRRRMM, např. VS 202603 = za 03/2026) = "Výplata mzdy za MM/RRRR (účet xxx/yyyy) – {amount}". **Nehlásit chybějící fakturu ve složce** a **neuvádět v shrnutí pro Patrika** — účetní má mzdovou dokumentaci u sebe.
- **Wedos** = "poplatek za doménu/hosting (Wedos)"
- **Inter-account transfers** = "Převod z/na {account}" with conversion rate if applicable
- **Card fees** = "Poplatek za vedení karty"
- **Account fees** = "Vedení účtu"
- For any **unknown vendor**, describe it based on the bank statement description and ask the user if unsure

When the invoice is in EUR but paid from USD account, note both: `{USD amount} (€{EUR amount})`

### Non-breaking spaces

Use `\xa0` (non-breaking space) after Czech prepositions: z, s, k, v, na, do, od, za, po, pro, při, o, u -- when followed by a word. This matches the existing document style.

---

## STEP 4 -- SKIP EMPTY ACCOUNTS

If an account only has bank fees (vedení účtu, vedení karty) and no other transactions, still generate the docx but only list the fees. If there are literally zero transactions on the statement, skip generating the docx for that account.

---

## STEP 5 -- SUMMARY

After generating all files, show the user:
- Which .docx files were created
- A brief list of transactions in each
- Any transactions you were unsure about (ask for clarification)

---

## PYTHON TEMPLATE

```python
from docx import Document
from docx.shared import Pt

doc = Document()
style = doc.styles['Normal']
font = style.font
font.name = 'Calibri'
font.size = Pt(11)

# Add lines
lines = [
    "D.M. – Description – amount",
    "",  # empty separator
    "D.M. – Description – amount",
]

for line in lines:
    doc.add_paragraph(line)

doc.save("path/to/file.docx")
```

---

## IMPORTANT

- Always read the bank statement PDF first -- it is the source of truth for what transactions occurred
- Cross-reference with invoice PDFs for details
- Write everything in Czech
- Use the `–` (en-dash) as separator, NOT `—` (em-dash) and NOT `-` (hyphen)
- Match the casual, simple style of existing docs -- no headers, no bold, no tables, just plain text lines
- If `python-docx` is not installed, install it with `pip3 install python-docx`
