importing sales started
This commit is contained in:
parent
c82378dfa9
commit
0a91de4d86
5 changed files with 54 additions and 2 deletions
|
@ -87,3 +87,18 @@ void JsonUtil::exportSales(const std::string& filename, Marketplace* market, int
|
||||||
|
|
||||||
writer->write(root, &file);
|
writer->write(root, &file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsonUtil::importSales(const std::string& filename, Marketplace* market, int cashPointNo)
|
||||||
|
{
|
||||||
|
Json::Value jsonValues;
|
||||||
|
std::ifstream file(filename);
|
||||||
|
file >> jsonValues;
|
||||||
|
|
||||||
|
int source_no = jsonValues["source_no"].asInt();
|
||||||
|
if (source_no == cashPointNo) {
|
||||||
|
throw std::runtime_error("Die Kassen-Nr. der zu imporierenden Daten wird von dieser Kasse "
|
||||||
|
"hier bereits verwendet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Import sales
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ class JsonUtil
|
||||||
static void exportSellers(const std::string& filename, Marketplace* market);
|
static void exportSellers(const std::string& filename, Marketplace* market);
|
||||||
static void importSellers(const std::string& filename, Marketplace* market);
|
static void importSellers(const std::string& filename, Marketplace* market);
|
||||||
static void exportSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
static void exportSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
||||||
|
static void importSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -12,6 +12,7 @@
|
||||||
#include <excelreader.h>
|
#include <excelreader.h>
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -70,6 +71,8 @@ MainWindow::MainWindow()
|
||||||
&MainWindow::onExportSellerJsonActionTriggered);
|
&MainWindow::onExportSellerJsonActionTriggered);
|
||||||
connect(ui_.exportSalesJsonAction, &QAction::triggered, this,
|
connect(ui_.exportSalesJsonAction, &QAction::triggered, this,
|
||||||
&MainWindow::onExportSalesJsonActionTriggered);
|
&MainWindow::onExportSalesJsonActionTriggered);
|
||||||
|
connect(ui_.importSalesJsonAction, &QAction::triggered, this,
|
||||||
|
&MainWindow::onImportSalesJsonActionTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onActionEditSellerTriggered()
|
void MainWindow::onActionEditSellerTriggered()
|
||||||
|
@ -292,5 +295,31 @@ void MainWindow::onExportSalesJsonActionTriggered()
|
||||||
|
|
||||||
auto filename = QFileDialog::getSaveFileName(this, "Umsätze/Transaktionen exportieren",
|
auto filename = QFileDialog::getSaveFileName(this, "Umsätze/Transaktionen exportieren",
|
||||||
QString(), "JSON Dateien (*.json)");
|
QString(), "JSON Dateien (*.json)");
|
||||||
JsonUtil::exportSales(filename.toStdString(), marketplace_.get(), settings.value("global/cashPointNo").toInt());
|
JsonUtil::exportSales(filename.toStdString(), marketplace_.get(),
|
||||||
|
settings.value("global/cashPointNo").toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onImportSalesJsonActionTriggered()
|
||||||
|
{
|
||||||
|
/* if (!marketplace_->getSales().empty()) {
|
||||||
|
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
|
||||||
|
"Der Import ist nicht möglich, da schon Verkäufe getätigt wurden.",
|
||||||
|
QMessageBox::StandardButton::Ok, this)
|
||||||
|
.exec();
|
||||||
|
return;
|
||||||
|
} */
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
auto filename = QFileDialog::getOpenFileName(this, "Umsätze/Transaktionen importieren",
|
||||||
|
QString(), "JSON Dateien (*.json)");
|
||||||
|
|
||||||
|
try {
|
||||||
|
JsonUtil::importSales(filename.toStdString(), marketplace_.get(),
|
||||||
|
settings.value("global/cashPointNo").toInt());
|
||||||
|
} catch (std::runtime_error& err) {
|
||||||
|
QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok,
|
||||||
|
this)
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -36,6 +36,7 @@ class MainWindow : public QMainWindow
|
||||||
void onImportSellerJsonActionTriggered();
|
void onImportSellerJsonActionTriggered();
|
||||||
void onExportSellerJsonActionTriggered();
|
void onExportSellerJsonActionTriggered();
|
||||||
void onExportSalesJsonActionTriggered();
|
void onExportSalesJsonActionTriggered();
|
||||||
|
void onImportSalesJsonActionTriggered();
|
||||||
void setSaleModel();
|
void setSaleModel();
|
||||||
|
|
||||||
Ui::MainWindow ui_;
|
Ui::MainWindow ui_;
|
||||||
|
|
|
@ -426,6 +426,7 @@ drucken</string>
|
||||||
<string>&Umsätze</string>
|
<string>&Umsätze</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="reportAction"/>
|
<addaction name="reportAction"/>
|
||||||
|
<addaction name="importSalesJsonAction"/>
|
||||||
<addaction name="exportSalesJsonAction"/>
|
<addaction name="exportSalesJsonAction"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menu_Datei"/>
|
<addaction name="menu_Datei"/>
|
||||||
|
@ -488,6 +489,11 @@ drucken</string>
|
||||||
<string>Exportieren (JSON)</string>
|
<string>Exportieren (JSON)</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="importSalesJsonAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Importieren (JSON)</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
Loading…
Reference in a new issue