Earning and Payment both inherit from Transaction
This commit is contained in:
parent
7bd0a69c62
commit
ecac206fce
@ -15,4 +15,4 @@ add_executable(${PROJECT_NAME} src/main.cpp src/main.h
|
|||||||
src/optHandlers/accountOptHandler.cpp src/optHandlers/accountOptHandler.h
|
src/optHandlers/accountOptHandler.cpp src/optHandlers/accountOptHandler.h
|
||||||
src/optHandlers/mainOptHandler.cpp src/optHandlers/mainOptHandler.h
|
src/optHandlers/mainOptHandler.cpp src/optHandlers/mainOptHandler.h
|
||||||
utilities/math.cpp utilities/math.h
|
utilities/math.cpp utilities/math.h
|
||||||
utilities/polynomialFunction.cpp utilities/polynomialFunction.h)
|
utilities/polynomialFunction.cpp utilities/polynomialFunction.h src/money/transaction.cpp src/money/transaction.h)
|
||||||
|
@ -72,7 +72,13 @@ int main(int argc, char *argv[]) {
|
|||||||
if (accountOptHandler.getSetOpts()->value) {
|
if (accountOptHandler.getSetOpts()->value) {
|
||||||
auto a = accounts.find(accountOptHandler.getSetOpts()->valueAccount);
|
auto a = accounts.find(accountOptHandler.getSetOpts()->valueAccount);
|
||||||
if (a != accounts.end()) {
|
if (a != accounts.end()) {
|
||||||
std::cout << "Account value: " << a->second.getAccount()->getValue() << std::endl;
|
int value = a->second.getAccount()->getValue();
|
||||||
|
std::vector<DateMoney> timeline = a->second.getAccount()->getTimeline();
|
||||||
|
printf("Account value: %n\n", &value);
|
||||||
|
printf("Last 10 payments:\n");
|
||||||
|
for (auto transaction : timeline) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (accountOptHandler.getSetOpts()->del) {
|
if (accountOptHandler.getSetOpts()->del) {
|
||||||
|
@ -4,8 +4,4 @@
|
|||||||
|
|
||||||
#include "earning.h"
|
#include "earning.h"
|
||||||
|
|
||||||
Earning::Earning(const int value, std::tm date) : value(value), date(date) {}
|
Earning::Earning(const int value, std::tm date) : Transaction(value, date) {}
|
||||||
|
|
||||||
tm *Earning::getDate() {
|
|
||||||
return &date;
|
|
||||||
}
|
|
||||||
|
@ -6,17 +6,11 @@
|
|||||||
#define BUDGET_EARNING_H
|
#define BUDGET_EARNING_H
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include "transaction.h"
|
||||||
|
|
||||||
class Earning {
|
class Earning : public Transaction {
|
||||||
public:
|
public:
|
||||||
const int value;
|
|
||||||
|
|
||||||
explicit Earning(int value, std::tm date);
|
explicit Earning(int value, std::tm date);
|
||||||
|
|
||||||
tm *getDate();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::tm date;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,15 +6,8 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
Payment::Payment(const int value, Receipt receipt, std::tm date) : value(value), receipt(std::move(receipt)),
|
Payment::Payment(const int value, Receipt receipt, std::tm date) : Transaction(value, date), receipt(std::move(receipt)) {}
|
||||||
date(date) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Receipt &Payment::getReceipt() {
|
Receipt &Payment::getReceipt() {
|
||||||
return receipt;
|
return receipt;
|
||||||
}
|
}
|
||||||
|
|
||||||
tm *Payment::getDate() {
|
|
||||||
return &date;
|
|
||||||
}
|
|
||||||
|
@ -6,23 +6,17 @@
|
|||||||
#define BUDGET_PAYMENT_H
|
#define BUDGET_PAYMENT_H
|
||||||
|
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
#include "recept.h"
|
#include "recept.h"
|
||||||
|
#include "transaction.h"
|
||||||
|
|
||||||
class Payment {
|
class Payment : public Transaction {
|
||||||
public:
|
public:
|
||||||
const int value;
|
|
||||||
|
|
||||||
Payment(int value, Receipt receipt, std::tm date);
|
Payment(int value, Receipt receipt, std::tm date);
|
||||||
|
|
||||||
Receipt &getReceipt();
|
Receipt &getReceipt();
|
||||||
|
|
||||||
tm *getDate();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Receipt receipt;
|
Receipt receipt;
|
||||||
std::tm date;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
11
src/money/transaction.cpp
Normal file
11
src/money/transaction.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// Created by quentin on 9/16/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "transaction.h"
|
||||||
|
|
||||||
|
Transaction::Transaction(const int value, const tm &date) : value(value), date(date) {}
|
||||||
|
|
||||||
|
tm *Transaction::getDate() {
|
||||||
|
return &date;
|
||||||
|
}
|
23
src/money/transaction.h
Normal file
23
src/money/transaction.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// Created by quentin on 9/16/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BUDGET_TRANSACTION_H
|
||||||
|
#define BUDGET_TRANSACTION_H
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
class Transaction {
|
||||||
|
public:
|
||||||
|
Transaction(int value, const tm &date);
|
||||||
|
|
||||||
|
const int value;
|
||||||
|
|
||||||
|
tm *getDate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::tm date;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //BUDGET_TRANSACTION_H
|
Loading…
x
Reference in New Issue
Block a user