1 /*******************************************************
2  Copyright (C) 2013,2014 James Higley
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  ********************************************************/
18 
19 #ifndef MODEL_BUDGET_H
20 #define MODEL_BUDGET_H
21 
22 #include "Model.h"
23 #include "db/DB_Table_Budgettable_V1.h"
24 
25 class Model_Budget : public Model<DB_Table_BUDGETTABLE_V1>
26 {
27 public:
28     Model_Budget();
29     ~Model_Budget();
30 
31 public:
32     /**
33     Initialize the global Model_Budget table on initial call.
34     Resets the global table on subsequent calls.
35     * Return the static instance address for Model_Budget table
36     * Note: Assigning the address to a local variable can destroy the instance.
37     */
38     static Model_Budget& instance(wxSQLite3Database* db);
39 
40     /**
41     * Return the static instance address for Model_Budget table
42     * Note: Assigning the address to a local variable can destroy the instance.
43     */
44     static Model_Budget& instance();
45 
46 public:
47     enum PERIOD_ENUM { NONE = 0, WEEKLY, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, HALFYEARLY, YEARLY, DAILY };
48     static const std::vector<std::pair<PERIOD_ENUM, wxString> > PERIOD_ENUM_CHOICES;
49 
50     static wxArrayString all_period();
51     static PERIOD_ENUM period(const Data* r);
52     static PERIOD_ENUM period(const Data& r);
53     static DB_Table_BUDGETTABLE_V1::PERIOD PERIOD(PERIOD_ENUM period, OP op = EQUAL);
54 
55     static void getBudgetEntry(int budgetYearID, std::map<int,
56         std::map<int, PERIOD_ENUM> > &budgetPeriod,
57         std::map<int, std::map<int, double> > &budgetAmt);
58     static void copyBudgetYear(int newYearID, int baseYearID);
59     static double getMonthlyEstimate(const PERIOD_ENUM period, const double amount);
60     static double getYearlyEstimate(const PERIOD_ENUM period, const double amount);
61 };
62 
63 #endif //
64