From 452d58ac4f3682c90c3ec27a5ceaa2af34d760a7 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 25 Jul 2016 22:41:39 +0200 Subject: [PATCH 01/14] UI fixes --- application/style.css | 1 + core/roles/metaData.json | 2 +- core/users/metaData.json | 2 +- shop/receiptloadform.cpp | 15 ++++++++------ shop/receiptloadform.ui | 9 ++++++++- shop/receiptsaveform.cpp | 42 ++++++++++++++++++++++++++++++++-------- shop/receiptsaveform.ui | 8 +++++++- shop/shopform.cpp | 5 +---- 8 files changed, 62 insertions(+), 22 deletions(-) diff --git a/application/style.css b/application/style.css index b2628ea..05d94e4 100644 --- a/application/style.css +++ b/application/style.css @@ -19,4 +19,5 @@ color: white; font-weight: bold; min-width: 80px; + font: 10px; } diff --git a/core/roles/metaData.json b/core/roles/metaData.json index 0a3c398..b0a7561 100644 --- a/core/roles/metaData.json +++ b/core/roles/metaData.json @@ -2,7 +2,7 @@ "MetaData" : { "id" : "CORE_ROLES", "name" : { - "default" : "Core Roles plugin", + "default" : "Roles", "CZ" : "Role" }, "description" : { diff --git a/core/users/metaData.json b/core/users/metaData.json index 4041d59..b6cbdf7 100644 --- a/core/users/metaData.json +++ b/core/users/metaData.json @@ -2,7 +2,7 @@ "MetaData" : { "id" : "CORE_USERS", "name" : { - "default" : "Core Users plugin", + "default" : "Users", "CZ" : "Uživatelé" }, "description" : { diff --git a/shop/receiptloadform.cpp b/shop/receiptloadform.cpp index 9622c27..f293ec3 100644 --- a/shop/receiptloadform.cpp +++ b/shop/receiptloadform.cpp @@ -16,19 +16,22 @@ 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(this); ui->tabItems->setModel(m_itemModel); + ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex ¤t, QModelIndex){ ShopService srv; @@ -47,7 +50,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)); diff --git a/shop/receiptloadform.ui b/shop/receiptloadform.ui index 4651ac7..792874f 100644 --- a/shop/receiptloadform.ui +++ b/shop/receiptloadform.ui @@ -31,7 +31,14 @@ - + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + diff --git a/shop/receiptsaveform.cpp b/shop/receiptsaveform.cpp index 8106eb4..d85e476 100644 --- a/shop/receiptsaveform.cpp +++ b/shop/receiptsaveform.cpp @@ -26,16 +26,18 @@ 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(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); connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); @@ -45,9 +47,15 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer voucher, QWidget *paren ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); }); - m_binder.setData(new Voucher); AddressBookService srvAdb; - m_binder.registerBinding(ui->contact, ComboData::createComboData(srvAdb.all())); + 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->name); m_binder.registerBinding(ui->description); m_binder.bindToUi(); @@ -70,7 +78,7 @@ void ReceiptSaveForm::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)); @@ -103,6 +111,24 @@ 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.ui b/shop/receiptsaveform.ui index aec56a6..58bc2f6 100644 --- a/shop/receiptsaveform.ui +++ b/shop/receiptsaveform.ui @@ -7,7 +7,7 @@ 0 0 804 - 513 + 578 @@ -51,6 +51,12 @@ 250 + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + diff --git a/shop/shopform.cpp b/shop/shopform.cpp index 0819eee..6ff678b 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -105,10 +105,7 @@ void ShopForm::on_saveButton_clicked() form->setAttribute(Qt::WA_DeleteOnClose); connect(form, &QDialog::accepted, [this]() { - ShopService srv; - m_voucher->setStatus(Voucher::NOT_PAID); - srv.saveVoucher(m_voucher); - m_voucher = srv.createVoucher(); + createEmptyVoucher(); m_itemsModel->setData(m_voucher->items()); ui->total->setText("0"); }); From 9e8d69827f7c723ffe6ac65fddb094a6521188c4 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 17 Feb 2017 23:13:59 +0100 Subject: [PATCH 02/14] Implemented communication with EET portal. --- shop/data/voucher.cpp | 51 +++++++++++++ shop/data/voucher.h | 34 +++++++++ shop/receiptgenerator.cpp | 6 ++ shop/settings/shopsettings.cpp | 85 +++++++++++++++++++++ shop/settings/shopsettings.h | 42 +++++++++++ shop/settings/shopsettingsform.cpp | 23 ++++++ shop/settings/shopsettingsform.h | 2 + shop/settings/shopsettingsform.ui | 117 ++++++++++++++++++++++++++++- shop/shop.json | 5 ++ shop/shop.pro | 5 ++ shop/shopform.cpp | 1 + shop/shopservice.cpp | 62 +++++++++++++++ shop/shopservice.h | 1 + 13 files changed, 433 insertions(+), 1 deletion(-) 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/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/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 b7280bf..b919ee9 100644 --- a/shop/settings/shopsettingsform.cpp +++ b/shop/settings/shopsettingsform.cpp @@ -2,6 +2,8 @@ #include "ui_shopsettingsform.h" #include +#include +#include #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 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(); } @@ -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); + } +} diff --git a/shop/settings/shopsettingsform.h b/shop/settings/shopsettingsform.h index f46f875..ecefb41 100644 --- a/shop/settings/shopsettingsform.h +++ b/shop/settings/shopsettingsform.h @@ -29,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 7e5b2e6..267bd7d 100644 --- a/shop/settings/shopsettingsform.ui +++ b/shop/settings/shopsettingsform.ui @@ -17,7 +17,7 @@ - 0 + 2 @@ -234,6 +234,121 @@ + + + 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 ccd3cab..62277d8 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\") diff --git a/shop/shop.pro b/shop/shop.pro index 665cec6..9507421 100644 --- a/shop/shop.pro +++ b/shop/shop.pro @@ -113,3 +113,8 @@ FORMS += \ paydvouchersdialog.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 4d29d80..9e5674c 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -306,6 +306,7 @@ void ShopForm::on_payButton_clicked() connect(dialog, &QDialog::accepted, [this](){ ShopService srv; srv.pay(m_voucher); + srv.processEet(m_voucher); ReceiptGenerator generator; generator.setVoucher(m_voucher); diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp index 9aa6895..8d719e0 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -3,6 +3,11 @@ #include "isellableservice.h" #include "shop-odb.hxx" +#include "settings/shopsettings.h" + +#include +#include + 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,62 @@ void ShopService::updateRelatedItem(VoucherItem* item, int countAdded) selSrv->addedToVoucher(item->refId(), countAdded); } } + +void ShopService::processEet(VoucherPtr voucher) +{ + if (voucher->eetStatus() == Voucher::EET_NOT_ENTERING) + { + return; + } + + 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; + + connect(sender, &EetSender::sendFinished, [this, voucher, sender, &loop](){ + Transaction tx; + + if (sender->resut()->status() == EetResult::RESPONSE_OK) + { + voucher->setEetBkp(sender->resut()->bkp()); + voucher->setEetPkp(sender->resut()->pkp()); + voucher->setEetFik(sender->resut()->fik()); + voucher->setEetSendDateTime(QDateTime::currentDateTime()); + voucher->setEetStatus(Voucher::EET_SENT); + } + else + { + voucher->setEetStatus(Voucher::EET_ERROR); + } + + this->update(voucher); + tx.commit(); + sender->deleteLater(); + + loop.quit(); + }); + + sender->sendRequest(&request); + loop.exec(); +} + void ShopService::moveItems(QList items, VoucherPtr source, VoucherPtr target) { Transaction tx; diff --git a/shop/shopservice.h b/shop/shopservice.h index e4b5bf6..55e6189 100644 --- a/shop/shopservice.h +++ b/shop/shopservice.h @@ -21,6 +21,7 @@ public: void pay(VoucherPtr voucher); void moveItems(QList items, VoucherPtr source, VoucherPtr target); void updateRelatedItem(VoucherItem* item, int countAdded); + void processEet(VoucherPtr voucher); QList savedVouchers(); QList tempVouchers(); QList paiedVouchers(); From ec16d90fa4f851a2f8ec75b4108b90fb9bc86659 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Tue, 21 Feb 2017 20:37:38 +0100 Subject: [PATCH 03/14] Fixed voucher saving. closes #274 --- shop/receiptsaveform.cpp | 17 ++++++++++++++++- shop/receiptsaveform.h | 5 ++++- shop/shopform.cpp | 40 +++++++++++++++++++++++++++++++--------- shop/shopservice.cpp | 35 ++++++++++++++++++++++++++++++----- shop/shopservice.h | 3 ++- 5 files changed, 83 insertions(+), 17 deletions(-) diff --git a/shop/receiptsaveform.cpp b/shop/receiptsaveform.cpp index 8106eb4..a2dc864 100644 --- a/shop/receiptsaveform.cpp +++ b/shop/receiptsaveform.cpp @@ -45,7 +45,7 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer 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; 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/shopform.cpp b/shop/shopform.cpp index 9e5674c..1ed3c1f 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -54,9 +54,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) @@ -119,13 +123,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(); @@ -306,7 +322,13 @@ void ShopForm::on_payButton_clicked() connect(dialog, &QDialog::accepted, [this](){ ShopService srv; srv.pay(m_voucher); - srv.processEet(m_voucher); + QString eetMsg; + bool eetRet = srv.processEet(m_voucher, eetMsg); + + if (!eetRet) + { + + } ReceiptGenerator generator; generator.setVoucher(m_voucher); diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp index 8d719e0..5055c4d 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -126,11 +126,11 @@ void ShopService::updateRelatedItem(VoucherItem* item, int countAdded) } } -void ShopService::processEet(VoucherPtr voucher) +bool ShopService::processEet(VoucherPtr voucher, QString message) { if (voucher->eetStatus() == Voucher::EET_NOT_ENTERING) { - return; + return true; } SettingsService srvSettings("SHOP"); @@ -157,11 +157,12 @@ void ShopService::processEet(VoucherPtr voucher) connect(sender, &EetSender::sendFinished, [this, voucher, sender, &loop](){ 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->setEetBkp(sender->resut()->bkp()); - voucher->setEetPkp(sender->resut()->pkp()); - voucher->setEetFik(sender->resut()->fik()); voucher->setEetSendDateTime(QDateTime::currentDateTime()); voucher->setEetStatus(Voucher::EET_SENT); } @@ -179,6 +180,30 @@ void ShopService::processEet(VoucherPtr voucher) sender->sendRequest(&request); 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; } void ShopService::moveItems(QList items, VoucherPtr source, VoucherPtr target) diff --git a/shop/shopservice.h b/shop/shopservice.h index 55e6189..29e58c7 100644 --- a/shop/shopservice.h +++ b/shop/shopservice.h @@ -21,7 +21,8 @@ public: void pay(VoucherPtr voucher); void moveItems(QList items, VoucherPtr source, VoucherPtr target); void updateRelatedItem(VoucherItem* item, int countAdded); - void processEet(VoucherPtr voucher); + bool processEet(VoucherPtr voucher, QString message); + void setEetOnline(bool online); QList savedVouchers(); QList tempVouchers(); QList paiedVouchers(); From 954f6553630bce8365fd2c9a16aa8874b5f6474d Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Tue, 21 Feb 2017 22:15:43 +0100 Subject: [PATCH 04/14] Implemented "EET switch to offline" feature. --- shop/shopform.cpp | 13 +++++++++++++ shop/shopservice.cpp | 17 ++++++++++++++--- shop/shopservice.h | 3 ++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/shop/shopform.cpp b/shop/shopform.cpp index 1ed3c1f..cd02c6d 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "shop-odb.hxx" @@ -327,7 +328,19 @@ void ShopForm::on_payButton_clicked() 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; diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp index 5055c4d..2b515be 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -126,7 +126,7 @@ void ShopService::updateRelatedItem(VoucherItem* item, int countAdded) } } -bool ShopService::processEet(VoucherPtr voucher, QString message) +bool ShopService::processEet(VoucherPtr voucher, QString &message) { if (voucher->eetStatus() == Voucher::EET_NOT_ENTERING) { @@ -153,8 +153,9 @@ bool ShopService::processEet(VoucherPtr voucher, QString message) sender->setPlayground(settings->eetPlayground()); QEventLoop loop; + bool replyFinished = false; - connect(sender, &EetSender::sendFinished, [this, voucher, sender, &loop](){ + connect(sender, &EetSender::sendFinished, [this, voucher, sender, &loop, &replyFinished](){ Transaction tx; voucher->setEetBkp(sender->resut()->bkp()); @@ -176,10 +177,15 @@ bool ShopService::processEet(VoucherPtr voucher, QString message) sender->deleteLater(); loop.quit(); + replyFinished = true; }); sender->sendRequest(&request); - loop.exec(); + + if (!replyFinished) + { + loop.exec(); + } auto addMessage = [&message](EetMessage *msg, const QString &label){ if (message.isEmpty()) @@ -206,6 +212,11 @@ void ShopService::setEetOnline(bool online) EetSender::m_online = online; } +bool ShopService::isEetOnline() +{ + return EetSender::m_online; +} + void ShopService::moveItems(QList items, VoucherPtr source, VoucherPtr target) { Transaction tx; diff --git a/shop/shopservice.h b/shop/shopservice.h index 29e58c7..b3bb095 100644 --- a/shop/shopservice.h +++ b/shop/shopservice.h @@ -21,8 +21,9 @@ public: void pay(VoucherPtr voucher); void moveItems(QList items, VoucherPtr source, VoucherPtr target); void updateRelatedItem(VoucherItem* item, int countAdded); - bool processEet(VoucherPtr voucher, QString message); + bool processEet(VoucherPtr voucher, QString &message); void setEetOnline(bool online); + bool isEetOnline(); QList savedVouchers(); QList tempVouchers(); QList paiedVouchers(); From 402535c40c60ea8f3c50b80c9aebdd032f014ac4 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Thu, 23 Feb 2017 22:50:01 +0100 Subject: [PATCH 05/14] Implemented EET batch send. closes #275 --- shop/eetbatchdialog.cpp | 19 ++++++++ shop/eetbatchdialog.h | 23 ++++++++++ shop/eetbatchdialog.ui | 74 +++++++++++++++++++++++++++++++ shop/icons/sendEet.svg | 8 ++++ shop/paydvouchersdialog.cpp | 71 ++++++++++++++++++++++++++++++ shop/paydvouchersdialog.h | 4 ++ shop/paydvouchersdialog.ui | 87 ++++++++++++++++++++++++++++++++++++- shop/shop.json | 5 ++- shop/shop.pro | 9 ++-- shop/shopform.cpp | 24 +++++----- shop/shoprc.qrc | 1 + shop/shopservice.cpp | 13 ++++++ shop/shopservice.h | 2 + 13 files changed, 324 insertions(+), 16 deletions(-) create mode 100644 shop/eetbatchdialog.cpp create mode 100644 shop/eetbatchdialog.h create mode 100644 shop/eetbatchdialog.ui create mode 100644 shop/icons/sendEet.svg 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: From 9418d739e612569f1cdebd0ac325bdb4d8f60405 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 24 Feb 2017 23:19:46 +0100 Subject: [PATCH 06/14] Improved EET integration- switch to online/offline mode now possible. Application starts to maximized window. --- application/main.cpp | 2 +- shop/paydialog.cpp | 10 ++++++++++ shop/paydialog.h | 1 + shop/paydialog.ui | 19 ++++++++++++++++--- shop/shopform.cpp | 23 +++++++++++++++++++++-- shop/shopform.h | 2 ++ shop/shopform.ui | 31 ++++++++++++++++++++++++++++++- 7 files changed, 81 insertions(+), 7 deletions(-) diff --git a/application/main.cpp b/application/main.cpp index 6b68e87..7712bbc 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -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(); } diff --git a/shop/paydialog.cpp b/shop/paydialog.cpp index e272503..7e61370 100644 --- a/shop/paydialog.cpp +++ b/shop/paydialog.cpp @@ -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) { diff --git a/shop/paydialog.h b/shop/paydialog.h index 55d81cb..fba7df2 100644 --- a/shop/paydialog.h +++ b/shop/paydialog.h @@ -15,6 +15,7 @@ class PayDialog : public QDialog public: explicit PayDialog(QDecDouble total, QWidget *parent = 0); ~PayDialog(); + bool sendToEet(); private slots: diff --git a/shop/paydialog.ui b/shop/paydialog.ui index fd9d4a2..25db67f 100644 --- a/shop/paydialog.ui +++ b/shop/paydialog.ui @@ -6,8 +6,8 @@ 0 0 - 449 - 134 + 457 + 168 @@ -105,7 +105,7 @@ - + false @@ -118,6 +118,19 @@ + + + + Send to EET portal + + + true + + + true + + + diff --git a/shop/shopform.cpp b/shop/shopform.cpp index 5a2b756..e998652 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -78,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("Online") : tr("Offline")); + } + else + { + ui->labelEete->setVisible(false); + ui->lblEetState->setVisible(false); + } } void ShopForm::fillRaceiptCombo() @@ -320,12 +330,12 @@ 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); QString eetMsg; - if (srv.isEetEnabled()) + if (srv.isEetEnabled() && dialog->sendToEet()) { bool eetRet = srv.processEet(m_voucher, eetMsg); @@ -343,6 +353,7 @@ void ShopForm::on_payButton_clicked() if (srv.isEetOnline() && QMessageBox::question(this, tr("EET error"), errMsg) == QMessageBox::Yes) { srv.setEetOnline(false); + ui->lblEetState->setText(srv.isEetOnline() ? tr("Online") : tr("Offline")); } } } @@ -403,3 +414,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("Online") : tr("Offline")); +} diff --git a/shop/shopform.h b/shop/shopform.h index d26d4ff..dee98dd 100644 --- a/shop/shopform.h +++ b/shop/shopform.h @@ -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 m_voucher; diff --git a/shop/shopform.ui b/shop/shopform.ui index 270547c..ebe21e6 100644 --- a/shop/shopform.ui +++ b/shop/shopform.ui @@ -399,6 +399,35 @@ + + 0 + + + + + EET status: + + + + + + + + 75 + true + + + + PointingHandCursor + + + <a href="#eet">dfghdfg</a> + + + Qt::RichText + + + @@ -571,8 +600,8 @@ - + From 8fe8f5952ee131cf0437072ea0011660ad42184d Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 6 Mar 2017 20:16:38 +0100 Subject: [PATCH 07/14] Send storno to EET now possible. --- shop/directsaleform.ui | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shop/directsaleform.ui b/shop/directsaleform.ui index 96a2a1a..e5b898c 100644 --- a/shop/directsaleform.ui +++ b/shop/directsaleform.ui @@ -7,7 +7,7 @@ 0 0 400 - 150 + 184 @@ -33,6 +33,9 @@ + + -9999999999999.000000000000000 + 9999999999.989999771118164 From 22faefa5582cb221c861c5bb1c9ef71f11bcad15 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Wed, 8 Mar 2017 14:03:51 +0100 Subject: [PATCH 08/14] Fixed saved voucher recalculation. closes #278 --- shop/settings/shopsettingsform.ui | 2 +- shop/shopservice.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/shop/settings/shopsettingsform.ui b/shop/settings/shopsettingsform.ui index 267bd7d..b3ba813 100644 --- a/shop/settings/shopsettingsform.ui +++ b/shop/settings/shopsettingsform.ui @@ -17,7 +17,7 @@ - 2 + 0 diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp index 8af8217..c07425a 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -247,6 +247,11 @@ void ShopService::moveItems(QList items, VoucherPtr source, Vouc { erase(source); } + else + { + calculate(source); + update(source); + } tx.commit(); } From 6a027caa8552bd6d05595cca91838536b92845de Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Wed, 8 Mar 2017 14:23:02 +0100 Subject: [PATCH 09/14] Commodity searching on shop form is case insensitive now. closes #283 --- shop/shopform.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/shop/shopform.cpp b/shop/shopform.cpp index e998652..0ce98a4 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -392,6 +392,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) { From f05442e748d664e0148b8157ce5f82aa79eddfb1 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Wed, 8 Mar 2017 14:39:09 +0100 Subject: [PATCH 10/14] Added application icon. --- application/appRc.qrc | 1 + application/application.pro | 5 ++++- application/icons/shop.ico | Bin 0 -> 4286 bytes application/logindialog.ui | 2 +- application/mainwindow.ui | 14 +++++++++----- application/shop.ico | Bin 0 -> 4286 bytes application/shop.rc | 1 + 7 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 application/icons/shop.ico create mode 100644 application/shop.ico create mode 100644 application/shop.rc diff --git a/application/appRc.qrc b/application/appRc.qrc index afa9743..e2ffa4c 100644 --- a/application/appRc.qrc +++ b/application/appRc.qrc @@ -5,5 +5,6 @@ style.css icons/settings.svg translations/prodejna_cs_CZ.qm + icons/shop.ico diff --git a/application/application.pro b/application/application.pro index eeb2f76..8ea5e6d 100644 --- a/application/application.pro +++ b/application/application.pro @@ -18,6 +18,8 @@ win32 { INCLUDEPATH += d:/prac/odb/libodb-qt-2.4.0 INCLUDEPATH += d:/prac/odb/libodb-sqlite-2.4.0 INCLUDEPATH += d:/prac/odb/sqlite + + RC_FILE = shop.rc } SOURCES += main.cpp\ @@ -59,4 +61,5 @@ RESOURCES += \ TRANSLATIONS = translations/prodejna_cz.ts -DISTFILES += +DISTFILES += \ + shop.rc diff --git a/application/icons/shop.ico b/application/icons/shop.ico new file mode 100644 index 0000000000000000000000000000000000000000..b7a49f3c124ae08e22f85f748b3b22c57667a1a3 GIT binary patch literal 4286 zcmeH~e@xVM7{@yX+RA)&Oe$3w%S@W8Y1DQ zT-wk~G=9`(xF~kI*>W0^w?Y>wh*)a48R#Z4b+HydlDqHI^L#$v@4nYJ^DesFY94#I z=Xrge=XpQh?>*lgFqVKn1_PtttbGn+_cF%P&=4^j8u44N|K1(2+wG}^p3KVP9Fu=0 zMzt=NYvD|;y!2_~TYm4Nk?*Th;L`f!85z}XD1G!&X^ye#@62Gcxzqe*i++Lz2GBSc zp) zf!x0x!l4jAM<$P4ZI`R;bM&iO9UI(tg$bP1Uu8j*=hfs@O-YhCYru)#qz_~T5kjR z5O?pgvU>sCJ&eiZv&u}JIU4KC69ob zR(5X^cW)Q&9x*ie$4|Ky9Kh#MVQ@fsCeMGOF{}ws&<;*wFWf=QEiXzxc_V$J(U@HA zdwdw$P^;q}tepUPcrWmn7@GXU4$fike2t^ebMfpCxmZh_dJ(VkE*ZxCp7mEVNRpJX zyVCG8e2iLT`wUo%yP(GO-hMm49_$y%$R|c;k(_F&hr-$_4Oda)$?NGOpXYW;N4@!` z5Pk;J|AtX-(jYDU40gMtU6LGdGmNzK`Z!b5&CnJaQj=ca?RMYca5!F*BxgP5Y(X1Q z=fQc;qrX|4(RozcWVbudsr8sYiaoaCHEu-zWzy2?>tl<>G8gAL7SZD%Js_SZNJje8&8bjbX6n`F$2%_aNDC^9%>kTae_6iW>|JTIkWZ{2*ZN?*^=|e1 zf8PO!c*%^d3o({8#n=OpHpW7-^xDu`D@hXdNU50c!E@wjlmbHk1S~ LmLe=dkKEq@$JMw+ literal 0 HcmV?d00001 diff --git a/application/logindialog.ui b/application/logindialog.ui index b4fd75e..56111cb 100644 --- a/application/logindialog.ui +++ b/application/logindialog.ui @@ -59,7 +59,7 @@ - + diff --git a/application/mainwindow.ui b/application/mainwindow.ui index 4a52742..e97c89e 100644 --- a/application/mainwindow.ui +++ b/application/mainwindow.ui @@ -13,6 +13,10 @@ MainWindow + + + :/icons/shop.ico:/icons/shop.ico + @@ -56,12 +60,12 @@ 0 0 1000 - 21 + 19 - File + Fi&le @@ -83,12 +87,12 @@ - Exit + &Exit - Open database... + &Open database... @@ -97,7 +101,7 @@ :/icons/login_32.png:/icons/login_32.png - Login... + &Login... diff --git a/application/shop.ico b/application/shop.ico new file mode 100644 index 0000000000000000000000000000000000000000..b7a49f3c124ae08e22f85f748b3b22c57667a1a3 GIT binary patch literal 4286 zcmeH~e@xVM7{@yX+RA)&Oe$3w%S@W8Y1DQ zT-wk~G=9`(xF~kI*>W0^w?Y>wh*)a48R#Z4b+HydlDqHI^L#$v@4nYJ^DesFY94#I z=Xrge=XpQh?>*lgFqVKn1_PtttbGn+_cF%P&=4^j8u44N|K1(2+wG}^p3KVP9Fu=0 zMzt=NYvD|;y!2_~TYm4Nk?*Th;L`f!85z}XD1G!&X^ye#@62Gcxzqe*i++Lz2GBSc zp) zf!x0x!l4jAM<$P4ZI`R;bM&iO9UI(tg$bP1Uu8j*=hfs@O-YhCYru)#qz_~T5kjR z5O?pgvU>sCJ&eiZv&u}JIU4KC69ob zR(5X^cW)Q&9x*ie$4|Ky9Kh#MVQ@fsCeMGOF{}ws&<;*wFWf=QEiXzxc_V$J(U@HA zdwdw$P^;q}tepUPcrWmn7@GXU4$fike2t^ebMfpCxmZh_dJ(VkE*ZxCp7mEVNRpJX zyVCG8e2iLT`wUo%yP(GO-hMm49_$y%$R|c;k(_F&hr-$_4Oda)$?NGOpXYW;N4@!` z5Pk;J|AtX-(jYDU40gMtU6LGdGmNzK`Z!b5&CnJaQj=ca?RMYca5!F*BxgP5Y(X1Q z=fQc;qrX|4(RozcWVbudsr8sYiaoaCHEu-zWzy2?>tl<>G8gAL7SZD%Js_SZNJje8&8bjbX6n`F$2%_aNDC^9%>kTae_6iW>|JTIkWZ{2*ZN?*^=|e1 zf8PO!c*%^d3o({8#n=OpHpW7-^xDu`D@hXdNU50c!E@wjlmbHk1S~ LmLe=dkKEq@$JMw+ literal 0 HcmV?d00001 diff --git a/application/shop.rc b/application/shop.rc new file mode 100644 index 0000000..befc6d6 --- /dev/null +++ b/application/shop.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "shop.ico" From 49a09415cdbbfa925a95e42115ef107aed7d0aa7 Mon Sep 17 00:00:00 2001 From: Pepa Rokos Date: Wed, 8 Mar 2017 14:43:53 +0100 Subject: [PATCH 11/14] Added POS printer support in Windows. --- shop/receiptgenerator.cpp | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/shop/receiptgenerator.cpp b/shop/receiptgenerator.cpp index daeafa4..cd62dfd 100644 --- a/shop/receiptgenerator.cpp +++ b/shop/receiptgenerator.cpp @@ -5,6 +5,11 @@ #include #include +#ifdef _WIN32 +#include +#include +#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(); + 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 From 378d052bd65362d79964b8ea99178baf4693779b Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Wed, 8 Mar 2017 14:58:28 +0100 Subject: [PATCH 12/14] Increase icon size. --- application/shop.ico | Bin 4286 -> 16958 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/application/shop.ico b/application/shop.ico index b7a49f3c124ae08e22f85f748b3b22c57667a1a3..d52c99acea0fc3690d45ceca1ab7692a45bea75b 100644 GIT binary patch literal 16958 zcmeHNeQ;FO72ha|b+nyQ!G6#ZD9Xna8v!Ai$;ZC8AIXL!fHbLXqd>7E5{k6>qqT@h z$Ej@@f_w=oAB8}$ML@9APLLv@GL41Cq6MX<(iklXVn*_@At8D9^mjJ<-oE$tz3eU_ z7&4p8$$fjz@1Aph=iYbjeVgZSB;eQSbl`8IW4!EejBq#{<00sBltQ>a{u9qYJOl9z z#4`}jKs*C|&w$hEOq6BUN}t>Lp4TO{WV+?HYborLeY;$)6<)9R>wRYwy#@Fza=YZq zb90kBcP>n%*NX3?s^SsXRM_W^g`=r3C#4gybjY$iFM0-7js*9|+%A{0f5}J^D;-2- zpRI_p1p0l^C<1?h*ydh2v&bW1|8AEocm46PuMw>R?*Syc79|qa!6n?6BO^1pGK5=} z*ZpYrv`$(L?m7|sGD+0FOrpA!XzdV#E`Zzcc@k&;OiKHwB;H&Tt`FK`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Z!b5&CnJaQj=ca?RMYca5!F*BxgP5Y(X1Q z=fQc;qrX|4(RozcWVbudsr8sYiaoaCHEu-zWzy2?>tl<>G8gAL7SZD%Js_SZNJje8&8bjbX6n`F$2%_aNDC^9%>kTae_6iW>|JTIkWZ{2*ZN?*^=|e1 zf8PO!c*%^d3o({8#n=OpHpW7-^xDu`D@hXdNU50c!E@wjlmbHk1S~ LmLe=dkKEq@$JMw+ From 94e4edc6e66437a713861765c38fe03eef03ef57 Mon Sep 17 00:00:00 2001 From: Pepa Rokos Date: Sat, 11 Mar 2017 21:05:11 +0100 Subject: [PATCH 13/14] UI changes for HDPI. Voucher could be marked as EET not entering. --- application/style.css | 4 ++-- shop/receiptgenerator.cpp | 29 +++++++++++++++++++++-------- shop/shopform.cpp | 2 ++ shop/shopform.ui | 10 ++-------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/application/style.css b/application/style.css index 05d94e4..b099ec7 100644 --- a/application/style.css +++ b/application/style.css @@ -18,6 +18,6 @@ #navigation QToolButton { color: white; font-weight: bold; - min-width: 80px; - font: 10px; + min-width: 90px; + font: 10pt; } diff --git a/shop/receiptgenerator.cpp b/shop/receiptgenerator.cpp index cd62dfd..8bab43b 100644 --- a/shop/receiptgenerator.cpp +++ b/shop/receiptgenerator.cpp @@ -123,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); @@ -135,12 +141,14 @@ QByteArray ReceiptGenerator::generate() out.append("\x0a"); foreach (QSharedPointer 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)); } @@ -171,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()); @@ -184,13 +192,18 @@ 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())); + 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"); diff --git a/shop/shopform.cpp b/shop/shopform.cpp index 0ce98a4..d3cb461 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -333,6 +333,8 @@ void ShopForm::on_payButton_clicked() 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()) diff --git a/shop/shopform.ui b/shop/shopform.ui index ebe21e6..35de415 100644 --- a/shop/shopform.ui +++ b/shop/shopform.ui @@ -37,12 +37,6 @@ - - - 500 - 16777215 - - @@ -555,7 +549,7 @@ - Show paied + Show paid @@ -600,8 +594,8 @@ - + From 405547d7b610f808faa0a1c616c6f928d26ab721 Mon Sep 17 00:00:00 2001 From: jony Date: Wed, 15 Mar 2017 21:44:54 +0100 Subject: [PATCH 14/14] Translation update --- application/translations/prodejna_cz.qm | Bin 0 -> 564 bytes application/translations/prodejna_cz.ts | 38 +++- core/translations/core_cs_CZ.qm | Bin 4357 -> 5431 bytes core/translations/core_cs_CZ.ts | 22 +- shop/translations/shop_cs_CZ.qm | Bin 2322 -> 6314 bytes shop/translations/shop_cs_CZ.ts | 291 +++++++++++++++++++----- 6 files changed, 273 insertions(+), 78 deletions(-) create mode 100644 application/translations/prodejna_cz.qm diff --git a/application/translations/prodejna_cz.qm b/application/translations/prodejna_cz.qm new file mode 100644 index 0000000000000000000000000000000000000000..f98d37de50dbe9ce2d94673febb760b046010040 GIT binary patch literal 564 zcmZ{hF-yZx6opT0qp=oIClQA_7(^ld0TB@u!Dqby>6NxNrtZ;-Pw-qy{y|^#K4v<+D zQmsqn290RK2>Xl11`Ta<$_r;ngm5}fO!wN6FUN6`6eg%pAmgDGdPzxsJg?5ZuB`*x6^7UWvuycKe@tN*Qe*sT+b8!Fw literal 0 HcmV?d00001 diff --git a/application/translations/prodejna_cz.ts b/application/translations/prodejna_cz.ts index 8d1a56b..35ab4a0 100644 --- a/application/translations/prodejna_cz.ts +++ b/application/translations/prodejna_cz.ts @@ -20,31 +20,47 @@ MainWindow - Prodejna + Prodejna + + + + Fi&le + &Soubor + + + + &Exit + &Konec + + + + &Open database... + &Otevřít databázi... + + + + &Login... + &Přihlásit... - File - Soubor + Soubor - Exit - Konec + Konec - Open database... - Otevřít databázi... + Otevřít databázi... - Login... - Přihlásit se... + Přihlásit se... - - + + Settings Nastavení diff --git a/core/translations/core_cs_CZ.qm b/core/translations/core_cs_CZ.qm index f3dead6e3be3982a9afd6aaa82337bfadfed49f8..7ddb2a5e8aec0a8ac903d4cd5416f3b9259a88ec 100644 GIT binary patch delta 1367 zcmaJ=Z)h839DXjnyQG&~uBm?r_K&wBiVCx%ROdddI@h&|)~<2N1Z}VFQ7@*+OfHG7 z(x5mf%CIxaoYqk{K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URkd`l&%hKHXr%$^}mP9fX3dzW1*7%7Wc`#3*9ph{)$`tmET78%IBSu^1C15of zcb8w014j2z5-)r@@6E=(Y`@6t+1q5|`R0e>%@`+kvIQePW}QARiI)b~O`C97!Eo!eOYl3G|(|STAd(DkhUf_+E+)|%Xy7x__qK7itKZWFkNB{r; diff --git a/core/translations/core_cs_CZ.ts b/core/translations/core_cs_CZ.ts index 6fd7131..755bc6b 100644 --- a/core/translations/core_cs_CZ.ts +++ b/core/translations/core_cs_CZ.ts @@ -128,7 +128,7 @@ Base settings - + Hlavní nastavení @@ -174,22 +174,22 @@ Number series - + Číselné řady Edit name - + Upravit název Season - + Sezóna Create new - + Vytvořit novou @@ -235,22 +235,22 @@ Switch season - + Změna sezóny Realy switch active season? - + Opravdu si přejete změnit aktivní sezónu? New season - + Nová sezóna Realy create new season and switch to it? - + Opravdu si přejete vytvořit novou sezónu a přepnout na ni? @@ -365,12 +365,12 @@ Season - + Sezóna Season name - + Název sezóny diff --git a/shop/translations/shop_cs_CZ.qm b/shop/translations/shop_cs_CZ.qm index 4ea69b9acbe1b1e9c1958651c2ee67d8b5770871..39c408628913edd68348acf339dddd6edfe8586d 100644 GIT binary patch literal 6314 zcma)AZEPH85uWpX`0jlEi0cN&SYew+Z9Xcu2=W7CToT(M329>GT$e_u?fUM$yN&O5 zkG(xRHX=o&qAj!m6$&LpDF_HZLdA~=nm|jTh#xIPssQm-ie#ZurO2v^NJXMH=9%5Q zclUg|7ss;S-0eFv&&)gX%)C2tKHLBDTc@79c+=nu4}ACe*LD%LohPC@uvVNk{AXuP zo+kQW7g6{bXH6b+*6u$N?fpK{x|3G8pB{(oPn@;$n6viYN0GPw zg75!D(H$01=hGD3vx6wUOws8HqRu`4Y9Cnj(r_rF})L^igL`y^r>PYlbMY zjV6CIhV=nwZNH!H`O1@!-$(g#KOpLTmx{bEHcThZLVwR`IpGM>NDcJ>y?8<-Qn=hAKOX*7yea0aJNzT z()0I0-$%l4{`L#7yBHat{s&R=xyZ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+ EET odeslání neodeslaných účtenek + + PayDialog Recieve money - + Platba Total: - Celkem: + Celkem: 0 - + Recieved - + Obdrženo Return - + Vrátit + + + + Send to EET portal + Odeslat na EET @@ -83,43 +96,75 @@ Paied vouchers - + Zaplacené účtenky Print receipt - + Vytisknout účtenku - + Save receipt - + Uložit účtenku + + ... - + - + Items - Položky + Položky - + + EET: + + + + Total: - Celkem: + Celkem: - + 0 - + + + + + not entering + Nevstupuje + + + + for send + K odeslání + + + + error + Chyba - + + sent + Odesláno + + + Text files (*.txt) - + Textové soubory (*.txt) + + + + Error + Chyba @@ -140,7 +185,7 @@ Hledat - + Items Položky @@ -150,7 +195,7 @@ Existing Receipts - Přidat k již uložené + Uložené účtenky @@ -164,35 +209,35 @@ Save receipt - + Uložení Add to existing - + Přidat k již uložené - + Save as new - + Uložit jako novou - + New receipt - + Nová účtenka - + Name Název - + Description Popis - + Search Contacts Vyhledat kontakt @@ -205,74 +250,133 @@ - + Commodity Zboží - + Count Počet - + Add Item Přidat položku - + Direct Sale Přímý prodej - + Ctrl+D - + + + + + + + + + + + ... + + + + Receipt Účtenka - + + EET status: + EET status: + + + + <a href="#eet">dfghdfg</a> + + + + Total: Celkem: - + 0 - + Temporary Save Dočasné uložení - + Save Uložení - + Load Načíst - - Show paied - + + Show paid + Zobrazit zaplacené - + Pay Zaplatit + + + <a href="#eet">Online</a> + + + + + + + <a href="#eet">Offline</a> + + + + << empty >> - + << nevybráno >> + + + + EET communication error. + + Chyba komunikace s EET + + + + Message from portal: + Zpráva z EET portálu: + + + + Switch to offline? + Přepnout do offline? + + + + EET error + Chyba EET @@ -280,27 +384,102 @@ Form - Zboží + Prodejna nastavení + + + + Favorite buttons + Nastavení rychlé volby + + + + + + + + + + + + + + ... + - + Printer - + Tiskárna - + Output device - + Jméno tiskárny - + Letters per line - + Znaků na řádek - + Footer text - + Patička + + + + EET + EET + + + + Activate EET + Zapnout podporu EET + + + + Shop ID + ID provozovny + + + + Cash register ID + ID zařízení + + + + EET mode + EET režim + + + + Certificate file + Certifikát + + + + Private key password + Heslo k certifikátu + + + + Test mode + Testovací režim + + + + Communication with playground + Testovací EET server + + + + Simplifyed + Zjednodušený + + + + Standard + Standartní