Josef Rokos 8 years ago
commit b9fe3aab37

@ -5,5 +5,6 @@
<file>style.css</file>
<file>icons/settings.svg</file>
<file>translations/prodejna_cs_CZ.qm</file>
<file>icons/shop.ico</file>
</qresource>
</RCC>

@ -22,6 +22,8 @@ win32 {
INCLUDEPATH += $$ODB_INCLUDE_PREFIX/libodb-qt-2.4.0
INCLUDEPATH += $$ODB_INCLUDE_PREFIX/libodb-sqlite-2.4.0
INCLUDEPATH += $$ODB_INCLUDE_PREFIX/sqlite
RC_FILE = shop.rc
}
SOURCES += main.cpp\
@ -61,3 +63,6 @@ RESOURCES += \
appRc.qrc
TRANSLATIONS = translations/prodejna_cz.ts
DISTFILES += \
shop.rc

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@ -59,7 +59,7 @@
</spacer>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<widget class="QWidget" name="widget1" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget_2" native="true">

@ -19,7 +19,7 @@ int main(int argc, char *argv[])
MainWindow w;
w.move(QApplication::desktop()->screen()->rect().center() - w.rect().center());
w.show();
w.showMaximized();
return a.exec();
}

@ -13,6 +13,10 @@
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset resource="appRc.qrc">
<normaloff>:/icons/shop.ico</normaloff>:/icons/shop.ico</iconset>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
@ -56,12 +60,12 @@
<x>0</x>
<y>0</y>
<width>1000</width>
<height>21</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
<string>Fi&amp;le</string>
</property>
<addaction name="actionOpen_database"/>
<addaction name="actionLogin"/>
@ -83,12 +87,12 @@
<widget class="QStatusBar" name="statusBar"/>
<action name="actionExit">
<property name="text">
<string>Exit</string>
<string>&amp;Exit</string>
</property>
</action>
<action name="actionOpen_database">
<property name="text">
<string>Open database...</string>
<string>&amp;Open database...</string>
</property>
</action>
<action name="actionLogin">
@ -97,7 +101,7 @@
<normaloff>:/icons/login_32.png</normaloff>:/icons/login_32.png</iconset>
</property>
<property name="text">
<string>Login...</string>
<string>&amp;Login...</string>
</property>
</action>
<action name="actionSettings">

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "shop.ico"

@ -18,5 +18,6 @@
#navigation QToolButton {
color: white;
font-weight: bold;
min-width: 80px;
min-width: 90px;
font: 10pt;
}

@ -20,31 +20,47 @@
<message>
<location filename="../mainwindow.ui" line="14"/>
<source>MainWindow</source>
<translation type="unfinished">Prodejna</translation>
<translation>Prodejna</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="68"/>
<source>Fi&amp;le</source>
<translation>&amp;Soubor</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="90"/>
<source>&amp;Exit</source>
<translation>&amp;Konec</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="95"/>
<source>&amp;Open database...</source>
<translation>&amp;Otevřít databázi...</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="104"/>
<source>&amp;Login...</source>
<translation>&amp;Přihlásit...</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="64"/>
<source>File</source>
<translation>Soubor</translation>
<translation type="vanished">Soubor</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="86"/>
<source>Exit</source>
<translation>Konec</translation>
<translation type="vanished">Konec</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="91"/>
<source>Open database...</source>
<translation>Otevřít databázi...</translation>
<translation type="vanished">Otevřít databázi...</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="100"/>
<source>Login...</source>
<translation>Přihlásit se...</translation>
<translation type="vanished">Přihlásit se...</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="109"/>
<location filename="../mainwindow.ui" line="112"/>
<location filename="../mainwindow.ui" line="113"/>
<location filename="../mainwindow.ui" line="116"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>

