Make commune configurable (Default is still Dettingen)
This commit is contained in:
parent
bc9e395ee9
commit
cac9ee9e30
6 changed files with 47 additions and 24 deletions
|
@ -387,7 +387,7 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printer->isValid())
|
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)
|
void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||||
|
|
|
@ -207,7 +207,9 @@ void ReportDialog::onPrintSellerReceiptButtonClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printer->isValid())
|
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,
|
void ReportDialog::onReportViewSelectionChanged(const QItemSelection& selected,
|
||||||
|
|
|
@ -18,6 +18,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
||||||
|
|
||||||
QSettings settings{};
|
QSettings settings{};
|
||||||
int cashPointNo = settings.value("global/cashPointNo").toInt();
|
int cashPointNo = settings.value("global/cashPointNo").toInt();
|
||||||
|
QString commune = settings.value("global/commune", "Dettingen").toString();
|
||||||
QString posPrinterDevice = settings.value("global/posPrinterDevice").toString();
|
QString posPrinterDevice = settings.value("global/posPrinterDevice").toString();
|
||||||
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint").toString();
|
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint").toString();
|
||||||
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
||||||
|
@ -27,6 +28,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
||||||
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
||||||
|
|
||||||
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
||||||
|
ui_.communeEdit->setText(commune);
|
||||||
ui_.posPrinterDeviceEdit->setText(posPrinterDevice);
|
ui_.posPrinterDeviceEdit->setText(posPrinterDevice);
|
||||||
ui_.posPrinterEndpointEdit->setText(posPrinterEndpoint);
|
ui_.posPrinterEndpointEdit->setText(posPrinterEndpoint);
|
||||||
ui_.feePercentSpinBox->setValue(feeInPercent);
|
ui_.feePercentSpinBox->setValue(feeInPercent);
|
||||||
|
@ -79,6 +81,7 @@ void SettingsDialog::accept()
|
||||||
int oldCashPointNo = settings.value("global/cashPointNo").toInt();
|
int oldCashPointNo = settings.value("global/cashPointNo").toInt();
|
||||||
int newCashPointNo = ui_.cashPointNoSpinBox->value();
|
int newCashPointNo = ui_.cashPointNoSpinBox->value();
|
||||||
|
|
||||||
|
settings.setValue("global/commune", ui_.communeEdit->text().trimmed());
|
||||||
settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text().trimmed());
|
settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text().trimmed());
|
||||||
settings.setValue("global/posPrinterEndpoint", ui_.posPrinterEndpointEdit->text().trimmed());
|
settings.setValue("global/posPrinterEndpoint", ui_.posPrinterEndpointEdit->text().trimmed());
|
||||||
settings.setValue("global/feeInPercent", ui_.feePercentSpinBox->value());
|
settings.setValue("global/feeInPercent", ui_.feePercentSpinBox->value());
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>392</width>
|
<width>392</width>
|
||||||
<height>242</height>
|
<height>246</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -24,14 +24,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Bondrucker:</string>
|
<string>Bondrucker:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="posPrinterDeviceEdit">
|
<widget class="QLineEdit" name="posPrinterDeviceEdit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
@ -47,42 +47,49 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3">
|
<item row="2" column="3">
|
||||||
<widget class="QPushButton" name="testPosPrinterButton">
|
<widget class="QPushButton" name="testPosPrinterButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Testen</string>
|
<string>Testen</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Gebühr in %:</string>
|
<string>Gebühr in %:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QSpinBox" name="feePercentSpinBox">
|
<widget class="QSpinBox" name="feePercentSpinBox">
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>20</number>
|
<number>20</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>max. Gebühr in €:</string>
|
<string>max. Gebühr in €:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QSpinBox" name="maxFeeSpinBox">
|
<widget class="QSpinBox" name="maxFeeSpinBox">
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>50</number>
|
<number>50</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="4">
|
<item row="3" column="1">
|
||||||
|
<widget class="QLineEdit" name="posPrinterEndpointEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Endpoint Address</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="4">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -92,10 +99,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="1" column="0">
|
||||||
<widget class="QLineEdit" name="posPrinterEndpointEdit">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="placeholderText">
|
<property name="text">
|
||||||
<string>Endpoint Address</string>
|
<string>Gemeinde:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="communeEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dettingen</string>
|
||||||
|
</property>
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>30</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -131,13 +131,13 @@ void PosPrinter::write(const std::string& text)
|
||||||
std::cerr << "Write Error" << std::endl;
|
std::cerr << "Write Error" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PosPrinter::printHeader()
|
void PosPrinter::printHeader(const std::string& commune)
|
||||||
{
|
{
|
||||||
std::stringstream commandStream;
|
std::stringstream commandStream;
|
||||||
|
|
||||||
commandStream << Command::RESET << Command::ENCODING << Command::CENTERING
|
commandStream << Command::RESET << Command::ENCODING << Command::CENTERING
|
||||||
<< Command::FONT_SIZE_BIG;
|
<< Command::FONT_SIZE_BIG;
|
||||||
commandStream << "Kindersachenmarkt\nDettingen\n\n";
|
commandStream << "Kindersachenmarkt\n" << commune << "\n\n";
|
||||||
commandStream << Command::LEFT_ALIGN << Command::Command::FONT_SIZE_NORMAL;
|
commandStream << Command::LEFT_ALIGN << Command::Command::FONT_SIZE_NORMAL;
|
||||||
|
|
||||||
write(commandStream.str());
|
write(commandStream.str());
|
||||||
|
@ -154,10 +154,10 @@ void PosPrinter::printTest()
|
||||||
write(commandStream.str());
|
write(commandStream.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PosPrinter::printSaleReceipt(Sale* sale)
|
void PosPrinter::printSaleReceipt(Sale* sale, const std::string& commune)
|
||||||
{
|
{
|
||||||
std::stringstream commandStream;
|
std::stringstream commandStream;
|
||||||
printHeader();
|
printHeader(commune);
|
||||||
commandStream << Command::RESET << Command::ENCODING << Command::RIGHT_ALIGN;
|
commandStream << Command::RESET << Command::ENCODING << Command::RIGHT_ALIGN;
|
||||||
commandStream << sale->getTimestampFormatted() << "\n\n";
|
commandStream << sale->getTimestampFormatted() << "\n\n";
|
||||||
commandStream << Command::LEFT_ALIGN;
|
commandStream << Command::LEFT_ALIGN;
|
||||||
|
@ -172,10 +172,11 @@ void PosPrinter::printSaleReceipt(Sale* sale)
|
||||||
write(commandStream.str());
|
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;
|
std::stringstream commandStream;
|
||||||
printHeader();
|
printHeader(commune);
|
||||||
commandStream << Command::RESET << Command::ENCODING << Command::RIGHT_ALIGN;
|
commandStream << Command::RESET << Command::ENCODING << Command::RIGHT_ALIGN;
|
||||||
std::string timeStr =
|
std::string timeStr =
|
||||||
boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time());
|
boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time());
|
||||||
|
|
|
@ -33,10 +33,10 @@ class PosPrinter
|
||||||
PosPrinter(const PrinterDevice& printerDevice);
|
PosPrinter(const PrinterDevice& printerDevice);
|
||||||
~PosPrinter();
|
~PosPrinter();
|
||||||
void write(const std::string& text);
|
void write(const std::string& text);
|
||||||
void printHeader();
|
void printHeader(const std::string& commune = "Musterhausen");
|
||||||
void printTest();
|
void printTest();
|
||||||
void printSaleReceipt(Sale* sale);
|
void printSaleReceipt(Sale* sale, const std::string& commune = "Dettingen");
|
||||||
void printSellerReceipt(Seller* seller, int percent, int maxFeeInCent);
|
void printSellerReceipt(Seller* seller, const int percent, const int maxFeeInCent, const std::string& commune = "Dettingen");
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
struct Command {
|
struct Command {
|
||||||
|
|
Loading…
Reference in a new issue