module account.model; import std.datetime; import money.currency; struct AccountType { const string id; const string name; const bool debitsPositive; import std.traits : EnumMembers; static AccountType fromId(string id) { static foreach (t; EnumMembers!AccountTypes) { if (id == t.id) return t; } throw new Exception("Invalid account type id " ~ id); } } enum AccountTypes : AccountType { CHECKING = AccountType("CHECKING", "Checking", true), SAVINGS = AccountType("SAVINGS", "Savings", true), CREDIT_CARD = AccountType("CREDIT_CARD", "Credit Card", false), BROKERAGE = AccountType("BROKERAGE", "Brokerage", true) } struct Account { ulong id; SysTime createdAt; bool archived; AccountType type; string numberSuffix; string name; Currency currency; string description; } struct AccountCreditCardProperties { ulong account_id; long creditLimit; }