Compare commits

..

No commits in common. "eb232436379e176fd0413b41133103c504f07d60" and "86a9ed38b63444d2baa3955de2d2b905d54976b8" have entirely different histories.

18 changed files with 39 additions and 169 deletions

View file

@ -1,3 +1,4 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
@ -89,6 +90,10 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
RawStringFormats:
- Delimiter: pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
@ -103,7 +108,8 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
Standard: Cpp11
TabWidth: 8
UseTab: Never
...

View file

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8)
project(kima2 VERSION 0.12.0)
project(kima2 VERSION 0.10.3)
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake" ${CMAKE_MODULE_PATH})
@ -87,9 +87,9 @@ if( MINGW )
${MINGW_PATH}/libsqlite3-0.dll
${MINGW_PATH}/libusb-1.0.dll
${MINGW_PATH}/libxlnt.dll
${MINGW_PATH}/libicuuc62.dll
${MINGW_PATH}/libicuin62.dll
${MINGW_PATH}/libicudt62.dll
${MINGW_PATH}/libicuuc61.dll
${MINGW_PATH}/libicuin61.dll
${MINGW_PATH}/libicudt61.dll
${MINGW_PATH}/libjsoncpp-20.dll
${MINGW_PATH}/libpcre2-16-0.dll
${MINGW_PATH}/zlib1.dll

Binary file not shown.

Binary file not shown.

View file

@ -5,8 +5,6 @@
#include <stdexcept>
#include <vector>
#include "boost/date_time/posix_time/posix_time.hpp"
Database::Database(const std::string& dbname)
{
dbname_ = dbname;
@ -32,29 +30,11 @@ Database::Database()
throw err;
}
}
dbpath /= "kima2.db";
dbpath /= "kima2-cpp.db";
dbname_ = dbpath.string();
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_); }
void Database::exec(const std::string& sql)
@ -75,7 +55,7 @@ void Database::createNew()
std::string sqlCreateKima2{"CREATE TABLE IF NOT EXISTS kima2 ("
"version INTEGER NOT NULL);"
"INSERT INTO kima2 (version) VALUES (2);"};
"INSERT INTO kima2 (version) VALUES (1);"};
sqlStrings.push_back(sqlCreateKima2);
std::string sqlCreateSellers{"CREATE TABLE IF NOT EXISTS sellers ("
"id TEXT PRIMARY KEY NOT NULL, "
@ -114,12 +94,6 @@ void Database::createNew()
");"};
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();
for (const auto& sql : sqlStrings) {
exec(sql);

View file

@ -24,7 +24,6 @@ class Database
unsigned int loadSales(std::vector<std::unique_ptr<Sale>>& sales,
std::vector<std::unique_ptr<Seller>>& sellers);
void updateCashPointNo(int oldCashPointNo, int newCashPointNo);
void newDb();
private:
sqlite3* db_{nullptr};

View file

@ -7,7 +7,6 @@
#include <iomanip>
#include <numeric>
#include <sstream>
#include <filesystem>
namespace fs = std::filesystem;
@ -114,7 +113,7 @@ Seller* Marketplace::findSellerWithUuid(const std::string& uuid)
void Marketplace::addArticleToBasket(std::unique_ptr<Article> article)
{
basket_.insert(basket_.begin(), std::move(article)); // article to the beginning of the basket vector
basket_.push_back(std::move(article));
}
size_t Marketplace::basketSize() { return basket_.size(); }
@ -273,7 +272,7 @@ std::string escapeCsvValue(const std::string& value, const char delimiter)
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") {
for (auto& article : seller->getArticles()) {
article->setState(Article::State::DELETE);
@ -284,9 +283,5 @@ void Marketplace::clear()
});
std::for_each(sales_.begin(), sales_.end(),
[](auto& sale) { sale->setState(Sale::State::DELETE); });
storeToDb(); */
Database db;
db.newDb();
loadFromDb();
storeToDb();
}

View file

