| name | foreign_currency_payment |
| tier | 3 |
| task | T27 |
| description | This skill handles foreign currency invoice payment with exchange rate differences (disagio/agio). Keywords include "exchange rate", "valutakurs", "vekslingskurs", "taux de change", "Wechselkurs", "tipo de cambio", "disagio", "agio", "currency difference", "valutadifferanse", "EUR", "USD", "foreign currency", "fremmed valuta". |
Foreign Currency Payment + Exchange Rate Difference
Register payment on foreign currency invoice and post disagio/agio. 5 calls.
Turn 1: 3 parallel GETs
GET /invoice?invoiceDateFrom=2020-01-01&invoiceDateTo=2030-12-31&fields=id,invoiceNumber,amount,amountCurrency,amountOutstanding,amountCurrencyOutstanding,currency(id,code),customer(id,name)&count=100
GET /invoice/paymentType?fields=id,description&count=10
GET /ledger/account?number=8060,8160,1920&fields=id,number,name
Find the invoice by matching the customer name/org and amount. The EUR invoice has currency.code = "EUR" and amountCurrency matching the EUR amount from the prompt.
Use amountOutstanding (in NOK) for payment. Use "Betalt til bank" payment type.
Account 8060 or 8160 = agio/disagio (exchange rate differences).
Turn 2: Register payment
PUT /invoice/<invoice_id>/:payment?paymentDate=2026-03-21&paymentTypeId=<bank_type_id>&paidAmount=<amountOutstanding_from_invoice>
Use the invoice's amountOutstanding (NOK) as paidAmount. This zeroes out the invoice.
Turn 3: Post agio/disagio voucher
Calculate:
- invoice_nok = amountOutstanding from the invoice (NOK at original rate)
- payment_nok = foreign_amount × new_rate (from prompt)
- difference = payment_nok - invoice_nok
If difference > 0 → agio (gain, customer paid MORE in NOK). Credit 8060/8160.
If difference < 0 → disagio (loss, customer paid LESS). Debit 8060/8160.
POST /ledger/voucher
{
"date": "2026-03-21",
"description": "Valutadifferanse",
"postings": [
{"date": "2026-03-21", "account": {"id": <account_1920_id>}, "amountGross": <payment_nok>, "amountGrossCurrency": <payment_nok>, "row": 1},
{"date": "2026-03-21", "account": {"id": <account_8060_id>}, "amountGross": -<difference>, "amountGrossCurrency": -<difference>, "row": 2},
{"date": "2026-03-21", "account": {"id": <customer_receivable_acct>}, "amountGross": -<invoice_nok>, "amountGrossCurrency": -<invoice_nok>, "row": 3}
]
}
Actually, simpler 2-line voucher for just the exchange rate difference:
POST /ledger/voucher
{
"date": "2026-03-21",
"description": "Valutadifferanse",
"postings": [
{"date": "2026-03-21", "account": {"id": <account_1920_id>}, "amountGross": <difference>, "amountGrossCurrency": <difference>, "row": 1},
{"date": "2026-03-21", "account": {"id": <account_8060_id>}, "amountGross": -<difference>, "amountGrossCurrency": -<difference>, "row": 2}
]
}
For agio (gain): difference is positive → debit 1920 (more cash), credit 8060 (gain).
For disagio (loss): difference is negative → credit 1920 (less cash), debit 8060 (loss).
5 calls, 0 errors.
Key details
- Find the EUR/USD invoice by
currency.code — NOT by amount in NOK
paidAmount = invoice's amountOutstanding in NOK (from GET response). Do NOT calculate from prompt rates.
- difference = (foreign_amount × new_rate) - invoice_amountOutstanding
- Account 8060 "Annen finansinntekt" or 8160 "Agio" for exchange differences — check which exists
- Agio = gain (new rate higher). Disagio = loss (new rate lower).