Josef Rokos 8 years ago
commit e733901286

@ -42,16 +42,19 @@ MainWindow::MainWindow(QWidget *parent) :
int i = 0;
foreach (IPlugin *plugin, Context::instance().plugins()) {
QToolButton *plugButton = new QToolButton(this);
plugButton->setText(plugin->pluginName());
plugButton->setIcon(plugin->pluginIcon());
plugButton->setIconSize(QSize(32, 32));
plugButton->setAutoRaise(true);
plugButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui->navigation->layout()->addWidget(plugButton);
plugButton->setProperty(PLUGIN_INDEX, i);
if (plugin->pluginId() != "CORE")
{
QToolButton *plugButton = new QToolButton(this);
plugButton->setText(plugin->pluginName());
plugButton->setIcon(plugin->pluginIcon());
plugButton->setIconSize(QSize(32, 32));
plugButton->setAutoRaise(true);
plugButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui->navigation->layout()->addWidget(plugButton);
plugButton->setProperty(PLUGIN_INDEX, i);
connect(plugButton, SIGNAL(clicked()), this, SLOT(openPlugin()) );
}
i++;
connect(plugButton, SIGNAL(clicked()), this, SLOT(openPlugin()) );
}
((QVBoxLayout*)ui->navigation->layout())->addStretch(1);

@ -30,11 +30,6 @@ CommodityForm::~CommodityForm()
void CommodityForm::registerCombos()
{
QList<ComboData> ct;
Service<CommodityTypeData> cts;
foreach (QSharedPointer<CommodityTypeData> ctd , cts.all()) {
ComboData cd(ctd);
ct << cd;
}
registerBinding(ui->type,ct);
Service<CommodityTypeData> srvComTypes;
registerBinding(ui->type, ComboData::createComboData(srvComTypes.all()));
}

@ -20,6 +20,20 @@ public:
QString label() const;
void setLabel(const QString &label);
template<class T>
static QList<ComboData> createComboData(QList<QSharedPointer<T> > list) {
QList<ComboData> data;
foreach (QSharedPointer<T> item, list) {
QSharedPointer<QObject> qObj = qSharedPointerDynamicCast<QObject, T>(item);
if (!qObj.isNull())
{
data << ComboData(qObj);
}
}
return data;
}
private:
QVariant m_index;
QString m_label;

@ -15,6 +15,8 @@
#include "users/users.h"
#include "roles/roles.h"
#include "permissionservice.h"
#include "seasonservice.h"
#include "numberseriesservice.h"
Context::~Context()
{
@ -50,7 +52,7 @@ void Context::loadPlugins()
m_plugins.append(new Users);
m_plugins.append(new Roles);
QDir pluginsDir(qApp->applicationDirPath() + "/../plugins");
QDir pluginsDir(qApp->applicationDirPath() + PLUGIN_ROOT);
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
@ -86,6 +88,8 @@ void Context::openDb(const QString &path)
m_dbOpened = true;
checkPermissions();
checkSeason();
checkNumberSeries();
}
void Context::destroy()
@ -121,6 +125,16 @@ Context::Context()
m_dbOpened = false;
}
SeasonPtr Context::currentSeason() const
{
return m_currentSeason;
}
void Context::setCurrentSeason(const SeasonPtr &currentSeason)
{
m_currentSeason = currentSeason;
}
QSharedPointer<User> Context::currentUser() const
{
return m_currentUser;
@ -253,3 +267,44 @@ void Context::checkPermissions()
permService.checkForAdmin();
}
void Context::checkSeason()
{
SeasonService srv;
QSharedPointer<Season> season = srv.active();
if (season.isNull())
{
season = QSharedPointer<Season>(new Season());
season->setName("<<new season>>");
season->setValidFrom(QDate::currentDate());
season->setActive(true);
srv.save(season);
}
m_currentSeason = season;
}
void Context::checkNumberSeries()
{
NumberSeriesService srv;
SeasonService sesSrv;
QSharedPointer<Season> curSeason = sesSrv.active();
foreach (IPlugin *plugin, m_plugins) {
if (plugin->hasNumberSeries())
{
QSharedPointer<NumberSeries> numSer = srv.forPlugin(plugin->pluginId());
if (numSer.isNull())
{
numSer = QSharedPointer<NumberSeries>(new NumberSeries());
numSer->setPrefix(plugin->numberSeriesPrefix());
numSer->setPluginId(plugin->pluginId());
numSer->setSeason(curSeason);
srv.save(numSer);
}
}
}
}

@ -39,6 +39,11 @@ public:
odb::session &session();
SeasonPtr currentSeason() const;
void setCurrentSeason(const SeasonPtr &currentSeason);
void checkNumberSeries();
private:
Context();
QList<IPlugin*> m_plugins;
@ -47,6 +52,7 @@ private:
bool m_dbOpened;
odb::session m_session;
QSharedPointer<User> m_currentUser;
SeasonPtr m_currentSeason;
QStringList m_solved;
@ -55,6 +61,7 @@ private:
void solveDep(IPlugin *plugin, const QSqlDatabase &db, const QMap<QString, int> &schemaMap);
void createSchema(IPlugin *plugin, const QSqlDatabase &db, const QMap<QString, int> &schemaMap);
void checkPermissions();
void checkSeason();
};
#endif // CONTEXT_H

