Ejemplo n.º 1
0
bool mmBudgetingPanel::DisplayEntryAllowed(int categoryID, int subcategoryID)
{
    bool result = false;

    double actual = 0;
    double estimated = 0;
    if (categoryID < 0)
    {
        actual = budgetTotals_[subcategoryID].second;
        estimated = budgetTotals_[subcategoryID].first;
    }
    else
    {
        actual = categoryStats_[categoryID][subcategoryID][0];
        estimated = getEstimate(categoryID, subcategoryID);
    }

    if (currentView_ == VIEW_NON_ZERO)
        result = ((estimated != 0.0) || (actual != 0.0));
    else if (currentView_ == VIEW_INCOME)
        result = ((estimated > 0.0) || (actual > 0.0));
    else if (currentView_ == VIEW_PLANNED)
        result = (estimated != 0.0);
    else if (currentView_ == VIEW_EXPENSE)
        result = ((estimated < 0.0) || (actual < 0.0));
    else if (currentView_ == VIEW_SUMM)
        result = (categoryID < 0);
    else
        result = true;

    return result;
}
Ejemplo n.º 2
0
void mmBudgetingPanel::OnListItemActivated(int selectedIndex)
{
    /***************************************************************************
     A TOTALS entry does not contain a budget entry, therefore ignore the event.
     ***************************************************************************/
    if (budget_[selectedIndex].first < 0) return;

    Model_Budget::Data_Set budget = Model_Budget::instance().find(Model_Budget::BUDGETYEARID(GetBudgetYearID())
        , Model_Budget::CATEGID(budget_[selectedIndex].first), Model_Budget::SUBCATEGID(budget_[selectedIndex].second));
    Model_Budget::Data* entry = 0;
    if (budget.empty())
    {
        entry = Model_Budget::instance().create();
        entry->BUDGETYEARID = GetBudgetYearID();
        entry->CATEGID = budget_[selectedIndex].first;
        entry->SUBCATEGID = budget_[selectedIndex].second;
        entry->PERIOD = "";
        entry->AMOUNT = 0.0;
        Model_Budget::instance().save(entry);
    }
    else
        entry = &budget[0];

    double estimated = getEstimate(budget_[selectedIndex].first, budget_[selectedIndex].second);
    double actual = categoryStats_[budget_[selectedIndex].first][budget_[selectedIndex].second][0];

    mmBudgetEntryDialog dlg(this, entry, Model_Currency::toCurrency(estimated), Model_Currency::toCurrency(actual));
    if (dlg.ShowModal() == wxID_OK)
    {
        initVirtualListControl();
        listCtrlBudget_->Refresh();
        listCtrlBudget_->Update();
        listCtrlBudget_->EnsureVisible(selectedIndex);
    }
}
Ejemplo n.º 3
0
bool pathOption::addNode(int newNode, pathOption &curBest)
{
    /*for (std::multiset<int>::iterator i = minPathSet.begin(); i != minPathSet.end(); i++)
    {
    	std::cout << *i << " ";
    }
    std::cout << std::endl << minPathEstimate << std::endl;*/

    if (curPath.size() < maxDepth)
    {
        openNodes.erase(newNode);
        curDistance += getLastNode().distanceArray[newNode];
        curPath.push_back(newNode);
        //std::cout << "New path: " << getDepth() << std::endl;
        if (curPath.size() >= maxDepth)
        {
            return false;
        }
    }

    if (getEstimate() >= curBest.curDistance)
    {
        //std::cout << "Path removed: " << curDistance << std::endl;
        return false;
    }

    for (std::set<uint8_t>::iterator i = openNodes.begin(); i != openNodes.end(); i++)
    {
        minPathSet.erase(minPathSet.find(getLastNode().distanceArray[*i]));
    }

    updateMinPath();

    return true;
}
Ejemplo n.º 4
0
bool pathOption::operator > (const pathOption& other)
{
    if (getDepth() > other.getDepth())
    {
        return false;
    }
    else if (getDepth() == other.getDepth())
    {
        return (getEstimate() > other.getEstimate());
    }
    else
    {
        return true;
    }
}
Ejemplo n.º 5
0
void LIPStateEstimator::update(float timePassed, const Array2f& LIPHeights, const Vector2f& leftOrigin, const SupportFoot newSupportFoot)
{
  this->LIPHeights = LIPHeights;
  Vector2f newOrigin = leftOrigin;
  if(newSupportFoot != SupportFoot::left)
    newOrigin.y() *= -1;
  const Vector4f measurement = measure(newSupportFoot, newOrigin);
  if(supportFoot != newSupportFoot)
  {
    EstimatedState est = getEstimate();
    est = convertToOtherFoot(est);
    ukf.mean.head<2>() = est.com.position;
    ukf.mean.segment<2>(2) = est.com.velocity;
    ukf.mean.tail<2>() = est.zmp;
  }
  else
  {
    ukf.mean.head<2>() = origin + ukf.mean.head<2>() - newOrigin;
    ukf.mean.tail<2>() = origin + ukf.mean.tail<2>() - newOrigin;
  }
  supportFoot = newSupportFoot;
  origin = newOrigin;

  auto dynamicMoldel = [&](Vector6f& state)
  {
    const Vector2f zmp = state.tail<2>();
    LIP3D lipState(state.head<2>(), state.segment<2>(2), LIPHeights);
    lipState.update(timePassed, zmp);
    state << lipState.position, lipState.velocity, zmp;
  };

  auto measurementModel = [&](const Vector6f& state)
  {
    return (Vector4f() << state.head<2>(), state.tail<2>()).finished();
  };

  const Vector6f dynamicNoise = (Vector6f() << params.positionProcessDeviation, params.velocityProcessDeviation,
                                 params.zmpProcessDeviation).finished() * timePassed;
  const Vector4f measurementNoise = (Vector4f() << params.positionMeasurementDeviation, params.zmpMeasurementDeviation).finished() * timePassed;
  ukf.predict(dynamicMoldel, dynamicNoise.cwiseAbs2().asDiagonal());
  ukf.update<4>(measurement, measurementModel, measurementNoise.cwiseAbs2().asDiagonal());
}
Ejemplo n.º 6
0
int mmBudgetingPanel::GetItemImage(long item) const
{
    double estimated = 0;
    double actual = 0;
    if (budget_[item].first < 0)
    {
        estimated = budgetTotals_.at(budget_[item].second).first;
        actual = budgetTotals_.at(budget_[item].second).second;
    }
    else
    {
        estimated = getEstimate(budget_[item].first, budget_[item].second);
        actual = categoryStats_.at(budget_[item].first).at(budget_[item].second).at(0);
    }

    if ((estimated == 0.0) && (actual == 0.0)) return 3;
    if ((estimated == 0.0) && (actual != 0.0)) return 2;
    if (estimated < actual) return 0;
    if (fabs(estimated - actual)  < 0.001) return 0;
    return 1;
}
Ejemplo n.º 7
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    GlobalCache *globalCache = new GlobalCache();
    loginStatus = false;

    updateTimer = startTimer(100);

    QTimerEvent *e= new QTimerEvent(updateTimer);

    setWindowTitle("#precIsioN Billing Software 1.2");

    /* Setting height and width properties */
    QDesktopWidget *desktop = QApplication::desktop();
    int width = desktop->width();
    int height = desktop->height();
    GlobalCache::setScreenWidth(width);
    GlobalCache::setScreenHeight(height);
    resize(width/2, height/2);
    int sideWidth = 10; //width/48;
    int sideHeight = (height-50)/14;
    widgetWidth = width - 20; //sideWidth *46;
    widgetHeight = sideHeight * 14;

    /* Creating menu bar and status bar */
    menubar = new QMenuBar(this);
    setMenuBar(menubar);

    menuAdministrator = new QMenu(menubar);
    menuAdministrator->setTitle("Administrator");
    menubar->addMenu(menuAdministrator);

    QAction *homeAct = new QAction(("&Home"), this);
    homeAct->setShortcut(QKeySequence(tr("Ctrl+H")));
    menuAdministrator->addAction(homeAct);
    menuAdministrator->addSeparator();
    QAction *changePasswordAct = new QAction("Change Password", this);
    menuAdministrator->addAction(changePasswordAct);
    QAction *refreshAct = new QAction(("&Refresh"), this);
    refreshAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuAdministrator->addAction(refreshAct);
    QAction *fullScreenAct = new QAction(("&Full Screen"), this);
    fullScreenAct->setShortcut(Qt::Key_F11);
    menuAdministrator->addAction(fullScreenAct);
    QAction *restartAct = new QAction("Restart", this);
    restartAct->setShortcut(QKeySequence((tr("Shift+Ctrl+X"))));
    menuAdministrator->addAction(restartAct);
    QAction *quitAct = new QAction(("Quit Application"), this);
    quitAct->setShortcut(QKeySequence(tr("Ctrl+X")));
    menuAdministrator->addAction(quitAct);

    menuStock = new QMenu(menubar);
    menuStock->setTitle("Stock");
    menubar->addMenu(menuStock);

    QAction *manageStockAct = new QAction(("Manage Stock"), this);
    manageStockAct->setShortcut(QKeySequence(tr("Ctrl+M")));
    menuStock->addAction(manageStockAct);
    QAction *bulkStockUpdationAct = new QAction("Bulk Stock Updation", this);
    bulkStockUpdationAct->setShortcut(QKeySequence(tr("Ctrl+U")));
    menuStock->addAction(bulkStockUpdationAct);
    menuStock->addSeparator();
    QAction *stockPruchaseInvoiceAct = new QAction(("Stock Purchase Invoice"), this);
    menuStock->addAction(stockPruchaseInvoiceAct);
    QAction *oldStockPurchaseInvoiceAct = new QAction(("Old Stock Purchase Invoice"), this);
    menuStock->addAction(oldStockPurchaseInvoiceAct);
    menuStock->addSeparator();
    QAction *stockUpdationAct = new QAction(("Single Stock Updation"), this);
    menuStock->addAction(stockUpdationAct);
    menuStock->addSeparator();
    QAction *addNewStockAct = new QAction(("Add New Stock"), this);
    menuStock->addAction(addNewStockAct);
    QAction *deleteStockact = new QAction(("Remove Stock"), this);
    menuStock->addAction(deleteStockact);
    QAction *updateStockAct = new QAction(("Edit Stock Details"), this);
    menuStock->addAction(updateStockAct);
    menuStock->addSeparator();
    QAction *checkStockAct = new QAction("Check Stock", this);
    checkStockAct->setShortcut(QKeySequence("Ctrl+F"));
    menuStock->addAction(checkStockAct);

    menuInvoice = new QMenu(menubar);
    menuInvoice->setTitle("Invoice");
    menubar->addMenu(menuInvoice);

    QAction *invoiceAct = new QAction(("&New Invoice"), this);
    invoiceAct->setShortcut(QKeySequence(tr("Ctrl+N")));
    menuInvoice->addAction(invoiceAct);
    QAction *setInvoiceAct = new QAction(("Set Invoice No"), this);
    menuInvoice->addAction(setInvoiceAct);
    QAction *cancelInvoiceAct = new QAction(("Cancel Invoice"), this);
    menuInvoice->addAction(cancelInvoiceAct);
    QAction *oldInvoiceAct = new QAction(("Old Invoices"), this);
    menuInvoice->addAction(oldInvoiceAct);

    menuEstimate = new QMenu(menubar);
    menuEstimate->setTitle("Estimate");
    menubar->addMenu(menuEstimate);

    QAction *estimateAct = new QAction(("&New Estimate"), this);
    estimateAct->setShortcut(QKeySequence(tr("Ctrl+E")));
    menuEstimate->addAction(estimateAct);
    QAction *setEstimateAct = new QAction(("Set Estimate No"), this);
    menuEstimate->addAction(setEstimateAct);
    QAction *cancelEstimateAct = new QAction(("Cancel Estimate"), this);
    menuEstimate->addAction(cancelEstimateAct);
    QAction *oldEstimateAct = new QAction(("Old Estimates"), this);
    menuEstimate->addAction(oldEstimateAct);
    menuEstimate->addSeparator();
    QAction *itemEstimateAct = new QAction("Item Estimates", this);
    menuEstimate->addAction(itemEstimateAct);


    menuDealer = new QMenu(menubar);
    menuDealer->setTitle("Dealer");
