Merge branch 'master' of https://git.bukova.info/repos/git/prodejna
This commit is contained in:
+2
-2
@@ -50,7 +50,7 @@ void Context::loadPlugins()
|
||||
m_plugins.append(new Users);
|
||||
m_plugins.append(new Roles);
|
||||
|
||||
QDir pluginsDir(qApp->applicationDirPath() + "/../plugins");
|
||||
QDir pluginsDir(qApp->applicationDirPath() + "/../../plugins");
|
||||
|
||||
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
|
||||
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
|
||||
@@ -144,7 +144,7 @@ void Context::checkDb(const QString &path)
|
||||
db.open();
|
||||
QSqlQuery q(db);
|
||||
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))
|
||||
{
|
||||
|
||||
+2
-1
@@ -1,12 +1,13 @@
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
#include "core_global.h"
|
||||
#include <QString>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
|
||||
#pragma db object
|
||||
class System
|
||||
class CORESHARED_EXPORT System
|
||||
{
|
||||
public:
|
||||
System();
|
||||
|
||||
+7
-1
@@ -11,7 +11,13 @@ class CORESHARED_EXPORT Enums : public QObject
|
||||
Q_ENUMS(VatType)
|
||||
public:
|
||||
|
||||
enum VatType { HIGH,FIRST_LOWER,SECOND_LOWER };
|
||||
enum VatType
|
||||
{
|
||||
NONE,
|
||||
HIGH,
|
||||
FIRST_LOWER,
|
||||
SECOND_LOWER
|
||||
};
|
||||
|
||||
Enums()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#include "globalsettings.h"
|
||||
#include <define.h>
|
||||
|
||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_ic = 0;
|
||||
m_vatHigh = 0;
|
||||
m_vatFirstLower = 0;
|
||||
m_vatSecondLower = 0;
|
||||
}
|
||||
|
||||
QString GlobalSettings::firmName() const
|
||||
@@ -94,3 +98,33 @@ void GlobalSettings::setLogoPath(const QString &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 <QString>
|
||||
#include <QDecDouble.hh>
|
||||
#include "../core_global.h"
|
||||
|
||||
class GlobalSettings : public QObject
|
||||
class CORESHARED_EXPORT GlobalSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -17,6 +19,9 @@ class GlobalSettings : public QObject
|
||||
Q_PROPERTY(QString dic READ dic WRITE setDic)
|
||||
Q_PROPERTY(bool vatPayer READ vatPayer WRITE setVatPayer)
|
||||
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:
|
||||
explicit GlobalSettings(QObject *parent = 0);
|
||||
|
||||
@@ -47,6 +52,15 @@ public:
|
||||
QString logoPath() const;
|
||||
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:
|
||||
QString m_firmName;
|
||||
QString m_street;
|
||||
@@ -57,6 +71,9 @@ private:
|
||||
QString m_dic;
|
||||
bool m_vatPayer;
|
||||
QString m_logoPath;
|
||||
int m_vatHigh;
|
||||
int m_vatFirstLower;
|
||||
int m_vatSecondLower;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ GlobalSettingsForm::GlobalSettingsForm(QWidget *parent) :
|
||||
registerBinding(ui->ic);
|
||||
registerBinding(ui->vatPayer);
|
||||
registerBinding(ui->dic);
|
||||
registerBinding(ui->vatHigh);
|
||||
registerBinding(ui->vatFirstLower);
|
||||
registerBinding(ui->vatSecondLower);
|
||||
}
|
||||
|
||||
GlobalSettingsForm::~GlobalSettingsForm()
|
||||
@@ -39,4 +42,10 @@ void GlobalSettingsForm::loadEntity()
|
||||
SettingsService srv("CORE");
|
||||
QSharedPointer<GlobalSettings> settings = srv.loadSettings<GlobalSettings>();
|
||||
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
|
||||
public:
|
||||
void loadEntity() override;
|
||||
private slots:
|
||||
void on_vatPayer_toggled(bool checked);
|
||||
};
|
||||
|
||||
#endif // GLOBALSETTINGSFORM_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>422</width>
|
||||
<height>323</height>
|
||||
<width>586</width>
|
||||
<height>419</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -20,6 +20,9 @@
|
||||
<string>Company info</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
@@ -47,6 +50,63 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
+16
-1
@@ -7,6 +7,8 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QMetaProperty>
|
||||
|
||||
#include <QDecDouble.hh>
|
||||
|
||||
#include "data/system.h"
|
||||
#include "service.h"
|
||||
#include "core_global.h"
|
||||
@@ -43,6 +45,12 @@ public:
|
||||
const char *propName = objSettings->metaObject()->property(i).name();
|
||||
QJsonValue v = val.toObject()[propName];
|
||||
QVariant varVal = v.toVariant();
|
||||
|
||||
if (objSettings->property(propName).canConvert<QDecDouble>())
|
||||
{
|
||||
QDecDouble dec(TO_DEC(varVal.toInt()));
|
||||
varVal = QVariant::fromValue(dec);
|
||||
}
|
||||
objSettings->setProperty(propName, varVal);
|
||||
}
|
||||
|
||||
@@ -59,7 +67,14 @@ public:
|
||||
for (int i = 0; i < objSettingsQo->metaObject()->propertyCount(); i++)
|
||||
{
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user