@ -52,7 +52,12 @@ SOURCES += \
settingsform.cpp \
settings/globalsettingsform.cpp \
permissionevaluator.cpp \
objectbinder.cpp
objectbinder.cpp \
data/numberseries.cpp \
data/season.cpp \
seasonservice.cpp \
numberseriesservice.cpp \
settings/seasonnamedialog.cpp
HEADERS += core.h\
core_global.h \
@ -104,7 +109,12 @@ HEADERS += core.h\
settings/globalsettingsform.h \
formbinder.h \
permissionevaluator.h \
objectbinder.h
objectbinder.h \
data/numberseries.h \
data/season.h \
seasonservice.h \
numberseriesservice.h \
settings/seasonnamedialog.h
unix {
target.path = /usr/lib
@ -138,7 +148,8 @@ FORMS += \
savefilterdialog.ui \
filterdialog.ui \
settingsform.ui \
settings/globalsettingsform.ui
settings/globalsettingsform.ui \
settings/seasonnamedialog.ui
OTHER_FILES += \
users/metaData.json \
@ -146,6 +157,9 @@ OTHER_FILES += \
CONFIG(debug, release|debug):DEFINES += _DEBUG
win32:CONFIG(release, debug|release):DEFINES += PLUGIN_ROOT=\\\"/plugins\\\"
else:unix:CONFIG(release, debug|release):DEFINES += PLUGIN_ROOT=\\\"/usr/lib/prodejna/plugins\\\"
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

@ -4,11 +4,15 @@
class User;
class Permission;
class Role;
class Season;
class NumberSeries;
#include "user.h"
#include "role.h"
#include "permission.h"
#include "system.h"
#include "search.h"
#include "numberseries.h"
#endif // COREDATA_H

@ -0,0 +1,75 @@
#include "numberseries.h"
#include "../context.h"
#include "../iplugin.h"
NumberSeries::NumberSeries(QObject *parent) : QObject(parent)
{
m_id = 0;
m_lastNumber = 0;
}
int NumberSeries::id() const
{
return m_id;
}
void NumberSeries::setId(int id)
{
m_id = id;
}
QString NumberSeries::prefix() const
{
return m_prefix;
}
void NumberSeries::setPrefix(const QString &prefix)
{
m_prefix = prefix;
}
int NumberSeries::lastNumber() const
{
return m_lastNumber;
}
void NumberSeries::setLastNumber(int lastNumber)
{
m_lastNumber = lastNumber;
}
QString NumberSeries::pluginId() const
{
return m_pluginId;
}
void NumberSeries::setPluginId(const QString &pluginId)
{
m_pluginId = pluginId;
}
QSharedPointer<Season> NumberSeries::season() const
{
return m_season;
}
void NumberSeries::setSeason(const QSharedPointer<Season> &season)
{
m_season = season;
}
QString NumberSeries::seasonName() const
{
if (!m_season.isNull())
{
return m_season->name();
}
return "";
}
QString NumberSeries::pluginName() const
{
IPlugin *plugin = Context::instance().plugin(m_pluginId);
return plugin != NULL ? plugin->pluginName() : "";
}

@ -0,0 +1,55 @@
#ifndef NUMBERSERIES_H
#define NUMBERSERIES_H
#include <QObject>
#include <QSharedPointer>
#include <odb/core.hxx>
#include "season.h"
#include "core_global.h"
#pragma db object
class CORESHARED_EXPORT NumberSeries : public QObject
{
Q_OBJECT
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
Q_PROPERTY(int lastNumber READ lastNumber WRITE setLastNumber)
Q_PROPERTY(QString pluginName READ pluginName)
Q_PROPERTY(QString seasonName READ seasonName)
public:
explicit NumberSeries(QObject *parent = 0);
int id() const;
void setId(int id);
QString prefix() const;
void setPrefix(const QString &prefix);
int lastNumber() const;
void setLastNumber(int lastNumber);
QString pluginId() const;
void setPluginId(const QString &pluginId);
QSharedPointer<Season> season() const;
void setSeason(const QSharedPointer<Season> &season);
QString seasonName() const;
QString pluginName() const;
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_prefix;
int m_lastNumber;
QString m_pluginId;
QSharedPointer<Season> m_season;
};
typedef QSharedPointer<NumberSeries> NumberSeriesPtr;
#endif // NUMBERSERIES_H

@ -0,0 +1,58 @@
#include "season.h"
Season::Season(QObject *parent)
:QObject(parent)
{
m_id = 0;
m_active = false;
}
QString Season::name() const
{
return m_name;
}
void Season::setName(const QString &name)
{
m_name = name;
}
QDate Season::validFrom() const
{
return m_validFrom;
}
void Season::setValidFrom(const QDate &validFrom)
{
m_validFrom = validFrom;
}
QDate Season::validTo() const
{
return m_validTo;
}
void Season::setValidTo(const QDate &validTo)
{
m_validTo = validTo;
}
bool Season::active() const
{
return m_active;
}
void Season::setActive(bool active)
{
m_active = active;
}
int Season::id() const
{
return m_id;
}
void Season::setId(int id)
{
m_id = id;
}

@ -0,0 +1,51 @@
#ifndef SEASON_H
#define SEASON_H
#include "core_global.h"
#include <QObject>
#include <QString>
#include <QDate>
#include <odb/core.hxx>
#pragma db object
class CORESHARED_EXPORT Season : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QDate validFrom READ validFrom WRITE setValidFrom)
Q_PROPERTY(QDate validTo READ validTo WRITE setValidTo)
Q_PROPERTY(bool active READ active WRITE setActive)
public:
explicit Season(QObject *parent = 0);
QString name() const;
void setName(const QString &name);
QDate validFrom() const;
void setValidFrom(const QDate &validFrom);
QDate validTo() const;
void setValidTo(const QDate &validTo);
bool active() const;
void setActive(bool active);
int id() const;
void setId(int id);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_name;
QDate m_validFrom;
QDate m_validTo;
bool m_active;
};
typedef QSharedPointer<Season> SeasonPtr;
#endif // SEASON_H

@ -13,5 +13,13 @@
#define TO_DEC(num) QDecDouble((double)num / DEC_MULTIPLE)
#define FROM_DEC(num) num.toDouble() * DEC_MULTIPLE
#ifndef PLUGIN_ROOT
#ifdef _WIN32
#define PLUGIN_ROOT "/../../plugins"
#else
#define PLUGIN_ROOT "/../plugins"
#endif
#endif
#endif // DEFINE_H

@ -77,6 +77,9 @@ public:
virtual QIcon pluginIcon() { return QIcon(); }
QMap<QString, QString> translations() { return m_translations; }
virtual bool hasNumberSeries() { return false; }
virtual QString numberSeriesPrefix() { return ""; }
protected:
QTranslator* translatorFrom(QString fileName) {
QTranslator *trans = new QTranslator();

@ -74,6 +74,23 @@ CREATE TABLE \"Permission\" (
\"createDate\" TEXT NULL,
\"active\" INTEGER NOT NULL);
CREATE TABLE \"Season\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"name\" TEXT NULL,
\"validFrom\" TEXT NULL,
\"validTo\" TEXT NULL,
\"active\" INTEGER NOT NULL);
CREATE TABLE \"NumberSeries\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"prefix\" TEXT NULL,
\"lastNumber\" INTEGER NOT NULL,
\"pluginId\" TEXT NULL,
\"season\" INTEGER NULL,
CONSTRAINT \"season_fk\"
FOREIGN KEY (\"season\")
REFERENCES \"Season\" (\"id\")
DEFERRABLE INITIALLY DEFERRED);
" ],
"dependencies" : []
}

