本文整理汇总了C++中MyMoneySecurity::isCurrency方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySecurity::isCurrency方法的具体用法?C++ MyMoneySecurity::isCurrency怎么用?C++ MyMoneySecurity::isCurrency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneySecurity
的用法示例。
在下文中一共展示了MyMoneySecurity::isCurrency方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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);
}
}
}
}
}
示例4: foreignCurrencyPrice
MyMoneyMoney ReportAccount::foreignCurrencyPrice(const QString foreignCurrency, const QDate& date, bool exactDate) const
{
DEBUG_ENTER(Q_FUNC_INFO);
MyMoneyMoney result(1, 1);
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneySecurity security = file->security(foreignCurrency);
//check whether it is a currency or a commodity. In the latter case case, get the trading currency
QString tradingCurrency;
if (security.isCurrency()) {
tradingCurrency = foreignCurrency;
} else {
tradingCurrency = security.tradingCurrency();
}
//It makes no sense to get the price if both currencies are the same
if (currency().id() != tradingCurrency) {
const MyMoneyPrice &price = file->price(currency().id(), tradingCurrency, date, exactDate);
if (price.isValid()) {
result = price.rate(tradingCurrency);
DEBUG_OUTPUT(QString("Converting deep %1 to currency %2, price on %3 is %4")
.arg(file->currency(currency().id()).name())
.arg(file->currency(foreignCurrency).name())
.arg(date.toString())
.arg(result.toDouble()));
} else {
DEBUG_OUTPUT(QString("No price to convert deep %1 to currency %2 on %3")
.arg(file->currency(currency().id()).name())
.arg(file->currency(foreignCurrency).name())
.arg(date.toString()));
}
}
return result;
}
示例5: 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;
}
}
}
}
}
示例6: 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);
}
}
}
}
}
示例7: writeStream
//.........这里部分代码省略.........
s << "Currencies" << "\n";
s << "----------" << "\n";
QList<MyMoneyCurrency> list_c = storage->currencyList();
QList<MyMoneyCurrency>::ConstIterator it_c;
for (it_c = list_c.begin(); it_c != list_c.end(); ++it_c) {
s << " Name = " << (*it_c).name() << "\n";
s << " ID = " << (*it_c).id() << "\n";
s << " Symbol = " << (*it_c).tradingSymbol() << "\n";
s << " Parts/Unit = " << (*it_c).partsPerUnit() << "\n";
s << " smallest cash fraction = " << (*it_c).smallestCashFraction() << "\n";
s << " smallest account fraction = " << (*it_c).smallestAccountFraction() << "\n";
dumpPriceHistory(s, (*it_c).priceHistory());
s << "\n";
}
s << "\n";
#endif
s << "Securities" << "\n";
s << "----------" << "\n";
QList<MyMoneySecurity> list_e = storage->securityList();
QList<MyMoneySecurity>::ConstIterator it_e;
for (it_e = list_e.constBegin(); it_e != list_e.constEnd(); ++it_e) {
s << " Name = " << (*it_e).name() << "\n";
s << " ID = " << (*it_e).id() << "\n";
s << " Market = " << (*it_e).tradingMarket() << "\n";
s << " Symbol = " << (*it_e).tradingSymbol() << "\n";
s << " Currency = " << (*it_e).tradingCurrency() << " (";
if ((*it_e).tradingCurrency().isEmpty()) {
s << "unknown";
} else {
MyMoneySecurity tradingCurrency = storage->currency((*it_e).tradingCurrency());
if (!tradingCurrency.isCurrency()) {
s << "invalid currency: ";
}
s << tradingCurrency.name();
}
s << ")\n";
s << " Type = " << MyMoneySecurity::securityTypeToString((*it_e).securityType()) << "\n";
s << " smallest account fraction = " << (*it_e).smallestAccountFraction() << "\n";
s << " KVP: " << "\n";
QMap<QString, QString>kvp = (*it_e).pairs();
QMap<QString, QString>::Iterator it;
for (it = kvp.begin(); it != kvp.end(); ++it) {
s << " '" << it.key() << "' = '" << it.value() << "'\n";
}
s << "\n";
}
s << "\n";
s << "Prices" << "\n";
s << "--------" << "\n";
MyMoneyPriceList list_pr = _storage->priceList();
MyMoneyPriceList::ConstIterator it_pr;
for (it_pr = list_pr.constBegin(); it_pr != list_pr.constEnd(); ++it_pr) {
s << " From = " << it_pr.key().first << "\n";
s << " To = " << it_pr.key().second << "\n";
MyMoneyPriceEntries::ConstIterator it_pre;
for (it_pre = (*it_pr).constBegin(); it_pre != (*it_pr).constEnd(); ++it_pre) {
s << " Date = " << (*it_pre).date().toString() << "\n";
s << " Price = " << (*it_pre).rate(QString()).formatMoney("", 8) << "\n";
s << " Source = " << (*it_pre).source() << "\n";