当前位置: 首页>>代码示例>>C++>>正文


C++ MyMoneyFile类代码示例

本文整理汇总了C++中MyMoneyFile的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneyFile类的具体用法?C++ MyMoneyFile怎么用?C++ MyMoneyFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MyMoneyFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DEBUG_ENTER

MyMoneyMoney ReportAccount::deepCurrencyPrice(const QDate& date, bool exactDate) const
{
  DEBUG_ENTER(Q_FUNC_INFO);

  MyMoneyMoney result(1, 1);
  MyMoneyFile* file = MyMoneyFile::instance();

  MyMoneySecurity undersecurity = file->security(currencyId());
  if (! undersecurity.isCurrency()) {
    const MyMoneyPrice &price = file->price(undersecurity.id(), undersecurity.tradingCurrency(), date, exactDate);
    if (price.isValid()) {
      result = price.rate(undersecurity.tradingCurrency());

      DEBUG_OUTPUT(QString("Converting under %1 to deep %2, price on %3 is %4")
                   .arg(undersecurity.name())
                   .arg(file->security(undersecurity.tradingCurrency()).name())
                   .arg(date.toString())
                   .arg(result.toDouble()));
    } else {
      DEBUG_OUTPUT(QString("No price to convert under %1 to deep %2 on %3")
                   .arg(undersecurity.name())
                   .arg(file->security(undersecurity.tradingCurrency()).name())
                   .arg(date.toString()));
      result = MyMoneyMoney();
    }
  }

  return result;
}
开发者ID:KDE,项目名称:kmymoney,代码行数:29,代码来源:reportaccount.cpp

示例2: 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);
    }
  }
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:26,代码来源:knewaccountdlg.cpp

示例3: updateLastNumberUsed

void KMyMoneyUtils::updateLastNumberUsed(const MyMoneyAccount& acc, const QString& number)
{
  MyMoneyAccount accnt = acc;
  QString num = number;
  // now check if this number has been used already
  MyMoneyFile* file = MyMoneyFile::instance();
  if (file->checkNoUsed(accnt.id(), num)) {
    // if a number has been entered which is immediately prior to
    // an existing number, the next new number produced would clash
    // so need to look ahead for free next number
    bool free = false;
    for (int i = 0; i < 10; i++) {
      // find next unused number - 10 tries (arbitrary)
      if (file->checkNoUsed(accnt.id(), num)) {
        //  increment and try again
        num = getAdjacentNumber(num);
      } else {
        //  found a free number
        free = true;
        break;
      }
    }
    if (!free) {
      qDebug() << "No free number found - set to '1'";
      num = '1';
    }
    setLastNumberUsed(getAdjacentNumber(num, - 1));
  }
}
开发者ID:KDE,项目名称:kmymoney,代码行数:29,代码来源:kmymoneyutils.cpp

示例4: updateBudget

void KMyMoneyAccountTreeForecastItem::updateBudget()
{
  MyMoneySecurity currency;
  MyMoneyMoney tAmountMM;

  MyMoneyFile* file = MyMoneyFile::instance();
  int it_c = 1; // iterator for the columns of the listview
  QDate forecastDate = m_forecast.forecastStartDate();

  if(m_account.isInvest()) {
    MyMoneySecurity underSecurity = file->security(m_account.currencyId());
    currency = file->security(underSecurity.tradingCurrency());
  } else {
    currency = file->security(m_account.currencyId());
  }

    //iterate columns
  for(; forecastDate <= m_forecast.forecastEndDate(); forecastDate = forecastDate.addMonths(1), ++it_c) {
    MyMoneyMoney amountMM;
    amountMM = m_forecast.forecastBalance(m_account,forecastDate);
    if(m_account.accountType() == MyMoneyAccount::Expense)
      amountMM = -amountMM;

    tAmountMM += amountMM;
    setAmount(it_c, amountMM);
    setValue(it_c, amountMM, forecastDate);
    showAmount(it_c, amountMM, currency);
  }

  //set total column
  setAmount(it_c, tAmountMM);
  setValue(it_c, tAmountMM, m_forecast.forecastEndDate());
  showAmount(it_c, tAmountMM, currency);
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:34,代码来源:kmymoneyaccounttreeforecast.cpp

示例5: updateDetailed

void KMyMoneyAccountTreeForecastItem::updateDetailed()
{
  QString amount;
  QString vAmount;
  MyMoneyMoney vAmountMM;
  MyMoneyFile* file = MyMoneyFile::instance();

  MyMoneySecurity currency;
  if(m_account.isInvest()) {
    MyMoneySecurity underSecurity = file->security(m_account.currencyId());
    currency = file->security(underSecurity.tradingCurrency());
  } else {
    currency = file->security(m_account.currencyId());
  }

  int it_c = 1; // iterator for the columns of the listview

  for(QDate forecastDate = QDate::currentDate(); forecastDate <= m_forecast.forecastEndDate(); ++it_c, forecastDate = forecastDate.addDays(1)) {
    MyMoneyMoney amountMM = m_forecast.forecastBalance(m_account, forecastDate);

    //calculate the balance in base currency for the total row
    setAmount(it_c, amountMM);
    setValue(it_c, amountMM, forecastDate);
    showAmount(it_c, amountMM, currency);
  }

    //calculate and add variation per cycle
  vAmountMM = m_forecast.accountTotalVariation(m_account);
  setAmount(it_c, vAmountMM);
  setValue(it_c, vAmountMM, m_forecast.forecastEndDate());
  showAmount(it_c, vAmountMM, currency);
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:32,代码来源:kmymoneyaccounttreeforecast.cpp

示例6: switch

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;
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:60,代码来源:mymoneyqifwriter.cpp

示例7: 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 &) {
  }
}
开发者ID:CGenie,项目名称:kmymoney,代码行数:34,代码来源:csvutil.cpp

