# Conflicts:
#	shop/receiptsaveform.cpp
#	shop/shopform.cpp
print
Josef Rokos 8 years ago
commit abed951e1f

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="cs_CZ">
<context>
<name>AddressbookForm</name>
<message>
<location filename="../addressbookform.ui" line="14"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="../addressbookform.ui" line="20"/>
<source>Title</source>
<translation>Titul</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="30"/>
<source>First Name</source>
<translation>Křestní jméno</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="62"/>
<source>Last Name</source>
<translation>Příjmení</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="69"/>
<source>Day of Birth</source>
<translation>Datum narození</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="76"/>
<source>ID Card Number</source>
<translation>Číslo dokladu totožnosti</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="83"/>
<source>City</source>
<translation>Město</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="90"/>
<source>ZTP</source>
<translation>ZTP</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="97"/>
<source>Street</source>
<translation>Ulice</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="107"/>
<source>House Number</source>
<translation>Číslo popisné</translation>
</message>
<message>
<location filename="../addressbookform.ui" line="114"/>
<source>ZIP</source>
<translation>PSČ</translation>
</message>
</context>
</TS>

@ -20,7 +20,7 @@
<message> <message>
<location filename="../mainwindow.ui" line="14"/> <location filename="../mainwindow.ui" line="14"/>
<source>MainWindow</source> <source>MainWindow</source>
<translation>Nastaveni</translation> <translation type="unfinished">Prodejna</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.ui" line="64"/> <location filename="../mainwindow.ui" line="64"/>

