kima2/src/core/sale.h

41 lines
836 B
C
Raw Normal View History

2018-07-11 12:53:18 +02:00
#ifndef SALE_H
#define SALE_H
2018-07-12 13:34:17 +02:00
#include "article.h"
2018-07-11 12:53:18 +02:00
2018-07-12 13:34:17 +02:00
#include <vector>
2018-07-13 10:51:07 +02:00
#include "boost/date_time/posix_time/posix_time.hpp"
2018-07-12 13:34:17 +02:00
2018-07-28 11:52:43 +02:00
// class Article;
2018-07-12 13:34:17 +02:00
2018-07-28 11:52:43 +02:00
namespace
{
2018-07-20 11:52:26 +02:00
using ArticlesVec = std::vector<Article*>;
2018-07-28 11:52:43 +02:00
}
2018-07-20 11:52:26 +02:00
2019-10-04 14:05:19 +02:00
class Sale : public EntityUuid
2018-07-12 13:34:17 +02:00
{
public:
2019-10-07 13:58:10 +02:00
Sale() = default;
Sale(const Sale&) = delete;
virtual ~Sale() = default;
2018-07-20 11:52:26 +02:00
void addArticle(Article* articlePtr);
2018-07-13 10:51:07 +02:00
void setTimestamp(const std::string& timestamp);
2018-07-20 11:52:26 +02:00
ArticlesVec& getArticles();
2018-08-06 16:14:45 +02:00
std::string getTimestamp() const;
2018-08-06 21:31:40 +02:00
std::string getTimestampFormatted() const;
2018-07-13 10:51:07 +02:00
int sumInCents();
2018-07-25 16:04:45 +02:00
std::string sumAsString();
2018-07-13 10:51:07 +02:00
2018-07-13 10:12:16 +02:00
void removeArticle(const Article* articlePtr);
2018-07-12 13:34:17 +02:00
private:
2018-07-13 10:51:07 +02:00
std::string timestamp_{
boost::posix_time::to_iso_extended_string(boost::posix_time::second_clock::local_time())};
2018-08-06 16:14:45 +02:00
mutable ArticlesVec articles_{};
2018-07-11 12:53:18 +02:00
};
2019-10-04 14:05:19 +02:00
#endif