本文整理汇总了C++中MyMoneySplit::accountId方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySplit::accountId方法的具体用法?C++ MyMoneySplit::accountId怎么用?C++ MyMoneySplit::accountId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneySplit
的用法示例。
在下文中一共展示了MyMoneySplit::accountId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例4: checkTransaction
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;
}
}
}
}
}
示例5: 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");
}
示例6: calculateAutoLoan
void MyMoneyForecast::calculateAutoLoan(const MyMoneySchedule& schedule, MyMoneyTransaction& transaction, const QMap<QString, MyMoneyMoney>& balances)
{
if (schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) {
//get amortization and interest autoCalc splits
MyMoneySplit amortizationSplit = transaction.amortizationSplit();
MyMoneySplit interestSplit = transaction.interestSplit();
if(!amortizationSplit.id().isEmpty() && !interestSplit.id().isEmpty()) {
MyMoneyAccountLoan acc(MyMoneyFile::instance()->account(amortizationSplit.accountId()));
MyMoneyFinancialCalculator calc;
QDate dueDate;
// FIXME: setup dueDate according to when the interest should be calculated
// current implementation: take the date of the next payment according to
// the schedule. If the calculation is based on the payment reception, and
// the payment is overdue then take the current date
dueDate = schedule.nextDueDate();
if(acc.interestCalculation() == MyMoneyAccountLoan::paymentReceived) {
if(dueDate < QDate::currentDate())
dueDate = QDate::currentDate();
}
// we need to calculate the balance at the time the payment is due
MyMoneyMoney balance;
if(balances.count() == 0)
balance = MyMoneyFile::instance()->balance(acc.id(), dueDate.addDays(-1));
else
balance = balances[acc.id()];
/*
QValueList<MyMoneyTransaction> list;
QValueList<MyMoneyTransaction>::ConstIterator it;
MyMoneySplit split;
MyMoneyTransactionFilter filter(acc.id());
filter.setDateFilter(QDate(), dueDate.addDays(-1));
list = MyMoneyFile::instance()->transactionList(filter);
for(it = list.begin(); it != list.end(); ++it) {
try {
split = (*it).splitByAccount(acc.id());
balance += split.value();
} catch(MyMoneyException *e) {
// account is not referenced within this transaction
delete e;
}
}
*/
// FIXME: for now, we only support interest calculation at the end of the period
calc.setBep();
// FIXME: for now, we only support periodic compounding
calc.setDisc();
calc.setPF(MyMoneySchedule::eventsPerYear(schedule.occurence()));
MyMoneySchedule::occurenceE compoundingOccurence = static_cast<MyMoneySchedule::occurenceE>(acc.interestCompounding());
if(compoundingOccurence == MyMoneySchedule::OCCUR_ANY)
compoundingOccurence = schedule.occurence();
calc.setCF(MyMoneySchedule::eventsPerYear(compoundingOccurence));
calc.setPv(balance.toDouble());
calc.setIr(static_cast<FCALC_DOUBLE> (acc.interestRate(dueDate).abs().toDouble()));
calc.setPmt(acc.periodicPayment().toDouble());
MyMoneyMoney interest(calc.interestDue()), amortization;
interest = interest.abs(); // make sure it's positive for now
amortization = acc.periodicPayment() - interest;
if(acc.accountType() == MyMoneyAccount::AssetLoan) {
interest = -interest;
amortization = -amortization;
}
amortizationSplit.setShares(amortization);
interestSplit.setShares(interest);
// FIXME: for now we only assume loans to be in the currency of the transaction
amortizationSplit.setValue(amortization);
interestSplit.setValue(interest);
transaction.modifySplit(amortizationSplit);
transaction.modifySplit(interestSplit);
}
}
}
示例7: 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");
}
}