|
|
@ -5,6 +5,9 @@
|
|
|
|
#include "receiptsaveform.h"
|
|
|
|
#include "receiptsaveform.h"
|
|
|
|
#include "receiptloadform.h"
|
|
|
|
#include "receiptloadform.h"
|
|
|
|
#include "shopservice.h"
|
|
|
|
#include "shopservice.h"
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
|
|
|
#include "shop-odb.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
ShopForm::ShopForm(QWidget *parent) :
|
|
|
|
ShopForm::ShopForm(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
QWidget(parent),
|
|
|
@ -18,6 +21,28 @@ ShopForm::~ShopForm()
|
|
|
|
delete ui;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ShopForm::loadLast()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_itemsModel = new AutoTableModel<VoucherItem>(this);
|
|
|
|
|
|
|
|
m_itemsModel->setEditableCols(QList<int>() << 1);
|
|
|
|
|
|
|
|
ui->actualReceipt->setModel(m_itemsModel);
|
|
|
|
|
|
|
|
ui->actualReceipt->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShopService srv;
|
|
|
|
|
|
|
|
QList<QSharedPointer<Voucher> > receipt = srv.all(QString("status = %1").arg(QString::number(Voucher::NEW)));
|
|
|
|
|
|
|
|
if (!receipt.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_voucher = receipt[0];
|
|
|
|
|
|
|
|
srv.loadItems(m_voucher);
|
|
|
|
|
|
|
|
m_itemsModel->setData(m_voucher->items());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
|
|
|
|
|
|
|
|
connect(item.data(), SIGNAL(countChanged()), this, SLOT(onCountChanged()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ShopForm::on_directSale_clicked()
|
|
|
|
void ShopForm::on_directSale_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_voucher.isNull())
|
|
|
|
if (m_voucher.isNull())
|
|
|
@ -73,17 +98,20 @@ void ShopForm::onCountChanged()
|
|
|
|
|
|
|
|
|
|
|
|
ShopService srv;
|
|
|
|
ShopService srv;
|
|
|
|
srv.calculate(m_voucher);
|
|
|
|
srv.calculate(m_voucher);
|
|
|
|
ui->total->setText(m_voucher->totalPrice().toString());
|
|
|
|
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
|
|
|
|
|
|
|
|
|
|
|
|
//if (m_voucher->status())
|
|
|
|
if (m_voucher->status() == Voucher::NEW && m_voucher->id() == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
srv.save(m_voucher);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
srv.update(m_voucher);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ShopForm::createVoucher()
|
|
|
|
void ShopForm::createVoucher()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ShopService srv;
|
|
|
|
ShopService srv;
|
|
|
|
m_voucher = srv.createVoucher();
|
|
|
|
m_voucher = srv.createVoucher();
|
|
|
|
m_itemsModel = new AutoTableModel<VoucherItem>(this);
|
|
|
|
|
|
|
|
m_itemsModel->setEditableCols(QList<int>() << 1);
|
|
|
|
|
|
|
|
ui->actualReceipt->setModel(m_itemsModel);
|
|
|
|
|
|
|
|
ui->actualReceipt->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|