@ -0,0 +1,53 @@
#include "numberseriesservice.h"
#include "seasonservice.h"
#include "core-odb.hxx"
NumberSeriesService::NumberSeriesService()
{
}
QSharedPointer<NumberSeries> NumberSeriesService::forPluginAndSeason(QString pluginId, QSharedPointer<Season> season)
{
QList<QSharedPointer<NumberSeries> > series = all(QString("pluginId = '%1' AND season = %2").arg(pluginId, QString::number(season->id())));
if (!series.isEmpty())
{
return series[0];
}
return QSharedPointer<NumberSeries>();
}
QSharedPointer<NumberSeries> NumberSeriesService::forPlugin(QString pluginId)
{
SeasonService sesSrv;
QSharedPointer<Season> currentSeason = sesSrv.active();
if (!currentSeason.isNull())
{
return forPluginAndSeason(pluginId, currentSeason);
}
return QSharedPointer<NumberSeries>();
}
QSharedPointer<NumberSeries> NumberSeriesService::nextForPlugin(QString pluginId)
{
QSharedPointer<NumberSeries> numSer = forPlugin(pluginId);
if (numSer.isNull())
{
return QSharedPointer<NumberSeries>();
}
numSer->setLastNumber(numSer->lastNumber() + 1);
update(numSer);
return numSer;
}
QList<QSharedPointer<NumberSeries> > NumberSeriesService::allForSeason(QSharedPointer<Season> season)
{
return all(QString("season = %1").arg(QString::number(season->id())));
}

@ -0,0 +1,20 @@
#ifndef NUMBERSERIESSERVICE_H
#define NUMBERSERIESSERVICE_H
#include "data/numberseries.h"
#include "data/season.h"
#include "service.h"
#include "core_global.h"
class CORESHARED_EXPORT NumberSeriesService : public Service<NumberSeries>
{
public:
NumberSeriesService();
QSharedPointer<NumberSeries> forPluginAndSeason(QString pluginId, QSharedPointer<Season> season);
QSharedPointer<NumberSeries> forPlugin(QString pluginId);
QSharedPointer<NumberSeries> nextForPlugin(QString pluginId);
QList<QSharedPointer<NumberSeries> > allForSeason(QSharedPointer<Season> season);
};
#endif // NUMBERSERIESSERVICE_H

@ -0,0 +1,34 @@
#include "seasonservice.h"
#include "core-odb.hxx"
SeasonService::SeasonService()
{
}
QSharedPointer<Season> SeasonService::active()
{
QList<QSharedPointer<Season> > seasons = all("active = 1");
if (seasons.count() > 0)
{
return seasons[0];
}
return QSharedPointer<Season>();
}
void SeasonService::activate(QSharedPointer<Season> season)
{
Transaction tx;
foreach (QSharedPointer<Season> ses, all()) {
ses->setActive(false);
update(ses);
}
season->setActive(true);
update(season);
tx.commit();
}

@ -0,0 +1,18 @@
#ifndef SEASONSERVICE_H
#define SEASONSERVICE_H
#include <QSharedPointer>
#include "data/season.h"
#include "service.h"
#include "core_global.h"
class CORESHARED_EXPORT SeasonService : public Service<Season>
{
public:
SeasonService();
QSharedPointer<Season> active();
void activate(QSharedPointer<Season> season);
};
#endif // SEASONSERVICE_H

@ -80,4 +80,6 @@ signals:
public slots:
};
typedef QSharedPointer<GlobalSettings> GlobalSettingsPtr;
#endif // GLOBALSETTINGS_H

