本文整理汇总了C++中MyMoneySplit类的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySplit类的具体用法?C++ MyMoneySplit怎么用?C++ MyMoneySplit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyMoneySplit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: diffAmount
MyMoneyMoney KSplitTransactionDlg::diffAmount()
{
MyMoneyMoney diff;
// if there is an amount specified in the transaction, we need to calculate the
// difference, otherwise we display the difference as 0 and display the same sum.
if (m_amountValid) {
MyMoneySplit split = m_transaction.splits()[0];
diff = -(splitsValue() + split.value());
}
return diff;
}
示例2: filter
void MyMoneyQifWriter::writeAccountEntry(QTextStream &s, const QString& accountId, const QDate& startDate, const QDate& endDate)
{
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneyAccount account;
account = file->account(accountId);
MyMoneyTransactionFilter filter(accountId);
filter.setDateFilter(startDate, endDate);
QValueList<MyMoneyTransaction> list = file->transactionList(filter);
QString openingBalanceTransactionId;
s << "!Type:" << m_qifProfile.profileType() << endl;
if(!startDate.isValid() || startDate <= account.openingDate()) {
s << "D" << m_qifProfile.date(account.openingDate()) << endl;
openingBalanceTransactionId = file->openingBalanceTransaction(account);
MyMoneySplit split;
if(!openingBalanceTransactionId.isEmpty()) {
MyMoneyTransaction openingBalanceTransaction = file->transaction(openingBalanceTransactionId);
split = openingBalanceTransaction.splitByAccount(account.id(), true /* match */);
}
s << "T" << m_qifProfile.value('T', split.value()) << endl;
} else {
s << "D" << m_qifProfile.date(startDate) << endl;
s << "T" << m_qifProfile.value('T', file->balance(accountId, startDate.addDays(-1))) << endl;
}
s << "CX" << endl;
s << "P" << m_qifProfile.openingBalanceText() << endl;
s << "L";
if(m_qifProfile.accountDelimiter().length())
s << m_qifProfile.accountDelimiter()[0];
s << account.name();
if(m_qifProfile.accountDelimiter().length() > 1)
s << m_qifProfile.accountDelimiter()[1];
s << endl;
s << "^" << endl;
QValueList<MyMoneyTransaction>::ConstIterator it;
signalProgress(0, list.count());
int count = 0;
for(it = list.begin(); it != list.end(); ++it) {
// don't include the openingBalanceTransaction again
if((*it).id() != openingBalanceTransactionId)
writeTransactionEntry(s, *it, accountId);
signalProgress(++count, 0);
}
}
示例3: if
void CsvUtil::dissectTransaction(const MyMoneyTransaction& transaction, const MyMoneySplit& split, MyMoneySplit& assetAccountSplit, QList<MyMoneySplit>& feeSplits, QList<MyMoneySplit>& interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency, MyMoneySplit::investTransactionTypeE& transactionType)
{
// collect the splits. split references the stock account and should already
// be set up. assetAccountSplit references the corresponding asset account (maybe
// empty), feeSplits is the list of all expenses and interestSplits
// the list of all incomes
MyMoneyFile* file = MyMoneyFile::instance();
QList<MyMoneySplit>::ConstIterator it_s;
for (it_s = transaction.splits().constBegin(); it_s != transaction.splits().constEnd(); ++it_s) {
MyMoneyAccount acc = file->account((*it_s).accountId());
if ((*it_s).id() == split.id()) {
security = file->security(acc.currencyId());
} else if (acc.accountGroup() == MyMoneyAccount::Expense) {
feeSplits.append(*it_s);
} else if (acc.accountGroup() == MyMoneyAccount::Income) {
interestSplits.append(*it_s);
} else {
assetAccountSplit = *it_s;
}
}
// determine transaction type
if (split.action() == MyMoneySplit::ActionAddShares) {
transactionType = (!split.shares().isNegative()) ? MyMoneySplit::AddShares : MyMoneySplit::RemoveShares;
} else if (split.action() == MyMoneySplit::ActionBuyShares) {
transactionType = (!split.value().isNegative()) ? MyMoneySplit::BuyShares : MyMoneySplit::SellShares;
} else if (split.action() == MyMoneySplit::ActionDividend) {
transactionType = MyMoneySplit::Dividend;
} else if (split.action() == MyMoneySplit::ActionReinvestDividend) {
transactionType = MyMoneySplit::ReinvestDividend;
} else if (split.action() == MyMoneySplit::ActionYield) {
transactionType = MyMoneySplit::Yield;
} else if (split.action() == MyMoneySplit::ActionSplitShares) {
transactionType = MyMoneySplit::SplitShares;
} else if (split.action() == MyMoneySplit::ActionInterestIncome) {
transactionType = MyMoneySplit::InterestIncome;
} else
transactionType = MyMoneySplit::BuyShares;
currency.setTradingSymbol("???");
try {
currency = file->security(transaction.commodity());
} catch (const MyMoneyException &) {
}
}
示例4: MyMoneySplit
const MyMoneySplit KMyMoneyUtils::stockSplit(const MyMoneyTransaction& t)
{
QList<MyMoneySplit>::ConstIterator it_s;
MyMoneySplit investmentAccountSplit;
for (it_s = t.splits().begin(); it_s != t.splits().end(); ++it_s) {
if (!(*it_s).accountId().isEmpty()) {
MyMoneyAccount acc = MyMoneyFile::instance()->account((*it_s).accountId());
if (acc.isInvest()) {
return *it_s;
}
// if we have a reference to an investment account, we remember it here
if (acc.accountType() == MyMoneyAccount::Investment)
investmentAccountSplit = *it_s;
}
}
// if we haven't found a stock split, we see if we've seen
// an investment account on the way. If so, we return it.
if (!investmentAccountSplit.id().isEmpty())
return investmentAccountSplit;
// if none was found, we return an empty split.
return MyMoneySplit();
}
示例5: testConstructor
void MyMoneyAccountTest::testConstructor()
{
QString id = "A000001";
QString institutionid = "B000001";
QString parent = "Parent";
MyMoneyAccount r;
MyMoneySplit s;
r.setAccountType(MyMoneyAccount::Asset);
r.setOpeningDate(QDate::currentDate());
r.setLastModified(QDate::currentDate());
r.setDescription("Desc");
r.setNumber("465500");
r.setParentAccountId(parent);
r.setValue(QString("key"), "value");
s.setShares(MyMoneyMoney::ONE);
r.adjustBalance(s);
QVERIFY(r.m_kvp.count() == 1);
QVERIFY(r.value("key") == "value");
MyMoneyAccount a(id, r);
QVERIFY(a.id() == id);
QVERIFY(a.institutionId().isEmpty());
QVERIFY(a.accountType() == MyMoneyAccount::Asset);
QVERIFY(a.openingDate() == QDate::currentDate());
QVERIFY(a.lastModified() == QDate::currentDate());
QVERIFY(a.number() == "465500");
QVERIFY(a.description() == "Desc");
QVERIFY(a.accountList().count() == 0);
QVERIFY(a.parentAccountId() == "Parent");
QVERIFY(a.balance() == MyMoneyMoney::ONE);
QMap<QString, QString> copy;
copy = r.pairs();
QVERIFY(copy.count() == 1);
QVERIFY(copy[QString("key")] == "value");
}
示例6: tm
void TransactionMatcher::accept(const MyMoneyTransaction& _t, const MyMoneySplit& _s)
{
if (_s.isMatched()) {
MyMoneyTransaction tm(_t);
MyMoneySplit sm(_s);
sm.removeMatch();
sm.deletePair("kmm-orig-postdate");
sm.deletePair("kmm-orig-payee");
sm.deletePair("kmm-orig-memo");
sm.deletePair("kmm-match-split");
tm.modifySplit(sm);
MyMoneyFile::instance()->modifyTransaction(tm);
}
}
示例7: Q_UNUSED
void TransactionMatcher::checkTransaction(const MyMoneyTransaction& tm, const MyMoneyTransaction& ti, const MyMoneySplit& si, QPair<MyMoneyTransaction, MyMoneySplit>& lastMatch, TransactionMatcher::autoMatchResultE& result, int variation) const
{
Q_UNUSED(ti);
const QValueList<MyMoneySplit>& splits = tm.splits();
QValueList<MyMoneySplit>::const_iterator it_s;
for(it_s = splits.begin(); it_s != splits.end(); ++it_s) {
MyMoneyMoney upper((*it_s).shares());
MyMoneyMoney lower(upper);
if((variation > 0) && (variation < 100)) {
lower = lower - (lower.abs() * MyMoneyMoney(variation, 100));
upper = upper + (upper.abs() * MyMoneyMoney(variation, 100));
}
// we only check for duplicates / matches if the sign
// of the amount for this split is identical
if((si.shares() >= lower) && (si.shares() <= upper)) {
// check for duplicate (we can only do that, if we have a bankID)
if(!si.bankID().isEmpty()) {
if((*it_s).bankID() == si.bankID()) {
lastMatch = QPair<MyMoneyTransaction, MyMoneySplit>(tm, *it_s);
result = matchedDuplicate;
break;
}
// in case the stored split already has a bankid
// assigned, it must be a different one and therefore
// will certainly not match
if(!(*it_s).bankID().isEmpty())
continue;
}
// check if this is the one that matches
if((*it_s).accountId() == si.accountId()
&& (si.shares() >= lower) && (si.shares() <= upper)
&& !(*it_s).isMatched()) {
if(tm.postDate() == ti.postDate()) {
lastMatch = QPair<MyMoneyTransaction, MyMoneySplit>(tm, *it_s);
result = matchedExact;
} else if(result != matchedExact) {
lastMatch = QPair<MyMoneyTransaction, MyMoneySplit>(tm, *it_s);
result = matched;
}
}
}
}
}
示例8: QVERIFY
void MyMoneyAccountTest::testAdjustBalance()
{
MyMoneyAccount a;
MyMoneySplit s;
s.setShares(MyMoneyMoney(3, 1));
a.adjustBalance(s);
QVERIFY(a.balance() == MyMoneyMoney(3, 1));
s.setShares(MyMoneyMoney(5, 1));
a.adjustBalance(s, true);
QVERIFY(a.balance() == MyMoneyMoney(-2, 1));
s.setShares(MyMoneyMoney(2, 1));
s.setAction(MyMoneySplit::ActionSplitShares);
a.adjustBalance(s);
QVERIFY(a.balance() == MyMoneyMoney(-4, 1));
s.setShares(MyMoneyMoney(4, 1));
s.setAction(QString());
a.adjustBalance(s);
QVERIFY(a.balance().isZero());
}
示例9: tm
void TransactionMatcher::unmatch(const MyMoneyTransaction& _t, const MyMoneySplit& _s)
{
if(_s.isMatched()) {
MyMoneyTransaction tm(_t);
MyMoneySplit sm(_s);
MyMoneyTransaction ti(sm.matchedTransaction());
MyMoneySplit si;
// if we don't have a split, then we don't have a memo
try {
si = ti.splitById(sm.value("kmm-match-split"));
} catch(MyMoneyException* e) {
delete e;
}
sm.removeMatch();
// restore the postdate if modified
if(!sm.value("kmm-orig-postdate").isEmpty()) {
tm.setPostDate(QDate::fromString(sm.value("kmm-orig-postdate"), Qt::ISODate));
}
// restore payee if modified
if(!sm.value("kmm-orig-payee").isEmpty()) {
sm.setPayeeId(sm.value("kmm-orig-payee"));
}
// restore memo if modified
if(!sm.value("kmm-orig-memo").isEmpty()) {
sm.setMemo(sm.value("kmm-orig-memo"));
}
sm.deletePair("kmm-orig-postdate");
sm.deletePair("kmm-orig-payee");
sm.deletePair("kmm-orig-memo");
sm.deletePair("kmm-match-split");
tm.modifySplit(sm);
MyMoneyFile::instance()->modifyTransaction(tm);
MyMoneyFile::instance()->addTransaction(ti);
}
}
示例10: writeSplitEntry
void MyMoneyQifWriter::writeSplitEntry(QTextStream& s, const MyMoneySplit& split)
{
MyMoneyFile* file = MyMoneyFile::instance();
s << "S";
MyMoneyAccount acc = file->account(split.accountId());
if(acc.accountGroup() != MyMoneyAccount::Income
&& acc.accountGroup() != MyMoneyAccount::Expense) {
s << m_qifProfile.accountDelimiter()[0]
<< file->accountToCategory(split.accountId())
<< m_qifProfile.accountDelimiter()[1];
} else {
s << file->accountToCategory(split.accountId());
}
s << endl;
if(split.memo().length() > 0) {
QString m = split.memo();
m.replace('\n', "\\n");
s << "E" << m << endl;
}
s << "$" << m_qifProfile.value('$', -split.value()) << endl;
}
示例11: MYMONEYEXCEPTION
void TransactionMatcher::match(MyMoneyTransaction tm, MyMoneySplit sm, MyMoneyTransaction ti, MyMoneySplit si, bool allowImportedTransactions)
{
const MyMoneySecurity& sec = MyMoneyFile::instance()->security(m_account.currencyId());
// Now match the transactions.
//
// 'Matching' the transactions entails DELETING the end transaction,
// and MODIFYING the start transaction as needed.
//
// There are a variety of ways that a transaction can conflict.
// Post date, splits, amount are the ones that seem to matter.
// TODO: Handle these conflicts intelligently, at least warning
// the user, or better yet letting the user choose which to use.
//
// For now, we will just use the transaction details from the start
// transaction. The only thing we'll take from the end transaction
// are the bank ID's.
//
// What we have to do here is iterate over the splits in the end
// transaction, and find the corresponding split in the start
// transaction. If there is a bankID in the end split but not the
// start split, add it to the start split. If there is a bankID
// in BOTH, then this transaction cannot be merged (both transactions
// were imported!!) If the corresponding start split cannot be
// found and the end split has a bankID, we should probably just fail.
// Although we could ADD it to the transaction.
// ipwizard: Don't know if iterating over the transactions is a good idea.
// In case of a split transaction recorded with KMyMoney and the transaction
// data being imported consisting only of a single category assignment, this
// does not make much sense. The same applies for investment transactions
// stored in KMyMoney against imported transactions. I think a better solution
// is to just base the match on the splits referencing the same (currently
// selected) account.
// verify, that tm is a manual (non-matched) transaction
// allow matching two manual transactions
if ((!allowImportedTransactions && tm.isImported()) || sm.isMatched())
throw MYMONEYEXCEPTION(i18n("First transaction does not match requirement for matching"));
// verify that the amounts are the same, otherwise we should not be matching!
if (sm.shares() != si.shares()) {
throw MYMONEYEXCEPTION(i18n("Splits for %1 have conflicting values (%2,%3)", m_account.name(), MyMoneyUtils::formatMoney(sm.shares(), m_account, sec), MyMoneyUtils::formatMoney(si.shares(), m_account, sec)));
}
// check that dates are within user's setting
const int gap = abs(tm.postDate().toJulianDay() - ti.postDate().toJulianDay());
if (gap > KMyMoneyGlobalSettings::matchInterval()) {
int rc = KMessageBox::questionYesNo(0, i18np("The transaction dates are one day apart. Do you want to match them anyway?",
"The transaction dates are %1 days apart. Do you want to match them anyway?", gap));
if (rc == KMessageBox::No) {
return;
}
}
// ipwizard: I took over the code to keep the bank id found in the endMatchTransaction
// This might not work for QIF imports as they don't setup this information. It sure
// makes sense for OFX and HBCI.
const QString& bankID = si.bankID();
if (!bankID.isEmpty()) {
try {
if (sm.bankID().isEmpty()) {
sm.setBankID(bankID);
tm.modifySplit(sm);
}
} catch (const MyMoneyException &e) {
QString estr = e.what();
throw MYMONEYEXCEPTION(i18n("Unable to match all splits (%1)", estr));
}
}
//
// we now allow matching of two non-imported transactions
//
// mark the split as cleared if it does not have a reconciliation information yet
if (sm.reconcileFlag() == MyMoneySplit::NotReconciled) {
sm.setReconcileFlag(MyMoneySplit::Cleared);
}
// if we don't have a payee assigned to the manually entered transaction
// we use the one we found in the imported transaction
if (sm.payeeId().isEmpty() && !si.payeeId().isEmpty()) {
sm.setValue("kmm-orig-payee", sm.payeeId());
sm.setPayeeId(si.payeeId());
}
// We use the imported postdate and keep the previous one for unmatch
if (tm.postDate() != ti.postDate()) {
sm.setValue("kmm-orig-postdate", tm.postDate().toString(Qt::ISODate));
tm.setPostDate(ti.postDate());
}
// combine the two memos into one
QString memo = sm.memo();
if (!si.memo().isEmpty() && si.memo() != memo) {
sm.setValue("kmm-orig-memo", memo);
if (!memo.isEmpty())
memo += '\n';
memo += si.memo();
//.........这里部分代码省略.........
示例12: QVERIFY
void MyMoneySplitTest::testReplaceId()
{
MyMoneySplit s;
bool changed;
s.setPayeeId("P000001");
s.setAccountId("A000076");
changed = s.replaceId("X0001", "Y00001");
QVERIFY(changed == false);
QVERIFY(s.payeeId() == "P000001");
QVERIFY(s.accountId() == "A000076");
changed = s.replaceId("P000002", "P000001");
QVERIFY(changed == true);
QVERIFY(s.payeeId() == "P000002");
QVERIFY(s.accountId() == "A000076");
changed = s.replaceId("A000079", "A000076");
QVERIFY(changed == true);
QVERIFY(s.payeeId() == "P000002");
QVERIFY(s.accountId() == "A000079");
QString ref_ok = QString(
"<!DOCTYPE TEST>\n"
"<SPLIT-CONTAINER>\n"
" <SPLIT payee=\"P000001\" reconciledate=\"\" shares=\"-125000/100\" action=\"Transfer\" bankid=\"A000076-2010-03-05-b6850c0-1\" number=\"\" reconcileflag=\"1\" memo=\"UMBUCHUNG\" value=\"-125000/100\" id=\"S0001\" account=\"A000076\" >\n"
" <KEYVALUEPAIRS>\n"
" <PAIR key=\"kmm-match-split\" value=\"S0002\" />\n"
" <PAIR key=\"kmm-matched-tx\" value=\"&lt;!DOCTYPE MATCH>\n"
" &lt;CONTAINER>\n"
" &lt;TRANSACTION postdate="2010-03-05" memo="UMBUCHUNG" id="" commodity="EUR" entrydate="2010-03-08" >\n"
" &lt;SPLITS>\n"
" &lt;SPLIT payee="P000010" reconciledate="" shares="125000/100" action="Transfer" bankid="" number="" reconcileflag="0" memo="UMBUCHUNG" value="125000/100" id="S0001" account="A000087" />\n"
" &lt;SPLIT payee="P000011" reconciledate="" shares="-125000/100" action="" bankid="A000076-2010-03-05-b6850c0-1" number="" reconcileflag="0" memo="UMBUCHUNG" value="-125000/100" id="S0002" account="A000076" />\n"
" &lt;/SPLITS>\n"
" &lt;KEYVALUEPAIRS>\n"
" &lt;PAIR key="Imported" value="true" />\n"
" &lt;/KEYVALUEPAIRS>\n"
" &lt;/TRANSACTION>\n"
" &lt;/CONTAINER>\n"
"\" />\n"
" <PAIR key=\"kmm-orig-memo\" value=\"\" />\n"
" </KEYVALUEPAIRS>\n"
" </SPLIT>\n"
"</SPLIT-CONTAINER>\n"
);
QDomDocument doc;
QDomElement node;
doc.setContent(ref_ok);
node = doc.documentElement().firstChild().toElement();
try {
s = MyMoneySplit(node);
QVERIFY(s.payeeId() == "P000001");
QVERIFY(s.replaceId("P2", "P1") == false);
QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P000010");
QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P000011");
QVERIFY(s.replaceId("P0010", "P000010") == true);
QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P0010");
QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P000011");
QVERIFY(s.replaceId("P0011", "P000011") == true);
QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P0010");
QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P0011");
} catch (const MyMoneyException &) {
QFAIL("Unexpected exception");
}
}
示例13: QString
void MyMoneySplitTest::testReadXML()
{
MyMoneySplit s;
QString ref_ok = QString(
"<!DOCTYPE TEST>\n"
"<SPLIT-CONTAINER>\n"
" <SPLIT payee=\"P000001\" reconciledate=\"\" shares=\"96379/100\" action=\"Deposit\" bankid=\"SPID\" number=\"124\" reconcileflag=\"2\" memo=\"MyMemo\" value=\"96379/1000\" account=\"A000076\">\n"
" <TAG id=\"G000001\"/>\n"
" </SPLIT>\n"
"</SPLIT-CONTAINER>\n");
QString ref_false = QString(
"<!DOCTYPE TEST>\n"
"<SPLIT-CONTAINER>\n"
" <SPLITS payee=\"P000001\" reconciledate=\"\" shares=\"96379/100\" action=\"Deposit\" bankid=\"SPID\" number=\"124\" reconcileflag=\"2\" memo=\"\" value=\"96379/1000\" account=\"A000076\" />\n"
" <TAG id=\"G000001\"/>\n"
"</SPLIT-CONTAINER>\n");
QDomDocument doc;
QDomElement node;
doc.setContent(ref_false);
node = doc.documentElement().firstChild().toElement();
try {
s = MyMoneySplit(node);
QFAIL("Missing expected exception");
} catch (const MyMoneyException &) {
}
doc.setContent(ref_ok);
node = doc.documentElement().firstChild().toElement();
try {
s = MyMoneySplit(node);
QVERIFY(s.id().isEmpty());
QVERIFY(s.payeeId() == "P000001");
QList<QString> tagIdList;
tagIdList << "G000001";
QVERIFY(s.tagIdList() == tagIdList);
QVERIFY(s.reconcileDate() == QDate());
QVERIFY(s.shares() == MyMoneyMoney(96379, 100));
QVERIFY(s.value() == MyMoneyMoney(96379, 1000));
QVERIFY(s.number() == "124");
QVERIFY(s.bankID() == "SPID");
QVERIFY(s.reconcileFlag() == MyMoneySplit::Reconciled);
QVERIFY(s.action() == MyMoneySplit::ActionDeposit);
QVERIFY(s.accountId() == "A000076");
QVERIFY(s.memo() == "MyMemo");
} catch (const MyMoneyException &) {
}
}
示例14: testWriteXML
void MyMoneySplitTest::testWriteXML()
{
MyMoneySplit s;
s.setPayeeId("P000001");
QList<QString> tagIdList;
tagIdList << "G000001";
s.setTagIdList(tagIdList);
s.setShares(MyMoneyMoney(96379, 100));
s.setValue(MyMoneyMoney(96379, 1000));
s.setAccountId("A000076");
s.setNumber("124");
s.setBankID("SPID");
s.setAction(MyMoneySplit::ActionDeposit);
s.setReconcileFlag(MyMoneySplit::Reconciled);
QDomDocument doc("TEST");
QDomElement el = doc.createElement("SPLIT-CONTAINER");
doc.appendChild(el);
s.writeXML(doc, el);
QCOMPARE(doc.doctype().name(), QLatin1String("TEST"));
QDomElement splitContainer = doc.documentElement();
QCOMPARE(splitContainer.tagName(), QLatin1String("SPLIT-CONTAINER"));
QCOMPARE(splitContainer.childNodes().size(), 1);
QVERIFY(splitContainer.childNodes().at(0).isElement());
QDomElement split = splitContainer.childNodes().at(0).toElement();
QCOMPARE(split.tagName(), QLatin1String("SPLIT"));
QCOMPARE(split.attribute("payee"), QLatin1String("P000001"));
QCOMPARE(split.attribute("reconcileflag"), QLatin1String("2"));
QCOMPARE(split.attribute("shares"), QLatin1String("96379/100"));
QCOMPARE(split.attribute("reconciledate"), QString());
QCOMPARE(split.attribute("action"), QLatin1String("Deposit"));
QCOMPARE(split.attribute("bankid"), QLatin1String("SPID"));
QCOMPARE(split.attribute("account"), QLatin1String("A000076"));
QCOMPARE(split.attribute("number"), QLatin1String("124"));
QCOMPARE(split.attribute("value"), QLatin1String("96379/1000"));
QCOMPARE(split.attribute("memo"), QString());
QCOMPARE(split.attribute("id"), QString());
QCOMPARE(split.childNodes().size(), 1);
QVERIFY(split.childNodes().at(0).isElement());
QDomElement tag = split.childNodes().at(0).toElement();
QCOMPARE(tag.tagName(), QLatin1String("TAG"));
QCOMPARE(tag.attribute("id"), QLatin1String("G000001"));
QCOMPARE(tag.childNodes().size(), 0);
QString ref = QString(
"<!DOCTYPE TEST>\n"
"<SPLIT-CONTAINER>\n"
" <SPLIT payee=\"P000001\" reconcileflag=\"2\" shares=\"96379/100\" reconciledate=\"\" action=\"Deposit\" bankid=\"SPID\" account=\"A000076\" number=\"124\" value=\"96379/1000\" memo=\"\" id=\"\">\n"
" <TAG id=\"G000001\"/>\n"
" </SPLIT>\n"
"</SPLIT-CONTAINER>\n");
}
示例15: testSetFunctions
void MyMoneySplitTest::testAssignmentConstructor()
{
testSetFunctions();
MyMoneySplit n;
n = *m;
QVERIFY(n.accountId() == "Account");
QVERIFY(n.memo() == "Memo");
QVERIFY(n.reconcileDate() == QDate(1, 2, 3));
QVERIFY(n.reconcileFlag() == MyMoneySplit::Cleared);
QVERIFY(n.shares() == MyMoneyMoney(1234, 100));
QVERIFY(n.value() == MyMoneyMoney(3456, 100));
QVERIFY(n.id() == "MyID");
QVERIFY(n.payeeId() == "Payee");
QList<QString> tagIdList;
tagIdList << "Tag";
QVERIFY(m->tagIdList() == tagIdList);
QVERIFY(n.action() == "Action");
QVERIFY(n.transactionId() == "TestTransaction");
QVERIFY(n.value("Key") == "Value");
}