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

This commit is contained in:
2017-05-29 14:08:06 +02:00
parent 87290d4be4
commit b941acf9a0
8 changed files with 38 additions and 6 deletions
+10
View File
@@ -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;
+5
View File
@@ -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;
+5 -1
View File
@@ -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" ],
+6 -5
View File
@@ -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();