currency.euroConvert
Convert between the euro and a currency it replaced, at GnuCash's fixed rates.
Converts between the euro and a currency it replaced, at the fixed rates fixed when the euro was introduced: to euros
divides by the rate, from euros multiplies, rounding half away from zero to the currency's fraction. One side must be
EUR. GnuCash returns 0 for a currency with no euro rate; red-ale refuses with invalid, so a zero is never taken for
an answer. For other pairs use the price database (price.nearest).
Examples
Example: with a new, empty book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"currency.euroConvert","params":{"amount":"100.00","from":"EUR","to":"DEM"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"amount": {
"num": "19558",
"denom": "100"
},
"rate": {
"num": "195583",
"denom": "100000"
}
}
}
Request:
{"jsonrpc":"2.0","id":2,"method":"currency.euroConvert","params":{"amount":"100.00","from":"USD","to":"GBP"}}
Response:
{
"jsonrpc": "2.0",
"id": 2,
"error": {
"code": 2001,
"message": "…",
"data": {
"help": "error/invalid"
}
}
}
Command line
red-ale exec --book book.gnucash --script - <<'EOF'
currency.euroConvert {"amount":"100.00","from":"EUR","to":"DEM"}
currency.euroConvert {"amount":"100.00","from":"USD","to":"GBP"}
EOF
It fails with exit status 2, printing on standard error:
{
"error": {
"code": 2001,
"message": "…",
"data": {
"help": "error/invalid"
}
}
}
MCP tool call
Tool call:
{"name":"currency.euroConvert","arguments":{"amount":"100.00","from":"EUR","to":"DEM"}}
Result:
{
"structuredContent": {
"amount": {
"num": "19558",
"denom": "100"
},
"rate": {
"num": "195583",
"denom": "100000"
}
}
}
Tool call:
{"name":"currency.euroConvert","arguments":{"amount":"100.00","from":"USD","to":"GBP"}}
Result:
{
"isError": true,
"structuredContent": {
"error": {
"code": 2001,
"name": "invalid",
"message": "…",
"data": {
"help": "error/invalid"
}
}
}
}
Effect: read.
Params
Params of currency.euroConvert.
amount(Amount, required): The amount, infrom.from(CommodityId, required): The currency of the amount:EURor a currency the euro replaced.to(CommodityId, required): The currency wanted:EURor a currency the euro replaced; one side must beEUR.
Result
The result of currency.euroConvert.
amount(Amount, required): The converted amount, rounded half away from zero to cents (to EUR) or to the currency's fraction.rate(Amount, required): The fixed rate used: units of the legacy currency per euro.