kima2/src/core/article.cpp

46 lines
1.4 KiB
C++

#include "article.h"
#include <iomanip>
#include <sstream>
// Article::Article() : Entity() {}
Article::Article(int price) : price_(price) {}
// Article::Article(std::shared_ptr<Seller> sellerPtr) : Entity() { sellerPtr_ = sellerPtr; }
void Article::setArticleNo(int articleNo) { articleNo_ = articleNo; }
void Article::setPrice(int price) { price_ = price; }
void Article::setDescription(const std::string& description) { description_ = description; }
void Article::setSale(Sale* salePtr) { salePtr_ = salePtr; }
void Article::setSeller(Seller* sellerPtr) { sellerPtr_ = sellerPtr; }
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_; }
std::string Article::getPriceAsString() const
{
std::stringstream sumStream;
// sumStream.imbue(std::locale("de_DE.utf8"));
sumStream << std::right << std::setw(10) << std::showbase << std::put_money(price_, false);
return sumStream.str();
}
int Article::getArticleNo() const { return articleNo_; }
std::string Article::getCompleteArticleNo() const
{
std::stringstream artNoStream;
artNoStream << sourceNo_ << "K" << std::setfill('0') << std::setw(5) << articleNo_;
return artNoStream.str();
}