aboutsummaryrefslogtreecommitdiff
path: root/transaction.h
blob: 8aa0a0689ffc0aeb9eba020c2c5313b156ef5a34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef TRANSACTION_H
#define TRANSACTION_H

#include <QString>
#include <QDate>

enum class TransactionType {
    Estimated,
    Actual
};

enum class RecurrenceFrequency {
    None,
    Daily,
    Weekly,
    BiWeekly,
    Monthly,
    Yearly
};

struct Transaction {
    int id;
    QDate date;
    double amount;
    QString account;
    QString category;
    QString description;
    TransactionType type;
    int recurringId; // -1 if not part of recurring series
    int sortOrder;   // For ordering on same date
    
    Transaction() : id(-1), amount(0.0), type(TransactionType::Estimated), recurringId(-1), sortOrder(0) {}
    
    double getBalance() const { return amount; }
};

struct RecurringRule {
    int id;
    QString name;
    RecurrenceFrequency frequency;
    QDate startDate;
    QDate endDate; // Can be null for indefinite
    double amount;
    QString account;
    QString category;
    QString description;
    int dayOfWeek;    // 1-7 for weekly (1=Monday), -1 if not applicable
    int dayOfMonth;   // 1-31 for monthly, -1 if not applicable
    int occurrences;  // Number of times to repeat, -1 for indefinite
    int sortOrder;    // For ordering transactions on same date
    
    RecurringRule() : id(-1), frequency(RecurrenceFrequency::None), 
                     amount(0.0), dayOfWeek(-1), dayOfMonth(-1), occurrences(-1), sortOrder(0) {}
};

#endif // TRANSACTION_H