68 std::array<std::int64_t, FINANCE_CATEGORY_COUNT>
by_category{};
90 explicit Finances(std::int64_t opening_balance,
100 std::int64_t amount);
136 std::int64_t current_weekly_wages);
139 const std::vector<FinanceTransaction>&
getLedger()
const noexcept;
156 const Team& team)
const;
A club's balance, budgets and dated transaction ledger.
Definition finances.h:83
void setTransferBudget(std::int64_t budget)
Sets the transfer allowance.
Definition finances.cpp:102
std::int64_t balance
Definition finances.h:173
void markPersisted() noexcept
Definition finances.cpp:203
int64_t getCurrentWageSpending(const GameData &gamedata, const Team &team) const
Gets the current total wage spending of the team.
Definition finances.cpp:171
std::span< const FinanceTransaction > pendingTransactions() const
Definition finances.cpp:196
std::int64_t wage_budget
Definition finances.h:175
std::vector< FinanceTransaction > ledger
Definition finances.h:176
std::size_t persistedCount() const noexcept
Definition finances.cpp:201
std::int64_t getBalance() const noexcept
Current cash.
Definition finances.cpp:95
std::int64_t getTransferBudget() const noexcept
Remaining transfer allowance for this season.
Definition finances.cpp:97
std::int64_t balanceAt(const GameDateValue &date) const
Balance from the transactions dated on or before date.
Definition finances.cpp:140
std::int64_t ledgerTotal() const
Sum of all ledger amounts (equals the balance).
Definition finances.cpp:132
std::size_t persisted
Definition finances.h:177
FinanceSummary summarize(const GameDateValue &from, const GameDateValue &to) const
Totals of the transactions dated in [from, to].
Definition finances.cpp:151
const std::vector< FinanceTransaction > & getLedger() const noexcept
All transactions in recording order (chronological).
Definition finances.cpp:127
bool moveTransferToWageBudget(std::int64_t transfer_amount, std::int64_t current_weekly_wages)
Moves money between the two budgets at 52 weeks per season.
Definition finances.cpp:114
void setWageBudget(std::int64_t weekly_budget)
Sets the weekly wage allowance.
Definition finances.cpp:109
void addBalance(std::int64_t amount)
Owner investment dated at the newest transaction.
Definition finances.cpp:83
bool revertLastTransaction()
Definition finances.cpp:63
std::int64_t getWageBudget() const noexcept
Weekly wage allowance (cap on the total weekly payroll).
Definition finances.cpp:107
void record(const GameDateValue &date, FinanceCategory category, std::int64_t amount)
Records a dated transaction and updates the balance.
Definition finances.cpp:51
std::int64_t transfer_budget
Definition finances.h:174
void restoreLedger(std::vector< FinanceTransaction > ledger)
Definition finances.cpp:189
Singleton class that acts as an in-memory cache for the database state.
Definition gamedata.h:43
Represents a football team.
Definition team.h:47
FinanceCategory
Ledger categories (values are persisted).
Definition finances.h:28
const char * financeCategoryKey(FinanceCategory category)
Definition finances.cpp:39
constexpr std::size_t FINANCE_CATEGORY_COUNT
Definition finances.h:45
Per-category totals of a ledger range.
Definition finances.h:67
std::int64_t expenses
Definition finances.h:70
std::array< std::int64_t, FINANCE_CATEGORY_COUNT > by_category
Definition finances.h:68
std::int64_t net() const
Definition finances.h:71
std::int64_t income
Definition finances.h:69
One dated ledger entry; positive amounts are income.
Definition finances.h:56
std::int64_t amount
Definition finances.h:59
FinanceCategory category
Definition finances.h:58
GameDateValue date
Definition finances.h:57
Represents a specific date in the game world.
Definition gamedate.h:20