use new pos printer settings
This commit is contained in:
parent
dc74c59287
commit
f0078647d4
9 changed files with 144 additions and 47 deletions
|
@ -166,6 +166,10 @@ void MainWindow::setSaleModel()
|
|||
ui_.salesView->setModel(new SaleModel(getMarketplace(), ui_.salesView));
|
||||
ui_.salesView->setColumnHidden(2, true);
|
||||
ui_.salesView->resizeColumnToContents(0);
|
||||
|
||||
ui_.printSaleReceiptButton->setEnabled(false);
|
||||
ui_.cancelSaleButton->setEnabled(false);
|
||||
|
||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
||||
static_cast<SaleModel*>(ui_.salesView->model()), &SaleModel::onBasketDataChanged);
|
||||
connect(ui_.salesView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
|
@ -349,11 +353,25 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
|
|||
if (selModel->hasSelection() == false)
|
||||
return;
|
||||
|
||||
QSettings settings{};
|
||||
QString posPrinterDevice = settings.value("global/posPrinterDevice", "").toString();
|
||||
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint", "").toString();
|
||||
|
||||
auto indexes = selModel->selectedRows();
|
||||
auto& sale = marketplace_->getSales().at(indexes[0].row());
|
||||
PosPrinter printer;
|
||||
if (printer.isValid())
|
||||
printer.printSaleReceipt(sale.get());
|
||||
|
||||
auto printerDevice = convertToPosPrinterDevice(posPrinterDevice.toStdString(), posPrinterEndpoint.toStdString());
|
||||
|
||||
std::unique_ptr<PosPrinter> printer;
|
||||
|
||||
if (printerDevice) {
|
||||
printer = std::make_unique<PosPrinter>(*printerDevice);
|
||||
} else {
|
||||
printer = std::make_unique<PosPrinter>();
|
||||
}
|
||||
|
||||
if (printer->isValid())
|
||||
printer->printSaleReceipt(sale.get());
|
||||
}
|
||||
|
||||
void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <posprinter.h>
|
||||
#include <utils.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFontDatabase>
|
||||
|
@ -90,7 +91,8 @@ void ReportDialog::onPrintReportButtonClicked()
|
|||
.arg("Auszahlung\n", -11);
|
||||
content.append(
|
||||
"---------------------------------------------------------------------------\n");
|
||||
for (unsigned int j = 0; j < ENTRIES_PER_PAGE && (i - 1) * ENTRIES_PER_PAGE + j < sellers.size(); ++j) {
|
||||
for (unsigned int j = 0;
|
||||
j < ENTRIES_PER_PAGE && (i - 1) * ENTRIES_PER_PAGE + j < sellers.size(); ++j) {
|
||||
int idx = (i - 1) * ENTRIES_PER_PAGE + j;
|
||||
if (sellers.at(idx)->getUuidAsString() == "11111111-1111-1111-1111-111111111111") {
|
||||
continue;
|
||||
|
@ -168,6 +170,8 @@ void ReportDialog::onPrintSellerReceiptButtonClicked()
|
|||
QSettings settings;
|
||||
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
||||
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
||||
QString posPrinterDevice = settings.value("global/posPrinterDevice", "").toString();
|
||||
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint", "").toString();
|
||||
|
||||
auto selModel = ui_.reportView->selectionModel();
|
||||
if (selModel->hasSelection() == false)
|
||||
|
@ -175,9 +179,20 @@ void ReportDialog::onPrintSellerReceiptButtonClicked()
|
|||
|
||||
auto indexes = selModel->selectedRows();
|
||||
auto& seller = market_->getSellers().at(indexes[0].row());
|
||||
PosPrinter printer;
|
||||
if (printer.isValid())
|
||||
printer.printSellerReceipt(seller.get(), feeInPercent, maxFeeInEuro * 100);
|
||||
|
||||
auto printerDevice =
|
||||
convertToPosPrinterDevice(posPrinterDevice.toStdString(), posPrinterEndpoint.toStdString());
|
||||
|
||||
std::unique_ptr<PosPrinter> printer;
|
||||
|
||||
if (printerDevice) {
|
||||
printer = std::make_unique<PosPrinter>(*printerDevice);
|
||||
} else {
|
||||
printer = std::make_unique<PosPrinter>();
|
||||
}
|
||||
|
||||
if (printer->isValid())
|
||||
printer->printSellerReceipt(seller.get(), feeInPercent, maxFeeInEuro * 100);
|
||||
}
|
||||
|
||||
void ReportDialog::onReportViewSelectionChanged(const QItemSelection& selected,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <database.h>
|
||||
#include <posprinter.h>
|
||||
#include <utils.h>
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
@ -18,6 +19,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
QSettings settings{};
|
||||
int cashPointNo = settings.value("global/cashPointNo").toInt();
|
||||
QString posPrinterDevice = settings.value("global/posPrinterDevice").toString();
|
||||
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint").toString();
|
||||
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
||||
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
||||
|
||||
|
@ -26,6 +28,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
|
||||
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
||||
ui_.posPrinterDeviceEdit->setText(posPrinterDevice);
|
||||
ui_.posPrinterEndpointEdit->setText(posPrinterEndpoint);
|
||||
ui_.feePercentSpinBox->setValue(feeInPercent);
|
||||
ui_.maxFeeSpinBox->setValue(maxFeeInEuro);
|
||||
|
||||
|
@ -37,26 +40,27 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
printer.printTest();
|
||||
} else {
|
||||
std::string posPrinterDeviceString = ui_.posPrinterDeviceEdit->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
PrinterDevice printerDevice;
|
||||
std::string posPrinterEndpointString =
|
||||
ui_.posPrinterEndpointEdit->text().toStdString();
|
||||
|
||||
try {
|
||||
printerDevice.idVendor = std::stoi(
|
||||
posPrinterDeviceString.substr(0, posPrinterDeviceString.find(delimiter)), 0,
|
||||
16);
|
||||
printerDevice.idProduct = std::stoi(
|
||||
posPrinterDeviceString.substr(posPrinterDeviceString.find(delimiter) + 1),
|
||||
0, 16);
|
||||
auto printerDevice =
|
||||
convertToPosPrinterDevice(posPrinterDeviceString, posPrinterEndpointString);
|
||||
|
||||
if (printerDevice) {
|
||||
PosPrinter printer(*printerDevice);
|
||||
printer.printTest();
|
||||
}
|
||||
|
||||
} catch (std::exception&) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Falsche Eingabe",
|
||||
QString("Eingabeformat für den Bondrucker (hexadezimale IDs): "
|
||||
"<VendorID>:<ProductID>\nBeispiel: 0416:5011"),
|
||||
QString("Eingabeformat für Device (hexadezimale IDs): "
|
||||
"<VendorID>:<ProductID>\nBeispiel: 0416:5011\n "
|
||||
"Eingabeformat für Endpoint: Hexadezimale Adresse"),
|
||||
QMessageBox::StandardButton::Ok, this)
|
||||
.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
PosPrinter printer(printerDevice);
|
||||
printer.printTest();
|
||||
}
|
||||
} catch (std::runtime_error& err) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler",
|
||||
|
@ -75,7 +79,8 @@ void SettingsDialog::accept()
|
|||
int oldCashPointNo = settings.value("global/cashPointNo").toInt();
|
||||
int newCashPointNo = ui_.cashPointNoSpinBox->value();
|
||||
|
||||
settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text());
|
||||
settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text().trimmed());
|
||||
settings.setValue("global/posPrinterEndpoint", ui_.posPrinterEndpointEdit->text().trimmed());
|
||||
settings.setValue("global/feeInPercent", ui_.feePercentSpinBox->value());
|
||||
settings.setValue("global/maxFeeInEuro", ui_.maxFeeSpinBox->value());
|
||||
|
||||
|
|
|
@ -6,14 +6,17 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>203</height>
|
||||
<width>392</width>
|
||||
<height>242</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Einstellungen</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="cashPointNoSpinBox"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
@ -21,51 +24,65 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="cashPointNoSpinBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Bondrucker Gerätedatei:</string>
|
||||
<string>Bondrucker:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="posPrinterDeviceEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><idVendor>:<idProduct></string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>VendorId:ProductId</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="testPosPrinterButton">
|
||||
<property name="text">
|
||||
<string>Testen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Gebühr in %:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="feePercentSpinBox"/>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="feePercentSpinBox">
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>max. Gebühr in €:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="maxFeeSpinBox"/>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="maxFeeSpinBox">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<item row="5" column="0" colspan="4">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -75,6 +92,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="posPrinterEndpointEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Endpoint Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue