You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
2.2 KiB
C++

#include "commoditydata.h"
#include <define.h>
QX_REGISTER_CPP_COMM(CommodityData)
namespace qx {
template<> void register_class(QxClass<CommodityData>& t) {
t.setName("CommodityData");
t.id(&CommodityData::m_id, "id");
t.data(&CommodityData::m_name, "name");
t.data(&CommodityData::m_shortName, "shortName");
t.data(&CommodityData::m_code, "code");
t.data(&CommodityData::m_price, "price");
t.data(&CommodityData::m_vat, "vat");
t.data(&CommodityData::m_count, "count");
t.relationManyToOne(&CommodityData::m_type, "type");
}
}
CommodityData::CommodityData(QObject *parent)
:IShopItem(parent)
{
m_count = 0;
m_price = 0;
m_vat = Enums::NONE;
}
long CommodityData::id()
{
return m_id;
}
void CommodityData::setId(long id)
{
m_id = id;
}
QString CommodityData::name()
{
return m_name;
}
void CommodityData::setName(const QString &name)
{
m_name = name;
}
QString CommodityData::shortName()
{
return m_shortName;
}
void CommodityData::setShortName(const QString &shortName)
{
m_shortName = shortName;
}
QString CommodityData::code() const
{
return m_code;
}
void CommodityData::setCode(const QString &code)
{
m_code = code;
}
QSharedPointer<QObject> CommodityData::type() const
{
return m_type;
}
void CommodityData::setType(const QSharedPointer<QObject> &type)
{
if (qobject_cast<CommodityTypeData*>(type.data()) != nullptr) {
m_type = qSharedPointerDynamicCast<CommodityTypeData, QObject>(type);
}
}
QDecDouble CommodityData::price() const
{
return QDecDouble((double)m_price / DEC_MULTIPLE);
}
void CommodityData::setPrice(const QDecDouble &price)
{
m_price = price.toDouble() * DEC_MULTIPLE;
}
Enums::VatType CommodityData::vat() const
{
return m_vat;
}
void CommodityData::setVat(const Enums::VatType &vat)
{
m_vat = vat;
}
int CommodityData::count() const
{
return m_count;
}
void CommodityData::setCount(int count)
{
m_count = count;
}
QDecDouble CommodityData::unitPrice()
{
return price();
}
Enums::VatType CommodityData::vatType()
{
return vat();
}
QString CommodityData::pluginId()
{
return "COMMODITY";
}
QStringList CommodityData::eagerLoad() {
return { "type" };
}