@ -1,8 +1,14 @@
#include "globalsettingsform.h"
#include "ui_globalsettingsform.h"
#include <QMessageBox>
#include "seasonnamedialog.h"
#include "globalsettings.h"
#include "../settingsservice.h"
#include "../seasonservice.h"
#include "../numberseriesservice.h"
#include "core-odb.hxx"
GlobalSettingsForm::GlobalSettingsForm(QWidget *parent) :
FormBinder<GlobalSettings>(parent),
@ -21,6 +27,10 @@ GlobalSettingsForm::GlobalSettingsForm(QWidget *parent) :
registerBinding(ui->vatHigh);
registerBinding(ui->vatFirstLower);
registerBinding(ui->vatSecondLower);
m_seriesModel = new AutoTableModel<NumberSeries>(this);
m_seriesModel->setEditableCols(QList<int>() << 0);
ui->tableNumSer->setModel(m_seriesModel);
}
GlobalSettingsForm::~GlobalSettingsForm()
@ -28,8 +38,61 @@ GlobalSettingsForm::~GlobalSettingsForm()
delete ui;
}
void GlobalSettingsForm::loadSeasons()
{
ui->season->clear();
SeasonService srv;
m_seasons = srv.all();
foreach (SeasonPtr season, m_seasons) {
ui->season->addItem(season->name());
if (season->active())
{
ui->season->setCurrentIndex(ui->season->count() - 1);
}
}
}
void GlobalSettingsForm::loadNumSeries()
{
NumberSeriesService srvNumSer;
SeasonService srvSeason;
if (ui->season->currentIndex() >= 0)
{
SeasonPtr currentSeason = m_seasons[ui->season->currentIndex()];
m_seriesModel->setData(srvNumSer.allForSeason(currentSeason));
}
}
bool GlobalSettingsForm::saveRecord()
{
SeasonService srvSeason;
NumberSeriesService srvNumSer;
SeasonPtr selSeason = m_seasons[ui->season->currentIndex()];
if (selSeason->id() != Context::instance().currentSeason()->id())
{
if (QMessageBox::question(this, tr("Switch season"), tr("Realy switch active season?")) == QMessageBox::Yes)
{
srvSeason.activate(selSeason);
Context::instance().setCurrentSeason(selSeason);
}
else
{
return false;
}
}
foreach (SeasonPtr season, m_seasons) {
srvSeason.update(season);
}
foreach (NumberSeriesPtr numSer, m_seriesModel->list()) {
srvNumSer.update(numSer);
}
bindToData();
SettingsService srv("CORE");
srv.saveSettings(entity());
@ -43,9 +106,52 @@ void GlobalSettingsForm::loadEntity()
QSharedPointer<GlobalSettings> settings = srv.loadSettings<GlobalSettings>();
setEntity(settings);
ui->grpVat->setEnabled(settings->vatPayer());
loadSeasons();
loadNumSeries();
}
void GlobalSettingsForm::on_vatPayer_toggled(bool checked)
{
ui->grpVat->setEnabled(checked);
}
void GlobalSettingsForm::on_season_currentIndexChanged(int)
{
loadNumSeries();
}
void GlobalSettingsForm::on_btnEditName_clicked()
{
SeasonPtr selSeason = m_seasons[ui->season->currentIndex()];
SeasonNameDialog *dialog = new SeasonNameDialog(selSeason, this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
connect(dialog, &QDialog::accepted, [this](){
this->loadSeasons();
});
}
void GlobalSettingsForm::on_btnNew_clicked()
{
if (QMessageBox::question(this, tr("New season"), tr("Realy create new season and switch to it?")) == QMessageBox::Yes)
{
SeasonPtr newSeason = SeasonPtr(new Season);
SeasonNameDialog *dialog = new SeasonNameDialog(newSeason, this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
connect(dialog, &QDialog::accepted, [this, newSeason](){
SeasonService srv;
newSeason->setValidFrom(QDate::currentDate());
srv.save(newSeason);
srv.activate(newSeason);
Context::instance().setCurrentSeason(newSeason);
Context::instance().checkNumberSeries();
this->loadSeasons();
this->loadNumSeries();
});
}
}

@ -4,6 +4,8 @@
#include <QWidget>
#include "../formbinder.h"
#include "globalsettings.h"
#include "../autotablemodel.h"
#include "../data/numberseries.h"
namespace Ui {
class GlobalSettingsForm;
@ -19,6 +21,11 @@ public:
private:
Ui::GlobalSettingsForm *ui;
AutoTableModel<NumberSeries> *m_seriesModel;
QList<SeasonPtr> m_seasons;
void loadSeasons();
void loadNumSeries();
// IForm interface
public slots:
@ -29,6 +36,9 @@ public:
void loadEntity() override;
private slots:
void on_vatPayer_toggled(bool checked);
void on_season_currentIndexChanged(int index);
void on_btnEditName_clicked();
void on_btnNew_clicked();
};
#endif // GLOBALSETTINGSFORM_H

@ -6,194 +6,293 @@
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>419</height>
<width>759</width>
<height>552</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<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">
<string>IC</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="ic"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>VAT number</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="dic"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="vatPayer">
<property name="text">
<string>VAT payer</string>
</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>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Contact</string>
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Firm Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="firmName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Street</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="street"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>House Number</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="houseNumber"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>City</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="city"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>ZIP code</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="zipCode"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Logo</string>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Logo</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Select file</string>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="tabBase">
<attribute name="title">
<string>Base settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Contact</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Firm Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="firmName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Street</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="street"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>House Number</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="houseNumber"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>City</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="city"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>ZIP code</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="zipCode"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Logo</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Logo</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Select file</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<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">
<string>IC</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="ic"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>VAT number</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="dic"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="vatPayer">
<property name="text">
<string>VAT payer</string>
</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>
</layout>
</widget>
<widget class="QWidget" name="tabNumSer">
<attribute name="title">
<string>Number series</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="season">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="btnEditName">
<property name="text">
<string>Edit name</string>
</property>
<property name="icon">
<iconset resource="../rc.qrc">
<normaloff>:/icons/edit.svg</normaloff>:/icons/edit.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Season</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="btnNew">
<property name="text">
<string>Create new</string>
</property>
<property name="icon">
<iconset resource="../rc.qrc">
<normaloff>:/icons/new.svg</normaloff>:/icons/new.svg</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Number series</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableView" name="tableNumSer"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../rc.qrc"/>
</resources>
<connections/>
</ui>

@ -0,0 +1,24 @@
#include "seasonnamedialog.h"
#include "ui_seasonnamedialog.h"
SeasonNameDialog::SeasonNameDialog(SeasonPtr season, QWidget *parent) :
QDialog(parent),
ui(new Ui::SeasonNameDialog)
{
ui->setupUi(this);
m_binder.registerBinding(ui->name);
m_binder.setData(season.data());
m_binder.bindToUi();
}
SeasonNameDialog::~SeasonNameDialog()
{
delete ui;
}
void SeasonNameDialog::accept()
{
m_binder.bindToData();
QDialog::accept();
}

@ -0,0 +1,30 @@
#ifndef SEASONNAMEDIALOG_H
#define SEASONNAMEDIALOG_H
#include <QDialog>
#include "../data/season.h"
#include "../objectbinder.h"
namespace Ui {
class SeasonNameDialog;
}
class SeasonNameDialog : public QDialog
{
Q_OBJECT
public:
explicit SeasonNameDialog(SeasonPtr season, QWidget *parent = 0);
~SeasonNameDialog();
private:
Ui::SeasonNameDialog *ui;
ObjectBinder m_binder;
// QDialog interface
public slots:
void accept();
};
#endif // SEASONNAMEDIALOG_H

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SeasonNameDialog</class>
<widget class="QDialog" name="SeasonNameDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>406</width>
<height>82</height>
</rect>
</property>
<property name="windowTitle">
<string>Season</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Season name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SeasonNameDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SeasonNameDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -16,6 +16,10 @@
<property name="windowTitle">
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="../application/appRc.qrc">
<normaloff>:/icons/settings.svg</normaloff>:/icons/settings.svg</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
@ -39,6 +43,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../application/appRc.qrc"/>
</resources>
<connections/>
</ui>

@ -6,7 +6,7 @@
#DEFINES += DECEXTFLAG=1 # default is 1
#DEFINES += DECLITEND=0 # default is 1
CONFIG += debug
#CONFIG += debug
if(win32) {
@ -24,7 +24,7 @@ if(win32) {
#msvc2010 onwards above flags are deprecated.
# Use Run-time checks for stack corruption and uninitialized var use
QMAKE_CXXFLAGS += /RTC1
#QMAKE_CXXFLAGS += /RTC1
}
} # end win32

@ -210,6 +210,26 @@ QDecDouble Voucher::VatAmountSecondLower()
return TO_DEC(m_totalPriceVatSecondLower) - TO_DEC(m_priceVatSecondLower);
}
QString Voucher::numSer() const
{
return m_numSer;
}
void Voucher::setNumSer(const QString &numSer)
{
m_numSer = numSer;
}
QDateTime Voucher::payDateTime() const
{
return m_payDateTime;
}
void Voucher::setPayDateTime(const QDateTime &payDateTime)
{
m_payDateTime = payDateTime;
}
int Voucher::id() const
{
return m_id;

@ -16,6 +16,8 @@ class Voucher : public QObject
{
Q_OBJECT
Q_PROPERTY(QString numSer READ numSer WRITE setNumSer)
Q_PROPERTY(QDateTime payDateTime READ payDateTime WRITE setPayDateTime)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString description READ description WRITE setDescription)
Q_PROPERTY(QSharedPointer<QObject> contact READ contact WRITE setContact)
@ -102,10 +104,18 @@ public:
QDecDouble vatAmountFirstLower();
QDecDouble VatAmountSecondLower();
QString numSer() const;
void setNumSer(const QString &numSer);
QDateTime payDateTime() const;
void setPayDateTime(const QDateTime &payDateTime);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_numSer;
QDateTime m_payDateTime;
QString m_name;
QString m_description;
QSharedPointer<AddressbookData> m_contact;

@ -0,0 +1 @@
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient gradientUnits="userSpaceOnUse" id="a" x1="249.999" x2="249.999" y1="112.399" y2="412.599"><stop offset="0" stop-color="#FCFCFD"/><stop offset="1" stop-color="#fff"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="b" x1="249.998" x2="249.998" y1="34.201" y2="85.799"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><g><path d="M95 65h310c8 0 15 7 15 15v365c0 8-7 15-15 15h-310c-8 0-15-7-15-15v-365c0-8 7-15 15-15z" fill="url(#a)" stroke="#434242" stroke-width="10"/><path d="M378 90h-256c-2 0-4-1-5-3 0-2 0-4 2-6l30-30c1-1 2-1 3-1h63c3 0 5-2 5-5v-10c0-3 2-5 5-5h50c3 0 5 2 5 5v10c0 3 2 5 5 5h63c1 0 2 0 3 1l30 30c2 2 2 4 2 6-1 2-3 3-5 3z" fill="url(#b)" stroke="#434242" stroke-width="10"/><path d="M120 140h40v40h-40v-40zm0 80h40v40h-40v-40zm0 80h40v40h-40v-40zm0 80h40v40h-40v-40zm55-210h165v10h-165v-10zm0 80h105v10h-105v-10zm0 80h165v10h-165v-10zm0 80h180v10h-180v-10zm0-265h205v10h-205v-10zm0 80h165v10h-165v-10zm0 80h130v10h-130v-10zm0 80h150v10h-150v-10z" fill="#434242"/></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -0,0 +1 @@
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient gradientUnits="userSpaceOnUse" id="a" x1="249.997" x2="249.997" y1="82.801" y2="417.199"><stop offset="0" stop-color="#FCFCFD"/><stop offset="1" stop-color="#fff"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="b" x1="249.998" x2="249.998" y1="62.399" y2="137.599"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><g><path d="M100 30h300c11 0 20 9 20 20v400c0 11-9 20-20 20h-300c-11 0-20-9-20-20v-400c0-11 9-20 20-20z" fill="url(#a)" stroke="#434242" stroke-width="10"/><path d="M120 60h260c6 0 10 4 10 10v60c0 6-4 10-10 10h-260c-6 0-10-4-10-10v-60c0-6 4-10 10-10z" fill="url(#b)" stroke="#434242" stroke-width="10"/><polygon fill="#434242" points="190,175 235,175 235,220 190,220"/><polygon fill="#434242" points="265,175 310,175 310,220 265,220"/><polygon fill="#434242" points="335,175 380,175 380,220 335,220"/><polygon fill="#434242" points="115,175 160,175 160,220 115,220"/><polygon fill="#434242" points="190,245 235,245 235,290 190,290"/><polygon fill="#434242" points="265,245 310,245 310,290 265,290"/><polygon fill="#434242" points="335,245 380,245 380,290 335,290"/><polygon fill="#434242" points="115,245 160,245 160,290 115,290"/><polygon fill="#434242" points="190,320 235,320 235,365 190,365"/><polygon fill="#434242" points="265,320 310,320 310,365 265,365"/><polygon fill="#434242" points="115,320 160,320 160,365 115,365"/><polygon fill="#434242" points="190,395 235,395 235,440 190,440"/><polygon fill="#434242" points="265,395 310,395 310,440 265,440"/><polygon fill="#434242" points="335,320 380,320 380,440 335,440"/><polygon fill="#434242" points="115,395 160,395 160,440 115,440"/></g></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -0,0 +1 @@
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="b" x1="1" x2="0" y1="1"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient><linearGradient id="a" x2="0" y1="1"><stop offset="0" stop-color="#FCFCFD"/><stop offset="1" stop-color="#DDDEDE"/></linearGradient></defs><g stroke="#434242" stroke-linejoin="round"><path d="M250 30h140c11 0 20 9 20 20v400c0 11-9 20-20 20h-280c-11 0-20-9-20-20v-260l160-160z" fill="url(#a)" stroke-linecap="round" stroke-width="15"/><path d="M220 190h-130l160-160v130c0 17-14 30-30 30z" fill="url(#b)" stroke-width="10"/></g></svg>

After

Width:  |  Height:  |  Size: 805 B

@ -0,0 +1,33 @@
#include "paydialog.h"
#include "ui_paydialog.h"
PayDialog::PayDialog(QDecDouble total, QWidget *parent) :
QDialog(parent),
ui(new Ui::PayDialog)
{
ui->setupUi(this);
m_total = total;
ui->labelTotal->setText(QString::number(total.toDouble(), 'f', 2));
ui->labelReturn->setText(QString::number(0, 'f', 2));
}
PayDialog::~PayDialog()
{
delete ui;
}
void PayDialog::on_recieved_valueChanged(double value)
{
if (value >= m_total.toDouble())
{
ui->buttonBox->setEnabled(true);
ui->labelReturn->setText(QString::number(value - m_total.toDouble(), 'f', 2));
}
else
{
ui->buttonBox->setEnabled(false);
ui->labelReturn->setText(QString::number(0, 'f', 2));
}
}

@ -0,0 +1,28 @@
#ifndef PAYDIALOG_H
#define PAYDIALOG_H
#include <QDialog>
#include <QDecDouble.hh>
namespace Ui {
class PayDialog;
}
class PayDialog : public QDialog
{
Q_OBJECT
public:
explicit PayDialog(QDecDouble total, QWidget *parent = 0);
~PayDialog();
private slots:
void on_recieved_valueChanged(double value);
private:
Ui::PayDialog *ui;
QDecDouble m_total;
};
#endif // PAYDIALOG_H

@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PayDialog</class>
<widget class="QDialog" name="PayDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>134</height>
</rect>
</property>
<property name="windowTitle">
<string>Recieve money</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Total:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelTotal">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Recieved</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="recieved">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<double>99999.990000000005239</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Return</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelReturn">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PayDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PayDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -0,0 +1,61 @@
#include "paydvouchersdialog.h"
#include "ui_paydvouchersdialog.h"
#include <QFileDialog>
#include "receiptgenerator.h"
#include "shopservice.h"
PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PaydVouchersDialog)
{
ui->setupUi(this);
m_voucherModel = new AutoTableModel<Voucher>(this);
m_itemModel = new AutoTableModel<VoucherItem>(this);
ui->tableVouchers->setModel(m_voucherModel);
ui->tableItems->setModel(m_itemModel);
ShopService srv;
m_voucherModel->setData(srv.paiedVouchers());
connect(ui->tableVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this, &srv](const QModelIndex &current, const QModelIndex &) {
QSharedPointer<Voucher> voucher = m_voucherModel->itemFromIndex(current);
srv.loadItems(voucher);
m_itemModel->setData(voucher->items());
ui->total->setText(QString::number(voucher->totalPrice().toDouble(), 'f', 2));
ui->btnPrint->setEnabled(true);
ui->btnSave->setEnabled(true);
});
}
PaydVouchersDialog::~PaydVouchersDialog()
{
delete ui;
}
void PaydVouchersDialog::on_btnPrint_clicked()
{
QSharedPointer<Voucher> voucher = m_voucherModel->itemFromIndex(ui->tableVouchers->currentIndex());
ReceiptGenerator generator;
generator.setVoucher(voucher);
generator.print();
}
void PaydVouchersDialog::on_btnSave_clicked()
{
QString fileToSave = QFileDialog::getSaveFileName(this, tr("Save receipt"), "", tr("Text files (*.txt)"));
QSharedPointer<Voucher> voucher = m_voucherModel->itemFromIndex(ui->tableVouchers->currentIndex());
if (!fileToSave.isEmpty())
{
ReceiptGenerator generator;
generator.setVoucher(voucher);
generator.setOutputFile(fileToSave);
generator.save();
}
}

