#include "voucher.h"
#include <define.h>

Voucher::Voucher(QObject *parent) : QObject(parent)
{
    m_id = 0;
    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;
    m_eetStatus = EET_FOR_SEND;
}

QString Voucher::name() const
{
    return m_name;
}

void Voucher::setName(const QString &name)
{
    m_name = name;
}

QString Voucher::description() const
{
    return m_description;
}

void Voucher::setDescription(const QString &description)
{
    m_description = description;
}

QSharedPointer<QObject> Voucher::contact() const
{
    return m_contact;
}

void Voucher::setContact(const QSharedPointer<QObject> &contact)
{
    if (qobject_cast<AddressbookData*>(contact.data()) != NULL)
    {
        m_contact = qSharedPointerDynamicCast<AddressbookData, QObject>(contact);
    }
}

Voucher::VoucherStatus Voucher::status() const
{
    return m_status;
}

void Voucher::setStatus(const Voucher::VoucherStatus &status)
{
    m_status = status;
}

QDecDouble Voucher::totalPrice() const
{
    return TO_DEC(m_totalPrice);
}

void Voucher::setTotalPrice(QDecDouble totalPrice)
{
    m_totalPrice = FROM_DEC(totalPrice);
}

QList<QSharedPointer<VoucherItem> > Voucher::items() const
{
    return m_items;
}

void Voucher::setItems(const QList<QSharedPointer<VoucherItem> > &items)
{
    m_items = items;
}

void Voucher::addItem(QSharedPointer<VoucherItem> item)
{
    m_items.append(item);
}

void Voucher::removeItem(QSharedPointer<VoucherItem> item)
{
    m_items.removeOne(item);
}

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 TO_DEC(m_totalPriceVatHigh) - TO_DEC(m_priceVatHigh);
}

QDecDouble Voucher::vatAmountFirstLower()
{
    return TO_DEC(m_totalPriceVatFirstLower) - TO_DEC(m_priceVatFirstLower);
}

QDecDouble Voucher::VatAmountSecondLower()
{
    return TO_DEC(m_totalPriceVatSecondLower) - TO_DEC(m_priceVatSecondLower);
}

QString Voucher::numSer() const
{
    return m_numSer;
}

void Voucher::setNumSer(const QString &numSer)
{
    m_numSer = numSer;
}

QDateTime Voucher::payDateTime() const
{
    return m_payDateTime;
}

void Voucher::setPayDateTime(const QDateTime &payDateTime)
{
    m_payDateTime = payDateTime;
}

Voucher::EetStatus Voucher::eetStatus() const
{
    return m_eetStatus;
}

void Voucher::setEetStatus(const Voucher::EetStatus &eetStatus)
{
    m_eetStatus = eetStatus;
}

QDateTime Voucher::eetSendDateTime() const
{
    return m_eetSendDateTime;
}

void Voucher::setEetSendDateTime(const QDateTime &eetSendDateTime)
{
    m_eetSendDateTime = eetSendDateTime;
}

QString Voucher::eetPkp() const
{
    return m_eetPkp;
}

void Voucher::setEetPkp(const QString &eetPkp)
{
    m_eetPkp = eetPkp;
}

QString Voucher::eetBkp() const
{
    return m_eetBkp;
}

void Voucher::setEetBkp(const QString &eetBkp)
{
    m_eetBkp = eetBkp;
}

QString Voucher::eetFik() const
{
    return m_eetFik;
}

void Voucher::setEetFik(const QString &eetFik)
{
    m_eetFik = eetFik;
}

QDateTime Voucher::saveDateTime() const
{
    return m_saveDateTime;
}

void Voucher::setSaveDateTime(const QDateTime &saveDateTime)
{
    m_saveDateTime = saveDateTime;
}

SeasonPtr Voucher::season() const
{
    return m_season;
}

void Voucher::setSeason(const SeasonPtr &season)
{
    m_season = season;
}

QString Voucher::createdBy() const
{
    return m_createdBy;
}

void Voucher::setCreatedBy(const QString &createdBy)
{
    m_createdBy = createdBy;
}

QString Voucher::updatedBy() const
{
    return m_updatedBy;
}

void Voucher::setUpdatedBy(const QString &updatedBy)
{
    m_updatedBy = updatedBy;
}

QDateTime Voucher::created() const
{
    return m_created;
}

void Voucher::setCreated(const QDateTime &created)
{
    m_created = created;
}

QDateTime Voucher::updated() const
{
    return m_updated;
}

void Voucher::setUpdated(const QDateTime &updated)
{
    m_updated = updated;
}

int Voucher::id() const
{
    return m_id;
}

void Voucher::setId(int id)
{
    m_id = id;
}

VoucherSum::VoucherSum()
{
    m_totalPrice = 0;
    m_count = 0;
}

QDecDouble VoucherSum::totalPrice() const
{
    return TO_DEC(m_totalPrice);
}

void VoucherSum::setTotalPrice(QDecDouble totalPrice)
{
    m_totalPrice = FROM_DEC(totalPrice);
}
