Added setting for default VAT type on Direct sell dialog. Fixed some compiler warnings.

master
Josef Rokos 4 years ago
parent 43e95eeb6f
commit ad9a66ab32

@ -1,12 +1,13 @@
#include "directsaleform.h"
#include "ui_directsaleform.h"
DirectSaleForm::DirectSaleForm(QWidget *parent) :
DirectSaleForm::DirectSaleForm(QWidget *parent, Enums::VatType defaultVat) :
QDialog(parent),
ui(new Ui::DirectSaleForm)
{
ui->setupUi(this);
m_shopItem = QSharedPointer<DirectSaleItem>(new DirectSaleItem);
m_shopItem->setVatType(defaultVat);
m_binder.setData(m_shopItem.data());
m_binder.registerBinding(ui->name);

@ -18,7 +18,7 @@ class DirectSaleForm : public QDialog
Q_OBJECT
public:
explicit DirectSaleForm(QWidget *parent = 0);
explicit DirectSaleForm(QWidget *parent = nullptr, Enums::VatType defaultVat = Enums::NONE);
~DirectSaleForm();
QSharedPointer<IShopItem> shopItem() const;

@ -17,6 +17,8 @@ ShopSettings::ShopSettings(QObject *parent) : QObject(parent)
m_rounding = Enums::R_NONE;
m_decimalPlaces = 0;
m_defaultVat = Enums::NONE;
m_doublePrint = false;
}
@ -219,3 +221,13 @@ void ShopSettings::setDoublePrintItem(const QString &doublePrintItem)
{
m_doublePrintItem = doublePrintItem;
}
Enums::VatType ShopSettings::defaultVat() const
{
return m_defaultVat;
}
void ShopSettings::setDefaultVat(const Enums::VatType &defaultVat)
{
m_defaultVat = defaultVat;
}

@ -30,6 +30,8 @@ class ShopSettings : public QObject
Q_PROPERTY(int decimalPlaces READ decimalPlaces WRITE setDecimalPlaces)
Q_PROPERTY(QString roundingItem READ roundingItem WRITE setRoundingItem)
Q_PROPERTY(Enums::VatType defaultVat READ defaultVat WRITE setDefaultVat)
Q_OBJECT
public:
@ -100,6 +102,9 @@ public:
QString doublePrintItem() const;
void setDoublePrintItem(const QString &doublePrintItem);
Enums::VatType defaultVat() const;
void setDefaultVat(const Enums::VatType &defaultVat);
private:
QString m_output;
CODEPAGE m_codepage;
@ -125,6 +130,8 @@ private:
Enums::Rounding m_rounding;
int m_decimalPlaces;
QString m_roundingItem;
Enums::VatType m_defaultVat;
};
typedef QSharedPointer<ShopSettings> ShopSettingsPtr;

@ -48,6 +48,14 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
registerBinding(ui->doublePrint);
registerBinding(ui->doublePrintItem);
QList<ComboData> listVatTypes;
listVatTypes
<< ComboData(Enums::NONE, tr("None"))
<< ComboData(Enums::HIGH, tr("High"))
<< ComboData(Enums::FIRST_LOWER, tr("First lower"))
<< ComboData(Enums::SECOND_LOWER, tr("Second lower"));
registerBinding(ui->defaultVat, listVatTypes);
m_itemModel = new AutoTableModel<ShopItem>();
}
@ -70,7 +78,7 @@ void ShopSettingsForm::drawButtons()
btn->setObjectName(QString::number(i) + "_" + QString::number(j));
btn->setAcceptDrops(true);
if (m_btnMap[btn->objectName()] != NULL)
if (m_btnMap[btn->objectName()] != nullptr)
{
btn->setText(m_btnMap[btn->objectName()]->shortName());
}

@ -317,6 +317,16 @@
<item row="2" column="1">
<widget class="QLineEdit" name="roundingItem"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Default VAT type</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="defaultVat"/>
</item>
</layout>
</widget>
</item>

@ -190,17 +190,17 @@ void ShopForm::loadButtons()
btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
((QGridLayout*)ui->favorites->layout())->addWidget(btn, i + 1, j);
if (btnMap[btnName] != NULL)
if (btnMap[btnName] != nullptr)
{
btn->setText(btnMap[btnName]->shortName());
connect(btn, &FavButton::clicked, [this, btnMap, btn](bool){
FavoritItemPtr item = btnMap[btn->objectName()];
IPlugin *plugin = Context::instance().plugin(item->pluginId());
IService *service = (plugin != NULL ? plugin->service<IService>() : NULL);
IService *service = (plugin != nullptr ? plugin->service<IService>() : nullptr);
ISellableService *selSrv = dynamic_cast<ISellableService*>(service);
if (selSrv != NULL)
if (selSrv != nullptr)
{
addItem(selSrv->shopItem(item->refId()), 1);
}
@ -236,7 +236,10 @@ void ShopForm::setEetStatusText(const QString &statusText)
void ShopForm::on_directSale_clicked()
{
DirectSaleForm *form = new DirectSaleForm(this);
SettingsService srv("SHOP");
ShopSettingsPtr settings = srv.loadSettings<ShopSettings>();
DirectSaleForm *form = new DirectSaleForm(this, settings->defaultVat());
form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this, form](){
@ -316,7 +319,7 @@ void ShopForm::on_loadButton_clicked()
void ShopForm::onCountChanged(int oldCount/* = 0*/)
{
VoucherItem *item = qobject_cast<VoucherItem*>(sender());
if (item != NULL && item->count() == 0)
if (item != nullptr && item->count() == 0)
{
for (int i = 0; i < m_voucher->items().count(); i++)
{
@ -346,7 +349,7 @@ void ShopForm::onCountChanged(int oldCount/* = 0*/)
srv.updateVoucher(m_voucher);
}
if (item != NULL)
if (item != nullptr)
{
int countAdded = item->count() - oldCount;
srv.updateRelatedItem(item, countAdded);
@ -437,7 +440,7 @@ void ShopForm::addItem(QSharedPointer<IShopItem> item, int count)
}
IPlugin *plugin = Context::instance().plugin(item->pluginId());
IService *service = (plugin != NULL ? plugin->service<IService>() : NULL);
IService *service = (plugin != nullptr ? plugin->service<IService>() : nullptr);
ISellableService *selSrv = dynamic_cast<ISellableService*>(service);
auto addFunc = [this](QSharedPointer<IShopItem> shopItem, int itemCount){
@ -448,7 +451,7 @@ void ShopForm::addItem(QSharedPointer<IShopItem> item, int count)
onCountChanged();
};
if (selSrv != NULL && selSrv->seller() != NULL)
if (selSrv != nullptr && selSrv->seller() != nullptr)
{
ISeller *seller = selSrv->seller();

Loading…
Cancel
Save