示例8: loadSubAccounts

void KInstitutionsView::loadSubAccounts(KMyMoneyAccountTreeItem* parent)
{
  bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked()
      || !KMyMoneyGlobalSettings::hideClosedAccounts();
  const MyMoneyAccount& account = dynamic_cast<const MyMoneyAccount&>(parent->itemObject());
  QValueList<QString>::const_iterator it_a;
  MyMoneyFile* file = MyMoneyFile::instance();
  for(it_a = account.accountList().begin(); it_a != account.accountList().end(); ++it_a) {
    MyMoneyAccount acc = m_accountMap[(*it_a)];
    if(!acc.isInvest())
      continue;
    if(acc.isClosed() && !showClosedAccounts)
      continue;
    const MyMoneySecurity& security = m_securityMap[acc.currencyId()];
    QValueList<MyMoneyPrice> prices;
    prices += file->price(acc.currencyId(), security.tradingCurrency());
    if(security.tradingCurrency() != file->baseCurrency().id()) {
      MyMoneySecurity sec = m_securityMap[security.tradingCurrency()];
      prices += file->price(sec.id(), file->baseCurrency().id());
    }
    KMyMoneyAccountTreeItem* item = new KMyMoneyAccountTreeItem(parent, acc, prices, security);
    if(acc.id() == m_reconciliationAccount.id())
      item->setReconciliation(true);
  }
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:25,代码来源:kinstitutionsview.cpp

示例9: makePrice

void makePrice(const QString& _currencyid, const QDate& _date, const MyMoneyMoney& _price )
{
  MyMoneyFileTransaction ft;
  MyMoneyFile* file = MyMoneyFile::instance();
  MyMoneySecurity curr = file->currency(_currencyid);
  MyMoneyPrice price(_currencyid, file->baseCurrency().id(), _date, _price, "test");
  file->addPrice(price);
  ft.commit();
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:9,代码来源:reportstestcommon.cpp

示例10: calculateAccountTrend

MyMoneyMoney MyMoneyForecast::calculateAccountTrend(const MyMoneyAccount& acc, int trendDays)
{
  MyMoneyFile* file = MyMoneyFile::instance();
  MyMoneyTransactionFilter filter;
  MyMoneyMoney netIncome;
  QDate startDate;
  QDate openingDate = acc.openingDate();

  //validate arguments
  if(trendDays < 1)
  {
    throw new MYMONEYEXCEPTION("Illegal arguments when calling calculateAccountTrend. trendDays must be higher than 0");
  }

  //If it is a new account, we don't take into account the first day
  //because it is usually a weird one and it would mess up the trend
  if(openingDate.daysTo(QDate::currentDate())<trendDays){
    startDate = (acc.openingDate()).addDays(1);
  }
  else {
    startDate = QDate::currentDate().addDays(-trendDays);
  }
  //get all transactions for the period
  filter.setDateFilter(startDate, QDate::currentDate());
  if(acc.accountGroup() == MyMoneyAccount::Income
     || acc.accountGroup() == MyMoneyAccount::Expense) {
    filter.addCategory(acc.id());
     } else {
       filter.addAccount(acc.id());
     }

  filter.setReportAllSplits(false);
  QValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
  QValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();

  //add all transactions for that account
  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()) {
        if(acc.id()==(*it_s).accountId()) netIncome += (*it_s).value();
      }
    }
  }

  //calculate trend of the account in the past period
  MyMoneyMoney accTrend;

  //don't take into account the first day of the account
  if(openingDate.daysTo(QDate::currentDate())<trendDays) {
    accTrend = netIncome/MyMoneyMoney(openingDate.daysTo(QDate::currentDate())-1,1);
  } else {
    accTrend = netIncome/MyMoneyMoney(trendDays,1);
  }
  return accTrend;
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:57,代码来源:mymoneyforecast.cpp