@ -3,6 +3,7 @@
#include "commodityform.h" #include "commodityform.h"
#include "commoditygrid.h" #include "commoditygrid.h"
#include "commoditysettingsform.h" #include "commoditysettingsform.h"
#include "commodityservice.h"
Commodity::Commodity() Commodity::Commodity()
{ {
@ -13,7 +14,7 @@ void Commodity::initServiceUi()
CommodityGrid *grid = new CommodityGrid(); CommodityGrid *grid = new CommodityGrid();
CommodityForm *form = new CommodityForm(); CommodityForm *form = new CommodityForm();
m_service = new Service<CommodityData>; m_service = new CommodityService();
m_ui = grid; m_ui = grid;
((CommodityGrid *) m_ui)->setForm(form); ((CommodityGrid *) m_ui)->setForm(form);
m_settingsUi = new CommoditySettingsForm(); m_settingsUi = new CommoditySettingsForm();

@ -20,7 +20,8 @@ SOURCES += commodity.cpp \
commoditytablemodel.cpp \ commoditytablemodel.cpp \
commodityform.cpp \ commodityform.cpp \
commoditygrid.cpp \ commoditygrid.cpp \
commoditysettingsform.cpp commoditysettingsform.cpp \
commodityservice.cpp
HEADERS += commodity.h\ HEADERS += commodity.h\
commodity_global.h \ commodity_global.h \
@ -30,7 +31,8 @@ HEADERS += commodity.h\
commoditytablemodel.h \ commoditytablemodel.h \
commodityform.h \ commodityform.h \
commoditygrid.h \ commoditygrid.h \
commoditysettingsform.h commoditysettingsform.h \
commodityservice.h
unix { unix {
target.path = /usr/lib target.path = /usr/lib
@ -53,6 +55,7 @@ DESTDIR = ../plugins
ODB_FILES = commodity/data/commodity-data.h ODB_FILES = commodity/data/commodity-data.h
H_DIR = $$PWD/data/*.h H_DIR = $$PWD/data/*.h
ODB_OTHER_INCLUDES = -I $$PWD/../shop
include(../odb.pri) include(../odb.pri)
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
@ -73,3 +76,10 @@ FORMS += \
RESOURCES += \ RESOURCES += \
commodityrc.qrc commodityrc.qrc
TRANSLATIONS = translations/commodity_cs_CZ.ts TRANSLATIONS = translations/commodity_cs_CZ.ts
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lshop
INCLUDEPATH += $$PWD/../shop
DEPENDPATH += $$PWD/../shop

@ -0,0 +1,31 @@
#include "commodityservice.h"
#include "commodity-odb.hxx"
CommodityService::CommodityService()
{
}
QList<QSharedPointer<ShopItem> > CommodityService::shopItems()
{
QList<QSharedPointer<ShopItem> > ret;
foreach (QSharedPointer<CommodityData> data, all()) {
ret.append(qSharedPointerDynamicCast<ShopItem, CommodityData>(data));
}
return ret;
}
void CommodityService::addedToVoucher(int itemId, int countAdded)
{
QSharedPointer<CommodityData> commodity = loadById(itemId);
if (!commodity.isNull())
{
commodity->setCount(commodity->count() - countAdded);
}
update(commodity);
}

@ -0,0 +1,19 @@
#ifndef COMMODITYSERVICE_H
#define COMMODITYSERVICE_H
#include <service.h>
#include <isellableservice.h>
#include "data/commodity-data.h"
class CommodityService : public Service<CommodityData>, public ISellableService
{
public:
CommodityService();
// ISellableService interface
public:
QList<QSharedPointer<ShopItem> > shopItems() override;
void addedToVoucher(int itemId, int countAdded) override;
};
#endif // COMMODITYSERVICE_H

@ -2,13 +2,13 @@
#include <define.h> #include <define.h>
CommodityData::CommodityData(QObject *parent) CommodityData::CommodityData(QObject *parent)
:QObject(parent) :ShopItem(parent)
{ {
m_count = 0; m_count = 0;
m_price = 0; m_price = 0;
m_vat = Enums::NONE; m_vat = Enums::NONE;
} }
int CommodityData::id() const int CommodityData::id()
{ {
return m_id; return m_id;
} }
@ -17,7 +17,7 @@ void CommodityData::setId(int id)
{ {
m_id = id; m_id = id;
} }
QString CommodityData::name() const QString CommodityData::name()
{ {
return m_name; return m_name;
} }
@ -83,6 +83,21 @@ void CommodityData::setCount(int count)
m_count = count; m_count = count;
} }
QDecDouble CommodityData::unitPrice()
{
return price();
}
Enums::VatType CommodityData::vatType()
{
return vat();
}
QString CommodityData::pluginId()
{
return "COMMODITY";
}

@ -5,17 +5,18 @@
#include <QString> #include <QString>
#include <odb/core.hxx> #include <odb/core.hxx>
#include "commoditytypedata.h" #include "commoditytypedata.h"
#include <shopitem.h>
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <QSharedDataPointer> #include <QSharedDataPointer>
#include <enums.h> #include <enums.h>
#pragma db object #pragma db object
class CommodityData : public QObject class CommodityData : public ShopItem
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString shortName READ shortName WRITE setShortName) Q_PROPERTY(QString shortName READ shortName WRITE setShortName)
Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QSharedPointer<QObject> type READ type WRITE setType) Q_PROPERTY(QSharedPointer<QObject> type READ type WRITE setType)
Q_PROPERTY(QDecDouble price READ price WRITE setPrice) Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
Q_PROPERTY(Enums::VatType vat READ vat WRITE setVat) Q_PROPERTY(Enums::VatType vat READ vat WRITE setVat)
@ -24,10 +25,10 @@ class CommodityData : public QObject
public: public:
CommodityData(QObject *parent = 0); CommodityData(QObject *parent = 0);
int id() const; int id() override;
void setId(int id); void setId(int id);
QString name() const; QString name() override;
void setName(const QString &name); void setName(const QString &name);
QString shortName() const; QString shortName() const;
@ -59,6 +60,12 @@ private:
int m_price; int m_price;
Enums::VatType m_vat; Enums::VatType m_vat;
int m_count; int m_count;
// IShopItem interface
public:
QDecDouble unitPrice() override;
Enums::VatType vatType() override;
QString pluginId() override;
}; };
#endif // COMMODITYDATA_H #endif // COMMODITYDATA_H

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="cs_CZ">
<context>
<name>CommodityForm</name>
<message>
<location filename="../commodityform.ui" line="14"/>
<source>Form</source>
<translation>Zboží</translation>
</message>
<message>
<location filename="../commodityform.ui" line="20"/>
<source>Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../commodityform.ui" line="30"/>
<source>Short Name</source>
<translation>Zobrazit na účtence</translation>
</message>
<message>
<location filename="../commodityform.ui" line="40"/>
<source>Code</source>
<translation>Kód</translation>
</message>
<message>
<location filename="../commodityform.ui" line="50"/>
<source>Type</source>
<translation>Druh</translation>
</message>
<message>
<location filename="../commodityform.ui" line="57"/>
<source>Price</source>
<translation>Cena</translation>
</message>
<message>
<location filename="../commodityform.ui" line="64"/>
<source>Vat</source>
<translation>DPH</translation>
</message>
<message>
<location filename="../commodityform.ui" line="71"/>
<source>Count</source>
<translation>Počet</translation>
</message>
<message>
<location filename="../commodityform.cpp" line="18"/>
<source>None</source>
<translation>Žádná</translation>
</message>
<message>
<location filename="../commodityform.cpp" line="19"/>
<source>High</source>
<translation>Vysoká</translation>
</message>
<message>
<location filename="../commodityform.cpp" line="20"/>
<source>First Lower</source>
<translation>První snížená</translation>
</message>
<message>
<location filename="../commodityform.cpp" line="21"/>
<source>Second Lower</source>
<translation>Druhá snížená</translation>
</message>
</context>
<context>
<name>CommoditySettingsForm</name>
<message>
<location filename="../commoditysettingsform.ui" line="14"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="../commoditysettingsform.ui" line="26"/>
<source>+</source>
<translation>+</translation>
</message>
<message>
<location filename="../commoditysettingsform.ui" line="37"/>
<source>-</source>
<translation>-</translation>
</message>
</context>
</TS>

@ -24,6 +24,7 @@ public:
:ITableModel(parent) :ITableModel(parent)
{ {
filtered = false; filtered = false;
m_checkboxSelect = false;
} }
virtual ~AutoTableModel() {} virtual ~AutoTableModel() {}
@ -50,6 +51,21 @@ public:
QVariant data(const QModelIndex &index, int role) const QVariant data(const QModelIndex &index, int role) const
{ {
if (index.column() == 0 && m_checkboxSelect)
{
if (role == Qt::CheckStateRole)
{
if (m_selectedRows.contains(index.row()))
{
return Qt::Checked;
}
else
{
return Qt::Unchecked;
}
}
}
QSharedPointer<T> entity = m_list.at(index.row()); QSharedPointer<T> entity = m_list.at(index.row());
QObject *rawEntity = (QObject*)entity.data(); QObject *rawEntity = (QObject*)entity.data();
@ -189,6 +205,21 @@ public:
m_translations = translations; m_translations = translations;
} }
QList<int> selectedRows() const
{
return m_selectedRows;
}
QList<QSharedPointer<T> > selectedItems()
{
QList<QSharedPointer<T> > ret;
foreach (int row, m_selectedRows) {
ret.append(m_list[row]);
}
return ret;
}
protected: protected:
void handleFilter(const QString &filter) override void handleFilter(const QString &filter) override
{ {
@ -220,10 +251,10 @@ protected:
private: private:
QList<QSharedPointer<T> > m_list; QList<QSharedPointer<T> > m_list;
QList<QSharedPointer<T> > m_fullList; QList<QSharedPointer<T> > m_fullList;
QList<int> m_selectedRows;
QMap<QString, QString> m_translations; QMap<QString, QString> m_translations;
bool filtered; bool filtered;
// QAbstractItemModel interface // QAbstractItemModel interface
public: public:
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
@ -236,10 +267,21 @@ public:
rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), value); rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), value);
} }
if (role == Qt::CheckStateRole)
{
if (m_selectedRows.contains(index.row()))
{
m_selectedRows.removeOne(index.row());
}
else
{
m_selectedRows.append(index.row());
}
}
emit editCompleted(); emit editCompleted();
return true; return true;
} }
}; };
#endif // ODBTABLEMODEL_H #endif // ODBTABLEMODEL_H

@ -65,6 +65,10 @@ void Context::loadPlugins()
m_plugins.append(plugin); m_plugins.append(plugin);
} }
} }
else
{
qDebug() << pluginLoader.errorString();
}
} }
QString dbPath = m_settings->value("db/path", "").toString(); QString dbPath = m_settings->value("db/path", "").toString();

@ -3,7 +3,17 @@
ITableModel::ITableModel(QObject *parent) ITableModel::ITableModel(QObject *parent)
:QAbstractTableModel(parent) :QAbstractTableModel(parent)
{ {
m_checkboxSelect = false;
}
bool ITableModel::checkboxSelect() const
{
return m_checkboxSelect;
}
void ITableModel::setCheckboxSelect(bool checkboxSelect)
{
m_checkboxSelect = checkboxSelect;
} }
void ITableModel::filter(const QString &filter) void ITableModel::filter(const QString &filter)
@ -18,12 +28,17 @@ void ITableModel::restore()
Qt::ItemFlags ITableModel::flags(const QModelIndex &index) const Qt::ItemFlags ITableModel::flags(const QModelIndex &index) const
{ {
if (index.column() == 0 && m_checkboxSelect)
{
return Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
}
if (m_editableCols.contains(index.column())) if (m_editableCols.contains(index.column()))
{ {
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
} }
return QAbstractTableModel::flags(index); return QAbstractTableModel::flags(index) | Qt::ItemIsDragEnabled;
} }
void ITableModel::setEditableCols(const QList<int> cols) void ITableModel::setEditableCols(const QList<int> cols)

@ -16,6 +16,7 @@ public:
protected: protected:
virtual void handleFilter(const QString &filter) = 0; virtual void handleFilter(const QString &filter) = 0;
virtual void handleRestore() = 0; virtual void handleRestore() = 0;
bool m_checkboxSelect;
public slots: public slots:
void filter(const QString &filter); void filter(const QString &filter);
@ -29,6 +30,9 @@ public:
virtual Qt::ItemFlags flags(const QModelIndex &index) const override; virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
void setEditableCols(const QList<int> cols); void setEditableCols(const QList<int> cols);
bool checkboxSelect() const;
void setCheckboxSelect(bool checkboxSelect);
private: private:
QList<int> m_editableCols; QList<int> m_editableCols;
}; };

@ -126,86 +126,132 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="20"/> <location filename="../settings/globalsettingsform.ui" line="33"/>
<source>Base settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="121"/>
<source>Company info</source> <source>Company info</source>
<translation>Informace o společnosti</translation> <translation>Informace o společnosti</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="29"/> <location filename="../settings/globalsettingsform.ui" line="130"/>
<source>IC</source> <source>IC</source>
<translation>IČO</translation> <translation>IČO</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="39"/> <location filename="../settings/globalsettingsform.ui" line="140"/>
<source>VAT number</source> <source>VAT number</source>
<translation>DIČ</translation> <translation>DIČ</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="49"/> <location filename="../settings/globalsettingsform.ui" line="150"/>
<source>VAT payer</source> <source>VAT payer</source>
<translation>Plátce DPH</translation> <translation>Plátce DPH</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="62"/> <location filename="../settings/globalsettingsform.ui" line="163"/>
<source>VAT rates</source> <source>VAT rates</source>
<translation>Sazby DPH</translation> <translation>Sazby DPH</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="68"/> <location filename="../settings/globalsettingsform.ui" line="169"/>
<source>High</source> <source>High</source>
<translation>Vysoká</translation> <translation>Vysoká</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="82"/> <location filename="../settings/globalsettingsform.ui" line="183"/>
<source>First lower</source> <source>First lower</source>
<translation>První snížená</translation> <translation>První snížená</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="96"/> <location filename="../settings/globalsettingsform.ui" line="197"/>
<source>Second lower</source> <source>Second lower</source>
<translation>Druhá snížená</translation> <translation>Druhá snížená</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="116"/> <location filename="../settings/globalsettingsform.ui" line="218"/>
<location filename="../settings/globalsettingsform.ui" line="279"/>
<source>Number series</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="247"/>
<source>Edit name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="258"/>
<source>Season</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="265"/>
<source>Create new</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="39"/>
<source>Contact</source> <source>Contact</source>
<translation>Kontaktní údaje</translation> <translation>Kontaktní údaje</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="122"/> <location filename="../settings/globalsettingsform.ui" line="45"/>
<source>Firm Name</source> <source>Firm Name</source>
<translation>Název společnosti</translation> <translation>Název společnosti</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="132"/> <location filename="../settings/globalsettingsform.ui" line="55"/>
<source>Street</source> <source>Street</source>
<translation>Ulice</translation> <translation>Ulice</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="142"/> <location filename="../settings/globalsettingsform.ui" line="65"/>
<source>House Number</source> <source>House Number</source>
<translation>Číslo popisné</translation> <translation>Číslo popisné</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="152"/> <location filename="../settings/globalsettingsform.ui" line="75"/>
<source>City</source> <source>City</source>
<translation>Město</translation> <translation>Město</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="162"/> <location filename="../settings/globalsettingsform.ui" line="85"/>
<source>ZIP code</source> <source>ZIP code</source>
<translation>PSČ</translation> <translation>PSČ</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="175"/> <location filename="../settings/globalsettingsform.ui" line="98"/>
<location filename="../settings/globalsettingsform.ui" line="181"/> <location filename="../settings/globalsettingsform.ui" line="104"/>
<source>Logo</source> <source>Logo</source>
<translation>Logo</translation> <translation>Logo</translation>
</message> </message>
<message> <message>
<location filename="../settings/globalsettingsform.ui" line="188"/> <location filename="../settings/globalsettingsform.ui" line="111"/>
<source>Select file</source> <source>Select file</source>
<translation>Vyber soubor</translation> <translation>Vyber soubor</translation>
</message> </message>
<message>
<location filename="../settings/globalsettingsform.cpp" line="77"/>
<source>Switch season</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.cpp" line="77"/>
<source>Realy switch active season?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.cpp" line="138"/>
<source>New season</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.cpp" line="138"/>
<source>Realy create new season and switch to it?</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>GridForm</name> <name>GridForm</name>
@ -314,6 +360,19 @@
<translation>Název filtru</translation> <translation>Název filtru</translation>
</message> </message>
</context> </context>
<context>
<name>SeasonNameDialog</name>
<message>
<location filename="../settings/seasonnamedialog.ui" line="14"/>
<source>Season</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/seasonnamedialog.ui" line="23"/>
<source>Season name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>SettingsForm</name> <name>SettingsForm</name>
<message> <message>

@ -46,7 +46,7 @@ ODB_FLAGS += -I $$PWD/core
ODB_FLAGS += -I $$PWD/qdecimal/src ODB_FLAGS += -I $$PWD/qdecimal/src
ODB_FLAGS += -I $$PWD/qdecimal/decnumber ODB_FLAGS += -I $$PWD/qdecimal/decnumber
ODB_FLAGS += $$ODB_OTHER_INCLUDES ODB_FLAGS += $$ODB_OTHER_INCLUDES
ODB_FLAGS += -D __PIC__ ODB_FLAGS += -x -std=c++11 -x -fPIC
win32 { win32 {
ODB_FLAGS += -I d:/prac/odb/libodb-2.4.0 ODB_FLAGS += -I d:/prac/odb/libodb-2.4.0

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="cs_CZ">
<context>
<name>AccServiceForm</name>
<message>
<location filename="../accserviceform.ui" line="14"/>
<source>Form</source>
<translation>Služba</translation>
</message>
<message>
<location filename="../accserviceform.ui" line="20"/>
<source>Service Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../accserviceform.ui" line="30"/>
<source>Price</source>
<translation>Cena</translation>
</message>
<message>
<location filename="../accserviceform.ui" line="37"/>
<source>Service Type</source>
<translation>Druh</translation>
</message>
<message>
<location filename="../accserviceform.ui" line="47"/>
<source>Sale Possible</source>
<translation>Umožnit slevu</translation>
</message>
<message>
<location filename="../accserviceform.ui" line="54"/>
<source>Active</source>
<translation>Aktivní</translation>
</message>
<message>
<location filename="../accserviceform.ui" line="64"/>
<source>ServiceCode</source>
<translation>Kód</translation>
</message>
<message>
<location filename="../accserviceform.ui" line="74"/>
<source>Vat Type</source>
<translation>Sazba DPH</translation>
</message>
<message>
<location filename="../accserviceform.cpp" line="18"/>
<source>Car</source>
<translation>Vozidlo</translation>
</message>
<message>
<location filename="../accserviceform.cpp" line="18"/>
<source>Tent</source>
<translation>Stan</translation>
</message>
<message>
<location filename="../accserviceform.cpp" line="18"/>
<source>OTHER</source>
<translation>Ostatní</translation>
</message>
<message>
<location filename="../accserviceform.cpp" line="21"/>
<source>None</source>
<translation>Žádná</translation>
</message>
<message>
<location filename="../accserviceform.cpp" line="22"/>
<source>High</source>
<translation>Vysoká</translation>
</message>
<message>
<location filename="../accserviceform.cpp" line="23"/>
<source>First Lower</source>
<translation>První snížená</translation>
</message>
<message>
<location filename="../accserviceform.cpp" line="24"/>
<source>Second Lower</source>
<translation>Druhá snížená</translation>
</message>
</context>
</TS>

@ -0,0 +1,69 @@
#include "favorititem.h"
#include <define.h>
FavoritItem::FavoritItem()
{
m_id = 0;
m_vatType = Enums::NONE;
m_unitPrice = 0;
}
int FavoritItem::id()
{
return m_id;
}
void FavoritItem::setId(int id)
{
m_id = id;
}
QString FavoritItem::name()
{
return m_name;
}
void FavoritItem::setName(const QString &name)
{
m_name = name;
}
QDecDouble FavoritItem::unitPrice()
{
return TO_DEC(m_unitPrice);
}
void FavoritItem::setUnitPrice(QDecDouble unitPrice)
{
m_unitPrice = FROM_DEC(unitPrice);
}
Enums::VatType FavoritItem::vatType()
{
return m_vatType;
}
void FavoritItem::setVatType(const Enums::VatType &vatType)
{
m_vatType = vatType;
}
QString FavoritItem::pluginId()
{
return m_pluginId;
}
void FavoritItem::setPluginId(const QString &pluginId)
{
m_pluginId = pluginId;
}
QString FavoritItem::favButtonName() const
{
return m_favButtonName;
}
void FavoritItem::setFavButtonName(const QString &favButtonName)
{
m_favButtonName = favButtonName;
}

@ -0,0 +1,62 @@
#ifndef FAVORITITEM_H
#define FAVORITITEM_H
#include <QObject>
#include <QSharedPointer>
#include <QString>
#include <QDecDouble.hh>
#include <enums.h>
#include <ishopitem.h>
#include <odb/core.hxx>
class IShopItem;
#pragma db object
class FavoritItem : public QObject, public IShopItem
{
Q_OBJECT
Q_PROPERTY(int id READ id WRITE setId)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType)
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
Q_PROPERTY(QString favButtonName READ favButtonName WRITE setFavButtonName)
public:
FavoritItem();
// IShopItem interface
public:
int id() override;
void setId(int id);
QString name() override;
void setName(const QString &name);
QDecDouble unitPrice() override;
void setUnitPrice(QDecDouble unitPrice);
Enums::VatType vatType() override;
void setVatType(const Enums::VatType &vatType);
QString pluginId() override;
void setPluginId(const QString &pluginId);
QString favButtonName() const;
void setFavButtonName(const QString &favButtonName);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_name;
int m_unitPrice;
Enums::VatType m_vatType;
QString m_pluginId;
QString m_favButtonName;
};
typedef QSharedPointer<FavoritItem> FavoritItemPtr;
#endif // FAVORITITEM_H

@ -3,5 +3,6 @@
#include "voucher.h" #include "voucher.h"
#include "voucheritem.h" #include "voucheritem.h"
#include "favorititem.h"
#endif // SHOPDATA_H #endif // SHOPDATA_H

@ -16,6 +16,7 @@ Voucher::Voucher(QObject *parent) : QObject(parent)
m_totalPriceVatFirstLower = 0; m_totalPriceVatFirstLower = 0;
m_totalPriceVatSecondLower = 0; m_totalPriceVatSecondLower = 0;
m_totalPrice = 0; m_totalPrice = 0;
m_eetStatus = EET_FOR_SEND;
} }
QString Voucher::name() const QString Voucher::name() const
@ -230,6 +231,56 @@ void Voucher::setPayDateTime(const QDateTime &payDateTime)
m_payDateTime = payDateTime; m_payDateTime = payDateTime;
} }
Voucher::EetStatus Voucher::eetStatus() const
{
return m_eetStatus;
}
void Voucher::setEetStatus(const Voucher::EetStatus &eetStatus)
{
m_eetStatus = eetStatus;
}
QDateTime Voucher::eetSendDateTime() const
{
return m_eetSendDateTime;
}
void Voucher::setEetSendDateTime(const QDateTime &eetSendDateTime)
{
m_eetSendDateTime = eetSendDateTime;
}
QString Voucher::eetPkp() const
{
return m_eetPkp;
}
void Voucher::setEetPkp(const QString &eetPkp)
{
m_eetPkp = eetPkp;
}
QString Voucher::eetBkp() const
{
return m_eetBkp;
}
void Voucher::setEetBkp(const QString &eetBkp)
{
m_eetBkp = eetBkp;
}
QString Voucher::eetFik() const
{
return m_eetFik;
}
void Voucher::setEetFik(const QString &eetFik)
{
m_eetFik = eetFik;
}
int Voucher::id() const int Voucher::id() const
{ {
return m_id; return m_id;

@ -28,7 +28,13 @@ class Voucher : public QObject
Q_PROPERTY(QDecDouble priceVatFirstLower READ priceVatFirstLower WRITE setPriceVatFirstLower) Q_PROPERTY(QDecDouble priceVatFirstLower READ priceVatFirstLower WRITE setPriceVatFirstLower)
Q_PROPERTY(QDecDouble priceVatSecondLower READ priceVatSecondLower WRITE setPriceVatSecondLower) Q_PROPERTY(QDecDouble priceVatSecondLower READ priceVatSecondLower WRITE setPriceVatSecondLower)
Q_PROPERTY(QDecDouble totalPrice READ totalPrice WRITE setTotalPrice) Q_PROPERTY(QDecDouble totalPrice READ totalPrice WRITE setTotalPrice)
Q_PROPERTY(EetStatus eetStatus READ eetStatus WRITE setEetStatus)
Q_PROPERTY(QDateTime eetSendDateTime READ eetSendDateTime WRITE setEetSendDateTime)
Q_PROPERTY(QString eetBkp READ eetBkp WRITE setEetBkp)
Q_PROPERTY(QString eetPkp READ eetPkp WRITE setEetPkp)
Q_PROPERTY(QString eetFik READ eetFik WRITE setEetFik)
Q_ENUMS(VoucherStatus) Q_ENUMS(VoucherStatus)
Q_ENUMS(EetStatus)
Q_PROPERTY(VoucherStatus status READ status WRITE setStatus) Q_PROPERTY(VoucherStatus status READ status WRITE setStatus)
public: public:
@ -42,6 +48,14 @@ public:
PAID PAID
}; };
enum EetStatus
{
EET_FOR_SEND,
EET_NOT_ENTERING,
EET_SENT,
EET_ERROR
};
int id() const; int id() const;
void setId(int id); void setId(int id);
@ -110,6 +124,21 @@ public:
QDateTime payDateTime() const; QDateTime payDateTime() const;
void setPayDateTime(const QDateTime &payDateTime); void setPayDateTime(const QDateTime &payDateTime);
EetStatus eetStatus() const;
void setEetStatus(const EetStatus &eetStatus);
QDateTime eetSendDateTime() const;
void setEetSendDateTime(const QDateTime &eetSendDateTime);
QString eetPkp() const;
void setEetPkp(const QString &eetPkp);
QString eetBkp() const;
void setEetBkp(const QString &eetBkp);
QString eetFik() const;
void setEetFik(const QString &eetFik);
private: private:
friend class odb::access; friend class odb::access;
#pragma db id auto #pragma db id auto
@ -131,6 +160,11 @@ private:
int m_totalPriceVatFirstLower; int m_totalPriceVatFirstLower;
int m_totalPriceVatSecondLower; int m_totalPriceVatSecondLower;
int m_totalPrice; int m_totalPrice;
EetStatus m_eetStatus;
QDateTime m_eetSendDateTime;
QString m_eetPkp;
QString m_eetBkp;
QString m_eetFik;
#pragma db value_not_null inverse(m_voucher) #pragma db value_not_null inverse(m_voucher)
QOdbList<QSharedPointer<VoucherItem> > m_items; QOdbList<QSharedPointer<VoucherItem> > m_items;
VoucherStatus m_status; VoucherStatus m_status;

@ -39,8 +39,9 @@ int VoucherItem::count() const
void VoucherItem::setCount(int count) void VoucherItem::setCount(int count)
{ {
int oldCount = m_count;
m_count = count; m_count = count;
emit countChanged(); emit countChanged(oldCount);
} }
QDecDouble VoucherItem::unitPrice() const QDecDouble VoucherItem::unitPrice() const

@ -63,7 +63,7 @@ public:
void setVoucher(const QWeakPointer<Voucher> &voucher); void setVoucher(const QWeakPointer<Voucher> &voucher);
signals: signals:
void countChanged(); void countChanged(int oldCount);
private: private:
friend class odb::access; friend class odb::access;

@ -0,0 +1,19 @@
#include "eetbatchdialog.h"
#include "ui_eetbatchdialog.h"
EetBatchDialog::EetBatchDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::EetBatchDialog)
{
ui->setupUi(this);
}
EetBatchDialog::~EetBatchDialog()
{
delete ui;
}
void EetBatchDialog::addLog(const QString &log)
{
ui->logView->setPlainText(ui->logView->toPlainText() + log);
}

@ -0,0 +1,23 @@
#ifndef EETBATCHDIALOG_H
#define EETBATCHDIALOG_H
#include <QDialog>
namespace Ui {
class EetBatchDialog;
}
class EetBatchDialog : public QDialog
{
Q_OBJECT
public:
explicit EetBatchDialog(QWidget *parent = 0);
~EetBatchDialog();
void addLog(const QString &log);
private:
Ui::EetBatchDialog *ui;
};
#endif // EETBATCHDIALOG_H

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EetBatchDialog</class>
<widget class="QDialog" name="EetBatchDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>272</height>
</rect>
</property>
<property name="windowTitle">
<string>EET batch send</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="logView">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>EetBatchDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>EetBatchDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -0,0 +1,8 @@
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><style type="text/css"><![CDATA[
.str1 {stroke:#434242;stroke-width:7.5;stroke-linejoin:round}
.str0 {stroke:#434242;stroke-width:10;stroke-linejoin:round}
.fil0 {fill:#434242}
.fil1 {fill:#DDDEDE}
.fil2 {fill:#FFFFFF}
.fil3 {fill:url(#id0)}
]]></style><linearGradient gradientUnits="userSpaceOnUse" id="id0" x1="459.999" x2="39.999" y1="378.236" y2="378.236"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><g id="Layer_x0020_1"><polygon class="fil0 str0" points="40,316 460,316 400,220 100,220"/><rect class="fil1 str1" height="260" rx="20" ry="20" transform="matrix(0 .846 .846 0 140.002 62.309)" width="420"/><polygon class="fil2 str1" points="140,397 140,79 275,240"/><path class="fil2 str1" d="M322 418h21c9 0 17-8 17-17v-322c0-9-8-17-17-17h-21l-93 161c-9 13-9 21 0 34l93 161z"/><path class="fil3 str0" d="M40 316h130v39c0 8 7 15 15 15h130c8 0 15-7 15-15v-39h130v99c0 14-11 25-25 25h-370c-14 0-25-11-25-25v-99z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,5 @@
#include "isellableservice.h"
ISellableService::ISellableService()
{
}

@ -2,14 +2,17 @@
#define ISELLABLESERVICE_H #define ISELLABLESERVICE_H
#include "shop_global.h" #include "shop_global.h"
#include "ishopitem.h" #include "shopitem.h"
#include <QList> #include <QList>
#include <QSharedPointer> #include <QSharedPointer>
class SHOPSHARED_EXPORT ISellableService class SHOPSHARED_EXPORT ISellableService
{ {
public: public:
QList<QSharedPointer<IShopItem> > shopItems() = 0; ISellableService();
virtual QList<QSharedPointer<ShopItem> > shopItems() = 0;
virtual void addedToVoucher(int itemId, int countAdded) = 0;
}; };
#endif // ISELLABLESERVICE_H #endif // ISELLABLESERVICE_H

@ -5,6 +5,7 @@
#include "receiptgenerator.h" #include "receiptgenerator.h"
#include "shopservice.h" #include "shopservice.h"
#include "eetbatchdialog.h"
PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) : PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -14,10 +15,30 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
m_voucherModel = new AutoTableModel<Voucher>(this); m_voucherModel = new AutoTableModel<Voucher>(this);
m_itemModel = new AutoTableModel<VoucherItem>(this); m_itemModel = new AutoTableModel<VoucherItem>(this);
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
m_itemModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tableVouchers->setModel(m_voucherModel); ui->tableVouchers->setModel(m_voucherModel);
ui->tableItems->setModel(m_itemModel); ui->tableItems->setModel(m_itemModel);
ui->tableVouchers->setColumnHidden(5, true);
ui->tableVouchers->setColumnHidden(6, true);
ui->tableVouchers->setColumnHidden(7, true);
ui->tableVouchers->setColumnHidden(8, true);
ui->tableVouchers->setColumnHidden(9, true);
ui->tableVouchers->setColumnHidden(10, true);
ui->tableVouchers->setColumnHidden(12, true);
ui->tableVouchers->setColumnHidden(13, true);
ui->tableVouchers->setColumnHidden(14, true);
ui->tableVouchers->setColumnHidden(15, true);
ui->tableVouchers->setColumnHidden(16, true);
ui->tableVouchers->setColumnHidden(17, true);
ui->tableVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
ui->tableVouchers->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
ui->tableVouchers->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
ui->tableItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
ShopService srv; ShopService srv;
m_voucherModel->setData(srv.paiedVouchers()); m_voucherModel->setData(srv.paiedVouchers());
@ -27,6 +48,23 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
m_itemModel->setData(voucher->items()); m_itemModel->setData(voucher->items());
ui->total->setText(QString::number(voucher->totalPrice().toDouble(), 'f', 2)); ui->total->setText(QString::number(voucher->totalPrice().toDouble(), 'f', 2));
switch (voucher->eetStatus()) {
case Voucher::EET_NOT_ENTERING:
ui->lblEetStatus->setText(tr("not entering"));
break;
case Voucher::EET_FOR_SEND:
ui->lblEetStatus->setText(tr("for send"));
break;
case Voucher::EET_ERROR:
ui->lblEetStatus->setText(tr("error"));
break;
case Voucher::EET_SENT:
ui->lblEetStatus->setText(tr("sent"));
break;
default:
break;
}
ui->btnPrint->setEnabled(true); ui->btnPrint->setEnabled(true);
ui->btnSave->setEnabled(true); ui->btnSave->setEnabled(true);
}); });
@ -59,3 +97,36 @@ void PaydVouchersDialog::on_btnSave_clicked()
generator.save(); generator.save();
} }
} }
void PaydVouchersDialog::on_btnEetNotSen_clicked(bool checked)
{
ShopService srv;
if (checked)
{
m_voucherModel->setData(srv.vouchersForEet());
}
else
{
m_voucherModel->setData(srv.paiedVouchers());
}
m_itemModel->setData(QList<VoucherItemPtr>());
}
void PaydVouchersDialog::on_btnSendEet_clicked()
{
ShopService srv;
QList<VoucherPtr> vouchers = srv.vouchersForEet();
EetBatchDialog *dialog = new EetBatchDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
foreach (VoucherPtr vch, vouchers) {
QString msg;
bool sent = srv.processEet(vch, msg);
dialog->addLog(vch->numSer() + ": ");
dialog->addLog(sent ? "OK\n" : tr("Error"));
dialog->addLog((msg.isEmpty() && !sent) ? "\n" : ": " + msg);
}
}

@ -24,6 +24,10 @@ private slots:
void on_btnSave_clicked(); void on_btnSave_clicked();
void on_btnEetNotSen_clicked(bool checked);
void on_btnSendEet_clicked();
private: private:
Ui::PaydVouchersDialog *ui; Ui::PaydVouchersDialog *ui;

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>798</width> <width>900</width>
<height>514</height> <height>650</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -72,6 +72,49 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="btnEetNotSen">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/filter.svg</normaloff>:/icons/filter.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSendEet">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="shoprc.qrc">
<normaloff>:/icons/sendEet.svg</normaloff>:/icons/sendEet.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
@ -90,6 +133,12 @@
</item> </item>
<item> <item>
<widget class="QTableView" name="tableVouchers"> <widget class="QTableView" name="tableVouchers">
<property name="minimumSize">
<size>
<width>0</width>
<height>300</height>
</size>
</property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum> <enum>QAbstractItemView::SingleSelection</enum>
</property> </property>
@ -110,6 +159,39 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>EET:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblEetStatus">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="widget_2" native="true"> <widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
@ -167,6 +249,7 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="shoprc.qrc"/>
<include location="../core/rc.qrc"/> <include location="../core/rc.qrc"/>
</resources> </resources>
<connections/> <connections/>

@ -138,7 +138,13 @@ QByteArray ReceiptGenerator::generate()
out.append("\x1b\x21"); out.append("\x1b\x21");
out.append((char)0); out.append((char)0);
out.append("\x0a"); out.append("\x0a");
out.append("BKP:");
out.append("\x0a"); out.append("\x0a");
out.append(prepareString(m_voucher->eetBkp()));
out.append("\x0a");
out.append("FIK:");
out.append("\x0a");
out.append(prepareString(m_voucher->eetFik()));
out.append("\x0a"); out.append("\x0a");
out.append("\x0a"); out.append("\x0a");
out.append("\x0a"); out.append("\x0a");

@ -30,6 +30,7 @@ ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) :
ui->tabVouchers->setColumnWidth(4, 200); ui->tabVouchers->setColumnWidth(4, 200);
m_itemModel = new AutoTableModel<VoucherItem>(this); m_itemModel = new AutoTableModel<VoucherItem>(this);
m_itemModel->setCheckboxSelect(true);
ui->tabItems->setModel(m_itemModel); ui->tabItems->setModel(m_itemModel);
ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
@ -46,6 +47,16 @@ ReceiptLoadForm::~ReceiptLoadForm()
delete ui; delete ui;
} }
QList<VoucherItemPtr> ReceiptLoadForm::selectedItems()
{
return m_itemModel->selectedItems();
}
VoucherPtr ReceiptLoadForm::selectedVoucher()
{
return m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex());
}
void ReceiptLoadForm::on_lineEdit_textChanged(const QString &text) void ReceiptLoadForm::on_lineEdit_textChanged(const QString &text)
{ {
QSortFilterProxyModel proxy; QSortFilterProxyModel proxy;

@ -16,6 +16,8 @@ class ReceiptLoadForm : public QDialog
public: public:
explicit ReceiptLoadForm(QWidget *parent = 0); explicit ReceiptLoadForm(QWidget *parent = 0);
~ReceiptLoadForm(); ~ReceiptLoadForm();
QList<VoucherItemPtr> selectedItems();
VoucherPtr selectedVoucher();
private slots: private slots:
void on_lineEdit_textChanged(const QString &text); void on_lineEdit_textChanged(const QString &text);

@ -26,18 +26,16 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)))); m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))));
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations()); m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tabVouchers->setModel(m_voucherModel); ui->tabVouchers->setModel(m_voucherModel);
ui->tabVouchers->hideColumn(0); ui->tabVouchers->hideColumn(3);
ui->tabVouchers->hideColumn(1); ui->tabVouchers->hideColumn(4);
ui->tabVouchers->hideColumn(5); ui->tabVouchers->hideColumn(5);
ui->tabVouchers->hideColumn(6); ui->tabVouchers->hideColumn(6);
ui->tabVouchers->hideColumn(7); ui->tabVouchers->hideColumn(7);
ui->tabVouchers->hideColumn(8); ui->tabVouchers->hideColumn(8);
ui->tabVouchers->hideColumn(9);
ui->tabVouchers->hideColumn(10); ui->tabVouchers->hideColumn(10);
ui->tabVouchers->hideColumn(12); ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); ui->tabVouchers->setColumnWidth(0, 190);
ui->tabVouchers->setColumnWidth(3, 200); ui->tabVouchers->setColumnWidth(2, 200);
ui->tabVouchers->setColumnWidth(4, 200);
connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){ connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
@ -47,15 +45,9 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
}); });
m_binder.setData(voucher.data());
AddressBookService srvAdb; AddressBookService srvAdb;
QList<ComboData> comboData; m_binder.registerBinding(ui->contact, ComboData::createComboData(srvAdb.all()));
foreach (QSharedPointer<AddressbookData> adb, srvAdb.all()) {
comboData << ComboData(adb);
}
m_voucher = voucher;
m_binder.setData(m_voucher.data());
m_binder.registerBinding(ui->contact, comboData);
m_binder.registerBinding(ui->name); m_binder.registerBinding(ui->name);
m_binder.registerBinding(ui->description); m_binder.registerBinding(ui->description);
m_binder.bindToUi(); m_binder.bindToUi();
@ -74,11 +66,26 @@ ReceiptSaveForm::~ReceiptSaveForm()
delete ui; delete ui;
} }
VoucherPtr ReceiptSaveForm::selectedVoucher()
{
if (ui->tabVouchers->currentIndex().isValid())
{
return m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex());
}
return VoucherPtr();
}
bool ReceiptSaveForm::saveAsNew()
{
return m_saveAsNew;
}
void ReceiptSaveForm::on_lineEdit_textChanged(const QString &text) void ReceiptSaveForm::on_lineEdit_textChanged(const QString &text)
{ {
QSortFilterProxyModel proxy; QSortFilterProxyModel proxy;
proxy.setSourceModel(m_voucherModel); proxy.setSourceModel(m_voucherModel);
proxy.setFilterKeyColumn(2); proxy.setFilterKeyColumn(0);
proxy.setFilterFixedString(text); proxy.setFilterFixedString(text);
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0)); QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
@ -111,24 +118,6 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked)
void ReceiptSaveForm::accept() void ReceiptSaveForm::accept()
{ {
ShopService srv;
m_binder.bindToData(); m_binder.bindToData();
if (m_saveAsNew)
{
m_voucher->setStatus(Voucher::NOT_PAID);
srv.updateVoucher(m_voucher);
}
else
{
QSharedPointer<Voucher> voucher = m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex());
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
voucher->addItem(item);
}
srv.calculate(voucher);
srv.updateVoucher(voucher);
srv.erase(m_voucher);
}
QDialog::accept(); QDialog::accept();
} }

@ -18,6 +18,9 @@ public:
explicit ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *parent = 0); explicit ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *parent = 0);
~ReceiptSaveForm(); ~ReceiptSaveForm();
VoucherPtr selectedVoucher();
bool saveAsNew();
private slots: private slots:
void on_lineEdit_textChanged(const QString &text); void on_lineEdit_textChanged(const QString &text);
@ -28,7 +31,7 @@ private:
ObjectBinder m_binder; ObjectBinder m_binder;
AutoTableModel<Voucher> *m_voucherModel; AutoTableModel<Voucher> *m_voucherModel;
bool m_saveAsNew; bool m_saveAsNew;
QSharedPointer<Voucher> m_voucher; VoucherPtr m_voucher;
// QDialog interface // QDialog interface
public slots: public slots:

@ -0,0 +1,6 @@
#include "favoriteservice.h"
FavoriteService::FavoriteService()
{
}

@ -0,0 +1,13 @@
#ifndef FAVORITESERVICE_H
#define FAVORITESERVICE_H
#include <core.h>
#include "data/favorititem.h"
class FavoriteService : public Service<FavoritItem>
{
public:
FavoriteService();
};
#endif // FAVORITESERVICE_H

@ -4,6 +4,11 @@ ShopSettings::ShopSettings(QObject *parent) : QObject(parent)
{ {
m_codepage = ASCII; m_codepage = ASCII;
m_lettersPerLine = 48; m_lettersPerLine = 48;
m_eetActive = false;
m_eetMode = 1;
m_eetTest = 0;
m_eetPlayground = 0;
} }
QString ShopSettings::output() const QString ShopSettings::output() const
@ -45,3 +50,83 @@ void ShopSettings::setByMessage(const QString &byMessage)
{ {
m_byMessage = byMessage; m_byMessage = byMessage;
} }
bool ShopSettings::eetActive() const
{
return m_eetActive;
}
void ShopSettings::setEetActive(bool eetActive)
{
m_eetActive = eetActive;
}
QString ShopSettings::eetShopId() const
{
return m_eetShopId;
}
void ShopSettings::setEetShopId(const QString &eetShopId)
{
m_eetShopId = eetShopId;
}
QString ShopSettings::eetRegisterId() const
{
return m_eetRegisterId;
}
void ShopSettings::setEetRegisterId(const QString &eetRegisterId)
{
m_eetRegisterId = eetRegisterId;
}
int ShopSettings::eetMode() const
{
return m_eetMode;
}
void ShopSettings::setEetMode(int eetMode)
{
m_eetMode = eetMode;
}
QString ShopSettings::eetCertificate() const
{
return m_eetCertificate;
}
void ShopSettings::setEetCertificate(const QString &eetCertificate)
{
m_eetCertificate = eetCertificate;
}
QString ShopSettings::eetKeyPassword() const
{
return m_eetKeyPassword;
}
void ShopSettings::setEetKeyPassword(const QString &eetKeyPassword)
{
m_eetKeyPassword = eetKeyPassword;
}
bool ShopSettings::eetTest() const
{
return m_eetTest;
}
void ShopSettings::setEetTest(bool eetTest)
{
m_eetTest = eetTest;
}
bool ShopSettings::eetPlayground() const
{
return m_eetPlayground;
}
void ShopSettings::setEetPlayground(bool eetPlayground)
{
m_eetPlayground = eetPlayground;
}

@ -9,6 +9,15 @@ class ShopSettings : public QObject
Q_PROPERTY(int lettersPerLine READ lettersPerLine WRITE setLettersPerLine) Q_PROPERTY(int lettersPerLine READ lettersPerLine WRITE setLettersPerLine)
Q_PROPERTY(QString byMessage READ byMessage WRITE setByMessage) Q_PROPERTY(QString byMessage READ byMessage WRITE setByMessage)
Q_PROPERTY(bool eetActive READ eetActive WRITE setEetActive)
Q_PROPERTY(QString eetShopId READ eetShopId WRITE setEetShopId)
Q_PROPERTY(QString eetRegisterId READ eetRegisterId WRITE setEetRegisterId)
Q_PROPERTY(int eetMode READ eetMode WRITE setEetMode)
Q_PROPERTY(QString eetCertificate READ eetCertificate WRITE setEetCertificate)
Q_PROPERTY(QString eetKeyPassword READ eetKeyPassword WRITE setEetKeyPassword)
Q_PROPERTY(bool eetTest READ eetTest WRITE setEetTest)
Q_PROPERTY(bool eetPlayground READ eetPlayground WRITE setEetPlayground)
Q_OBJECT Q_OBJECT
public: public:
@ -31,11 +40,44 @@ public:
QString byMessage() const; QString byMessage() const;
void setByMessage(const QString &byMessage); void setByMessage(const QString &byMessage);
bool eetActive() const;
void setEetActive(bool eetActive);
QString eetShopId() const;
void setEetShopId(const QString &eetShopId);
QString eetRegisterId() const;
void setEetRegisterId(const QString &eetRegisterId);
int eetMode() const;
void setEetMode(int eetMode);
QString eetCertificate() const;
void setEetCertificate(const QString &eetCertificate);
QString eetKeyPassword() const;
void setEetKeyPassword(const QString &eetKeyPassword);
bool eetTest() const;
void setEetTest(bool eetTest);
bool eetPlayground() const;
void setEetPlayground(bool eetPlayground);
private: private:
QString m_output; QString m_output;
CODEPAGE m_codepage; CODEPAGE m_codepage;
int m_lettersPerLine; int m_lettersPerLine;
QString m_byMessage; QString m_byMessage;
bool m_eetActive;
QString m_eetShopId;
QString m_eetRegisterId;
int m_eetMode;
QString m_eetCertificate;
QString m_eetKeyPassword;
bool m_eetTest;
bool m_eetPlayground;
}; };
typedef QSharedPointer<ShopSettings> ShopSettingsPtr; typedef QSharedPointer<ShopSettings> ShopSettingsPtr;

@ -2,6 +2,9 @@
#include "ui_shopsettingsform.h" #include "ui_shopsettingsform.h"
#include <settingsservice.h> #include <settingsservice.h>
#include <combodata.h>
#include <QFileDialog>
#include "shopservice.h"
ShopSettingsForm::ShopSettingsForm(QWidget *parent) : ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
FormBinder<ShopSettings>(parent), FormBinder<ShopSettings>(parent),
@ -12,6 +15,19 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
registerBinding(ui->output); registerBinding(ui->output);
registerBinding(ui->lettersPerLine); registerBinding(ui->lettersPerLine);
registerBinding(ui->byMessage); registerBinding(ui->byMessage);
registerBinding(ui->eetActive);
registerBinding(ui->eetShopId);
registerBinding(ui->eetRegisterId);
QList<ComboData> listModes;
listModes << ComboData(0, tr("Simplifyed")) << ComboData(1, tr("Standard"));
registerBinding(ui->eetMode, listModes);
registerBinding(ui->eetCertificate);
registerBinding(ui->eetKeyPassword);
registerBinding(ui->eetTest);
registerBinding(ui->eetPlayground);
m_itemModel = new AutoTableModel<ShopItem>();
} }
ShopSettingsForm::~ShopSettingsForm() ShopSettingsForm::~ShopSettingsForm()
@ -24,6 +40,10 @@ void ShopSettingsForm::loadEntity()
SettingsService srv("SHOP"); SettingsService srv("SHOP");
ShopSettingsPtr settings = srv.loadSettings<ShopSettings>(); ShopSettingsPtr settings = srv.loadSettings<ShopSettings>();
setEntity(settings); setEntity(settings);
ShopService srvShop;
m_itemModel->setData(srvShop.allSellableItems());
ui->tableItems->setModel(m_itemModel);
} }
bool ShopSettingsForm::saveRecord() bool ShopSettingsForm::saveRecord()
@ -34,3 +54,13 @@ bool ShopSettingsForm::saveRecord()
return true; return true;
} }
void ShopSettingsForm::on_btnCertBrowse_clicked()
{
QString certFile = QFileDialog::getOpenFileName(this, "Certificate file", "", "P12 Files (*.p12)");
if (!certFile.isEmpty())
{
ui->eetCertificate->setText(certFile);
}
}

@ -4,6 +4,8 @@
#include <QWidget> #include <QWidget>
#include <formbinder.h> #include <formbinder.h>
#include "shopsettings.h" #include "shopsettings.h"
#include <core.h>
#include "shopitem.h"
namespace Ui { namespace Ui {
class ShopSettingsForm; class ShopSettingsForm;
@ -19,6 +21,7 @@ public:
private: private:
Ui::ShopSettingsForm *ui; Ui::ShopSettingsForm *ui;
AutoTableModel<ShopItem> *m_itemModel;
// IForm interface // IForm interface
public: public:
@ -26,6 +29,8 @@ public:
public slots: public slots:
bool saveRecord(); bool saveRecord();
private slots:
void on_btnCertBrowse_clicked();
}; };
#endif // SHOPSETTINGSFORM_H #endif // SHOPSETTINGSFORM_H

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>608</width> <width>645</width>
<height>450</height> <height>463</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,11 +15,193 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QTabWidget" name="tabWidget">
<property name="title"> <property name="currentIndex">
<string>Printer</string> <number>2</number>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <widget class="QWidget" name="tab">
<attribute name="title">
<string>Favorite buttons</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTableView" name="tableItems">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="3">
<widget class="QToolButton" name="toolButton_9">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QToolButton" name="toolButton_10">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="toolButton_3">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="toolButton_6">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="toolButton_4">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="toolButton">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="toolButton_8">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolButton_2">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="toolButton_5">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="toolButton_7">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Printer</string>
</attribute>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
@ -30,28 +212,144 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="output"/> <widget class="QLineEdit" name="output"/>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Letters per line</string> <string>Letters per line</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="QSpinBox" name="lettersPerLine"/> <widget class="QSpinBox" name="lettersPerLine"/>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Footer text</string> <string>Footer text</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="byMessage"/> <widget class="QLineEdit" name="byMessage"/>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>EET</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="eetActive">
<property name="title">
<string>Activate EET</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Shop ID</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="eetShopId"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Cash register ID</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="eetRegisterId"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>EET mode</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="eetMode"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Certificate file</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QWidget" name="widget_2" native="true">
<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">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="eetCertificate"/>
</item>
<item>
<widget class="QToolButton" name="btnCertBrowse">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Private key password</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="eetKeyPassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="eetTest">
<property name="text">
<string>Test mode</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="eetPlayground">
<property name="text">
<string>Communication with playground </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

@ -47,6 +47,11 @@ CREATE TABLE \"Voucher\" (
\"totalPriceVatSecondLower\" INTEGER NOT NULL, \"totalPriceVatSecondLower\" INTEGER NOT NULL,
\"totalPrice\" INTEGER NOT NULL, \"totalPrice\" INTEGER NOT NULL,
\"status\" INTEGER NOT NULL, \"status\" INTEGER NOT NULL,
\"eetStatus\" INTEGER NOT NULL,
\"eetSendDateTime\" TEXT NULL,
\"eetPkp\" TEXT,
\"eetBkp\" TEXT,
\"eetFik\" TEXT,
CONSTRAINT \"contact_fk\" CONSTRAINT \"contact_fk\"
FOREIGN KEY (\"contact\") FOREIGN KEY (\"contact\")
REFERENCES \"AddressbookData\" (\"id\") REFERENCES \"AddressbookData\" (\"id\")
@ -57,6 +62,7 @@ CREATE TABLE \"Voucher\" (
"translations" : { "translations" : {
"CZ" : { "CZ" : {
"name" : "Název", "name" : "Název",
"code" : "Kod",
"count" : "Počet", "count" : "Počet",
"unitPrice" : "Jednotková cena", "unitPrice" : "Jednotková cena",
"vatRate" : "Procento DPH", "vatRate" : "Procento DPH",
@ -68,6 +74,7 @@ CREATE TABLE \"Voucher\" (
"vatRateHigh" : "Vysoká sazba", "vatRateHigh" : "Vysoká sazba",
"vatRateFirstLower" : "První snížená sazba", "vatRateFirstLower" : "První snížená sazba",
"vatRateSecondLower" : "Druhá snížená sazba", "vatRateSecondLower" : "Druhá snížená sazba",
"vatAmount" : "Dan",
"priceNoVat" : "Cena zboží s nulovou DPH", "priceNoVat" : "Cena zboží s nulovou DPH",
"priceVatHigh" : "Cena zboží s vysokou sazbou DPH", "priceVatHigh" : "Cena zboží s vysokou sazbou DPH",
"priceVatFirstLower" : "Cena zboží s první sníženou sazbou DPH", "priceVatFirstLower" : "Cena zboží s první sníženou sazbou DPH",
@ -77,7 +84,9 @@ CREATE TABLE \"Voucher\" (
"totalPriceVatFirstLower" : "Celková cena zboží s první sníženou sazbou DPH", "totalPriceVatFirstLower" : "Celková cena zboží s první sníženou sazbou DPH",
"totalPriceVatSecondLower" : "Celková cena zboží s druhou sníženou sazbou DPH", "totalPriceVatSecondLower" : "Celková cena zboží s druhou sníženou sazbou DPH",
"totalPrice" : "Celková cena", "totalPrice" : "Celková cena",
"status" : "Stav" "status" : "Stav",
"numSer" : "Číslo",
"payDateTime" : "Datum"
} }
} }
} }

@ -26,7 +26,12 @@ SOURCES += shop.cpp \
settings/shopsettings.cpp \ settings/shopsettings.cpp \
settings/shopsettingsform.cpp \ settings/shopsettingsform.cpp \
paydialog.cpp \ paydialog.cpp \
paydvouchersdialog.cpp paydvouchersdialog.cpp \
shopitem.cpp \
isellableservice.cpp \
data/favorititem.cpp \
settings/favoriteservice.cpp \
eetbatchdialog.cpp
HEADERS += shop.h\ HEADERS += shop.h\
shop_global.h \ shop_global.h \
@ -46,7 +51,11 @@ HEADERS += shop.h\
settings/shopsettings.h \ settings/shopsettings.h \
settings/shopsettingsform.h \ settings/shopsettingsform.h \
paydialog.h \ paydialog.h \
paydvouchersdialog.h paydvouchersdialog.h \
shopitem.h \
data/favorititem.h \
settings/favoriteservice.h \
eetbatchdialog.h
unix { unix {
target.path = /usr/lib target.path = /usr/lib
@ -72,6 +81,7 @@ else:unix: LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
INCLUDEPATH += $$PWD/../addressbook/data INCLUDEPATH += $$PWD/../addressbook/data
INCLUDEPATH += $$PWD/../addressbook INCLUDEPATH += $$PWD/../addressbook
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/../addressbook DEPENDPATH += $$PWD/../addressbook
DESTDIR = ../plugins DESTDIR = ../plugins
@ -80,7 +90,7 @@ OTHER_FILES += shop.json
ODB_FILES = shop/data/shop-data.h ODB_FILES = shop/data/shop-data.h
H_DIR = $$PWD/data/*.h H_DIR = $$PWD/data/*.h
ODB_OTHER_INCLUDES = -I $$PWD/../addressbook/data ODB_OTHER_INCLUDES = -I $$PWD/../addressbook/data -I $$PWD/
include(../odb.pri) include(../odb.pri)
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
@ -102,6 +112,12 @@ FORMS += \
receiptloadform.ui \ receiptloadform.ui \
settings/shopsettingsform.ui \ settings/shopsettingsform.ui \
paydialog.ui \ paydialog.ui \
paydvouchersdialog.ui paydvouchersdialog.ui \
eetbatchdialog.ui
TRANSLATIONS = translations/shop_cs_CZ.ts TRANSLATIONS = translations/shop_cs_CZ.ts
unix|win32: LIBS += -L$$PWD/../../build-EetCpp-Desktop-Debug/libEet -lEetCpp
INCLUDEPATH += $$PWD/../../EetCpp/libEet
DEPENDPATH += $$PWD/../../EetCpp/libEet

@ -8,8 +8,12 @@
#include "receiptgenerator.h" #include "receiptgenerator.h"
#include "paydialog.h" #include "paydialog.h"
#include "paydvouchersdialog.h" #include "paydvouchersdialog.h"
#include "isellableservice.h"
#include <QList> #include <QList>
#include <QSharedPointer> #include <QSharedPointer>
#include <QSortFilterProxyModel>
#include <QMessageBox>
#include "shop-odb.hxx" #include "shop-odb.hxx"
ShopForm::ShopForm(QWidget *parent) : ShopForm::ShopForm(QWidget *parent) :
@ -18,6 +22,7 @@ ShopForm::ShopForm(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
m_itemsModel = NULL; m_itemsModel = NULL;
m_commodityModel = NULL;
ui->temporarySaveButton->setEnabled(false); ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false); ui->saveButton->setEnabled(false);
@ -50,10 +55,29 @@ void ShopForm::loadLast()
connectItemSignals(); connectItemSignals();
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2)); ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
if (!m_voucher->items().isEmpty())
{
ui->temporarySaveButton->setEnabled(true); ui->temporarySaveButton->setEnabled(true);
ui->saveButton->setEnabled(true); ui->saveButton->setEnabled(true);
ui->payButton->setEnabled(true); ui->payButton->setEnabled(true);
} }
}
if (m_commodityModel == NULL)
{
m_commodityModel = new AutoTableModel<ShopItem>(this);
m_commodityModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->commodityTable->setModel(m_commodityModel);
connect(ui->commodityTable->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, const QModelIndex &){
ui->btnAddItem->setEnabled(current.isValid());
});
}
m_commodityModel->setData(srv.allSellableItems());
ui->commodityTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->commodityTable->setColumnHidden(3, true);
} }
void ShopForm::fillRaceiptCombo() void ShopForm::fillRaceiptCombo()
@ -84,11 +108,7 @@ void ShopForm::on_directSale_clicked()
form->setAttribute(Qt::WA_DeleteOnClose); form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this, form](){ connect(form, &QDialog::accepted, [this, form](){
ShopService srv; addItem(form->shopItem(), ((DirectSaleItem*)form->shopItem().data())->count());
srv.addShopItem(m_voucher, form->shopItem(), ((DirectSaleItem*)form->shopItem().data())->count());
this->m_itemsModel->addRow(m_voucher->items()[m_voucher->items().count() - 1]);
connect(m_voucher->items()[m_voucher->items().count() - 1].data(), SIGNAL(countChanged()), this, SLOT(onCountChanged()));
onCountChanged();
}); });
form->show(); form->show();
@ -104,10 +124,25 @@ void ShopForm::on_saveButton_clicked()
ReceiptSaveForm *form = new ReceiptSaveForm(m_voucher, this); ReceiptSaveForm *form = new ReceiptSaveForm(m_voucher, this);
form->setAttribute(Qt::WA_DeleteOnClose); form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this]() { connect(form, &QDialog::accepted, [this, form]() {
ShopService srv;
if (form->saveAsNew())
{
m_voucher->setStatus(Voucher::NOT_PAID);
srv.saveVoucher(m_voucher);
createEmptyVoucher(); createEmptyVoucher();
}
else
{
VoucherPtr selVoucher = form->selectedVoucher();
srv.moveItems(m_voucher->items(), m_voucher, selVoucher);
srv.calculate(selVoucher);
srv.updateVoucher(selVoucher);
createEmptyVoucher();
}
m_itemsModel->setData(m_voucher->items()); m_itemsModel->setData(m_voucher->items());
ui->total->setText("0");
}); });
form->show(); form->show();
@ -117,10 +152,27 @@ void ShopForm::on_loadButton_clicked()
{ {
ReceiptLoadForm *form = new ReceiptLoadForm(this); ReceiptLoadForm *form = new ReceiptLoadForm(this);
form->setAttribute(Qt::WA_DeleteOnClose); form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this, form](){
ShopService srv;
if (m_voucher.isNull())
{
m_voucher = srv.createVoucher();
}
srv.moveItems(form->selectedItems(), form->selectedVoucher(), this->m_voucher);
m_itemsModel->setData(m_voucher->items());
connectItemSignals();
onCountChanged();
});
form->show(); form->show();
} }
void ShopForm::onCountChanged() void ShopForm::onCountChanged(int oldCount/* = 0*/)
{ {
VoucherItem *item = qobject_cast<VoucherItem*>(sender()); VoucherItem *item = qobject_cast<VoucherItem*>(sender());
if (item != NULL && item->count() == 0) if (item != NULL && item->count() == 0)
@ -150,6 +202,12 @@ void ShopForm::onCountChanged()
{ {
srv.updateVoucher(m_voucher); srv.updateVoucher(m_voucher);
} }
if (item != NULL)
{
int countAdded = item->count() - oldCount;
srv.updateRelatedItem(item, countAdded);
}
} }
void ShopForm::createVoucher() void ShopForm::createVoucher()
@ -212,7 +270,7 @@ void ShopForm::changeReceipt()
void ShopForm::connectItemSignals() void ShopForm::connectItemSignals()
{ {
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) { foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
connect(item.data(), SIGNAL(countChanged()), this, SLOT(onCountChanged())); connect(item.data(), SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int)));
} }
} }
@ -226,6 +284,15 @@ void ShopForm::createEmptyVoucher()
ui->payButton->setEnabled(false); ui->payButton->setEnabled(false);
} }
void ShopForm::addItem(QSharedPointer<IShopItem> item, int count)
{
ShopService srv;
srv.addShopItem(m_voucher, item, count);
this->m_itemsModel->addRow(m_voucher->items()[m_voucher->items().count() - 1]);
connect(m_voucher->items()[m_voucher->items().count() - 1].data(), SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int)));
onCountChanged();
}
void ShopForm::on_receiptCombo_currentIndexChanged(int) void ShopForm::on_receiptCombo_currentIndexChanged(int)
{ {
if (!m_voucher.isNull() && m_voucher->items().isEmpty()) if (!m_voucher.isNull() && m_voucher->items().isEmpty())
@ -256,6 +323,29 @@ void ShopForm::on_payButton_clicked()
connect(dialog, &QDialog::accepted, [this](){ connect(dialog, &QDialog::accepted, [this](){
ShopService srv; ShopService srv;
srv.pay(m_voucher); srv.pay(m_voucher);
QString eetMsg;
if (srv.isEetEnabled())
{
bool eetRet = srv.processEet(m_voucher, eetMsg);
if (!eetRet)
{
QString errMsg = tr("EET communication error.\n");
if (!eetMsg.isEmpty())
{
errMsg += tr("Message from portal: ") + eetMsg + "\n";
}
errMsg += tr("Switch to offline?");
if (srv.isEetOnline() && QMessageBox::question(this, tr("EET error"), errMsg) == QMessageBox::Yes)
{
srv.setEetOnline(false);
}
}
}
ReceiptGenerator generator; ReceiptGenerator generator;
generator.setVoucher(m_voucher); generator.setVoucher(m_voucher);
@ -274,3 +364,42 @@ void ShopForm::on_showPaiedButton_clicked()
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show(); dialog->show();
} }
void ShopForm::on_btnAddItem_clicked()
{
if (m_voucher.isNull())
{
createVoucher();
}
ShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
addItem(item, ui->spnCount->value());
}
void ShopForm::on_commoditySearch_textChanged(const QString &text)
{
QSortFilterProxyModel proxy;
proxy.setSourceModel(m_commodityModel);
proxy.setFilterKeyColumn(0);
proxy.setFilterFixedString(text);
auto moveToIndex = [this](const QModelIndex &matchingIndex) {
ui->commodityTable->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible);
ui->commodityTable->setCurrentIndex(matchingIndex);
};
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
if(matchingIndex.isValid()) {
moveToIndex(matchingIndex);
}
else
{
proxy.setFilterKeyColumn(1);
matchingIndex = proxy.mapToSource(proxy.index(0,0));
if (matchingIndex.isValid())
{
moveToIndex(matchingIndex);
}
}
}

@ -6,6 +6,9 @@
#include "data/shop-data.h" #include "data/shop-data.h"
#include <autotablemodel.h> #include <autotablemodel.h>
class ShopItem;
class IShopItem;
namespace Ui { namespace Ui {
class ShopForm; class ShopForm;
} }
@ -29,7 +32,7 @@ private slots:
void on_loadButton_clicked(); void on_loadButton_clicked();
void onCountChanged(); void onCountChanged(int oldCount = 0);
void on_receiptCombo_currentIndexChanged(int index); void on_receiptCombo_currentIndexChanged(int index);
@ -37,16 +40,22 @@ private slots:
void on_showPaiedButton_clicked(); void on_showPaiedButton_clicked();
void on_btnAddItem_clicked();
void on_commoditySearch_textChanged(const QString &text);
private: private:
Ui::ShopForm *ui; Ui::ShopForm *ui;
QSharedPointer<Voucher> m_voucher; QSharedPointer<Voucher> m_voucher;
AutoTableModel<VoucherItem> *m_itemsModel; AutoTableModel<VoucherItem> *m_itemsModel;
AutoTableModel<ShopItem> *m_commodityModel;
void createVoucher(); void createVoucher();
void doTempSave(bool comboChanged); void doTempSave(bool comboChanged);
void changeReceipt(); void changeReceipt();
void connectItemSignals(); void connectItemSignals();
void createEmptyVoucher(); void createEmptyVoucher();
void addItem(QSharedPointer<IShopItem> item, int count);
}; };
#endif // SHOPFORM_H #endif // SHOPFORM_H

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>959</width> <width>959</width>
<height>582</height> <height>643</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -55,7 +55,14 @@
<widget class="QLineEdit" name="commoditySearch"/> <widget class="QLineEdit" name="commoditySearch"/>
</item> </item>
<item> <item>
<widget class="QTableView" name="commodityTable"/> <widget class="QTableView" name="commodityTable">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QWidget" name="widget_8" native="true"> <widget class="QWidget" name="widget_8" native="true">
@ -68,7 +75,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox"> <widget class="QSpinBox" name="spnCount">
<property name="wrapping"> <property name="wrapping">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -78,13 +85,23 @@
<property name="showGroupSeparator" stdset="0"> <property name="showGroupSeparator" stdset="0">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="minimum">
<number>1</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="btnAddItem">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Add Item</string> <string>Add Item</string>
</property> </property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/new.svg</normaloff>:/icons/new.svg</iconset>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -114,6 +131,11 @@
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QToolButton" name="directSale"> <widget class="QToolButton" name="directSale">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text"> <property name="text">
<string>Direct Sale</string> <string>Direct Sale</string>
</property> </property>
@ -160,7 +182,82 @@
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QGridLayout" name="favorites2"/> <widget class="QToolButton" name="toolFav1">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="toolFav5">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolFav2">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="toolFav3">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="toolFav4">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_3">
<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> </layout>
</widget> </widget>
@ -183,8 +280,96 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="1">
<widget class="QToolButton" name="toolFav7">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QGridLayout" name="favorites3"/> <widget class="QToolButton" name="toolFav6">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="toolFav8">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="toolFav9">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="toolFav10">
<property name="minimumSize">
<size>
<width>75</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_4">
<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 row="1" column="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -386,8 +571,8 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="shoprc.qrc"/>
<include location="../core/rc.qrc"/> <include location="../core/rc.qrc"/>
<include location="shoprc.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

@ -0,0 +1,6 @@
#include "shopitem.h"
ShopItem::ShopItem(QObject *parent) : QObject(parent)
{
}

@ -0,0 +1,37 @@
#ifndef SHOPITEM_H
#define SHOPITEM_H
#include <QObject>
#include "shop_global.h"
#include "ishopitem.h"
class SHOPSHARED_EXPORT ShopItem : public QObject, public IShopItem
{
Q_OBJECT
Q_PROPERTY(QString code READ code)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QDecDouble unitPrice READ unitPrice)
Q_PROPERTY(Enums::VatType vatType READ vatType)
public:
explicit ShopItem(QObject *parent = 0);
signals:
public slots:
// IShopItem interface
public:
virtual int id() override { return 0; }
virtual QString code() { return ""; }
virtual QString name() override { return ""; }
virtual QDecDouble unitPrice() override { return QDecDouble(); }
virtual Enums::VatType vatType() override { return Enums::NONE; }
virtual QString pluginId() override { return ""; }
};
typedef QSharedPointer<ShopItem> ShopItemPtr;
#endif // SHOPITEM_H

