importing sales started
This commit is contained in:
parent
c82378dfa9
commit
0a91de4d86
5 changed files with 54 additions and 2 deletions
|
@ -86,4 +86,19 @@ void JsonUtil::exportSales(const std::string& filename, Marketplace* market, int
|
|||
}
|
||||
|
||||
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 importSellers(const std::string& filename, Marketplace* market);
|
||||
static void exportSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
||||
static void importSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -12,6 +12,7 @@
|
|||
#include <excelreader.h>
|
||||
|
||||
#include <regex>
|
||||
#include <exception>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
@ -70,6 +71,8 @@ MainWindow::MainWindow()
|
|||
&MainWindow::onExportSellerJsonActionTriggered);
|
||||
connect(ui_.exportSalesJsonAction, &QAction::triggered, this,
|
||||
&MainWindow::onExportSalesJsonActionTriggered);
|
||||
connect(ui_.importSalesJsonAction, &QAction::triggered, this,
|
||||
&MainWindow::onImportSalesJsonActionTriggered);
|
||||
}
|
||||
|
||||
void MainWindow::onActionEditSellerTriggered()
|
||||
|
@ -292,5 +295,31 @@ void MainWindow::onExportSalesJsonActionTriggered()
|
|||
|
||||
auto filename = QFileDialog::getSaveFileName(this, "Umsätze/Transaktionen exportieren",
|
||||
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 onExportSellerJsonActionTriggered();
|
||||
void onExportSalesJsonActionTriggered();
|
||||
void onImportSalesJsonActionTriggered();
|
||||
void setSaleModel();
|
||||
|
||||
Ui::MainWindow ui_;
|
||||
|
|
|
@ -426,6 +426,7 @@ drucken</string>
|
|||
<string>&Umsätze</string>
|
||||
</property>
|
||||
<addaction name="reportAction"/>
|
||||
<addaction name="importSalesJsonAction"/>
|
||||
<addaction name="exportSalesJsonAction"/>
|
||||
</widget>
|
||||
<addaction name="menu_Datei"/>
|
||||
|
@ -488,6 +489,11 @@ drucken</string>
|
|||
<string>Exportieren (JSON)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="importSalesJsonAction">
|
||||
<property name="text">
|
||||
<string>Importieren (JSON)</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Loading…
Reference in a new issue