|
|
|
#ifndef COMMODITYDATA_H
|
|
|
|
#define COMMODITYDATA_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include "commoditytypedata.h"
|
|
|
|
#include <shopitem.h>
|
|
|
|
#include <QDecDouble.hh>
|
|
|
|
#include <QSharedDataPointer>
|
|
|
|
#include <enums.h>
|
|
|
|
|
|
|
|
#include "../commodity_global.h"
|
|
|
|
|
|
|
|
#pragma db object
|
|
|
|
class CommodityData : public IShopItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QX_REGISTER_FRIEND_CLASS(CommodityData)
|
|
|
|
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(QSharedPointer<QObject> type READ type WRITE setType)
|
|
|
|
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
|
|
|
|
Q_PROPERTY(Enums::VatType vat READ vat WRITE setVat)
|
|
|
|
Q_PROPERTY(int count READ count WRITE setCount)
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit CommodityData(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
long id() override;
|
|
|
|
void setId(long id);
|
|
|
|
|
|
|
|
QString name() override;
|
|
|
|
void setName(const QString &name);
|
|
|
|
|
|
|
|
QString shortName() override;
|
|
|
|
void setShortName(const QString &shortName);
|
|
|
|
|
|
|
|
QString code() const;
|
|
|
|
void setCode(const QString &code);
|
|
|
|
|
|
|
|
QSharedPointer<QObject> type() const;
|
|
|
|
void setType(const QSharedPointer<QObject> &type);
|
|
|
|
|
|
|
|
QDecDouble price() const;
|
|
|
|
void setPrice(const QDecDouble &price);
|
|
|
|
|
|
|
|
Enums::VatType vat() const;
|
|
|
|
void setVat(const Enums::VatType &vat);
|
|
|
|
|
|
|
|
int count() const;
|
|
|
|
void setCount(int count);
|
|
|
|
|
|
|
|
Q_INVOKABLE QStringList eagerLoad();
|
|
|
|
|
|
|
|
private:
|
|
|
|
long m_id{0};
|
|
|
|
QString m_name;
|
|
|
|
QString m_shortName;
|
|
|
|
QString m_code;
|
|
|
|
QSharedPointer<CommodityTypeData> m_type;
|
|
|
|
int m_price;
|
|
|
|
Enums::VatType m_vat;
|
|
|
|
int m_count;
|
|
|
|
|
|
|
|
// IShopItem interface
|
|
|
|
public:
|
|
|
|
QDecDouble unitPrice() override;
|
|
|
|
Enums::VatType vatType() override;
|
|
|
|
QString pluginId() override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QSharedPointer<CommodityData> CommodityDataPtr;
|
|
|
|
|
|
|
|
QX_REGISTER_HPP_COMM(CommodityData, IShopItem, 0)
|
|
|
|
|
|
|
|
#endif // COMMODITYDATA_H
|