diff --git a/src/core/marketplace.cpp b/src/core/marketplace.cpp index 4913317..38abcf9 100644 --- a/src/core/marketplace.cpp +++ b/src/core/marketplace.cpp @@ -150,10 +150,10 @@ std::string marketFeeAsString(int sum, int percent, int maxFee) return feeStream.str(); } -std::string paymentAsString(int sum, int percent) +std::string paymentAsString(int sumInCent, int percent, int maxFeeInCent) { std::stringstream feeStream; feeStream << std::right << std::setw(10) << std::showbase - << std::put_money(sum - marketFee(sum, percent), false); + << std::put_money(sumInCent - marketFee(sumInCent, percent, maxFeeInCent), false); return feeStream.str(); } \ No newline at end of file diff --git a/src/core/marketplace.h b/src/core/marketplace.h index b5c63a4..203079d 100644 --- a/src/core/marketplace.h +++ b/src/core/marketplace.h @@ -47,8 +47,8 @@ class Marketplace BasketVec basket_; }; -double marketFee(int sum, int percent, int maxFee = 5000); -std::string marketFeeAsString(int sum, int percent, int maxFee = 5000); -std::string paymentAsString(int sum, int percent); +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); #endif \ No newline at end of file diff --git a/src/gui/reportmodel.cpp b/src/gui/reportmodel.cpp index 45ff334..4cd2feb 100644 --- a/src/gui/reportmodel.cpp +++ b/src/gui/reportmodel.cpp @@ -1,10 +1,15 @@ #include "reportmodel.h" #include +#include ReportModel::ReportModel(Marketplace* market, QObject* parent) : QAbstractTableModel(parent), market_(market) { + QSettings settings; + feeInPercent_ = settings.value("global/feeInPercent").toInt(); + maxFeeInCent_ = settings.value("global/maxFeeInEuro").toInt() * 100; + } int ReportModel::rowCount([[maybe_unused]] const QModelIndex& parent) const @@ -67,7 +72,7 @@ QVariant ReportModel::data(const QModelIndex& index, int role) const case 5: return seller->sumAsString().c_str(); case 6: - return paymentAsString(seller->sumInCents(), 20).c_str(); + return paymentAsString(seller->sumInCents(), feeInPercent_, maxFeeInCent_).c_str(); default: return "???"; } diff --git a/src/gui/reportmodel.h b/src/gui/reportmodel.h index f880e03..6509d2f 100644 --- a/src/gui/reportmodel.h +++ b/src/gui/reportmodel.h @@ -16,6 +16,8 @@ class ReportModel : public QAbstractTableModel private: Marketplace* market_; + int feeInPercent_{}; + int maxFeeInCent_{}; }; #endif \ No newline at end of file