new plugin commodity implemented
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#ifndef COMMODITY_DATA_H
|
||||
#define COMMODITY_DATA_H
|
||||
#include "commoditydata.h"
|
||||
#include "commoditytypedata.h"
|
||||
|
||||
#endif // COMMODITY_DATA_H
|
||||
@@ -0,0 +1,89 @@
|
||||
#include "commoditydata.h"
|
||||
#include <define.h>
|
||||
|
||||
CommodityData::CommodityData(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
}
|
||||
int CommodityData::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void CommodityData::setId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
QString CommodityData::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void CommodityData::setName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
QString CommodityData::shortName() const
|
||||
{
|
||||
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()) != NULL) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#ifndef COMMODITYDATA_H
|
||||
#define COMMODITYDATA_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <odb/core.hxx>
|
||||
#include "commoditytypedata.h"
|
||||
#include <QDecDouble.hh>
|
||||
#include <QSharedDataPointer>
|
||||
#include <enums.h>
|
||||
|
||||
#pragma db object
|
||||
class CommodityData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
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)
|
||||
Q_PROPERTY(int count READ count WRITE setCount)
|
||||
|
||||
public:
|
||||
CommodityData(QObject *parent = 0);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
QString shortName() const;
|
||||
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);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
QString m_name;
|
||||
QString m_shortName;
|
||||
QString m_code;
|
||||
QSharedPointer<CommodityTypeData> m_type;
|
||||
int m_price;
|
||||
Enums::VatType m_vat;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
#endif // COMMODITYDATA_H
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "commoditytypedata.h"
|
||||
|
||||
CommodityTypeData::CommodityTypeData(QObject *parent)
|
||||
:ComboItem(parent)
|
||||
{
|
||||
}
|
||||
int CommodityTypeData::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void CommodityTypeData::setId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
QString CommodityTypeData::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void CommodityTypeData::setName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
bool CommodityTypeData::eq(ComboItem *other)
|
||||
{
|
||||
CommodityTypeData* ct = qobject_cast<CommodityTypeData *> (other);
|
||||
|
||||
return ct != NULL && this->id() == ct->id() ;
|
||||
}
|
||||
|
||||
QString CommodityTypeData::toString()
|
||||
{
|
||||
return this->name();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef COMMODITYTYPEDATA_H
|
||||
#define COMMODITYTYPEDATA_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <odb/core.hxx>
|
||||
#include <data/comboitem.h>
|
||||
|
||||
#pragma db object
|
||||
class CommodityTypeData :public ComboItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
|
||||
public:
|
||||
CommodityTypeData(QObject *parent = 0);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
QString m_name;
|
||||
|
||||
// ComboItem interface
|
||||
public:
|
||||
bool eq(ComboItem *other);
|
||||
QString toString();
|
||||
};
|
||||
|
||||
#endif // COMMODITYTYPEDATA_H
|
||||
Reference in New Issue
Block a user