-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJob.h
More file actions
105 lines (79 loc) · 3.02 KB
/
Job.h
File metadata and controls
105 lines (79 loc) · 3.02 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Job.h
*
* Created on: 27 Nov 2011
* Author: Max Foster
*/
#ifndef JOB_H_
#define JOB_H_
#include <fstream>
#include <ctime>
#include "Record.h"
class Job : public Record
{
public:
enum CompletionState
{
NOT_DONE = 0,
DONE_UNPAID,
DONE_PAID
};
enum PaymentMethod
{
NA = 0,
CASH,
CHEQUE,
CREDIT,
DEBIT,
BANK_TRANSFER
};
static const std::string databaseFilename;
static const int minDescriptionLength, maxDescriptionLength;
static int size();
Job(const int customerId = -1, const time_t date = 0, const char *description = "", const double labourCharge = 0.0,
const int completionState = 0, const int paymentMethod = 0, const time_t paymentDate = 0);
Job(const Job &job);
~Job();
void operator =(const Job &job);
void writeToFile(std::fstream &file) const;
void readFromFile(std::fstream &file);
bool hasMatchingField(const std::string &fieldName, const int searchTerm) const;
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 fieldCompare(const Job &rhs) const;
bool completeCompare(const Job &rhs) const;
int getCustomerId() const;
void setCustomerId(const int newCustomerId);
static bool isValidCustomerId(const int value, std::string &errorMessage);
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 getLabourCharge() const;
void setLabourCharge(const double newLabourCharge); // Recalculates VAT
static bool isValidLabourCharge(const double value, std::string &errorMessage);
double getVat() const; // No setter because VAT is automatically calculated
int getCompletionState() const;
std::string getCompletionStateString() const;
void setCompletionState(const int newCompletionState);
static bool isValidCompletionState(const int value, std::string &errorMessage);
int getPaymentMethod() const;
std::string getPaymentMethodString() const;
void setPaymentMethod(const int newPaymentMethod);
static bool isValidPaymentMethod(const int value, std::string &errorMessage);
time_t getPaymentDate() const;
void setPaymentDate(const time_t newPaymentDate);
static bool isValidPaymentDate(const time_t value, std::string &errorMessage);
void validate() const;
double getTotalPrice() const;
private:
int customerId, completionState, paymentMethod;
unsigned date, paymentDate;
char *description;
double labourCharge, vat;
};
std::ostream & operator <<(std::ostream &stream, const Job &job);
#endif /* JOB_H_ */