acurrencyentry.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "acurrencyentry.h"
  2. #include "src/opl.h"
  3. //ACurrencyEntry::ACurrencyEntry()
  4. //{
  5. //
  6. //}
  7. /*!
  8. * \brief ACurrencyEntry::ACurrencyEntry Creates an ACurrenyEntry object.
  9. *
  10. * The Data Position is initalized by using the strongly typed enum
  11. * CurrencyName, which maps to the static row id for the currency.
  12. */
  13. ACurrencyEntry::ACurrencyEntry(ACurrencyEntry::CurrencyName currency_name)
  14. : AEntry::AEntry(DataPosition(OPL::Db::TABLE_CURRENCIES, static_cast<int>(currency_name)))
  15. {}
  16. ACurrencyEntry::ACurrencyEntry(ACurrencyEntry::CurrencyName currency_name, QDate expiration_date)
  17. : AEntry::AEntry(DataPosition(OPL::Db::TABLE_CURRENCIES, static_cast<int>(currency_name)))
  18. {
  19. if (expiration_date.isValid()) {
  20. tableData.insert(OPL::Db::CURRENCIES_EXPIRYDATE, expiration_date.toString(Qt::ISODate));
  21. } else {
  22. DEB << "Invalid Date.";
  23. }
  24. }
  25. /*!
  26. * \brief ACurrencyEntry::isValid returns true if the object holds a valid expiration date.
  27. *
  28. * Unless a user has previously entered an expiration date, this will return false.
  29. * \return
  30. */
  31. bool ACurrencyEntry::isValid() const
  32. {
  33. return QDate::fromString(
  34. tableData.value(OPL::Db::CURRENCIES_EXPIRYDATE).toString(), Qt::ISODate
  35. ).isValid();
  36. }