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/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/shop.json b/shop/shop.json index 62277d8..8b9be10 100644 --- a/shop/shop.json +++ b/shop/shop.json @@ -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" } } } diff --git a/shop/shop.pro b/shop/shop.pro index 9507421..5ec558b 100644 --- a/shop/shop.pro +++ b/shop/shop.pro @@ -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 diff --git a/shop/shopform.cpp b/shop/shopform.cpp index cd02c6d..5a2b756 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -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); + } } } 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 2b515be..8af8217 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -217,6 +217,13 @@ 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; @@ -259,6 +266,12 @@ 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; diff --git a/shop/shopservice.h b/shop/shopservice.h index b3bb095..2a622bb 100644 --- a/shop/shopservice.h +++ b/shop/shopservice.h @@ -24,9 +24,11 @@ public: 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: