Initial implementation of salemodel

This commit is contained in:
Martin Brodbeck 2018-07-25 16:04:45 +02:00
parent bc67018c1c
commit e24b6c4e5f
11 changed files with 212 additions and 1 deletions

View file

@ -24,6 +24,7 @@ bool Article::isSold() { return salePtr_ ? true : false; }
std::string Article::getDescription() { return description_; }
Seller* Article::getSeller() { return sellerPtr_; }
Sale* Article::getSale() { return salePtr_; }
int Article::getPrice() const { return price_; }

View file

@ -28,6 +28,7 @@ class Article : public Entity
int getArticleNo();
std::string getDescription();
Seller* getSeller();
Sale* getSale();
int getPrice() const;
std::string getPriceAsString() const;

View file

@ -29,6 +29,8 @@ void Marketplace::loadFromDb()
SellersVec& Marketplace::getSellers() { return sellers_; }
SalesVec& Marketplace::getSales() { return sales_; }
int Marketplace::getNextSellerNo()
{
auto iter = std::max_element(

View file

@ -26,6 +26,7 @@ class Marketplace
void loadFromDb();
SellersVec& getSellers();
SalesVec& getSales();
int getNextSellerNo();
int getNextArticleNo();
int getNumSellersDelete();

View file

@ -31,6 +31,13 @@ int Sale::sumInCents()
return sum;
}
std::string Sale::sumAsString()
{
std::stringstream sumStream;
sumStream << std::right << std::setw(12) << std::showbase << std::put_money(sumInCents(), false);
return sumStream.str();
}
std::string Sale::getTimestamp() { return timestamp_; }
void Sale::setTimestamp(const std::string& timestamp) { timestamp_ = timestamp; }

View file

@ -20,6 +20,7 @@ class Sale : public Entity
ArticlesVec& getArticles();
std::string getTimestamp();
int sumInCents();
std::string sumAsString();
void removeArticle(const Article* articlePtr);