handle "Sonderkonto" in imports
This commit is contained in:
parent
410eb775aa
commit
d1c5d3a6f8
4 changed files with 47 additions and 6 deletions
|
@ -37,5 +37,19 @@ void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace*
|
||||||
market->getSellers().push_back(std::move(seller));
|
market->getSellers().push_back(std::move(seller));
|
||||||
rowCount++;
|
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>();
|
||||||
|
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();
|
market->storeToDb();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,21 @@ void JsonUtil::importSellers(const std::string& filename, Marketplace* market)
|
||||||
seller->setNumArticlesOffered(val["num_offered_articles"].asInt());
|
seller->setNumArticlesOffered(val["num_offered_articles"].asInt());
|
||||||
market->getSellers().push_back(std::move(seller));
|
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>();
|
||||||
|
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();
|
market->storeToDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <database.h>
|
#include <database.h>
|
||||||
#include <posprinter.h>
|
#include <posprinter.h>
|
||||||
|
|
||||||
|
@ -18,6 +20,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
||||||
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
||||||
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
||||||
|
|
||||||
|
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
||||||
|
|
||||||
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
||||||
// ui_.posPrinterDeviceEdit->setText(posPrinterDevice);
|
// ui_.posPrinterDeviceEdit->setText(posPrinterDevice);
|
||||||
ui_.feePercentSpinBox->setValue(feeInPercent);
|
ui_.feePercentSpinBox->setValue(feeInPercent);
|
||||||
|
@ -56,12 +60,17 @@ void SettingsDialog::accept()
|
||||||
settings.setValue("global/maxFeeInEuro", ui_.maxFeeSpinBox->value());
|
settings.setValue("global/maxFeeInEuro", ui_.maxFeeSpinBox->value());
|
||||||
|
|
||||||
if (oldCashPointNo != newCashPointNo) {
|
if (oldCashPointNo != newCashPointNo) {
|
||||||
int result =
|
int result{0};
|
||||||
QMessageBox(QMessageBox::Icon::Question, "Sind Sie sicher?",
|
if (market_->getSales().size() > 0) {
|
||||||
"Möchten Sie die Kassen-Nr wirklich ändern? Diese muss über alle "
|
result = QMessageBox(QMessageBox::Icon::Question, "Sind Sie sicher?",
|
||||||
"Installationen hinweg eindeutig sein.",
|
"Möchten Sie die Kassen-Nr wirklich ändern? Diese muss über alle "
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
"Installationen hinweg eindeutig sein.",
|
||||||
.exec();
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
|
||||||
|
this)
|
||||||
|
.exec();
|
||||||
|
} else {
|
||||||
|
result = QMessageBox::Yes;
|
||||||
|
}
|
||||||
if (result == QMessageBox::Yes) {
|
if (result == QMessageBox::Yes) {
|
||||||
try {
|
try {
|
||||||
Database().updateCashPointNo(oldCashPointNo, newCashPointNo);
|
Database().updateCashPointNo(oldCashPointNo, newCashPointNo);
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "ui_settingsdialog.h"
|
#include "ui_settingsdialog.h"
|
||||||
|
|
||||||
|
#include <marketplace.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class SettingsDialog : public QDialog
|
class SettingsDialog : public QDialog
|
||||||
|
@ -16,6 +18,7 @@ class SettingsDialog : public QDialog
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingsDialog ui_;
|
Ui::SettingsDialog ui_;
|
||||||
|
Marketplace* market_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue