Compare commits
3 commits
d1c5d3a6f8
...
cdc737a823
Author | SHA1 | Date | |
---|---|---|---|
cdc737a823 | |||
a7a83ba3b9 | |||
a3b832b087 |
6 changed files with 43 additions and 7 deletions
|
@ -81,12 +81,13 @@ QVariant BasketModel::headerData(int section, Qt::Orientation orientation, int r
|
|||
return "";
|
||||
}
|
||||
|
||||
void BasketModel::addArticle(Seller* seller, int price)
|
||||
void BasketModel::addArticle(Seller* seller, int price, const std::string& desc)
|
||||
{
|
||||
emit beginInsertRows(QModelIndex(), marketplace_->getBasket().size(),
|
||||
marketplace_->getBasket().size());
|
||||
auto article = std::make_unique<Article>(price);
|
||||
article->createUuid();
|
||||
article->setDescription(desc);
|
||||
article->setArticleNo(marketplace_->getNextArticleNo());
|
||||
article->setSourceNo(QSettings().value("global/cashPointNo").toInt());
|
||||
article->setSeller(seller);
|
||||
|
|
|
@ -18,7 +18,7 @@ class BasketModel : public QAbstractTableModel
|
|||
//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 insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
||||
void addArticle(Seller* seller, int price);
|
||||
void addArticle(Seller* seller, int price, const std::string& desc);
|
||||
void finishSale();
|
||||
void cancelSale();
|
||||
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
||||
|
|
|
@ -149,7 +149,8 @@ void MainWindow::onSellerNoEditCheckSellerNo()
|
|||
auto dialogResult = priceDialog.exec();
|
||||
if (dialogResult == QDialog::Accepted) {
|
||||
int price = priceDialog.getPrice();
|
||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price);
|
||||
std::string desc = priceDialog.getDescription();
|
||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price, desc);
|
||||
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ PriceDialog::PriceDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f
|
|||
|
||||
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()
|
||||
{
|
||||
if (static_cast<int>(std::round(ui_.priceSpinBox->value() * 100.0L)) % 50 != 0) {
|
||||
|
|
|
@ -13,6 +13,7 @@ class PriceDialog : public QDialog
|
|||
PriceDialog(QWidget* parent = nullptr,
|
||||
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
||||
int getPrice() const;
|
||||
std::string getDescription() const;
|
||||
|
||||
private:
|
||||
void on_model_duplicateSellerNo(const QString& message);
|
||||
|
|
|
@ -89,8 +89,8 @@ void ReportDialog::onPrintReportButtonClicked()
|
|||
for (unsigned int j = 0; j < ENTRIES_PER_PAGE && (i * j) < sellers.size(); ++j) {
|
||||
content += QString("%1 %2 %3 %4 %5 %6 %7\n")
|
||||
.arg(sellers.at(i * j)->getSellerNo(), 3)
|
||||
.arg(sellers.at(i * j)->getLastName().c_str(), -14)
|
||||
.arg(sellers.at(i * j)->getFirstName().c_str(), -14)
|
||||
.arg(sellers.at(i * j)->getLastName().substr(0, 14).c_str(), -14)
|
||||
.arg(sellers.at(i * j)->getFirstName().substr(0, 14).c_str(), -14)
|
||||
.arg(sellers.at(i * j)->numArticlesOffered(), 9)
|
||||
.arg(sellers.at(i * j)->numArticlesSold(), 8)
|
||||
.arg(sellers.at(i * j)->sumAsString().c_str(), 10)
|
||||
|
@ -102,13 +102,44 @@ void ReportDialog::onPrintReportButtonClicked()
|
|||
painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content);
|
||||
}
|
||||
|
||||
// now print the overall statistics
|
||||
// pieces booked on the special account "Sonderkonto"
|
||||
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("Gesamtstatistik\n---------------\n\n");
|
||||
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();
|
||||
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("Gesamtstatistik\n===============\n\n");
|
||||
content += QString("Registrierte Verkäufer: %1\n").arg(sellers.size(), 6);
|
||||
content += QString("Verkaufte Artikel: %1\n\n").arg(6, 6);
|
||||
content += QString("Gesamtumsatz: %1\n").arg(market_->getOverallSumAsString().c_str(), 10);
|
||||
|
|
Loading…
Reference in a new issue