57 lines
No EOL
1.4 KiB
C++
57 lines
No EOL
1.4 KiB
C++
#ifndef MARKETPLACE_H
|
|
#define MARKETPLACE_H
|
|
|
|
#include "article.h"
|
|
#include "sale.h"
|
|
#include "seller.h"
|
|
|
|
#include <vector>
|
|
|
|
namespace
|
|
{
|
|
using SellersVec = std::vector<std::unique_ptr<Seller>>;
|
|
using SalesVec = std::vector<std::unique_ptr<Sale>>;
|
|
using BasketVec = std::vector<std::unique_ptr<Article>>;
|
|
} // namespace
|
|
|
|
struct Basket {
|
|
};
|
|
|
|
class Marketplace
|
|
{
|
|
public:
|
|
Marketplace();
|
|
|
|
void storeToDb(bool onlyDelete = false);
|
|
void loadFromDb();
|
|
|
|
SellersVec& getSellers();
|
|
SalesVec& getSales();
|
|
int getNextSellerNo();
|
|
int getNextArticleNo();
|
|
int getNumSellersDelete();
|
|
BasketVec& getBasket();
|
|
int getBasketSumInCent();
|
|
std::string getBasketSumAsString();
|
|
|
|
void sortSellers();
|
|
Seller* findSellerWithSellerNo(int sellerNo);
|
|
void addArticleToBasket(std::unique_ptr<Article> article);
|
|
size_t basketSize();
|
|
void finishCurrentSale(std::unique_ptr<Sale> sale);
|
|
void removeSale(boost::uuids::uuid uuid);
|
|
|
|
void exportReportToCSV(const std::string& filename, int feeInPercent, int maxFeeInEuro);
|
|
|
|
private:
|
|
SellersVec sellers_;
|
|
SalesVec sales_;
|
|
BasketVec basket_;
|
|
};
|
|
|
|
double marketFee(int sumInCent, int percent, int maxFeeInCent);
|
|
std::string marketFeeAsString(int sumInCent, int percent, int maxFeeInCent);
|
|
std::string paymentAsString(int sumInCent, int percent, int maxFeeInCent);
|
|
std::string escapeCsvValue(const std::string& value, const char delimiter);
|
|
|
|
#endif |