@ -2,7 +2,7 @@
"MetaData" : {
"id" : "CORE_ROLES",
"name" : {
"default" : "Core Roles plugin",
"default" : "Roles",
"CZ" : "Role"
},
"description" : {

Binary file not shown.

@ -128,7 +128,7 @@
<message>
<location filename="../settings/globalsettingsform.ui" line="33"/>
<source>Base settings</source>
<translation type="unfinished"></translation>
<translation>Hlavní nastavení</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="121"/>
@ -174,22 +174,22 @@
<location filename="../settings/globalsettingsform.ui" line="218"/>
<location filename="../settings/globalsettingsform.ui" line="279"/>
<source>Number series</source>
<translation type="unfinished"></translation>
<translation>Číselné řady</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="247"/>
<source>Edit name</source>
<translation type="unfinished"></translation>
<translation>Upravit název</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="258"/>
<source>Season</source>
<translation type="unfinished"></translation>
<translation>Sezóna</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="265"/>
<source>Create new</source>
<translation type="unfinished"></translation>
<translation>Vytvořit novou</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="39"/>
@ -235,22 +235,22 @@
<message>
<location filename="../settings/globalsettingsform.cpp" line="77"/>
<source>Switch season</source>
<translation type="unfinished"></translation>
<translation>Změna sezóny</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.cpp" line="77"/>
<source>Realy switch active season?</source>
<translation type="unfinished"></translation>
<translation>Opravdu si přejete změnit aktivní sezónu?</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.cpp" line="138"/>
<source>New season</source>
<translation type="unfinished"></translation>
<translation>Nová sezóna</translation>
</message>
<message>
<location filename="../settings/globalsettingsform.cpp" line="138"/>
<source>Realy create new season and switch to it?</source>
<translation type="unfinished"></translation>
<translation>Opravdu si přejete vytvořit novou sezónu a přepnout na ni?</translation>
</message>
</context>
<context>
@ -365,12 +365,12 @@
<message>
<location filename="../settings/seasonnamedialog.ui" line="14"/>
<source>Season</source>
<translation type="unfinished"></translation>
<translation>Sezóna</translation>
</message>
<message>
<location filename="../settings/seasonnamedialog.ui" line="23"/>
<source>Season name</source>
<translation type="unfinished"></translation>
<translation>Název sezóny</translation>
</message>
</context>
<context>

@ -2,7 +2,7 @@
"MetaData" : {
"id" : "CORE_USERS",
"name" : {
"default" : "Core Users plugin",
"default" : "Users",
"CZ" : "Uživatelé"
},
"description" : {

@ -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;

@ -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<QSharedPointer<VoucherItem> > m_items;
VoucherStatus m_status;

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>150</height>
<height>184</height>
</rect>
</property>
<property name="windowTitle">
@ -33,6 +33,9 @@
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="unitPrice">
<property name="minimum">
<double>-9999999999999.000000000000000</double>
</property>
<property name="maximum">
<double>9999999999.989999771118164</double>
</property>

@ -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

@ -1,5 +1,6 @@
#include "paydialog.h"
#include "ui_paydialog.h"
#include "shopservice.h"
PayDialog::PayDialog(QDecDouble total, QWidget *parent) :
QDialog(parent),
@ -10,6 +11,10 @@ PayDialog::PayDialog(QDecDouble total, QWidget *parent) :
ui->labelTotal->setText(QString::number(total.toDouble(), 'f', 2));
ui->labelReturn->setText(QString::number(0, 'f', 2));
ui->recieved->setFocus();
ShopService srv;
ui->checkEet->setVisible(srv.isEetEnabled());
}
PayDialog::~PayDialog()
@ -17,6 +22,11 @@ PayDialog::~PayDialog()
delete ui;
}
bool PayDialog::sendToEet()
{
return ui->checkEet->checkState() == Qt::Checked;
}
void PayDialog::on_recieved_valueChanged(double value)
{

@ -15,6 +15,7 @@ class PayDialog : public QDialog
public:
explicit PayDialog(QDecDouble total, QWidget *parent = 0);
~PayDialog();
bool sendToEet();
private slots:

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>134</height>
<width>457</width>
<height>168</height>
</rect>
</property>
<property name="windowTitle">
@ -105,7 +105,7 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="enabled">
<bool>false</bool>
@ -118,6 +118,19 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkEet">
<property name="text">
<string>Send to EET portal</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

@ -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<Voucher>(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->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<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_btnEetNotSen_clicked(bool checked);
void on_btnSendEet_clicked();
private:
Ui::PaydVouchersDialog *ui;

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>798</width>
<height>514</height>
<width>900</width>
<height>650</height>
</rect>
</property>
<property name="windowTitle">
@ -72,6 +72,49 @@
</property>
</widget>
</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>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -90,6 +133,12 @@
</item>
<item>
<widget class="QTableView" name="tableVouchers">
<property name="minimumSize">
<size>
<width>0</width>
<height>300</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
@ -110,6 +159,39 @@
</layout>
</widget>
</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>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
@ -167,6 +249,7 @@
</layout>
</widget>
<resources>
<include location="shoprc.qrc"/>
<include location="../core/rc.qrc"/>
</resources>
<connections/>

@ -5,6 +5,11 @@
#include <QTextCodec>
#include <QFile>
#ifdef _WIN32
#include <Windows.h>
#include <winspool.h>
#endif
const QString ReceiptGenerator::DIACRITIC = "ÂâÁáÄäĂ㥹ĆćČčÇçĎďĐđÉéËëĚěĘęÍíÎîĹ弾ŁłŃńŇňÓóÖöÔôŐőŔŕŘřŚśŠšŞşŤťŢţÚúÜüŮůŰűÝýŹźŽžŻż";
const QString ReceiptGenerator::NON_DIACRITIC = "AaAaAaAaAaCcCcCcDdDdEeEeEeEeIiIiLlLlLlNnNnOoOoOoOoRrRrSsSsSsTtTtUuUuUuUuYyZzZzZz";
@ -43,7 +48,48 @@ void ReceiptGenerator::save()
void ReceiptGenerator::print()
{
#ifdef _WIN32
SettingsService srvShopSettings("SHOP");
ShopSettingsPtr shopSettings = srvShopSettings.loadSettings<ShopSettings>();
QString printer = shopSettings->output();
HANDLE hPrinter;
DOC_INFO_1 docInfo;
DWORD dwJob;
DWORD dwBytes;
BOOL bStatus = FALSE;
if (OpenPrinter((LPWSTR)printer.toStdWString().c_str(), &hPrinter, NULL))
{
docInfo.pDocName = L"Uctenka";
docInfo.pOutputFile = NULL;
docInfo.pDatatype = L"RAW";
dwJob = StartDocPrinter(hPrinter, 1, (LPBYTE)&docInfo);
if (dwJob > 0)
{
if (!StartPagePrinter(hPrinter))
{
ClosePrinter(hPrinter);
return;
}
QByteArray data = generate();
BOOL bPrinted = WritePrinter(hPrinter, (LPBYTE)data.data(), data.length(), &dwBytes);
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
if (!bPrinted)
{
DWORD dwErr = GetLastError();
int i = 1;
}
}
}
ClosePrinter(hPrinter);
#else
save();
#endif
}
QString ReceiptGenerator::outputFile() const
@ -77,6 +123,12 @@ QByteArray ReceiptGenerator::generate()
out.append("\x0a");
out.append(prepareString("IC: " + QString::number(gs->ic())));
out.append("\x0a");
out.append(prepareString("DIC: " + gs->dic()));
out.append("\x0a");
out.append(prepareString("ID provozovny: " + shopSettings->eetShopId()));
out.append("\x0a");
out.append(prepareString("ID pokladny: " + shopSettings->eetRegisterId()));
out.append("\x0a");
out.append("\x1b\x21");
out.append(printMode);
@ -89,12 +141,14 @@ QByteArray ReceiptGenerator::generate()
out.append("\x0a");
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
QString count = QString::number(item->count());
QString name = item->name();
QString price = QString::number(item->price().toDouble(), 'f', 2);
int numSpaces = 0;
if ((name.length() + price.length()) < shopSettings->lettersPerLine())
{
name = count + "x " + name;
numSpaces = shopSettings->lettersPerLine() - (name.length() + price.length());
out.append(prepareString(name));
}
@ -125,7 +179,7 @@ QByteArray ReceiptGenerator::generate()
out.append("\x1b\x21");
out.append(printMode);
out.append("Celekem:");
out.append("Celkem:");
QString totalPrice = QString::number(m_voucher->totalPrice().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (8 + totalPrice.length());
@ -138,7 +192,18 @@ QByteArray ReceiptGenerator::generate()
out.append("\x1b\x21");
out.append((char)0);
out.append("\x0a");
out.append("\x0a");
if (!m_voucher->eetBkp().isEmpty())
{
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");
out.append("\x0a");
out.append("\x0a");

@ -16,20 +16,23 @@ ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) :
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(3);
ui->tabVouchers->hideColumn(4);
ui->tabVouchers->hideColumn(0);
ui->tabVouchers->hideColumn(1);
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->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->tabVouchers->setColumnWidth(0, 190);
ui->tabVouchers->setColumnWidth(2, 200);
ui->tabVouchers->hideColumn(12);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
ui->tabVouchers->setColumnWidth(3, 200);
ui->tabVouchers->setColumnWidth(4, 200);
m_itemModel = new AutoTableModel<VoucherItem>(this);
m_itemModel->setCheckboxSelect(true);
ui->tabItems->setModel(m_itemModel);
ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, QModelIndex){
ShopService srv;
@ -58,7 +61,7 @@ void ReceiptLoadForm::on_lineEdit_textChanged(const QString &text)
{
QSortFilterProxyModel proxy;
proxy.setSourceModel(m_voucherModel);
proxy.setFilterKeyColumn(0);
proxy.setFilterKeyColumn(2);
proxy.setFilterFixedString(text);
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));

@ -31,7 +31,14 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QTableView" name="tabVouchers"/>
<widget class="QTableView" name="tabVouchers">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>
</widget>

@ -45,7 +45,7 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
});
m_binder.setData(new Voucher);
m_binder.setData(voucher.data());
AddressBookService srvAdb;
m_binder.registerBinding(ui->contact, ComboData::createComboData(srvAdb.all()));
m_binder.registerBinding(ui->name);
@ -66,6 +66,21 @@ 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;

@ -18,6 +18,9 @@ public:
explicit ReceiptSaveForm(QSharedPointer<Voucher> 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<Voucher> *m_voucherModel;
bool m_saveAsNew;
QSharedPointer<Voucher> m_voucher;
VoucherPtr m_voucher;
// QDialog interface
public slots:

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>804</width>
<height>513</height>
<height>578</height>
</rect>
</property>
<property name="windowTitle">
@ -51,6 +51,12 @@
<height>250</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>

@ -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;
}

@ -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<ShopSettings> ShopSettingsPtr;

@ -2,6 +2,8 @@
#include "ui_shopsettingsform.h"
#include <settingsservice.h>
#include <combodata.h>
#include <QFileDialog>
#include "shopservice.h"
ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
@ -14,6 +16,17 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
registerBinding(ui->lettersPerLine);
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>();
}
@ -41,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);
}
}

