Improved work with number series. Added season to voucher record.

master
Josef Rokos 8 years ago
parent 87290d4be4
commit b941acf9a0

@ -17,6 +17,7 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../core/debug/ -lco
else:unix: LIBS += -L$$OUT_PWD/../core/ -lcore
INCLUDEPATH += $$PWD/core
INCLUDEPATH += $$PWD/core/data
DEPENDPATH += $$PWD/core
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber

@ -51,3 +51,12 @@ QList<QSharedPointer<NumberSeries> > NumberSeriesService::allForSeason(QSharedPo
{
return all(QString("season = %1").arg(QString::number(season->id())));
}
QString NumberSeriesService::nextStrForPlugin(QString pluginId)
{
NumberSeriesPtr numSer = nextForPlugin(pluginId);
QString numSerStr;
numSerStr.sprintf("%s%05d", numSer->prefix().toStdString().c_str(), numSer->lastNumber());
return numSerStr;
}

@ -15,6 +15,7 @@ public:
QSharedPointer<NumberSeries> forPlugin(QString pluginId);
QSharedPointer<NumberSeries> nextForPlugin(QString pluginId);
QList<QSharedPointer<NumberSeries> > allForSeason(QSharedPointer<Season> season);
QString nextStrForPlugin(QString pluginId);
};
#endif // NUMBERSERIESSERVICE_H

@ -45,6 +45,7 @@ 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/core/data
ODB_FLAGS += -I $$PWD/qdecimal/src
ODB_FLAGS += -I $$PWD/qdecimal/decnumber
ODB_FLAGS += $$ODB_OTHER_INCLUDES

@ -291,6 +291,16 @@ void Voucher::setSaveDateTime(const QDateTime &saveDateTime)
m_saveDateTime = saveDateTime;
}
SeasonPtr Voucher::season() const
{
return m_season;
}
void Voucher::setSeason(const SeasonPtr &season)
{
m_season = season;
}
int Voucher::id() const
{
return m_id;

@ -6,6 +6,7 @@
#include <QString>
#include <QSharedPointer>
#include <addressbookdata.h>
#include <season.h>
#include <odb/core.hxx>
#include <odb/qt/list.hxx>
@ -143,6 +144,9 @@ public:
QDateTime saveDateTime() const;
void setSaveDateTime(const QDateTime &saveDateTime);
SeasonPtr season() const;
void setSeason(const SeasonPtr &season);
private:
friend class odb::access;
#pragma db id auto
@ -173,6 +177,7 @@ private:
#pragma db value_not_null inverse(m_voucher)
QOdbList<QSharedPointer<VoucherItem> > m_items;
VoucherStatus m_status;
SeasonPtr m_season;
};
typedef QSharedPointer<Voucher> VoucherPtr;

@ -8,7 +8,7 @@
"default" : "",
"CZ" : ""
},
"schemaVersion" : 5,
"schemaVersion" : 6,
"sql" : [
"CREATE TABLE \"VoucherItem\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
@ -72,6 +72,10 @@ CREATE TABLE \"Voucher\" (
\"favButtonName\" TEXT NULL);
",
"ALTER TABLE \"FavoritItem\" ADD \"shortName\" TEXT NULL;
",
"ALTER TABLE \"Voucher\" ADD \"season\" INTEGER NULL;
UPDATE \"Voucher\" SET season = (SELECT id FROM \"Season\" WHERE active = 1);
"
],
"dependencies" : [ "ADDRESSBOOK" ],

@ -7,6 +7,7 @@
#include <eetcpp.h>
#include <QEventLoop>
#include <seasonservice.h>
ShopService::ShopService()
{
@ -101,11 +102,7 @@ void ShopService::pay(VoucherPtr voucher)
Transaction tx;
NumberSeriesService srvNs;
NumberSeriesPtr numSer = srvNs.nextForPlugin("SHOP");
QString numSerStr;
numSerStr.sprintf("%s%05d", numSer->prefix().toStdString().c_str(), numSer->lastNumber());
voucher->setNumSer(numSerStr);
voucher->setNumSer(srvNs.nextStrForPlugin("SHOP"));
voucher->setStatus(Voucher::PAID);
voucher->setEetStatus(Voucher::EET_FOR_SEND);
voucher->setPayDateTime(QDateTime::currentDateTime());
@ -345,6 +342,10 @@ QDecDouble ShopService::vatRate(Enums::VatType vatType)
void ShopService::saveVoucher(VoucherPtr entity)
{
SeasonService seasonSrv;
SeasonPtr season = seasonSrv.active();
entity->setSeason(season);
Transaction tr;
odb::database *db = Context::instance().db();

Loading…
Cancel
Save