File indexing completed on 2024-06-16 04:45:43
0001 /* 0002 SPDX-FileCopyrightText: 2014 Christian Dávid <christian-david@web.de> 0003 SPDX-FileCopyrightText: 2022 Thomas Baumgart <tbaumgart@kde.org> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include <QVariant> 0008 0009 #include "payeeidentifier/nationalaccount/nationalaccount.h" 0010 #include "xmlhelper/xmlstoragehelper.h" 0011 0012 #include <typeinfo> 0013 0014 namespace payeeIdentifiers 0015 { 0016 0017 nationalAccount::nationalAccount() 0018 : m_ownerName(), 0019 m_country(), 0020 m_bankCode(), 0021 m_accountNumber() 0022 { 0023 } 0024 0025 nationalAccount::nationalAccount(const nationalAccount& other) 0026 : m_ownerName(other.m_ownerName), 0027 m_country(other.m_country), 0028 m_bankCode(other.m_bankCode), 0029 m_accountNumber(other.m_accountNumber) 0030 { 0031 0032 } 0033 0034 nationalAccount* nationalAccount::createFromXml(QXmlStreamReader* reader) const 0035 { 0036 nationalAccount* ident = new nationalAccount; 0037 0038 ident->setBankCode(MyMoneyXmlHelper::readStringAttribute(reader, QLatin1String("bankcode"))); 0039 ident->setAccountNumber(MyMoneyXmlHelper::readStringAttribute(reader, QLatin1String("accountnumber"))); 0040 ident->setOwnerName(MyMoneyXmlHelper::readStringAttribute(reader, QLatin1String("ownername"))); 0041 ident->setCountry(MyMoneyXmlHelper::readStringAttribute(reader, QLatin1String("country"))); 0042 return ident; 0043 } 0044 0045 void nationalAccount::writeXML(QXmlStreamWriter* writer) const 0046 { 0047 writer->writeAttribute("accountnumber", m_accountNumber); 0048 if (!m_bankCode.isEmpty()) { 0049 writer->writeAttribute("bankcode", m_bankCode); 0050 } 0051 writer->writeAttribute("ownername", m_ownerName); 0052 writer->writeAttribute("country", m_country); 0053 } 0054 0055 /** @todo implement */ 0056 bool nationalAccount::isValid() const 0057 { 0058 return true; 0059 } 0060 0061 bool nationalAccount::operator==(const payeeIdentifierData& other) const 0062 { 0063 try { 0064 const nationalAccount& otherCasted = dynamic_cast<const nationalAccount&>(other); 0065 return operator==(otherCasted); 0066 } catch (const std::bad_cast&) { 0067 } 0068 return false; 0069 } 0070 0071 bool nationalAccount::operator==(const nationalAccount& other) const 0072 { 0073 return (m_accountNumber == other.m_accountNumber && m_bankCode == other.m_bankCode && m_ownerName == other.m_ownerName && m_country == other.m_country); 0074 } 0075 0076 } // namespace payeeIdentifiers