@ -35,16 +35,6 @@ std::string Seller::getLastName() const { return lastName_; }
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*> articles;
@ -104,6 +94,7 @@ int Seller::sumInCents()
std::string Seller::sumAsString() { return formatCentAsEuroString(sumInCents()); }
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)
{

View file

@ -28,7 +28,6 @@ class Seller : public Entity
std::string getFirstName() const;
std::string getLastName() const;
int getSellerNo() const;
std::string getSellerNoAsString() const;
int numArticlesOffered() const;
int numArticlesSold() const;
// int numArticlesTotal() const;

View file

@ -21,19 +21,15 @@ QVariant BasketModel::data(const QModelIndex& index, int role) const
if (role == Qt::FontRole) {
QFont myFont;
QFont myFixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
switch (index.column()) {
case 0:
[[fallthrough]];
case 1:
return myFixedFont;
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
case 2:
myFixedFont.setPointSize(myFixedFont.pointSize() + 3);
return myFixedFont;
return myFont;
case 3:
myFixedFont.setPointSize(myFixedFont.pointSize() + 3);
return myFixedFont;
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
}
}

View file

@ -62,7 +62,6 @@ MainWindow::MainWindow()
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
marketplace_->clear();
setSaleModel();
updateStatLabel();
});
ui_.sellerNoEdit->installEventFilter(this);
@ -140,8 +139,6 @@ MainWindow::MainWindow()
readGeometry();
setWindowIcon(QIcon(":/misc/kima2.ico"));
updateStatLabel();
}
void MainWindow::onActionEditSellerTriggered()
@ -162,7 +159,6 @@ void MainWindow::onActionEditSellerTriggered()
}
setSaleModel();
updateStatLabel();
}
void MainWindow::setSaleModel()
@ -193,7 +189,6 @@ void MainWindow::onPaidButtonTriggered()
ui_.drawbackContainerWidget->setEnabled(false);
ui_.sellerNoEdit->setFocus();
statusBar()->showMessage("Verkaufsvorgang erfolgreich durchgeführt.", STATUSBAR_TIMEOUT);
updateStatLabel();
}
}
@ -260,15 +255,11 @@ void MainWindow::checkSellerNo(bool ctrlPressed)
auto seller = marketplace_->findSellerWithSellerNo(sellerNo);
if (seller) {
PriceDialog priceDialog(this);
if(sellerNo == 0) {
priceDialog.setForceDesc(true);
}
auto dialogResult = priceDialog.exec();
if (dialogResult == QDialog::Accepted) {
int price = priceDialog.getPrice();
std::string desc = priceDialog.getDescription();
dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price, desc);
ui_.basketView->resizeColumnToContents(1);
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
}
}
@ -331,9 +322,6 @@ void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked)
for (auto iter = indexes.constEnd() - 1; iter >= indexes.constBegin(); --iter) {
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)
@ -357,9 +345,6 @@ void MainWindow::onCancelSaleButtonClicked([[maybe_unused]] bool checked)
for (auto iter = indexes.constEnd() - 1; iter >= indexes.constBegin(); --iter) {
ui_.salesView->model()->removeRow(iter->row(), iter->parent());
}
ui_.salesView->collapseAll();
updateStatLabel();
}
void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
@ -404,9 +389,6 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
return;
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); }
@ -449,7 +431,6 @@ void MainWindow::onImportSellerExcelActionTriggered()
fs::path filePath(filename.toStdWString());
ExcelReader::readSellersFromFile(filePath, marketplace_.get());
updateStatLabel();
}
void MainWindow::onImportSellerJsonActionTriggered()
@ -471,7 +452,6 @@ void MainWindow::onImportSellerJsonActionTriggered()
fs::path filePath(filename.toStdWString());
JsonUtil::importSellers(filePath, marketplace_.get());
updateStatLabel();
}
void MainWindow::onExportSellerJsonActionTriggered()
@ -491,10 +471,8 @@ void MainWindow::onExportSalesJsonActionTriggered()
{
QSettings settings;
auto filename = QFileDialog::getSaveFileName(
this, "Umsätze/Transaktionen exportieren",
QString("kima2_umsaetze_kasse") + settings.value("global/cashPointNo").toString() + ".json",
"JSON Dateien (*.json)");
auto filename = QFileDialog::getSaveFileName(this, "Umsätze/Transaktionen exportieren",
QString(), "JSON Dateien (*.json)");
if (filename.isEmpty())
return;
@ -528,7 +506,6 @@ void MainWindow::onImportSalesJsonActionTriggered()
marketplace_->loadFromDb();
}
setSaleModel();
updateStatLabel();
}
void MainWindow::writeGeometry()
@ -556,14 +533,3 @@ void MainWindow::closeEvent(QCloseEvent* event)
writeGeometry();
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());
}

View file

@ -47,7 +47,6 @@ class MainWindow : public QMainWindow
void setSaleModel();
void writeGeometry();
void readGeometry();
void updateStatLabel();
Ui::MainWindow ui_;
std::unique_ptr<Marketplace> marketplace_;

