Euro Triangulation Converter
When the euro arrived, Council Regulation (EC) No 1103/97 froze every legacy currency to a six-significant-digit rate against the euro and made the conversion arithmetic itself a matter of law: converting Deutsche Mark to French francs means going through the euro, with the rounding at each step prescribed — because a one-step "cross rate" produces amounts that are off by a centime, and off-by-a-centime is illegal on an invoice. You are building that converter; archival modules that restate historical documents still need it, and the tests hold you to the letter of the regulation.
Requirements
The starter ships a table named "Euro Fixed Rate" — keep its name, fields and primary key exactly as they are, because the grading tests write rows into it directly:
| Field | Type |
|---|---|
"Currency Code" |
Code[10] (primary key) |
"Units per EUR" |
Decimal |
"Amount Rounding Precision" |
Decimal |
A row means: 1 euro equals "Units per EUR" units of that currency (e.g. 1.95583 for the Mark, 1936.27 for the lira), and "Amount Rounding Precision" is the currency's smallest expressible unit — the tests only ever seed 0.01 (centesimal currencies) or 1 (the lira has no decimals).
Complete the codeunit named "Euro Triangulation" with one public procedure:
procedure ConvertCurrency(FromCurrencyCode: Code[10]; ToCurrencyCode: Code[10]; Amount: Decimal): DecimalThe euro itself is identified by the literal currency code EUR and never has a row in the table — recognize it by code.
Wherever a rule below says round, it means: round to the nearest multiple of the stated precision, and when the value sits exactly halfway between two multiples, round up — away from zero (Article 5 of the regulation; amounts here are never negative, so "up" and "away from zero" coincide).
Solve it with Pro
You’re reading the opening of the statement. Pro unlocks the whole problem:
- The full statement
- Starter code in the browser editor
- 14 grading tests, run on Business Central 28.5
- 3 hints
- The reference solution
Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.
Already on Pro? Sign in