Compare commits

..

No commits in common. "da4e223b16edffd6cd1cf5054fb5984e562e0b91" and "b2d696ccb56c7d42eef5479a30608f4deb7032ef" have entirely different histories.

9 changed files with 18 additions and 140 deletions

View file

@ -3,8 +3,7 @@ set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.62 COMPONENTS date_time REQUIRED) find_package(Boost 1.62 COMPONENTS date_time REQUIRED)
find_package(SQLite3 REQUIRED) find_package(SQLite3 REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(XLNT REQUIRED xlnt>=1.3) pkg_check_modules(XLNT REQUIRED xlnt)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
set(CORE_SOURCES set(CORE_SOURCES
database.cpp database.cpp
@ -14,11 +13,10 @@ set(CORE_SOURCES
sale.cpp sale.cpp
marketplace.cpp marketplace.cpp
excelreader.cpp excelreader.cpp
jsonutil
) )
add_library(core STATIC ${CORE_SOURCES}) add_library(core STATIC ${CORE_SOURCES})
target_link_libraries(core Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARIES} ${JSONCPP_LIBRARIES}) target_link_libraries(core Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARIES})
if (WIN32) if (WIN32)
target_link_libraries(core bcrypt) target_link_libraries(core bcrypt)
endif() endif()

View file

@ -8,19 +8,15 @@ void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace*
wb.load(filename); wb.load(filename);
auto ws = wb.sheet_by_index(0); auto ws = wb.sheet_by_index(0);
const int START_ROW = 5; const int START_ROW = 6;
const int END_ROW = 350; const int END_ROW = 349;
int rowCount{}; int rowCount{};
for (const auto& row : ws.rows(false)) { for (const auto& row : ws.rows(false)) {
// auto test = row[0].value<int>(); // auto test = row[0].value<int>();
if (rowCount < START_ROW) { if (rowCount < START_ROW)
rowCount++;
continue; continue;
} else if (rowCount > END_ROW) { std::cout << row[0].to_string() << "\n";
break;
}
std::cout << row[0].value<int>() << "\n";
rowCount++; rowCount++;
} }
} }

View file

@ -1,54 +0,0 @@
#include "jsonutil.h"
#include "database.h"
#include <json/json.h>
#include <fstream>
void JsonUtil::exportSellers(const std::string& filename, Marketplace* market)
{
Json::Value root;
std::ofstream file(filename);
Json::StreamWriterBuilder builder;
builder["commentStyle"] = "None";
builder["indentation"] = " ";
std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
for (const auto& seller : market->getSellers()) {
Json::Value newEntry;
newEntry["uuid"] = seller->getUuidAsString();
newEntry["seller_no"] = seller->getSellerNo();
newEntry["last_name"] = seller->getLastName();
newEntry["first_name"] = seller->getFirstName();
newEntry["num_offered_articles"] = seller->numArticlesOffered();
root["sellers"].append(newEntry);
}
writer->write(root, &file);
}
void JsonUtil::importSellers(const std::string& filename, Marketplace* market)
{
for (auto& seller : market->getSellers())
{
seller->setState(Seller::State::DELETE);
}
market->storeToDb(true);
Json::Value jsonValues;
std::ifstream file(filename);
file >> jsonValues;
for(auto val : jsonValues["sellers"]) {
auto seller = std::make_unique<Seller>();
seller->setUuidFromString(val["uuid"].asString());
seller->setSellerNo(val["seller_no"].asInt());
seller->setLastName(val["last_name"].asString());
seller->setFirstName(val["first_name"].asString());
seller->setNumArticlesOffered(val["num_offered_articles"].asInt());
market->getSellers().push_back(std::move(seller));
}
market->storeToDb();
}

View file

@ -1,15 +0,0 @@
#ifndef JSON_H
#define JSON_H
#include "marketplace.h"
#include <string>
class JsonUtil
{
public:
static void exportSellers(const std::string& filename, Marketplace* market);
static void importSellers(const std::string& filename, Marketplace* market);
};
#endif

View file

