Exemplo n.º 1
0
mmLast12Months::mmLast12Months()
: mmDateRange()
{
    this->end_date_ = wxDateTime(this->start_date_).GetLastMonthDay();
    this->start_date_ = wxDateTime(end_date_).SetDay(1)
        .Add(wxDateSpan::Months(1))
        .Subtract(wxDateSpan::Years(1));
    this->title_ = wxTRANSLATE("Last 12 Months");
}
Exemplo n.º 2
0
wxDateTime wxQtConvertDate(const QDate& date)
{
    if ( !date.isNull() )
        return wxDateTime(date.day(),
            static_cast<wxDateTime::Month>(date.month() - 1),
            date.year(), 0, 0, 0, 0);
    else
        return wxDateTime();
}
Exemplo n.º 3
0
void GRIBUIDialog::OpenFile(bool newestFile)
{
    m_bpPlay->SetBitmap(*m_bPlay);
    m_bpPlay->SetToolTip(_("Play"));
    m_tPlayStop.Stop();

    m_cRecordForecast->Clear();
    /* this should be un-commented to avoid a memory leak,
       but for some reason it crbashes windows */
//    delete m_bGRIBActiveFile;
    m_pTimelineSet = NULL;

    //get more recent file in default directory if necessary
    wxFileName f( m_file_name );
    if( newestFile || f.GetFullName().IsEmpty() ) m_file_name = GetNewestFileInDirectory();

    m_bGRIBActiveFile = new GRIBFile( m_file_name,
                                      pPlugIn->GetCopyFirstCumRec(),
                                      pPlugIn->GetCopyMissWaveRec() );    

    ArrayOfGribRecordSets *rsa = m_bGRIBActiveFile->GetRecordSetArrayPtr();
    if(rsa->GetCount() < 2)
        m_TimeLineHours = 0;
    else {
        GribRecordSet &first=rsa->Item(0), &last = rsa->Item(rsa->GetCount()-1);
        
        wxTimeSpan span = wxDateTime(last.m_Reference_Time) - wxDateTime(first.m_Reference_Time);
        m_TimeLineHours = span.GetHours();
        m_sTimeline->Enable();
    }
    m_sTimeline->SetValue(0);
    
    wxFileName fn( m_file_name );
    SetLabel( fn.GetFullName() );

    if( m_bGRIBActiveFile ) {
        if( m_bGRIBActiveFile->IsOK() ) { 
            //there could be valid but empty file
            if( rsa->GetCount() == 0 ) {
                m_bGRIBActiveFile = NULL;
                pPlugIn->GetGRIBOverlayFactory()->SetMessage( _("Error:  No valid data in this file!") );
            } else
                PopulateComboDataList( 0 );
        } else {
            if( fn.IsDir() ) {
                pPlugIn->GetGRIBOverlayFactory()->SetMessage( _("Warning:  Empty directory!") );
                SetLabel( fn.GetFullPath() );
            }
            else
                pPlugIn->GetGRIBOverlayFactory()->SetMessage( m_bGRIBActiveFile->GetLastMessage() );
	}
        SetFactoryOptions();
        DisplayDataGRS();
        PopulateTrackingControls();
    }
}
Exemplo n.º 4
0
void udfPaymentHistory::OnUpdate( wxCommandEvent& event )
{
    do
    {
        unsigned int nItem = m_listPayments->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if(-1 == nItem)
            break;
        unsigned int nId = *(int*)m_listPayments->GetItemData(nItem);

        CPaymentHistoryTable::tTableIt it = m_payments.find(nId);
        if(it == m_payments.end())
            break;

        CPaymentHistoryTable::tDATA& data = it->second;

        udfPayment	dlg(this);
        dlg.SetPayDate(data.payDate);
        dlg.SetExpDate(data.expDate);
        if (data.sum == -1.0)
            dlg.SetFreeCheck(true);
        else
            dlg.SetSum(data.sum);
        // fill dialog fields
        if(dlg.ShowModal() == wxID_OK)
        {
            data.payDate = dlg.GetPayDate().GetTicks();
            data.expDate = dlg.GetExpDate().GetTicks();
            if(dlg.GetFreeCheck())
                data.sum = -1.0;
            else
                data.sum = dlg.GetSum();

            if(UDF_OK != CPaymentHistoryTable(m_pCon).UpdateRow(nId, data))
                break;

            int nCol = 1;
            wxListItem info;
            info.SetId(nItem);
            info.SetText(wxDateTime(data.payDate).Format(STR_FORMAT_DATE));
            m_listPayments->SetItem(info);

            info.SetColumn(nCol++);
            info.SetText(wxDateTime(data.expDate).Format(STR_FORMAT_DATE));
            m_listPayments->SetItem(info);

            info.SetColumn(nCol++);
            if (data.sum == -1.0)
                info.SetText(STR_FREE);
            else
                info.SetText(wxString::Format(STR_FORMAT_SUM, data.sum));
            m_listPayments->SetItem(info);
        }
    } while(0);
}
void PanelOptionsParameters::CreateControls()
{    
////@begin PanelOptionsParameters content construction
    PanelOptionsParameters* itemPanel1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
    itemPanel1->SetSizer(itemBoxSizer2);

    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_RIGHT|wxALL, 5);

    wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, ID_LBL_Underlying, _("Underlying:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
    itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_txtUnderlying = new wxTextCtrl( itemPanel1, ID_TXT_Underlying, _("GLD"), wxDefaultPosition, wxDefaultSize, 0 );
    m_txtUnderlying->SetMaxLength(10);
    itemBoxSizer3->Add(m_txtUnderlying, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_RIGHT|wxALL, 5);

    wxStaticText* itemStaticText7 = new wxStaticText( itemPanel1, ID_LBL_OPTIONNEARDATE, _("Near Date:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
    itemBoxSizer6->Add(itemStaticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_ctrlNearDate = new wxDatePickerCtrl( itemPanel1, ID_DATE_NearDate, wxDateTime(), wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT );
    itemBoxSizer6->Add(m_ctrlNearDate, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer9, 0, wxALIGN_RIGHT|wxALL, 5);

    wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, ID_LBL_OPTIONFARDATE, _("Far Date:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
    itemBoxSizer9->Add(itemStaticText10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_ctrlFarDate = new wxDatePickerCtrl( itemPanel1, ID_DATE_FarDate, wxDateTime(), wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT );
    itemBoxSizer9->Add(m_ctrlFarDate, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    m_btnStart = new wxButton( itemPanel1, ID_BTN_START, _("Start"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer12->Add(m_btnStart, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_btnStop = new wxButton( itemPanel1, ID_BTN_STOP, _("Stop"), wxDefaultPosition, wxDefaultSize, 0 );
    m_btnStop->Enable(false);
    itemBoxSizer12->Add(m_btnStop, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    m_btnSave = new wxButton( itemPanel1, ID_BTN_SAVE, _("Save"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer15->Add(m_btnSave, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

////@end PanelOptionsParameters content construction
}
Exemplo n.º 6
0
void CGarbageCollector::RecycleTaskInstances()
{
    BSLERRCODE rc;
    std::vector<CTaskInstance*> oTaskInstances;
    std::vector<CTaskInstance*>::iterator iter;
    CTaskInstance* pTaskInstance = NULL;
    CRPCProfile* pRPCProfile = NULL;
    CSyncProfile* pSyncProfile = NULL;
    wxDateTime dtExpirationDate = wxDateTime((time_t)0);
    wxDateTime dtRPCCompletedDate = wxDateTime((time_t)0);
    wxUint32 uiInterval = 0;

    rc = m_pHost->FindSyncProfile(CBSLClient::AutoSyncPropertyTaskInstancesUpdateInterval, &pSyncProfile);
    if (BSLERR_SUCCESS != rc) return;
    if (!pSyncProfile) return;

    rc = m_pHost->FindRPCProfile(CLASSINFO(CRPCSyncTaskInstances)->GetClassName(), &pRPCProfile);
    if (BSLERR_SUCCESS != rc) return;
    if (!pRPCProfile) return;

    uiInterval = pSyncProfile->GetValue();
    if (!uiInterval) return;

    dtRPCCompletedDate = pRPCProfile->GetLastRequestTime() + pRPCProfile->GetTotalDuration();

    rc = m_pHost->EnumerateTaskInstances(oTaskInstances);
    if (BSLERR_SUCCESS != rc) return;

    for (iter = oTaskInstances.begin(); iter != oTaskInstances.end(); ++iter)
    {
        pTaskInstance = *iter;

        // An item is deemed expired if it wasn't refreshed the last time the synchronize
        // RPC was called.
        //
        dtExpirationDate =
            pTaskInstance->GetLastModifiedTime() +
            wxTimeSpan(0, 0, uiInterval, 0) +
            wxTimeSpan(0, 0, 0, 250);

        if ((m_dtNow > dtExpirationDate) && (dtRPCCompletedDate > dtExpirationDate))
        {
            wxLogTrace(wxT("Function Status"),
                wxT("CGarbageCollector::RecycleTaskInstances - Recycle '%p', dtNow: '%s', dtExpirationDate: '%s', dtRPCCompletedDate: '%s'"),
                pTaskInstance,
                m_dtNow.Format(wxT("%H:%M:%S.%l")).c_str(),
                dtRPCCompletedDate.Format(wxT("%H:%M:%S.%l")).c_str(),
                dtExpirationDate.Format(wxT("%H:%M:%S.%l")).c_str()
            );

            m_pHost->DeleteTaskInstance(pTaskInstance);
        }
    }
}
Exemplo n.º 7
0
int
tutorial2(bool testMode)
{
  int rc = 0;
  if (wxFileName::IsFileReadable(wxS("smile.jpg")) &&
      wxFileName::IsFileReadable(wxS("apple.gif")))
  {
    // Instantiation of inherited class
    PdfTuto2 pdf;
    if (testMode)
    {
      pdf.SetCreationDate(wxDateTime(1, wxDateTime::Jan, 2017));
      pdf.SetCompression(false);
    }
    pdf.AliasNbPages();
    pdf.AddPage();
    pdf.Image(wxS("smile.jpg"), 70, 40, 12);
    pdf.Image(wxS("apple.gif"), 110, 40, 25);
    pdf.SetFont(wxS("Times"), wxS(""), 12);
    int i;
    for (i = 1; i <= 40; i++)
    {
      pdf.Cell(0, 10, wxString::Format(wxS("Printing line number %d"), i), 0, 1);
    }
    pdf.SaveAsFile(wxS("tutorial2.pdf"));
  }
  else
  {
    rc = 1;
  }
  return rc;
}
Exemplo n.º 8
0
mmLastMonth::mmLastMonth()
: mmDateRange()
{
    this->start_date_.Subtract(wxDateSpan::Months(1)).SetDay(1);
    this->end_date_ = wxDateTime(this->start_date_).GetLastMonthDay();
    this->title_ = wxTRANSLATE("Last Month");
}
Exemplo n.º 9
0
mmCurrentMonth::mmCurrentMonth()
: mmDateRange()
{
    this->start_date_ = wxDateTime(today_).SetDay(1);
    this->end_date_ = today_.GetLastMonthDay();
    this->title_ = wxTRANSLATE("Current Month");
}
Exemplo n.º 10
0
mmLastYear::mmLastYear()
: mmDateRange()
{
    this->start_date_.Subtract(wxDateSpan::Years(1)).SetDay(1).SetMonth(wxDateTime::Jan);
    this->end_date_ = wxDateTime(start_date_).SetMonth(wxDateTime::Dec).SetDay(31);
    this->title_ = wxTRANSLATE("Last Year");
}
Exemplo n.º 11
0
wxFSFile* wxFileSystemBlobHandler::OpenFile(wxFileSystem& fs, const wxString& location)
{
	auto pos = location.Find(':');
	if (pos != 4) {
		return 0;
	}
	wxString data = location.Mid(pos + 1);
	if (data.size() % 2) {
		return 0;
	}

	wxChar const* str = data.c_str();

	unsigned char* buf = static_cast<unsigned char*>(malloc(data.size() / 2));
	for (size_t i = 0; i < data.size() / 2; ++i) {
		buf[i] = static_cast<unsigned char>(fz::hex_char_to_int(str[i * 2]) * 16 + fz::hex_char_to_int(str[i * 2 + 1]));
	}

	// Whoever came up with the API for the wx streams obviously didn't ever use it.
	// Why else wouldn't it have an ownership-taking constructor?
	auto stream = new wxMemoryInputStream(0, data.size() / 2); 

	// Or why does it expect a buffer allocated with malloc?
	stream->GetInputStreamBuffer()->SetBufferIO(buf, data.size() / 2, true);

	return new wxFSFile(stream, location, _T(""), _T(""), wxDateTime());
}
Exemplo n.º 12
0
void udfTrainersMngrDlg::OnSelectTrainer(wxCommandEvent& event)
{
	do
	{
		int nItem = m_listTrainers->GetSelection();
		if(nItem == -1)
			break;
		
		int nId = *(int*)m_listTrainers->GetClientData(nItem);
		
		CTrainersTable::tTableIt it = m_Trainers.find(nId);
		if(it == m_Trainers.end())
			break;
		
		CTrainersTable::tDATA& data = it->second;
		m_textName->SetValue(data.name);
		m_textEmail->SetValue(data.email);
		m_textInfo->SetValue(data.additionalInfo);
		m_textPhone->SetValue(data.phone);
		
		wxString clubName = GetClubNameById(data.clubId);
		if(!clubName.IsEmpty())
		{
			m_comboClub->SetValue(clubName);
		}
		
		m_dateBd->SetValue(wxDateTime(data.bd));
	}while(0);
}
Exemplo n.º 13
0
wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
{
    // location has Unix path separators
    wxString right = GetRightLocation(location);
    wxFileName fn = wxFileSystem::URLToFileName(right);
    wxString fullpath = ms_root + fn.GetFullPath();

    if (!wxFileExists(fullpath))
        return (wxFSFile*) NULL;

    // we need to check whether we can really read from this file, otherwise
    // wxFSFile is not going to work
    wxFFileInputStream *is = new wxFFileInputStream(fullpath);
    if ( !is->Ok() )
    {
        delete is;
        return (wxFSFile*) NULL;
    }

    return new wxFSFile(is,
                        right,
                        GetMimeTypeFromExt(location),
                        GetAnchor(location)
#if wxUSE_DATETIME
                        ,wxDateTime(wxFileModificationTime(fullpath))
#endif // wxUSE_DATETIME
                        );
}
Exemplo n.º 14
0
void DrawsWidget::OnJumpToDate() {

	wxDateTime date = GetCurrentTime();

	if (date.IsValid() == false)
		return;

	DateChooserWidget *dcw =
		new DateChooserWidget(
				m_parent,
				_("Select date"),
				1,
				wxDateTime(1, 1, 1990).GetTicks(),
				wxDateTime::Now().GetTicks(),
				10
		);

	bool ret = dcw->GetDate(date);
	delete dcw;

	if (ret == false)
		return;

	m_draws_controller->Set(date);

}
Exemplo n.º 15
0
wxDateTime wxCalendarCtrl::GetDate() const
{
    if ( !m_qtCalendar )
        return wxDateTime();

    return wxQtConvertDate(m_qtCalendar->selectedDate());
}
Exemplo n.º 16
0
void ValuesTable::InsertValue(DatabaseQuery::ValueData::V *v, bool &view_values_changed, bool& stats_updated) {
	DTime dt(m_draw->GetPeriod(), wxDateTime(v->time));

	int view_index = m_draw->m_index.GetStartTime().GetDistance(dt);
	int index = view_index + m_view.Start();

	if (index < 0 || index >= (int)m_values.size()) 
		return;

	if (m_values.at(index).IsData())
		return;

	ValueInfo& vi = m_values.at(index);

	vi.av_val = v->response;
	vi.sum = v->sum;
	vi.first_val = v->first_val;
	vi.last_val = v->last_val;
	vi.count_probes = v->count;

	switch (m_draw->m_draw_info->GetAverageValueCalculationMethod()) {
		case AVERAGE_VALUE_CALCULATION_AVERAGE:
			vi.db_val = v->response;
			break;
		case AVERAGE_VALUE_CALCULATION_LAST:
			vi.db_val = v->last_val;
			break;
		case AVERAGE_VALUE_CALCULATION_LAST_FIRST:
			vi.db_val = v->last_val - v->first_val;
			break;
	}

	UpdateProbesValues(index, stats_updated, view_values_changed);
}
Exemplo n.º 17
0
wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
{
    // location has Unix path separators
    wxString right = GetRightLocation(location);
    wxFileName fn = wxFileSystem::URLToFileName(right);
    wxString fullpath = ms_root + fn.GetFullPath();

    if (!wxFileExists(fullpath))
        return NULL;

    // we need to check whether we can really read from this file, otherwise
    // wxFSFile is not going to work
#if wxUSE_FFILE
    wxFFileInputStream *is = new wxFFileInputStream(fullpath);
#elif wxUSE_FILE
    wxFileInputStream *is = new wxFileInputStream(fullpath);
#else
#error One of wxUSE_FILE or wxUSE_FFILE must be set to 1 for wxFSHandler to work
#endif
    if ( !is->IsOk() )
    {
        delete is;
        return NULL;
    }

    return new wxFSFile(is,
                        location,
                        wxEmptyString,
                        GetAnchor(location)
#if wxUSE_DATETIME
                        ,wxDateTime(wxFileModificationTime(fullpath))
#endif // wxUSE_DATETIME
                        );
}
Exemplo n.º 18
0
void Test_BillsDeposits::test_enter_simple_entry()
{
    Model_Billsdeposits::Data_Set bill_table = Model_Billsdeposits::instance().all();
    if (bill_table.size() < 1) return;

    m_user_request->Show_InfoBarMessage(
        "Please confirm Simple entry - Enter\n\n"
        "Account Name: Savings,   Repeats: Monthly\n"
        "Amount: 200,   Payee: Supermarket\n"
        "Category: Food/Groceries\n");

    Model_Billsdeposits::Data bill_entry = bill_table.at(bill_table.size() - 1);
    mmBDDialog* dlg = new mmBDDialog(m_base_frame, bill_entry.BDID, false, true);
    if (dlg->ShowModal() == wxID_OK)
    {
        bill_table = Model_Billsdeposits::instance().all();
        bill_entry = bill_table.at(bill_table.size() - 1);
        CPPUNIT_ASSERT(bill_entry.REPEATS == Model_Billsdeposits::REPEAT_MONTHLY);
        wxDateTime next_date = wxDateTime(wxDateTime::Today()).Add(wxDateSpan::Month());
        CPPUNIT_ASSERT(bill_entry.NEXTOCCURRENCEDATE == next_date.FormatISODate());

        Model_Checking::Data_Set checking_table = Model_Checking::instance().all();
        CPPUNIT_ASSERT(checking_table.size() > 0);

        Model_Checking::Data checking_entry = checking_table.at(checking_table.size() - 1);
        CPPUNIT_ASSERT(checking_entry.ACCOUNTID == Model_Account::instance().get("Savings")->ACCOUNTID);
        CPPUNIT_ASSERT(checking_entry.TRANSAMOUNT == 200);
        CPPUNIT_ASSERT(checking_entry.TOTRANSAMOUNT == 200);
    }
}
Exemplo n.º 19
0
/// For testing: triggered by Advanced / Options menu item.
void CMainDocument::TestAsyncRPC() {
    ALL_PROJECTS_LIST pl;
    ASYNC_RPC_REQUEST request;
    wxDateTime completionTime = wxDateTime((time_t)0);
    int req_retval = 0, rpc_result = 0;

    completionTime.ResetTime();

    request.which_rpc = RPC_GET_ALL_PROJECTS_LIST;
    request.arg1 = &pl;
    request.exchangeBuf = NULL;
    request.arg2 = NULL;
    request.arg3 = NULL;
    request.arg4 = NULL;
    request.rpcType = RPC_TYPE_WAIT_FOR_COMPLETION;
    request.completionTime = &completionTime;
//    request.result = NULL;
    request.resultPtr = &rpc_result;        // For testing async RPCs
    request.isActive = false;
    
//retval = rpcClient.get_all_projects_list(pl);

    req_retval = RequestRPC(request, true);

    wxString s = completionTime.FormatTime();
    wxLogMessage(wxT("Completion time = %s"), s.c_str());
    wxLogMessage(wxT("RequestRPC returned %d\n"), req_retval);
    ::wxSafeYield(NULL, true);  // Allow processing of RPC_FINISHED event
    wxLogMessage(wxT("rpcClient.get_all_projects_list returned %d\n"), rpc_result);
}
Exemplo n.º 20
0
void Test_BillsDeposits::test_enter_transfer_entry()
{
    Model_Billsdeposits::Data_Set bill_table = Model_Billsdeposits::instance().all();
    if (bill_table.size() < 1) return;

    m_user_request->Show_InfoBarMessage(
        "Please confirm transfer entry - Enter\n\n"
        "Account Name: Savings,   Repeats: Quarterly\n"
        "Type: Transfer,   Advanced,   Amount: 100, 50\n"
        "To Account: Cheque   Category: Gifts\n");

    Model_Billsdeposits::Data bill_entry = bill_table.at(bill_table.size() - 1);
    mmBDDialog* dlg = new mmBDDialog(m_base_frame, bill_entry.BDID, false, true);
    if (dlg->ShowModal() == wxID_OK)
    {
        bill_table = Model_Billsdeposits::instance().all();
        bill_entry = bill_table.at(bill_table.size() - 1);
        CPPUNIT_ASSERT(bill_entry.REPEATS == Model_Billsdeposits::REPEAT_QUARTERLY);
        wxDateTime next_date = wxDateTime(wxDateTime::Today()).Add(wxDateSpan::Months(3));
        CPPUNIT_ASSERT(bill_entry.NEXTOCCURRENCEDATE == next_date.FormatISODate());

        Model_Checking::Data_Set checking_table = Model_Checking::instance().all();
        CPPUNIT_ASSERT(checking_table.size() > 0);

        Model_Checking::Data checking_entry = checking_table.at(checking_table.size() - 1);
        CPPUNIT_ASSERT(checking_entry.ACCOUNTID == Model_Account::instance().get("Savings")->ACCOUNTID);
        CPPUNIT_ASSERT(checking_entry.TRANSAMOUNT == 100);
        CPPUNIT_ASSERT(checking_entry.TOTRANSAMOUNT == 50);
    }
}
Exemplo n.º 21
0
mmCurrentYear::mmCurrentYear()
: mmDateRange()
{
    this->start_date_.SetDay(1).SetMonth(wxDateTime::Jan);
    this->end_date_ = wxDateTime(start_date_).SetMonth(wxDateTime::Dec).SetDay(31);
    this->title_ = wxTRANSLATE("Current Year");
}
Exemplo n.º 22
0
void Test_BillsDeposits::test_new_split_entry()
{
    m_user_request->Show_InfoBarMessage(
        "Please create a new Split entry\n\n"
        "Account Name: Savings,   Repeats: Monthly\n"
        "Amount: 150,             Payee: Supermarket,   Split\n"
        "Add Deposit 50,          Category: Bills/Water\n");

    mmBDDialog* dlg = new mmBDDialog(m_base_frame, 0, false, false);
    if (dlg->ShowModal() == wxID_OK)
    {
        Model_Billsdeposits::Data_Set bill_table = Model_Billsdeposits::instance().all();
        CPPUNIT_ASSERT(bill_table.size() > 0);

        // check the data in the bill table
        Model_Billsdeposits::Data bill_entry = bill_table.at(bill_table.size() - 1);
        CPPUNIT_ASSERT(bill_entry.ACCOUNTID == Model_Account::instance().get("Savings")->ACCOUNTID);
        CPPUNIT_ASSERT(bill_entry.NEXTOCCURRENCEDATE == wxDateTime(wxDateTime::Today()).FormatISODate());
        CPPUNIT_ASSERT(bill_entry.TRANSAMOUNT == 100);
        CPPUNIT_ASSERT(bill_entry.TOTRANSAMOUNT == 100);
        CPPUNIT_ASSERT(bill_entry.REPEATS == Model_Billsdeposits::REPEAT_MONTHLY);
        CPPUNIT_ASSERT(bill_entry.CATEGID == -1);
        CPPUNIT_ASSERT(bill_entry.SUBCATEGID == -1);

        Model_Budgetsplittransaction::Data_Set bill_split_subtable = Model_Budgetsplittransaction::instance().find(Model_Budgetsplittransaction::TRANSID(bill_entry.id()));
        CPPUNIT_ASSERT(bill_split_subtable.size() == 2);

        CPPUNIT_ASSERT(bill_split_subtable[0].SPLITTRANSAMOUNT == 150);
        CPPUNIT_ASSERT(bill_split_subtable[1].SPLITTRANSAMOUNT == -50);
        CPPUNIT_ASSERT(Model_Budgetsplittransaction::instance().get_total(bill_split_subtable) == 100);
    }
}
Exemplo n.º 23
0
mmAllTime::mmAllTime()
: mmDateRange()
{
    this->title_ = wxTRANSLATE("Over Time");
    this->start_date_.SetDay(1).SetMonth(wxDateTime::Jan).SetYear(1);
    this->end_date_ = wxDateTime(31, wxDateTime::Dec, 9999);
}
Exemplo n.º 24
0
TiXmlElement* CXmlFile::Load(const wxFileName& fileName)
{
	if (fileName.IsOk())
		SetFileName(fileName);

	wxCHECK(m_fileName.IsOk(), 0);

	delete m_pDocument;
	m_pDocument = 0;

	TiXmlElement* pElement = GetXmlFile(m_fileName);
	if (!pElement)
	{
		m_modificationTime = wxDateTime();
		return 0;
	}

	{
		wxLogNull log;
		m_modificationTime = m_fileName.GetModificationTime();
	}

	m_pDocument = pElement->GetDocument();
	return pElement;
}
Exemplo n.º 25
0
mmCurrentMonthToDate::mmCurrentMonthToDate()
: mmDateRange()
{
    this->start_date_ = wxDateTime(today_).SetDay(1);
    // no change to end_date_
    this->title_ = wxTRANSLATE("Current Month to Date");
}
Exemplo n.º 26
0
TiXmlElement* CXmlFile::Load(const wxFileName& fileName)
{
	if (fileName.IsOk())
		SetFileName(fileName);

	wxCHECK(m_fileName.IsOk(), 0);

	delete m_pDocument;
	m_pDocument = 0;

	wxString error;
	TiXmlElement* pElement = GetXmlFile(m_fileName, &error);
	if (!pElement)
	{
		if (!error.empty())
		{
			m_error.Printf(_("The file '%s' could not be loaded."), m_fileName.GetFullPath().c_str());
			if (!error.empty())
				m_error += _T("\n") + error;
			else
				m_error += wxString(_T("\n")) + _("Make sure the file can be accessed and is a well-formed XML document.");
			m_modificationTime = wxDateTime();
		}
		return 0;
	}

	{
		wxLogNull log;
		m_modificationTime = m_fileName.GetModificationTime();
	}

	m_pDocument = pElement->GetDocument();
	return pElement;
}
Exemplo n.º 27
0
CDateTime::CDateTime( int year, int month, int day, int hour, int minute, int second, int millisecond )
	: a_()
{
	if( !Set( year, month, day, hour, minute, second, millisecond ) ) {
		t_ = wxDateTime();
	}
}
Exemplo n.º 28
0
void ParamEdit::TransferToWindow(DefinedParam *param) {
	DrawsSets *ds = m_cfg_mgr->GetConfigByPrefix(param->GetBasePrefix());

	m_button_base_config->SetLabel(ds->GetID());
	m_prec_spin->SetValue(param->GetPrec());
 	m_formula_input->SetText(param->GetFormula());
	m_user_param_label->SetLabel(param->GetParamName().BeforeLast(L':') + L':');
	m_param_name_input->SetValue(param->GetParamName().AfterLast(L':'));
	m_unit_input->SetValue(param->GetUnit());
	m_formula_type_choice->SetSelection(param->GetFormulaType() == TParam::LUA_VA ? 0 : 1);
	
	
	if (param->GetStartTime() > 0) {
		struct tm *start_date;
		time_t tmp_time = param->GetStartTime();
		start_date = localtime(&tmp_time);
	
		m_spin_ctrl_start_minutes->SetValue(start_date->tm_min);
		m_spin_ctrl_start_hours->SetValue(start_date->tm_hour);
	
		m_datepicker_ctrl_start_date->SetValue(wxDateTime(param->GetStartTime()));
		m_checkbox_start->SetValue(true);
		
		m_datepicker_ctrl_start_date->Enable(true);
		m_spin_ctrl_start_hours->Enable(true);
		m_spin_ctrl_start_minutes->Enable(true);
	}

}
Exemplo n.º 29
0
void VHDDExplorer::UpdateList()
{
	m_list->Freeze();
	m_list->DeleteAllItems();
	m_entries.clear();
	m_names.clear();

	u64 block;
	vfsHDD_Entry entry;
	std::string name;

	for(bool is_ok = m_hdd->GetFirstEntry(block, entry, name); is_ok; is_ok = m_hdd->GetNextEntry(block, entry, name))
	{
		int item = m_list->GetItemCount();
		m_list->InsertItem(item, fmt::FromUTF8(name));
		m_list->SetItem(item, 1, entry.type == vfsHDD_Entry_Dir ? "Dir" : "File");
		m_list->SetItem(item, 2, wxString::Format("%lld", entry.size));
		m_list->SetItem(item, 3, wxDateTime().Set(time_t(entry.ctime)).Format());
		m_entries.push_back(entry);
		m_names.push_back(name);
	}

	m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
	m_list->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
	m_list->SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER);
	m_list->SetColumnWidth(3, wxLIST_AUTOSIZE_USEHEADER);
	m_list->Thaw();
}
Exemplo n.º 30
0
void mmHomePagePanel::getExpensesIncomeStats(std::map<int, std::pair<double, double> > &incomeExpensesStats
    , mmDateRange* date_range)const
{
    //Initialization
    bool ignoreFuture = mmIniOptions::instance().ignoreFutureTransactions_;
    wxDateTime start_date = wxDateTime(date_range->end_date()).SetDay(1);

    //Calculations
    const auto &transactions = Model_Checking::instance().find(
        Model_Checking::TRANSDATE(date_range->start_date(), GREATER_OR_EQUAL)
        , Model_Checking::TRANSDATE(date_range->end_date(), LESS_OR_EQUAL)
        , Model_Checking::STATUS(Model_Checking::VOID_, NOT_EQUAL)
        , Model_Checking::TRANSCODE(Model_Checking::TRANSFER, NOT_EQUAL)
        );

    for (const auto& pBankTransaction : transactions)
    {
        if (ignoreFuture)
        {
            if (Model_Checking::TRANSDATE(pBankTransaction).IsLaterThan(date_range->today()))
                continue; //skip future dated transactions
        }

        // We got this far, get the currency conversion rate for this account
        Model_Account::Data *account = Model_Account::instance().get(pBankTransaction.ACCOUNTID);
        double convRate = (account ? Model_Account::currency(account)->BASECONVRATE : 1);

        int idx = pBankTransaction.ACCOUNTID;
        if (Model_Checking::type(pBankTransaction) == Model_Checking::DEPOSIT)
            incomeExpensesStats[idx].first += pBankTransaction.TRANSAMOUNT * convRate;
        else
            incomeExpensesStats[idx].second += pBankTransaction.TRANSAMOUNT * convRate;
    }
}