diff --git a/addressbook/translations/addressbook_cs_CZ.ts b/addressbook/translations/addressbook_cs_CZ.ts
new file mode 100644
index 0000000..64d466c
--- /dev/null
+++ b/addressbook/translations/addressbook_cs_CZ.ts
@@ -0,0 +1,62 @@
+
+
+
+
+ AddressbookForm
+
+
+
+
+
+
+
+
+ Titul
+
+
+
+
+ Křestní jméno
+
+
+
+
+ Příjmení
+
+
+
+
+ Datum narození
+
+
+
+
+ Číslo dokladu totožnosti
+
+
+
+
+ Město
+
+
+
+
+ ZTP
+
+
+
+
+ Ulice
+
+
+
+
+ Číslo popisné
+
+
+
+
+ PSČ
+
+
+
diff --git a/application/translations/prodejna_cs_CZ.qm b/application/translations/prodejna_cs_CZ.qm
index ff3af12..f569e5d 100644
Binary files a/application/translations/prodejna_cs_CZ.qm and b/application/translations/prodejna_cs_CZ.qm differ
diff --git a/application/translations/prodejna_cz.ts b/application/translations/prodejna_cz.ts
index cc1072e..8d1a56b 100644
--- a/application/translations/prodejna_cz.ts
+++ b/application/translations/prodejna_cz.ts
@@ -20,7 +20,7 @@
- Nastaveni
+ Prodejna
diff --git a/commodity/commodity.cpp b/commodity/commodity.cpp
index cd0622f..68db393 100644
--- a/commodity/commodity.cpp
+++ b/commodity/commodity.cpp
@@ -3,6 +3,7 @@
#include "commodityform.h"
#include "commoditygrid.h"
#include "commoditysettingsform.h"
+#include "commodityservice.h"
Commodity::Commodity()
{
@@ -13,7 +14,7 @@ void Commodity::initServiceUi()
CommodityGrid *grid = new CommodityGrid();
CommodityForm *form = new CommodityForm();
- m_service = new Service;
+ m_service = new CommodityService();
m_ui = grid;
((CommodityGrid *) m_ui)->setForm(form);
m_settingsUi = new CommoditySettingsForm();
diff --git a/commodity/commodity.pro b/commodity/commodity.pro
index 0ca4f0b..5fc1b92 100644
--- a/commodity/commodity.pro
+++ b/commodity/commodity.pro
@@ -20,7 +20,8 @@ SOURCES += commodity.cpp \
commoditytablemodel.cpp \
commodityform.cpp \
commoditygrid.cpp \
- commoditysettingsform.cpp
+ commoditysettingsform.cpp \
+ commodityservice.cpp
HEADERS += commodity.h\
commodity_global.h \
@@ -30,7 +31,8 @@ HEADERS += commodity.h\
commoditytablemodel.h \
commodityform.h \
commoditygrid.h \
- commoditysettingsform.h
+ commoditysettingsform.h \
+ commodityservice.h
unix {
target.path = /usr/lib
@@ -53,6 +55,7 @@ DESTDIR = ../plugins
ODB_FILES = commodity/data/commodity-data.h
H_DIR = $$PWD/data/*.h
+ODB_OTHER_INCLUDES = -I $$PWD/../shop
include(../odb.pri)
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
@@ -73,3 +76,10 @@ FORMS += \
RESOURCES += \
commodityrc.qrc
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
diff --git a/commodity/commodityservice.cpp b/commodity/commodityservice.cpp
new file mode 100644
index 0000000..ecb1d3f
--- /dev/null
+++ b/commodity/commodityservice.cpp
@@ -0,0 +1,31 @@
+#include "commodityservice.h"
+
+#include "commodity-odb.hxx"
+
+CommodityService::CommodityService()
+{
+
+}
+
+QList > CommodityService::shopItems()
+{
+ QList > ret;
+
+ foreach (QSharedPointer data, all()) {
+ ret.append(qSharedPointerDynamicCast(data));
+ }
+
+ return ret;
+}
+
+void CommodityService::addedToVoucher(int itemId, int countAdded)
+{
+ QSharedPointer commodity = loadById(itemId);
+
+ if (!commodity.isNull())
+ {
+ commodity->setCount(commodity->count() - countAdded);
+ }
+
+ update(commodity);
+}
diff --git a/commodity/commodityservice.h b/commodity/commodityservice.h
new file mode 100644
index 0000000..4f67690
--- /dev/null
+++ b/commodity/commodityservice.h
@@ -0,0 +1,19 @@
+#ifndef COMMODITYSERVICE_H
+#define COMMODITYSERVICE_H
+
+#include
+#include
+#include "data/commodity-data.h"
+
+class CommodityService : public Service, public ISellableService
+{
+public:
+ CommodityService();
+
+ // ISellableService interface
+public:
+ QList > shopItems() override;
+ void addedToVoucher(int itemId, int countAdded) override;
+};
+
+#endif // COMMODITYSERVICE_H
diff --git a/commodity/data/commoditydata.cpp b/commodity/data/commoditydata.cpp
index b0b9769..2463564 100644
--- a/commodity/data/commoditydata.cpp
+++ b/commodity/data/commoditydata.cpp
@@ -2,13 +2,13 @@
#include
CommodityData::CommodityData(QObject *parent)
- :QObject(parent)
+ :ShopItem(parent)
{
m_count = 0;
m_price = 0;
m_vat = Enums::NONE;
}
-int CommodityData::id() const
+int CommodityData::id()
{
return m_id;
}
@@ -17,7 +17,7 @@ void CommodityData::setId(int id)
{
m_id = id;
}
-QString CommodityData::name() const
+QString CommodityData::name()
{
return m_name;
}
@@ -83,6 +83,21 @@ void CommodityData::setCount(int count)
m_count = count;
}
+QDecDouble CommodityData::unitPrice()
+{
+ return price();
+}
+
+Enums::VatType CommodityData::vatType()
+{
+ return vat();
+}
+
+QString CommodityData::pluginId()
+{
+ return "COMMODITY";
+}
+
diff --git a/commodity/data/commoditydata.h b/commodity/data/commoditydata.h
index 7ac5e48..462b4f1 100644
--- a/commodity/data/commoditydata.h
+++ b/commodity/data/commoditydata.h
@@ -5,17 +5,18 @@
#include
#include
#include "commoditytypedata.h"
+#include
#include
#include
#include
#pragma db object
-class CommodityData : public QObject
+class CommodityData : public ShopItem
{
Q_OBJECT
+ Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString shortName READ shortName WRITE setShortName)
- Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QSharedPointer type READ type WRITE setType)
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
Q_PROPERTY(Enums::VatType vat READ vat WRITE setVat)
@@ -24,10 +25,10 @@ class CommodityData : public QObject
public:
CommodityData(QObject *parent = 0);
- int id() const;
+ int id() override;
void setId(int id);
- QString name() const;
+ QString name() override;
void setName(const QString &name);
QString shortName() const;
@@ -59,6 +60,12 @@ private:
int m_price;
Enums::VatType m_vat;
int m_count;
+
+ // IShopItem interface
+public:
+ QDecDouble unitPrice() override;
+ Enums::VatType vatType() override;
+ QString pluginId() override;
};
#endif // COMMODITYDATA_H
diff --git a/commodity/translations/commodity_cs_CZ.ts b/commodity/translations/commodity_cs_CZ.ts
new file mode 100644
index 0000000..db5539e
--- /dev/null
+++ b/commodity/translations/commodity_cs_CZ.ts
@@ -0,0 +1,85 @@
+
+
+
+
+ CommodityForm
+
+
+
+ Zboží
+
+
+
+
+ Název
+
+
+
+
+ Zobrazit na účtence
+
+
+
+
+ Kód
+
+
+
+
+ Druh
+
+
+
+
+ Cena
+
+
+
+
+ DPH
+
+
+
+
+ Počet
+
+
+
+
+ Žádná
+
+
+
+
+ Vysoká
+
+
+
+
+ První snížená
+
+
+
+
+ Druhá snížená
+
+
+
+ CommoditySettingsForm
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ -
+
+
+
diff --git a/core/autotablemodel.h b/core/autotablemodel.h
index 6f45b0f..2b12a38 100644
--- a/core/autotablemodel.h
+++ b/core/autotablemodel.h
@@ -24,6 +24,7 @@ public:
:ITableModel(parent)
{
filtered = false;
+ m_checkboxSelect = false;
}
virtual ~AutoTableModel() {}
@@ -50,6 +51,21 @@ public:
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 entity = m_list.at(index.row());
QObject *rawEntity = (QObject*)entity.data();
@@ -189,6 +205,21 @@ public:
m_translations = translations;
}
+ QList selectedRows() const
+ {
+ return m_selectedRows;
+ }
+
+ QList > selectedItems()
+ {
+ QList > ret;
+ foreach (int row, m_selectedRows) {
+ ret.append(m_list[row]);
+ }
+
+ return ret;
+ }
+
protected:
void handleFilter(const QString &filter) override
{
@@ -220,10 +251,10 @@ protected:
private:
QList > m_list;
QList > m_fullList;
+ QList m_selectedRows;
QMap m_translations;
bool filtered;
-
// QAbstractItemModel interface
public:
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);
}
+ if (role == Qt::CheckStateRole)
+ {
+ if (m_selectedRows.contains(index.row()))
+ {
+ m_selectedRows.removeOne(index.row());
+ }
+ else
+ {
+ m_selectedRows.append(index.row());
+ }
+ }
+
emit editCompleted();
return true;
}
};
#endif // ODBTABLEMODEL_H
-
diff --git a/core/context.cpp b/core/context.cpp
index c658df6..7b92ef3 100644
--- a/core/context.cpp
+++ b/core/context.cpp
@@ -65,6 +65,10 @@ void Context::loadPlugins()
m_plugins.append(plugin);
}
}
+ else
+ {
+ qDebug() << pluginLoader.errorString();
+ }
}
QString dbPath = m_settings->value("db/path", "").toString();
diff --git a/core/itablemodel.cpp b/core/itablemodel.cpp
index dfde394..6c7ff0b 100644
--- a/core/itablemodel.cpp
+++ b/core/itablemodel.cpp
@@ -3,7 +3,17 @@
ITableModel::ITableModel(QObject *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)
@@ -18,12 +28,17 @@ void ITableModel::restore()
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()))
{
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
}
- return QAbstractTableModel::flags(index);
+ return QAbstractTableModel::flags(index) | Qt::ItemIsDragEnabled;
}
void ITableModel::setEditableCols(const QList cols)
diff --git a/core/itablemodel.h b/core/itablemodel.h
index e30780f..b337c16 100644
--- a/core/itablemodel.h
+++ b/core/itablemodel.h
@@ -16,6 +16,7 @@ public:
protected:
virtual void handleFilter(const QString &filter) = 0;
virtual void handleRestore() = 0;
+ bool m_checkboxSelect;
public slots:
void filter(const QString &filter);
@@ -29,6 +30,9 @@ public:
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
void setEditableCols(const QList cols);
+ bool checkboxSelect() const;
+ void setCheckboxSelect(bool checkboxSelect);
+
private:
QList m_editableCols;
};
diff --git a/core/translations/core_cs_CZ.ts b/core/translations/core_cs_CZ.ts
index e23a684..6fd7131 100644
--- a/core/translations/core_cs_CZ.ts
+++ b/core/translations/core_cs_CZ.ts
@@ -126,86 +126,132 @@
-
+
+
+
+
+
+
Informace o společnosti
-
+
IČO
-
+
DIČ
-
+
Plátce DPH
-
+
Sazby DPH
-
+
Vysoká
-
+
První snížená
-
+
Druhá snížená
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Kontaktní údaje
-
+
Název společnosti
-
+
Ulice
-
+
Číslo popisné
-
+
Město
-
+
PSČ
-
-
+
+
Logo
-
+
Vyber soubor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
GridForm
@@ -314,6 +360,19 @@
Název filtru
+
+ SeasonNameDialog
+
+
+
+
+
+
+
+
+
+
+
SettingsForm
diff --git a/odb.pri b/odb.pri
index 5459420..ab3dc7b 100644
--- a/odb.pri
+++ b/odb.pri
@@ -46,7 +46,7 @@ ODB_FLAGS += -I $$PWD/core
ODB_FLAGS += -I $$PWD/qdecimal/src
ODB_FLAGS += -I $$PWD/qdecimal/decnumber
ODB_FLAGS += $$ODB_OTHER_INCLUDES
-ODB_FLAGS += -D __PIC__
+ODB_FLAGS += -x -std=c++11 -x -fPIC
win32 {
ODB_FLAGS += -I d:/prac/odb/libodb-2.4.0
diff --git a/services/translations/services_cs_CZ.ts b/services/translations/services_cs_CZ.ts
new file mode 100644
index 0000000..a065c7e
--- /dev/null
+++ b/services/translations/services_cs_CZ.ts
@@ -0,0 +1,82 @@
+
+
+
+
+ AccServiceForm
+
+
+
+ Služba
+
+
+
+
+ Název
+
+
+
+
+ Cena
+
+
+
+
+ Druh
+
+
+
+
+ Umožnit slevu
+
+
+
+
+ Aktivní
+
+
+
+
+ Kód
+
+
+
+
+ Sazba DPH
+
+
+
+
+ Vozidlo
+
+
+
+
+ Stan
+
+
+
+
+ Ostatní
+
+
+
+
+ Žádná
+
+
+
+
+ Vysoká
+
+
+
+
+ První snížená
+
+
+
+
+ Druhá snížená
+
+
+
diff --git a/shop/data/favorititem.cpp b/shop/data/favorititem.cpp
new file mode 100644
index 0000000..3d7e5e3
--- /dev/null
+++ b/shop/data/favorititem.cpp
@@ -0,0 +1,69 @@
+#include "favorititem.h"
+#include
+
+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;
+}
diff --git a/shop/data/favorititem.h b/shop/data/favorititem.h
new file mode 100644
index 0000000..c569838
--- /dev/null
+++ b/shop/data/favorititem.h
@@ -0,0 +1,62 @@
+#ifndef FAVORITITEM_H
+#define FAVORITITEM_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+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 FavoritItemPtr;
+
+#endif // FAVORITITEM_H
diff --git a/shop/data/shop-data.h b/shop/data/shop-data.h
index 856c470..43c0f25 100644
--- a/shop/data/shop-data.h
+++ b/shop/data/shop-data.h
@@ -3,5 +3,6 @@
#include "voucher.h"
#include "voucheritem.h"
+#include "favorititem.h"
#endif // SHOPDATA_H
diff --git a/shop/data/voucher.cpp b/shop/data/voucher.cpp
index 5ad6cf4..99cf029 100644
--- a/shop/data/voucher.cpp
+++ b/shop/data/voucher.cpp
@@ -16,6 +16,7 @@ Voucher::Voucher(QObject *parent) : QObject(parent)
m_totalPriceVatFirstLower = 0;
m_totalPriceVatSecondLower = 0;
m_totalPrice = 0;
+ m_eetStatus = EET_FOR_SEND;
}
QString Voucher::name() const
@@ -230,6 +231,56 @@ void Voucher::setPayDateTime(const QDateTime &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
{
return m_id;
diff --git a/shop/data/voucher.h b/shop/data/voucher.h
index 36063d1..3ad0385 100644
--- a/shop/data/voucher.h
+++ b/shop/data/voucher.h
@@ -28,7 +28,13 @@ class Voucher : public QObject
Q_PROPERTY(QDecDouble priceVatFirstLower READ priceVatFirstLower WRITE setPriceVatFirstLower)
Q_PROPERTY(QDecDouble priceVatSecondLower READ priceVatSecondLower WRITE setPriceVatSecondLower)
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(EetStatus)
Q_PROPERTY(VoucherStatus status READ status WRITE setStatus)
public:
@@ -42,6 +48,14 @@ public:
PAID
};
+ enum EetStatus
+ {
+ EET_FOR_SEND,
+ EET_NOT_ENTERING,
+ EET_SENT,
+ EET_ERROR
+ };
+
int id() const;
void setId(int id);
@@ -110,6 +124,21 @@ public:
QDateTime payDateTime() const;
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:
friend class odb::access;
#pragma db id auto
@@ -131,6 +160,11 @@ private:
int m_totalPriceVatFirstLower;
int m_totalPriceVatSecondLower;
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)
QOdbList > m_items;
VoucherStatus m_status;
diff --git a/shop/data/voucheritem.cpp b/shop/data/voucheritem.cpp
index 3d25f3f..cd7132f 100644
--- a/shop/data/voucheritem.cpp
+++ b/shop/data/voucheritem.cpp
@@ -39,8 +39,9 @@ int VoucherItem::count() const
void VoucherItem::setCount(int count)
{
+ int oldCount = m_count;
m_count = count;
- emit countChanged();
+ emit countChanged(oldCount);
}
QDecDouble VoucherItem::unitPrice() const
diff --git a/shop/data/voucheritem.h b/shop/data/voucheritem.h
index 02ee8de..d41e77f 100644
--- a/shop/data/voucheritem.h
+++ b/shop/data/voucheritem.h
@@ -63,7 +63,7 @@ public:
void setVoucher(const QWeakPointer &voucher);
signals:
- void countChanged();
+ void countChanged(int oldCount);
private:
friend class odb::access;
diff --git a/shop/eetbatchdialog.cpp b/shop/eetbatchdialog.cpp
new file mode 100644
index 0000000..59232e4
--- /dev/null
+++ b/shop/eetbatchdialog.cpp
@@ -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);
+}
diff --git a/shop/eetbatchdialog.h b/shop/eetbatchdialog.h
new file mode 100644
index 0000000..9c15fba
--- /dev/null
+++ b/shop/eetbatchdialog.h
@@ -0,0 +1,23 @@
+#ifndef EETBATCHDIALOG_H
+#define EETBATCHDIALOG_H
+
+#include
+
+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
diff --git a/shop/eetbatchdialog.ui b/shop/eetbatchdialog.ui
new file mode 100644
index 0000000..2a6bd2e
--- /dev/null
+++ b/shop/eetbatchdialog.ui
@@ -0,0 +1,74 @@
+
+
+ EetBatchDialog
+
+
+
+ 0
+ 0
+ 324
+ 272
+
+
+
+ EET batch send
+
+
+ true
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Close
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ EetBatchDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ EetBatchDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/shop/icons/sendEet.svg b/shop/icons/sendEet.svg
new file mode 100644
index 0000000..ce6a617
--- /dev/null
+++ b/shop/icons/sendEet.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/shop/isellableservice.cpp b/shop/isellableservice.cpp
new file mode 100644
index 0000000..f8dad60
--- /dev/null
+++ b/shop/isellableservice.cpp
@@ -0,0 +1,5 @@
+#include "isellableservice.h"
+
+ISellableService::ISellableService()
+{
+}
diff --git a/shop/isellableservice.h b/shop/isellableservice.h
index 717164e..dc778c0 100644
--- a/shop/isellableservice.h
+++ b/shop/isellableservice.h
@@ -2,14 +2,17 @@
#define ISELLABLESERVICE_H
#include "shop_global.h"
-#include "ishopitem.h"
+#include "shopitem.h"
#include
#include
class SHOPSHARED_EXPORT ISellableService
{
public:
- QList > shopItems() = 0;
+ ISellableService();
+
+ virtual QList > shopItems() = 0;
+ virtual void addedToVoucher(int itemId, int countAdded) = 0;
};
#endif // ISELLABLESERVICE_H
diff --git a/shop/paydvouchersdialog.cpp b/shop/paydvouchersdialog.cpp
index 9bca5d7..b4ee136 100644
--- a/shop/paydvouchersdialog.cpp
+++ b/shop/paydvouchersdialog.cpp
@@ -5,6 +5,7 @@
#include "receiptgenerator.h"
#include "shopservice.h"
+#include "eetbatchdialog.h"
PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
QDialog(parent),
@@ -14,10 +15,30 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
m_voucherModel = new AutoTableModel(this);
m_itemModel = new AutoTableModel(this);
+ m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
+ m_itemModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tableVouchers->setModel(m_voucherModel);
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;
m_voucherModel->setData(srv.paiedVouchers());
@@ -27,6 +48,23 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
m_itemModel->setData(voucher->items());
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->btnSave->setEnabled(true);
});
@@ -59,3 +97,36 @@ void PaydVouchersDialog::on_btnSave_clicked()
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());
+}
+
+void PaydVouchersDialog::on_btnSendEet_clicked()
+{
+ ShopService srv;
+ QList 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);
+ }
+}
diff --git a/shop/paydvouchersdialog.h b/shop/paydvouchersdialog.h
index 973e3f0..9c8f5bf 100644
--- a/shop/paydvouchersdialog.h
+++ b/shop/paydvouchersdialog.h
@@ -24,6 +24,10 @@ private slots:
void on_btnSave_clicked();
+ void on_btnEetNotSen_clicked(bool checked);
+
+ void on_btnSendEet_clicked();
+
private:
Ui::PaydVouchersDialog *ui;
diff --git a/shop/paydvouchersdialog.ui b/shop/paydvouchersdialog.ui
index 8512420..feeb4dd 100644
--- a/shop/paydvouchersdialog.ui
+++ b/shop/paydvouchersdialog.ui
@@ -6,8 +6,8 @@
0
0
- 798
- 514
+ 900
+ 650
@@ -72,6 +72,49 @@
+ -
+
+
+ ...
+
+
+
+ :/icons/filter.svg:/icons/filter.svg
+
+
+
+ 32
+ 32
+
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ ...
+
+
+
+ :/icons/sendEet.svg:/icons/sendEet.svg
+
+
+
+ 32
+ 32
+
+
+
+ true
+
+
+
-
@@ -90,6 +133,12 @@
-
+
+
+ 0
+ 300
+
+
QAbstractItemView::SingleSelection
@@ -110,6 +159,39 @@
+ -
+
+
+
-
+
+
+ EET:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
-
@@ -167,6 +249,7 @@
+
diff --git a/shop/receiptgenerator.cpp b/shop/receiptgenerator.cpp
index 4f513e1..daeafa4 100644
--- a/shop/receiptgenerator.cpp
+++ b/shop/receiptgenerator.cpp
@@ -138,7 +138,13 @@ QByteArray ReceiptGenerator::generate()
out.append("\x1b\x21");
out.append((char)0);
out.append("\x0a");
+ out.append("BKP:");
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");
diff --git a/shop/receiptloadform.cpp b/shop/receiptloadform.cpp
index f293ec3..f00c506 100644
--- a/shop/receiptloadform.cpp
+++ b/shop/receiptloadform.cpp
@@ -30,6 +30,7 @@ ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) :
ui->tabVouchers->setColumnWidth(4, 200);
m_itemModel = new AutoTableModel(this);
+ m_itemModel->setCheckboxSelect(true);
ui->tabItems->setModel(m_itemModel);
ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
@@ -46,6 +47,16 @@ ReceiptLoadForm::~ReceiptLoadForm()
delete ui;
}
+QList ReceiptLoadForm::selectedItems()
+{
+ return m_itemModel->selectedItems();
+}
+
+VoucherPtr ReceiptLoadForm::selectedVoucher()
+{
+ return m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex());
+}
+
void ReceiptLoadForm::on_lineEdit_textChanged(const QString &text)
{
QSortFilterProxyModel proxy;
diff --git a/shop/receiptloadform.h b/shop/receiptloadform.h
index ec022d3..f49954d 100644
--- a/shop/receiptloadform.h
+++ b/shop/receiptloadform.h
@@ -16,6 +16,8 @@ class ReceiptLoadForm : public QDialog
public:
explicit ReceiptLoadForm(QWidget *parent = 0);
~ReceiptLoadForm();
+ QList selectedItems();
+ VoucherPtr selectedVoucher();
private slots:
void on_lineEdit_textChanged(const QString &text);
diff --git a/shop/receiptsaveform.cpp b/shop/receiptsaveform.cpp
index d85e476..a2dc864 100644
--- a/shop/receiptsaveform.cpp
+++ b/shop/receiptsaveform.cpp
@@ -26,18 +26,16 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer voucher, QWidget *paren
m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))));
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tabVouchers->setModel(m_voucherModel);
- ui->tabVouchers->hideColumn(0);
- ui->tabVouchers->hideColumn(1);
+ ui->tabVouchers->hideColumn(3);
+ ui->tabVouchers->hideColumn(4);
ui->tabVouchers->hideColumn(5);
ui->tabVouchers->hideColumn(6);
ui->tabVouchers->hideColumn(7);
ui->tabVouchers->hideColumn(8);
- ui->tabVouchers->hideColumn(9);
ui->tabVouchers->hideColumn(10);
- ui->tabVouchers->hideColumn(12);
- ui->tabVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
- ui->tabVouchers->setColumnWidth(3, 200);
- ui->tabVouchers->setColumnWidth(4, 200);
+ ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
+ ui->tabVouchers->setColumnWidth(0, 190);
+ ui->tabVouchers->setColumnWidth(2, 200);
connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
@@ -47,15 +45,9 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer voucher, QWidget *paren
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
});
+ m_binder.setData(voucher.data());
AddressBookService srvAdb;
- QList comboData;
- foreach (QSharedPointer 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->contact, ComboData::createComboData(srvAdb.all()));
m_binder.registerBinding(ui->name);
m_binder.registerBinding(ui->description);
m_binder.bindToUi();
@@ -74,11 +66,26 @@ ReceiptSaveForm::~ReceiptSaveForm()
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)
{
QSortFilterProxyModel proxy;
proxy.setSourceModel(m_voucherModel);
- proxy.setFilterKeyColumn(2);
+ proxy.setFilterKeyColumn(0);
proxy.setFilterFixedString(text);
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
@@ -111,24 +118,6 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked)
void ReceiptSaveForm::accept()
{
- ShopService srv;
m_binder.bindToData();
- if (m_saveAsNew)
- {
- m_voucher->setStatus(Voucher::NOT_PAID);
- srv.updateVoucher(m_voucher);
- }
- else
- {
- QSharedPointer voucher = m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex());
- foreach (QSharedPointer item, m_voucher->items()) {
- voucher->addItem(item);
- }
-
- srv.calculate(voucher);
- srv.updateVoucher(voucher);
- srv.erase(m_voucher);
- }
-
QDialog::accept();
}
diff --git a/shop/receiptsaveform.h b/shop/receiptsaveform.h
index 663f3c4..09e6175 100644
--- a/shop/receiptsaveform.h
+++ b/shop/receiptsaveform.h
@@ -18,6 +18,9 @@ public:
explicit ReceiptSaveForm(QSharedPointer voucher, QWidget *parent = 0);
~ReceiptSaveForm();
+ VoucherPtr selectedVoucher();
+ bool saveAsNew();
+
private slots:
void on_lineEdit_textChanged(const QString &text);
@@ -28,7 +31,7 @@ private:
ObjectBinder m_binder;
AutoTableModel *m_voucherModel;
bool m_saveAsNew;
- QSharedPointer m_voucher;
+ VoucherPtr m_voucher;
// QDialog interface
public slots:
diff --git a/shop/settings/favoriteservice.cpp b/shop/settings/favoriteservice.cpp
new file mode 100644
index 0000000..b90ace2
--- /dev/null
+++ b/shop/settings/favoriteservice.cpp
@@ -0,0 +1,6 @@
+#include "favoriteservice.h"
+
+FavoriteService::FavoriteService()
+{
+
+}
diff --git a/shop/settings/favoriteservice.h b/shop/settings/favoriteservice.h
new file mode 100644
index 0000000..d99648e
--- /dev/null
+++ b/shop/settings/favoriteservice.h
@@ -0,0 +1,13 @@
+#ifndef FAVORITESERVICE_H
+#define FAVORITESERVICE_H
+
+#include
+#include "data/favorititem.h"
+
+class FavoriteService : public Service
+{
+public:
+ FavoriteService();
+};
+
+#endif // FAVORITESERVICE_H
diff --git a/shop/settings/shopsettings.cpp b/shop/settings/shopsettings.cpp
index 78064d3..38e6ad5 100644
--- a/shop/settings/shopsettings.cpp
+++ b/shop/settings/shopsettings.cpp
@@ -4,6 +4,11 @@ ShopSettings::ShopSettings(QObject *parent) : QObject(parent)
{
m_codepage = ASCII;
m_lettersPerLine = 48;
+
+ m_eetActive = false;
+ m_eetMode = 1;
+ m_eetTest = 0;
+ m_eetPlayground = 0;
}
QString ShopSettings::output() const
@@ -45,3 +50,83 @@ void ShopSettings::setByMessage(const QString &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;
+}
diff --git a/shop/settings/shopsettings.h b/shop/settings/shopsettings.h
index acfb626..d57f892 100644
--- a/shop/settings/shopsettings.h
+++ b/shop/settings/shopsettings.h
@@ -9,6 +9,15 @@ class ShopSettings : public QObject
Q_PROPERTY(int lettersPerLine READ lettersPerLine WRITE setLettersPerLine)
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
public:
@@ -31,11 +40,44 @@ public:
QString byMessage() const;
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:
QString m_output;
CODEPAGE m_codepage;
int m_lettersPerLine;
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 ShopSettingsPtr;
diff --git a/shop/settings/shopsettingsform.cpp b/shop/settings/shopsettingsform.cpp
index 18c2b1d..b919ee9 100644
--- a/shop/settings/shopsettingsform.cpp
+++ b/shop/settings/shopsettingsform.cpp
@@ -2,6 +2,9 @@
#include "ui_shopsettingsform.h"
#include
+#include
+#include
+#include "shopservice.h"
ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
FormBinder(parent),
@@ -12,6 +15,19 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
registerBinding(ui->output);
registerBinding(ui->lettersPerLine);
registerBinding(ui->byMessage);
+
+ registerBinding(ui->eetActive);
+ registerBinding(ui->eetShopId);
+ registerBinding(ui->eetRegisterId);
+ QList 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();
}
ShopSettingsForm::~ShopSettingsForm()
@@ -24,6 +40,10 @@ void ShopSettingsForm::loadEntity()
SettingsService srv("SHOP");
ShopSettingsPtr settings = srv.loadSettings();
setEntity(settings);
+
+ ShopService srvShop;
+ m_itemModel->setData(srvShop.allSellableItems());
+ ui->tableItems->setModel(m_itemModel);
}
bool ShopSettingsForm::saveRecord()
@@ -34,3 +54,13 @@ bool ShopSettingsForm::saveRecord()
return true;
}
+
+void ShopSettingsForm::on_btnCertBrowse_clicked()
+{
+ QString certFile = QFileDialog::getOpenFileName(this, "Certificate file", "", "P12 Files (*.p12)");
+
+ if (!certFile.isEmpty())
+ {
+ ui->eetCertificate->setText(certFile);
+ }
+}
diff --git a/shop/settings/shopsettingsform.h b/shop/settings/shopsettingsform.h
index 42bb46f..ecefb41 100644
--- a/shop/settings/shopsettingsform.h
+++ b/shop/settings/shopsettingsform.h
@@ -4,6 +4,8 @@
#include
#include
#include "shopsettings.h"
+#include
+#include "shopitem.h"
namespace Ui {
class ShopSettingsForm;
@@ -19,6 +21,7 @@ public:
private:
Ui::ShopSettingsForm *ui;
+ AutoTableModel *m_itemModel;
// IForm interface
public:
@@ -26,6 +29,8 @@ public:
public slots:
bool saveRecord();
+private slots:
+ void on_btnCertBrowse_clicked();
};
#endif // SHOPSETTINGSFORM_H
diff --git a/shop/settings/shopsettingsform.ui b/shop/settings/shopsettingsform.ui
index 405dd54..267bd7d 100644
--- a/shop/settings/shopsettingsform.ui
+++ b/shop/settings/shopsettingsform.ui
@@ -6,8 +6,8 @@
0
0
- 608
- 450
+ 645
+ 463
@@ -15,42 +15,340 @@
-
-
-
- Printer
+
+
+ 2
-
-
-
-
-
- Output device
-
-
-
- -
-
-
- -
-
-
- Letters per line
-
-
-
- -
-
-
- -
-
-
- Footer text
-
-
-
- -
-
-
-
+
+
+ Favorite buttons
+
+
+ -
+
+
+ QAbstractItemView::NoEditTriggers
+
+
+ true
+
+
+ QAbstractItemView::DragDrop
+
+
+ QAbstractItemView::SingleSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+ true
+
+
+
+ -
+
+
+
-
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+ Printer
+
+
+ -
+
+
+ Output device
+
+
+
+ -
+
+
+ -
+
+
+ Letters per line
+
+
+
+ -
+
+
+ -
+
+
+ Footer text
+
+
+
+ -
+
+
+
+
+
+
+ EET
+
+
+ -
+
+
+ Activate EET
+
+
+ true
+
+
+ false
+
+
+
-
+
+
+ Shop ID
+
+
+
+ -
+
+
+ -
+
+
+ Cash register ID
+
+
+
+ -
+
+
+ -
+
+
+ EET mode
+
+
+
+ -
+
+
+ -
+
+
+ Certificate file
+
+
+
+ -
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ -
+
+
+ ...
+
+
+
+
+
+
+ -
+
+
+ Private key password
+
+
+
+ -
+
+
+ QLineEdit::Password
+
+
+
+ -
+
+
+ Test mode
+
+
+
+ -
+
+
+ Communication with playground
+
+
+
+
+
+
+
+
diff --git a/shop/shop.json b/shop/shop.json
index 9f54cc6..8b9be10 100644
--- a/shop/shop.json
+++ b/shop/shop.json
@@ -47,6 +47,11 @@ CREATE TABLE \"Voucher\" (
\"totalPriceVatSecondLower\" INTEGER NOT NULL,
\"totalPrice\" INTEGER NOT NULL,
\"status\" INTEGER NOT NULL,
+ \"eetStatus\" INTEGER NOT NULL,
+ \"eetSendDateTime\" TEXT NULL,
+ \"eetPkp\" TEXT,
+ \"eetBkp\" TEXT,
+ \"eetFik\" TEXT,
CONSTRAINT \"contact_fk\"
FOREIGN KEY (\"contact\")
REFERENCES \"AddressbookData\" (\"id\")
@@ -57,6 +62,7 @@ CREATE TABLE \"Voucher\" (
"translations" : {
"CZ" : {
"name" : "Název",
+ "code" : "Kod",
"count" : "Počet",
"unitPrice" : "Jednotková cena",
"vatRate" : "Procento DPH",
@@ -68,6 +74,7 @@ CREATE TABLE \"Voucher\" (
"vatRateHigh" : "Vysoká sazba",
"vatRateFirstLower" : "První snížená sazba",
"vatRateSecondLower" : "Druhá snížená sazba",
+ "vatAmount" : "Dan",
"priceNoVat" : "Cena zboží s nulovou DPH",
"priceVatHigh" : "Cena zboží s vysokou 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",
"totalPriceVatSecondLower" : "Celková cena zboží s druhou sníženou sazbou DPH",
"totalPrice" : "Celková cena",
- "status" : "Stav"
+ "status" : "Stav",
+ "numSer" : "Číslo",
+ "payDateTime" : "Datum"
}
}
}
diff --git a/shop/shop.pro b/shop/shop.pro
index 3bcd021..5ec558b 100644
--- a/shop/shop.pro
+++ b/shop/shop.pro
@@ -26,7 +26,12 @@ SOURCES += shop.cpp \
settings/shopsettings.cpp \
settings/shopsettingsform.cpp \
paydialog.cpp \
- paydvouchersdialog.cpp
+ paydvouchersdialog.cpp \
+ shopitem.cpp \
+ isellableservice.cpp \
+ data/favorititem.cpp \
+ settings/favoriteservice.cpp \
+ eetbatchdialog.cpp
HEADERS += shop.h\
shop_global.h \
@@ -46,7 +51,11 @@ HEADERS += shop.h\
settings/shopsettings.h \
settings/shopsettingsform.h \
paydialog.h \
- paydvouchersdialog.h
+ paydvouchersdialog.h \
+ shopitem.h \
+ data/favorititem.h \
+ settings/favoriteservice.h \
+ eetbatchdialog.h
unix {
target.path = /usr/lib
@@ -72,6 +81,7 @@ else:unix: LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
INCLUDEPATH += $$PWD/../addressbook/data
INCLUDEPATH += $$PWD/../addressbook
+INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/../addressbook
DESTDIR = ../plugins
@@ -80,7 +90,7 @@ OTHER_FILES += shop.json
ODB_FILES = shop/data/shop-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)
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
@@ -102,6 +112,12 @@ FORMS += \
receiptloadform.ui \
settings/shopsettingsform.ui \
paydialog.ui \
- paydvouchersdialog.ui
+ paydvouchersdialog.ui \
+ eetbatchdialog.ui
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
diff --git a/shop/shopform.cpp b/shop/shopform.cpp
index 6ff678b..5a2b756 100644
--- a/shop/shopform.cpp
+++ b/shop/shopform.cpp
@@ -8,8 +8,12 @@
#include "receiptgenerator.h"
#include "paydialog.h"
#include "paydvouchersdialog.h"
+#include "isellableservice.h"
#include
#include
+#include
+#include
+
#include "shop-odb.hxx"
ShopForm::ShopForm(QWidget *parent) :
@@ -18,6 +22,7 @@ ShopForm::ShopForm(QWidget *parent) :
{
ui->setupUi(this);
m_itemsModel = NULL;
+ m_commodityModel = NULL;
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
@@ -50,10 +55,29 @@ void ShopForm::loadLast()
connectItemSignals();
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
- ui->temporarySaveButton->setEnabled(true);
- ui->saveButton->setEnabled(true);
- ui->payButton->setEnabled(true);
+
+ if (!m_voucher->items().isEmpty())
+ {
+ ui->temporarySaveButton->setEnabled(true);
+ ui->saveButton->setEnabled(true);
+ ui->payButton->setEnabled(true);
+ }
+ }
+
+ if (m_commodityModel == NULL)
+ {
+ m_commodityModel = new AutoTableModel(this);
+ m_commodityModel->setTranslations(Context::instance().plugin("SHOP")->translations());
+ ui->commodityTable->setModel(m_commodityModel);
+
+ connect(ui->commodityTable->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex ¤t, 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()
@@ -84,11 +108,7 @@ void ShopForm::on_directSale_clicked()
form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this, form](){
- ShopService srv;
- 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();
+ addItem(form->shopItem(), ((DirectSaleItem*)form->shopItem().data())->count());
});
form->show();
@@ -104,10 +124,25 @@ void ShopForm::on_saveButton_clicked()
ReceiptSaveForm *form = new ReceiptSaveForm(m_voucher, this);
form->setAttribute(Qt::WA_DeleteOnClose);
- connect(form, &QDialog::accepted, [this]() {
- createEmptyVoucher();
+ connect(form, &QDialog::accepted, [this, form]() {
+ ShopService srv;
+
+ if (form->saveAsNew())
+ {
+ m_voucher->setStatus(Voucher::NOT_PAID);
+ srv.saveVoucher(m_voucher);
+ 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());
- ui->total->setText("0");
});
form->show();
@@ -117,10 +152,27 @@ void ShopForm::on_loadButton_clicked()
{
ReceiptLoadForm *form = new ReceiptLoadForm(this);
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();
}
-void ShopForm::onCountChanged()
+void ShopForm::onCountChanged(int oldCount/* = 0*/)
{
VoucherItem *item = qobject_cast(sender());
if (item != NULL && item->count() == 0)
@@ -150,6 +202,12 @@ void ShopForm::onCountChanged()
{
srv.updateVoucher(m_voucher);
}
+
+ if (item != NULL)
+ {
+ int countAdded = item->count() - oldCount;
+ srv.updateRelatedItem(item, countAdded);
+ }
}
void ShopForm::createVoucher()
@@ -212,7 +270,7 @@ void ShopForm::changeReceipt()
void ShopForm::connectItemSignals()
{
foreach (QSharedPointer 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);
}
+void ShopForm::addItem(QSharedPointer 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)
{
if (!m_voucher.isNull() && m_voucher->items().isEmpty())
@@ -256,6 +323,29 @@ void ShopForm::on_payButton_clicked()
connect(dialog, &QDialog::accepted, [this](){
ShopService srv;
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;
generator.setVoucher(m_voucher);
@@ -274,3 +364,42 @@ void ShopForm::on_showPaiedButton_clicked()
dialog->setAttribute(Qt::WA_DeleteOnClose);
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);
+ }
+ }
+}
diff --git a/shop/shopform.h b/shop/shopform.h
index 36cb250..d26d4ff 100644
--- a/shop/shopform.h
+++ b/shop/shopform.h
@@ -6,6 +6,9 @@
#include "data/shop-data.h"
#include
+class ShopItem;
+class IShopItem;
+
namespace Ui {
class ShopForm;
}
@@ -29,7 +32,7 @@ private slots:
void on_loadButton_clicked();
- void onCountChanged();
+ void onCountChanged(int oldCount = 0);
void on_receiptCombo_currentIndexChanged(int index);
@@ -37,16 +40,22 @@ private slots:
void on_showPaiedButton_clicked();
+ void on_btnAddItem_clicked();
+
+ void on_commoditySearch_textChanged(const QString &text);
+
private:
Ui::ShopForm *ui;
QSharedPointer m_voucher;
AutoTableModel *m_itemsModel;
+ AutoTableModel *m_commodityModel;
void createVoucher();
void doTempSave(bool comboChanged);
void changeReceipt();
void connectItemSignals();
void createEmptyVoucher();
+ void addItem(QSharedPointer item, int count);
};
#endif // SHOPFORM_H
diff --git a/shop/shopform.ui b/shop/shopform.ui
index 56dceaf..270547c 100644
--- a/shop/shopform.ui
+++ b/shop/shopform.ui
@@ -7,7 +7,7 @@
0
0
959
- 582
+ 643
@@ -55,7 +55,14 @@
-
-
+
+
+ QAbstractItemView::SingleSelection
+
+
+ QAbstractItemView::SelectRows
+
+
-
@@ -68,7 +75,7 @@
-
-
+
false
@@ -78,13 +85,23 @@
false
+
+ 1
+
-
-
+
+
+ false
+
Add Item
+
+
+ :/icons/new.svg:/icons/new.svg
+
@@ -114,6 +131,11 @@
-
+
+
+ 10
+
+
Direct Sale
@@ -160,7 +182,82 @@
0
-
-
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
@@ -183,8 +280,96 @@
0
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
-
-
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+ ...
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
@@ -386,8 +571,8 @@
-
+
diff --git a/shop/shopitem.cpp b/shop/shopitem.cpp
new file mode 100644
index 0000000..541aaac
--- /dev/null
+++ b/shop/shopitem.cpp
@@ -0,0 +1,6 @@
+#include "shopitem.h"
+
+ShopItem::ShopItem(QObject *parent) : QObject(parent)
+{
+
+}
diff --git a/shop/shopitem.h b/shop/shopitem.h
new file mode 100644
index 0000000..0f03f44
--- /dev/null
+++ b/shop/shopitem.h
@@ -0,0 +1,37 @@
+#ifndef SHOPITEM_H
+#define SHOPITEM_H
+
+#include
+
+#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 ShopItemPtr;
+
+#endif // SHOPITEM_H
diff --git a/shop/shoprc.qrc b/shop/shoprc.qrc
index 77a3ead..6a447f7 100644
--- a/shop/shoprc.qrc
+++ b/shop/shoprc.qrc
@@ -5,5 +5,6 @@
icons/tempSave.svg
icons/paied.svg
icons/pay.svg
+ icons/sendEet.svg
diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp
index 15e52a4..8af8217 100644
--- a/shop/shopservice.cpp
+++ b/shop/shopservice.cpp
@@ -1,19 +1,25 @@
#include "shopservice.h"
#include "numberseriesservice.h"
+#include "isellableservice.h"
#include "shop-odb.hxx"
+#include "settings/shopsettings.h"
+
+#include
+#include
+
ShopService::ShopService()
{
}
-QSharedPointer ShopService::createVoucher()
+VoucherPtr ShopService::createVoucher()
{
QSharedPointer voucher(new Voucher);
voucher->setStatus(Voucher::NEW);
return voucher;
}
-void ShopService::addShopItem(QSharedPointer voucher, QSharedPointer item, int count)
+void ShopService::addShopItem(VoucherPtr voucher, QSharedPointer item, int count)
{
QSharedPointer vItem(new VoucherItem);
vItem->setName(item->name());
@@ -24,9 +30,11 @@ void ShopService::addShopItem(QSharedPointer voucher, QSharedPointersetVatType(item->vatType());
voucher->addItem(vItem);
+
+ updateRelatedItem(vItem.data(), count);
}
-void ShopService::calculate(QSharedPointer voucher)
+void ShopService::calculate(VoucherPtr voucher)
{
QDecDouble total;
@@ -65,7 +73,7 @@ void ShopService::calculate(QSharedPointer voucher)
voucher->setTotalPrice(total);
}
-void ShopService::calculateItem(QSharedPointer item)
+void ShopService::calculateItem(VoucherItemPtr item)
{
loadSettings();
if (m_gs->vatPayer())
@@ -81,13 +89,13 @@ void ShopService::calculateItem(QSharedPointer item)
}
}
-void ShopService::loadItems(QSharedPointer voucher)
+void ShopService::loadItems(VoucherPtr voucher)
{
Service srv;
voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id())));
}
-void ShopService::pay(QSharedPointer voucher)
+void ShopService::pay(VoucherPtr voucher)
{
Transaction tx;
NumberSeriesService srvNs;
@@ -98,6 +106,7 @@ void ShopService::pay(QSharedPointer voucher)
voucher->setNumSer(numSerStr);
voucher->setStatus(Voucher::PAID);
+ voucher->setEetStatus(Voucher::EET_FOR_SEND);
voucher->setPayDateTime(QDateTime::currentDateTime());
this->update(voucher);
@@ -105,21 +114,180 @@ void ShopService::pay(QSharedPointer voucher)
tx.commit();
}
-QList > ShopService::savedVouchers()
+void ShopService::updateRelatedItem(VoucherItem* item, int countAdded)
+{
+ IPlugin *plugin = Context::instance().plugin(item->itemPlugin());
+ IService *srv = (plugin != NULL ? plugin->service() : NULL);
+ ISellableService *selSrv = dynamic_cast(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();
+
+ 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();
+ return settings->eetActive();
+}
+
+void ShopService::moveItems(QList 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 ShopService::savedVouchers()
{
return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)));
}
-QList > ShopService::tempVouchers()
+QList ShopService::tempVouchers()
{
return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY)));
}
-QList > ShopService::paiedVouchers()
+QList ShopService::paiedVouchers()
{
return all(QString("status = %1").arg(QString::number(Voucher::PAID)));
}
+QList 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 ShopService::allSellableItems()
+{
+ QList > items;
+ foreach (IPlugin *plugin, Context::instance().plugins()) {
+ IService *srv = plugin->service();
+ ISellableService *selSrv = dynamic_cast(srv);
+
+ if (selSrv != NULL)
+ {
+ items.append(selSrv->shopItems());
+ }
+ }
+
+ return items;
+}
+
QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType)
{
return price * ((vatRate(vatType) / 100) + QDecDouble(1));
@@ -159,7 +327,7 @@ QDecDouble ShopService::vatRate(Enums::VatType vatType)
return vatRate;
}
-void ShopService::saveVoucher(QSharedPointer entity)
+void ShopService::saveVoucher(VoucherPtr entity)
{
Transaction tr;
odb::database *db = Context::instance().db();
@@ -174,7 +342,7 @@ void ShopService::saveVoucher(QSharedPointer entity)
tr.commit();
}
-void ShopService::updateVoucher(QSharedPointer entity)
+void ShopService::updateVoucher(VoucherPtr entity)
{
Transaction tr;
odb::database *db = Context::instance().db();
diff --git a/shop/shopservice.h b/shop/shopservice.h
index 0c626d1..2a622bb 100644
--- a/shop/shopservice.h
+++ b/shop/shopservice.h
@@ -7,21 +7,29 @@
#include
#include "data/shop-data.h"
-#include "ishopitem.h"
+#include "shopitem.h"
class ShopService : public Service
{
public:
ShopService();
- QSharedPointer createVoucher();
- void addShopItem(QSharedPointer voucher, QSharedPointer item, int count);
- void calculate(QSharedPointer voucher);
- void calculateItem(QSharedPointer item);
- void loadItems(QSharedPointer voucher);
- void pay(QSharedPointer voucher);
- QList > savedVouchers();
- QList > tempVouchers();
- QList > paiedVouchers();
+ VoucherPtr createVoucher();
+ void addShopItem(VoucherPtr voucher, QSharedPointer item, int count);
+ void calculate(VoucherPtr voucher);
+ void calculateItem(VoucherItemPtr item);
+ void loadItems(VoucherPtr voucher);
+ void pay(VoucherPtr voucher);
+ void moveItems(QList items, VoucherPtr source, VoucherPtr target);
+ void updateRelatedItem(VoucherItem* item, int countAdded);
+ bool processEet(VoucherPtr voucher, QString &message);
+ void setEetOnline(bool online);
+ bool isEetOnline();
+ bool isEetEnabled();
+ QList savedVouchers();
+ QList tempVouchers();
+ QList paiedVouchers();
+ QList vouchersForEet();
+ QList allSellableItems();
private:
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);
@@ -31,8 +39,8 @@ private:
QDecDouble vatRate(Enums::VatType vatType);
public:
- void saveVoucher(QSharedPointer entity);
- void updateVoucher(QSharedPointer entity);
+ void saveVoucher(VoucherPtr entity);
+ void updateVoucher(VoucherPtr entity);
};
#endif // SHOPSERVICE_H
diff --git a/shop/translations/shop_cs_CZ.ts b/shop/translations/shop_cs_CZ.ts
new file mode 100644
index 0000000..c92efdf
--- /dev/null
+++ b/shop/translations/shop_cs_CZ.ts
@@ -0,0 +1,319 @@
+
+
+
+
+ DirectSaleForm
+
+
+
+ Zboží
+
+
+
+
+ Název
+
+
+
+
+ Cena
+
+
+
+
+ Počet
+
+
+
+
+ Sazba DPH
+
+
+
+
+ Žádná
+
+
+
+
+ Vysoká
+
+
+
+
+ První snížená
+
+
+
+
+ Druhá snížená
+
+
+
+ PayDialog
+
+
+
+
+
+
+
+
+ Celkem:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PaydVouchersDialog
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Položky
+
+
+
+
+ Celkem:
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ReceiptLoadForm
+
+
+
+
+
+
+
+
+ Účtenky
+
+
+
+
+ Hledat
+
+
+
+
+ Položky
+
+
+
+ ReceiptSaveForm
+
+
+
+ Přidat k již uložené
+
+
+
+
+ Hledat
+
+
+
+ Uložit novou
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Název
+
+
+
+
+ Popis
+
+
+
+
+ Vyhledat kontakt
+
+
+
+ ShopForm
+
+
+
+
+
+
+
+
+ Zboží
+
+
+
+
+ Počet
+
+
+
+
+ Přidat položku
+
+
+
+
+ Přímý prodej
+
+
+
+
+
+
+
+
+
+ Účtenka
+
+
+
+
+ Celkem:
+
+
+
+
+
+
+
+
+
+ Dočasné uložení
+
+
+
+
+ Uložení
+
+
+
+
+ Načíst
+
+
+
+
+
+
+
+
+
+ Zaplatit
+
+
+
+
+
+
+
+
+ ShopSettingsForm
+
+
+
+ Zboží
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TemporaryReceiptSaveForm
+
+
+
+ Dočasné uložení
+
+
+
+
+ Název dočasně uložené účtenky
+
+
+