Implemented base functionality for commodity grid on shop form.

This commit is contained in:
2016-07-13 15:15:18 +02:00
parent f9d7df9ab5
commit fb6b4fe027
15 changed files with 138 additions and 10 deletions
+5
View File
@@ -0,0 +1,5 @@
#include "isellableservice.h"
ISellableService::ISellableService()
{
}
+4 -2
View File
@@ -2,14 +2,16 @@
#define ISELLABLESERVICE_H
#include "shop_global.h"
#include "ishopitem.h"
#include "shopitem.h"
#include <QList>
#include <QSharedPointer>
class SHOPSHARED_EXPORT ISellableService
{
public:
QList<QSharedPointer<IShopItem> > shopItems() = 0;
ISellableService();
virtual QList<QSharedPointer<ShopItem> > shopItems() = 0;
};
#endif // ISELLABLESERVICE_H
+5 -2
View File
@@ -26,7 +26,9 @@ SOURCES += shop.cpp \
settings/shopsettings.cpp \
settings/shopsettingsform.cpp \
paydialog.cpp \
paydvouchersdialog.cpp
paydvouchersdialog.cpp \
shopitem.cpp \
isellableservice.cpp
HEADERS += shop.h\
shop_global.h \
@@ -46,7 +48,8 @@ HEADERS += shop.h\
settings/shopsettings.h \
settings/shopsettingsform.h \
paydialog.h \
paydvouchersdialog.h
paydvouchersdialog.h \
shopitem.h
unix {
target.path = /usr/lib
+9
View File
@@ -18,6 +18,7 @@ ShopForm::ShopForm(QWidget *parent) :
{
ui->setupUi(this);
m_itemsModel = NULL;
m_commodityModel = NULL;
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
@@ -54,6 +55,14 @@ void ShopForm::loadLast()
ui->saveButton->setEnabled(true);
ui->payButton->setEnabled(true);
}
if (m_commodityModel == NULL)
{
m_commodityModel = new AutoTableModel<ShopItem>(this);
ui->commodityTable->setModel(m_commodityModel);
}
m_commodityModel->setData(srv.allSellableItems());
}
void ShopForm::fillRaceiptCombo()
+3
View File
@@ -6,6 +6,8 @@
#include "data/shop-data.h"
#include <autotablemodel.h>
class ShopItem;
namespace Ui {
class ShopForm;
}
@@ -41,6 +43,7 @@ private:
Ui::ShopForm *ui;
QSharedPointer<Voucher> m_voucher;
AutoTableModel<VoucherItem> *m_itemsModel;
AutoTableModel<ShopItem> *m_commodityModel;
void createVoucher();
void doTempSave(bool comboChanged);
+6
View File
@@ -0,0 +1,6 @@
#include "shopitem.h"
ShopItem::ShopItem(QObject *parent) : QObject(parent)
{
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef SHOPITEM_H
#define SHOPITEM_H
#include <QObject>
#include "shop_global.h"
#include "ishopitem.h"
class SHOPSHARED_EXPORT ShopItem : public QObject, public IShopItem
{
Q_OBJECT
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QDecDouble unitPrice READ unitPrice)
Q_PROPERTY(Enums::VatType vatType READ vatType)
public:
explicit ShopItem(QObject *parent = 0);
signals:
public slots:
// IShopItem interface
public:
virtual int id() override { return 0; }
virtual QString name() override { return ""; }
virtual QDecDouble unitPrice() override { return QDecDouble(); }
virtual Enums::VatType vatType() override { return Enums::NONE; }
virtual QString pluginId() override { return ""; }
};
#endif // SHOPITEM_H
+17
View File
@@ -1,5 +1,6 @@
#include "shopservice.h"
#include "numberseriesservice.h"
#include "isellableservice.h"
#include "shop-odb.hxx"
ShopService::ShopService()
@@ -120,6 +121,22 @@ QList<QSharedPointer<Voucher> > ShopService::paiedVouchers()
return all(QString("status = %1").arg(QString::number(Voucher::PAID)));
}
QList<QSharedPointer<ShopItem> > ShopService::allSellableItems()
{
QList<QSharedPointer<ShopItem> > items;
foreach (IPlugin *plugin, Context::instance().plugins()) {
IService *srv = plugin->service<IService>();
ISellableService *selSrv = dynamic_cast<ISellableService*>(srv);
if (selSrv != NULL)
{
items.append(selSrv->shopItems());
}
}
return items;
}
QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType)
{
return price * ((vatRate(vatType) / 100) + QDecDouble(1));
+2 -1
View File
@@ -7,7 +7,7 @@
#include <settings/globalsettings.h>
#include "data/shop-data.h"
#include "ishopitem.h"
#include "shopitem.h"
class ShopService : public Service<Voucher>
{
@@ -22,6 +22,7 @@ public:
QList<QSharedPointer<Voucher> > savedVouchers();
QList<QSharedPointer<Voucher> > tempVouchers();
QList<QSharedPointer<Voucher> > paiedVouchers();
QList<QSharedPointer<ShopItem> > allSellableItems();
private:
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);