@ -5,5 +5,6 @@
<file>icons/tempSave.svg</file> <file>icons/tempSave.svg</file>
<file>icons/paied.svg</file> <file>icons/paied.svg</file>
<file>icons/pay.svg</file> <file>icons/pay.svg</file>
<file>icons/sendEet.svg</file>
</qresource> </qresource>
</RCC> </RCC>

@ -1,19 +1,25 @@
#include "shopservice.h" #include "shopservice.h"
#include "numberseriesservice.h" #include "numberseriesservice.h"
#include "isellableservice.h"
#include "shop-odb.hxx" #include "shop-odb.hxx"
#include "settings/shopsettings.h"
#include <eetcpp.h>
#include <QEventLoop>
ShopService::ShopService() ShopService::ShopService()
{ {
} }
QSharedPointer<Voucher> ShopService::createVoucher() VoucherPtr ShopService::createVoucher()
{ {
QSharedPointer<Voucher> voucher(new Voucher); QSharedPointer<Voucher> voucher(new Voucher);
voucher->setStatus(Voucher::NEW); voucher->setStatus(Voucher::NEW);
return voucher; return voucher;
} }
void ShopService::addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count) void ShopService::addShopItem(VoucherPtr voucher, QSharedPointer<IShopItem> item, int count)
{ {
QSharedPointer<VoucherItem> vItem(new VoucherItem); QSharedPointer<VoucherItem> vItem(new VoucherItem);
vItem->setName(item->name()); vItem->setName(item->name());
@ -24,9 +30,11 @@ void ShopService::addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IS
vItem->setVatType(item->vatType()); vItem->setVatType(item->vatType());
voucher->addItem(vItem); voucher->addItem(vItem);
updateRelatedItem(vItem.data(), count);
} }
void ShopService::calculate(QSharedPointer<Voucher> voucher) void ShopService::calculate(VoucherPtr voucher)
{ {
QDecDouble total; QDecDouble total;
@ -65,7 +73,7 @@ void ShopService::calculate(QSharedPointer<Voucher> voucher)
voucher->setTotalPrice(total); voucher->setTotalPrice(total);
} }
void ShopService::calculateItem(QSharedPointer<VoucherItem> item) void ShopService::calculateItem(VoucherItemPtr item)
{ {
loadSettings(); loadSettings();
if (m_gs->vatPayer()) if (m_gs->vatPayer())
@ -81,13 +89,13 @@ void ShopService::calculateItem(QSharedPointer<VoucherItem> item)
} }
} }
void ShopService::loadItems(QSharedPointer<Voucher> voucher) void ShopService::loadItems(VoucherPtr voucher)
{ {
Service<VoucherItem> srv; Service<VoucherItem> srv;
voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id()))); voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id())));
} }
void ShopService::pay(QSharedPointer<Voucher> voucher) void ShopService::pay(VoucherPtr voucher)
{ {
Transaction tx; Transaction tx;
NumberSeriesService srvNs; NumberSeriesService srvNs;
@ -98,6 +106,7 @@ void ShopService::pay(QSharedPointer<Voucher> voucher)
voucher->setNumSer(numSerStr); voucher->setNumSer(numSerStr);
voucher->setStatus(Voucher::PAID); voucher->setStatus(Voucher::PAID);
voucher->setEetStatus(Voucher::EET_FOR_SEND);
voucher->setPayDateTime(QDateTime::currentDateTime()); voucher->setPayDateTime(QDateTime::currentDateTime());
this->update(voucher); this->update(voucher);
@ -105,21 +114,180 @@ void ShopService::pay(QSharedPointer<Voucher> voucher)
tx.commit(); tx.commit();
} }
QList<QSharedPointer<Voucher> > ShopService::savedVouchers() void ShopService::updateRelatedItem(VoucherItem* item, int countAdded)
{
IPlugin *plugin = Context::instance().plugin(item->itemPlugin());
IService *srv = (plugin != NULL ? plugin->service<IService>() : NULL);
ISellableService *selSrv = dynamic_cast<ISellableService*>(srv);
if (selSrv != NULL)
{
selSrv->addedToVoucher(item->refId(), countAdded);
}
}
bool ShopService::processEet(VoucherPtr voucher, QString &message)
{
if (voucher->eetStatus() == Voucher::EET_NOT_ENTERING)
{
return true;
}
SettingsService srvSettings("SHOP");
ShopSettingsPtr settings = srvSettings.loadSettings<ShopSettings>();
loadSettings();
EetRequest request;
request.setCelkTrzba(voucher->totalPrice().toDouble());
request.setDatTrzby(voucher->payDateTime());
request.setIdPokl(settings->eetRegisterId());
request.setIdProvoz(settings->eetShopId());
request.setPrvniZaslani(voucher->eetStatus() == Voucher::EET_FOR_SEND);
request.setDicPopl(m_gs->dic());
request.setPoradCis(voucher->numSer());
request.setDatOdesl(QDateTime::currentDateTime());
request.setRezim((EetRequest::EetRezim)settings->eetMode());
EetSender *sender = new EetSender(this);
sender->setupSigner(settings->eetCertificate(), settings->eetKeyPassword());
sender->setPlayground(settings->eetPlayground());
QEventLoop loop;
bool replyFinished = false;
connect(sender, &EetSender::sendFinished, [this, voucher, sender, &loop, &replyFinished](){
Transaction tx;
voucher->setEetBkp(sender->resut()->bkp());
voucher->setEetPkp(sender->resut()->pkp());
voucher->setEetFik(sender->resut()->fik());
if (sender->resut()->status() == EetResult::RESPONSE_OK)
{
voucher->setEetSendDateTime(QDateTime::currentDateTime());
voucher->setEetStatus(Voucher::EET_SENT);
}
else
{
voucher->setEetStatus(Voucher::EET_ERROR);
}
this->update(voucher);
tx.commit();
sender->deleteLater();
loop.quit();
replyFinished = true;
});
sender->sendRequest(&request);
if (!replyFinished)
{
loop.exec();
}
auto addMessage = [&message](EetMessage *msg, const QString &label){
if (message.isEmpty())
{
message = label + "\n";
}
message += QString::number(msg->code()) + ": " + msg->message();
};
foreach (EetMessage *msg, sender->resut()->errors()) {
addMessage(msg, "Errors:");
}
foreach (EetMessage *msg, sender->resut()->warnings()) {
addMessage(msg, "Warnings:");
}
return voucher->eetStatus() == Voucher::EET_SENT;
}
void ShopService::setEetOnline(bool online)
{
EetSender::m_online = online;
}
bool ShopService::isEetOnline()
{
return EetSender::m_online;
}
bool ShopService::isEetEnabled()
{
SettingsService srvSettings("SHOP");
ShopSettingsPtr settings = srvSettings.loadSettings<ShopSettings>();
return settings->eetActive();
}
void ShopService::moveItems(QList<VoucherItemPtr> items, VoucherPtr source, VoucherPtr target)
{
Transaction tx;
if (target->status() == Voucher::NEW && target->id() == 0)
{
this->saveVoucher(target);
}
odb::database *db = Context::instance().db();
foreach (VoucherItemPtr item, items) {
QString sql = QString("update VoucherItem set voucher = %1 where id = %2").arg(QString::number(target->id()), QString::number(item->id()));
db->execute(sql.toStdString());
}
loadItems(source);
loadItems(target);
if (source->items().isEmpty())
{
erase(source);
}
tx.commit();
}
QList<VoucherPtr> ShopService::savedVouchers()
{ {
return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))); return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)));
} }
QList<QSharedPointer<Voucher> > ShopService::tempVouchers() QList<VoucherPtr> ShopService::tempVouchers()
{ {
return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY))); return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY)));
} }
QList<QSharedPointer<Voucher> > ShopService::paiedVouchers() QList<VoucherPtr> ShopService::paiedVouchers()
{ {
return all(QString("status = %1").arg(QString::number(Voucher::PAID))); return all(QString("status = %1").arg(QString::number(Voucher::PAID)));
} }
QList<VoucherPtr> ShopService::vouchersForEet()
{
return all(QString("status = %1 AND eetStatus <> %2 AND eetStatus <> %3")
.arg(QString::number(Voucher::PAID), QString::number(Voucher::EET_SENT), QString::number(Voucher::EET_NOT_ENTERING)));
}
QList<ShopItemPtr> ShopService::allSellableItems()
{
QList<QSharedPointer<ShopItem> > items;
foreach (IPlugin *plugin, Context::instance().plugins()) {
IService *srv = plugin->service<IService>();
ISellableService *selSrv = dynamic_cast<ISellableService*>(srv);
if (selSrv != NULL)
{
items.append(selSrv->shopItems());
}
}
return items;
}
QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType) QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType)
{ {
return price * ((vatRate(vatType) / 100) + QDecDouble(1)); return price * ((vatRate(vatType) / 100) + QDecDouble(1));
@ -159,7 +327,7 @@ QDecDouble ShopService::vatRate(Enums::VatType vatType)
return vatRate; return vatRate;
} }
void ShopService::saveVoucher(QSharedPointer<Voucher> entity) void ShopService::saveVoucher(VoucherPtr entity)
{ {
Transaction tr; Transaction tr;
odb::database *db = Context::instance().db(); odb::database *db = Context::instance().db();
@ -174,7 +342,7 @@ void ShopService::saveVoucher(QSharedPointer<Voucher> entity)
tr.commit(); tr.commit();
} }
void ShopService::updateVoucher(QSharedPointer<Voucher> entity) void ShopService::updateVoucher(VoucherPtr entity)
{ {
Transaction tr; Transaction tr;
odb::database *db = Context::instance().db(); odb::database *db = Context::instance().db();

@ -7,21 +7,29 @@
#include <settings/globalsettings.h> #include <settings/globalsettings.h>
#include "data/shop-data.h" #include "data/shop-data.h"
#include "ishopitem.h" #include "shopitem.h"
class ShopService : public Service<Voucher> class ShopService : public Service<Voucher>
{ {
public: public:
ShopService(); ShopService();
QSharedPointer<Voucher> createVoucher(); VoucherPtr createVoucher();
void addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count); void addShopItem(VoucherPtr voucher, QSharedPointer<IShopItem> item, int count);
void calculate(QSharedPointer<Voucher> voucher); void calculate(VoucherPtr voucher);
void calculateItem(QSharedPointer<VoucherItem> item); void calculateItem(VoucherItemPtr item);
void loadItems(QSharedPointer<Voucher> voucher); void loadItems(VoucherPtr voucher);
void pay(QSharedPointer<Voucher> voucher); void pay(VoucherPtr voucher);
QList<QSharedPointer<Voucher> > savedVouchers(); void moveItems(QList<VoucherItemPtr> items, VoucherPtr source, VoucherPtr target);
QList<QSharedPointer<Voucher> > tempVouchers(); void updateRelatedItem(VoucherItem* item, int countAdded);
QList<QSharedPointer<Voucher> > paiedVouchers(); bool processEet(VoucherPtr voucher, QString &message);
void setEetOnline(bool online);
bool isEetOnline();
bool isEetEnabled();
QList<VoucherPtr> savedVouchers();
QList<VoucherPtr> tempVouchers();
QList<VoucherPtr> paiedVouchers();
QList<VoucherPtr> vouchersForEet();
QList<ShopItemPtr> allSellableItems();
private: private:
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType); QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);
@ -31,8 +39,8 @@ private:
QDecDouble vatRate(Enums::VatType vatType); QDecDouble vatRate(Enums::VatType vatType);
public: public:
void saveVoucher(QSharedPointer<Voucher> entity); void saveVoucher(VoucherPtr entity);
void updateVoucher(QSharedPointer<Voucher> entity); void updateVoucher(VoucherPtr entity);
}; };
#endif // SHOPSERVICE_H #endif // SHOPSERVICE_H