View file

@ -92,16 +92,7 @@
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -175,7 +166,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Stornieren</string>
<string>Stornieren</string>
</property>
</widget>
</item>
@ -185,7 +176,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Alles stornieren</string>
<string>Alles stornieren</string>
</property>
</widget>
</item>
@ -340,37 +331,6 @@ drucken</string>
</property>
</spacer>
</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>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
@ -419,7 +379,7 @@ drucken</string>
<x>0</x>
<y>0</y>
<width>817</width>
<height>24</height>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menu_Datei">
@ -473,7 +433,8 @@ drucken</string>
<action name="actionQuit">
<property name="icon">
<iconset theme="application-exit">
<normaloff>.</normaloff>.</iconset>
<normaloff/>
</iconset>
</property>
<property name="text">
<string>&amp;Beenden</string>

View file

@ -4,9 +4,8 @@
#include <QMessageBox>
PriceDialog::PriceDialog(QWidget* parent, bool forceDesc, Qt::WindowFlags f) : QDialog(parent, f)
PriceDialog::PriceDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
{
forceDesc_ = forceDesc;
ui_.setupUi(this);
ui_.priceSpinBox->setFocus();
}
@ -22,18 +21,7 @@ void PriceDialog::accept()
"Es sind nur 0,50 Cent-Schritte erlaubt.", QMessageBox::StandardButton::Ok,
this)
.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 {
QDialog::accept();
}
}
void PriceDialog::setForceDesc(bool force)
{
forceDesc_ = force;
}

View file

@ -10,17 +10,15 @@ class PriceDialog : public QDialog
Q_OBJECT
public:
PriceDialog(QWidget* parent = nullptr, bool forceDesc = false,
PriceDialog(QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
int getPrice() const;
std::string getDescription() const;
void setForceDesc(bool force);
private:
void on_model_duplicateSellerNo(const QString& message);
virtual void accept() override;
Ui::PriceDialog ui_;
bool forceDesc_;
};
#endif

View file

@ -161,10 +161,9 @@ void ReportDialog::onPrintReportButtonClicked()
(static_cast<double>(numArticlesSold) / static_cast<double>(numArticlesOffered)) * 100;
content += QString("Registrierte Verkäufer: %1\n").arg(sellers.size() - 1, 6);
content += QString("Angelieferte Artikel: %1\n").arg(numArticlesOffered, 6);
content += QString("Verkaufte Artikel: %1 (%L2 %)\n")
content += QString("Verkaufte Artikel: %1 (%L2 %)\n\n")
.arg(numArticlesSold, 6)
.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("Ausgezahlt: %1\n")

View file

@ -108,7 +108,7 @@ QVariant SaleModel::data(const QModelIndex& index, int role) const
Article* article = static_cast<Article*>(index.internalPointer());
switch (index.column()) {
case 0:
return (std::string("Verk. ") + std::to_string(article->getSeller()->getSellerNo()) + " (" + article->getCompleteArticleNo() + ")").c_str();
return article->getCompleteArticleNo().c_str();
case 1:
return article->getPriceAsString().c_str();
case 2:
@ -146,7 +146,7 @@ QVariant SaleModel::headerData(int section, Qt::Orientation orientation, int rol
if (orientation == Qt::Horizontal) {
switch (section) {
case 0:
return "Zeit / Verk.Nr. (Art.Nr)";
return "Zeit / Art.Nr.";
case 1:
return "Preis";
default:

View file

@ -46,8 +46,7 @@ PosPrinter::PosPrinter(const PrinterDevice& printerDevice) : printerDevice_(prin
if (printerDevice_.idVendor == 0) {
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;
printerEndpoint_ = std::get<2>(supported);
break;
@ -162,8 +161,8 @@ void PosPrinter::printSaleReceipt(Sale* sale)
commandStream << sale->getTimestampFormatted() << "\n\n";
commandStream << Command::LEFT_ALIGN;
for (const auto& article : sale->getArticles()) {
commandStream << "Verk.Nr. " << article->getSeller()->getSellerNoAsString()
<< "........... " << article->getPriceAsString() << "\n";
commandStream << "Art. " << article->getCompleteArticleNo() << "........... "
<< article->getPriceAsString() << "\n";
}
commandStream << "\nGesamt................. " << sale->sumAsString() << "\n";
commandStream << Command::CENTERING;