示例11: 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

}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:56,代码来源:mymoneyforecast.cpp

示例12: currency

/**
  * Fetch the trading currency of this account's currency
  *
  * @return The account's currency trading currency
  */
MyMoneySecurity ReportAccount::currency() const
{
  MyMoneyFile* file = MyMoneyFile::instance();

  // First, get the deep currency
  MyMoneySecurity deepcurrency = file->security(currencyId());
  if (! deepcurrency.isCurrency())
    deepcurrency = file->security(deepcurrency.tradingCurrency());

  // Return the deep currency's ID
  return deepcurrency;
}
开发者ID:KDE,项目名称:kmymoney,代码行数:17,代码来源:reportaccount.cpp

示例13: 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);
        }
      }
    }
  }
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:52,代码来源:mymoneyforecast.cpp

示例14: makeEquityPrice

void makeEquityPrice(const QString& _id, const QDate& _date, const MyMoneyMoney& _price )
{
  MyMoneyFile* file = MyMoneyFile::instance();
  MyMoneyFileTransaction ft;
  QString basecurrencyid = file->baseCurrency().id();
  MyMoneyPrice price = file->price( _id, basecurrencyid, _date, true );
  if ( !price.isValid() )
  {
    MyMoneyPrice newprice( _id, basecurrencyid, _date, _price, "test" );
    file->addPrice(newprice);
  }
  ft.commit();
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:13,代码来源:reportstestcommon.cpp

示例15: updateSummary

void KForecastView::updateSummary(QTreeWidgetItem *item)
{
  MyMoneyMoney amountMM;
  int it_c = 1; // iterator for the columns of the listview
  MyMoneyFile* file = MyMoneyFile::instance();
  int daysToBeginDay;

  MyMoneyForecast forecast = item->data(0, ForecastRole).value<MyMoneyForecast>();

  if (QDate::currentDate() < forecast.beginForecastDate()) {
    daysToBeginDay = QDate::currentDate().daysTo(forecast.beginForecastDate());
  } else {
    daysToBeginDay = forecast.accountsCycle();
  }

  MyMoneyAccount account = item->data(0, AccountRole).value<MyMoneyAccount>();
  MyMoneySecurity currency;
  if (account.isInvest()) {
    MyMoneySecurity underSecurity = file->security(account.currencyId());
    currency = file->security(underSecurity.tradingCurrency());
  } else {
    currency = file->security(account.currencyId());
  }


  //add current balance column
  QDate summaryDate = QDate::currentDate();
  amountMM = forecast.forecastBalance(account, summaryDate);

  //calculate the balance in base currency for the total row
  setAmount(item, it_c, amountMM);
  setValue(item, it_c, amountMM, summaryDate);
  showAmount(item, it_c, amountMM, currency);
  it_c++;

  //iterate through all other columns
  for (QDate summaryDate = QDate::currentDate().addDays(daysToBeginDay); summaryDate <= forecast.forecastEndDate(); summaryDate = summaryDate.addDays(forecast.accountsCycle()), ++it_c) {
    amountMM = forecast.forecastBalance(account, summaryDate);

    //calculate the balance in base currency for the total row
    setAmount(item, it_c, amountMM);
    setValue(item, it_c, amountMM, summaryDate);
    showAmount(item, it_c, amountMM, currency);
  }
  //calculate and add variation per cycle
  setNegative(item, forecast.accountTotalVariation(account).isNegative());
  setAmount(item, it_c, forecast.accountTotalVariation(account));
  setValue(item, it_c, forecast.accountTotalVariation(account), forecast.forecastEndDate());
  showAmount(item, it_c, forecast.accountTotalVariation(account), currency);
}
开发者ID:KDE,项目名称:kmymoney,代码行数:50,代码来源:kforecastview.cpp


注:本文中的MyMoneyFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。