fixed only handling two fields of a check
This commit is contained in:
		@@ -1,9 +1,19 @@
 | 
			
		||||
#include "check.h"
 | 
			
		||||
#include "../goods/goods.h"
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#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();
 | 
			
		||||
@@ -25,50 +35,24 @@ double Check::calculae_total_price() {
 | 
			
		||||
    return total;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::vector<Goods>& Check::get_goods() {
 | 
			
		||||
    return goods;
 | 
			
		||||
}
 | 
			
		||||
std::vector<Goods>& Check::get_goods() { return goods; }
 | 
			
		||||
 | 
			
		||||
void Check::set_fn(std::string fn) {
 | 
			
		||||
    this->fn = fn;
 | 
			
		||||
}
 | 
			
		||||
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_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;
 | 
			
		||||
}
 | 
			
		||||
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) {
 | 
			
		||||
    // 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 &&
 | 
			
		||||
@@ -79,13 +63,6 @@ bool Check::operator==(Check &c) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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 &&
 | 
			
		||||
@@ -94,3 +71,5 @@ bool Check::operator==(const Check &c) {
 | 
			
		||||
        this->operation_type == c.operation_type &&
 | 
			
		||||
        this->total == c.total;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(Check)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
#ifndef CHECK_H
 | 
			
		||||
#define CHECK_H
 | 
			
		||||
#include "../goods/goods.h"
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
typedef enum OperationTypes {
 | 
			
		||||
@@ -23,6 +24,7 @@ class Check {
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    Check();
 | 
			
		||||
    Check(std::string date, double total, OperationType type, std::string fn, std::string fd, std::string fi, std::vector<Goods> goods);
 | 
			
		||||
    void add_goods(Goods);
 | 
			
		||||
    void add_goods(std::vector<Goods> &goods);
 | 
			
		||||
 | 
			
		||||
@@ -37,6 +39,8 @@ public:
 | 
			
		||||
    void set_operation_type(OperationType);
 | 
			
		||||
    void set_total(double);
 | 
			
		||||
 | 
			
		||||
    void set_goods(std::vector<Goods>);
 | 
			
		||||
 | 
			
		||||
    std::string get_fn();
 | 
			
		||||
    std::string get_fd();
 | 
			
		||||
    std::string get_fi();
 | 
			
		||||
@@ -48,4 +52,5 @@ public:
 | 
			
		||||
    bool operator==(const Check &);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // CHECK_H
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user