Compare commits
3 commits
42bf036f85
...
c4ccd43b45
Author | SHA1 | Date | |
---|---|---|---|
c4ccd43b45 | |||
16745a248c | |||
19ea7f27de |
11 changed files with 20 additions and 135 deletions
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
project(kima2 VERSION 1.6.1)
|
project(kima2 VERSION 1.7.0)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake")
|
||||||
|
|
||||||
|
@ -95,7 +95,6 @@ if( MINGW )
|
||||||
${MINGW_PATH}/libwinpthread-1.dll
|
${MINGW_PATH}/libwinpthread-1.dll
|
||||||
${MINGW_PATH}/libsqlite3-0.dll
|
${MINGW_PATH}/libsqlite3-0.dll
|
||||||
${MINGW_PATH}/libusb-1.0.dll
|
${MINGW_PATH}/libusb-1.0.dll
|
||||||
${MINGW_PATH}/libxlnt.dll
|
|
||||||
${MINGW_PATH}/libicuuc71.dll
|
${MINGW_PATH}/libicuuc71.dll
|
||||||
${MINGW_PATH}/libicuin71.dll
|
${MINGW_PATH}/libicuin71.dll
|
||||||
${MINGW_PATH}/libicudt71.dll
|
${MINGW_PATH}/libicudt71.dll
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,12 +1,12 @@
|
||||||
# Maintainer: Martin Brodbeck <martin at brodbeck-online dot de>
|
# Maintainer: Martin Brodbeck <martin at brodbeck-online dot de>
|
||||||
pkgname=kima2
|
pkgname=kima2
|
||||||
pkgver=1.6.1
|
pkgver=1.7.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="A small cash point program for children's things markets (German only)"
|
pkgdesc="A small cash point program for children's things markets (German only)"
|
||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
url="http://www.rustysoft.de/software/kima2"
|
url="http://www.rustysoft.de/software/kima2"
|
||||||
license=('custom')
|
license=('custom')
|
||||||
depends=('glibc' 'libusb' 'qt6-base' 'sqlite3' 'xlnt')
|
depends=('glibc' 'libusb' 'qt6-base' 'sqlite3')
|
||||||
makedepends=('boost>=1.62')
|
makedepends=('boost>=1.62')
|
||||||
source=(git+https://git.rustysoft.de/martin/kima2)
|
source=(git+https://git.rustysoft.de/martin/kima2)
|
||||||
sha256sums=('SKIP')
|
sha256sums=('SKIP')
|
||||||
|
|
|
@ -13,7 +13,6 @@ BuildRequires: boost-date-time
|
||||||
BuildRequires: sqlite-devel
|
BuildRequires: sqlite-devel
|
||||||
BuildRequires: libusb-devel
|
BuildRequires: libusb-devel
|
||||||
BuildRequires: qt5-qtdeclarative-devel
|
BuildRequires: qt5-qtdeclarative-devel
|
||||||
#BuildRequires: pkgconfig(xlnt)
|
|
||||||
#BuildRequires: pkgconfig(pthreads)
|
#BuildRequires: pkgconfig(pthreads)
|
||||||
|
|
||||||
%description
|
%description
|
||||||
|
|
|
@ -9,14 +9,6 @@ find_package(Threads REQUIRED)
|
||||||
|
|
||||||
find_package(fmt)
|
find_package(fmt)
|
||||||
|
|
||||||
|
|
||||||
if (MINGW)
|
|
||||||
find_package(XLNT REQUIRED STATIC)
|
|
||||||
else (MINGW)
|
|
||||||
find_package(PkgConfig REQUIRED)
|
|
||||||
pkg_check_modules(XLNT REQUIRED xlnt>=1.3)
|
|
||||||
endif (MINGW)
|
|
||||||
|
|
||||||
set(CORE_SOURCES
|
set(CORE_SOURCES
|
||||||
database.cpp
|
database.cpp
|
||||||
entity.cpp
|
entity.cpp
|
||||||
|
@ -26,7 +18,6 @@ set(CORE_SOURCES
|
||||||
article.cpp
|
article.cpp
|
||||||
sale.cpp
|
sale.cpp
|
||||||
marketplace.cpp
|
marketplace.cpp
|
||||||
excelreader.cpp
|
|
||||||
csvreader.cpp
|
csvreader.cpp
|
||||||
jsonutil.cpp
|
jsonutil.cpp
|
||||||
utils.cpp
|
utils.cpp
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
#include "excelreader.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <xlnt/xlnt.hpp>
|
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
std::size_t ExcelReader::readSellersFromFile(const fs::path &filePath, Marketplace *market)
|
|
||||||
{
|
|
||||||
xlnt::workbook wb;
|
|
||||||
std::ifstream mystream(filePath, std::ios::binary);
|
|
||||||
if (!mystream.is_open()) {
|
|
||||||
throw std::runtime_error("Could not open Excel file");
|
|
||||||
}
|
|
||||||
wb.load(mystream);
|
|
||||||
|
|
||||||
for (auto &seller : market->getSellers()) {
|
|
||||||
seller->setState(Seller::State::DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
market->storeToDb(true);
|
|
||||||
auto ws = wb.sheet_by_index(0);
|
|
||||||
|
|
||||||
for (auto row : ws.rows(true)) {
|
|
||||||
// Skip the row if the first value is not a number (= seller no)
|
|
||||||
if (row[0].data_type() != xlnt::cell::type::number) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto seller = std::make_unique<Seller>();
|
|
||||||
seller->setSellerNo(row[0].value<int>());
|
|
||||||
seller->setNumArticlesOffered(row[1].value<int>());
|
|
||||||
|
|
||||||
// If both, first name and last name, are empty, use N. N.
|
|
||||||
// Else, use the real values.
|
|
||||||
if (row[2].value<std::string>().empty() && row[3].value<std::string>().empty()) {
|
|
||||||
seller->setFirstName("N.");
|
|
||||||
seller->setLastName("N.");
|
|
||||||
} else {
|
|
||||||
std::string firstName = row[2].value<std::string>();
|
|
||||||
seller->setFirstName(trim(firstName));
|
|
||||||
std::string lastName = row[3].value<std::string>();
|
|
||||||
seller->setLastName(trim(lastName));
|
|
||||||
}
|
|
||||||
|
|
||||||
market->getSellers().push_back(std::move(seller));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add one additional seller "RESERVE RESERVE"
|
|
||||||
auto seller = std::make_unique<Seller>();
|
|
||||||
seller->setSellerNo(market->getNextSellerNo());
|
|
||||||
seller->setFirstName("RESERVE");
|
|
||||||
seller->setLastName("RESERVE");
|
|
||||||
market->getSellers().push_back(std::move(seller));
|
|
||||||
|
|
||||||
// If there was no special seller "Sonderkonto" in import data, then create one
|
|
||||||
auto specialSeller = market->findSellerWithSellerNo(0);
|
|
||||||
if (!specialSeller) {
|
|
||||||
auto seller = std::make_unique<Seller>();
|
|
||||||
seller->setSellerNo(0);
|
|
||||||
seller->setLastName("Sonderkonto");
|
|
||||||
seller->setFirstName("Sonderkonto");
|
|
||||||
seller->setNumArticlesOffered(0);
|
|
||||||
market->getSellers().push_back(std::move(seller));
|
|
||||||
}
|
|
||||||
|
|
||||||
market->sortSellers();
|
|
||||||
market->storeToDb();
|
|
||||||
|
|
||||||
return market->getSellers().size() - 1; // minus 1 because we don't count the "special" seller
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef EXCEL_READER_H
|
|
||||||
#define EXCEL_READER_H
|
|
||||||
|
|
||||||
#include "marketplace.h"
|
|
||||||
#include "seller.h"
|
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class ExcelReader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static std::size_t readSellersFromFile(const std::filesystem::path &filePath,
|
|
||||||
Marketplace *market);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <core/csvreader.h>
|
#include <core/csvreader.h>
|
||||||
#include <core/excelreader.h>
|
|
||||||
#include <core/jsonutil.h>
|
#include <core/jsonutil.h>
|
||||||
#include <core/utils.h>
|
#include <core/utils.h>
|
||||||
#include <printer/posprinter.h>
|
#include <printer/posprinter.h>
|
||||||
|
@ -137,8 +136,8 @@ MainWindow::MainWindow()
|
||||||
this->setWindowTitle("KIMA2 - Kasse Nr. " +
|
this->setWindowTitle("KIMA2 - Kasse Nr. " +
|
||||||
QSettings().value("global/cashPointNo").toString());
|
QSettings().value("global/cashPointNo").toString());
|
||||||
});
|
});
|
||||||
connect(m_ui.importSellerExcelAction, &QAction::triggered, this,
|
connect(m_ui.importSellerAction, &QAction::triggered, this,
|
||||||
&MainWindow::onImportSellerExcelActionTriggered);
|
&MainWindow::onImportSellerActionTriggered);
|
||||||
connect(m_ui.importSellerJsonAction, &QAction::triggered, this,
|
connect(m_ui.importSellerJsonAction, &QAction::triggered, this,
|
||||||
&MainWindow::onImportSellerJsonActionTriggered);
|
&MainWindow::onImportSellerJsonActionTriggered);
|
||||||
connect(m_ui.exportSellerJsonAction, &QAction::triggered, this,
|
connect(m_ui.exportSellerJsonAction, &QAction::triggered, this,
|
||||||
|
@ -345,7 +344,8 @@ void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked)
|
||||||
m_ui.basketView->model()->removeRow(iter->row());
|
m_ui.basketView->model()->removeRow(iter->row());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui.basketSumLabel->setText(m_marketplace->getBasketSumAsString().c_str()); // Update basket sum
|
m_ui.basketSumLabel->setText(
|
||||||
|
m_marketplace->getBasketSumAsString().c_str()); // Update basket sum
|
||||||
m_ui.sellerNoEdit->setFocus();
|
m_ui.sellerNoEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +428,8 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||||
|
|
||||||
dynamic_cast<BasketModel *>(m_ui.basketView->model())->cancelSale();
|
dynamic_cast<BasketModel *>(m_ui.basketView->model())->cancelSale();
|
||||||
|
|
||||||
m_ui.basketSumLabel->setText(m_marketplace->getBasketSumAsString().c_str()); // Update basket sum
|
m_ui.basketSumLabel->setText(
|
||||||
|
m_marketplace->getBasketSumAsString().c_str()); // Update basket sum
|
||||||
m_ui.sellerNoEdit->setFocus();
|
m_ui.sellerNoEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +446,7 @@ void MainWindow::onAbout()
|
||||||
">info@rustysoft.de</a>></p>");
|
">info@rustysoft.de</a>></p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onImportSellerExcelActionTriggered()
|
void MainWindow::onImportSellerActionTriggered()
|
||||||
{
|
{
|
||||||
if (!m_marketplace->getSales().empty()) {
|
if (!m_marketplace->getSales().empty()) {
|
||||||
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
|
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
|
||||||
|
@ -455,9 +456,9 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto filename = QFileDialog::getOpenFileName(
|
auto filename =
|
||||||
this, "Verkäufer importieren", QString(),
|
QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(),
|
||||||
"Alle unterstützte Dateien (*.xlsx *.csv);;Excel Dateien (*.xlsx);;CSV Dateien (*.csv)");
|
"Alle unterstützte Dateien (*.csv);;CSV Dateien (*.csv)");
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -469,27 +470,13 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::size_t numImported{};
|
std::size_t numImported{};
|
||||||
if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) {
|
numImported = CsvReader::readSellersFromFile(filePath, m_marketplace.get());
|
||||||
try {
|
|
||||||
numImported = ExcelReader::readSellersFromFile(filePath, m_marketplace.get());
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
QMessageBox(QMessageBox::Icon::Critical, "Fehler beim Importieren",
|
|
||||||
"Beim Import aus der Excel-Datei ist ein Fehler aufgetreten. "
|
|
||||||
"Sie könnten ggf. versuchen, die Daten aus einer .csv Datei zu imporieren.",
|
|
||||||
QMessageBox::StandardButton::Ok, this)
|
|
||||||
.exec();
|
|
||||||
std::cerr << e.what() << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
numImported = CsvReader::readSellersFromFile(filePath, m_marketplace.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateStatLabel();
|
updateStatLabel();
|
||||||
|
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Aus der Excel/CSV-Datei wurden <b>"s << std::to_string(numImported)
|
msg << "Aus der CSV-Datei wurden <b>"s << std::to_string(numImported)
|
||||||
<< "</b> Verkäufer importiert.";
|
<< "</b> Verkäufer importiert.";
|
||||||
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
||||||
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MainWindow : public QMainWindow
|
||||||
void checkSellerNo(bool ctrlPressed = false);
|
void checkSellerNo(bool ctrlPressed = false);
|
||||||
void onPaidButtonTriggered();
|
void onPaidButtonTriggered();
|
||||||
void onGivenSpinBoxValueChanged(double value);
|
void onGivenSpinBoxValueChanged(double value);
|
||||||
void onImportSellerExcelActionTriggered();
|
void onImportSellerActionTriggered();
|
||||||
void onImportSellerJsonActionTriggered();
|
void onImportSellerJsonActionTriggered();
|
||||||
void onExportSellerJsonActionTriggered();
|
void onExportSellerJsonActionTriggered();
|
||||||
void onExportSalesJsonActionTriggered();
|
void onExportSalesJsonActionTriggered();
|
||||||
|
|
|
@ -423,7 +423,7 @@ drucken</string>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>817</width>
|
<width>817</width>
|
||||||
<height>30</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu_Datei">
|
<widget class="QMenu" name="menu_Datei">
|
||||||
|
@ -444,7 +444,7 @@ drucken</string>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Importieren</string>
|
<string>Importieren</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="importSellerExcelAction"/>
|
<addaction name="importSellerAction"/>
|
||||||
<addaction name="importSellerJsonAction"/>
|
<addaction name="importSellerJsonAction"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionEditSeller"/>
|
<addaction name="actionEditSeller"/>
|
||||||
|
@ -513,9 +513,9 @@ drucken</string>
|
||||||
<string>Exportieren für andere Kasse (JSON)</string>
|
<string>Exportieren für andere Kasse (JSON)</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="importSellerExcelAction">
|
<action name="importSellerAction">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Aus Excel/CSV-Datei (initial)</string>
|
<string>Aus CSV-Datei (initial)</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="importSellerJsonAction">
|
<action name="importSellerJsonAction">
|
||||||
|
|
Loading…
Reference in a new issue