本文整理汇总了C++中MyMoneyFile::account方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneyFile::account方法的具体用法?C++ MyMoneyFile::account怎么用?C++ MyMoneyFile::account使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneyFile
的用法示例。
在下文中一共展示了MyMoneyFile::account方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showSubAccounts
void KNewAccountDlg::showSubAccounts(QStringList accounts, KMyMoneyAccountTreeBaseItem *parentItem,
const QString& parentId, const QString& accountId)
{
MyMoneyFile *file = MyMoneyFile::instance();
for ( QStringList::ConstIterator it = accounts.begin(); it != accounts.end(); ++it )
{
KMyMoneyAccountTreeBaseItem *accountItem = new KMyMoneyAccountTreeItem(parentItem,
file->account(*it));
QString id = file->account(*it).id();
if(parentId == id) {
m_parentItem = accountItem;
} else if(accountId == id) {
if(m_isEditing)
accountItem->setSelectable(false);
m_accountItem = accountItem;
}
QStringList subAccounts = file->account(*it).accountList();
if (subAccounts.count() >= 1)
{
showSubAccounts(subAccounts, accountItem, parentId, accountId);
}
}
}
示例2: calculateAccountHierarchy
void ReportAccount::calculateAccountHierarchy()
{
DEBUG_ENTER(Q_FUNC_INFO);
MyMoneyFile* file = MyMoneyFile::instance();
QString resultid = id();
QString parentid = parentAccountId();
#ifdef DEBUG_HIDE_SENSITIVE
m_nameHierarchy.prepend(file->account(resultid).id());
#else
m_nameHierarchy.prepend(file->account(resultid).name());
#endif
while (!parentid.isEmpty() && !file->isStandardAccount(parentid)) {
// take on the identity of our parent
resultid = parentid;
// and try again
parentid = file->account(resultid).parentAccountId();
#ifdef DEBUG_HIDE_SENSITIVE
m_nameHierarchy.prepend(file->account(resultid).id());
#else
m_nameHierarchy.prepend(file->account(resultid).name());
#endif
}
}
示例3: loadAccounts
void KForecastView::loadAccounts(MyMoneyForecast& forecast, const MyMoneyAccount& account, QTreeWidgetItem* parentItem, int forecastType)
{
QMap<QString, QString> nameIdx;
QStringList accList;
MyMoneyFile* file = MyMoneyFile::instance();
QTreeWidgetItem *forecastItem = 0;
//Get all accounts of the right type to calculate forecast
accList = account.accountList();
if (accList.size() == 0)
return;
QStringList::ConstIterator accList_t;
for (accList_t = accList.constBegin(); accList_t != accList.constEnd(); ++accList_t) {
MyMoneyAccount subAccount = file->account(*accList_t);
//only add the account if it is a forecast account or the parent of a forecast account
if (includeAccount(forecast, subAccount)) {
nameIdx[subAccount.id()] = subAccount.id();
}
}
QMap<QString, QString>::ConstIterator it_nc;
for (it_nc = nameIdx.constBegin(); it_nc != nameIdx.constEnd(); ++it_nc) {
const MyMoneyAccount subAccount = file->account(*it_nc);
MyMoneySecurity currency;
if (subAccount.isInvest()) {
MyMoneySecurity underSecurity = file->security(subAccount.currencyId());
currency = file->security(underSecurity.tradingCurrency());
} else {
currency = file->security(subAccount.currencyId());
}
forecastItem = new QTreeWidgetItem(parentItem);
forecastItem->setText(0, subAccount.name());
forecastItem->setIcon(0, subAccount.accountPixmap());
forecastItem->setData(0, ForecastRole, QVariant::fromValue(forecast));
forecastItem->setData(0, AccountRole, QVariant::fromValue(subAccount));
forecastItem->setExpanded(true);
switch (forecastType) {
case eSummary:
updateSummary(forecastItem);
break;
case eDetailed:
updateDetailed(forecastItem);
break;
case eBudget:
updateBudget(forecastItem);
break;
default:
break;
}
loadAccounts(forecast, subAccount, forecastItem, forecastType);
}
}
示例4: addFutureTransactions
void MyMoneyForecast::addFutureTransactions(void)
{
MyMoneyTransactionFilter filter;
MyMoneyFile* file = MyMoneyFile::instance();
// collect and process all transactions that have already been entered but
// are located in the future.
filter.setDateFilter(forecastStartDate(), forecastEndDate());
filter.setReportAllSplits(false);
QValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
QValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
for(; it_t != transactions.end(); ++it_t ) {
const QValueList<MyMoneySplit>& splits = (*it_t).splits();
QValueList<MyMoneySplit>::const_iterator it_s = splits.begin();
for(; it_s != splits.end(); ++it_s ) {
if(!(*it_s).shares().isZero()) {
MyMoneyAccount acc = file->account((*it_s).accountId());
if(isForecastAccount(acc)) {
dailyBalances balance;
balance = m_accountList[acc.id()];
//if it is income, the balance is stored as negative number
if(acc.accountType() == MyMoneyAccount::Income) {
balance[(*it_t).postDate()] += ((*it_s).shares() * MyMoneyMoney(-1, 1));
} else {
balance[(*it_t).postDate()] += (*it_s).shares();
}
m_accountList[acc.id()] = balance;
}
}
}
}
#if 0
QFile trcFile("forecast.csv");
trcFile.open(IO_WriteOnly);
QTextStream s(&trcFile);
{
s << "Already present transactions\n";
QMap<QString, dailyBalances>::Iterator it_a;
QMap<QString, QString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
it_a = m_accountList.find(*it_n);
s << "\"" << acc.name() << "\",";
for(int i = 0; i < 90; ++i) {
s << "\"" << (*it_a)[i].formatMoney("") << "\",";
}
s << "\n";
}
}
#endif
}
示例5: addCategories
void KImportDlg::addCategories(QStringList& strList, const QString& id, const QString& leadIn) const
{
MyMoneyFile *file = MyMoneyFile::instance();
QString name;
MyMoneyAccount account = file->account(id);
QStringList accList = account.accountList();
QStringList::ConstIterator it_a;
for (it_a = accList.constBegin(); it_a != accList.constEnd(); ++it_a) {
account = file->account(*it_a);
strList << leadIn + account.name();
addCategories(strList, *it_a, leadIn + account.name() + MyMoneyFile::AccountSeperator);
}
}
示例6: previouslyUsedCategories
void CsvUtil::previouslyUsedCategories(const QString& investmentAccount, QString& feesId, QString& interestId)
{
feesId.clear();
interestId.clear();
MyMoneyFile* file = MyMoneyFile::instance();
try {
MyMoneyAccount acc = file->account(investmentAccount);
MyMoneyTransactionFilter filter(investmentAccount);
filter.setReportAllSplits(false);
// since we assume an investment account here, we need to collect the stock accounts as well
filter.addAccount(acc.accountList());
QList< QPair<MyMoneyTransaction, MyMoneySplit> > list;
file->transactionList(list, filter);
QList< QPair<MyMoneyTransaction, MyMoneySplit> >::const_iterator it_t;
for (it_t = list.constBegin(); it_t != list.constEnd(); ++it_t) {
const MyMoneyTransaction& t = (*it_t).first;
const MyMoneySplit&s = (*it_t).second;
MyMoneySplit assetAccountSplit;
QList<MyMoneySplit> feeSplits;
QList<MyMoneySplit> interestSplits;
MyMoneySecurity security;
MyMoneySecurity currency;
MyMoneySplit::investTransactionTypeE transactionType;
dissectTransaction(t, s, assetAccountSplit, feeSplits, interestSplits, security, currency, transactionType);
if (feeSplits.count() == 1) {
feesId = feeSplits.first().accountId();
}
if (interestSplits.count() == 1) {
interestId = interestSplits.first().accountId();
}
}
} catch (const MyMoneyException &) {
}
}
示例7: 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;
}
示例8: setPostDate
TransactionHelper::TransactionHelper( const QDate& _date, const QString& _action, MyMoneyMoney _value, const QString& _accountid, const QString& _categoryid, const QString& _currencyid, const QString& _payee )
{
// _currencyid is the currency of the transaction, and of the _value
// both the account and category can have their own currency (athough the category having
// a foreign currency is not yet supported by the program, the reports will still allow it,
// so it must be tested.)
MyMoneyFile* file = MyMoneyFile::instance();
bool haspayee = ! _payee.isEmpty();
MyMoneyPayee payeeTest = file->payeeByName(_payee);
MyMoneyFileTransaction ft;
setPostDate(_date);
QString currencyid = _currencyid;
if ( currencyid.isEmpty() )
currencyid=MyMoneyFile::instance()->baseCurrency().id();
setCommodity(currencyid);
MyMoneyMoney price;
MyMoneySplit splitLeft;
if ( haspayee )
splitLeft.setPayeeId(payeeTest.id());
splitLeft.setAction(_action);
splitLeft.setValue(-_value);
price = MyMoneyFile::instance()->price(currencyid, file->account(_accountid).currencyId(),_date).rate(file->account(_accountid).currencyId());
splitLeft.setShares(-_value * price);
splitLeft.setAccountId(_accountid);
addSplit(splitLeft);
MyMoneySplit splitRight;
if ( haspayee )
splitRight.setPayeeId(payeeTest.id());
splitRight.setAction(_action);
splitRight.setValue(_value);
price = MyMoneyFile::instance()->price(currencyid, file->account(_categoryid).currencyId(),_date).rate(file->account(_categoryid).currencyId());
splitRight.setShares(_value * price );
splitRight.setAccountId(_categoryid);
addSplit(splitRight);
MyMoneyFile::instance()->addTransaction(*this);
ft.commit();
}
示例9: calculateHistoricDailyBalances
void MyMoneyForecast::calculateHistoricDailyBalances()
{
MyMoneyFile* file = MyMoneyFile::instance();
calculateAccountTrendList();
//Calculate account daily balances
QMap<QString, QString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
//set the starting balance of the account
setStartingBalance(acc);
switch(historyMethod()) {
case 0:
case 1:
{
for(QDate f_day = forecastStartDate(); f_day <= forecastEndDate(); ) {
for(int t_day = 1; t_day <= accountsCycle(); ++t_day) {
MyMoneyMoney balanceDayBefore = m_accountList[acc.id()][(f_day.addDays(-1))];//balance of the day before
MyMoneyMoney accountDailyTrend = m_accountTrendList[acc.id()][t_day]; //trend for that day
//balance of the day is the balance of the day before multiplied by the trend for the day
m_accountList[acc.id()][f_day] = balanceDayBefore;
m_accountList[acc.id()][f_day] += accountDailyTrend; //movement trend for that particular day
m_accountList[acc.id()][f_day] = m_accountList[acc.id()][f_day].convert(acc.fraction());
//m_accountList[acc.id()][f_day] += m_accountListPast[acc.id()][f_day.addDays(-historyDays())];
f_day = f_day.addDays(1);
}
}
}
break;
case 2:
{
QDate baseDate = QDate::currentDate().addDays(-accountsCycle());
for(int t_day = 1; t_day <= accountsCycle(); ++t_day) {
int f_day = 1;
QDate fDate = baseDate.addDays(accountsCycle()+1);
while (fDate <= forecastEndDate()) {
//the calculation is based on the balance for the last month, that is then multiplied by the trend
m_accountList[acc.id()][fDate] = m_accountListPast[acc.id()][baseDate] + (m_accountTrendList[acc.id()][t_day] * MyMoneyMoney(f_day,1));
m_accountList[acc.id()][fDate] = m_accountList[acc.id()][fDate].convert(acc.fraction());
++f_day;
fDate = baseDate.addDays(accountsCycle() * f_day);
}
baseDate = baseDate.addDays(1);
}
}
}
}
}
示例10: writeAccountEntry
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);
}
}
示例11: doFutureScheduledForecast
void MyMoneyForecast::doFutureScheduledForecast(void)
{
MyMoneyFile* file = MyMoneyFile::instance();
if(isIncludingFutureTransactions())
addFutureTransactions();
if(isIncludingScheduledTransactions())
addScheduledTransactions();
//do not show accounts with no transactions
if(!isIncludingUnusedAccounts())
purgeForecastAccountsList(m_accountList);
//adjust value of investments to deep currency
QMap<QString, QString>::ConstIterator it_n;
for ( it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n ) {
MyMoneyAccount acc = file->account ( *it_n );
if ( acc.isInvest() ) {
//get the id of the security for that account
MyMoneySecurity undersecurity = file->security ( acc.currencyId() );
//only do it if the security is not an actual currency
if ( ! undersecurity.isCurrency() )
{
//set the default value
MyMoneyMoney rate = MyMoneyMoney ( 1, 1 );
MyMoneyPrice price;
for (QDate it_day = QDate::currentDate(); it_day <= forecastEndDate(); ) {
//get the price for the tradingCurrency that day
price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), it_day );
if ( price.isValid() )
{
rate = price.rate ( undersecurity.tradingCurrency() );
}
//value is the amount of shares multiplied by the rate of the deep currency
m_accountList[acc.id() ][it_day] = m_accountList[acc.id() ][it_day] * rate;
it_day = it_day.addDays(1);
}
}
}
}
}
示例12: dissectTransaction
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 &) {
}
}
示例13: topParent
ReportAccount ReportAccount::topParent() const
{
DEBUG_ENTER(Q_FUNC_INFO);
MyMoneyFile* file = MyMoneyFile::instance();
QString resultid = id();
QString parentid = parentAccountId();
while (!parentid.isEmpty() && !file->isStandardAccount(parentid)) {
// take on the identity of our parent
resultid = parentid;
// and try again
parentid = file->account(resultid).parentAccountId();
}
return ReportAccount(resultid);
}
示例14: includeAccount
bool KForecastView::includeAccount(MyMoneyForecast& forecast, const MyMoneyAccount& acc)
{
MyMoneyFile* file = MyMoneyFile::instance();
if (forecast.isForecastAccount(acc))
return true;
QStringList accounts = acc.accountList();
if (accounts.size() > 0) {
QStringList::ConstIterator it_acc;
for (it_acc = accounts.constBegin(); it_acc != accounts.constEnd(); ++it_acc) {
MyMoneyAccount account = file->account(*it_acc);
if (includeAccount(forecast, account))
return true;
}
}
return false;
}
示例15: slotSelectionChanged
void KNewAccountDlg::slotSelectionChanged(QListViewItem *item)
{
KMyMoneyAccountTreeBaseItem *accountItem = dynamic_cast<KMyMoneyAccountTreeBaseItem*>(item);
try
{
MyMoneyFile *file = MyMoneyFile::instance();
//qDebug("Selected account id: %s", accountItem->accountID().data());
m_parentAccount = file->account(accountItem->id());
m_subAccountLabel->setText(i18n("Is a sub account of %1").arg(m_parentAccount.name()));
if(m_qlistviewParentAccounts->isEnabled()) {
m_bSelectedParentAccount = true;
}
}
catch (MyMoneyException *e)
{
qDebug("This shouldn't happen! : %s", e->what().latin1());
delete e;
}
}