39 lines
846 B
C++

//
// Created by Nik on 07/04/2022.
//
#include "Invoice.h"
//int Invoice::countId = 0;
Invoice::Invoice(std::string seller) : seller(seller){
countId += 1;
id = countId;
}
Invoice::~Invoice() {
countId -= 1;
}
void Invoice::addArticle(Article *a) {
for(int i = 0; i < articels.size(); i++){
if(articels[i]->hasSameCode(a)){
articels[i]->increseQuantity();
return;
}
}
articels.push_back(a);
}
void Invoice::print() const {
double skupaj = 0.0;
std::cout << seller << " " << std::to_string(id) << "\n";
for(int i = 0; i < articels.size(); i++){
std::cout << articels[i]->toSting() << "\n";
skupaj += articels[i]->getTotalPrice();
}
std::cout << "skupna cena " << std::to_string(skupaj) << " E \n\n";
}