Compare commits

..

No commits in common. "cdc737a823284decafb03cd222f0db0375c79665" and "d1c5d3a6f8e492e0f1cb2a4808694928a6707aab" have entirely different histories.

6 changed files with 7 additions and 43 deletions

View file

@ -81,13 +81,12 @@ QVariant BasketModel::headerData(int section, Qt::Orientation orientation, int r
return ""; return "";
} }
void BasketModel::addArticle(Seller* seller, int price, const std::string& desc) void BasketModel::addArticle(Seller* seller, int price)
{ {
emit beginInsertRows(QModelIndex(), marketplace_->getBasket().size(), emit beginInsertRows(QModelIndex(), marketplace_->getBasket().size(),
marketplace_->getBasket().size()); marketplace_->getBasket().size());
auto article = std::make_unique<Article>(price); auto article = std::make_unique<Article>(price);
article->createUuid(); article->createUuid();
article->setDescription(desc);
article->setArticleNo(marketplace_->getNextArticleNo()); article->setArticleNo(marketplace_->getNextArticleNo());
article->setSourceNo(QSettings().value("global/cashPointNo").toInt()); article->setSourceNo(QSettings().value("global/cashPointNo").toInt());
article->setSeller(seller); article->setSeller(seller);

View file

@ -18,7 +18,7 @@ class BasketModel : public QAbstractTableModel
//virtual Qt::ItemFlags flags(const QModelIndex& index) const override; //virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
//virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; //virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
//virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; //virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
void addArticle(Seller* seller, int price, const std::string& desc); void addArticle(Seller* seller, int price);
void finishSale(); void finishSale();
void cancelSale(); void cancelSale();
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;

View file

@ -149,8 +149,7 @@ void MainWindow::onSellerNoEditCheckSellerNo()
auto dialogResult = priceDialog.exec(); auto dialogResult = priceDialog.exec();
if (dialogResult == QDialog::Accepted) { if (dialogResult == QDialog::Accepted) {
int price = priceDialog.getPrice(); int price = priceDialog.getPrice();
std::string desc = priceDialog.getDescription(); dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price);
dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price, desc);
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str()); ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
} }
} }

View file

@ -12,8 +12,6 @@ PriceDialog::PriceDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f
int PriceDialog::getPrice() const { return static_cast<int>(ui_.priceSpinBox->value() * 100); } int PriceDialog::getPrice() const { return static_cast<int>(ui_.priceSpinBox->value() * 100); }
std::string PriceDialog::getDescription() const { return ui_.descEdit->text().toStdString(); }
void PriceDialog::accept() void PriceDialog::accept()
{ {
if (static_cast<int>(std::round(ui_.priceSpinBox->value() * 100.0L)) % 50 != 0) { if (static_cast<int>(std::round(ui_.priceSpinBox->value() * 100.0L)) % 50 != 0) {

View file

@ -13,7 +13,6 @@ class PriceDialog : public QDialog
PriceDialog(QWidget* parent = nullptr, PriceDialog(QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint); Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
int getPrice() const; int getPrice() const;
std::string getDescription() const;
private: private:
void on_model_duplicateSellerNo(const QString& message); void on_model_duplicateSellerNo(const QString& message);

View file

@ -89,8 +89,8 @@ void ReportDialog::onPrintReportButtonClicked()
for (unsigned int j = 0; j < ENTRIES_PER_PAGE && (i * j) < sellers.size(); ++j) { for (unsigned int j = 0; j < ENTRIES_PER_PAGE && (i * j) < sellers.size(); ++j) {
content += QString("%1 %2 %3 %4 %5 %6 %7\n") content += QString("%1 %2 %3 %4 %5 %6 %7\n")
.arg(sellers.at(i * j)->getSellerNo(), 3) .arg(sellers.at(i * j)->getSellerNo(), 3)
.arg(sellers.at(i * j)->getLastName().substr(0, 14).c_str(), -14) .arg(sellers.at(i * j)->getLastName().c_str(), -14)
.arg(sellers.at(i * j)->getFirstName().substr(0, 14).c_str(), -14) .arg(sellers.at(i * j)->getFirstName().c_str(), -14)
.arg(sellers.at(i * j)->numArticlesOffered(), 9) .arg(sellers.at(i * j)->numArticlesOffered(), 9)
.arg(sellers.at(i * j)->numArticlesSold(), 8) .arg(sellers.at(i * j)->numArticlesSold(), 8)
.arg(sellers.at(i * j)->sumAsString().c_str(), 10) .arg(sellers.at(i * j)->sumAsString().c_str(), 10)
@ -102,44 +102,13 @@ void ReportDialog::onPrintReportButtonClicked()
painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content); painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content);
} }
// pieces booked on the special account "Sonderkonto" // now print the overall statistics
const auto specialSeller = market_->findSellerWithUuid("11111111-1111-1111-1111-111111111111");
if (specialSeller && specialSeller->numArticlesSold() > 0) {
printer.newPage();
painter.setFont(QFont("Arial", 16, QFont::Bold));
painter.drawText(QRect(0, 0, width, height), Qt::AlignTop | Qt::AlignHCenter,
"Auswertung Kindersachenmarkt");
painter.setFont(QFont("monospace", 12));
QString content("Einzelteile ohne Nummer\n=======================\n\n");
unsigned int lines{0};
unsigned int pages{1};
for (const auto& article : specialSeller->getArticles(true)) {
content += QString("- %1:").arg(article->getDescription().substr(0, 45).c_str(), -45);
content += QString("%1\n").arg(article->getPriceAsString().c_str(), 11);
++lines;
if (lines % static_cast<int>(ENTRIES_PER_PAGE) == 0 &&
(pages * lines) < specialSeller->getArticles(true).size()) {
painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content);
lines = 0;
++pages;
printer.newPage();
painter.setFont(QFont("Arial", 16, QFont::Bold));
painter.drawText(QRect(0, 0, width, height), Qt::AlignTop | Qt::AlignHCenter,
"Auswertung Kindersachenmarkt");
painter.setFont(QFont("monospace", 12));
content = "Einzelteile ohne Nummer\n=======================\n\n";
}
}
painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content);
}
// overall statistics
printer.newPage(); printer.newPage();
painter.setFont(QFont("Arial", 16, QFont::Bold)); painter.setFont(QFont("Arial", 16, QFont::Bold));
painter.drawText(QRect(0, 0, width, height), Qt::AlignTop | Qt::AlignHCenter, painter.drawText(QRect(0, 0, width, height), Qt::AlignTop | Qt::AlignHCenter,
"Auswertung Kindersachenmarkt"); "Auswertung Kindersachenmarkt");
painter.setFont(QFont("monospace", 12)); painter.setFont(QFont("monospace", 12));
QString content("Gesamtstatistik\n===============\n\n"); QString content("Gesamtstatistik\n---------------\n\n");
content += QString("Registrierte Verkäufer: %1\n").arg(sellers.size(), 6); content += QString("Registrierte Verkäufer: %1\n").arg(sellers.size(), 6);
content += QString("Verkaufte Artikel: %1\n\n").arg(6, 6); content += QString("Verkaufte Artikel: %1\n\n").arg(6, 6);
content += QString("Gesamtumsatz: %1\n").arg(market_->getOverallSumAsString().c_str(), 10); content += QString("Gesamtumsatz: %1\n").arg(market_->getOverallSumAsString().c_str(), 10);