@ -0,0 +1,34 @@
#ifndef PAYDVOUCHERSDIALOG_H
#define PAYDVOUCHERSDIALOG_H
#include <autotablemodel.h>
#include "data/voucher.h"
#include <QDialog>
namespace Ui {
class PaydVouchersDialog;
}
class PaydVouchersDialog : public QDialog
{
Q_OBJECT
public:
explicit PaydVouchersDialog(QWidget *parent = 0);
~PaydVouchersDialog();
private slots:
void on_btnPrint_clicked();
void on_btnSave_clicked();
private:
Ui::PaydVouchersDialog *ui;
AutoTableModel<Voucher> *m_voucherModel;
AutoTableModel<VoucherItem> *m_itemModel;
};
#endif // PAYDVOUCHERSDIALOG_H

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PaydVouchersDialog</class>
<widget class="QDialog" name="PaydVouchersDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>798</width>
<height>514</height>
</rect>
</property>
<property name="windowTitle">
<string>Paied vouchers</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="btnPrint">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Print receipt</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/print.svg</normaloff>:/icons/print.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSave">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Save receipt</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/save.svg</normaloff>:/icons/save.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTableView" name="tableVouchers">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Items</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableView" name="tableItems"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Total:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="total">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../core/rc.qrc"/>
</resources>
<connections/>
</ui>

