diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 2a3d326..7f1e9c8 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -387,7 +387,7 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked) } if (printer->isValid()) - printer->printSaleReceipt(sale.get()); + printer->printSaleReceipt(sale.get(), settings.value("global/commune", "Dettingen").toString().toStdString()); } void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked) diff --git a/src/gui/reportdialog.cpp b/src/gui/reportdialog.cpp index 0f84c5c..5559598 100644 --- a/src/gui/reportdialog.cpp +++ b/src/gui/reportdialog.cpp @@ -207,7 +207,9 @@ void ReportDialog::onPrintSellerReceiptButtonClicked() } if (printer->isValid()) - printer->printSellerReceipt(seller.get(), feeInPercent, maxFeeInEuro * 100); + printer->printSellerReceipt( + seller.get(), feeInPercent, maxFeeInEuro * 100, + settings.value("global/commune", "Dettingen").toString().toStdString()); } void ReportDialog::onReportViewSelectionChanged(const QItemSelection& selected, diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index ea01532..ac3a7a4 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -18,6 +18,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par QSettings settings{}; int cashPointNo = settings.value("global/cashPointNo").toInt(); + QString commune = settings.value("global/commune", "Dettingen").toString(); QString posPrinterDevice = settings.value("global/posPrinterDevice").toString(); QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint").toString(); int feeInPercent = settings.value("global/feeInPercent").toInt(); @@ -27,6 +28,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par market_ = dynamic_cast(parent)->getMarketplace(); ui_.cashPointNoSpinBox->setValue(cashPointNo); + ui_.communeEdit->setText(commune); ui_.posPrinterDeviceEdit->setText(posPrinterDevice); ui_.posPrinterEndpointEdit->setText(posPrinterEndpoint); ui_.feePercentSpinBox->setValue(feeInPercent); @@ -79,6 +81,7 @@ void SettingsDialog::accept() int oldCashPointNo = settings.value("global/cashPointNo").toInt(); int newCashPointNo = ui_.cashPointNoSpinBox->value(); + settings.setValue("global/commune", ui_.communeEdit->text().trimmed()); settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text().trimmed()); settings.setValue("global/posPrinterEndpoint", ui_.posPrinterEndpointEdit->text().trimmed()); settings.setValue("global/feeInPercent", ui_.feePercentSpinBox->value()); diff --git a/src/gui/settingsdialog.ui b/src/gui/settingsdialog.ui index 2df8cd2..8cf9c74 100644 --- a/src/gui/settingsdialog.ui +++ b/src/gui/settingsdialog.ui @@ -7,7 +7,7 @@ 0 0 392 - 242 + 246 @@ -24,14 +24,14 @@ - + Bondrucker: - + @@ -47,42 +47,49 @@ - + Testen - + Gebühr in %: - + 20 - + max. Gebühr in €: - + 50 - + + + + Endpoint Address + + + + Qt::Horizontal @@ -92,10 +99,20 @@ - - - - Endpoint Address + + + + Gemeinde: + + + + + + + Dettingen + + + 30 diff --git a/src/printer/posprinter.cpp b/src/printer/posprinter.cpp index 5636e87..43a900f 100644 --- a/src/printer/posprinter.cpp +++ b/src/printer/posprinter.cpp @@ -131,13 +131,13 @@ void PosPrinter::write(const std::string& text) std::cerr << "Write Error" << std::endl; } -void PosPrinter::printHeader() +void PosPrinter::printHeader(const std::string& commune) { std::stringstream commandStream; commandStream << Command::RESET << Command::ENCODING << Command::CENTERING << Command::FONT_SIZE_BIG; - commandStream << "Kindersachenmarkt\nDettingen\n\n"; + commandStream << "Kindersachenmarkt\n" << commune << "\n\n"; commandStream << Command::LEFT_ALIGN << Command::Command::FONT_SIZE_NORMAL; write(commandStream.str()); @@ -154,10 +154,10 @@ void PosPrinter::printTest() write(commandStream.str()); } -void PosPrinter::printSaleReceipt(Sale* sale) +void PosPrinter::printSaleReceipt(Sale* sale, const std::string& commune) { std::stringstream commandStream; - printHeader(); + printHeader(commune); commandStream << Command::RESET << Command::ENCODING << Command::RIGHT_ALIGN; commandStream << sale->getTimestampFormatted() << "\n\n"; commandStream << Command::LEFT_ALIGN; @@ -172,10 +172,11 @@ void PosPrinter::printSaleReceipt(Sale* sale) write(commandStream.str()); } -void PosPrinter::printSellerReceipt(Seller* seller, int percent, int maxFeeInCent) +void PosPrinter::printSellerReceipt(Seller* seller, const int percent, const int maxFeeInCent, + const std::string& commune) { std::stringstream commandStream; - printHeader(); + printHeader(commune); commandStream << Command::RESET << Command::ENCODING << Command::RIGHT_ALIGN; std::string timeStr = boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()); diff --git a/src/printer/posprinter.h b/src/printer/posprinter.h index a5f788c..8ede494 100644 --- a/src/printer/posprinter.h +++ b/src/printer/posprinter.h @@ -33,10 +33,10 @@ class PosPrinter PosPrinter(const PrinterDevice& printerDevice); ~PosPrinter(); void write(const std::string& text); - void printHeader(); + void printHeader(const std::string& commune = "Musterhausen"); void printTest(); - void printSaleReceipt(Sale* sale); - void printSellerReceipt(Seller* seller, int percent, int maxFeeInCent); + void printSaleReceipt(Sale* sale, const std::string& commune = "Dettingen"); + void printSellerReceipt(Seller* seller, const int percent, const int maxFeeInCent, const std::string& commune = "Dettingen"); bool isValid(); struct Command {