diff --git a/src/core/sale.cpp b/src/core/sale.cpp index d15e286..1da00fc 100644 --- a/src/core/sale.cpp +++ b/src/core/sale.cpp @@ -8,6 +8,16 @@ void Sale::addArticle(std::shared_ptr
articlePtr) articles_.push_back(articlePtr); } +std::vector Sale::getArticles() +{ + std::vector articles(articles_.size()); + for (const auto& article : articles_) { + articles.push_back(article.get()); + } + + return articles; +} + void Sale::removeArticle(const Article* articlePtr) { auto it = std::find_if(articles_.begin(), articles_.end(), @@ -23,4 +33,8 @@ int Sale::sumInCents() int sum = std::accumulate(articles_.begin(), articles_.end(), 0, [](int a, std::shared_ptr
b) { return a + b->getPrice(); }); return sum; -} \ No newline at end of file +} + +std::string Sale::getTimestamp() { return timestamp_; } + +void Sale::setTimestamp(const std::string& timestamp) { timestamp_ = timestamp; } \ No newline at end of file diff --git a/src/core/sale.h b/src/core/sale.h index 0c38e51..f11f14c 100644 --- a/src/core/sale.h +++ b/src/core/sale.h @@ -5,19 +5,25 @@ #include -#include +#include "boost/date_time/posix_time/posix_time.hpp" class Article; class Sale : public Entity { public: - int sumInCents(); void addArticle(std::shared_ptr
articlePtr); + void setTimestamp(const std::string& timestamp); + + std::vector getArticles(); + std::string getTimestamp(); + int sumInCents(); + void removeArticle(const Article* articlePtr); private: - boost::posix_time::ptime systemTime_{boost::posix_time::second_clock::local_time()}; + std::string timestamp_{ + boost::posix_time::to_iso_extended_string(boost::posix_time::second_clock::local_time())}; std::vector> articles_{}; };