void mmMainCurrencyDialog::ShowCurrencyHistory() { valueListBox_->DeleteAllItems(); int baseCurrencyID = Option::instance().BaseCurrency(); if (currencyID_ <= 0 || currencyID_ == baseCurrencyID) { historyButtonAdd_->Disable(); historyButtonDelete_->Disable(); return; } else { historyButtonAdd_->Enable(); historyButtonDelete_->Enable(); } Model_CurrencyHistory::Data_Set histData = Model_CurrencyHistory::instance().find(Model_CurrencyHistory::CURRENCYID(currencyID_)); std::stable_sort(histData.begin(), histData.end(), SorterByCURRDATE()); std::reverse(histData.begin(), histData.end()); if (!histData.empty()) { int idx = 0; for (const auto &d : histData) { wxListItem item; item.SetId(idx); item.SetData(d.CURRHISTID); valueListBox_->InsertItem(item); const wxDate dtdt = Model_CurrencyHistory::CURRDATE(d); const wxString dispAmount = wxString::Format(wxT("%f"), d.CURRVALUE); valueListBox_->SetItem(idx, 0, mmGetDateForDisplay(dtdt)); valueListBox_->SetItem(idx, 1, dispAmount); const wxString& priceAmount = wxEmptyString; valueListBox_->SetItem(idx, 2, priceAmount); idx++; } valueListBox_->RefreshItems(0, --idx); } }
/** Return the last attachment number linked to a specific object */ double Model_CurrencyHistory::getLastRate(const int& currencyID) { Model_CurrencyHistory::Data_Set histData = Model_CurrencyHistory::instance().find(Model_CurrencyHistory::CURRENCYID(currencyID)); std::stable_sort(histData.begin(), histData.end(), SorterByCURRDATE()); if (!histData.empty()) return histData.back().CURRVALUE; else { Model_Currency::Data* Currency = Model_Currency::instance().get(currencyID); return Currency->BASECONVRATE; } }