@ -16,6 +16,9 @@ using SalesVec = std::vector<std::unique_ptr<Sale>>;
using BasketVec = std::vector<std::unique_ptr<Article>>; using BasketVec = std::vector<std::unique_ptr<Article>>;
} // namespace } // namespace
struct Basket {
};
class Marketplace class Marketplace
{ {
public: public:

View file

@ -14,8 +14,8 @@ int main(int argc, char* argv[])
// Set the locale to german, so that currency is correct // Set the locale to german, so that currency is correct
// std::locale german("de_DE.utf-8"); // std::locale german("de_DE.utf-8");
//std::locale myLocale(""); std::locale myLocale("");
//std::locale::global(myLocale); std::locale::global(myLocale);
QApplication kimaApp{argc, argv}; QApplication kimaApp{argc, argv};

View file

@ -2,7 +2,6 @@
#include "basketmodel.h" #include "basketmodel.h"
#include "config.h" #include "config.h"
#include "jsonutil.h"
#include "pricedialog.h" #include "pricedialog.h"
#include "reportdialog.h" #include "reportdialog.h"
#include "salemodel.h" #include "salemodel.h"
@ -62,12 +61,8 @@ MainWindow::MainWindow()
this->setWindowTitle("KIMA2 - Kasse Nr. " + this->setWindowTitle("KIMA2 - Kasse Nr. " +
QSettings().value("global/cashPointNo").toString()); QSettings().value("global/cashPointNo").toString());
}); });
connect(ui_.importSellerExcelAction, &QAction::triggered, this, connect(ui_.importExcelAction, &QAction::triggered, this,
&MainWindow::onImportSellerExcelActionTriggered); &MainWindow::onImportExcelActionTriggered);
connect(ui_.importSellerJsonAction, &QAction::triggered, this,
&MainWindow::onImportSellerJsonActionTriggered);
connect(ui_.exportSellerJsonAction, &QAction::triggered, this,
&MainWindow::onExportSellerJsonActionTriggered);
} }
void MainWindow::onActionEditSellerTriggered() void MainWindow::onActionEditSellerTriggered()
@ -244,7 +239,7 @@ void MainWindow::onAbout()
">info@rustysoft.de</a>&gt;</p>"); ">info@rustysoft.de</a>&gt;</p>");
} }
void MainWindow::onImportSellerExcelActionTriggered() void MainWindow::onImportExcelActionTriggered()
{ {
if (!marketplace_->getSales().empty()) { if (!marketplace_->getSales().empty()) {
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich", QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
@ -258,29 +253,4 @@ void MainWindow::onImportSellerExcelActionTriggered()
"Excel Dateien (*.xlsx *.xls)"); "Excel Dateien (*.xlsx *.xls)");
ExcelReader::readSellersFromFile(filename.toStdString(), marketplace_.get()); ExcelReader::readSellersFromFile(filename.toStdString(), marketplace_.get());
}
void MainWindow::onImportSellerJsonActionTriggered()
{
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;
}
auto filename = QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(),
"JSON Dateien (*.json)");
JsonUtil::importSellers(filename.toStdString(), marketplace_.get());
}
void MainWindow::onExportSellerJsonActionTriggered()
{
auto filename = QFileDialog::getSaveFileName(this, "Verkäufer exportieren", QString(),
"JSON Dateien (*.json)");
JsonUtil::exportSellers(filename.toStdString(), marketplace_.get());
} }

View file

@ -32,9 +32,7 @@ class MainWindow : public QMainWindow
void onActionEditSellerTriggered(); void onActionEditSellerTriggered();
void onSellerNoEditCheckSellerNo(); void onSellerNoEditCheckSellerNo();
void onPaidButtonTriggered(); void onPaidButtonTriggered();
void onImportSellerExcelActionTriggered(); void onImportExcelActionTriggered();
void onImportSellerJsonActionTriggered();
void onExportSellerJsonActionTriggered();
void setSaleModel(); void setSaleModel();
Ui::MainWindow ui_; Ui::MainWindow ui_;

View file

@ -403,16 +403,8 @@ drucken</string>
<property name="title"> <property name="title">
<string>&amp;Verkäufer</string> <string>&amp;Verkäufer</string>
</property> </property>
<widget class="QMenu" name="importSellerMenu">
<property name="title">
<string>Importieren</string>
</property>
<addaction name="importSellerExcelAction"/>
<addaction name="importSellerJsonAction"/>
</widget>
<addaction name="actionEditSeller"/> <addaction name="actionEditSeller"/>
<addaction name="importSellerMenu"/> <addaction name="importExcelAction"/>
<addaction name="exportSellerJsonAction"/>
</widget> </widget>
<widget class="QMenu" name="menuHilfe"> <widget class="QMenu" name="menuHilfe">
<property name="title"> <property name="title">
@ -467,19 +459,9 @@ drucken</string>
<string>Auswertung</string> <string>Auswertung</string>
</property> </property>
</action> </action>
<action name="exportSellerJsonAction"> <action name="importExcelAction">
<property name="text"> <property name="text">
<string>Exportieren (JSON)</string> <string>Importieren (Excel)</string>
</property>
</action>
<action name="importSellerExcelAction">
<property name="text">
<string>Aus Excel-Datei</string>
</property>
</action>
<action name="importSellerJsonAction">
<property name="text">
<string>Aus JSON-Datei</string>
</property> </property>
</action> </action>
</widget> </widget>