@ -0,0 +1,151 @@
#include "receiptgenerator.h"
#include <settingsservice.h>
#include <settings/globalsettings.h>
#include <QTextCodec>
#include <QFile>
const QString ReceiptGenerator::DIACRITIC = "ÂâÁáÄäĂ㥹ĆćČčÇçĎďĐđÉéËëĚěĘęÍíÎîĹ弾ŁłŃńŇňÓóÖöÔôŐőŔŕŘřŚśŠšŞşŤťŢţÚúÜüŮůŰűÝýŹźŽžŻż";
const QString ReceiptGenerator::NON_DIACRITIC = "AaAaAaAaAaCcCcCcDdDdEeEeEeEeIiIiLlLlLlNnNnOoOoOoOoRrRrSsSsSsTtTtUuUuUuUuYyZzZzZz";
ReceiptGenerator::ReceiptGenerator()
{
}
void ReceiptGenerator::setVoucher(const QSharedPointer<Voucher> &voucher)
{
m_voucher = voucher;
}
void ReceiptGenerator::setSettings(const ShopSettingsPtr &settings)
{
m_settings = settings;
}
void ReceiptGenerator::save()
{
SettingsService srvShopSettings("SHOP");
ShopSettingsPtr shopSettings = srvShopSettings.loadSettings<ShopSettings>();
QString outFile = m_outputFile;
if (outFile.isEmpty())
{
outFile = shopSettings->output();
}
QFile file(outFile);
file.open(QIODevice::WriteOnly);
file.write(generate());
file.close();
}
void ReceiptGenerator::print()
{
save();
}
QString ReceiptGenerator::outputFile() const
{
return m_outputFile;
}
void ReceiptGenerator::setOutputFile(const QString &outputFile)
{
m_outputFile = outputFile;
}
QByteArray ReceiptGenerator::generate()
{
QByteArray out;
SettingsService srvGsSettings("CORE");
SettingsService srvShopSettings("SHOP");
ShopSettingsPtr shopSettings = srvShopSettings.loadSettings<ShopSettings>();
GlobalSettingsPtr gs = srvGsSettings.loadSettings<GlobalSettings>();
out.append("\x1b\x40\x1b\x61\x01");
out.append(prepareString(gs->firmName()));
out.append("\x0a");
out.append(prepareString(gs->street() + " " + gs->houseNumber()));
out.append("\x0a");
out.append(prepareString(gs->zipCode() + " " + gs->city()));
out.append("\x0a");
out.append(prepareString("IC: " + gs->ic()));
out.append("\x0a");
out.append("\x1b\x61\0");
for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
{
out.append("_");
}
out.append("\x0a");
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
QString name = item->name();
QString price = QString::number(item->price().toDouble(), 'f', 2);
int numSpaces = 0;
if ((name.length() + price.length()) < shopSettings->lettersPerLine())
{
numSpaces = shopSettings->lettersPerLine() - (name.length() + price.length());
out.append(prepareString(name));
}
else
{
numSpaces = shopSettings->lettersPerLine() - (name.length() + price.length());
out.append(prepareString(name));
out.append("\x0a");
}
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(price));
out.append("\x0a");
}
for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
{
out.append("_");
}
out.append("\x0a");
char printMode = 8 | 16 ;
out.append("\x1b\x21");
out.append(printMode);
out.append("Celekem:");
QString totalPrice = QString::number(m_voucher->totalPrice().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (8 * 2 + totalPrice.length() * 2);
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(totalPrice));
out.append("\x1b\x21\0");
out.append("\x0a");
out.append("\x0a");
out.append("\x0a");
return out;
}
QByteArray ReceiptGenerator::prepareString(const QString &str)
{
QString strOut = str;
//ToDo - dát do nastavení
for (int i = 0; i < DIACRITIC.length(); i++)
{
strOut = strOut.replace(DIACRITIC.at(i), NON_DIACRITIC.at(i));
}
QTextCodec *codec = QTextCodec::codecForName("IBM850");
return codec->fromUnicode(strOut);
}

@ -0,0 +1,35 @@
#ifndef RECEIPTGENERATOR_H
#define RECEIPTGENERATOR_H
#include "data/voucher.h"
#include "settings/shopsettings.h"
class ReceiptGenerator
{
public:
ReceiptGenerator();
void setVoucher(const QSharedPointer<Voucher> &voucher);
void setSettings(const ShopSettingsPtr &settings);
void save();
void print();
QString outputFile() const;
void setOutputFile(const QString &outputFile);
private:
static const QString DIACRITIC;
static const QString NON_DIACRITIC;
QSharedPointer<Voucher> m_voucher;
ShopSettingsPtr m_settings;
QString m_outputFile;
QByteArray generate();
QByteArray prepareString(const QString &str);
};
#endif // RECEIPTGENERATOR_H

