Added dashboard to Shop plugin.
This commit is contained in:
@@ -350,3 +350,19 @@ void Voucher::setId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
VoucherSum::VoucherSum()
|
||||
{
|
||||
m_totalPrice = 0;
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
QDecDouble VoucherSum::totalPrice() const
|
||||
{
|
||||
return TO_DEC(m_totalPrice);
|
||||
}
|
||||
|
||||
void VoucherSum::setTotalPrice(QDecDouble totalPrice)
|
||||
{
|
||||
m_totalPrice = FROM_DEC(totalPrice);
|
||||
}
|
||||
|
||||
@@ -210,4 +210,18 @@ private:
|
||||
|
||||
typedef QSharedPointer<Voucher> VoucherPtr;
|
||||
|
||||
#pragma db view object(Voucher)
|
||||
struct VoucherSum
|
||||
{
|
||||
VoucherSum();
|
||||
|
||||
QDecDouble totalPrice() const;
|
||||
void setTotalPrice(QDecDouble totalPrice);
|
||||
|
||||
#pragma db column("count(id)")
|
||||
int m_count;
|
||||
#pragma db column("sum(totalPrice)")
|
||||
int m_totalPrice;
|
||||
};
|
||||
|
||||
#endif // VOUCHER_H
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@@ -4,6 +4,7 @@
|
||||
#include "shopservice.h"
|
||||
#include "settings/shopsettingsform.h"
|
||||
#include "shop-odb.hxx"
|
||||
#include "shopoverview.h"
|
||||
|
||||
Shop::Shop()
|
||||
{
|
||||
@@ -14,6 +15,7 @@ void Shop::initServiceUi()
|
||||
m_ui = new ShopForm();
|
||||
m_service = new ShopService();
|
||||
m_settingsUi = new ShopSettingsForm();
|
||||
m_dashboardWidgets << new ShopOverview();
|
||||
}
|
||||
|
||||
QIcon Shop::pluginIcon()
|
||||
|
||||
+6
-3
@@ -32,7 +32,8 @@ SOURCES += shop.cpp \
|
||||
isellableservice.cpp \
|
||||
data/favorititem.cpp \
|
||||
eetbatchdialog.cpp \
|
||||
iseller.cpp
|
||||
iseller.cpp \
|
||||
shopoverview.cpp
|
||||
|
||||
HEADERS += shop.h\
|
||||
shop_global.h \
|
||||
@@ -57,7 +58,8 @@ HEADERS += shop.h\
|
||||
data/favorititem.h \
|
||||
eetbatchdialog.h \
|
||||
favbutton.h \
|
||||
iseller.h
|
||||
iseller.h \
|
||||
shopoverview.h
|
||||
|
||||
include(../config_plugin.pri)
|
||||
|
||||
@@ -80,7 +82,8 @@ FORMS += \
|
||||
settings/shopsettingsform.ui \
|
||||
paydialog.ui \
|
||||
paydvouchersdialog.ui \
|
||||
eetbatchdialog.ui
|
||||
eetbatchdialog.ui \
|
||||
shopoverview.ui
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "shopoverview.h"
|
||||
#include "ui_shopoverview.h"
|
||||
#include "shop-odb.hxx"
|
||||
#include "shopservice.h"
|
||||
|
||||
ShopOverview::ShopOverview(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::ShopOverview)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
ShopOverview::~ShopOverview()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ShopOverview::refresh()
|
||||
{
|
||||
ShopService srv;
|
||||
|
||||
VoucherSum unpaid = srv.unpaidSummary();
|
||||
VoucherSum unsend = srv.unsendEET();
|
||||
|
||||
ui->labelUnapiedCount->setText(QString::number(unpaid.m_count));
|
||||
ui->labelUnpaiedAmount->setText(QString::number(unpaid.totalPrice().toDouble()));
|
||||
ui->labelUnsendEET->setText(QString::number(unsend.m_count));
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef SHOPOVERVIEW_H
|
||||
#define SHOPOVERVIEW_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <idashboardwidget.h>
|
||||
|
||||
namespace Ui {
|
||||
class ShopOverview;
|
||||
}
|
||||
|
||||
class ShopOverview : public QFrame, public IDashboardWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShopOverview(QWidget *parent = 0);
|
||||
~ShopOverview();
|
||||
|
||||
private:
|
||||
Ui::ShopOverview *ui;
|
||||
|
||||
// IDashboardWidget interface
|
||||
public:
|
||||
virtual void refresh() override;
|
||||
};
|
||||
|
||||
#endif // SHOPOVERVIEW_H
|
||||
@@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ShopOverview</class>
|
||||
<widget class="QFrame" name="ShopOverview">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>908</width>
|
||||
<height>95</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="shoprc.qrc">:/icons/shop_64x64.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Unpaid vouchers: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelUnapiedCount">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Unpaid amount:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="labelUnpaiedAmount">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unsend to EET:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="labelUnsendEET">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="shoprc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -7,5 +7,6 @@
|
||||
<file>icons/pay.svg</file>
|
||||
<file>icons/sendEet.svg</file>
|
||||
<file>icons/pay_24x24.png</file>
|
||||
<file>icons/shop_64x64.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -427,6 +427,34 @@ QList<ShopItemPtr> ShopService::allSellableItems()
|
||||
return items;
|
||||
}
|
||||
|
||||
VoucherSum ShopService::unpaidSummary()
|
||||
{
|
||||
Transaction tr;
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
typedef odb::query<VoucherSum> query;
|
||||
|
||||
VoucherSum sum = db->query_value<VoucherSum>("status = " + query::_ref((int)Voucher::NOT_PAID));
|
||||
|
||||
tr.commit();
|
||||
return sum;
|
||||
}
|
||||
|
||||
VoucherSum ShopService::unsendEET()
|
||||
{
|
||||
Transaction tr;
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
typedef odb::query<VoucherSum> query;
|
||||
|
||||
VoucherSum sum = db->query_value<VoucherSum>("(eetStatus = " + query::_ref((int)Voucher::EET_FOR_SEND)
|
||||
+ " OR eetStatus = " + query::_ref((int)Voucher::EET_ERROR)
|
||||
+ ") AND status = " + query::_ref((int)Voucher::PAID));
|
||||
|
||||
tr.commit();
|
||||
return sum;
|
||||
}
|
||||
|
||||
QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType)
|
||||
{
|
||||
return price * ((vatRate(vatType) / 100) + QDecDouble(1));
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
QList<VoucherPtr> paiedVouchers();
|
||||
QList<VoucherPtr> vouchersForEet();
|
||||
QList<ShopItemPtr> allSellableItems();
|
||||
VoucherSum unpaidSummary();
|
||||
VoucherSum unsendEET();
|
||||
|
||||
private:
|
||||
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);
|
||||
|
||||
Reference in New Issue
Block a user