本文整理汇总了C++中MyMoneySplit::payeeId方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySplit::payeeId方法的具体用法?C++ MyMoneySplit::payeeId怎么用?C++ MyMoneySplit::payeeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneySplit
的用法示例。
在下文中一共展示了MyMoneySplit::payeeId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeTransactionEntry
void MyMoneyQifWriter::writeTransactionEntry(QTextStream &s, const MyMoneyTransaction& t, const QString& accountId)
{
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneySplit split = t.splitByAccount(accountId);
s << "D" << m_qifProfile.date(t.postDate()) << endl;
switch(split.reconcileFlag()) {
case MyMoneySplit::Cleared:
s << "C*" << endl;
break;
case MyMoneySplit::Reconciled:
case MyMoneySplit::Frozen:
s << "CX" << endl;
break;
default:
break;
}
if(split.memo().length() > 0) {
QString m = split.memo();
m.replace('\n', "\\n");
s << "M" << m << endl;
}
s << "T" << m_qifProfile.value('T', split.value()) << endl;
if(split.number().length() > 0)
s << "N" << split.number() << endl;
if(!split.payeeId().isEmpty()) {
MyMoneyPayee payee = file->payee(split.payeeId());
s << "P" << payee.name() << endl;
}
QValueList<MyMoneySplit> list = t.splits();
if(list.count() > 1) {
MyMoneySplit sp = t.splitByAccount(accountId, false);
MyMoneyAccount acc = file->account(sp.accountId());
if(acc.accountGroup() != MyMoneyAccount::Income
&& acc.accountGroup() != MyMoneyAccount::Expense) {
s << "L" << m_qifProfile.accountDelimiter()[0]
<< MyMoneyFile::instance()->accountToCategory(sp.accountId())
<< m_qifProfile.accountDelimiter()[1] << endl;
} else {
s << "L" << file->accountToCategory(sp.accountId()) << endl;
}
if(list.count() > 2) {
QValueList<MyMoneySplit>::ConstIterator it;
for(it = list.begin(); it != list.end(); ++it) {
if(!((*it) == split)) {
writeSplitEntry(s, *it);
}
}
}
}
s << "^" << endl;
}
示例2: testReadXML
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 &) {
}
}
示例3: testAssignmentConstructor
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");
}
示例4: match
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();
//.........这里部分代码省略.........
示例5: testReplaceId
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");
}
}
示例6: match
//.........这里部分代码省略.........
}
}
#if 0 // Ace's original code
// TODO (Ace) Add in another error to catch the case where a user
// tries to match two hand-entered transactions.
QValueList<MyMoneySplit> endSplits = endMatchTransaction.splits();
QValueList<MyMoneySplit>::const_iterator it_split = endSplits.begin();
while (it_split != endSplits.end())
{
// find the corresponding split in the start transaction
MyMoneySplit startSplit;
QString accountid = (*it_split).accountId();
try
{
startSplit = startMatchTransaction.splitByAccount( accountid );
}
// only exception is thrown if we cannot find a split like this
catch(MyMoneyException *e)
{
delete e;
startSplit = (*it_split);
startSplit.clearId();
startMatchTransaction.addSplit(startSplit);
}
// verify that the amounts are the same, otherwise we should not be
// matching!
if ( (*it_split).value() != startSplit.value() )
{
QString accountname = MyMoneyFile::instance()->account(accountid).name();
throw new MYMONEYEXCEPTION(i18n("Splits for %1 have conflicting values (%2,%3)").arg(accountname).arg((*it_split).value().formatMoney(),startSplit.value().formatMoney()));
}
QString bankID = (*it_split).bankID();
if ( ! bankID.isEmpty() )
{
try
{
if ( startSplit.bankID().isEmpty() )
{
startSplit.setBankID( bankID );
startMatchTransaction.modifySplit(startSplit);
}
else
{
QString accountname = MyMoneyFile::instance()->account(accountid).name();
throw new MYMONEYEXCEPTION(i18n("Both of these transactions have been imported into %1. Therefore they cannot be matched. Matching works with one imported transaction and one non-imported transaction.").arg(accountname));
}
}
catch(MyMoneyException *e)
{
QString estr = e->what();
delete e;
throw new MYMONEYEXCEPTION(i18n("Unable to match all splits (%1)").arg(estr));
}
}
++it_split;
}
#endif
// 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();
}
sm.setMemo(memo);
// remember the split we matched
sm.setValue("kmm-match-split", si.id());
sm.addMatch(ti);
tm.modifySplit(sm);
MyMoneyFile::instance()->modifyTransaction(tm);
// Delete the end transaction if it was stored in the engine
if(!ti.id().isEmpty())
MyMoneyFile::instance()->removeTransaction(ti);
}