|
Player12
An open source football management simulator
|
A club's balance, budgets and dated transaction ledger. More...
#include <finances.h>
Public Member Functions | |
| Finances (std::int64_t opening_balance, GameDateValue opening_date=GameDateValue(2025, 7, 2)) | |
| Creates the finances with an opening-balance transaction. | |
| void | record (const GameDateValue &date, FinanceCategory category, std::int64_t amount) |
| Records a dated transaction and updates the balance. | |
| bool | revertLastTransaction () |
| void | addBalance (std::int64_t amount) |
| Owner investment dated at the newest transaction. | |
| std::int64_t | getBalance () const noexcept |
| Current cash. | |
| std::int64_t | getTransferBudget () const noexcept |
| Remaining transfer allowance for this season. | |
| void | setTransferBudget (std::int64_t budget) |
| Sets the transfer allowance. | |
| std::int64_t | getWageBudget () const noexcept |
| Weekly wage allowance (cap on the total weekly payroll). | |
| void | setWageBudget (std::int64_t weekly_budget) |
| Sets the weekly wage allowance. | |
| bool | moveTransferToWageBudget (std::int64_t transfer_amount, std::int64_t current_weekly_wages) |
| Moves money between the two budgets at 52 weeks per season. | |
| const std::vector< FinanceTransaction > & | getLedger () const noexcept |
| All transactions in recording order (chronological). | |
| std::int64_t | ledgerTotal () const |
| Sum of all ledger amounts (equals the balance). | |
| std::int64_t | balanceAt (const GameDateValue &date) const |
Balance from the transactions dated on or before date. | |
| FinanceSummary | summarize (const GameDateValue &from, const GameDateValue &to) const |
| Totals of the transactions dated in [from, to]. | |
| int64_t | getCurrentWageSpending (const GameData &gamedata, const Team &team) const |
| Gets the current total wage spending of the team. | |
| void | restoreLedger (std::vector< FinanceTransaction > ledger) |
| std::span< const FinanceTransaction > | pendingTransactions () const |
| std::size_t | persistedCount () const noexcept |
| void | markPersisted () noexcept |
Private Attributes | |
| std::int64_t | balance = 0 |
| std::int64_t | transfer_budget = 0 |
| std::int64_t | wage_budget = 0 |
| std::vector< FinanceTransaction > | ledger |
| std::size_t | persisted = 0 |
A club's balance, budgets and dated transaction ledger.
Every balance change is recorded as a transaction, so the balance always equals the sum of the ledger. The transfer budget and the weekly wage budget are separate allowances set by the board each season.
|
explicit |
Creates the finances with an opening-balance transaction.
| opening_balance | Initial cash. |
| opening_date | Date of the opening transaction. |
| void Finances::addBalance | ( | std::int64_t | amount | ) |
Owner investment dated at the newest transaction.
The funds are unrestricted: they raise the transfer budget by the full amount and the weekly wage budget by one season's worth (amount / 52).
| std::int64_t Finances::balanceAt | ( | const GameDateValue & | date | ) | const |
Balance from the transactions dated on or before date.
|
noexcept |
Current cash.
Gets the current total wage spending of the team.
|
noexcept |
All transactions in recording order (chronological).
|
noexcept |
Remaining transfer allowance for this season.
|
noexcept |
Weekly wage allowance (cap on the total weekly payroll).
| std::int64_t Finances::ledgerTotal | ( | ) | const |
Sum of all ledger amounts (equals the balance).
|
noexcept |
Marks every transaction as written.
| bool Finances::moveTransferToWageBudget | ( | std::int64_t | transfer_amount, |
| std::int64_t | current_weekly_wages | ||
| ) |
Moves money between the two budgets at 52 weeks per season.
| transfer_amount | Positive moves transfer budget into weekly wages, negative moves unused weekly wage room back into the transfer budget. |
| current_weekly_wages | Payroll that the wage budget must cover. |
| std::span< const FinanceTransaction > Finances::pendingTransactions | ( | ) | const |
Transactions not yet written to the database.
|
noexcept |
Index of the first pending transaction.
| void Finances::record | ( | const GameDateValue & | date, |
| FinanceCategory | category, | ||
| std::int64_t | amount | ||
| ) |
Records a dated transaction and updates the balance.
Fees paid reduce the transfer budget; a share of fees received is returned to it.
| void Finances::restoreLedger | ( | std::vector< FinanceTransaction > | ledger | ) |
Replaces the ledger with persisted rows; the balance follows it.
| bool Finances::revertLastTransaction | ( | ) |
Removes the newest transaction and undoes its effects.
| void Finances::setTransferBudget | ( | std::int64_t | budget | ) |
Sets the transfer allowance.
| void Finances::setWageBudget | ( | std::int64_t | weekly_budget | ) |
Sets the weekly wage allowance.
| FinanceSummary Finances::summarize | ( | const GameDateValue & | from, |
| const GameDateValue & | to | ||
| ) | const |
Totals of the transactions dated in [from, to].
|
private |
|
private |
|
private |
|
private |
|
private |