-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpense.h
More file actions
89 lines (68 loc) · 2.33 KB
/
Expense.h
File metadata and controls
89 lines (68 loc) · 2.33 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Expense.h
*
* Created on: 27 Nov 2011
* Author: Max Foster
*/
#ifndef EXPENSE_H_
#define EXPENSE_H_
#include <fstream>
#include <ctime>
#include "Record.h"
class Expense : public Record
{
public:
enum Type
{
STOCK_MATERIALS = 0,
SUBCONTRACTOR,
PREMISES,
REPAIRS,
ADMIN,
MOTOR,
ADVERTISING,
DEBT,
OTHER
};
static const std::string databaseFilename;
static const int minDescriptionLength, maxDescriptionLength;
static int size();
Expense(const time_t date = 0, const char *description = "", const double price = 0.0,
const double vat = 0.0, const int type = 0);
Expense(const Expense &expense);
~Expense();
void operator =(const Expense &expense);
void writeToFile(std::fstream &file) const;
void readFromFile(std::fstream &file);
bool hasMatchingField(const std::string & fieldName, const time_t searchTerm) const;
bool hasMatchingField(const std::string & fieldName, const char *searchTerm) const;
bool hasMatchingField(const std::string & fieldName, const double searchTerm) const;
bool hasMatchingField(const std::string & fieldName, const int searchTerm) const;
bool fieldCompare(const Expense &rhs) const;
bool completeCompare(const Expense &rhs) const;
time_t getDate() const;
void setDate(const time_t newDate);
static bool isValidDate(const time_t value, std::string &errorMessage);
const char * getDescription() const;
void setDescription(const char *newDescription);
static bool isValidDescription(const char *value, std::string &errorMessage);
double getPrice() const;
void setPrice(const double newPrice);
static bool isValidPrice(const double value, std::string &errorMessage);
double getVat() const;
void setVat(const double newVat);
static bool isValidVat(const double value, std::string &errorMessage);
int getType() const;
std::string getTypeString() const;
void setType(const int newType);
static bool isValidType(const double value, std::string &errorMessage);
void validate() const;
double getTotalPrice() const;
private:
unsigned date;
char *description;
double price, vat;
int type;
};
std::ostream & operator <<(std::ostream &stream, const Expense &expense);
#endif /* EXPENSE_H_ */