checks-parser/check/check.cpp

76 lines
2.1 KiB
C++

#include "check.h"
#include "../goods/goods.h"
#include <QObject>
Check::Check() {}
Check::Check(std::string date, double total, OperationType type, std::string fn, std::string fd, std::string fi, std::vector<Goods> goods) {
set_date(date);
set_total(total);
set_operation_type(type);
set_fn(fn);
set_fd(fd);
set_fi(fi);
set_goods(goods);
}
void Check::add_goods(Goods goods) {
this->goods.push_back(goods);
this->total = this->calculae_total_price();
}
void Check::add_goods(std::vector<Goods> &goods) {
for (auto &g : goods) {
this->goods.push_back(g);
}
this->total = this->calculae_total_price();
}
double Check::calculae_total_price() {
double total = 0.0;
for (Goods &g : goods) {
total += g.calculate_total_price();
}
return total;
}
std::vector<Goods>& Check::get_goods() { return goods; }
void Check::set_fn(std::string fn) { this->fn = fn; }
void Check::set_fd(std::string fd) { this->fd = fd; }
void Check::set_fi(std::string fi) { this->fi = fi; }
std::string Check::get_date() { return date; }
OperationType Check::get_operationType() { return operation_type; }
void Check::set_date(std::string date) { this->date = date; }
void Check::set_operation_type(OperationType t) { this->operation_type = t; }
void Check::set_total(double total) { this->total = total; }
void Check::set_goods(std::vector<Goods> goods) { this->goods = goods; }
std::string Check::get_fn() { return fn; }
std::string Check::get_fd() { return fd; }
std::string Check::get_fi() { return fi; }
double Check::get_total() { return total; }
bool Check::operator==(Check &c) {
return
this->date == c.date &&
this->fd == c.fd &&
this->fi == c.fi &&
this->fn == c.fn &&
this->operation_type == c.operation_type &&
this->total == c.total;
}
bool Check::operator==(const Check &c) {
return
this->date == c.date &&
this->fd == c.fd &&
this->fi == c.fi &&
this->fn == c.fn &&
this->operation_type == c.operation_type &&
this->total == c.total;
}
Q_DECLARE_METATYPE(Check)