@ -45,15 +45,9 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
});
m_binder.setData(new Voucher);
AddressBookService srvAdb;
QList<ComboData> comboData;
foreach (QSharedPointer<AddressbookData> adb, srvAdb.all()) {
comboData << ComboData(adb);
}
m_voucher = voucher;
m_binder.setData(m_voucher.data());
m_binder.registerBinding(ui->contact, comboData);
m_binder.registerBinding(ui->contact, ComboData::createComboData(srvAdb.all()));
m_binder.registerBinding(ui->name);
m_binder.registerBinding(ui->description);
m_binder.bindToUi();
@ -106,27 +100,3 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked)
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->name->text().isEmpty());
}
}
void ReceiptSaveForm::accept()
{
ShopService srv;
m_binder.bindToData();
if (m_saveAsNew)
{
m_voucher->setStatus(Voucher::NOT_PAID);
srv.updateVoucher(m_voucher);
}
else
{
QSharedPointer<Voucher> voucher = m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex());
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
voucher->addItem(item);
}
srv.calculate(voucher);
srv.updateVoucher(voucher);
srv.erase(m_voucher);
}
QDialog::accept();
}

@ -0,0 +1,47 @@
#include "shopsettings.h"
ShopSettings::ShopSettings(QObject *parent) : QObject(parent)
{
m_codepage = ASCII;
m_lettersPerLine = 48;
}
QString ShopSettings::output() const
{
return m_output;
}
void ShopSettings::setOutput(const QString &output)
{
m_output = output;
}
ShopSettings::CODEPAGE ShopSettings::codepage() const
{
return m_codepage;
}
void ShopSettings::setCodepage(const CODEPAGE &codepage)
{
m_codepage = codepage;
}
int ShopSettings::lettersPerLine() const
{
return m_lettersPerLine;
}
void ShopSettings::setLettersPerLine(int lettersPerLine)
{
m_lettersPerLine = lettersPerLine;
}
QString ShopSettings::byMessage() const
{
return m_byMessage;
}
void ShopSettings::setByMessage(const QString &byMessage)
{
m_byMessage = byMessage;
}

@ -0,0 +1,43 @@
#ifndef RECEIPTSETTINGS_H
#define RECEIPTSETTINGS_H
#include <QObject>
class ShopSettings : public QObject
{
Q_PROPERTY(QString output READ output WRITE setOutput)
Q_PROPERTY(int lettersPerLine READ lettersPerLine WRITE setLettersPerLine)
Q_PROPERTY(QString byMessage READ byMessage WRITE setByMessage)
Q_OBJECT
public:
enum CODEPAGE
{
ASCII
};
explicit ShopSettings(QObject *parent = 0);
QString output() const;
void setOutput(const QString &output);
CODEPAGE codepage() const;
void setCodepage(const CODEPAGE &codepage);
int lettersPerLine() const;
void setLettersPerLine(int lettersPerLine);
QString byMessage() const;
void setByMessage(const QString &byMessage);
private:
QString m_output;
CODEPAGE m_codepage;
int m_lettersPerLine;
QString m_byMessage;
};
typedef QSharedPointer<ShopSettings> ShopSettingsPtr;
#endif // RECEIPTSETTINGS_H

@ -0,0 +1,36 @@
#include "shopsettingsform.h"
#include "ui_shopsettingsform.h"
#include <settingsservice.h>
ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
FormBinder<ShopSettings>(parent),
ui(new Ui::ShopSettingsForm)
{
ui->setupUi(this);
registerBinding(ui->output);
registerBinding(ui->lettersPerLine);
registerBinding(ui->byMessage);
}
ShopSettingsForm::~ShopSettingsForm()
{
delete ui;
}
void ShopSettingsForm::loadEntity()
{
SettingsService srv("SHOP");
ShopSettingsPtr settings = srv.loadSettings<ShopSettings>();
setEntity(settings);
}
bool ShopSettingsForm::saveRecord()
{
bindToData();
SettingsService srv("SHOP");
srv.saveSettings(entity());
return true;
}

@ -0,0 +1,31 @@
#ifndef SHOPSETTINGSFORM_H
#define SHOPSETTINGSFORM_H
#include <QWidget>
#include <formbinder.h>
#include "shopsettings.h"
namespace Ui {
class ShopSettingsForm;
}
class ShopSettingsForm : public FormBinder<ShopSettings>
{
Q_OBJECT
public:
explicit ShopSettingsForm(QWidget *parent = 0);
~ShopSettingsForm();
private:
Ui::ShopSettingsForm *ui;
// IForm interface
public:
void loadEntity();
public slots:
bool saveRecord();
};
#endif // SHOPSETTINGSFORM_H

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShopSettingsForm</class>
<widget class="QWidget" name="ShopSettingsForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>608</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Printer</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Output device</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="output"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Letters per line</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="lettersPerLine"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Footer text</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="byMessage"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -2,6 +2,7 @@
#include <QIcon>
#include "shopform.h"
#include "shopservice.h"
#include "settings/shopsettingsform.h"
Shop::Shop()
@ -12,6 +13,7 @@ void Shop::initServiceUi()
{
m_ui = new ShopForm();
m_service = new ShopService();
m_settingsUi = new ShopSettingsForm();
}
QIcon Shop::pluginIcon()
@ -31,3 +33,13 @@ QTranslator *Shop::translator()
{
return translatorFrom(":/translations/shop_");
}
bool Shop::hasNumberSeries()
{
return true;
}
QString Shop::numberSeriesPrefix()
{
return "PD";
}

@ -24,6 +24,8 @@ public:
virtual QIcon pluginIcon();
virtual QWidget *ui() override;
QTranslator *translator();
bool hasNumberSeries();
QString numberSeriesPrefix();
};
#endif // SHOP_H

@ -29,6 +29,8 @@
CREATE TABLE \"Voucher\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"numSer\" TEXT NULL,
\"payDateTime\" TEXT NULL,
\"name\" TEXT NULL,
\"description\" TEXT NULL,
\"contact\" INTEGER NULL,

