This commit is contained in:
2016-07-06 21:42:27 +02:00
56 changed files with 2170 additions and 238 deletions
+46 -4
View File
@@ -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);
}
}
@@ -136,6 +141,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)
{
@@ -173,10 +179,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();
@@ -202,6 +205,7 @@ void ShopForm::changeReceipt()
ui->temporarySaveButton->setEnabled(true);
ui->saveButton->setEnabled(true);
ui->payButton->setEnabled(true);
fillRaceiptCombo();
}
@@ -213,6 +217,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())
@@ -233,3 +247,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();
}