1 /*******************************************************
2  Copyright (C) 2013,2014 Guan Lisheng (guanlisheng@gmail.com)
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_SPLITTRANSACTIONS_H
20 #define MODEL_SPLITTRANSACTIONS_H
21 
22 #include "Model.h"
23 #include "Model_Currency.h"
24 #include "db/DB_Table_Splittransactions_V1.h"
25 
26 struct Split
27 {
28     int CATEGID;
29     int SUBCATEGID;
30     double SPLITTRANSAMOUNT;
31 };
32 
33 class Model_Splittransaction : public Model<DB_Table_SPLITTRANSACTIONS_V1>
34 {
35 public:
36     Model_Splittransaction();
37     ~Model_Splittransaction();
38 
39 public:
40     /**
41     Initialize the global Model_Splittransaction table on initial call.
42     Resets the global table on subsequent calls.
43     * Return the static instance address for Model_Splittransaction table
44     * Note: Assigning the address to a local variable can destroy the instance.
45     */
46     static Model_Splittransaction& instance(wxSQLite3Database* db);
47 
48     /**
49     * Return the static instance address for Model_Splittransaction table
50     * Note: Assigning the address to a local variable can destroy the instance.
51     */
52     static Model_Splittransaction& instance();
53 
54 public:
55     static double get_total(const Data_Set& rows);
56     static double get_total(const std::vector<Split>& local_splits);
57     static const wxString get_tooltip(const std::vector<Split>& local_splits, const Model_Currency::Data* currency);
58     std::map<int, Model_Splittransaction::Data_Set> get_all();
59     int update(const Data_Set& rows, int transactionID);
60 };
61 
62 #endif //
63