models:
- name: FxGainLoss
collection: fx_gain_losses
description: "A realised FX gain/loss recognised on bank clearance of a foreign-currency settlement"
fields:
id: { type: uuid, attributes: ["@id", "@default(uuid)"] }
bank_clearance_id: { type: uuid?, attributes: ["@exclude_from_foreign_key_check"], description: "The clearance that triggered the realisation # logical FK" }
matched_source_id: { type: uuid, attributes: ["@required", "@exclude_from_foreign_key_check"], description: "The settled document id" }
currency: { type: string, attributes: ["@required", "@max(3)"], description: "The foreign currency" }
original_rate: { type: decimal, attributes: ["@required", "@precision(20,8)", "@positive"], description: "Rate at the original post" }
realised_rate: { type: decimal, attributes: ["@required", "@precision(20,8)", "@positive"], description: "Rate at the bank statement" }
base_amount_delta: { type: decimal, attributes: ["@required", "@precision(18,2)"], description: "realised_base − original_base. Positive = gain; negative = loss." }
direction: { type: FxDirection, attributes: ["@required"] }
fx_account_id: { type: uuid, attributes: ["@required", "@exclude_from_foreign_key_check"], description: "FX Gain or FX Loss GL account" }
metadata: { type: Metadata, attributes: ["@audit_metadata"] }
indexes:
enums:
- name: FxDirection
description: "Sign of an FX realisation"
variants:
- { name: gain, description: "Favourable (cash cleared higher than booked)", default: true }
- { name: loss, description: "Unfavourable" }