45 lines
1.1 KiB
D
45 lines
1.1 KiB
D
module account.model;
|
|
|
|
import std.datetime;
|
|
import std.traits : EnumMembers;
|
|
|
|
import util.money;
|
|
|
|
struct AccountType {
|
|
const string id;
|
|
const string name;
|
|
const bool debitsPositive;
|
|
|
|
static AccountType fromId(string id) {
|
|
static foreach (t; ALL_ACCOUNT_TYPES) {
|
|
if (t.id == 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)
|
|
}
|
|
|
|
immutable(AccountType[]) ALL_ACCOUNT_TYPES = cast(AccountType[]) [ EnumMembers!AccountTypes ];
|
|
|
|
struct Account {
|
|
const ulong id;
|
|
const SysTime createdAt;
|
|
const bool archived;
|
|
const AccountType type;
|
|
const string numberSuffix;
|
|
const string name;
|
|
const Currency currency;
|
|
const string description;
|
|
}
|
|
|
|
struct AccountCreditCardProperties {
|
|
const ulong account_id;
|
|
const long creditLimit;
|
|
}
|