Compare commits
37 commits
86a9ed38b6
...
eb23243637
Author | SHA1 | Date | |
---|---|---|---|
eb23243637 | |||
e92b080f7a | |||
bd23e2417c | |||
fe7ddc5cf2 | |||
43faf05006 | |||
04de363af5 | |||
1aa56f24a3 | |||
d546b61f00 | |||
373e143aa4 | |||
6c0441992f | |||
4fb6d2f98b | |||
e9fde76a60 | |||
f6528bdf45 | |||
127fbc1398 | |||
ef88604ad4 | |||
ad68fb8bf7 | |||
0b4041c13a | |||
9ef1ada6d9 | |||
723dee825b | |||
d15deb42c8 | |||
4f0ce62ce5 | |||
7571ef6a13 | |||
6b9ac3d284 | |||
9f114660e1 | |||
d5d309ac10 | |||
cdec552f04 | |||
cdeea37f8c | |||
639c8ec576 | |||
8e5080b888 | |||
cfc632a986 | |||
271aac0914 | |||
725bc8f04b | |||
42a1a3151f | |||
337462f010 | |||
634b256da7 | |||
b76d1e129a | |||
a870736d72 |
18 changed files with 169 additions and 39 deletions
|
@ -1,4 +1,3 @@
|
||||||
---
|
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
# BasedOnStyle: LLVM
|
# BasedOnStyle: LLVM
|
||||||
AccessModifierOffset: -2
|
AccessModifierOffset: -2
|
||||||
|
@ -90,10 +89,6 @@ PenaltyBreakString: 1000
|
||||||
PenaltyExcessCharacter: 1000000
|
PenaltyExcessCharacter: 1000000
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
RawStringFormats:
|
|
||||||
- Delimiter: pb
|
|
||||||
Language: TextProto
|
|
||||||
BasedOnStyle: google
|
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
SortIncludes: true
|
SortIncludes: true
|
||||||
SortUsingDeclarations: true
|
SortUsingDeclarations: true
|
||||||
|
@ -108,8 +103,7 @@ SpacesInContainerLiterals: true
|
||||||
SpacesInCStyleCastParentheses: false
|
SpacesInCStyleCastParentheses: false
|
||||||
SpacesInParentheses: false
|
SpacesInParentheses: false
|
||||||
SpacesInSquareBrackets: false
|
SpacesInSquareBrackets: false
|
||||||
Standard: Cpp11
|
Standard: Auto
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
...
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
project(kima2 VERSION 0.10.3)
|
project(kima2 VERSION 0.12.0)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ if( MINGW )
|
||||||
${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}/libxlnt.dll
|
||||||
${MINGW_PATH}/libicuuc61.dll
|
${MINGW_PATH}/libicuuc62.dll
|
||||||
${MINGW_PATH}/libicuin61.dll
|
${MINGW_PATH}/libicuin62.dll
|
||||||
${MINGW_PATH}/libicudt61.dll
|
${MINGW_PATH}/libicudt62.dll
|
||||||
${MINGW_PATH}/libjsoncpp-20.dll
|
${MINGW_PATH}/libjsoncpp-20.dll
|
||||||
${MINGW_PATH}/libpcre2-16-0.dll
|
${MINGW_PATH}/libpcre2-16-0.dll
|
||||||
${MINGW_PATH}/zlib1.dll
|
${MINGW_PATH}/zlib1.dll
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -5,6 +5,8 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||||
|
|
||||||
Database::Database(const std::string& dbname)
|
Database::Database(const std::string& dbname)
|
||||||
{
|
{
|
||||||
dbname_ = dbname;
|
dbname_ = dbname;
|
||||||
|
@ -30,11 +32,29 @@ Database::Database()
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbpath /= "kima2-cpp.db";
|
dbpath /= "kima2.db";
|
||||||
dbname_ = dbpath.string();
|
dbname_ = dbpath.string();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Database::newDb()
|
||||||
|
{
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
sqlite3_close(db_);
|
||||||
|
|
||||||
|
fs::path sourcePath = dbname_;
|
||||||
|
fs::path destPath = sourcePath.parent_path() / sourcePath.stem();
|
||||||
|
destPath += std::string("_") +=
|
||||||
|
boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time()) += ".db";
|
||||||
|
|
||||||
|
fs::copy_file(sourcePath, destPath, fs::copy_options::overwrite_existing);
|
||||||
|
|
||||||
|
fs::remove(sourcePath);
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
Database::~Database() { sqlite3_close(db_); }
|
Database::~Database() { sqlite3_close(db_); }
|
||||||
|
|
||||||
void Database::exec(const std::string& sql)
|
void Database::exec(const std::string& sql)
|
||||||
|
@ -55,7 +75,7 @@ void Database::createNew()
|
||||||
|
|
||||||
std::string sqlCreateKima2{"CREATE TABLE IF NOT EXISTS kima2 ("
|
std::string sqlCreateKima2{"CREATE TABLE IF NOT EXISTS kima2 ("
|
||||||
"version INTEGER NOT NULL);"
|
"version INTEGER NOT NULL);"
|
||||||
"INSERT INTO kima2 (version) VALUES (1);"};
|
"INSERT INTO kima2 (version) VALUES (2);"};
|
||||||
sqlStrings.push_back(sqlCreateKima2);
|
sqlStrings.push_back(sqlCreateKima2);
|
||||||
std::string sqlCreateSellers{"CREATE TABLE IF NOT EXISTS sellers ("
|
std::string sqlCreateSellers{"CREATE TABLE IF NOT EXISTS sellers ("
|
||||||
"id TEXT PRIMARY KEY NOT NULL, "
|
"id TEXT PRIMARY KEY NOT NULL, "
|
||||||
|
@ -94,6 +114,12 @@ void Database::createNew()
|
||||||
");"};
|
");"};
|
||||||
sqlStrings.push_back(sqlCreateSalesItems);
|
sqlStrings.push_back(sqlCreateSalesItems);
|
||||||
|
|
||||||
|
std::string sqlInitialEntries{
|
||||||
|
"INSERT OR IGNORE INTO sellers (id, seller_no, first_name, last_name, "
|
||||||
|
"num_offered_articles) VALUES "
|
||||||
|
"('11111111-1111-1111-1111-111111111111', 0, 'Sonderkonto', 'Sonderkonto', 0)"};
|
||||||
|
sqlStrings.push_back(sqlInitialEntries);
|
||||||
|
|
||||||
beginTransaction();
|
beginTransaction();
|
||||||
for (const auto& sql : sqlStrings) {
|
for (const auto& sql : sqlStrings) {
|
||||||
exec(sql);
|
exec(sql);
|
||||||
|
|
|
@ -24,6 +24,7 @@ class Database
|
||||||
unsigned int loadSales(std::vector<std::unique_ptr<Sale>>& sales,
|
unsigned int loadSales(std::vector<std::unique_ptr<Sale>>& sales,
|
||||||
std::vector<std::unique_ptr<Seller>>& sellers);
|
std::vector<std::unique_ptr<Seller>>& sellers);
|
||||||
void updateCashPointNo(int oldCashPointNo, int newCashPointNo);
|
void updateCashPointNo(int oldCashPointNo, int newCashPointNo);
|
||||||
|
void newDb();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sqlite3* db_{nullptr};
|
sqlite3* db_{nullptr};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ Seller* Marketplace::findSellerWithUuid(const std::string& uuid)
|
||||||
|
|
||||||
void Marketplace::addArticleToBasket(std::unique_ptr<Article> article)
|
void Marketplace::addArticleToBasket(std::unique_ptr<Article> article)
|
||||||
{
|
{
|
||||||
basket_.push_back(std::move(article));
|
basket_.insert(basket_.begin(), std::move(article)); // article to the beginning of the basket vector
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Marketplace::basketSize() { return basket_.size(); }
|
size_t Marketplace::basketSize() { return basket_.size(); }
|
||||||
|
@ -272,7 +273,7 @@ std::string escapeCsvValue(const std::string& value, const char delimiter)
|
||||||
|
|
||||||
void Marketplace::clear()
|
void Marketplace::clear()
|
||||||
{
|
{
|
||||||
std::for_each(sellers_.begin(), sellers_.end(), [](auto& seller) {
|
/* std::for_each(sellers_.begin(), sellers_.end(), [](auto& seller) {
|
||||||
if (seller->getUuidAsString() == "11111111-1111-1111-1111-111111111111") {
|
if (seller->getUuidAsString() == "11111111-1111-1111-1111-111111111111") {
|
||||||
for (auto& article : seller->getArticles()) {
|
for (auto& article : seller->getArticles()) {
|
||||||
article->setState(Article::State::DELETE);
|
article->setState(Article::State::DELETE);
|
||||||
|
@ -283,5 +284,9 @@ void Marketplace::clear()
|
||||||
});
|
});
|
||||||
std::for_each(sales_.begin(), sales_.end(),
|
std::for_each(sales_.begin(), sales_.end(),
|
||||||
[](auto& sale) { sale->setState(Sale::State::DELETE); });
|
[](auto& sale) { sale->setState(Sale::State::DELETE); });
|
||||||
storeToDb();
|
storeToDb(); */
|
||||||
|
|
||||||
|
Database db;
|
||||||
|
db.newDb();
|
||||||
|
loadFromDb();
|
||||||
}
|
}
|
|
@ -35,6 +35,16 @@ std::string Seller::getLastName() const { return lastName_; }
|
||||||
|
|
||||||
int Seller::getSellerNo() const { return sellerNo_; }
|
int Seller::getSellerNo() const { return sellerNo_; }
|
||||||
|
|
||||||
|
std::string Seller::getSellerNoAsString() const
|
||||||
|
{
|
||||||
|
std::stringstream selNoStr;
|
||||||
|
|
||||||
|
selNoStr << std::setfill('0') << std::setw(3) << sellerNo_;
|
||||||
|
|
||||||
|
return selNoStr.str();
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Article*> Seller::getArticles(bool onlySold) const
|
std::vector<Article*> Seller::getArticles(bool onlySold) const
|
||||||
{
|
{
|
||||||
std::vector<Article*> articles;
|
std::vector<Article*> articles;
|
||||||
|
@ -94,7 +104,6 @@ int Seller::sumInCents()
|
||||||
|
|
||||||
std::string Seller::sumAsString() { return formatCentAsEuroString(sumInCents()); }
|
std::string Seller::sumAsString() { return formatCentAsEuroString(sumInCents()); }
|
||||||
|
|
||||||
|
|
||||||
bool operator<(const Seller& li, const Seller& re) { return li.sellerNo_ < re.sellerNo_; }
|
bool operator<(const Seller& li, const Seller& re) { return li.sellerNo_ < re.sellerNo_; }
|
||||||
bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re)
|
bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//class Article;
|
// class Article;
|
||||||
|
|
||||||
class Seller : public Entity
|
class Seller : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Seller() = default;
|
Seller() = default;
|
||||||
//virtual ~Seller() = default;
|
// virtual ~Seller() = default;
|
||||||
Seller(const std::string& firstName, const std::string& lastName, int sellerNo = 0,
|
Seller(const std::string& firstName, const std::string& lastName, int sellerNo = 0,
|
||||||
int numArticlesOffered = 0);
|
int numArticlesOffered = 0);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ class Seller : public Entity
|
||||||
std::string getFirstName() const;
|
std::string getFirstName() const;
|
||||||
std::string getLastName() const;
|
std::string getLastName() const;
|
||||||
int getSellerNo() const;
|
int getSellerNo() const;
|
||||||
|
std::string getSellerNoAsString() const;
|
||||||
int numArticlesOffered() const;
|
int numArticlesOffered() const;
|
||||||
int numArticlesSold() const;
|
int numArticlesSold() const;
|
||||||
// int numArticlesTotal() const;
|
// int numArticlesTotal() const;
|
||||||
|
|
|
@ -21,15 +21,19 @@ QVariant BasketModel::data(const QModelIndex& index, int role) const
|
||||||
if (role == Qt::FontRole) {
|
if (role == Qt::FontRole) {
|
||||||
QFont myFont;
|
QFont myFont;
|
||||||
|
|
||||||
|
QFont myFixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||||
|
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0:
|
case 0:
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case 1:
|
case 1:
|
||||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
return myFixedFont;
|
||||||
case 2:
|
case 2:
|
||||||
return myFont;
|
myFixedFont.setPointSize(myFixedFont.pointSize() + 3);
|
||||||
|
return myFixedFont;
|
||||||
case 3:
|
case 3:
|
||||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
myFixedFont.setPointSize(myFixedFont.pointSize() + 3);
|
||||||
|
return myFixedFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ MainWindow::MainWindow()
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
|
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
|
||||||
marketplace_->clear();
|
marketplace_->clear();
|
||||||
setSaleModel();
|
setSaleModel();
|
||||||
|
updateStatLabel();
|
||||||
});
|
});
|
||||||
|
|
||||||
ui_.sellerNoEdit->installEventFilter(this);
|
ui_.sellerNoEdit->installEventFilter(this);
|
||||||
|
@ -139,6 +140,8 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
readGeometry();
|
readGeometry();
|
||||||
setWindowIcon(QIcon(":/misc/kima2.ico"));
|
setWindowIcon(QIcon(":/misc/kima2.ico"));
|
||||||
|
|
||||||
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onActionEditSellerTriggered()
|
void MainWindow::onActionEditSellerTriggered()
|
||||||
|
@ -159,6 +162,7 @@ void MainWindow::onActionEditSellerTriggered()
|
||||||
}
|
}
|
||||||
|
|
||||||
setSaleModel();
|
setSaleModel();
|
||||||
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setSaleModel()
|
void MainWindow::setSaleModel()
|
||||||
|
@ -189,6 +193,7 @@ void MainWindow::onPaidButtonTriggered()
|
||||||
ui_.drawbackContainerWidget->setEnabled(false);
|
ui_.drawbackContainerWidget->setEnabled(false);
|
||||||
ui_.sellerNoEdit->setFocus();
|
ui_.sellerNoEdit->setFocus();
|
||||||
statusBar()->showMessage("Verkaufsvorgang erfolgreich durchgeführt.", STATUSBAR_TIMEOUT);
|
statusBar()->showMessage("Verkaufsvorgang erfolgreich durchgeführt.", STATUSBAR_TIMEOUT);
|
||||||
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,11 +260,15 @@ void MainWindow::checkSellerNo(bool ctrlPressed)
|
||||||
auto seller = marketplace_->findSellerWithSellerNo(sellerNo);
|
auto seller = marketplace_->findSellerWithSellerNo(sellerNo);
|
||||||
if (seller) {
|
if (seller) {
|
||||||
PriceDialog priceDialog(this);
|
PriceDialog priceDialog(this);
|
||||||
|
if(sellerNo == 0) {
|
||||||
|
priceDialog.setForceDesc(true);
|
||||||
|
}
|
||||||
auto dialogResult = priceDialog.exec();
|
auto dialogResult = priceDialog.exec();
|
||||||
if (dialogResult == QDialog::Accepted) {
|
if (dialogResult == QDialog::Accepted) {
|
||||||
int price = priceDialog.getPrice();
|
int price = priceDialog.getPrice();
|
||||||
std::string desc = priceDialog.getDescription();
|
std::string desc = priceDialog.getDescription();
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price, desc);
|
dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price, desc);
|
||||||
|
ui_.basketView->resizeColumnToContents(1);
|
||||||
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
|
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,6 +331,9 @@ void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked)
|
||||||
for (auto iter = indexes.constEnd() - 1; iter >= indexes.constBegin(); --iter) {
|
for (auto iter = indexes.constEnd() - 1; iter >= indexes.constBegin(); --iter) {
|
||||||
ui_.basketView->model()->removeRow(iter->row());
|
ui_.basketView->model()->removeRow(iter->row());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str()); // Update basket sum
|
||||||
|
ui_.sellerNoEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onCancelSaleButtonClicked([[maybe_unused]] bool checked)
|
void MainWindow::onCancelSaleButtonClicked([[maybe_unused]] bool checked)
|
||||||
|
@ -345,6 +357,9 @@ void MainWindow::onCancelSaleButtonClicked([[maybe_unused]] bool checked)
|
||||||
for (auto iter = indexes.constEnd() - 1; iter >= indexes.constBegin(); --iter) {
|
for (auto iter = indexes.constEnd() - 1; iter >= indexes.constBegin(); --iter) {
|
||||||
ui_.salesView->model()->removeRow(iter->row(), iter->parent());
|
ui_.salesView->model()->removeRow(iter->row(), iter->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui_.salesView->collapseAll();
|
||||||
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
|
void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
|
||||||
|
@ -389,6 +404,9 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
|
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
|
||||||
|
|
||||||
|
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str()); // Update basket sum
|
||||||
|
ui_.sellerNoEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAboutQt() { QMessageBox::aboutQt(this); }
|
void MainWindow::onAboutQt() { QMessageBox::aboutQt(this); }
|
||||||
|
@ -431,6 +449,7 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
fs::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
||||||
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onImportSellerJsonActionTriggered()
|
void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
|
@ -452,6 +471,7 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
fs::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
JsonUtil::importSellers(filePath, marketplace_.get());
|
JsonUtil::importSellers(filePath, marketplace_.get());
|
||||||
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onExportSellerJsonActionTriggered()
|
void MainWindow::onExportSellerJsonActionTriggered()
|
||||||
|
@ -471,8 +491,10 @@ void MainWindow::onExportSalesJsonActionTriggered()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
auto filename = QFileDialog::getSaveFileName(this, "Umsätze/Transaktionen exportieren",
|
auto filename = QFileDialog::getSaveFileName(
|
||||||
QString(), "JSON Dateien (*.json)");
|
this, "Umsätze/Transaktionen exportieren",
|
||||||
|
QString("kima2_umsaetze_kasse") + settings.value("global/cashPointNo").toString() + ".json",
|
||||||
|
"JSON Dateien (*.json)");
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -506,6 +528,7 @@ void MainWindow::onImportSalesJsonActionTriggered()
|
||||||
marketplace_->loadFromDb();
|
marketplace_->loadFromDb();
|
||||||
}
|
}
|
||||||
setSaleModel();
|
setSaleModel();
|
||||||
|
updateStatLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::writeGeometry()
|
void MainWindow::writeGeometry()
|
||||||
|
@ -533,3 +556,14 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
writeGeometry();
|
writeGeometry();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateStatLabel()
|
||||||
|
{
|
||||||
|
std::string statistics("<b>KIMA2 - Version ");
|
||||||
|
statistics += PROJECT_VERSION;
|
||||||
|
statistics += "</b><br />Verkäufer: " + std::to_string(marketplace_->getSellers().size() - 1);
|
||||||
|
statistics += "<br />Kunden: " + std::to_string(marketplace_->getSales().size());
|
||||||
|
statistics += "<br />Umsatz: " + marketplace_->getOverallSumAsString();
|
||||||
|
|
||||||
|
ui_.statLabel->setText(statistics.c_str());
|
||||||
|
}
|
|
@ -47,6 +47,7 @@ class MainWindow : public QMainWindow
|
||||||
void setSaleModel();
|
void setSaleModel();
|
||||||
void writeGeometry();
|
void writeGeometry();
|
||||||
void readGeometry();
|
void readGeometry();
|
||||||
|
void updateStatLabel();
|
||||||
|
|
||||||
Ui::MainWindow ui_;
|
Ui::MainWindow ui_;
|
||||||
std::unique_ptr<Marketplace> marketplace_;
|
std::unique_ptr<Marketplace> marketplace_;
|
||||||
|
|
|
@ -92,7 +92,16 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
@ -166,7 +175,7 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Stornieren</string>
|
<string>&Stornieren</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -176,7 +185,7 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Alles stornieren</string>
|
<string>&Alles stornieren</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -331,6 +340,37 @@ drucken</string>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="statLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::RichText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
|
@ -379,7 +419,7 @@ drucken</string>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>817</width>
|
<width>817</width>
|
||||||
<height>29</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu_Datei">
|
<widget class="QMenu" name="menu_Datei">
|
||||||
|
@ -433,8 +473,7 @@ drucken</string>
|
||||||
<action name="actionQuit">
|
<action name="actionQuit">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="application-exit">
|
<iconset theme="application-exit">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Beenden</string>
|
<string>&Beenden</string>
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
PriceDialog::PriceDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
|
PriceDialog::PriceDialog(QWidget* parent, bool forceDesc, Qt::WindowFlags f) : QDialog(parent, f)
|
||||||
{
|
{
|
||||||
|
forceDesc_ = forceDesc;
|
||||||
ui_.setupUi(this);
|
ui_.setupUi(this);
|
||||||
ui_.priceSpinBox->setFocus();
|
ui_.priceSpinBox->setFocus();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +22,18 @@ void PriceDialog::accept()
|
||||||
"Es sind nur 0,50 Cent-Schritte erlaubt.", QMessageBox::StandardButton::Ok,
|
"Es sind nur 0,50 Cent-Schritte erlaubt.", QMessageBox::StandardButton::Ok,
|
||||||
this)
|
this)
|
||||||
.exec();
|
.exec();
|
||||||
|
} else if (forceDesc_ && ui_.descEdit->text().trimmed().isEmpty()) {
|
||||||
|
QMessageBox(QMessageBox::Icon::Warning, "Artikelbeschreibung fehlt",
|
||||||
|
"Da Sie auf das Sonderkonto buchen ist eine Artikelbeschreibung erforderlich.",
|
||||||
|
QMessageBox::StandardButton::Ok, this)
|
||||||
|
.exec();
|
||||||
|
ui_.descEdit->setFocus();
|
||||||
} else {
|
} else {
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PriceDialog::setForceDesc(bool force)
|
||||||
|
{
|
||||||
|
forceDesc_ = force;
|
||||||
|
}
|
|
@ -10,15 +10,17 @@ class PriceDialog : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PriceDialog(QWidget* parent = nullptr,
|
PriceDialog(QWidget* parent = nullptr, bool forceDesc = false,
|
||||||
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
||||||
int getPrice() const;
|
int getPrice() const;
|
||||||
std::string getDescription() const;
|
std::string getDescription() const;
|
||||||
|
void setForceDesc(bool force);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void on_model_duplicateSellerNo(const QString& message);
|
void on_model_duplicateSellerNo(const QString& message);
|
||||||
virtual void accept() override;
|
virtual void accept() override;
|
||||||
Ui::PriceDialog ui_;
|
Ui::PriceDialog ui_;
|
||||||
|
bool forceDesc_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -161,9 +161,10 @@ void ReportDialog::onPrintReportButtonClicked()
|
||||||
(static_cast<double>(numArticlesSold) / static_cast<double>(numArticlesOffered)) * 100;
|
(static_cast<double>(numArticlesSold) / static_cast<double>(numArticlesOffered)) * 100;
|
||||||
content += QString("Registrierte Verkäufer: %1\n").arg(sellers.size() - 1, 6);
|
content += QString("Registrierte Verkäufer: %1\n").arg(sellers.size() - 1, 6);
|
||||||
content += QString("Angelieferte Artikel: %1\n").arg(numArticlesOffered, 6);
|
content += QString("Angelieferte Artikel: %1\n").arg(numArticlesOffered, 6);
|
||||||
content += QString("Verkaufte Artikel: %1 (%L2 %)\n\n")
|
content += QString("Verkaufte Artikel: %1 (%L2 %)\n")
|
||||||
.arg(numArticlesSold, 6)
|
.arg(numArticlesSold, 6)
|
||||||
.arg(percentArticlesSold, 0, 'f', 2);
|
.arg(percentArticlesSold, 0, 'f', 2);
|
||||||
|
content += QString("Anzahl Kunden: %1\n\n").arg(market_->getSales().size(), 6);
|
||||||
content += QString("Gesamtumsatz: %1\n").arg(market_->getOverallSumAsString().c_str(), 10);
|
content += QString("Gesamtumsatz: %1\n").arg(market_->getOverallSumAsString().c_str(), 10);
|
||||||
content +=
|
content +=
|
||||||
QString("Ausgezahlt: %1\n")
|
QString("Ausgezahlt: %1\n")
|
||||||
|
|
|
@ -108,7 +108,7 @@ QVariant SaleModel::data(const QModelIndex& index, int role) const
|
||||||
Article* article = static_cast<Article*>(index.internalPointer());
|
Article* article = static_cast<Article*>(index.internalPointer());
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0:
|
case 0:
|
||||||
return article->getCompleteArticleNo().c_str();
|
return (std::string("Verk. ") + std::to_string(article->getSeller()->getSellerNo()) + " (" + article->getCompleteArticleNo() + ")").c_str();
|
||||||
case 1:
|
case 1:
|
||||||
return article->getPriceAsString().c_str();
|
return article->getPriceAsString().c_str();
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -146,7 +146,7 @@ QVariant SaleModel::headerData(int section, Qt::Orientation orientation, int rol
|
||||||
if (orientation == Qt::Horizontal) {
|
if (orientation == Qt::Horizontal) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
return "Zeit / Art.Nr.";
|
return "Zeit / Verk.Nr. (Art.Nr)";
|
||||||
case 1:
|
case 1:
|
||||||
return "Preis";
|
return "Preis";
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -46,7 +46,8 @@ PosPrinter::PosPrinter(const PrinterDevice& printerDevice) : printerDevice_(prin
|
||||||
|
|
||||||
if (printerDevice_.idVendor == 0) {
|
if (printerDevice_.idVendor == 0) {
|
||||||
for (const auto& supported : supportedPrinters_.models) {
|
for (const auto& supported : supportedPrinters_.models) {
|
||||||
if (desc.idVendor == std::get<0>(supported) && desc.idProduct == std::get<1>(supported)) {
|
if (desc.idVendor == std::get<0>(supported) &&
|
||||||
|
desc.idProduct == std::get<1>(supported)) {
|
||||||
numDevice = i;
|
numDevice = i;
|
||||||
printerEndpoint_ = std::get<2>(supported);
|
printerEndpoint_ = std::get<2>(supported);
|
||||||
break;
|
break;
|
||||||
|
@ -161,8 +162,8 @@ void PosPrinter::printSaleReceipt(Sale* sale)
|
||||||
commandStream << sale->getTimestampFormatted() << "\n\n";
|
commandStream << sale->getTimestampFormatted() << "\n\n";
|
||||||
commandStream << Command::LEFT_ALIGN;
|
commandStream << Command::LEFT_ALIGN;
|
||||||
for (const auto& article : sale->getArticles()) {
|
for (const auto& article : sale->getArticles()) {
|
||||||
commandStream << "Art. " << article->getCompleteArticleNo() << "........... "
|
commandStream << "Verk.Nr. " << article->getSeller()->getSellerNoAsString()
|
||||||
<< article->getPriceAsString() << "\n";
|
<< "........... " << article->getPriceAsString() << "\n";
|
||||||
}
|
}
|
||||||
commandStream << "\nGesamt................. " << sale->sumAsString() << "\n";
|
commandStream << "\nGesamt................. " << sale->sumAsString() << "\n";
|
||||||
commandStream << Command::CENTERING;
|
commandStream << Command::CENTERING;
|
||||||
|
|
Loading…
Reference in a new issue