checks-parser/check/check.cpp

97 lines
2.4 KiB
C++

#include "check.h"
#include "../goods/goods.h"
#include <iostream>
Check::Check() {}
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;
}
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;
}
double Check::get_total() {
return total;
}
bool Check::operator==(Check &c) {
// std::cout << "Comparing" << std::endl;
// std::cout << this->date << " <>" << c.date << std::endl;
// std::cout << this->fd << " <>" << c.fd << std::endl;
// std::cout << this->fi<< " <>" << c.fi << std::endl;
// std::cout << this->fn<< " <>" << c.fn << std::endl;
// std::cout << this->operation_type << " <>" << c.operation_type << std::endl;
// std::cout << this->total<< " <>" << c.total<< std::endl;
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) {
// std::cout << "Comparing" << std::endl;
// std::cout << this->date << " <>" << c.date << std::endl;
// std::cout << this->fd << " <>" << c.fd << std::endl;
// std::cout << this->fi<< " <>" << c.fi << std::endl;
// std::cout << this->fn<< " <>" << c.fn << std::endl;
// std::cout << this->operation_type << " <>" << c.operation_type << std::endl;
// std::cout << this->total<< " <>" << c.total<< std::endl;
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;
}