Added support for VAT calculations.
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();
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDecDouble.hh>
|
||||
#include "../core_global.h"
|
||||
|
||||
class GlobalSettings : public QObject
|
||||
class CORESHARED_EXPORT GlobalSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -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