printing of seller receipt works now
This commit is contained in:
parent
4a92832e19
commit
f45e295c75
5 changed files with 50 additions and 11 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <posprinter.h>
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
@ -20,6 +22,10 @@ ReportDialog::ReportDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
|
||||||
&ReportDialog::onExportCsvButtonClicked);
|
&ReportDialog::onExportCsvButtonClicked);
|
||||||
connect(ui_.printReportButton, &QPushButton::clicked, this,
|
connect(ui_.printReportButton, &QPushButton::clicked, this,
|
||||||
&ReportDialog::onPrintReportButtonClicked);
|
&ReportDialog::onPrintReportButtonClicked);
|
||||||
|
connect(ui_.printSellerReceiptButton, &QPushButton::clicked, this,
|
||||||
|
&ReportDialog::onPrintSellerReceiptButtonClicked);
|
||||||
|
connect(ui_.reportView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
|
&ReportDialog::onReportViewSelectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDialog::onExportCsvButtonClicked()
|
void ReportDialog::onExportCsvButtonClicked()
|
||||||
|
@ -106,11 +112,40 @@ void ReportDialog::onPrintReportButtonClicked()
|
||||||
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);
|
||||||
content += QString("Ausgezahlt: %1\n")
|
content +=
|
||||||
.arg(market_->getOverallPaymentAsString(feeInPercent, maxFeeInEuro * 100).c_str(), 10);
|
QString("Ausgezahlt: %1\n")
|
||||||
content += QString("Verbleibend: %1\n")
|
.arg(market_->getOverallPaymentAsString(feeInPercent, maxFeeInEuro * 100).c_str(), 10);
|
||||||
.arg(market_->getOverallRevenueAsString(feeInPercent, maxFeeInEuro * 100).c_str(), 10);
|
content +=
|
||||||
|
QString("Verbleibend: %1\n")
|
||||||
|
.arg(market_->getOverallRevenueAsString(feeInPercent, maxFeeInEuro * 100).c_str(), 10);
|
||||||
painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content);
|
painter.drawText(QRect(0, 50, width, height), Qt::AlignLeft, content);
|
||||||
|
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReportDialog::onPrintSellerReceiptButtonClicked()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
||||||
|
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
||||||
|
|
||||||
|
auto selModel = ui_.reportView->selectionModel();
|
||||||
|
if (selModel->hasSelection() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto indexes = selModel->selectedRows();
|
||||||
|
auto& seller = market_->getSellers().at(indexes[0].row());
|
||||||
|
PosPrinter printer;
|
||||||
|
if (printer.isValid())
|
||||||
|
printer.printSellerReceipt(seller.get(), feeInPercent, maxFeeInEuro * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportDialog::onReportViewSelectionChanged(const QItemSelection& selected,
|
||||||
|
[[maybe_unused]] const QItemSelection& deselected)
|
||||||
|
{
|
||||||
|
if (selected.size() > 0) {
|
||||||
|
ui_.printSellerReceiptButton->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
ui_.printSellerReceiptButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,9 +20,11 @@ class ReportDialog : public QDialog
|
||||||
private slots:
|
private slots:
|
||||||
void onExportCsvButtonClicked();
|
void onExportCsvButtonClicked();
|
||||||
void onPrintReportButtonClicked();
|
void onPrintReportButtonClicked();
|
||||||
|
void onPrintSellerReceiptButtonClicked();
|
||||||
|
void onReportViewSelectionChanged(const QItemSelection& selected,
|
||||||
|
const QItemSelection& deselected);
|
||||||
|
|
||||||
private:
|
private : Ui::ReportDialog ui_;
|
||||||
Ui::ReportDialog ui_;
|
|
||||||
Marketplace* market_;
|
Marketplace* market_;
|
||||||
std::unique_ptr<ReportModel> model_;
|
std::unique_ptr<ReportModel> model_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="printSellerReceiptButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -157,7 +157,7 @@ void PosPrinter::printSaleReceipt(Sale* sale)
|
||||||
write(commandStream.str());
|
write(commandStream.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PosPrinter::printSellerReceipt(Seller* seller, int percent, int maxFee)
|
void PosPrinter::printSellerReceipt(Seller* seller, int percent, int maxFeeInCent)
|
||||||
{
|
{
|
||||||
std::stringstream commandStream;
|
std::stringstream commandStream;
|
||||||
printHeader();
|
printHeader();
|
||||||
|
@ -182,10 +182,12 @@ void PosPrinter::printSellerReceipt(Seller* seller, int percent, int maxFee)
|
||||||
}
|
}
|
||||||
commandStream << "\nGesamt................." << seller->sumAsString() << "\n";
|
commandStream << "\nGesamt................." << seller->sumAsString() << "\n";
|
||||||
commandStream << "./. Gebühr............."
|
commandStream << "./. Gebühr............."
|
||||||
<< marketFeeAsString(seller->sumInCents(), percent, maxFee * 100) << "\n";
|
<< marketFeeAsString(seller->sumInCents(), percent, maxFeeInCent) << "\n";
|
||||||
commandStream << "\nAuszahlung............."
|
commandStream << "\nAuszahlung............."
|
||||||
<< paymentAsString(seller->sumInCents(), percent, maxFee * 100) << "\n";
|
<< paymentAsString(seller->sumInCents(), percent, maxFeeInCent) << "\n";
|
||||||
commandStream << Command::FEED;
|
commandStream << Command::FEED;
|
||||||
|
|
||||||
|
write(commandStream.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PosPrinter::isValid()
|
bool PosPrinter::isValid()
|
||||||
|
|
|
@ -25,7 +25,7 @@ class PosPrinter
|
||||||
void printHeader();
|
void printHeader();
|
||||||
void printTest();
|
void printTest();
|
||||||
void printSaleReceipt(Sale* sale);
|
void printSaleReceipt(Sale* sale);
|
||||||
void printSellerReceipt(Seller* seller, int percent, int maxFee);
|
void printSellerReceipt(Seller* seller, int percent, int maxFeeInCent);
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
struct Command {
|
struct Command {
|
||||||
|
|
Loading…
Reference in a new issue