fully support special seller "Sonderkonto"
This commit is contained in:
parent
a3b832b087
commit
a7a83ba3b9
6 changed files with 24 additions and 4 deletions
|
@ -81,12 +81,13 @@ QVariant BasketModel::headerData(int section, Qt::Orientation orientation, int r
|
||||||
return "";
|
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(),
|
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);
|
||||||
|
|
|
@ -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);
|
void addArticle(Seller* seller, int price, const std::string& desc);
|
||||||
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;
|
||||||
|
|
|
@ -149,7 +149,8 @@ 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();
|
||||||
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());
|
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); }
|
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) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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);
|
||||||
|
|
|
@ -111,9 +111,24 @@ void ReportDialog::onPrintReportButtonClicked()
|
||||||
"Auswertung Kindersachenmarkt");
|
"Auswertung Kindersachenmarkt");
|
||||||
painter.setFont(QFont("monospace", 12));
|
painter.setFont(QFont("monospace", 12));
|
||||||
QString content("Einzelteile ohne Nummer\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)) {
|
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);
|
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);
|
painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue