fully support special seller "Sonderkonto"

This commit is contained in:
Martin Brodbeck 2018-08-07 09:27:15 +02:00
parent a3b832b087
commit a7a83ba3b9
6 changed files with 24 additions and 4 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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());
}
}

View file

@ -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) {

View file

@ -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);

View file

@ -111,9 +111,24 @@ void ReportDialog::onPrintReportButtonClicked()
"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:\t").arg(article->getDescription().c_str(), -45);
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);
}