Compare commits

..

2 commits

Author SHA1 Message Date
e295c6a743 started with xls import 2018-08-01 15:36:41 +02:00
7d405234d4 fix bcrypt issue 2018-08-01 11:27:13 +02:00
8 changed files with 75 additions and 6 deletions

View file

@ -2,6 +2,8 @@ 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)
pkg_check_modules(XLNT REQUIRED xlnt)
set(CORE_SOURCES set(CORE_SOURCES
database.cpp database.cpp
@ -10,9 +12,12 @@ set(CORE_SOURCES
article.cpp article.cpp
sale.cpp sale.cpp
marketplace.cpp marketplace.cpp
excelreader.cpp
) )
add_library(core STATIC ${CORE_SOURCES}) add_library(core STATIC ${CORE_SOURCES})
target_link_libraries(core Boost::boost Boost::date_time) target_link_libraries(core Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARIES})
target_link_libraries(core sqlite3) if (WIN32)
target_link_libraries(core bcrypt)
endif()
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

View file

@ -9,11 +9,7 @@ Entity::~Entity() = default;
void Entity::createUuid() void Entity::createUuid()
{ {
#if defined __linux__
static boost::uuids::random_generator generator{}; static boost::uuids::random_generator generator{};
#elif defined __WIN32
static boost::uuids::random_generator_mt19937 generator{};
#endif
uuid_ = generator(); uuid_ = generator();
} }

18
src/core/excelreader.cpp Normal file
View file

@ -0,0 +1,18 @@
#include "excelreader.h"
#include <xlnt/xlnt.hpp>
void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace* market)
{
xlnt::workbook wb;
wb.load(filename);
auto ws = wb.sheet_by_index(0);
const int START_ROW = 6;
const int END_ROW = 349;
for (const auto& row : ws.rows(false)) {
//auto test = row[0].value<int>();
//std::cout << test << "\n";
}
}

18
src/core/excelreader.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef EXCEL_READER_H
#define EXCEL_READER_H
#include "seller.h"
#include "marketplace.h"
#include <memory>
#include <string>
#include <vector>
class ExcelReader
{
public:
static void readSellersFromFile(const std::string& filename,
Marketplace* market);
};
#endif

View file

@ -7,6 +7,8 @@
#include <vector> #include <vector>
class ExcelReader;
namespace namespace
{ {
using SellersVec = std::vector<std::unique_ptr<Seller>>; using SellersVec = std::vector<std::unique_ptr<Seller>>;
@ -49,6 +51,8 @@ class Marketplace
void exportReportToCSV(const std::string& filename, int feeInPercent, int maxFeeInEuro); void exportReportToCSV(const std::string& filename, int feeInPercent, int maxFeeInEuro);
friend class ExcelReader;
private: private:
SellersVec sellers_; SellersVec sellers_;
SalesVec sales_; SalesVec sales_;

View file

@ -8,8 +8,11 @@
#include "sellerdialog.h" #include "sellerdialog.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include <excelreader.h>
#include <regex> #include <regex>
#include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
@ -58,6 +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_.importExcelAction, &QAction::triggered, this,
&MainWindow::onImportExcelActionTriggered);
} }
void MainWindow::onActionEditSellerTriggered() void MainWindow::onActionEditSellerTriggered()
@ -233,3 +238,19 @@ void MainWindow::onAbout()
"<p>Copyright © Martin Brodbeck &lt;<a href=mailto:martin@brodbeck-online.de" "<p>Copyright © Martin Brodbeck &lt;<a href=mailto:martin@brodbeck-online.de"
">info@rustysoft.de</a>&gt;</p>"); ">info@rustysoft.de</a>&gt;</p>");
} }
void MainWindow::onImportExcelActionTriggered()
{
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(),
"Excel Dateien (*.xlsx *.xls)");
ExcelReader::readSellersFromFile(filename.toStdString(), marketplace_.get());
}

View file

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

View file

@ -404,6 +404,7 @@ drucken</string>
<string>&amp;Verkäufer</string> <string>&amp;Verkäufer</string>
</property> </property>
<addaction name="actionEditSeller"/> <addaction name="actionEditSeller"/>
<addaction name="importExcelAction"/>
</widget> </widget>
<widget class="QMenu" name="menuHilfe"> <widget class="QMenu" name="menuHilfe">
<property name="title"> <property name="title">
@ -458,6 +459,11 @@ drucken</string>
<string>Auswertung</string> <string>Auswertung</string>
</property> </property>
</action> </action>
<action name="importExcelAction">
<property name="text">
<string>Importieren (Excel)</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>