@ -0,0 +1,319 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="cs_CZ">
<context>
<name>DirectSaleForm</name>
<message>
<location filename="../directsaleform.ui" line="14"/>
<source>Form</source>
<translation>Zboží</translation>
</message>
<message>
<location filename="../directsaleform.ui" line="20"/>
<source>Commodity Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../directsaleform.ui" line="30"/>
<source>Price</source>
<translation>Cena</translation>
</message>
<message>
<location filename="../directsaleform.ui" line="44"/>
<source>Count</source>
<translation>Počet</translation>
</message>
<message>
<location filename="../directsaleform.ui" line="58"/>
<source>VAT rate</source>
<translation>Sazba DPH</translation>
</message>
<message>
<location filename="../directsaleform.cpp" line="17"/>
<source>None</source>
<translation>Žádná</translation>
</message>
<message>
<location filename="../directsaleform.cpp" line="18"/>
<source>High</source>
<translation>Vysoká</translation>
</message>
<message>
<location filename="../directsaleform.cpp" line="19"/>
<source>First Lower</source>
<translation>První snížená</translation>
</message>
<message>
<location filename="../directsaleform.cpp" line="20"/>
<source>Second Lower</source>
<translation>Druhá snížená</translation>
</message>
</context>
<context>
<name>PayDialog</name>
<message>
<location filename="../paydialog.ui" line="14"/>
<source>Recieve money</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydialog.ui" line="30"/>
<source>Total:</source>
<translation type="unfinished">Celkem:</translation>
</message>
<message>
<location filename="../paydialog.ui" line="44"/>
<location filename="../paydialog.ui" line="101"/>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydialog.ui" line="59"/>
<source>Recieved</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydialog.ui" line="89"/>
<source>Return</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PaydVouchersDialog</name>
<message>
<location filename="../paydvouchersdialog.ui" line="14"/>
<source>Paied vouchers</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="29"/>
<source>Print receipt</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="55"/>
<location filename="../paydvouchersdialog.cpp" line="51"/>
<source>Save receipt</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="58"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="104"/>
<source>Items</source>
<translation type="unfinished">Položky</translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="137"/>
<source>Total:</source>
<translation type="unfinished">Celkem:</translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="157"/>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../paydvouchersdialog.cpp" line="51"/>
<source>Text files (*.txt)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ReceiptLoadForm</name>
<message>
<location filename="../receiptloadform.ui" line="14"/>
<source>Dialog</source>
<translation></translation>
</message>
<message>
<location filename="../receiptloadform.ui" line="20"/>
<source>Receipts</source>
<translation>Účtenky</translation>
</message>
<message>
<location filename="../receiptloadform.ui" line="29"/>
<source>Search</source>
<translation>Hledat</translation>
</message>
<message>
<location filename="../receiptloadform.ui" line="42"/>
<source>Items</source>
<translation>Položky</translation>
</message>
</context>
<context>
<name>ReceiptSaveForm</name>
<message>
<location filename="../receiptsaveform.ui" line="33"/>
<source>Existing Receipts</source>
<translation>Přidat k již uložené</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="39"/>
<source>Search</source>
<translation>Hledat</translation>
</message>
<message>
<source>GroupBox</source>
<translation type="vanished">Uložit novou</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="14"/>
<source>Save receipt</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="23"/>
<source>Add to existing</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="62"/>
<source>Save as new</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="69"/>
<source>New receipt</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="78"/>
<source>Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="88"/>
<source>Description</source>
<translation>Popis</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="98"/>
<source>Search Contacts</source>
<translation>Vyhledat kontakt</translation>
</message>
</context>
<context>
<name>ShopForm</name>
<message>
<location filename="../shopform.ui" line="14"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="50"/>
<source>Commodity</source>
<translation>Zboží</translation>
</message>
<message>
<location filename="../shopform.ui" line="73"/>
<source>Count</source>
<translation>Počet</translation>
</message>
<message>
<location filename="../shopform.ui" line="99"/>
<source>Add Item</source>
<translation>Přidat položku</translation>
</message>
<message>
<location filename="../shopform.ui" line="135"/>
<source>Direct Sale</source>
<translation>Přímý prodej</translation>
</message>
<message>
<location filename="../shopform.ui" line="148"/>
<source>Ctrl+D</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="221"/>
<source>Receipt</source>
<translation>Účtenka</translation>
</message>
<message>
<location filename="../shopform.ui" line="257"/>
<source>Total:</source>
<translation>Celkem:</translation>
</message>
<message>
<location filename="../shopform.ui" line="274"/>
<source>0</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="295"/>
<source>Temporary Save</source>
<translation>Dočasné uložení</translation>
</message>
<message>
<location filename="../shopform.ui" line="317"/>
<source>Save</source>
<translation>Uložení</translation>
</message>
<message>
<location filename="../shopform.ui" line="339"/>
<source>Load</source>
<translation>Načíst</translation>
</message>
<message>
<location filename="../shopform.ui" line="361"/>
<source>Show paied</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../shopform.ui" line="383"/>
<source>Pay</source>
<translation>Zaplatit</translation>
</message>
<message>
<location filename="../shopform.cpp" line="84"/>
<source>&lt;&lt; empty &gt;&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShopSettingsForm</name>
<message>
<location filename="../settings/shopsettingsform.ui" line="14"/>
<source>Form</source>
<translation type="unfinished">Zboží</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="20"/>
<source>Printer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="26"/>
<source>Output device</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="36"/>
<source>Letters per line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="46"/>
<source>Footer text</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TemporaryReceiptSaveForm</name>
<message>
<location filename="../temporaryreceiptsaveform.ui" line="14"/>
<source>Dialog</source>
<translation>Dočasné uložení</translation>
</message>
<message>
<location filename="../temporaryreceiptsaveform.ui" line="20"/>
<source>Temporary Receipt Name</source>
<translation>Název dočasně uložené účtenky</translation>
</message>
</context>
</TS>
Loading…
Cancel
Save