# Rule: Currency & Amounts

Currency codes (table `currency.cucode`):
- `01` = LBP (Lebanese Pound) — **base currency**
- `02` = USD, `03` = EUR, `04` = GBP, `06` = CHF, `08` = SAR, `10` = EGP

Every ledger line stores three pre-converted amounts (all positive; side given by `dc` = D/C):
- `amountl` = amount in **LBP (base)**
- `amountd` = amount in **USD**
- `amountf` = amount in the **foreign currency**
- `rate` (USD↔LBP) and `rateFC` (foreign) are the rates used.

Reporting rules:
- **Report in LBP by default**; switch to USD only when asked. Always state the currency.
- Do **not** re-convert with `rate` — sum the column that matches the requested currency (`amountl`/`amountd`/`amountf`).
- Configured rates live in `curtrans` (`ExRate`, `ExRate_POS`) per currency code (`cutrcode`, USD='02').

## Exchange rate: the JOURNAL rate is the source of truth, NOT the rate table
**Critical business rule (confirmed by the owner):** users enter the exchange rate **directly in each journal voucher** and **usually do NOT update the `curtrans` rate table**. So:
- `curtrans` is **frequently stale/incomplete** — for USD it sits at the **official peg 1,507.5** and was never updated for the crash. **Do NOT use `curtrans` to value USD or to find the rate paid.**
- The **authoritative actual rate of a transaction = `amountl ÷ amountd`** (LBP leg ÷ USD leg from the journal). This reflects the rate the user actually keyed into the voucher.
- The `trans_child.rate` field is **unreliable** too — it is sometimes left at 1,507.5 while the real booked rate (amountl/amountd) was 8,925–9,000. Prefer `amountl ÷ amountd`.
- To get the highest / lowest / average rate paid, aggregate `amountl/amountd` over USD lines (`accurrency='02'`, `amountd<>0`). Peak in this data = **9,000 LBP/USD (Jan 2021)** vs 1,507.5 official.
- Always value USD exposure at the **actual journal rate**, and report LBP and USD legs separately.

