/**
    File        : Base.h
    Description : Base classes
    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 BASE_H_INCLUDED
#define BASE_H_INCLUDED

#include <wx/string.h>
#include <wx/arrstr.h>
#include <vector>

typedef unsigned long ULONG;

class wxDialog;
class wxDynamicLibrary;
class wxMenuBar;
class wxToolBar;
class wxEvtHandler;
class CAccountBase;

enum TRANSACTIONTYPE
{
    TT_NONE         = 9050,
    TT_START,
    TT_DEPOSIT,
    TT_TRANSFER,
    TT_ATM,
    TT_DEBIT,
    TT_CHECK
};

enum TRANSACTIONSTATUS
{
    TS_OPEN         = 9075,
    TS_CLEARED,
    TS_RECONCILED
};

enum REOCCURINGLISTTYPE
{
    RT_DEBIT        = 9100,
    RT_DEPOSIT,
    RT_TRANSFER
};

enum OCCURANCE
{
    BO_NONE         = 9125,
    BO_ONCE,
    BO_DAILY,
    BO_WEEKLY,
    BO_BIWEEKLY,
    BO_TWICEMONTHLY,
    BO_MONTHLY,
    BO_QUARTERLY,
    BO_TWICEANNUALLY,
    BO_ANNUALLY
};

enum SEARCHTYPE
{
    ST_DATE         = 9150,
    ST_DATERANGE,
    ST_CHECK,
    ST_CHECKRANGE,
    ST_TRANSACTIONTYPE,
    ST_PAYEE,
    ST_CATEGORY
};

enum LANGUAGES
{
    LA_ENGLISH      = 0,
};




struct STransaction
{
    ULONG                  TransactionNumber;
    ULONG                  TransferNumber;
    wxString               AccountName;
    wxString               TransferAccount;
    CAccountBase*          pTransferAccount;
    wxString               Date;
    ULONG                  Type;
    ULONG                  CheckNumber;
    wxString               Payee;
    double                 Amount;
    wxString               Category;
    wxString               SubCategory;
    wxString               Comment;
    ULONG                  Status;
    bool                   IsDeposit;
    double                 Balance;
    std::vector<wxString>  ImageFileNames;
};

struct SAccountInfo
{
    wxString  AccountName;
    wxString  AccountNumber;
    wxString  AccountType;
    wxString  BankName;
    wxString  BankPhoneNumber;
    double    Balance;
    wxString  DateOpened;
    double    OpeningBalance;
    double    LastStatementBalance;
    wxString  LastStatementDate;
};

struct SReoccuringTransaction
{
    ULONG               Number;
    wxString            Name;
    ULONG               Type;
    ULONG               Frequency;
    wxString            NextOccurance;
    wxString            LastOccurance;
    double              EstAmount;
    double              LastAmount;
    ULONG               TransactionType;
    wxString            PayFromAccountName;
    wxString            DepositToAccountName;
    wxString            Category;
    wxString            SubCategory;
};

struct SBalanceInfo
{
    wxString    EndDate;
    wxString    EndBalance;
    wxString    ServiceCharge;
    wxString    InterestPaid;
    bool        IsServiceCharge;
    bool        IsInterestPaid;
};

struct SSearchCriteria
{
    SEARCHTYPE  SearchType;
    wxString    SearchStringOne;
    wxString    SearchStringTwo;
};



class CAccountBase
{
    public:
    virtual ~CAccountBase() { }
    virtual const wxString GetAccountName()                                 = 0;
    virtual bool SaveTransaction(STransaction, const bool = false, const bool = true) = 0;
    virtual ULONG GetNextTransactionNumber()                                = 0;
    virtual void StopBalancing()                                            = 0;
    virtual void ResetTransactionCounter()                                  = 0;
    virtual bool HasMoreTransactions()                                      = 0;
    virtual const STransaction& GetNextTransaction()                        = 0;
    virtual void BalancingAccountFinished(wxString)                         = 0;
    virtual SAccountInfo GetAccountInfo()                                   = 0;
    virtual void DeleteTransaction(const ULONG, const bool)                 = 0;
};

class CAccountManagerBase
{
    public:
    virtual ~CAccountManagerBase() { }
    virtual bool RecordTransaction(STransaction)                            = 0;
    virtual bool SaveAccountsToDisk()                                       = 0;
    virtual const int GetNumberOfAccounts() const                           = 0;
    virtual const wxArrayString& GetAccountNames()                          = 0;
    virtual const ULONG GetNextTransferNumber()                             = 0;
    virtual const ULONG GetLastTransferNumber() const                       = 0;
    virtual void SetLastTransferNumber(ULONG)                               = 0;
    virtual void TransferFunds(const STransaction)                          = 0;
    virtual ULONG SelectAccount(wxString*, wxString)                        = 0;
    virtual CAccountBase* GetAccountByName(wxString)                        = 0;
    virtual void SetPageLabel(size_t& PageNum, wxString& Label)             =0;
    virtual size_t GetNewPageNum()                                          = 0;
};

class CDataBase
{
    public:
    virtual ~CDataBase() { }
    virtual bool Initialize()                                               = 0;
    virtual bool AddNewCategory(const wxString&)                            = 0;
    virtual bool AddNewSubCategory(const wxString&, const wxString&)        = 0;
    virtual bool SaveCategories()                                           = 0;
    virtual bool VerifyCorrectAmountFormat(wxString&)                       = 0;
    virtual bool IsDeposit(const wxString)                                  = 0;
    virtual bool IsDeposit(const TRANSACTIONTYPE type)                      = 0;

    virtual bool GetAllAccountTypes(wxArrayString&)                         = 0;
    virtual const wxString GetAccountTypeString(const ULONG)                = 0;
    virtual const ULONG GetAccountTypeValue(const wxString&)                = 0;

    virtual void AddNewAccountType(wxString)                                = 0;
    virtual const ULONG GetNewAccountTypeValue()                            = 0;

    virtual bool GetAllTransactionTypes(wxArrayString&, const bool)         = 0;
    virtual const wxString GetTransactionTypeString(const ULONG)            = 0;
    virtual const ULONG GetTransactionTypeValue(const wxString&)            = 0;

    virtual bool GetAllTransactionStatuses(wxArrayString&)                  = 0;
    virtual const wxString GetTransactionStatusString(const ULONG)          = 0;
    virtual const ULONG GetTransactionStatusValue(const wxString&)          = 0;

    virtual bool GetAllReoccuringTypes(wxArrayString&)                      = 0;
    virtual const wxString GetReoccuringTypeString(const ULONG)             = 0;
    virtual const ULONG GetReoccuringTypeValue(const wxString&)             = 0;

    virtual bool GetAllFrequencyTypes(wxArrayString&, bool)                 = 0;
    virtual const wxString GetFrequencyTypeString(const ULONG)              = 0;
    virtual const ULONG GetFrequencyTypeValue(const wxString&)              = 0;

    virtual bool GetAllCategories(wxArrayString&)                           = 0;
    virtual bool GetAllSubCategories(const wxString&, wxArrayString&)       = 0;
};



#endif // BASE_H_INCLUDED