@ -29,6 +29,8 @@ public:
public slots:
bool saveRecord();
private slots:
void on_btnCertBrowse_clicked();
};
#endif // SHOPSETTINGSFORM_H

@ -234,6 +234,121 @@
</item>
</layout>
</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>
</layout>

@ -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\")
@ -69,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",
@ -78,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"
}
}
}

@ -29,7 +29,8 @@ SOURCES += shop.cpp \
shopitem.cpp \
isellableservice.cpp \
data/favorititem.cpp \
settings/favoriteservice.cpp
settings/favoriteservice.cpp \
eetbatchdialog.cpp
HEADERS += shop.h\
shop_global.h \
@ -52,7 +53,8 @@ HEADERS += shop.h\
paydvouchersdialog.h \
shopitem.h \
data/favorititem.h \
settings/favoriteservice.h
settings/favoriteservice.h \
eetbatchdialog.h
include(../config_plugin.pri)
@ -74,7 +76,8 @@ FORMS += \
receiptloadform.ui \
settings/shopsettingsform.ui \
paydialog.ui \
paydvouchersdialog.ui
paydvouchersdialog.ui \
eetbatchdialog.ui
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
@ -86,3 +89,8 @@ INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/../addressbook
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

@ -12,6 +12,7 @@
#include <QList>
#include <QSharedPointer>
#include <QSortFilterProxyModel>
#include <QMessageBox>
#include "shop-odb.hxx"
@ -54,9 +55,13 @@ 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)
@ -73,6 +78,16 @@ void ShopForm::loadLast()
m_commodityModel->setData(srv.allSellableItems());
ui->commodityTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->commodityTable->setColumnHidden(3, true);
if (srv.isEetEnabled())
{
ui->lblEetState->setText(srv.isEetOnline() ? tr("<a href=\"#eet\">Online</a>") : tr("<a href=\"#eet\">Offline</a>"));
}
else
{
ui->labelEete->setVisible(false);
ui->lblEetState->setVisible(false);
}
}
void ShopForm::fillRaceiptCombo()
@ -119,13 +134,25 @@ void ShopForm::on_saveButton_clicked()
ReceiptSaveForm *form = new ReceiptSaveForm(m_voucher, this);
form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this]() {
connect(form, &QDialog::accepted, [this, form]() {
ShopService srv;
m_voucher->setStatus(Voucher::NOT_PAID);
srv.saveVoucher(m_voucher);
m_voucher = srv.createVoucher();
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();
@ -303,9 +330,35 @@ void ShopForm::on_payButton_clicked()
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
connect(dialog, &QDialog::accepted, [this](){
connect(dialog, &QDialog::accepted, [this, dialog](){
ShopService srv;
srv.pay(m_voucher);
m_voucher->setEetStatus(dialog->sendToEet() ? Voucher::EET_FOR_SEND : Voucher::EET_NOT_ENTERING);
srv.update(m_voucher);
QString eetMsg;
if (srv.isEetEnabled() && dialog->sendToEet())
{
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);
ui->lblEetState->setText(srv.isEetOnline() ? tr("<a href=\"#eet\">Online</a>") : tr("<a href=\"#eet\">Offline</a>"));
}
}
}
ReceiptGenerator generator;
generator.setVoucher(m_voucher);
@ -341,6 +394,7 @@ void ShopForm::on_commoditySearch_textChanged(const QString &text)
QSortFilterProxyModel proxy;
proxy.setSourceModel(m_commodityModel);
proxy.setFilterKeyColumn(0);
proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);
proxy.setFilterFixedString(text);
auto moveToIndex = [this](const QModelIndex &matchingIndex) {
@ -363,3 +417,11 @@ void ShopForm::on_commoditySearch_textChanged(const QString &text)
}
}
}
void ShopForm::on_lblEetState_linkActivated(const QString &link)
{
ShopService srv;
srv.setEetOnline(!srv.isEetOnline());
ui->lblEetState->setText(srv.isEetOnline() ? tr("<a href=\"#eet\">Online</a>") : tr("<a href=\"#eet\">Offline</a>"));
}

@ -44,6 +44,8 @@ private slots:
void on_commoditySearch_textChanged(const QString &text);
void on_lblEetState_linkActivated(const QString &link);
private:
Ui::ShopForm *ui;
QSharedPointer<Voucher> m_voucher;

@ -37,12 +37,6 @@
</property>
<item>
<widget class="QWidget" name="widgetComodity" native="true">
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="commodity">
@ -399,6 +393,35 @@
<item>
<widget class="QWidget" name="widget_7" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelEete">
<property name="text">
<string>EET status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblEetState">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>&lt;a href=&quot;#eet&quot;&gt;dfghdfg&lt;/a&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -526,7 +549,7 @@
</font>
</property>
<property name="text">
<string>Show paied</string>
<string>Show paid</string>
</property>
<property name="icon">
<iconset resource="shoprc.qrc">

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

@ -3,6 +3,11 @@
#include "isellableservice.h"
#include "shop-odb.hxx"
#include "settings/shopsettings.h"
#include <eetcpp.h>
#include <QEventLoop>
ShopService::ShopService()
{
}
@ -101,6 +106,7 @@ void ShopService::pay(VoucherPtr voucher)
voucher->setNumSer(numSerStr);
voucher->setStatus(Voucher::PAID);
voucher->setEetStatus(Voucher::EET_FOR_SEND);
voucher->setPayDateTime(QDateTime::currentDateTime());
this->update(voucher);
@ -119,6 +125,105 @@ void ShopService::updateRelatedItem(VoucherItem* item, int countAdded)
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;
@ -142,6 +247,11 @@ void ShopService::moveItems(QList<VoucherItemPtr> items, VoucherPtr source, Vouc
{
erase(source);
}
else
{
calculate(source);
update(source);
}
tx.commit();
}
@ -161,6 +271,12 @@ QList<VoucherPtr> ShopService::paiedVouchers()
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;

@ -21,9 +21,14 @@ public:
void pay(VoucherPtr voucher);
void moveItems(QList<VoucherItemPtr> 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<VoucherPtr> savedVouchers();
QList<VoucherPtr> tempVouchers();
QList<VoucherPtr> paiedVouchers();
QList<VoucherPtr> vouchersForEet();
QList<ShopItemPtr> allSellableItems();
private:

Binary file not shown.

@ -19,12 +19,12 @@
<translation>Cena</translation>
</message>
<message>
<location filename="../directsaleform.ui" line="44"/>
<location filename="../directsaleform.ui" line="47"/>
<source>Count</source>
<translation>Počet</translation>
</message>
<message>
<location filename="../directsaleform.ui" line="58"/>
<location filename="../directsaleform.ui" line="61"/>
<source>VAT rate</source>
<translation>Sazba DPH</translation>
</message>
@ -49,33 +49,46 @@
<translation>Druhá snížená</translation>
</message>
</context>
<context>
<name>EetBatchDialog</name>
<message>
<location filename="../eetbatchdialog.ui" line="14"/>
<source>EET batch send</source>
<translation>EET odeslání neodeslaných účtenek</translation>
</message>
</context>
<context>
<name>PayDialog</name>
<message>
<location filename="../paydialog.ui" line="14"/>
<source>Recieve money</source>
<translation type="unfinished"></translation>
<translation>Platba</translation>
</message>
<message>
<location filename="../paydialog.ui" line="30"/>
<source>Total:</source>
<translation type="unfinished">Celkem:</translation>
<translation>Celkem:</translation>
</message>
<message>
<location filename="../paydialog.ui" line="44"/>
<location filename="../paydialog.ui" line="101"/>
<source>0</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../paydialog.ui" line="59"/>
<source>Recieved</source>
<translation type="unfinished"></translation>
<translation>Obdrženo</translation>
</message>
<message>
<location filename="../paydialog.ui" line="89"/>
<source>Return</source>
<translation type="unfinished"></translation>
<translation>Vrátit</translation>
</message>
<message>
<location filename="../paydialog.ui" line="124"/>
<source>Send to EET portal</source>
<translation>Odeslat na EET</translation>
</message>
</context>
<context>
@ -83,43 +96,75 @@
<message>
<location filename="../paydvouchersdialog.ui" line="14"/>
<source>Paied vouchers</source>
<translation type="unfinished"></translation>
<translation>Zaplacené účtenky</translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="29"/>
<source>Print receipt</source>
<translation type="unfinished"></translation>
<translation>Vytisknout účtenku</translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="55"/>
<location filename="../paydvouchersdialog.cpp" line="51"/>
<location filename="../paydvouchersdialog.cpp" line="89"/>
<source>Save receipt</source>
<translation type="unfinished"></translation>
<translation>Uložit účtenku</translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="58"/>
<location filename="../paydvouchersdialog.ui" line="78"/>
<location filename="../paydvouchersdialog.ui" line="101"/>
<source>...</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="104"/>
<location filename="../paydvouchersdialog.ui" line="153"/>
<source>Items</source>
<translation type="unfinished">Položky</translation>
<translation>Položky</translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="137"/>
<location filename="../paydvouchersdialog.ui" line="168"/>
<source>EET:</source>
<translation></translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="219"/>
<source>Total:</source>
<translation type="unfinished">Celkem:</translation>
<translation>Celkem:</translation>
</message>
<message>
<location filename="../paydvouchersdialog.ui" line="157"/>
<location filename="../paydvouchersdialog.ui" line="239"/>
<source>0</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../paydvouchersdialog.cpp" line="53"/>
<source>not entering</source>
<translation>Nevstupuje</translation>
</message>
<message>
<location filename="../paydvouchersdialog.cpp" line="56"/>
<source>for send</source>
<translation>K odeslání</translation>
</message>
<message>
<location filename="../paydvouchersdialog.cpp" line="59"/>
<source>error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../paydvouchersdialog.cpp" line="51"/>
<location filename="../paydvouchersdialog.cpp" line="62"/>
<source>sent</source>
<translation>Odesláno</translation>
</message>
<message>
<location filename="../paydvouchersdialog.cpp" line="89"/>
<source>Text files (*.txt)</source>
<translation type="unfinished"></translation>
<translation>Textové soubory (*.txt)</translation>
</message>
<message>
<location filename="../paydvouchersdialog.cpp" line="129"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
</context>
<context>
@ -140,7 +185,7 @@
<translation>Hledat</translation>
</message>
<message>
<location filename="../receiptloadform.ui" line="42"/>
<location filename="../receiptloadform.ui" line="49"/>
<source>Items</source>
<translation>Položky</translation>
</message>
@ -150,7 +195,7 @@
<message>
<location filename="../receiptsaveform.ui" line="33"/>
<source>Existing Receipts</source>
<translation>Přidat k již uložené</translation>
<translation>Uložené účtenky</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="39"/>
@ -164,35 +209,35 @@
<message>
<location filename="../receiptsaveform.ui" line="14"/>
<source>Save receipt</source>
<translation type="unfinished"></translation>
<translation>Uložení</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="23"/>
<source>Add to existing</source>
<translation type="unfinished"></translation>
<translation>Přidat k již uložené</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="62"/>
<location filename="../receiptsaveform.ui" line="68"/>
<source>Save as new</source>
<translation type="unfinished"></translation>
<translation>Uložit jako novou</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="69"/>
<location filename="../receiptsaveform.ui" line="75"/>
<source>New receipt</source>
<translation type="unfinished"></translation>
<translation>Nová účtenka</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="78"/>
<location filename="../receiptsaveform.ui" line="84"/>
<source>Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="88"/>
<location filename="../receiptsaveform.ui" line="94"/>
<source>Description</source>
<translation>Popis</translation>
</message>
<message>
<location filename="../receiptsaveform.ui" line="98"/>
<location filename="../receiptsaveform.ui" line="104"/>
<source>Search Contacts</source>
<translation>Vyhledat kontakt</translation>
</message>
@ -205,74 +250,133 @@
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="50"/>
<location filename="../shopform.ui" line="44"/>
<source>Commodity</source>
<translation>Zboží</translation>
</message>
<message>
<location filename="../shopform.ui" line="73"/>
<location filename="../shopform.ui" line="67"/>
<source>Count</source>
<translation>Počet</translation>
</message>
<message>
<location filename="../shopform.ui" line="99"/>
<location filename="../shopform.ui" line="93"/>
<source>Add Item</source>
<translation>Přidat položku</translation>
</message>
<message>
<location filename="../shopform.ui" line="135"/>
<location filename="../shopform.ui" line="134"/>
<source>Direct Sale</source>
<translation>Přímý prodej</translation>
</message>
<message>
<location filename="../shopform.ui" line="148"/>
<location filename="../shopform.ui" line="147"/>
<source>Ctrl+D</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="221"/>
<location filename="../shopform.ui" line="187"/>
<location filename="../shopform.ui" line="200"/>
<location filename="../shopform.ui" line="213"/>
<location filename="../shopform.ui" line="226"/>
<location filename="../shopform.ui" line="239"/>
<location filename="../shopform.ui" line="286"/>
<location filename="../shopform.ui" line="299"/>
<location filename="../shopform.ui" line="312"/>
<location filename="../shopform.ui" line="325"/>
<location filename="../shopform.ui" line="338"/>
<source>...</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="383"/>
<source>Receipt</source>
<translation>Účtenka</translation>
</message>
<message>
<location filename="../shopform.ui" line="257"/>
<location filename="../shopform.ui" line="402"/>
<source>EET status:</source>
<translation>EET status:</translation>
</message>
<message>
<location filename="../shopform.ui" line="418"/>
<source>&lt;a href=&quot;#eet&quot;&gt;dfghdfg&lt;/a&gt;</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="448"/>
<source>Total:</source>
<translation>Celkem:</translation>
</message>
<message>
<location filename="../shopform.ui" line="274"/>
<location filename="../shopform.ui" line="465"/>
<source>0</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.ui" line="295"/>
<location filename="../shopform.ui" line="486"/>
<source>Temporary Save</source>
<translation>Dočasné uložení</translation>
</message>
<message>
<location filename="../shopform.ui" line="317"/>
<location filename="../shopform.ui" line="508"/>
<source>Save</source>
<translation>Uložení</translation>
</message>
<message>
<location filename="../shopform.ui" line="339"/>
<location filename="../shopform.ui" line="530"/>
<source>Load</source>
<translation>Načíst</translation>
</message>
<message>
<location filename="../shopform.ui" line="361"/>
<source>Show paied</source>
<translation type="unfinished"></translation>
<location filename="../shopform.ui" line="552"/>
<source>Show paid</source>
<translation>Zobrazit zaplacené</translation>
</message>
<message>
<location filename="../shopform.ui" line="383"/>
<location filename="../shopform.ui" line="574"/>
<source>Pay</source>
<translation>Zaplatit</translation>
</message>
<message>
<location filename="../shopform.cpp" line="84"/>
<location filename="../shopform.cpp" line="358"/>
<location filename="../shopform.cpp" line="426"/>
<source>&lt;a href=&quot;#eet&quot;&gt;Online&lt;/a&gt;</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.cpp" line="84"/>
<location filename="../shopform.cpp" line="358"/>
<location filename="../shopform.cpp" line="426"/>
<source>&lt;a href=&quot;#eet&quot;&gt;Offline&lt;/a&gt;</source>
<translation></translation>
</message>
<message>
<location filename="../shopform.cpp" line="101"/>
<source>&lt;&lt; empty &gt;&gt;</source>
<translation type="unfinished"></translation>
<translation>&lt;&lt; nevybráno &gt;&gt;</translation>
</message>
<message>
<location filename="../shopform.cpp" line="346"/>
<source>EET communication error.
</source>
<translation>Chyba komunikace s EET</translation>
</message>
<message>
<location filename="../shopform.cpp" line="350"/>
<source>Message from portal: </source>
<translation>Zpráva z EET portálu:</translation>
</message>
<message>
<location filename="../shopform.cpp" line="353"/>
<source>Switch to offline?</source>
<translation>Přepnout do offline?</translation>
</message>
<message>
<location filename="../shopform.cpp" line="355"/>
<source>EET error</source>
<translation>Chyba EET</translation>
</message>
</context>
<context>
@ -280,27 +384,102 @@
<message>
<location filename="../settings/shopsettingsform.ui" line="14"/>
<source>Form</source>
<translation type="unfinished">Zboží</translation>
<translation>Prodejna nastavení</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="24"/>
<source>Favorite buttons</source>
<translation>Nastavení rychlé volby</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="61"/>
<location filename="../settings/shopsettingsform.ui" line="74"/>
<location filename="../settings/shopsettingsform.ui" line="87"/>
<location filename="../settings/shopsettingsform.ui" line="100"/>
<location filename="../settings/shopsettingsform.ui" line="113"/>
<location filename="../settings/shopsettingsform.ui" line="126"/>
<location filename="../settings/shopsettingsform.ui" line="139"/>
<location filename="../settings/shopsettingsform.ui" line="152"/>
<location filename="../settings/shopsettingsform.ui" line="165"/>
<location filename="../settings/shopsettingsform.ui" line="178"/>
<location filename="../settings/shopsettingsform.ui" line="312"/>
<source>...</source>
<translation></translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="20"/>
<location filename="../settings/shopsettingsform.ui" line="202"/>
<source>Printer</source>
<translation type="unfinished"></translation>
<translation>Tiskárna</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="26"/>
<location filename="../settings/shopsettingsform.ui" line="208"/>
<source>Output device</source>
<translation type="unfinished"></translation>
<translation>Jméno tiskárny</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="36"/>
<location filename="../settings/shopsettingsform.ui" line="218"/>
<source>Letters per line</source>
<translation type="unfinished"></translation>
<translation>Znaků na řádek</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="46"/>
<location filename="../settings/shopsettingsform.ui" line="228"/>
<source>Footer text</source>
<translation type="unfinished"></translation>
<translation>Patička</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="239"/>
<source>EET</source>
<translation>EET</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="245"/>
<source>Activate EET</source>
<translation>Zapnout podporu EET</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="257"/>
<source>Shop ID</source>
<translation>ID provozovny</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="267"/>
<source>Cash register ID</source>
<translation>ID zařízení</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="277"/>
<source>EET mode</source>
<translation>EET režim</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="287"/>
<source>Certificate file</source>
<translation>Certifikát</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="322"/>
<source>Private key password</source>
<translation>Heslo k certifikátu</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="336"/>
<source>Test mode</source>
<translation>Testovací režim</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.ui" line="343"/>
<source>Communication with playground </source>
<translation>Testovací EET server</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.cpp" line="23"/>
<source>Simplifyed</source>
<translation>Zjednodušený</translation>
</message>
<message>
<location filename="../settings/shopsettingsform.cpp" line="23"/>
<source>Standard</source>
<translation>Standartní</translation>
</message>
</context>
<context>

Loading…
Cancel
Save