/**
    File        : BalanceAccount.h
    Description : Classes to balance an account
    Author      : Raymond Marsh
    Created     : 08/01/2009
    Copyright 2009, 2010 Raymond Marsh

    This program is distributed under the terms of the GNU General Public License.
    To view a copy of the license see the file 'copying.txt'

    This file is part of the Ace Personal Finance Assistant Suite.

    Ace Personal Finance Assistant is free software: you can redistribute it and/or modify it under
    the terms of the GNU General Public License as published by the Free Software Foundation, either
    version 3 of the License, or (at your option) any later version.

    Ace Personal Finance Assistant is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with Ace Personal Finance Assistant.
    If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef BALANCEACCOUNT_H_INCLUDED
#define BALANCEACCOUNT_H_INCLUDED

#include <wx/dialog.h>
#include <wx/string.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/datectrl.h>
#include <wx/stattext.h>
#include <wx/statline.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/valtext.h>
#include <wx/valgen.h>
#include "Base.h"
#include "Data.h"
#include "Dialogs.h"

class CAccount;

class CBalanceDlg : public wxDialog
{
    public:
    CBalanceDlg(wxWindow* pParent, /*ace::CData* pData, */SBalanceInfo &BalanceInfo);
    ~CBalanceDlg() { }

    private:
    // id's
    enum
    {
        idEndDateCtrl = 300,
        idEndBalanceCtrl,
        idServiceChargeCtrl,
        idInterestPaidCtrl,
        idServiceChargeBtn,
        idInterestPaidBtn,
    };
    // event handlers
    void OnContinue(wxCommandEvent &event);
    void OnCancel(wxCommandEvent &event);
    void OnServiceChargeBtnSelected(wxCommandEvent &event);
    void OnInterestPaidBtnSelected(wxCommandEvent &event);

    // child controls
    wxDatePickerCtrl*    m_pEndDateCtrl;
    wxTextCtrl*          m_pEndBalanceCtrl;
    wxTextCtrl*          m_pServiceChargeCtrl;
    wxTextCtrl*          m_pInterestPaidCtrl;
    wxCheckBox*          m_pServiceChargeBtn;
    wxCheckBox*          m_pInterestPaidBtn;

    // private data
    wxWindow*            m_pParent;
//    ace::CData*          m_pData;
    SBalanceInfo*        m_pBalanceInfo;
};

class CBalancePanel : public wxPanel
{
    public:
    CBalancePanel(wxWindow* pParent, CAccountBase* pAccount, SBalanceInfo& BalanceInfo);
    ~CBalancePanel() { }
    void UpdateBalancingStatus(const double Amount, const bool IsDeposit, const bool IsCleared, const bool IsEdit);

    private:
    // id's
    enum
    {
        idStatementDateCtrl = 320,
        idStatementBalanceCtrl,
        idClearedTransactionsCtrl,
        idClearedAmountCtrl,
        idDifferenceCtrl,
    };
    // event handlers
    void OnFinish(wxCommandEvent &event);
    void OnCancel(wxCommandEvent &event);

    // child controls
    wxTextCtrl*          m_pClearedTransactionsCtrl;
    wxTextCtrl*          m_pClearedAmountCtrl;
    wxTextCtrl*          m_pDifferenceCtrl;

    // private data
    wxWindow*            m_pParent;
    CAccountBase*        m_pAccount;
    SBalanceInfo*        m_pBalanceInfo;
    double               m_StatementBalance;
    double               m_ClearedAmount;
    double               m_Difference;
    ULONG                m_ClearedTransactions;
};

#endif // BALANCEACCOUNT_H_INCLUDED
