Added possibility for creating vouchers from other module.
This commit is contained in:
+47
-33
@@ -4,9 +4,9 @@
|
||||
#include "temporaryreceiptsaveform.h"
|
||||
#include "receiptsaveform.h"
|
||||
#include "receiptloadform.h"
|
||||
#include "paydialog.h"
|
||||
#include "shopservice.h"
|
||||
#include "receiptgenerator.h"
|
||||
#include "paydialog.h"
|
||||
#include "paydvouchersdialog.h"
|
||||
#include "isellableservice.h"
|
||||
#include <QList>
|
||||
@@ -18,6 +18,46 @@
|
||||
|
||||
#include "shop-odb.hxx"
|
||||
|
||||
void payVoucherFromUI(VoucherPtr voucher, PayDialog *dialog, ShopForm *form)
|
||||
{
|
||||
ShopService srv;
|
||||
srv.pay(voucher);
|
||||
voucher->setEetStatus(dialog->sendToEet() ? Voucher::EET_FOR_SEND : Voucher::EET_NOT_ENTERING);
|
||||
srv.update(voucher);
|
||||
QString eetMsg;
|
||||
|
||||
if (srv.isEetEnabled() && dialog->sendToEet())
|
||||
{
|
||||
bool eetRet = srv.processEet(voucher, eetMsg);
|
||||
|
||||
if (!eetRet)
|
||||
{
|
||||
QString errMsg = QObject::tr("EET communication error.\n");
|
||||
|
||||
if (!eetMsg.isEmpty())
|
||||
{
|
||||
errMsg += QObject::tr("Message from portal: ") + eetMsg + "\n";
|
||||
}
|
||||
|
||||
errMsg += QObject::tr("Switch to offline?");
|
||||
|
||||
if (srv.isEetOnline() && QMessageBox::question(NULL, QObject::tr("EET error"), errMsg) == QMessageBox::Yes)
|
||||
{
|
||||
srv.setEetOnline(false);
|
||||
|
||||
if (form != NULL)
|
||||
{
|
||||
form->setEetStatusText(srv.isEetOnline() ? QObject::tr("<a href=\"#eet\">Online</a>") : QObject::tr("<a href=\"#eet\">Offline</a>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReceiptGenerator generator;
|
||||
generator.setVoucher(voucher);
|
||||
generator.print();
|
||||
}
|
||||
|
||||
ShopForm::ShopForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ShopForm)
|
||||
@@ -172,6 +212,11 @@ void ShopForm::fillRaceiptCombo()
|
||||
ui->receiptCombo->blockSignals(oldState);
|
||||
}
|
||||
|
||||
void ShopForm::setEetStatusText(const QString &statusText)
|
||||
{
|
||||
ui->lblEetState->setText(statusText);
|
||||
}
|
||||
|
||||
void ShopForm::on_directSale_clicked()
|
||||
{
|
||||
DirectSaleForm *form = new DirectSaleForm(this);
|
||||
@@ -429,38 +474,7 @@ void ShopForm::on_payButton_clicked()
|
||||
dialog->show();
|
||||
|
||||
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);
|
||||
generator.print();
|
||||
payVoucherFromUI(m_voucher, dialog, this);
|
||||
|
||||
createEmptyVoucher();
|
||||
m_itemsModel->setData(m_voucher->items());
|
||||
|
||||
Reference in New Issue
Block a user