Implemented EET batch send.

closes #275
print
Josef Rokos 8 years ago
parent 954f655363
commit 402535c40c

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

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

@ -74,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",
@ -83,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"
}
}
}

@ -30,7 +30,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 \
@ -53,7 +54,8 @@ HEADERS += shop.h\
paydvouchersdialog.h \
shopitem.h \
data/favorititem.h \
settings/favoriteservice.h
settings/favoriteservice.h \
eetbatchdialog.h
unix {
target.path = /usr/lib
@ -110,7 +112,8 @@ FORMS += \
receiptloadform.ui \
settings/shopsettingsform.ui \
paydialog.ui \
paydvouchersdialog.ui
paydvouchersdialog.ui \
eetbatchdialog.ui
TRANSLATIONS = translations/shop_cs_CZ.ts

@ -324,22 +324,26 @@ void ShopForm::on_payButton_clicked()
ShopService srv;
srv.pay(m_voucher);
QString eetMsg;
bool eetRet = srv.processEet(m_voucher, eetMsg);
if (!eetRet)
if (srv.isEetEnabled())
{
QString errMsg = tr("EET communication error.\n");
bool eetRet = srv.processEet(m_voucher, eetMsg);
if (!eetMsg.isEmpty())
if (!eetRet)
{
errMsg += tr("Message from portal: ") + eetMsg + "\n";
}
QString errMsg = tr("EET communication error.\n");
errMsg += tr("Switch to offline?");
if (!eetMsg.isEmpty())
{
errMsg += tr("Message from portal: ") + eetMsg + "\n";
}
if (srv.isEetOnline() && QMessageBox::question(this, tr("EET error"), errMsg) == QMessageBox::Yes)
{
srv.setEetOnline(false);
errMsg += tr("Switch to offline?");
if (srv.isEetOnline() && QMessageBox::question(this, tr("EET error"), errMsg) == QMessageBox::Yes)
{
srv.setEetOnline(false);
}
}
}

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

@ -217,6 +217,13 @@ 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;
@ -259,6 +266,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;

@ -24,9 +24,11 @@ public:
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:

Loading…
Cancel
Save