@ -21,7 +21,12 @@ SOURCES += shop.cpp \
receiptloadform.cpp \
data/voucheritem.cpp \
shopservice.cpp \
directsaleitem.cpp
directsaleitem.cpp \
receiptgenerator.cpp \
settings/shopsettings.cpp \
settings/shopsettingsform.cpp \
paydialog.cpp \
paydvouchersdialog.cpp
HEADERS += shop.h\
shop_global.h \
@ -36,7 +41,12 @@ HEADERS += shop.h\
data/shop-data.h \
isellableservice.h \
shopservice.h \
directsaleitem.h
directsaleitem.h \
receiptgenerator.h \
settings/shopsettings.h \
settings/shopsettingsform.h \
paydialog.h \
paydvouchersdialog.h
unix {
target.path = /usr/lib
@ -89,6 +99,9 @@ FORMS += \
directsaleform.ui \
temporaryreceiptsaveform.ui \
receiptsaveform.ui \
receiptloadform.ui
receiptloadform.ui \
settings/shopsettingsform.ui \
paydialog.ui \
paydvouchersdialog.ui
TRANSLATIONS = translations/shop_cs_CZ.ts

@ -5,6 +5,9 @@
#include "receiptsaveform.h"
#include "receiptloadform.h"
#include "shopservice.h"
#include "receiptgenerator.h"
#include "paydialog.h"
#include "paydvouchersdialog.h"
#include <QList>
#include <QSharedPointer>
#include "shop-odb.hxx"
@ -18,6 +21,7 @@ ShopForm::ShopForm(QWidget *parent) :
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
ui->payButton->setEnabled(false);
}
ShopForm::~ShopForm()
@ -48,6 +52,7 @@ void ShopForm::loadLast()
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
ui->temporarySaveButton->setEnabled(true);
ui->saveButton->setEnabled(true);
ui->payButton->setEnabled(true);
}
}
@ -136,6 +141,7 @@ void ShopForm::onCountChanged()
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
ui->temporarySaveButton->setEnabled(!m_voucher->items().isEmpty());
ui->saveButton->setEnabled(!m_voucher->items().isEmpty());
ui->payButton->setEnabled(!m_voucher->items().isEmpty());
if (m_voucher->status() == Voucher::NEW && m_voucher->id() == 0)
{
@ -173,10 +179,7 @@ void ShopForm::doTempSave(bool comboChanged)
}
else
{
m_voucher = srv.createVoucher();
ui->total->setText("0");
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
createEmptyVoucher();
}
fillRaceiptCombo();
@ -202,6 +205,7 @@ void ShopForm::changeReceipt()
ui->temporarySaveButton->setEnabled(true);
ui->saveButton->setEnabled(true);
ui->payButton->setEnabled(true);
fillRaceiptCombo();
}
@ -213,6 +217,16 @@ void ShopForm::connectItemSignals()
}
}
void ShopForm::createEmptyVoucher()
{
ShopService srv;
m_voucher = srv.createVoucher();
ui->total->setText("0");
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
ui->payButton->setEnabled(false);
}
void ShopForm::on_receiptCombo_currentIndexChanged(int)
{
if (!m_voucher.isNull() && m_voucher->items().isEmpty())
@ -233,3 +247,31 @@ void ShopForm::on_receiptCombo_currentIndexChanged(int)
doTempSave(true);
}
}
void ShopForm::on_payButton_clicked()
{
PayDialog *dialog = new PayDialog(m_voucher->totalPrice(), this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
connect(dialog, &QDialog::accepted, [this](){
ShopService srv;
srv.pay(m_voucher);
ReceiptGenerator generator;
generator.setVoucher(m_voucher);
generator.print();
createEmptyVoucher();
m_itemsModel->setData(m_voucher->items());
});
}
void ShopForm::on_showPaiedButton_clicked()
{
PaydVouchersDialog *dialog = new PaydVouchersDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}

@ -33,6 +33,10 @@ private slots:
void on_receiptCombo_currentIndexChanged(int index);
void on_payButton_clicked();
void on_showPaiedButton_clicked();
private:
Ui::ShopForm *ui;
QSharedPointer<Voucher> m_voucher;
@ -42,6 +46,7 @@ private:
void doTempSave(bool comboChanged);
void changeReceipt();
void connectItemSignals();
void createEmptyVoucher();
};
#endif // SHOPFORM_H

@ -269,30 +269,112 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="temporarySaveButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Temporary Save</string>
</property>
<property name="icon">
<iconset resource="shoprc.qrc">
<normaloff>:/icons/tempSave.svg</normaloff>:/icons/tempSave.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Save</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/save.svg</normaloff>:/icons/save.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Load</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/edit.svg</normaloff>:/icons/edit.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="showPaiedButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Show paied</string>
</property>
<property name="icon">
<iconset resource="shoprc.qrc">
<normaloff>:/icons/paied.svg</normaloff>:/icons/paied.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="payButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Pay</string>
</property>
<property name="icon">
<iconset resource="shoprc.qrc">
<normaloff>:/icons/pay.svg</normaloff>:/icons/pay.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
</layout>
@ -305,6 +387,7 @@
</widget>
<resources>
<include location="shoprc.qrc"/>
<include location="../core/rc.qrc"/>
</resources>
<connections/>
</ui>

@ -2,5 +2,8 @@
<qresource prefix="/">
<file>icons/shop.svg</file>
<file>translations/shop_cs_CZ.qm</file>
<file>icons/tempSave.svg</file>
<file>icons/paied.svg</file>
<file>icons/pay.svg</file>
</qresource>
</RCC>

@ -1,4 +1,5 @@
#include "shopservice.h"
#include "numberseriesservice.h"
#include "shop-odb.hxx"
ShopService::ShopService()
@ -76,6 +77,7 @@ void ShopService::calculateItem(QSharedPointer<VoucherItem> item)
else
{
item->setPrice(item->unitPrice() * item->count());
item->setPriceWitouthVat(item->price());
}
}
@ -85,6 +87,39 @@ void ShopService::loadItems(QSharedPointer<Voucher> voucher)
voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id())));
}
void ShopService::pay(QSharedPointer<Voucher> 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->setStatus(Voucher::PAID);
voucher->setPayDateTime(QDateTime::currentDateTime());
this->update(voucher);
tx.commit();
}
QList<QSharedPointer<Voucher> > ShopService::savedVouchers()
{
return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)));
}
QList<QSharedPointer<Voucher> > ShopService::tempVouchers()
{
return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY)));
}
QList<QSharedPointer<Voucher> > ShopService::paiedVouchers()
{
return all(QString("status = %1").arg(QString::number(Voucher::PAID)));
}
QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType)
{
return price * ((vatRate(vatType) / 100) + QDecDouble(1));

@ -18,6 +18,10 @@ public:
void calculate(QSharedPointer<Voucher> voucher);
void calculateItem(QSharedPointer<VoucherItem> item);
void loadItems(QSharedPointer<Voucher> voucher);
void pay(QSharedPointer<Voucher> voucher);
QList<QSharedPointer<Voucher> > savedVouchers();
QList<QSharedPointer<Voucher> > tempVouchers();
QList<QSharedPointer<Voucher> > paiedVouchers();
private:
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);

Loading…
Cancel
Save