Added support for VAT calculations.
This commit is contained in:
+126
-1
@@ -3,7 +3,18 @@
|
||||
|
||||
Voucher::Voucher(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
m_vatRateHigh = 0;
|
||||
m_vatRateFirstLower = 0;
|
||||
m_vatRateSecondLower = 0;
|
||||
m_priceNoVat = 0;
|
||||
m_priceVatHigh = 0;
|
||||
m_priceVatFirstLower = 0;
|
||||
m_priceVatSecondLower = 0;
|
||||
m_priceWitouthVat = 0;
|
||||
m_totalPriceVatHigh = 0;
|
||||
m_totalPriceVatFirstLower = 0;
|
||||
m_totalPriceVatSecondLower = 0;
|
||||
m_totalPrice = 0;
|
||||
}
|
||||
|
||||
QString Voucher::name() const
|
||||
@@ -83,6 +94,120 @@ void Voucher::clearItems()
|
||||
{
|
||||
m_items.clear();
|
||||
}
|
||||
QDecDouble Voucher::vatRateHigh() const
|
||||
{
|
||||
return TO_DEC(m_vatRateHigh);
|
||||
}
|
||||
|
||||
void Voucher::setVatRateHigh(QDecDouble vatRateHigh)
|
||||
{
|
||||
m_vatRateHigh = FROM_DEC(vatRateHigh);
|
||||
}
|
||||
QDecDouble Voucher::vatRateFirstLower() const
|
||||
{
|
||||
return TO_DEC(m_vatRateFirstLower);
|
||||
}
|
||||
|
||||
void Voucher::setVatRateFirstLower(QDecDouble vatRateFirstLower)
|
||||
{
|
||||
m_vatRateFirstLower = FROM_DEC(vatRateFirstLower);
|
||||
}
|
||||
QDecDouble Voucher::vatRateSecondLower() const
|
||||
{
|
||||
return TO_DEC(m_vatRateSecondLower);
|
||||
}
|
||||
|
||||
void Voucher::setVatRateSecondLower(QDecDouble vatRateSecondLower)
|
||||
{
|
||||
m_vatRateSecondLower = FROM_DEC(vatRateSecondLower);
|
||||
}
|
||||
QDecDouble Voucher::priceVatHigh() const
|
||||
{
|
||||
return TO_DEC(m_priceVatHigh);
|
||||
}
|
||||
|
||||
void Voucher::setPriceVatHigh(QDecDouble priceVatHigh)
|
||||
{
|
||||
m_priceVatHigh = FROM_DEC(priceVatHigh);
|
||||
}
|
||||
QDecDouble Voucher::priceVatFirstLower() const
|
||||
{
|
||||
return TO_DEC(m_priceVatFirstLower);
|
||||
}
|
||||
|
||||
void Voucher::setPriceVatFirstLower(QDecDouble priceVatFirstLower)
|
||||
{
|
||||
m_priceVatFirstLower = FROM_DEC(priceVatFirstLower);
|
||||
}
|
||||
QDecDouble Voucher::priceVatSecondLower() const
|
||||
{
|
||||
return TO_DEC(m_priceVatSecondLower);
|
||||
}
|
||||
|
||||
void Voucher::setPriceVatSecondLower(QDecDouble priceVatSecondLower)
|
||||
{
|
||||
m_priceVatSecondLower = FROM_DEC(priceVatSecondLower);
|
||||
}
|
||||
QDecDouble Voucher::priceNoVat() const
|
||||
{
|
||||
return TO_DEC(m_priceNoVat);
|
||||
}
|
||||
|
||||
void Voucher::setPriceNoVat(QDecDouble priceNoVat)
|
||||
{
|
||||
m_priceNoVat = FROM_DEC(priceNoVat);
|
||||
}
|
||||
QDecDouble Voucher::priceWitouthVat() const
|
||||
{
|
||||
return TO_DEC(m_priceWitouthVat);
|
||||
}
|
||||
|
||||
void Voucher::setPriceWitouthVat(QDecDouble priceWitouthVat)
|
||||
{
|
||||
m_priceWitouthVat = FROM_DEC(priceWitouthVat);
|
||||
}
|
||||
QDecDouble Voucher::totalPriceVatHigh() const
|
||||
{
|
||||
return TO_DEC(m_totalPriceVatHigh);
|
||||
}
|
||||
|
||||
void Voucher::setTotalPriceVatHigh(QDecDouble totalPriceVatHigh)
|
||||
{
|
||||
m_totalPriceVatHigh = FROM_DEC(totalPriceVatHigh);
|
||||
}
|
||||
QDecDouble Voucher::totalPriceVatFirstLower() const
|
||||
{
|
||||
return TO_DEC(m_totalPriceVatFirstLower);
|
||||
}
|
||||
|
||||
void Voucher::setTotalPriceVatFirstLower(QDecDouble totalPriceVatFirstLower)
|
||||
{
|
||||
m_totalPriceVatFirstLower = FROM_DEC(totalPriceVatFirstLower);
|
||||
}
|
||||
QDecDouble Voucher::totalPriceVatSecondLower() const
|
||||
{
|
||||
return TO_DEC(m_totalPriceVatSecondLower);
|
||||
}
|
||||
|
||||
void Voucher::setTotalPriceVatSecondLower(QDecDouble totalPriceVatSecondLower)
|
||||
{
|
||||
m_totalPriceVatSecondLower = FROM_DEC(totalPriceVatSecondLower);
|
||||
}
|
||||
|
||||
QDecDouble Voucher::vatAmountHigh()
|
||||
{
|
||||
return m_totalPriceVatHigh - m_priceVatHigh;
|
||||
}
|
||||
|
||||
QDecDouble Voucher::vatAmountFirstLower()
|
||||
{
|
||||
return m_totalPriceVatFirstLower - m_priceVatFirstLower;
|
||||
}
|
||||
|
||||
QDecDouble Voucher::VatAmountSecondLower()
|
||||
{
|
||||
return m_totalPriceVatSecondLower - m_priceVatSecondLower;
|
||||
}
|
||||
|
||||
int Voucher::id() const
|
||||
{
|
||||
|
||||
@@ -19,6 +19,12 @@ class Voucher : public QObject
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString description READ description WRITE setDescription)
|
||||
Q_PROPERTY(QSharedPointer<QObject> contact READ contact WRITE setContact)
|
||||
Q_PROPERTY(QDecDouble vatRateHigh READ vatRateHigh WRITE setVatRateHigh)
|
||||
Q_PROPERTY(QDecDouble vatRateFirstLower READ vatRateFirstLower WRITE setVatRateFirstLower)
|
||||
Q_PROPERTY(QDecDouble vatRateSecondLower READ vatRateSecondLower WRITE setVatRateSecondLower)
|
||||
Q_PROPERTY(QDecDouble priceVatHigh READ priceVatHigh WRITE setPriceVatHigh)
|
||||
Q_PROPERTY(QDecDouble priceVatFirstLower READ priceVatFirstLower WRITE setPriceVatFirstLower)
|
||||
Q_PROPERTY(QDecDouble priceVatSecondLower READ priceVatSecondLower WRITE setPriceVatSecondLower)
|
||||
Q_PROPERTY(QDecDouble totalPrice READ totalPrice WRITE setTotalPrice)
|
||||
Q_ENUMS(VoucherStatus)
|
||||
Q_PROPERTY(VoucherStatus status READ status WRITE setStatus)
|
||||
@@ -59,6 +65,43 @@ public:
|
||||
void removeItem(QSharedPointer<VoucherItem> item);
|
||||
void clearItems();
|
||||
|
||||
QDecDouble vatRateHigh() const;
|
||||
void setVatRateHigh(QDecDouble vatRateHigh);
|
||||
|
||||
QDecDouble vatRateFirstLower() const;
|
||||
void setVatRateFirstLower(QDecDouble vatRateFirstLower);
|
||||
|
||||
QDecDouble vatRateSecondLower() const;
|
||||
void setVatRateSecondLower(QDecDouble vatRateSecondLower);
|
||||
|
||||
QDecDouble priceVatHigh() const;
|
||||
void setPriceVatHigh(QDecDouble priceVatHigh);
|
||||
|
||||
QDecDouble priceVatFirstLower() const;
|
||||
void setPriceVatFirstLower(QDecDouble priceVatFirstLower);
|
||||
|
||||
QDecDouble priceVatSecondLower() const;
|
||||
void setPriceVatSecondLower(QDecDouble priceVatSecondLower);
|
||||
|
||||
QDecDouble priceNoVat() const;
|
||||
void setPriceNoVat(QDecDouble priceNoVat);
|
||||
|
||||
QDecDouble priceWitouthVat() const;
|
||||
void setPriceWitouthVat(QDecDouble priceWitouthVat);
|
||||
|
||||
QDecDouble totalPriceVatHigh() const;
|
||||
void setTotalPriceVatHigh(QDecDouble totalPriceVatHigh);
|
||||
|
||||
QDecDouble totalPriceVatFirstLower() const;
|
||||
void setTotalPriceVatFirstLower(QDecDouble totalPriceVatFirstLower);
|
||||
|
||||
QDecDouble totalPriceVatSecondLower() const;
|
||||
void setTotalPriceVatSecondLower(QDecDouble totalPriceVatSecondLower);
|
||||
|
||||
QDecDouble vatAmountHigh();
|
||||
QDecDouble vatAmountFirstLower();
|
||||
QDecDouble VatAmountSecondLower();
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
@@ -66,6 +109,17 @@ private:
|
||||
QString m_name;
|
||||
QString m_description;
|
||||
QSharedPointer<AddressbookData> m_contact;
|
||||
int m_vatRateHigh;
|
||||
int m_vatRateFirstLower;
|
||||
int m_vatRateSecondLower;
|
||||
int m_priceNoVat;
|
||||
int m_priceVatHigh;
|
||||
int m_priceVatFirstLower;
|
||||
int m_priceVatSecondLower;
|
||||
int m_priceWitouthVat;
|
||||
int m_totalPriceVatHigh;
|
||||
int m_totalPriceVatFirstLower;
|
||||
int m_totalPriceVatSecondLower;
|
||||
int m_totalPrice;
|
||||
QOdbList<QSharedPointer<VoucherItem> > m_items;
|
||||
VoucherStatus m_status;
|
||||
|
||||
@@ -8,6 +8,8 @@ VoucherItem::VoucherItem(QObject *parent) : QObject(parent)
|
||||
m_count = 0;
|
||||
m_refId = 0;
|
||||
m_vatType = Enums::NONE;
|
||||
m_vatRate = 0;
|
||||
m_priceWitouthVat = 0;
|
||||
}
|
||||
|
||||
int VoucherItem::id() const
|
||||
@@ -90,3 +92,28 @@ void VoucherItem::setVatType(const Enums::VatType &vatType)
|
||||
{
|
||||
m_vatType = vatType;
|
||||
}
|
||||
QDecDouble VoucherItem::vatRate() const
|
||||
{
|
||||
return TO_DEC(m_vatRate);
|
||||
}
|
||||
|
||||
void VoucherItem::setVatRate(QDecDouble vatRate)
|
||||
{
|
||||
m_vatRate = FROM_DEC(vatRate);
|
||||
}
|
||||
QDecDouble VoucherItem::priceWitouthVat() const
|
||||
{
|
||||
return TO_DEC(m_priceWitouthVat);
|
||||
}
|
||||
|
||||
void VoucherItem::setPriceWitouthVat(QDecDouble priceWitouthVat)
|
||||
{
|
||||
m_priceWitouthVat = FROM_DEC(priceWitouthVat);
|
||||
}
|
||||
|
||||
QDecDouble VoucherItem::vatAmount() const
|
||||
{
|
||||
return m_price - m_priceWitouthVat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+13
-1
@@ -16,8 +16,10 @@ class VoucherItem : public QObject
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
|
||||
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
|
||||
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
|
||||
Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType)
|
||||
Q_PROPERTY(QDecDouble vatRate READ vatRate WRITE setVatRate)
|
||||
Q_PROPERTY(QDecDouble vatAmount READ vatAmount)
|
||||
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
|
||||
|
||||
public:
|
||||
explicit VoucherItem(QObject *parent = 0);
|
||||
@@ -46,6 +48,14 @@ public:
|
||||
Enums::VatType vatType() const;
|
||||
void setVatType(const Enums::VatType &vatType);
|
||||
|
||||
QDecDouble vatRate() const;
|
||||
void setVatRate(QDecDouble vatRate);
|
||||
|
||||
QDecDouble priceWitouthVat() const;
|
||||
void setPriceWitouthVat(QDecDouble priceWitouthVat);
|
||||
|
||||
QDecDouble vatAmount() const;
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
|
||||
@@ -56,6 +66,8 @@ private:
|
||||
QString m_name;
|
||||
int m_count;
|
||||
int m_unitPrice;
|
||||
int m_vatRate;
|
||||
int m_priceWitouthVat;
|
||||
int m_price;
|
||||
int m_refId;
|
||||
QString m_itemPlugin;
|
||||
|
||||
Reference in New Issue
Block a user