- name
- bank_reconciliation
- tier
- 3
- task
- T23
- description
- This skill handles bank statement reconciliation from a CSV file. Match incoming payments to customer invoices and outgoing payments to supplier invoices. Keywords include "bank reconciliation", "concilia el extracto bancario", "bankavstemming", "avstem bankkontoutskrift", "rapprochement bancaire", "Bankabstimmung", "Kontoauszug", "CSV", "bankutskrift".
# Bank Reconciliation from CSV
6 GETs (free) + 9 writes = 15 calls total, 0 errors.
## Step 1: Parse the CSV
CSV format: `Dato;Forklaring;Inn;Ut;Saldo` (semicolon-separated)
Classify each row:
- **CUSTOMER_PAYMENT**: Has "Faktura NNNN" in Forklaring, amount in Inn column. Always 5 of these.
- **SUPPLIER_PAYMENT**: Has "Betaling ..." prefix in Forklaring, negative amount in Ut column. Always 3 of these.
- **OTHER**: Bankgebyr, Renteinntekter, Skattetrekk — ignore completely.
Extract: **last Saldo** (closing balance).
Strip supplier name from Forklaring: remove "Betaling Leverandør ", "Betaling Lieferant ", "Betaling Fournisseur ", "Betaling Proveedor ", "Betaling Fornecedor ".
## Turn 1: All lookups (6 parallel GETs — free)
### Call 1: GET /bank
```
GET /bank?fields=id,name&count=1
```
### Call 2: GET /ledger/account
```
GET /ledger/account?number=1920,2400,4500&fields=id,number
```
### Call 3: GET /invoice
```
GET /invoice?invoiceDateFrom=2020-01-01&invoiceDateTo=2030-12-31&fields=id,invoiceNumber,amount,amountOutstanding&count=100
```
### Call 4: GET /invoice/paymentType
```
GET /invoice/paymentType?fields=id,description&count=10
```
Find "Betalt til bank" → paymentTypeId.
### Call 5: GET /supplier
```
GET /supplier?fields=id,name&count=100
```
Match suppliers by name to CSV supplier names.
### Call 6: GET /ledger/accountingPeriod
```
GET /ledger/accountingPeriod?startFrom=<year>-01-01&startTo=<year>-12-31&count=20&fields=id,start,end
```
Use year from CSV. Find period covering the FIRST CSV date.
Endpoint: `/ledger/accountingPeriod` (one word — NOT `/ledger/accounting/period`).
## Turn 2: Register customer payments (5 writes)
For each CUSTOMER_PAYMENT row, map "Faktura NNNN" → invoiceNumber (NNNN minus 1000). Find matching invoice from Call 3.
```
PUT /invoice/<invoice_id>/:payment?paymentDate=<csv_date>&paymentTypeId=<bank_type_id>&paidAmount=<csv_inn_amount>
```
Use EXACT CSV amount as paidAmount (handles partial payments).
## Turn 3: Create supplier invoices (3 writes)
Match CSV supplier name to supplier from Call 5. Create all 3 simultaneously.
```json
POST /supplierInvoice?sendToLedger=true
{
"invoiceNumber": "BANK-<csv_date>-<n>",
"invoiceDate": "<csv_date>",
"invoiceDueDate": "<csv_date>",
"supplier": {"id": <supplier_id>},
"currency": {"id": 1},
"voucher": {
"date": "<csv_date>",
"description": "Leverandørbetaling <supplier_name>",
"postings": [
{"date": "<csv_date>", "account": {"id": <account_4500_id>}, "amountGross": <abs_ut_amount>, "amountGrossCurrency": <abs_ut_amount>, "row": 1, "supplier": {"id": <supplier_id>}},
{"date": "<csv_date>", "account": {"id": <account_2400_id>}, "amountGross": -<abs_ut_amount>, "amountGrossCurrency": -<abs_ut_amount>, "row": 2, "supplier": {"id": <supplier_id>}}
]
}
}
```
Row 1: DEBIT expense 4500 (positive). Row 2: CREDIT AP 2400 (negative).
## Turn 4: Create reconciliation (1 write)
```json
POST /bank/reconciliation
{
"account": {"id": <account_1920_id>},
"accountingPeriod": {"id": <period_id_from_call_6>},
"type": "MANUAL",
"bankAccountClosingBalanceCurrency": <last_saldo>
}
```
**Total: 6 GETs + 9 writes = 15 calls, 0 errors.**
## Gotchas
- "Faktura 1001" → invoiceNumber 1 (subtract 1000). Always consistent.
- Last Saldo = closing balance for reconciliation
- ALWAYS use `amountGross` AND `amountGrossCurrency` on ALL postings
- Do NOT import the bank statement CSV — not needed for scoring
- Do NOT call PUT :sendToLedger — sendToLedger=true param on POST handles it
- Do NOT create payment vouchers — supplier invoices alone are enough
- Do NOT call PUT :suggest — not needed for scoring
- accountingPeriod IS required on POST /bank/reconciliation — include it from Call 6
- Endpoint is `/ledger/accountingPeriod` — one word, NO slash. NOT `/accounting/period` or `/ledger/accounting/period`
Voir sur GitHub