//    menubar->addMenu(menuDealer);

    QAction *dealerHomeAct = new QAction(("&Dealer Home"), this);
    dealerHomeAct->setShortcut(QKeySequence(tr("Ctrl+D")));
    menuDealer->addAction(dealerHomeAct);
    QAction *salesDetailsAct = new QAction(("Sales De&tais"), this);
    salesDetailsAct->setShortcut(QKeySequence(tr("Ctrl+T")));
    menuDealer->addAction(salesDetailsAct);
    QAction *addNewDealerAct = new QAction(("Add New Dealer"), this);
    menuDealer->addAction(addNewDealerAct);
    QAction *deleteDealerAct = new QAction(("Delete Dealer"), this);
    menuDealer->addAction(deleteDealerAct);
    QAction *updateDealerAct = new QAction(("Edit Dealer Details"), this);
    menuDealer->addAction(updateDealerAct);

    menuAccounts = new QMenu(menubar);
    menuAccounts->setTitle("Accounts");
    menubar->addMenu(menuAccounts);

    QAction *accountsAct = new QAction(("Accounts"), this);
    accountsAct->setShortcut(QKeySequence(tr("Ctrl+A")));
    menuAccounts->addAction(accountsAct);

    menuReports = new QMenu(menubar);
    menuReports->setTitle("Reports");
    menubar->addMenu(menuReports);

    QAction *todaysItemSalesAct = new QAction(("Today's &Item Sales"), this);
    todaysItemSalesAct->setShortcut(QKeySequence(tr("Ctrl+I")));
    menuReports->addAction(todaysItemSalesAct);
    QAction *dailyReportAct = new QAction(("Daily Sales &Report"), this);
    dailyReportAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuReports->addAction(dailyReportAct);
    QAction *itemSalesReportAct = new QAction("Selected Item Sales Report", this);
    menuReports->addAction(itemSalesReportAct);
    QAction *historyItemSalesAct = new QAction(("History Item Sales"), this);
    menuReports->addAction(historyItemSalesAct);
    menuReports->addSeparator();
    QAction *purchaseReportAct = new QAction("Purchase Report", this);
    menuReports->addAction(purchaseReportAct);
    QAction *purchaseItemsAct = new QAction("Purchased Item Report", this);
    menuReports->addAction(purchaseItemsAct);

    menuSettings = new QMenu(menubar);
    menuSettings->setTitle("Settings");
    menubar->addMenu(menuSettings);

    QAction *configurationAct = new QAction(("Configure Product"), this);
    menuSettings->addAction(configurationAct);
    QAction *deleteDataAct = new QAction("Clear Data", this);
    menuSettings->addAction(deleteDataAct);
    QAction *backupAct = new QAction(("Backup"), this);
    menuSettings->addAction(backupAct);

    menuHelp = new QMenu(menubar);
    menuHelp->setTitle("Help");
    menubar->addMenu(menuHelp);

    QAction *shortcutAct = new QAction(("Shorcuts Used"), this);
    menuHelp->addAction(shortcutAct);
    QAction *aboutAct = new QAction(("About"), this);
    menuHelp->addAction(aboutAct);

    adminHome = new AdminHomeWidget(widgetWidth, this);
    adminHome->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    manageStock = new ManageStockWidget(widgetWidth, this);
    manageStock->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseInvoice = new StockPurchaseInvoiceWidget(widgetWidth, this);
    purchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldPurchaseInvoice = new OldPurchaseInvoiceWidget(widgetWidth, this);
    oldPurchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    invoice = new InvoiceWidget(widgetWidth, this);
    invoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    dailyReport = new DailySalesReportWidget(widgetWidth, this);
    dailyReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemSales = new TodaysItemSalesWidget(widgetWidth, this);
    itemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldInvoice = new OldInvoicesWidget(widgetWidth, this);
    oldInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    allInvoices = new AllInvoices(widgetWidth, this);
    allInvoices->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldEstimate = new OldEstimates(widgetWidth, this);
    oldEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemEstimate = new ItemEstimateWidget(widgetWidth, this);
    itemEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    estimate = new EstimateWidget(widgetWidth, this);
    estimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    salesDetails = new SalesDetailsWidget(widgetWidth, this);
    salesDetails->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    accounts = new AccountsWidget(widgetWidth, this);
    accounts->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseReport = new PurchaseReportWidget(widgetWidth, this);
    purchaseReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchasedItems = new PurchasedItemWidget(widgetWidth, this);
    purchasedItems->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyDsr = new HistoryDSRWidget(widgetWidth, this);
    historyDsr->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyItemSales = new HistoryItemSalesWidget(widgetWidth, this);
    historyItemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyinvoice = new HistoryInvoiceWidget(widgetWidth, this);
    historyinvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);

    /* Main Window setup */

    connect( homeAct, SIGNAL(triggered()), this, SLOT(getAdminHome()));
    connect( todaysItemSalesAct, SIGNAL(triggered()), this, SLOT(getItemSales()));
    connect( dailyReportAct, SIGNAL(triggered()), this, SLOT(getDailySalesReport()));
    connect( itemSalesReportAct, SIGNAL(triggered()), this, SLOT(getItemSalesReport()));
    connect( bulkStockUpdationAct, SIGNAL(triggered()), this, SLOT(getBulkStockUpdationDialog()));
    connect( stockUpdationAct, SIGNAL(triggered()), this, SLOT(getStockUpdationDialog()));
    connect( addNewStockAct, SIGNAL(triggered()), this, SLOT(getAddNewStockDialog()));
    connect( deleteStockact, SIGNAL(triggered()), this, SLOT(getDeleteStockDialog()));
    connect( updateStockAct, SIGNAL(triggered()), this, SLOT(getUpdateStockDialog()));
    connect( checkStockAct, SIGNAL(triggered()), this, SLOT(getCheckStockDialog()));
    connect( changePasswordAct, SIGNAL(triggered()), this, SLOT(getChangePasswordDialog()));
    connect( refreshAct, SIGNAL(triggered()), this, SLOT(refresh()));
    connect( fullScreenAct, SIGNAL(triggered()), this, SLOT(getFullScreen()));
    connect( restartAct, SIGNAL(triggered()), this, SLOT(restart()));
    connect( quitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect( manageStockAct, SIGNAL(triggered()), this, SLOT(getManageStockWidget()));
    connect( stockPruchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getStockPurchaseInvoice()));
    connect( oldStockPurchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldStockPurchaseInvoice()));
    connect( invoiceAct, SIGNAL(triggered()), this, SLOT(getInvoice()));
    connect( setInvoiceAct, SIGNAL(triggered()), this, SLOT(getSetInvoiceDialog()));
    connect( cancelInvoiceAct, SIGNAL(triggered()), this, SLOT(cancelInvoice()));
    connect( oldInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldInvoice()));
    connect( estimateAct, SIGNAL(triggered()), this, SLOT(getEstimate()));
    connect( setEstimateAct, SIGNAL(triggered()), this, SLOT(getSetEstimateDialog()));
    connect( cancelEstimateAct, SIGNAL(triggered()), this, SLOT(cancelEstimate()));
    connect( oldEstimateAct, SIGNAL(triggered()), this, SLOT(getOldEstimates()));
    connect( itemEstimateAct, SIGNAL(triggered()), this, SLOT(getItemEstimate()));
    connect( salesDetailsAct, SIGNAL(triggered()), this, SLOT(getSalesDetails()));
    connect( accountsAct, SIGNAL(triggered()), this, SLOT(getAccountsWidget()));
    connect( purchaseReportAct, SIGNAL(triggered()), this, SLOT(getPurchaseReport()));
    connect( purchaseItemsAct, SIGNAL(triggered()), this, SLOT(getPurchasedItems()));
    connect( historyItemSalesAct, SIGNAL(triggered()), this, SLOT(getHistoryItemSales()));
    connect( configurationAct, SIGNAL(triggered()), this, SLOT(getConfiguration()));
    connect( deleteDataAct, SIGNAL(triggered()), this, SLOT(getDeleteDataAct()));
    connect( backupAct, SIGNAL(triggered()), this, SLOT(getBackup()));
    connect( shortcutAct, SIGNAL(triggered()), this, SLOT(shortcuts()));
    connect( aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));

    hideAllWidgets();
    showMinimized();
}
Ejemplo n.º 8
0
wxString mmBudgetingPanel::getItem(long item, long column)
{
    switch (column)
    {
    case COL_ICON:
        return " ";
    case COL_CATEGORY:
    {
        if (budget_[item].first < 0)
        {
            Model_Category::Data* category = Model_Category::instance().get(budget_[item].second);
            if (category) return category->CATEGNAME;
        }
        else
        {
            Model_Category::Data* category = Model_Category::instance().get(budget_[item].first);
            if (category) return category->CATEGNAME;
        }
        return wxEmptyString;
    }
    case COL_SUBCATEGORY:
    {
        if (budget_[item].first >= 0)
        {
            Model_Subcategory::Data* subcategory = Model_Subcategory::instance().get(budget_[item].second);
            if (subcategory) return subcategory->SUBCATEGNAME;
        }
        return wxEmptyString;
    }
    case COL_FREQUENCY:
    {
        if (budget_[item].first >= 0)
            return Model_Budget::all_period()[budgetPeriod_[budget_[item].first][budget_[item].second]];
        return wxEmptyString;
    }
    case COL_AMOUNT:
    {
        if (budget_[item].first >= 0)
        {
            double amt = budgetAmt_[budget_[item].first][budget_[item].second];
            return Model_Currency::toCurrency(amt);
        }
        return wxEmptyString;
    }
    case COL_ESTIMATED:
    {
        if (budget_[item].first < 0)
        {
            double estimated = budgetTotals_[budget_[item].second].first;
            return Model_Currency::toCurrency(estimated);
        }
        else
        {
            double estimated = getEstimate(budget_[item].first, budget_[item].second);
            return Model_Currency::toCurrency(estimated);
        }
    }
    case COL_ACTUAL:
    {
        if (budget_[item].first < 0)
        {
            double actual = budgetTotals_[budget_[item].second].second;
            return Model_Currency::toCurrency(actual);
        }
        else
        {
            double actual = categoryStats_[budget_[item].first][budget_[item].second][0];
            return Model_Currency::toCurrency(actual);
        }
    }
    default:
        return wxEmptyString;
    }
}
Ejemplo n.º 9
0
void mmBudgetingPanel::initVirtualListControl()
{
    budget_.clear();
    budgetTotals_.clear();
    budgetPeriod_.clear();
    budgetAmt_.clear();
    categoryStats_.clear();
    double estIncome = 0.0;
    double estExpenses = 0.0;
    double actIncome = 0.0;
    double actExpenses = 0.0;
    mmReportBudget budgetDetails;

    bool evaluateTransfer = false;
    if (mmIniOptions::instance().budgetIncludeTransfers_)
    {
        evaluateTransfer = true;
    }

    currentView_ = Model_Infotable::instance().GetStringInfo("BUDGET_FILTER", VIEW_ALL);
    const wxString budgetYearStr = Model_Budgetyear::instance().Get(budgetYearID_);
    long year = 0;
    budgetYearStr.ToLong(&year);
    wxDateTime dtBegin(1, wxDateTime::Jan, year);
    wxDateTime dtEnd(31, wxDateTime::Dec, year);

    monthlyBudget_ = (budgetYearStr.length() > 5);

    if (monthlyBudget_)
    {
        budgetDetails.SetBudgetMonth(budgetYearStr, dtBegin, dtEnd);
    }
    else
    {
        int day = -1, month = -1;
        budgetDetails.AdjustYearValues(day, month, dtBegin);
        budgetDetails.AdjustDateForEndFinancialYear(dtEnd);
    }
    mmSpecifiedRange date_range(dtBegin, dtEnd);
    //Get statistics
    Model_Budget::instance().getBudgetEntry(budgetYearID_, budgetPeriod_, budgetAmt_);
    Model_Category::instance().getCategoryStats(categoryStats_
        , &date_range, mmIniOptions::instance().ignoreFutureTransactions_
        , false, true, (evaluateTransfer ? &budgetAmt_ : 0));

    const Model_Subcategory::Data_Set& allSubcategories = Model_Subcategory::instance().all(Model_Subcategory::COL_SUBCATEGNAME);
    for (const auto& category : Model_Category::instance().all(Model_Category::COL_CATEGNAME))
    {
        double estimated = getEstimate(category.CATEGID, -1);
        if (estimated < 0)
            estExpenses += estimated;
        else
            estIncome += estimated;

        double actual = 0;
        if (currentView_ != VIEW_PLANNED || estimated != 0)
        {
            actual = categoryStats_[category.CATEGID][-1][0];
            if (actual < 0)
                actExpenses += actual;
            else
                actIncome += actual;
        }

        /***************************************************************************
         Create a TOTALS entry for the category.
         ***************************************************************************/
        double catTotalsEstimated = estimated;
        double catTotalsActual = actual;

        if (DisplayEntryAllowed(category.CATEGID, -1))
            budget_.push_back(std::make_pair(category.CATEGID, -1));

        for (const auto& subcategory : allSubcategories)
        {
            if (subcategory.CATEGID != category.CATEGID) continue;

            estimated = getEstimate(category.CATEGID, subcategory.SUBCATEGID);
            if (estimated < 0)
                estExpenses += estimated;
            else
                estIncome += estimated;

            actual = 0;
            if (currentView_ != VIEW_PLANNED || estimated != 0)
            {
                actual = categoryStats_[category.CATEGID][subcategory.SUBCATEGID][0];
                if (actual < 0)
                    actExpenses += actual;
                else
                    actIncome += actual;
            }
    
            /***************************************************************************
             Update the TOTALS entry for the subcategory.
            ***************************************************************************/
            catTotalsEstimated += estimated;
            catTotalsActual += actual;

            if (DisplayEntryAllowed(category.CATEGID, subcategory.SUBCATEGID))
                budget_.push_back(std::make_pair(category.CATEGID, subcategory.SUBCATEGID));
        }

        budgetTotals_[category.CATEGID].first = catTotalsEstimated;
        budgetTotals_[category.CATEGID].second = catTotalsActual;

        if ((!mmIniOptions::instance().budgetSetupWithoutSummaries_ || currentView_ == VIEW_SUMM)
            && DisplayEntryAllowed(-1, category.CATEGID))
        {
            budget_.push_back(std::make_pair(-1, category.CATEGID));
            int transCatTotalIndex = (int)budget_.size() - 1;
            listCtrlBudget_->RefreshItem(transCatTotalIndex);
        }
    }

    listCtrlBudget_->SetItemCount((int)budget_.size());

    wxString est_amount, act_amount, diff_amount;
    est_amount = Model_Currency::toCurrency(estIncome);
    act_amount = Model_Currency::toCurrency(actIncome);
    diff_amount = Model_Currency::toCurrency(estIncome - actIncome);

    income_estimated_->SetLabelText(est_amount);
    income_actual_->SetLabelText(act_amount);
    income_diff_->SetLabelText(diff_amount);

    if (estExpenses < 0.0) estExpenses = -estExpenses;
    if (actExpenses < 0.0) actExpenses = -actExpenses;
    est_amount = Model_Currency::toCurrency(estExpenses);
    act_amount = Model_Currency::toCurrency(actExpenses);
    diff_amount = Model_Currency::toCurrency(estExpenses - actExpenses);

    expenses_estimated_->SetLabelText(est_amount);
    expenses_actual_->SetLabelText(act_amount);
    expenses_diff_->SetLabelText(diff_amount);
    UpdateBudgetHeading();
}