Added sell commodity feature.

This commit is contained in:
2016-07-21 16:24:07 +02:00
parent fb6b4fe027
commit 44c74a5cfe
13 changed files with 122 additions and 19 deletions
+12
View File
@@ -17,3 +17,15 @@ QList<QSharedPointer<ShopItem> > CommodityService::shopItems()
return ret;
}
void CommodityService::addedToVoucher(int itemId, int countAdded)
{
QSharedPointer<CommodityData> commodity = loadById(itemId);
if (!commodity.isNull())
{
commodity->setCount(commodity->count() - countAdded);
}
update(commodity);
}
+1
View File
@@ -13,6 +13,7 @@ public:
// ISellableService interface
public:
QList<QSharedPointer<ShopItem> > shopItems() override;
void addedToVoucher(int itemId, int countAdded) override;
};
#endif // COMMODITYSERVICE_H
+17 -2
View File
@@ -8,7 +8,7 @@ CommodityData::CommodityData(QObject *parent)
m_price = 0;
m_vat = Enums::NONE;
}
int CommodityData::id() const
int CommodityData::id()
{
return m_id;
}
@@ -17,7 +17,7 @@ void CommodityData::setId(int id)
{
m_id = id;
}
QString CommodityData::name() const
QString CommodityData::name()
{
return m_name;
}
@@ -83,6 +83,21 @@ void CommodityData::setCount(int count)
m_count = count;
}
QDecDouble CommodityData::unitPrice()
{
return price();
}
Enums::VatType CommodityData::vatType()
{
return vat();
}
QString CommodityData::pluginId()
{
return "COMMODITY";
}
+9 -3
View File
@@ -14,9 +14,9 @@
class CommodityData : public ShopItem
{
Q_OBJECT
Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString shortName READ shortName WRITE setShortName)
Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QSharedPointer<QObject> type READ type WRITE setType)
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
Q_PROPERTY(Enums::VatType vat READ vat WRITE setVat)
@@ -25,10 +25,10 @@ class CommodityData : public ShopItem
public:
CommodityData(QObject *parent = 0);
int id() const;
int id() override;
void setId(int id);
QString name() const;
QString name() override;
void setName(const QString &name);
QString shortName() const;
@@ -60,6 +60,12 @@ private:
int m_price;
Enums::VatType m_vat;
int m_count;
// IShopItem interface
public:
QDecDouble unitPrice() override;
Enums::VatType vatType() override;
QString pluginId() override;
};
#endif // COMMODITYDATA_H