File indexing completed on 2024-05-12 16:42:18
0001 /* 0002 SPDX-FileCopyrightText: 2016-2017 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "ledgersplit.h" 0008 0009 // ---------------------------------------------------------------------------- 0010 // QT Includes 0011 0012 #include <QDebug> 0013 #include <QString> 0014 0015 // ---------------------------------------------------------------------------- 0016 // KDE Includes 0017 0018 // ---------------------------------------------------------------------------- 0019 // Project Includes 0020 0021 #include "ledgertransaction_p.h" 0022 #include "mymoneytransaction.h" 0023 #include "mymoneyfile.h" 0024 #include "mymoneypayee.h" 0025 #include "mymoneyexception.h" 0026 0027 using namespace eMyMoney; 0028 0029 class LedgerSplitPrivate : public LedgerTransactionPrivate 0030 { 0031 public: 0032 }; 0033 0034 LedgerSplit::LedgerSplit() : 0035 LedgerTransaction(*new LedgerSplitPrivate, MyMoneyTransaction(), MyMoneySplit()) 0036 { 0037 } 0038 0039 LedgerSplit::LedgerSplit(const MyMoneyTransaction& t, const MyMoneySplit& s) : 0040 LedgerTransaction(*new LedgerSplitPrivate, t, s) 0041 { 0042 Q_D(LedgerSplit); 0043 // override the settings made in the base class 0044 d->m_payeeName.clear(); 0045 d->m_payeeId = d->m_split.payeeId(); 0046 if(!d->m_payeeId.isEmpty()) { 0047 try { 0048 d->m_payeeName = MyMoneyFile::instance()->payee(d->m_payeeId).name(); 0049 } catch (const MyMoneyException &) { 0050 qDebug() << "payee" << d->m_payeeId << "not found."; 0051 } 0052 } 0053 } 0054 0055 LedgerSplit::LedgerSplit(const LedgerSplit& other) : 0056 LedgerTransaction(*new LedgerSplitPrivate(*other.d_func())) 0057 { 0058 } 0059 0060 LedgerSplit::~LedgerSplit() 0061 { 0062 } 0063 0064 QString LedgerSplit::memo() const 0065 { 0066 Q_D(const LedgerSplit); 0067 return d->m_split.memo(); 0068 }