#include #include "voucher.h" #include QX_REGISTER_CPP_SHOP(Voucher) namespace qx { template<> void register_class(QxClass& t) { t.setName("Voucher"); t.id(&Voucher::m_id, "id"); t.data(&Voucher::m_numSer, "numSer"); t.data(&Voucher::m_payDateTime, "payDateTime"); t.data(&Voucher::m_name, "name"); t.data(&Voucher::m_description, "description"); t.data(&Voucher::m_vatRateHigh, "vatRateHigh"); t.data(&Voucher::m_vatRateFirstLower, "vatRateFirstLower"); t.data(&Voucher::m_vatRateSecondLower, "vatRateSecondLower"); t.data(&Voucher::m_priceNoVat, "priceNoVat"); t.data(&Voucher::m_priceVatHigh, "priceVatHigh"); t.data(&Voucher::m_priceVatFirstLower, "priceVatFirstLower"); t.data(&Voucher::m_priceVatSecondLower, "priceVatSecondLower"); t.data(&Voucher::m_priceWitouthVat, "priceWitouthVat"); t.data(&Voucher::m_totalPriceVatHigh, "totalPriceVatHigh"); t.data(&Voucher::m_totalPriceVatFirstLower, "totalPriceVatFirstLower"); t.data(&Voucher::m_totalPriceVatSecondLower, "totalPriceVatSecondLower"); t.data(&Voucher::m_totalPrice, "totalPrice"); t.data(&Voucher::m_status, "status"); t.data(&Voucher::m_eetStatus, "eetStatus"); t.data(&Voucher::m_eetSendDateTime, "eetSendDateTime"); t.data(&Voucher::m_eetPkp, "eetPkp"); t.data(&Voucher::m_eetBkp, "eetBkp"); t.data(&Voucher::m_eetFik, "eetFik"); t.data(&Voucher::m_saveDateTime, "saveDateTime"); t.data(&Voucher::m_createdBy, "createdBy"); t.data(&Voucher::m_created, "created"); t.data(&Voucher::m_updatedBy, "updatedBy"); t.data(&Voucher::m_updated, "updated"); t.relationOneToMany(&Voucher::m_items, "voucher", "voucher"); t.relationManyToOne(&Voucher::m_season, "season"); t.relationManyToOne(&Voucher::m_contact, "contact"); } } 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; m_status = NEW; } 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 Voucher::contact() const { return m_contact; } void Voucher::setContact(const QSharedPointer &contact) { if (qobject_cast(contact.data()) != NULL) { m_contact = qSharedPointerDynamicCast(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 > Voucher::items() const { return m_items; } void Voucher::setItems(const QList > &items) { m_items = items; } void Voucher::addItem(QSharedPointer item) { m_items.append(item); } void Voucher::removeItem(QSharedPointer item) { if (item->id() != 0) { m_items.removeIf([&item](const auto& it){ return item->id() == it->id(); }); } else { 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; } long Voucher::id() const { return m_id; } void Voucher::setId(long id) { m_id = id; } QStringList Voucher::eagerLoad() { return { "season", "contact" }; } QX_REGISTER_CPP_SHOP(VoucherSum) namespace qx { template<> void register_class(QxClass& t) { t.setName("VoucherSum"); t.data(&VoucherSum::m_count, "count"); t.data(&VoucherSum::m_totalPrice, "totalPrice"); } } QDecDouble VoucherSum::totalPrice() const { return TO_DEC(m_totalPrice); } int VoucherSum::count() const { return m_count; } VoucherSum::VoucherSum(int count, int totalPrice) : m_count(count), m_totalPrice(totalPrice) {} void VoucherSum::addPrice(QDecDouble price) { m_totalPrice += FROM_DEC(price); } void VoucherSum::addCount(int count) { m_count += count; }