diff --git a/accommodation/accommodation.pro b/accommodation/accommodation.pro index 8634a1f..905e0d7 100644 --- a/accommodation/accommodation.pro +++ b/accommodation/accommodation.pro @@ -60,3 +60,10 @@ ODB_FILES = accommodation/data/accommodation-data.h H_DIR = $$PWD/data/*.h include(../odb.pri) +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber + +INCLUDEPATH += $$PWD/../qdecimal/src +INCLUDEPATH += $$PWD/../qdecimal/decnumber + diff --git a/application/application.pro b/application/application.pro index 8f70e76..b41a177 100644 --- a/application/application.pro +++ b/application/application.pro @@ -47,5 +47,12 @@ else:unix: LIBS += -L$$OUT_PWD/../core/ -lcore INCLUDEPATH += $$PWD/../core DEPENDPATH += $$PWD/../core +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber + +INCLUDEPATH += $$PWD/../qdecimal/src +INCLUDEPATH += $$PWD/../qdecimal/decnumber + RESOURCES += \ appRc.qrc diff --git a/core/autoform.h b/core/autoform.h index e288811..3970c3e 100644 --- a/core/autoform.h +++ b/core/autoform.h @@ -10,6 +10,9 @@ #include #include #include +#include + +#include "../qdecimal/src/QDecDouble.hh" #include "iform.h" #include "service.h" @@ -77,7 +80,15 @@ private: registerCombos(); foreach (QWidget *widget, m_bindWidgets) { const char* prop = widget->metaObject()->userProperty().name(); - widget->setProperty(prop, ((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str())); + QVariant value = ((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str()); + if (value.canConvert()) + { + widget->setProperty(prop, value.value().toString()); + } + else + { + widget->setProperty(prop, value); + } } foreach (QComboBox *combo, m_bindCombos.keys()) { @@ -117,7 +128,14 @@ private: foreach (QWidget *widget, m_bindWidgets) { const char* prop = widget->metaObject()->userProperty().name(); - ((QObject*)m_entity.data())->setProperty(widget->objectName().toStdString().c_str(), widget->property(prop)); + + QVariant val = widget->property(prop); + if (((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str()).canConvert()) + { + QDecDouble dec(val.toDouble()); + val = QVariant::fromValue(dec); + } + ((QObject*)m_entity.data())->setProperty(widget->objectName().toStdString().c_str(), val); } foreach (QComboBox *combo, m_bindCombos.keys()) { diff --git a/core/autotablemodel.h b/core/autotablemodel.h index 196b935..2e5c309 100644 --- a/core/autotablemodel.h +++ b/core/autotablemodel.h @@ -5,6 +5,9 @@ #include #include #include +#include + +#include "../qdecimal/src/QDecDouble.hh" #include "define.h" #include "core_global.h" @@ -58,6 +61,11 @@ public: return qobject_cast(dispData.value())->toString(); } + if (dispData.canConvert()) + { + return dispData.value().toDouble(); + } + return dispData; } diff --git a/core/core.pro b/core/core.pro index 8fce268..9478801 100644 --- a/core/core.pro +++ b/core/core.pro @@ -127,4 +127,9 @@ OTHER_FILES += \ users/metaData.json \ roles/metaData.json -TRANSLATIONS = core_cz.ts +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber + +INCLUDEPATH += $$PWD/../qdecimal/src +INCLUDEPATH += $$PWD/../qdecimal/decnumber diff --git a/core/define.h b/core/define.h index 42ac1a7..850b245 100644 --- a/core/define.h +++ b/core/define.h @@ -9,5 +9,7 @@ #define PERM_EDIT "EDIT" #define PERM_DELETE "DELETE" +#define DEC_MULTIPLE 100 + #endif // DEFINE_H diff --git a/core/enums.h b/core/enums.h index 1c7858a..e41e5de 100644 --- a/core/enums.h +++ b/core/enums.h @@ -2,18 +2,19 @@ #define ENUMS_H #include +#include "core_global.h" -class Enums : public QObject +class CORESHARED_EXPORT Enums : public QObject { Q_OBJECT + Q_ENUMS(VatType) - public: +public: enum VatType { HIGH,FIRST_LOWER,SECOND_LOWER }; Enums() { - } }; diff --git a/odb.pri b/odb.pri index 43ad744..146fac5 100644 --- a/odb.pri +++ b/odb.pri @@ -43,6 +43,8 @@ DEFINES += DATABASE_SQLITE ODB_FLAGS += -I $$[QT_INSTALL_HEADERS] ODB_FLAGS += -I $$[QT_INSTALL_HEADERS]/QtCore ODB_FLAGS += -I $$PWD/core +ODB_FLAGS += -I $$PWD/qdecimal/src +ODB_FLAGS += -I $$PWD/qdecimal/decnumber ODB_FLAGS += -D __PIC__ win32 { diff --git a/services/data/accservice.cpp b/services/data/accservice.cpp index 3b8fd50..b3aa13c 100644 --- a/services/data/accservice.cpp +++ b/services/data/accservice.cpp @@ -1,4 +1,5 @@ #include "accservice.h" +#include AccService::AccService() { @@ -14,14 +15,14 @@ void AccService::setId(int id) { m_id = id; } -int AccService::price() const +QDecDouble AccService::price() const { - return m_price; + return QDecDouble((double)m_price / DEC_MULTIPLE); } -void AccService::setPrice(int price) +void AccService::setPrice(QDecDouble price) { - m_price = price; + m_price = price.toDouble() * DEC_MULTIPLE; } bool AccService::active() const { diff --git a/services/data/accservice.h b/services/data/accservice.h index 9043016..af512ba 100644 --- a/services/data/accservice.h +++ b/services/data/accservice.h @@ -3,6 +3,7 @@ #include #include +#include #include @@ -15,7 +16,7 @@ class AccService : public QObject Q_PROPERTY(QString accServiceName READ accServiceName WRITE setAccServiceName) Q_PROPERTY(QString accServiceCode READ accServiceCode WRITE setAccServiceCode) - Q_PROPERTY(int price READ price WRITE setPrice) + Q_PROPERTY(QDecDouble price READ price WRITE setPrice) Q_PROPERTY(bool active READ active WRITE setActive) Q_PROPERTY(bool salePossible READ salePossible WRITE setSalePossible) Q_PROPERTY(ServiceType serviceType READ serviceType WRITE setServiceType) @@ -32,8 +33,8 @@ public: int id() const; void setId(int id); - int price() const; - void setPrice(int price); + QDecDouble price() const; + void setPrice(QDecDouble price); bool active() const; void setActive(bool active); diff --git a/services/service.json b/services/service.json index c35c844..ebdabf0 100644 --- a/services/service.json +++ b/services/service.json @@ -17,7 +17,7 @@ \"price\" INTEGER NOT NULL, \"active\" INTEGER NOT NULL, \"salePossible\" INTEGER NOT NULL, - \"serviceType\" INTEGER NOT NULL + \"serviceType\" INTEGER NOT NULL, \"vatType\" INTEGER NOT NULL);" ], diff --git a/services/services.pro b/services/services.pro index 2a80701..331dac1 100644 --- a/services/services.pro +++ b/services/services.pro @@ -57,11 +57,12 @@ include(../odb.pri) FORMS += \ accserviceform.ui -win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/release/ -lqdecimal -else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/debug/ -lqdecimal -else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber +else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber INCLUDEPATH += $$PWD/../qdecimal/src +INCLUDEPATH += $$PWD/../qdecimal/decnumber DEPENDPATH += $$PWD/../qdecimal/src #win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../qdecimal/src/release/libqdecimal.a