From 3a4c517a7585a8df40e416ec0c488a7eb086321c Mon Sep 17 00:00:00 2001 From: Zdenek Jonak Date: Mon, 12 Oct 2026 16:29:43 +0200 Subject: [PATCH] fix problems from tests --- commodity/data/commoditydata.cpp | 2 +- core/define.h | 4 +++- core/service.h | 5 ++++- services/data/accservice.cpp | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/commodity/data/commoditydata.cpp b/commodity/data/commoditydata.cpp index 54173ca..822d005 100644 --- a/commodity/data/commoditydata.cpp +++ b/commodity/data/commoditydata.cpp @@ -84,7 +84,7 @@ QDecDouble CommodityData::price() const void CommodityData::setPrice(const QDecDouble &price) { - m_price = price.toDouble() * DEC_MULTIPLE; + m_price = qRound(price.toDouble() * DEC_MULTIPLE); } Enums::VatType CommodityData::vat() const { diff --git a/core/define.h b/core/define.h index d44ab98..9cb0e7e 100644 --- a/core/define.h +++ b/core/define.h @@ -1,6 +1,8 @@ #ifndef DEFINE_H #define DEFINE_H +#include + #define ALL(arr) arr.begin(), arr.end() // default rights @@ -11,7 +13,7 @@ #define DEC_MULTIPLE 100 #define TO_DEC(num) (QDecDouble(num) / QDecDouble(DEC_MULTIPLE)) -#define FROM_DEC(num) (num * QDecDouble(DEC_MULTIPLE)).toDouble() +#define FROM_DEC(num) qRound((num * QDecDouble(DEC_MULTIPLE)).toDouble()) #ifndef PLUGIN_ROOT #ifdef _WIN32 diff --git a/core/service.h b/core/service.h index 6dcf5ac..9c718bb 100644 --- a/core/service.h +++ b/core/service.h @@ -237,7 +237,10 @@ protected: } else { - obj->setProperty("updatedBy", Context::instance().currentUser()->login()); + if (!Context::instance().currentUser().isNull()) { + obj->setProperty("updatedBy", Context::instance().currentUser()->login()); + } + obj->setProperty("updated", QDateTime::currentDateTime()); } } diff --git a/services/data/accservice.cpp b/services/data/accservice.cpp index 4ecde08..f9f4506 100644 --- a/services/data/accservice.cpp +++ b/services/data/accservice.cpp @@ -39,7 +39,7 @@ QDecDouble AccService::price() const void AccService::setPrice(QDecDouble price) { - m_price = price.toDouble() * DEC_MULTIPLE; + m_price = qRound(price.toDouble() * DEC_MULTIPLE); } bool AccService::active() const {