本文整理汇总了C++中MyMoneySecurity::id方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySecurity::id方法的具体用法?C++ MyMoneySecurity::id怎么用?C++ MyMoneySecurity::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneySecurity
的用法示例。
在下文中一共展示了MyMoneySecurity::id方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deepCurrencyPrice
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;
}
示例2: 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);
}
}
示例3: addInvestment
void KEquityPriceUpdateDlg::addInvestment(const MyMoneySecurity& inv)
{
MyMoneyFile* file = MyMoneyFile::instance();
QString symbol = inv.tradingSymbol();
QString id = inv.id();
// Check that the pair does not already exist
if (lvEquityList->findItems(id, Qt::MatchExactly, ID_COL).empty()) {
// check that the security is still in use
QList<MyMoneyAccount>::const_iterator it_a;
QList<MyMoneyAccount> list;
file->accountList(list);
for (it_a = list.constBegin(); it_a != list.constEnd(); ++it_a) {
if ((*it_a).isInvest()
&& ((*it_a).currencyId() == inv.id())
&& !(*it_a).isClosed())
break;
}
// if it is in use, it_a is not equal to list.end()
if (it_a != list.constEnd()) {
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(SYMBOL_COL, symbol);
item->setText(NAME_COL, inv.name());
MyMoneySecurity currency = file->currency(inv.tradingCurrency());
const MyMoneyPrice &pr = file->price(id.toUtf8(), inv.tradingCurrency());
if (pr.isValid()) {
item->setText(PRICE_COL, pr.rate(currency.id()).formatMoney(currency.tradingSymbol(), KMyMoneyGlobalSettings::pricePrecision()));
item->setText(DATE_COL, pr.date().toString(Qt::ISODate));
}
item->setText(ID_COL, id);
if (inv.value("kmm-online-quote-system") == "Finance::Quote")
item->setText(SOURCE_COL, QString("Finance::Quote %1").arg(inv.value("kmm-online-source")));
else
item->setText(SOURCE_COL, inv.value("kmm-online-source"));
lvEquityList->invisibleRootItem()->addChild(item);
// If this investment is denominated in a foreign currency, ensure that
// the appropriate price pair is also on the list
if (currency.id() != file->baseCurrency().id()) {
addPricePair(MyMoneySecurityPair(currency.id(), file->baseCurrency().id()));
}
}
}
}
示例4: makeEquity
QString makeEquity(const QString& _name, const QString& _symbol )
{
MyMoneySecurity equity;
MyMoneyFileTransaction ft;
equity.setName( _name );
equity.setTradingSymbol( _symbol );
equity.setSmallestAccountFraction( 1000 );
equity.setSecurityType( MyMoneySecurity::SECURITY_NONE /*MyMoneyEquity::ETYPE_STOCK*/ );
MyMoneyFile::instance()->addSecurity( equity );
ft.commit();
return equity.id();
}
示例5: 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);
}
}
}
}
}
示例6: if
QList<MyMoneyPrice> KForecastView::getAccountPrices(const MyMoneyAccount& acc)
{
MyMoneyFile* file = MyMoneyFile::instance();
QList<MyMoneyPrice> prices;
MyMoneySecurity security = file->baseCurrency();
try {
if (acc.isInvest()) {
security = file->security(acc.currencyId());
if (security.tradingCurrency() != file->baseCurrency().id()) {
MyMoneySecurity sec = file->security(security.tradingCurrency());
prices += file->price(sec.id(), file->baseCurrency().id());
}
} else if (acc.currencyId() != file->baseCurrency().id()) {
if (acc.currencyId() != file->baseCurrency().id()) {
security = file->security(acc.currencyId());
prices += file->price(acc.currencyId(), file->baseCurrency().id());
}
}
} catch (const MyMoneyException &e) {
qDebug() << Q_FUNC_INFO << " caught exception while adding " << acc.name() << "[" << acc.id() << "]: " << e.what();
}
return prices;
}
示例7: setStartingBalance
void MyMoneyForecast::setStartingBalance(const MyMoneyAccount &acc)
{
MyMoneyFile* file = MyMoneyFile::instance();
//Get current account balance
if ( acc.isInvest() ) { //investments require special treatment
//get the security id of 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 );
//get te
MyMoneyPrice price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), QDate::currentDate() );
if ( price.isValid() )
{
rate = price.rate ( undersecurity.tradingCurrency() );
}
m_accountList[acc.id()][QDate::currentDate()] = file->balance(acc.id(), QDate::currentDate()) * rate;
}
} else {
m_accountList[acc.id()][QDate::currentDate()] = file->balance(acc.id(), QDate::currentDate());
}
//if the method is linear regression, we have to add the opening balance to m_accountListPast
if(forecastMethod() == eHistoric && historyMethod() == 2) {
//FIXME workaround for stock opening dates
QDate openingDate;
if(acc.accountType() == MyMoneyAccount::Stock) {
MyMoneyAccount parentAccount = file->account(acc.parentAccountId());
openingDate = parentAccount.openingDate();
} else {
openingDate = acc.openingDate();
}
//add opening balance only if it opened after the history start
if(openingDate >= historyStartDate()) {
MyMoneyMoney openingBalance;
openingBalance = file->balance(acc.id(), openingDate);
//calculate running sum
for(QDate it_date = openingDate; it_date <= historyEndDate(); it_date = it_date.addDays(1) ) {
//investments require special treatment
if ( acc.isInvest() ) {
//get the security id of 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 );
//get the rate for that specific date
MyMoneyPrice price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), it_date );
if ( price.isValid() )
{
rate = price.rate ( undersecurity.tradingCurrency() );
}
m_accountListPast[acc.id()][it_date] += openingBalance * rate;
}
} else {
m_accountListPast[acc.id()][it_date] += openingBalance;
}
}
}
}
}
示例8: pastTransactions
void MyMoneyForecast::pastTransactions()
{
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneyTransactionFilter filter;
filter.setDateFilter(historyStartDate(), historyEndDate());
filter.setReportAllSplits(false);
QValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
QValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
//Check past transactions
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());
//workaround for stock accounts which have faulty opening dates
QDate openingDate;
if(acc.accountType() == MyMoneyAccount::Stock) {
MyMoneyAccount parentAccount = file->account(acc.parentAccountId());
openingDate = parentAccount.openingDate();
} else {
openingDate = acc.openingDate();
}
if(isForecastAccount(acc) //If it is one of the accounts we are checking, add the amount of the transaction
&& ( (openingDate < (*it_t).postDate() && skipOpeningDate())
|| !skipOpeningDate() ) ){ //don't take the opening day of the account to calculate balance
dailyBalances balance;
//FIXME deal with leap years
balance = m_accountListPast[acc.id()];
if(acc.accountType() == MyMoneyAccount::Income) {//if it is income, the balance is stored as negative number
balance[(*it_t).postDate()] += ((*it_s).shares() * MyMoneyMoney(-1, 1));
} else {
balance[(*it_t).postDate()] += (*it_s).shares();
}
// check if this is a new account for us
m_accountListPast[acc.id()] = balance;
}
}
}
}
//purge those accounts with no transactions on the period
if(isIncludingUnusedAccounts() == false)
purgeForecastAccountsList(m_accountListPast);
//calculate running sum
QMap<QString, QString>::Iterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
m_accountListPast[acc.id()][historyStartDate().addDays(-1)] = file->balance(acc.id(), historyStartDate().addDays(-1));
for(QDate it_date = historyStartDate(); it_date <= historyEndDate(); ) {
m_accountListPast[acc.id()][it_date] += m_accountListPast[acc.id()][it_date.addDays(-1)]; //Running sum
it_date = it_date.addDays(1);
}
}
//adjust value of investments to deep currency
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() );
if ( ! undersecurity.isCurrency() ) //only do it if the security is not an actual currency
{
MyMoneyMoney rate = MyMoneyMoney ( 1, 1 ); //set the default value
MyMoneyPrice price;
for ( QDate it_date = historyStartDate().addDays(-1) ; it_date <= historyEndDate();) {
//get the price for the tradingCurrency that day
price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), it_date );
if ( price.isValid() )
{
rate = price.rate ( undersecurity.tradingCurrency() );
}
//value is the amount of shares multiplied by the rate of the deep currency
m_accountListPast[acc.id() ][it_date] = m_accountListPast[acc.id() ][it_date] * rate;
it_date = it_date.addDays(1);
}
}
}
}
}
示例9: update
void KMyMoneySecuritySelector::update(const QString& id)
{
MyMoneySecurity curr = MyMoneyFile::instance()->baseCurrency();
QString baseCurrency = curr.id();
if(!id.isEmpty())
curr = m_currency;
this->clear();
m_list.clear();
if(m_displayType & TypeCurrencies)
m_list += MyMoneyFile::instance()->currencyList();
if(m_displayType & TypeSecurities)
m_list += MyMoneyFile::instance()->securityList();
// sort
qHeapSort(m_list);
QValueList<MyMoneySecurity>::ConstIterator it;
// construct a transparent 16x16 pixmap
QPixmap empty(16, 16);
empty.setMask(QBitmap(16, 16, true));
int itemId = 0;
int m_selectedItemId = 0;
for(it = m_list.begin(); it != m_list.end(); ++it) {
QString display;
switch(m_displayItem) {
default:
case FullName:
if((*it).isCurrency()) {
display = QString("%2 (%1)").arg((*it).id()).arg((*it).name());
} else
display = QString("%2 (%1)").arg((*it).tradingSymbol()).arg((*it).name());
break;
break;
case Symbol:
if((*it).isCurrency())
display = (*it).id();
else
display = (*it).tradingSymbol();
break;
}
if((*it).id() == baseCurrency) {
insertItem(QPixmap( locate("icon","hicolor/16x16/apps/kmymoney2.png")),
display, itemId);
} else {
insertItem(empty, display, itemId);
}
if(curr.id() == (*it).id()) {
m_selectedItemId = itemId;
m_currency = (*it);
}
itemId++;
}
setCurrentItem(m_selectedItemId);
}
示例10: showTransactions
void KTagsView::showTransactions()
{
MyMoneyMoney balance;
MyMoneyFile *file = MyMoneyFile::instance();
MyMoneySecurity base = file->baseCurrency();
// setup sort order
m_register->setSortOrder(KMyMoneyGlobalSettings::sortSearchView());
// clear the register
m_register->clear();
if (m_tag.id().isEmpty() || !m_tabWidget->isEnabled()) {
m_balanceLabel->setText(i18n("Balance: %1", balance.formatMoney(file->baseCurrency().smallestAccountFraction())));
return;
}
// setup the list and the pointer vector
MyMoneyTransactionFilter filter;
filter.addTag(m_tag.id());
filter.setDateFilter(KMyMoneyGlobalSettings::startDate().date(), QDate());
// retrieve the list from the engine
file->transactionList(m_transactionList, filter);
// create the elements for the register
QList<QPair<MyMoneyTransaction, MyMoneySplit> >::const_iterator it;
QMap<QString, int> uniqueMap;
MyMoneyMoney deposit, payment;
int splitCount = 0;
bool balanceAccurate = true;
for (it = m_transactionList.constBegin(); it != m_transactionList.constEnd(); ++it) {
const MyMoneySplit& split = (*it).second;
MyMoneyAccount acc = file->account(split.accountId());
++splitCount;
uniqueMap[(*it).first.id()]++;
KMyMoneyRegister::Register::transactionFactory(m_register, (*it).first, (*it).second, uniqueMap[(*it).first.id()]);
// take care of foreign currencies
MyMoneyMoney val = split.shares().abs();
if (acc.currencyId() != base.id()) {
const MyMoneyPrice &price = file->price(acc.currencyId(), base.id());
// in case the price is valid, we use it. Otherwise, we keep
// a flag that tells us that the balance is somewhat inaccurate
if (price.isValid()) {
val *= price.rate(base.id());
} else {
balanceAccurate = false;
}
}
if (split.shares().isNegative()) {
payment += val;
} else {
deposit += val;
}
}
balance = deposit - payment;
// add the group markers
m_register->addGroupMarkers();
// sort the transactions according to the sort setting
m_register->sortItems();
// remove trailing and adjacent markers
m_register->removeUnwantedGroupMarkers();
m_register->updateRegister(true);
// we might end up here with updates disabled on the register so
// make sure that we enable updates here
m_register->setUpdatesEnabled(true);
m_balanceLabel->setText(i18n("Balance: %1%2",
balanceAccurate ? "" : "~",
balance.formatMoney(file->baseCurrency().smallestAccountFraction())));
}