aboutsummaryrefslogtreecommitdiff
path: root/cashflow.h
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2025-12-27 14:19:21 -0500
committerCalvin Morrison <calvin@pobox.com>2025-12-27 14:19:21 -0500
commit88b069141faafd1c5aefda1573b2285a38885ce4 (patch)
treea99e069672be94edd087ef49e7a22d23a0eb0fd0 /cashflow.h
initial commit
Diffstat (limited to 'cashflow.h')
-rw-r--r--cashflow.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/cashflow.h b/cashflow.h
new file mode 100644
index 0000000..9de01ae
--- /dev/null
+++ b/cashflow.h
@@ -0,0 +1,72 @@
+#ifndef CASHFLOW_H
+#define CASHFLOW_H
+
+#include <QMainWindow>
+#include <QTableWidget>
+#include <QDate>
+#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 onTransactionFieldChanged();
+ void onNewTransaction();
+ void onDeleteTransaction();
+ void onRecurringSelected();
+ void onSaveRecurring();
+ void onNewRecurring();
+ void onDeleteRecurring();
+ void onPeriodChanged();
+
+private:
+ Ui::CashFlow *ui;
+ Database *database;
+ int currentTransactionId;
+ int currentRecurringId;
+ double startingBalance;
+ QFont currentAmountFont;
+
+ enum PeriodType {
+ Daily,
+ Weekly,
+ Monthly,
+ Quarterly
+ };
+
+ void setupConnections();
+ void refreshView();
+ void refreshTransactionTable();
+ void refreshRecurringTable();
+ void calculateAndDisplayBalance();
+ QList<Transaction> getAllTransactionsInRange();
+ QList<Transaction> generateProjectedTransactions();
+ 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<QString, double> &accountBalances);
+ void updateAmountColors();
+ void loadSettings();
+ void applySettings();
+ void onSaveSettings();
+ void onChooseAmountFont();
+ QString formatCurrency(double amount) const;
+};
+#endif // CASHFLOW_H