Added pay voucher feature. Added dialog with paied vouchers. Added
support for printing receipts on POS printer.
This commit is contained in:
+46
-4
@@ -5,6 +5,9 @@
|
||||
#include "receiptsaveform.h"
|
||||
#include "receiptloadform.h"
|
||||
#include "shopservice.h"
|
||||
#include "receiptgenerator.h"
|
||||
#include "paydialog.h"
|
||||
#include "paydvouchersdialog.h"
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
#include "shop-odb.hxx"
|
||||
@@ -18,6 +21,7 @@ ShopForm::ShopForm(QWidget *parent) :
|
||||
|
||||
ui->temporarySaveButton->setEnabled(false);
|
||||
ui->saveButton->setEnabled(false);
|
||||
ui->payButton->setEnabled(false);
|
||||
}
|
||||
|
||||
ShopForm::~ShopForm()
|
||||
@@ -48,6 +52,7 @@ void ShopForm::loadLast()
|
||||
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
|
||||
ui->temporarySaveButton->setEnabled(true);
|
||||
ui->saveButton->setEnabled(true);
|
||||
ui->payButton->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +131,7 @@ void ShopForm::onCountChanged()
|
||||
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
|
||||
ui->temporarySaveButton->setEnabled(!m_voucher->items().isEmpty());
|
||||
ui->saveButton->setEnabled(!m_voucher->items().isEmpty());
|
||||
ui->payButton->setEnabled(!m_voucher->items().isEmpty());
|
||||
|
||||
if (m_voucher->status() == Voucher::NEW && m_voucher->id() == 0)
|
||||
{
|
||||
@@ -163,10 +169,7 @@ void ShopForm::doTempSave(bool comboChanged)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_voucher = srv.createVoucher();
|
||||
ui->total->setText("0");
|
||||
ui->temporarySaveButton->setEnabled(false);
|
||||
ui->saveButton->setEnabled(false);
|
||||
createEmptyVoucher();
|
||||
}
|
||||
|
||||
fillRaceiptCombo();
|
||||
@@ -192,6 +195,7 @@ void ShopForm::changeReceipt()
|
||||
|
||||
ui->temporarySaveButton->setEnabled(true);
|
||||
ui->saveButton->setEnabled(true);
|
||||
ui->payButton->setEnabled(true);
|
||||
|
||||
fillRaceiptCombo();
|
||||
}
|
||||
@@ -203,6 +207,16 @@ void ShopForm::connectItemSignals()
|
||||
}
|
||||
}
|
||||
|
||||
void ShopForm::createEmptyVoucher()
|
||||
{
|
||||
ShopService srv;
|
||||
m_voucher = srv.createVoucher();
|
||||
ui->total->setText("0");
|
||||
ui->temporarySaveButton->setEnabled(false);
|
||||
ui->saveButton->setEnabled(false);
|
||||
ui->payButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void ShopForm::on_receiptCombo_currentIndexChanged(int)
|
||||
{
|
||||
if (!m_voucher.isNull() && m_voucher->items().isEmpty())
|
||||
@@ -223,3 +237,31 @@ void ShopForm::on_receiptCombo_currentIndexChanged(int)
|
||||
doTempSave(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ShopForm::on_payButton_clicked()
|
||||
{
|
||||
PayDialog *dialog = new PayDialog(m_voucher->totalPrice(), this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->show();
|
||||
|
||||
connect(dialog, &QDialog::accepted, [this](){
|
||||
ShopService srv;
|
||||
srv.pay(m_voucher);
|
||||
|
||||
ReceiptGenerator generator;
|
||||
generator.setVoucher(m_voucher);
|
||||
generator.print();
|
||||
|
||||
createEmptyVoucher();
|
||||
m_itemsModel->setData(m_voucher->items());
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ShopForm::on_showPaiedButton_clicked()
|
||||
{
|
||||
PaydVouchersDialog *dialog = new PaydVouchersDialog(this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user