diff --git a/src/core/excelreader.cpp b/src/core/excelreader.cpp index f39333c..5d14584 100644 --- a/src/core/excelreader.cpp +++ b/src/core/excelreader.cpp @@ -37,5 +37,19 @@ void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace* market->getSellers().push_back(std::move(seller)); rowCount++; } + + // If there was no special seller "Sonderkonto" in import data, then create one + auto specialSeller = market->findSellerWithUuid("11111111-1111-1111-1111-111111111111"); + if (!specialSeller) { + auto seller = std::make_unique(); + seller->setUuidFromString("11111111-1111-1111-1111-111111111111"); + seller->setSellerNo(0); + seller->setLastName("Sonderkonto"); + seller->setFirstName("Sonderkonto"); + seller->setNumArticlesOffered(0); + market->getSellers().push_back(std::move(seller)); + } + + market->sortSellers(); market->storeToDb(); } diff --git a/src/core/jsonutil.cpp b/src/core/jsonutil.cpp index 935c8fd..a41f69b 100644 --- a/src/core/jsonutil.cpp +++ b/src/core/jsonutil.cpp @@ -49,6 +49,21 @@ void JsonUtil::importSellers(const std::string& filename, Marketplace* market) seller->setNumArticlesOffered(val["num_offered_articles"].asInt()); market->getSellers().push_back(std::move(seller)); } + + // If there was no special seller "Sonderkonto" in import data, then create one + auto specialSeller = market->findSellerWithUuid("11111111-1111-1111-1111-111111111111"); + if (!specialSeller) { + auto seller = std::make_unique(); + seller->setUuidFromString("11111111-1111-1111-1111-111111111111"); + seller->setSellerNo(0); + seller->setLastName("Sonderkonto"); + seller->setFirstName("Sonderkonto"); + seller->setNumArticlesOffered(0); + market->getSellers().push_back(std::move(seller)); + } + + market->sortSellers(); + market->storeToDb(); } diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index b3a4a3a..bc882b2 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -1,5 +1,7 @@ #include "settingsdialog.h" +#include "mainwindow.h" + #include #include @@ -18,6 +20,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par int feeInPercent = settings.value("global/feeInPercent").toInt(); int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt(); + market_ = dynamic_cast(parent)->getMarketplace(); + ui_.cashPointNoSpinBox->setValue(cashPointNo); // ui_.posPrinterDeviceEdit->setText(posPrinterDevice); ui_.feePercentSpinBox->setValue(feeInPercent); @@ -56,12 +60,17 @@ void SettingsDialog::accept() settings.setValue("global/maxFeeInEuro", ui_.maxFeeSpinBox->value()); if (oldCashPointNo != newCashPointNo) { - int result = - QMessageBox(QMessageBox::Icon::Question, "Sind Sie sicher?", - "Möchten Sie die Kassen-Nr wirklich ändern? Diese muss über alle " - "Installationen hinweg eindeutig sein.", - QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this) - .exec(); + int result{0}; + if (market_->getSales().size() > 0) { + result = QMessageBox(QMessageBox::Icon::Question, "Sind Sie sicher?", + "Möchten Sie die Kassen-Nr wirklich ändern? Diese muss über alle " + "Installationen hinweg eindeutig sein.", + QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, + this) + .exec(); + } else { + result = QMessageBox::Yes; + } if (result == QMessageBox::Yes) { try { Database().updateCashPointNo(oldCashPointNo, newCashPointNo); diff --git a/src/gui/settingsdialog.h b/src/gui/settingsdialog.h index 7533a3b..39e3086 100644 --- a/src/gui/settingsdialog.h +++ b/src/gui/settingsdialog.h @@ -3,6 +3,8 @@ #include "ui_settingsdialog.h" +#include + #include class SettingsDialog : public QDialog @@ -16,6 +18,7 @@ class SettingsDialog : public QDialog private: Ui::SettingsDialog ui_; + Marketplace* market_{}; }; #endif \ No newline at end of file