kima2/src/core/marketplace.h

74 lines
2 KiB
C
Raw Normal View History

2018-07-13 13:04:19 +02:00
#ifndef MARKETPLACE_H
#define MARKETPLACE_H
#include "article.h"
2019-10-07 14:08:01 +02:00
#include "database.h"
2018-07-13 13:04:19 +02:00
#include "sale.h"
#include "seller.h"
#include <filesystem>
2018-07-13 13:04:19 +02:00
#include <vector>
2018-08-01 15:36:41 +02:00
class ExcelReader;
2018-07-20 11:52:26 +02:00
namespace
{
using SellersVec = std::vector<std::unique_ptr<Seller>>;
using SalesVec = std::vector<std::unique_ptr<Sale>>;
2018-07-21 19:24:56 +02:00
using BasketVec = std::vector<std::unique_ptr<Article>>;
2018-07-20 11:52:26 +02:00
} // namespace
2018-07-13 13:04:19 +02:00
class Marketplace
{
public:
2018-07-16 12:00:17 +02:00
Marketplace();
2018-07-21 21:18:22 +02:00
void storeToDb(bool onlyDelete = false);
Database::InitResult loadFromDb();
2018-07-22 20:10:22 +02:00
2018-07-20 11:52:26 +02:00
SellersVec& getSellers();
2018-07-25 16:04:45 +02:00
SalesVec& getSales();
2018-07-16 18:04:25 +02:00
int getNextSellerNo();
2018-07-22 20:10:22 +02:00
int getNextArticleNo();
2018-07-17 15:32:16 +02:00
int getNumSellersDelete();
int getNumArticlesSold();
2018-08-15 11:25:45 +02:00
int getNumArticlesOffered();
2018-07-22 20:10:22 +02:00
BasketVec& getBasket();
2018-07-23 14:18:24 +02:00
int getBasketSumInCent();
std::string getBasketSumAsString();
2018-07-22 20:10:22 +02:00
2018-07-18 09:00:46 +02:00
void sortSellers();
2018-07-20 22:07:42 +02:00
Seller* findSellerWithSellerNo(int sellerNo);
2018-08-05 14:52:34 +02:00
Seller* findSellerWithUuid(const std::string& uuid);
2018-07-21 19:24:56 +02:00
void addArticleToBasket(std::unique_ptr<Article> article);
2018-07-21 21:18:22 +02:00
size_t basketSize();
2018-07-30 14:43:02 +02:00
void finishCurrentSale(std::unique_ptr<Sale> sale);
2018-07-28 11:52:43 +02:00
void removeSale(boost::uuids::uuid uuid);
2018-08-05 14:52:34 +02:00
void setSalesToDelete(int cashPointNo);
2018-07-16 12:00:17 +02:00
2018-07-31 16:15:48 +02:00
int getOverallSumInCent();
std::string getOverallSumAsString();
int getOverallPaymentInCent(int percent, int maxFee);
std::string getOverallPaymentAsString(int percent, int maxFee);
std::string getOverallRevenueAsString(int percent, int maxFee);
2018-08-08 10:22:38 +02:00
void clear();
void exportReportToCSV(const std::filesystem::path& filePath, int feeInPercent,
int maxFeeInEuro);
2018-07-31 10:28:07 +02:00
2018-08-01 15:36:41 +02:00
friend class ExcelReader;
2018-07-13 13:04:19 +02:00
private:
2018-08-10 15:15:12 +02:00
SellersVec sellers_;
SalesVec sales_;
BasketVec basket_;
2018-07-13 13:04:19 +02:00
};
2018-07-30 15:19:29 +02:00
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);
2018-07-31 10:28:07 +02:00
std::string escapeCsvValue(const std::string& value, const char delimiter);
2018-07-30 09:50:54 +02:00
#endif