#ifndef CASHFLOW_H #define CASHFLOW_H #include #include #include #include "database.h" #include "transaction.h" QT_BEGIN_NAMESPACE namespace Ui { class CashFlow; } QT_END_NAMESPACE class CashFlow : public QMainWindow { Q_OBJECT public: CashFlow(QWidget *parent = nullptr); ~CashFlow(); private slots: void onDateRangeChanged(); void onTransactionSelected(); void onSaveTransaction(); void onNewTransaction(); void onDeleteTransaction(); void onRecurringSelected(); void onSaveRecurring(); void onNewRecurring(); void onDeleteRecurring(); void onPeriodChanged(); void onNewFile(); void onOpenFile(); void onQuit(); void onPreferences(); void onRecurringRuleChanged(); void onTransactionDateChanged(); void onCreateAdjustment(); private: Ui::CashFlow *ui; Database *database; int currentTransactionId; int currentRecurringId; double startingBalance; QFont currentAmountFont; int weekStartDay; QString currentFilePath; enum PeriodType { Daily, Weekly, Monthly, Quarterly }; void setupConnections(); void refreshView(); void refreshTransactionTable(); void refreshRecurringTable(); void calculateAndDisplayBalance(); QList getAllTransactionsInRange(); void clearTransactionEntry(); void loadTransactionToEntry(const Transaction &t); void clearRecurringEntry(); void loadRecurringToEntry(const RecurringRule &r); QDate getPeriodEnd(const QDate &date, PeriodType periodType); QDate getPeriodStart(const QDate &date, PeriodType periodType); QString getPeriodLabel(const QDate &date, PeriodType periodType, int count); void insertPeriodEndRow(const QString &label, double balance, const QMap &accountBalances); void updateAmountColors(); void loadSettings(); QString formatCurrency(double amount) const; double calculateBalanceUpTo(const QDate &date, const QString &account); void recalculateAllReconciliations(); bool openDatabase(const QString &filePath); void populateRecurringRulesCombo(); void updateOccurrenceKey(); QString generateOccurrenceKey(const QDate &date, RecurrenceFrequency frequency) const; }; #endif // CASHFLOW_H