Allow import of multiple sales at once.
This commit is contained in:
parent
54e5c70447
commit
32d0ec7749
2 changed files with 19 additions and 14 deletions
|
@ -102,8 +102,10 @@ void JsonUtil::importSales(const std::filesystem::path &filePath, Marketplace *m
|
||||||
|
|
||||||
int source_no = jsonValues["source_no"];
|
int source_no = jsonValues["source_no"];
|
||||||
if (source_no == cashPointNo) {
|
if (source_no == cashPointNo) {
|
||||||
throw std::runtime_error("Die Kassen-Nr. der zu imporierenden Daten wird von dieser Kasse "
|
std::string ret = "Die Kassen-Nr. ";
|
||||||
"hier bereits verwendet.");
|
ret += std::to_string(source_no);
|
||||||
|
ret += " der zu imporierenden Daten wird von dieser Kasse hier bereits verwendet.";
|
||||||
|
throw std::runtime_error(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
market->setSalesToDelete(jsonValues["source_no"]);
|
market->setSalesToDelete(jsonValues["source_no"]);
|
||||||
|
|
|
@ -504,27 +504,30 @@ void MainWindow::onImportSalesJsonActionTriggered()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
auto filename = QFileDialog::getOpenFileName(this, "Umsätze/Transaktionen importieren",
|
auto filenames = QFileDialog::getOpenFileNames(this, "Umsätze/Transaktionen importieren",
|
||||||
QString(), "JSON Dateien (*.json)");
|
QString(), "JSON Dateien (*.json)");
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filenames.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for(auto filename: filenames) {
|
||||||
#if defined(_WIN64) || defined(_WIN32)
|
#if defined(_WIN64) || defined(_WIN32)
|
||||||
fs::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
#else
|
#else
|
||||||
fs::path filePath(filename.toStdString());
|
fs::path filePath(filename.toStdString());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete m_ui.salesView->model();
|
delete m_ui.salesView->model();
|
||||||
try {
|
try {
|
||||||
JsonUtil::importSales(filePath, m_marketplace.get(),
|
JsonUtil::importSales(filePath, m_marketplace.get(),
|
||||||
settings.value("global/cashPointNo").toInt());
|
settings.value("global/cashPointNo").toInt());
|
||||||
} catch (std::runtime_error &err) {
|
} catch (std::runtime_error &err) {
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok,
|
QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok,
|
||||||
this)
|
this)
|
||||||
.exec();
|
.exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSaleModel();
|
setSaleModel();
|
||||||
updateStatLabel();
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue