Merge branch 'master' of https://git.bukova.info/repos/git/prodejna
This commit is contained in:
@@ -5,9 +5,16 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <odb/core.hxx>
|
#include <odb/core.hxx>
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#if defined(ADDRESSBOOK_LIBRARY)
|
||||||
|
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
#pragma db object
|
#pragma db object
|
||||||
class AddressbookData : public QObject
|
class ADDRESSBOOKSHARED_EXPORT AddressbookData : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString title READ title WRITE setTitle)
|
Q_PROPERTY(QString title READ title WRITE setTitle)
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ CommodityForm::CommodityForm(QWidget *parent) :
|
|||||||
registerBinding(ui->shortName);
|
registerBinding(ui->shortName);
|
||||||
registerBinding(ui->code);
|
registerBinding(ui->code);
|
||||||
registerBinding(ui->price);
|
registerBinding(ui->price);
|
||||||
QList<ComboData> vt ;
|
QList<ComboData> vt;
|
||||||
vt << ComboData(Enums::HIGH,tr("High")) << ComboData(Enums::FIRST_LOWER,tr("First Lower")) << ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
vt << ComboData(Enums::NONE,tr("None"))
|
||||||
registerBinding(ui->vat,vt);
|
<< ComboData(Enums::HIGH,tr("High"))
|
||||||
|
<< ComboData(Enums::FIRST_LOWER,tr("First Lower"))
|
||||||
|
<< ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
||||||
|
registerBinding(ui->vat, vt);
|
||||||
registerBinding(ui->count);
|
registerBinding(ui->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ bool CommoditySettingsForm::saveRecord()
|
|||||||
commodityService.erase(item);
|
commodityService.erase(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommoditySettingsForm::on_addCommodityType_clicked()
|
void CommoditySettingsForm::on_addCommodityType_clicked()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ CommodityData::CommodityData(QObject *parent)
|
|||||||
{
|
{
|
||||||
m_count = 0;
|
m_count = 0;
|
||||||
m_price = 0;
|
m_price = 0;
|
||||||
|
m_vat = Enums::NONE;
|
||||||
}
|
}
|
||||||
int CommodityData::id() const
|
int CommodityData::id() const
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -50,7 +50,7 @@ void Context::loadPlugins()
|
|||||||
m_plugins.append(new Users);
|
m_plugins.append(new Users);
|
||||||
m_plugins.append(new Roles);
|
m_plugins.append(new Roles);
|
||||||
|
|
||||||
QDir pluginsDir(qApp->applicationDirPath() + "/../plugins");
|
QDir pluginsDir(qApp->applicationDirPath() + "/../../plugins");
|
||||||
|
|
||||||
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
|
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
|
||||||
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
|
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
|
||||||
@@ -144,7 +144,7 @@ void Context::checkDb(const QString &path)
|
|||||||
db.open();
|
db.open();
|
||||||
QSqlQuery q(db);
|
QSqlQuery q(db);
|
||||||
QString verSql = "SELECT pluginId, schemaVersion FROM system";
|
QString verSql = "SELECT pluginId, schemaVersion FROM system";
|
||||||
QString createSysSql = "CREATE TABLE \"system\" (\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \"pluginId\" TEXT NULL, \"schemaVersion\" TEXT NULL)";
|
QString createSysSql = "CREATE TABLE \"system\" (\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \"pluginId\" TEXT NULL, \"schemaVersion\" TEXT NULL, \"settings\" TEXT NULL)";
|
||||||
|
|
||||||
if (q.exec(verSql))
|
if (q.exec(verSql))
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-1
@@ -1,12 +1,13 @@
|
|||||||
#ifndef SYSTEM_H
|
#ifndef SYSTEM_H
|
||||||
#define SYSTEM_H
|
#define SYSTEM_H
|
||||||
|
|
||||||
|
#include "core_global.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <odb/core.hxx>
|
#include <odb/core.hxx>
|
||||||
|
|
||||||
#pragma db object
|
#pragma db object
|
||||||
class System
|
class CORESHARED_EXPORT System
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
System();
|
System();
|
||||||
|
|||||||
+7
-1
@@ -11,7 +11,13 @@ class CORESHARED_EXPORT Enums : public QObject
|
|||||||
Q_ENUMS(VatType)
|
Q_ENUMS(VatType)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum VatType { HIGH,FIRST_LOWER,SECOND_LOWER };
|
enum VatType
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
HIGH,
|
||||||
|
FIRST_LOWER,
|
||||||
|
SECOND_LOWER
|
||||||
|
};
|
||||||
|
|
||||||
Enums()
|
Enums()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
#include "globalsettings.h"
|
#include "globalsettings.h"
|
||||||
|
#include <define.h>
|
||||||
|
|
||||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_ic = 0;
|
m_ic = 0;
|
||||||
|
m_vatHigh = 0;
|
||||||
|
m_vatFirstLower = 0;
|
||||||
|
m_vatSecondLower = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GlobalSettings::firmName() const
|
QString GlobalSettings::firmName() const
|
||||||
@@ -94,3 +98,33 @@ void GlobalSettings::setLogoPath(const QString &logoPath)
|
|||||||
{
|
{
|
||||||
m_logoPath = logoPath;
|
m_logoPath = logoPath;
|
||||||
}
|
}
|
||||||
|
QDecDouble GlobalSettings::vatHigh() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_vatHigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettings::setVatHigh(QDecDouble vatHigh)
|
||||||
|
{
|
||||||
|
m_vatHigh = FROM_DEC(vatHigh);
|
||||||
|
}
|
||||||
|
QDecDouble GlobalSettings::vatFirstLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_vatFirstLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettings::setVatFirstLower(QDecDouble vatFirstLower)
|
||||||
|
{
|
||||||
|
m_vatFirstLower = FROM_DEC(vatFirstLower);
|
||||||
|
}
|
||||||
|
QDecDouble GlobalSettings::vatSecondLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_vatSecondLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettings::setVatSecondLower(QDecDouble vatSecondLower)
|
||||||
|
{
|
||||||
|
m_vatSecondLower = FROM_DEC(vatSecondLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QDecDouble.hh>
|
||||||
|
#include "../core_global.h"
|
||||||
|
|
||||||
class GlobalSettings : public QObject
|
class CORESHARED_EXPORT GlobalSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -17,6 +19,9 @@ class GlobalSettings : public QObject
|
|||||||
Q_PROPERTY(QString dic READ dic WRITE setDic)
|
Q_PROPERTY(QString dic READ dic WRITE setDic)
|
||||||
Q_PROPERTY(bool vatPayer READ vatPayer WRITE setVatPayer)
|
Q_PROPERTY(bool vatPayer READ vatPayer WRITE setVatPayer)
|
||||||
Q_PROPERTY(QString logoPath READ logoPath WRITE setLogoPath)
|
Q_PROPERTY(QString logoPath READ logoPath WRITE setLogoPath)
|
||||||
|
Q_PROPERTY(QDecDouble vatHigh READ vatHigh WRITE setVatHigh)
|
||||||
|
Q_PROPERTY(QDecDouble vatFirstLower READ vatFirstLower WRITE setVatFirstLower)
|
||||||
|
Q_PROPERTY(QDecDouble vatSecondLower READ vatSecondLower WRITE setVatSecondLower)
|
||||||
public:
|
public:
|
||||||
explicit GlobalSettings(QObject *parent = 0);
|
explicit GlobalSettings(QObject *parent = 0);
|
||||||
|
|
||||||
@@ -47,6 +52,15 @@ public:
|
|||||||
QString logoPath() const;
|
QString logoPath() const;
|
||||||
void setLogoPath(const QString &logoPath);
|
void setLogoPath(const QString &logoPath);
|
||||||
|
|
||||||
|
QDecDouble vatHigh() const;
|
||||||
|
void setVatHigh(QDecDouble vatHigh);
|
||||||
|
|
||||||
|
QDecDouble vatFirstLower() const;
|
||||||
|
void setVatFirstLower(QDecDouble vatFirstLower);
|
||||||
|
|
||||||
|
QDecDouble vatSecondLower() const;
|
||||||
|
void setVatSecondLower(QDecDouble vatSecondLower);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_firmName;
|
QString m_firmName;
|
||||||
QString m_street;
|
QString m_street;
|
||||||
@@ -57,6 +71,9 @@ private:
|
|||||||
QString m_dic;
|
QString m_dic;
|
||||||
bool m_vatPayer;
|
bool m_vatPayer;
|
||||||
QString m_logoPath;
|
QString m_logoPath;
|
||||||
|
int m_vatHigh;
|
||||||
|
int m_vatFirstLower;
|
||||||
|
int m_vatSecondLower;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ GlobalSettingsForm::GlobalSettingsForm(QWidget *parent) :
|
|||||||
registerBinding(ui->ic);
|
registerBinding(ui->ic);
|
||||||
registerBinding(ui->vatPayer);
|
registerBinding(ui->vatPayer);
|
||||||
registerBinding(ui->dic);
|
registerBinding(ui->dic);
|
||||||
|
registerBinding(ui->vatHigh);
|
||||||
|
registerBinding(ui->vatFirstLower);
|
||||||
|
registerBinding(ui->vatSecondLower);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalSettingsForm::~GlobalSettingsForm()
|
GlobalSettingsForm::~GlobalSettingsForm()
|
||||||
@@ -39,4 +42,10 @@ void GlobalSettingsForm::loadEntity()
|
|||||||
SettingsService srv("CORE");
|
SettingsService srv("CORE");
|
||||||
QSharedPointer<GlobalSettings> settings = srv.loadSettings<GlobalSettings>();
|
QSharedPointer<GlobalSettings> settings = srv.loadSettings<GlobalSettings>();
|
||||||
setEntity(settings);
|
setEntity(settings);
|
||||||
|
ui->grpVat->setEnabled(settings->vatPayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsForm::on_vatPayer_toggled(bool checked)
|
||||||
|
{
|
||||||
|
ui->grpVat->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public slots:
|
|||||||
// IForm interface
|
// IForm interface
|
||||||
public:
|
public:
|
||||||
void loadEntity() override;
|
void loadEntity() override;
|
||||||
|
private slots:
|
||||||
|
void on_vatPayer_toggled(bool checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSETTINGSFORM_H
|
#endif // GLOBALSETTINGSFORM_H
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>422</width>
|
<width>586</width>
|
||||||
<height>323</height>
|
<height>419</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
<string>Company info</string>
|
<string>Company info</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -47,6 +50,63 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QGroupBox" name="grpVat">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>VAT rates</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>High</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="vatHigh">
|
||||||
|
<property name="buttonSymbols">
|
||||||
|
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>First lower</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="vatFirstLower">
|
||||||
|
<property name="buttonSymbols">
|
||||||
|
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>Second lower</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="vatSecondLower">
|
||||||
|
<property name="buttonSymbols">
|
||||||
|
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
+16
-1
@@ -7,6 +7,8 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QMetaProperty>
|
#include <QMetaProperty>
|
||||||
|
|
||||||
|
#include <QDecDouble.hh>
|
||||||
|
|
||||||
#include "data/system.h"
|
#include "data/system.h"
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
@@ -43,6 +45,12 @@ public:
|
|||||||
const char *propName = objSettings->metaObject()->property(i).name();
|
const char *propName = objSettings->metaObject()->property(i).name();
|
||||||
QJsonValue v = val.toObject()[propName];
|
QJsonValue v = val.toObject()[propName];
|
||||||
QVariant varVal = v.toVariant();
|
QVariant varVal = v.toVariant();
|
||||||
|
|
||||||
|
if (objSettings->property(propName).canConvert<QDecDouble>())
|
||||||
|
{
|
||||||
|
QDecDouble dec(TO_DEC(varVal.toInt()));
|
||||||
|
varVal = QVariant::fromValue(dec);
|
||||||
|
}
|
||||||
objSettings->setProperty(propName, varVal);
|
objSettings->setProperty(propName, varVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +67,14 @@ public:
|
|||||||
for (int i = 0; i < objSettingsQo->metaObject()->propertyCount(); i++)
|
for (int i = 0; i < objSettingsQo->metaObject()->propertyCount(); i++)
|
||||||
{
|
{
|
||||||
const char *propName = objSettings->metaObject()->property(i).name();
|
const char *propName = objSettings->metaObject()->property(i).name();
|
||||||
jsonObj[propName] = QJsonValue::fromVariant(objSettingsQo->property(propName));
|
QVariant val = objSettingsQo->property(propName);
|
||||||
|
if (val.canConvert<QDecDouble>())
|
||||||
|
{
|
||||||
|
int vat = FROM_DEC(val.value<QDecDouble>());
|
||||||
|
val = QVariant::fromValue(vat);
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObj[propName] = QJsonValue::fromVariant(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject jsonSettings;
|
QJsonObject jsonSettings;
|
||||||
|
|||||||
@@ -18,8 +18,11 @@ AccServiceForm::AccServiceForm(QWidget *parent) :
|
|||||||
cd << ComboData(AccService::CAR,tr("Car")) << ComboData(AccService::TENT,tr("Tent")) << ComboData(AccService::OTHER,tr("OTHER"));
|
cd << ComboData(AccService::CAR,tr("Car")) << ComboData(AccService::TENT,tr("Tent")) << ComboData(AccService::OTHER,tr("OTHER"));
|
||||||
registerBinding(ui->serviceType,cd);
|
registerBinding(ui->serviceType,cd);
|
||||||
QList<ComboData> vt ;
|
QList<ComboData> vt ;
|
||||||
vt << ComboData(Enums::HIGH,tr("High")) << ComboData(Enums::FIRST_LOWER,tr("First Lower")) << ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
vt << ComboData(Enums::NONE,tr("None"))
|
||||||
registerBinding(ui->vatType,vt);
|
<< ComboData(Enums::HIGH,tr("High"))
|
||||||
|
<< ComboData(Enums::FIRST_LOWER,tr("First Lower"))
|
||||||
|
<< ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
||||||
|
registerBinding(ui->vatType, vt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+131
-1
@@ -3,7 +3,18 @@
|
|||||||
|
|
||||||
Voucher::Voucher(QObject *parent) : QObject(parent)
|
Voucher::Voucher(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
m_vatRateHigh = 0;
|
||||||
|
m_vatRateFirstLower = 0;
|
||||||
|
m_vatRateSecondLower = 0;
|
||||||
|
m_priceNoVat = 0;
|
||||||
|
m_priceVatHigh = 0;
|
||||||
|
m_priceVatFirstLower = 0;
|
||||||
|
m_priceVatSecondLower = 0;
|
||||||
|
m_priceWitouthVat = 0;
|
||||||
|
m_totalPriceVatHigh = 0;
|
||||||
|
m_totalPriceVatFirstLower = 0;
|
||||||
|
m_totalPriceVatSecondLower = 0;
|
||||||
|
m_totalPrice = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Voucher::name() const
|
QString Voucher::name() const
|
||||||
@@ -74,10 +85,129 @@ void Voucher::addItem(QSharedPointer<VoucherItem> item)
|
|||||||
m_items.append(item);
|
m_items.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Voucher::removeItem(QSharedPointer<VoucherItem> item)
|
||||||
|
{
|
||||||
|
m_items.removeOne(item);
|
||||||
|
}
|
||||||
|
|
||||||
void Voucher::clearItems()
|
void Voucher::clearItems()
|
||||||
{
|
{
|
||||||
m_items.clear();
|
m_items.clear();
|
||||||
}
|
}
|
||||||
|
QDecDouble Voucher::vatRateHigh() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_vatRateHigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setVatRateHigh(QDecDouble vatRateHigh)
|
||||||
|
{
|
||||||
|
m_vatRateHigh = FROM_DEC(vatRateHigh);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::vatRateFirstLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_vatRateFirstLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setVatRateFirstLower(QDecDouble vatRateFirstLower)
|
||||||
|
{
|
||||||
|
m_vatRateFirstLower = FROM_DEC(vatRateFirstLower);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::vatRateSecondLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_vatRateSecondLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setVatRateSecondLower(QDecDouble vatRateSecondLower)
|
||||||
|
{
|
||||||
|
m_vatRateSecondLower = FROM_DEC(vatRateSecondLower);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::priceVatHigh() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_priceVatHigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setPriceVatHigh(QDecDouble priceVatHigh)
|
||||||
|
{
|
||||||
|
m_priceVatHigh = FROM_DEC(priceVatHigh);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::priceVatFirstLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_priceVatFirstLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setPriceVatFirstLower(QDecDouble priceVatFirstLower)
|
||||||
|
{
|
||||||
|
m_priceVatFirstLower = FROM_DEC(priceVatFirstLower);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::priceVatSecondLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_priceVatSecondLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setPriceVatSecondLower(QDecDouble priceVatSecondLower)
|
||||||
|
{
|
||||||
|
m_priceVatSecondLower = FROM_DEC(priceVatSecondLower);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::priceNoVat() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_priceNoVat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setPriceNoVat(QDecDouble priceNoVat)
|
||||||
|
{
|
||||||
|
m_priceNoVat = FROM_DEC(priceNoVat);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::priceWitouthVat() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_priceWitouthVat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setPriceWitouthVat(QDecDouble priceWitouthVat)
|
||||||
|
{
|
||||||
|
m_priceWitouthVat = FROM_DEC(priceWitouthVat);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::totalPriceVatHigh() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_totalPriceVatHigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setTotalPriceVatHigh(QDecDouble totalPriceVatHigh)
|
||||||
|
{
|
||||||
|
m_totalPriceVatHigh = FROM_DEC(totalPriceVatHigh);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::totalPriceVatFirstLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_totalPriceVatFirstLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setTotalPriceVatFirstLower(QDecDouble totalPriceVatFirstLower)
|
||||||
|
{
|
||||||
|
m_totalPriceVatFirstLower = FROM_DEC(totalPriceVatFirstLower);
|
||||||
|
}
|
||||||
|
QDecDouble Voucher::totalPriceVatSecondLower() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_totalPriceVatSecondLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Voucher::setTotalPriceVatSecondLower(QDecDouble totalPriceVatSecondLower)
|
||||||
|
{
|
||||||
|
m_totalPriceVatSecondLower = FROM_DEC(totalPriceVatSecondLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDecDouble Voucher::vatAmountHigh()
|
||||||
|
{
|
||||||
|
return m_totalPriceVatHigh - m_priceVatHigh;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDecDouble Voucher::vatAmountFirstLower()
|
||||||
|
{
|
||||||
|
return m_totalPriceVatFirstLower - m_priceVatFirstLower;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDecDouble Voucher::VatAmountSecondLower()
|
||||||
|
{
|
||||||
|
return m_totalPriceVatSecondLower - m_priceVatSecondLower;
|
||||||
|
}
|
||||||
|
|
||||||
int Voucher::id() const
|
int Voucher::id() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ class Voucher : public QObject
|
|||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(QString description READ description WRITE setDescription)
|
Q_PROPERTY(QString description READ description WRITE setDescription)
|
||||||
Q_PROPERTY(QSharedPointer<QObject> contact READ contact WRITE setContact)
|
Q_PROPERTY(QSharedPointer<QObject> contact READ contact WRITE setContact)
|
||||||
|
Q_PROPERTY(QDecDouble vatRateHigh READ vatRateHigh WRITE setVatRateHigh)
|
||||||
|
Q_PROPERTY(QDecDouble vatRateFirstLower READ vatRateFirstLower WRITE setVatRateFirstLower)
|
||||||
|
Q_PROPERTY(QDecDouble vatRateSecondLower READ vatRateSecondLower WRITE setVatRateSecondLower)
|
||||||
|
Q_PROPERTY(QDecDouble priceVatHigh READ priceVatHigh WRITE setPriceVatHigh)
|
||||||
|
Q_PROPERTY(QDecDouble priceVatFirstLower READ priceVatFirstLower WRITE setPriceVatFirstLower)
|
||||||
|
Q_PROPERTY(QDecDouble priceVatSecondLower READ priceVatSecondLower WRITE setPriceVatSecondLower)
|
||||||
Q_PROPERTY(QDecDouble totalPrice READ totalPrice WRITE setTotalPrice)
|
Q_PROPERTY(QDecDouble totalPrice READ totalPrice WRITE setTotalPrice)
|
||||||
Q_ENUMS(VoucherStatus)
|
Q_ENUMS(VoucherStatus)
|
||||||
Q_PROPERTY(VoucherStatus status READ status WRITE setStatus)
|
Q_PROPERTY(VoucherStatus status READ status WRITE setStatus)
|
||||||
@@ -56,8 +62,46 @@ public:
|
|||||||
void setItems(const QList<QSharedPointer<VoucherItem> > &items);
|
void setItems(const QList<QSharedPointer<VoucherItem> > &items);
|
||||||
|
|
||||||
void addItem(QSharedPointer<VoucherItem> item);
|
void addItem(QSharedPointer<VoucherItem> item);
|
||||||
|
void removeItem(QSharedPointer<VoucherItem> item);
|
||||||
void clearItems();
|
void clearItems();
|
||||||
|
|
||||||
|
QDecDouble vatRateHigh() const;
|
||||||
|
void setVatRateHigh(QDecDouble vatRateHigh);
|
||||||
|
|
||||||
|
QDecDouble vatRateFirstLower() const;
|
||||||
|
void setVatRateFirstLower(QDecDouble vatRateFirstLower);
|
||||||
|
|
||||||
|
QDecDouble vatRateSecondLower() const;
|
||||||
|
void setVatRateSecondLower(QDecDouble vatRateSecondLower);
|
||||||
|
|
||||||
|
QDecDouble priceVatHigh() const;
|
||||||
|
void setPriceVatHigh(QDecDouble priceVatHigh);
|
||||||
|
|
||||||
|
QDecDouble priceVatFirstLower() const;
|
||||||
|
void setPriceVatFirstLower(QDecDouble priceVatFirstLower);
|
||||||
|
|
||||||
|
QDecDouble priceVatSecondLower() const;
|
||||||
|
void setPriceVatSecondLower(QDecDouble priceVatSecondLower);
|
||||||
|
|
||||||
|
QDecDouble priceNoVat() const;
|
||||||
|
void setPriceNoVat(QDecDouble priceNoVat);
|
||||||
|
|
||||||
|
QDecDouble priceWitouthVat() const;
|
||||||
|
void setPriceWitouthVat(QDecDouble priceWitouthVat);
|
||||||
|
|
||||||
|
QDecDouble totalPriceVatHigh() const;
|
||||||
|
void setTotalPriceVatHigh(QDecDouble totalPriceVatHigh);
|
||||||
|
|
||||||
|
QDecDouble totalPriceVatFirstLower() const;
|
||||||
|
void setTotalPriceVatFirstLower(QDecDouble totalPriceVatFirstLower);
|
||||||
|
|
||||||
|
QDecDouble totalPriceVatSecondLower() const;
|
||||||
|
void setTotalPriceVatSecondLower(QDecDouble totalPriceVatSecondLower);
|
||||||
|
|
||||||
|
QDecDouble vatAmountHigh();
|
||||||
|
QDecDouble vatAmountFirstLower();
|
||||||
|
QDecDouble VatAmountSecondLower();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class odb::access;
|
friend class odb::access;
|
||||||
#pragma db id auto
|
#pragma db id auto
|
||||||
@@ -65,6 +109,17 @@ private:
|
|||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
QSharedPointer<AddressbookData> m_contact;
|
QSharedPointer<AddressbookData> m_contact;
|
||||||
|
int m_vatRateHigh;
|
||||||
|
int m_vatRateFirstLower;
|
||||||
|
int m_vatRateSecondLower;
|
||||||
|
int m_priceNoVat;
|
||||||
|
int m_priceVatHigh;
|
||||||
|
int m_priceVatFirstLower;
|
||||||
|
int m_priceVatSecondLower;
|
||||||
|
int m_priceWitouthVat;
|
||||||
|
int m_totalPriceVatHigh;
|
||||||
|
int m_totalPriceVatFirstLower;
|
||||||
|
int m_totalPriceVatSecondLower;
|
||||||
int m_totalPrice;
|
int m_totalPrice;
|
||||||
QOdbList<QSharedPointer<VoucherItem> > m_items;
|
QOdbList<QSharedPointer<VoucherItem> > m_items;
|
||||||
VoucherStatus m_status;
|
VoucherStatus m_status;
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ VoucherItem::VoucherItem(QObject *parent) : QObject(parent)
|
|||||||
m_unitPrice = 0;
|
m_unitPrice = 0;
|
||||||
m_count = 0;
|
m_count = 0;
|
||||||
m_refId = 0;
|
m_refId = 0;
|
||||||
|
m_vatType = Enums::NONE;
|
||||||
|
m_vatRate = 0;
|
||||||
|
m_priceWitouthVat = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoucherItem::id() const
|
int VoucherItem::id() const
|
||||||
@@ -37,6 +40,7 @@ int VoucherItem::count() const
|
|||||||
void VoucherItem::setCount(int count)
|
void VoucherItem::setCount(int count)
|
||||||
{
|
{
|
||||||
m_count = count;
|
m_count = count;
|
||||||
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDecDouble VoucherItem::unitPrice() const
|
QDecDouble VoucherItem::unitPrice() const
|
||||||
@@ -88,3 +92,28 @@ void VoucherItem::setVatType(const Enums::VatType &vatType)
|
|||||||
{
|
{
|
||||||
m_vatType = vatType;
|
m_vatType = vatType;
|
||||||
}
|
}
|
||||||
|
QDecDouble VoucherItem::vatRate() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_vatRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoucherItem::setVatRate(QDecDouble vatRate)
|
||||||
|
{
|
||||||
|
m_vatRate = FROM_DEC(vatRate);
|
||||||
|
}
|
||||||
|
QDecDouble VoucherItem::priceWitouthVat() const
|
||||||
|
{
|
||||||
|
return TO_DEC(m_priceWitouthVat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoucherItem::setPriceWitouthVat(QDecDouble priceWitouthVat)
|
||||||
|
{
|
||||||
|
m_priceWitouthVat = FROM_DEC(priceWitouthVat);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDecDouble VoucherItem::vatAmount() const
|
||||||
|
{
|
||||||
|
return m_price - m_priceWitouthVat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+17
-2
@@ -14,10 +14,12 @@ class VoucherItem : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(int count READ count WRITE setCount)
|
Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
|
||||||
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
|
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
|
||||||
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
|
|
||||||
Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType)
|
Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType)
|
||||||
|
Q_PROPERTY(QDecDouble vatRate READ vatRate WRITE setVatRate)
|
||||||
|
Q_PROPERTY(QDecDouble vatAmount READ vatAmount)
|
||||||
|
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VoucherItem(QObject *parent = 0);
|
explicit VoucherItem(QObject *parent = 0);
|
||||||
@@ -46,6 +48,17 @@ public:
|
|||||||
Enums::VatType vatType() const;
|
Enums::VatType vatType() const;
|
||||||
void setVatType(const Enums::VatType &vatType);
|
void setVatType(const Enums::VatType &vatType);
|
||||||
|
|
||||||
|
QDecDouble vatRate() const;
|
||||||
|
void setVatRate(QDecDouble vatRate);
|
||||||
|
|
||||||
|
QDecDouble priceWitouthVat() const;
|
||||||
|
void setPriceWitouthVat(QDecDouble priceWitouthVat);
|
||||||
|
|
||||||
|
QDecDouble vatAmount() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void countChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class odb::access;
|
friend class odb::access;
|
||||||
#pragma db id auto
|
#pragma db id auto
|
||||||
@@ -53,6 +66,8 @@ private:
|
|||||||
QString m_name;
|
QString m_name;
|
||||||
int m_count;
|
int m_count;
|
||||||
int m_unitPrice;
|
int m_unitPrice;
|
||||||
|
int m_vatRate;
|
||||||
|
int m_priceWitouthVat;
|
||||||
int m_price;
|
int m_price;
|
||||||
int m_refId;
|
int m_refId;
|
||||||
QString m_itemPlugin;
|
QString m_itemPlugin;
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ DirectSaleForm::DirectSaleForm(QWidget *parent) :
|
|||||||
m_binder.registerBinding(ui->name);
|
m_binder.registerBinding(ui->name);
|
||||||
m_binder.registerBinding(ui->unitPrice);
|
m_binder.registerBinding(ui->unitPrice);
|
||||||
m_binder.registerBinding(ui->count);
|
m_binder.registerBinding(ui->count);
|
||||||
|
|
||||||
|
QList<ComboData> vt;
|
||||||
|
vt << ComboData(Enums::NONE,tr("None"))
|
||||||
|
<< ComboData(Enums::HIGH,tr("High"))
|
||||||
|
<< ComboData(Enums::FIRST_LOWER,tr("First Lower"))
|
||||||
|
<< ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
||||||
|
|
||||||
|
m_binder.registerBinding(ui->vatType, vt);
|
||||||
m_binder.bindToUi();
|
m_binder.bindToUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-3
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>136</height>
|
<height>150</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -32,7 +32,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="unitPrice"/>
|
<widget class="QDoubleSpinBox" name="unitPrice">
|
||||||
|
<property name="maximum">
|
||||||
|
<double>9999999999.989999771118164</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="countLabel">
|
<widget class="QLabel" name="countLabel">
|
||||||
@@ -42,9 +46,23 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="count"/>
|
<widget class="QSpinBox" name="count">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>VAT rate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="vatType"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
DirectSaleItem::DirectSaleItem(QObject *parent) : QObject(parent)
|
DirectSaleItem::DirectSaleItem(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_count = 1;
|
m_count = 1;
|
||||||
|
m_vat = Enums::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DirectSaleItem::id()
|
int DirectSaleItem::id()
|
||||||
@@ -25,6 +26,11 @@ QString DirectSaleItem::pluginId()
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Enums::VatType DirectSaleItem::vatType()
|
||||||
|
{
|
||||||
|
return m_vat;
|
||||||
|
}
|
||||||
|
|
||||||
int DirectSaleItem::count() const
|
int DirectSaleItem::count() const
|
||||||
{
|
{
|
||||||
return m_count;
|
return m_count;
|
||||||
@@ -44,3 +50,8 @@ void DirectSaleItem::setUnitPrice(const QDecDouble &unitPrice)
|
|||||||
{
|
{
|
||||||
m_unitPrice = unitPrice;
|
m_unitPrice = unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DirectSaleItem::setVatType(Enums::VatType vat)
|
||||||
|
{
|
||||||
|
m_vat = vat;
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class DirectSaleItem : public QObject, public IShopItem
|
|||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
|
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
|
||||||
Q_PROPERTY(int count READ count WRITE setCount)
|
Q_PROPERTY(int count READ count WRITE setCount)
|
||||||
|
Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DirectSaleItem(QObject *parent = 0);
|
explicit DirectSaleItem(QObject *parent = 0);
|
||||||
@@ -25,6 +26,7 @@ public:
|
|||||||
QString name() override;
|
QString name() override;
|
||||||
QDecDouble unitPrice() override;
|
QDecDouble unitPrice() override;
|
||||||
QString pluginId() override;
|
QString pluginId() override;
|
||||||
|
Enums::VatType vatType() override;
|
||||||
|
|
||||||
int count() const;
|
int count() const;
|
||||||
void setCount(int count);
|
void setCount(int count);
|
||||||
@@ -33,10 +35,13 @@ public:
|
|||||||
|
|
||||||
void setUnitPrice(const QDecDouble &unitPrice);
|
void setUnitPrice(const QDecDouble &unitPrice);
|
||||||
|
|
||||||
|
void setVatType(Enums::VatType vatType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QDecDouble m_unitPrice;
|
QDecDouble m_unitPrice;
|
||||||
int m_count;
|
int m_count;
|
||||||
|
Enums::VatType m_vat;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIRECTSALEITEM_H
|
#endif // DIRECTSALEITEM_H
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "shop_global.h"
|
#include "shop_global.h"
|
||||||
#include <QDecDouble.hh>
|
#include <QDecDouble.hh>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <enums.h>
|
||||||
|
|
||||||
class SHOPSHARED_EXPORT IShopItem
|
class SHOPSHARED_EXPORT IShopItem
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ public:
|
|||||||
virtual int id() = 0;
|
virtual int id() = 0;
|
||||||
virtual QString name() = 0;
|
virtual QString name() = 0;
|
||||||
virtual QDecDouble unitPrice() = 0;
|
virtual QDecDouble unitPrice() = 0;
|
||||||
|
virtual Enums::VatType vatType() = 0;
|
||||||
virtual QString pluginId() = 0;
|
virtual QString pluginId() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+49
-35
@@ -11,45 +11,59 @@
|
|||||||
"schemaVersion" : 1,
|
"schemaVersion" : 1,
|
||||||
"sql" : [
|
"sql" : [
|
||||||
"CREATE TABLE \"VoucherItem\" (
|
"CREATE TABLE \"VoucherItem\" (
|
||||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
\"name\" TEXT NULL,
|
\"name\" TEXT NULL,
|
||||||
\"count\" INTEGER NOT NULL,
|
\"count\" INTEGER NOT NULL,
|
||||||
\"unitPrice\" INTEGER NOT NULL,
|
\"unitPrice\" INTEGER NOT NULL,
|
||||||
\"price\" INTEGER NOT NULL,
|
\"vatRate\" INTEGER NOT NULL,
|
||||||
\"refId\" INTEGER NOT NULL,
|
\"priceWitouthVat\" INTEGER NOT NULL,
|
||||||
\"itemPlugin\" TEXT NULL,
|
\"price\" INTEGER NOT NULL,
|
||||||
\"vatType\" INTEGER NOT NULL);
|
\"refId\" INTEGER NOT NULL,
|
||||||
|
\"itemPlugin\" TEXT NULL,
|
||||||
|
\"vatType\" INTEGER NOT NULL);
|
||||||
|
|
||||||
CREATE TABLE \"Voucher\" (
|
CREATE TABLE \"Voucher\" (
|
||||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
\"name\" TEXT NULL,
|
\"name\" TEXT NULL,
|
||||||
\"description\" TEXT NULL,
|
\"description\" TEXT NULL,
|
||||||
\"contact\" INTEGER NULL,
|
\"contact\" INTEGER NULL,
|
||||||
\"totalPrice\" INTEGER NOT NULL,
|
\"vatRateHigh\" INTEGER NOT NULL,
|
||||||
\"status\" INTEGER NOT NULL,
|
\"vatRateFirstLower\" INTEGER NOT NULL,
|
||||||
CONSTRAINT \"contact_fk\"
|
\"vatRateSecondLower\" INTEGER NOT NULL,
|
||||||
FOREIGN KEY (\"contact\")
|
\"priceNoVat\" INTEGER NOT NULL,
|
||||||
REFERENCES \"AddressbookData\" (\"id\")
|
\"priceVatHigh\" INTEGER NOT NULL,
|
||||||
DEFERRABLE INITIALLY DEFERRED);
|
\"priceVatFirstLower\" INTEGER NOT NULL,
|
||||||
|
\"priceVatSecondLower\" INTEGER NOT NULL,
|
||||||
|
\"priceWitouthVat\" INTEGER NOT NULL,
|
||||||
|
\"totalPriceVatHigh\" INTEGER NOT NULL,
|
||||||
|
\"totalPriceVatFirstLower\" INTEGER NOT NULL,
|
||||||
|
\"totalPriceVatSecondLower\" INTEGER NOT NULL,
|
||||||
|
\"totalPrice\" INTEGER NOT NULL,
|
||||||
|
\"status\" INTEGER NOT NULL,
|
||||||
|
CONSTRAINT \"contact_fk\"
|
||||||
|
FOREIGN KEY (\"contact\")
|
||||||
|
REFERENCES \"AddressbookData\" (\"id\")
|
||||||
|
DEFERRABLE INITIALLY DEFERRED);
|
||||||
|
|
||||||
CREATE TABLE \"Voucher_items\" (
|
CREATE TABLE \"Voucher_items\" (
|
||||||
\"object_id\" INTEGER NOT NULL,
|
\"object_id\" INTEGER NOT NULL,
|
||||||
\"index\" INTEGER NOT NULL,
|
\"index\" INTEGER NOT NULL,
|
||||||
\"value\" INTEGER NULL,
|
\"value\" INTEGER NULL,
|
||||||
CONSTRAINT \"object_id_fk\"
|
CONSTRAINT \"object_id_fk\"
|
||||||
FOREIGN KEY (\"object_id\")
|
FOREIGN KEY (\"object_id\")
|
||||||
REFERENCES \"Voucher\" (\"id\")
|
REFERENCES \"Voucher\" (\"id\")
|
||||||
ON DELETE CASCADE,
|
ON DELETE CASCADE,
|
||||||
CONSTRAINT \"value_fk\"
|
CONSTRAINT \"value_fk\"
|
||||||
FOREIGN KEY (\"value\")
|
FOREIGN KEY (\"value\")
|
||||||
REFERENCES \"VoucherItem\" (\"id\")
|
REFERENCES \"VoucherItem\" (\"id\")
|
||||||
DEFERRABLE INITIALLY DEFERRED);
|
DEFERRABLE INITIALLY DEFERRED);
|
||||||
|
|
||||||
CREATE INDEX \"Voucher_items_object_id_i\"
|
CREATE INDEX \"Voucher_items_object_id_i\"
|
||||||
ON \"Voucher_items\" (\"object_id\");
|
ON \"Voucher_items\" (\"object_id\");
|
||||||
|
|
||||||
CREATE INDEX \"Voucher_items_index_i\"
|
CREATE INDEX \"Voucher_items_index_i\"
|
||||||
ON \"Voucher_items\" (\"index\");"
|
ON \"Voucher_items\" (\"index\");
|
||||||
|
"
|
||||||
],
|
],
|
||||||
"dependencies" : [ "ADDRESSBOOK" ]
|
"dependencies" : [ "ADDRESSBOOK" ]
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-5
@@ -11,11 +11,6 @@ ShopForm::ShopForm(QWidget *parent) :
|
|||||||
ui(new Ui::ShopForm)
|
ui(new Ui::ShopForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ShopService srv;
|
|
||||||
m_voucher = srv.createVoucher();
|
|
||||||
m_itemsModel = new AutoTableModel<VoucherItem>(this);
|
|
||||||
m_itemsModel->setEditableCols(QList<int>() << 1);
|
|
||||||
ui->actualReceipt->setModel(m_itemsModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopForm::~ShopForm()
|
ShopForm::~ShopForm()
|
||||||
@@ -25,12 +20,19 @@ ShopForm::~ShopForm()
|
|||||||
|
|
||||||
void ShopForm::on_directSale_clicked()
|
void ShopForm::on_directSale_clicked()
|
||||||
{
|
{
|
||||||
|
if (m_voucher.isNull())
|
||||||
|
{
|
||||||
|
createVoucher();
|
||||||
|
}
|
||||||
|
|
||||||
DirectSaleForm *form = new DirectSaleForm(this);
|
DirectSaleForm *form = new DirectSaleForm(this);
|
||||||
|
|
||||||
connect(form, &QDialog::accepted, [this, form](){
|
connect(form, &QDialog::accepted, [this, form](){
|
||||||
ShopService srv;
|
ShopService srv;
|
||||||
srv.addShopItem(m_voucher, form->shopItem(), ((DirectSaleItem*)form->shopItem().data())->count());
|
srv.addShopItem(m_voucher, form->shopItem(), ((DirectSaleItem*)form->shopItem().data())->count());
|
||||||
this->m_itemsModel->addRow(m_voucher->items()[m_voucher->items().count() - 1]);
|
this->m_itemsModel->addRow(m_voucher->items()[m_voucher->items().count() - 1]);
|
||||||
|
connect(m_voucher->items()[m_voucher->items().count() - 1].data(), SIGNAL(countChanged()), this, SLOT(onCountChanged()));
|
||||||
|
onCountChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
form->show();
|
form->show();
|
||||||
@@ -53,3 +55,35 @@ void ShopForm::on_loadButton_clicked()
|
|||||||
ReceiptLoadForm *form = new ReceiptLoadForm;
|
ReceiptLoadForm *form = new ReceiptLoadForm;
|
||||||
form->show();
|
form->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShopForm::onCountChanged()
|
||||||
|
{
|
||||||
|
VoucherItem *item = qobject_cast<VoucherItem*>(sender());
|
||||||
|
if (item != NULL && item->count() == 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_voucher->items().count(); i++)
|
||||||
|
{
|
||||||
|
if (m_voucher->items()[i].data() == item)
|
||||||
|
{
|
||||||
|
m_voucher->removeItem(m_voucher->items()[i]);
|
||||||
|
m_itemsModel->setData(m_voucher->items());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShopService srv;
|
||||||
|
srv.calculate(m_voucher);
|
||||||
|
ui->total->setText(m_voucher->totalPrice().toString());
|
||||||
|
|
||||||
|
//if (m_voucher->status())
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShopForm::createVoucher()
|
||||||
|
{
|
||||||
|
ShopService srv;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,10 +27,14 @@ private slots:
|
|||||||
|
|
||||||
void on_loadButton_clicked();
|
void on_loadButton_clicked();
|
||||||
|
|
||||||
|
void onCountChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ShopForm *ui;
|
Ui::ShopForm *ui;
|
||||||
QSharedPointer<Voucher> m_voucher;
|
QSharedPointer<Voucher> m_voucher;
|
||||||
AutoTableModel<VoucherItem> *m_itemsModel;
|
AutoTableModel<VoucherItem> *m_itemsModel;
|
||||||
|
|
||||||
|
void createVoucher();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHOPFORM_H
|
#endif // SHOPFORM_H
|
||||||
|
|||||||
+181
-72
@@ -7,57 +7,186 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>959</width>
|
<width>959</width>
|
||||||
<height>531</height>
|
<height>582</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="commodity">
|
<widget class="QWidget" name="widgetComodity" native="true">
|
||||||
<property name="text">
|
<property name="maximumSize">
|
||||||
<string>Commodity</string>
|
<size>
|
||||||
|
<width>500</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="commodity">
|
||||||
|
<property name="text">
|
||||||
|
<string>Commodity</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="commoditySearch"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="commodityTable"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget_8" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Count</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinBox">
|
||||||
|
<property name="wrapping">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="buttonSymbols">
|
||||||
|
<enum>QAbstractSpinBox::UpDownArrows</enum>
|
||||||
|
</property>
|
||||||
|
<property name="showGroupSeparator" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add Item</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="commoditySearch"/>
|
<widget class="QWidget" name="widgetButtons" native="true">
|
||||||
</item>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QTableView" name="commodityTable"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget_8" native="true">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QWidget" name="favorites1" native="true">
|
||||||
<property name="text">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<string>Count</string>
|
<item row="0" column="1">
|
||||||
</property>
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QToolButton" name="directSale">
|
||||||
|
<property name="text">
|
||||||
|
<string>Direct Sale</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="shoprc.qrc">
|
||||||
|
<normaloff>:/icons/shop.svg</normaloff>:/icons/shop.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>45</width>
|
||||||
|
<height>45</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+D</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="spinBox">
|
<widget class="QWidget" name="widget_5" native="true">
|
||||||
<property name="wrapping">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<bool>false</bool>
|
<property name="leftMargin">
|
||||||
</property>
|
<number>0</number>
|
||||||
<property name="buttonSymbols">
|
</property>
|
||||||
<enum>QAbstractSpinBox::UpDownArrows</enum>
|
<property name="topMargin">
|
||||||
</property>
|
<number>0</number>
|
||||||
<property name="showGroupSeparator" stdset="0">
|
</property>
|
||||||
<bool>false</bool>
|
<property name="rightMargin">
|
||||||
</property>
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QGridLayout" name="favorites2"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QWidget" name="widget_6" native="true">
|
||||||
<property name="text">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
<string>Add Item</string>
|
<property name="leftMargin">
|
||||||
</property>
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QGridLayout" name="favorites3"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -67,44 +196,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget_2" native="true">
|
<widget class="QWidget" name="widgetReceipt" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="favorites1" native="true">
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QPushButton" name="directSale">
|
|
||||||
<property name="text">
|
|
||||||
<string>Direct Sale</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget_5" native="true">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QGridLayout" name="favorites2"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget_6" native="true">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QGridLayout" name="favorites3"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget_3" native="true">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="receipt">
|
<widget class="QLabel" name="receipt">
|
||||||
@@ -122,16 +214,30 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget_7" native="true">
|
<widget class="QWidget" name="widget_7" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<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>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Total</string>
|
<string>Total:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
@@ -142,6 +248,7 @@
|
|||||||
<widget class="QLabel" name="total">
|
<widget class="QLabel" name="total">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
@@ -196,6 +303,8 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="shoprc.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
+84
-3
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
ShopService::ShopService()
|
ShopService::ShopService()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<Voucher> ShopService::createVoucher()
|
QSharedPointer<Voucher> ShopService::createVoucher()
|
||||||
@@ -20,6 +19,7 @@ void ShopService::addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IS
|
|||||||
vItem->setCount(count);
|
vItem->setCount(count);
|
||||||
vItem->setRefId(item->id());
|
vItem->setRefId(item->id());
|
||||||
vItem->setItemPlugin(item->pluginId());
|
vItem->setItemPlugin(item->pluginId());
|
||||||
|
vItem->setVatType(item->vatType());
|
||||||
|
|
||||||
voucher->addItem(vItem);
|
voucher->addItem(vItem);
|
||||||
}
|
}
|
||||||
@@ -28,10 +28,91 @@ void ShopService::calculate(QSharedPointer<Voucher> voucher)
|
|||||||
{
|
{
|
||||||
QDecDouble total;
|
QDecDouble total;
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
voucher->setVatRateHigh(m_gs->vatHigh());
|
||||||
|
voucher->setVatRateFirstLower(m_gs->vatFirstLower());
|
||||||
|
voucher->setVatRateSecondLower(m_gs->vatSecondLower());
|
||||||
|
|
||||||
foreach (QSharedPointer<VoucherItem> item, voucher->items()) {
|
foreach (QSharedPointer<VoucherItem> item, voucher->items()) {
|
||||||
QDecDouble itemPrice = item->unitPrice() * item->count();
|
calculateItem(item);
|
||||||
total += itemPrice;
|
|
||||||
|
QDecDouble priceWitouthWat = item->priceWitouthVat();
|
||||||
|
switch (item->vatType()) {
|
||||||
|
case Enums::NONE:
|
||||||
|
voucher->setPriceNoVat(voucher->priceNoVat() + priceWitouthWat);
|
||||||
|
break;
|
||||||
|
case Enums::HIGH:
|
||||||
|
voucher->setPriceVatHigh(voucher->priceVatHigh() + priceWitouthWat);
|
||||||
|
break;
|
||||||
|
case Enums::FIRST_LOWER:
|
||||||
|
voucher->setPriceVatFirstLower(voucher->priceVatFirstLower() + priceWitouthWat);
|
||||||
|
break;
|
||||||
|
case Enums::SECOND_LOWER:
|
||||||
|
voucher->setPriceVatSecondLower(voucher->priceVatSecondLower() + priceWitouthWat);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += item->price();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
voucher->setTotalPriceVatHigh(includeVat(voucher->priceVatHigh(), Enums::HIGH));
|
||||||
|
voucher->setTotalPriceVatFirstLower(includeVat(voucher->priceVatFirstLower(), Enums::FIRST_LOWER));
|
||||||
|
voucher->setTotalPriceVatSecondLower(includeVat(voucher->priceVatSecondLower(), Enums::SECOND_LOWER));
|
||||||
voucher->setTotalPrice(total);
|
voucher->setTotalPrice(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShopService::calculateItem(QSharedPointer<VoucherItem> item)
|
||||||
|
{
|
||||||
|
loadSettings();
|
||||||
|
if (m_gs->vatPayer())
|
||||||
|
{
|
||||||
|
item->setVatRate(vatRate(item->vatType()));
|
||||||
|
item->setPriceWitouthVat(item->unitPrice() * item->count());
|
||||||
|
item->setPrice(includeVat(item->priceWitouthVat(), item->vatType()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item->setPrice(item->unitPrice() * item->count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType)
|
||||||
|
{
|
||||||
|
return price * ((vatRate(vatType) / 100) + QDecDouble(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShopService::loadSettings()
|
||||||
|
{
|
||||||
|
if (m_gs.isNull())
|
||||||
|
{
|
||||||
|
SettingsService settings("CORE");
|
||||||
|
m_gs = settings.loadSettings<GlobalSettings>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDecDouble ShopService::vatRate(Enums::VatType vatType)
|
||||||
|
{
|
||||||
|
QDecDouble vatRate;
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
switch (vatType) {
|
||||||
|
case Enums::NONE:
|
||||||
|
vatRate = 0;
|
||||||
|
break;
|
||||||
|
case Enums::HIGH:
|
||||||
|
vatRate = m_gs->vatHigh();
|
||||||
|
break;
|
||||||
|
case Enums::FIRST_LOWER:
|
||||||
|
vatRate = m_gs->vatFirstLower();
|
||||||
|
break;
|
||||||
|
case Enums::SECOND_LOWER:
|
||||||
|
vatRate = m_gs->vatSecondLower();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vatRate;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
#include <core.h>
|
#include <core.h>
|
||||||
|
#include <settings/globalsettings.h>
|
||||||
|
|
||||||
#include "data/shop-data.h"
|
#include "data/shop-data.h"
|
||||||
#include "ishopitem.h"
|
#include "ishopitem.h"
|
||||||
@@ -15,6 +16,14 @@ public:
|
|||||||
QSharedPointer<Voucher> createVoucher();
|
QSharedPointer<Voucher> createVoucher();
|
||||||
void addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count);
|
void addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count);
|
||||||
void calculate(QSharedPointer<Voucher> voucher);
|
void calculate(QSharedPointer<Voucher> voucher);
|
||||||
|
void calculateItem(QSharedPointer<VoucherItem> item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);
|
||||||
|
void loadSettings();
|
||||||
|
|
||||||
|
QSharedPointer<GlobalSettings> m_gs;
|
||||||
|
QDecDouble vatRate(Enums::VatType vatType);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHOPSERVICE_H
|
#endif // SHOPSERVICE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user