Add blocked account (mainly for statistics)

Really fix the previous bug
This commit is contained in:
Grégory Soutadé 2010-11-01 11:34:39 +01:00
parent 7af9f1d9c2
commit 0832e020c4
11 changed files with 220 additions and 130 deletions

View File

@ -1,6 +1,6 @@
CREATE TABLE kisscount(db_version VARCHAR(20));
CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255), password VARCHAR(255));
CREATE TABLE account(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), number VARCHAR(255), shared CHAR(1), default_account CHAR(1));
CREATE TABLE account(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), number VARCHAR(255), shared CHAR(1), blocked CHAR(1), default_account CHAR(1));
CREATE TABLE shared_account(account REFERENCES account(id), user REFERENCES user(id));
CREATE TABLE account_amount(id INTEGER PRIMARY KEY, account REFERENCES account(id), year INTEGER, month INTEGER, amount FLOAT);
CREATE TABLE operation(id INTEGER PRIMARY KEY, parent REFERENCES operation(id), user REFERENCES user(id), account REFERENCES account(id), year INTEGER, month INTEGER, day INTEGER, amount FLOAT, description VARCHAR(255), category REFERENCES category(id), fix_cost CHAR(1), checked CHAR(1), formula VARCHAR(255), transfert REFERENCES operation(id), meta CHAR(1));

Binary file not shown.

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-10-30 20:31+0200\n"
"POT-Creation-Date: 2010-11-01 11:34+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Soutadé <soutade@gmail.com>\n"
"Language-Team: \n"
@ -20,20 +20,20 @@ msgstr ""
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: src/view/StatsPanel.cpp:282
#: src/view/PreferencesPanel.cpp:745
#: src/view/PreferencesPanel.cpp:767
msgid " - "
msgstr " - "
#: src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:406
#: src/view/PreferencesPanel.cpp:425
#: src/view/PreferencesPanel.cpp:638
#: src/view/PreferencesPanel.cpp:657
#: src/view/PreferencesPanel.cpp:703
#: src/view/PreferencesPanel.cpp:420
#: src/view/PreferencesPanel.cpp:439
#: src/view/PreferencesPanel.cpp:660
#: src/view/PreferencesPanel.cpp:679
#: src/view/PreferencesPanel.cpp:725
msgid " already exists"
msgstr " existe déjà "
#: src/view/SearchPanel.cpp:227
#: src/view/SearchPanel.cpp:222
msgid " entries found"
msgstr " entrées trouvées"
@ -41,11 +41,11 @@ msgstr " entrées trouvées"
msgid " not found, aborting"
msgstr " non trouvé, arrêt"
#: src/view/AccountPanel.cpp:709
#: src/view/AccountPanel.cpp:727
msgid " operations ?"
msgstr " opérations ?"
#: src/view/PreferencesPanel.cpp:752
#: src/view/PreferencesPanel.cpp:774
msgid " profil ?"
msgstr " profil ?"
@ -53,7 +53,7 @@ msgstr " profil ?"
msgid "!! Warning !! If there was a bug, the old database will be suppressed !"
msgstr "!! Attention !! S'il y a eu un bug, l'ancienne base de donnée va être supprimée !"
#: src/view/SearchPanel.cpp:229
#: src/view/SearchPanel.cpp:224
msgid "1 entry found"
msgstr "1 entrée trouvée"
@ -66,8 +66,8 @@ msgstr "A propos"
msgid "Account"
msgstr "Compte"
#: src/view/PreferencesPanel.cpp:406
#: src/view/PreferencesPanel.cpp:425
#: src/view/PreferencesPanel.cpp:420
#: src/view/PreferencesPanel.cpp:439
msgid "Account "
msgstr "Le compte "
@ -92,25 +92,29 @@ msgstr "Montant min"
msgid "Amount to"
msgstr "Montant max"
#: src/view/PreferencesPanel.cpp:387
#: src/view/PreferencesPanel.cpp:752
#: src/view/AccountPanel.cpp:704
#: src/view/PreferencesPanel.cpp:401
#: src/view/PreferencesPanel.cpp:774
#: src/view/AccountPanel.cpp:722
msgid "Are you sure want to delete "
msgstr "Etes vous sûr de vouloir supprimer "
#: src/view/PreferencesPanel.cpp:619
#: src/view/PreferencesPanel.cpp:641
#: src/view/grid/GridAccount.cpp:760
msgid "Are you sure want to delete : \n"
msgstr "Etes vous sûr de vouloir supprimer : \n"
#: src/view/PreferencesPanel.cpp:308
#: src/view/PreferencesPanel.cpp:315
msgid "Ascending"
msgstr "Croissant"
#: src/view/PreferencesPanel.cpp:247
#: src/view/PreferencesPanel.cpp:254
msgid "Background color"
msgstr "Couleur d'arrière plan"
#: src/view/PreferencesPanel.cpp:187
msgid "Blocked"
msgstr "Bloqué"
#: src/view/SearchPanel.cpp:76
msgid "Both"
msgstr "Les deux"
@ -140,8 +144,8 @@ msgstr "Catégories"
msgid "Category"
msgstr "Catégorie"
#: src/view/PreferencesPanel.cpp:638
#: src/view/PreferencesPanel.cpp:657
#: src/view/PreferencesPanel.cpp:660
#: src/view/PreferencesPanel.cpp:679
msgid "Category "
msgstr "Catégorie"
@ -210,13 +214,13 @@ msgstr "Débit"
msgid "Default"
msgstr "Défaut"
#: src/view/PreferencesPanel.cpp:187
#: src/view/PreferencesPanel.cpp:250
#: src/view/AccountPanel.cpp:563
#: src/view/PreferencesPanel.cpp:188
#: src/view/PreferencesPanel.cpp:257
#: src/view/AccountPanel.cpp:578
msgid "Delete"
msgstr "Supprimer"
#: src/view/PreferencesPanel.cpp:309
#: src/view/PreferencesPanel.cpp:316
msgid "Descending"
msgstr "Décroissant"
@ -231,16 +235,16 @@ msgstr "Description"
#: src/view/SearchPanel.cpp:150
#: src/view/SearchPanel.cpp:164
#: src/view/SearchPanel.cpp:175
#: src/view/PreferencesPanel.cpp:383
#: src/view/PreferencesPanel.cpp:406
#: src/view/PreferencesPanel.cpp:425
#: src/view/PreferencesPanel.cpp:638
#: src/view/PreferencesPanel.cpp:657
#: src/view/PreferencesPanel.cpp:697
#: src/view/PreferencesPanel.cpp:703
#: src/view/PreferencesPanel.cpp:397
#: src/view/PreferencesPanel.cpp:420
#: src/view/PreferencesPanel.cpp:439
#: src/view/PreferencesPanel.cpp:660
#: src/view/PreferencesPanel.cpp:679
#: src/view/PreferencesPanel.cpp:719
#: src/view/PreferencesPanel.cpp:725
#: src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78
#: src/view/AccountPanel.cpp:700
#: src/view/AccountPanel.cpp:718
#: src/view/grid/GridAccount.cpp:1144
#: src/view/grid/GridAccount.cpp:1151
#: src/view/grid/GridAccount.cpp:1280
@ -267,16 +271,16 @@ msgstr "Valeur finale"
#: src/view/SearchPanel.cpp:76
#: src/view/grid/GridAccount.cpp:300
#: src/model/Database.cpp:329
#: src/model/Database.cpp:331
#: src/controller/KissCount.cpp:335
msgid "Fix"
msgstr "Fixe"
#: src/view/PreferencesPanel.cpp:249
#: src/view/PreferencesPanel.cpp:256
msgid "Font"
msgstr "Police"
#: src/view/PreferencesPanel.cpp:248
#: src/view/PreferencesPanel.cpp:255
msgid "Foreground color"
msgstr "Couleur d'avant plan"
@ -289,7 +293,7 @@ msgid "From "
msgstr "A partir de "
#: src/view/GenerateDialog.cpp:31
#: src/view/AccountPanel.cpp:560
#: src/view/AccountPanel.cpp:575
msgid "Generate month"
msgstr "Générer mois"
@ -329,7 +333,7 @@ msgstr "Intervalle de temps invalide"
msgid "Invalid formula !"
msgstr "Formule invalide !"
#: src/view/PreferencesPanel.cpp:697
#: src/view/PreferencesPanel.cpp:719
msgid "Invalid name"
msgstr "Nom invalide"
@ -345,11 +349,11 @@ msgstr "Mot de passe invalide"
msgid "Invalide date range"
msgstr "Intervalle de temps invalide"
#: src/view/PreferencesPanel.cpp:383
#: src/view/PreferencesPanel.cpp:397
msgid "It must be at least one account !"
msgstr "Il doit y avoir au moins un compte !"
#: src/view/AccountPanel.cpp:700
#: src/view/AccountPanel.cpp:718
msgid "It must be at least one month !"
msgstr "Il doit rester au mois un mois"
@ -358,8 +362,8 @@ msgid "Kill me"
msgstr "Kill me"
#: src/view/StatsPanel.cpp:302
#: src/view/PreferencesPanel.cpp:737
#: src/view/PreferencesPanel.cpp:740
#: src/view/PreferencesPanel.cpp:759
#: src/view/PreferencesPanel.cpp:762
msgid "KissCount"
msgstr "KissCount"
@ -367,21 +371,21 @@ msgstr "KissCount"
msgid "Language"
msgstr "Langue"
#: src/view/PreferencesPanel.cpp:740
#: src/view/PreferencesPanel.cpp:762
msgid "Language not changed"
msgstr "Langue non changée"
#: src/view/PreferencesPanel.cpp:737
#: src/view/PreferencesPanel.cpp:759
msgid "Language successfully changed, please go to another panel"
msgstr "Langue changée, allez sur un autre panneau pour rendre le changement effectif"
#: src/view/PreferencesPanel.cpp:71
#: src/view/PreferencesPanel.cpp:184
#: src/view/PreferencesPanel.cpp:246
#: src/view/PreferencesPanel.cpp:253
msgid "Name"
msgstr "Nom"
#: src/view/PreferencesPanel.cpp:709
#: src/view/PreferencesPanel.cpp:731
msgid "Name changed"
msgstr "Nom changé"
@ -402,7 +406,7 @@ msgstr ""
"Aucune base de données trouvée, voulez vous en créer une nouvelle ?\n"
"\n"
#: src/view/SearchPanel.cpp:232
#: src/view/SearchPanel.cpp:227
msgid "No entry found"
msgstr "Pas d'entrée trouvée"
@ -467,8 +471,8 @@ msgstr ""
msgid "Please retype new password"
msgstr "Re entrez le mot de passe"
#: src/view/PreferencesPanel.cpp:711
#: src/view/PreferencesPanel.cpp:745
#: src/view/PreferencesPanel.cpp:733
#: src/view/PreferencesPanel.cpp:767
#: src/view/ButtonPanel.cpp:72
msgid "Preferences"
msgstr "Préférences"
@ -490,7 +494,7 @@ msgid "Remains"
msgstr "Restant"
#: src/view/SearchPanel.cpp:83
#: src/view/SearchPanel.cpp:243
#: src/view/SearchPanel.cpp:238
#: src/view/ButtonPanel.cpp:71
msgid "Search"
msgstr "Chercher"
@ -542,7 +546,7 @@ msgstr "Exceptionnel"
#: src/model/User.cpp:52
#: src/model/User.cpp:72
#: src/model/User.cpp:112
#: src/model/User.cpp:120
msgid "Unknown"
msgstr "Inconnu"
@ -556,7 +560,7 @@ msgstr "Utilisateur"
#: src/view/UsersDialog.cpp:38
#: src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:703
#: src/view/PreferencesPanel.cpp:725
msgid "User "
msgstr "Utilisateur"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-10-30 20:52+0200\n"
"POT-Creation-Date: 2010-11-01 11:34+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,17 +17,17 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/view/StatsPanel.cpp:282 src/view/PreferencesPanel.cpp:745
#: src/view/StatsPanel.cpp:282 src/view/PreferencesPanel.cpp:767
msgid " - "
msgstr ""
#: src/view/UsersDialog.cpp:118 src/view/PreferencesPanel.cpp:406
#: src/view/PreferencesPanel.cpp:425 src/view/PreferencesPanel.cpp:638
#: src/view/PreferencesPanel.cpp:657 src/view/PreferencesPanel.cpp:703
#: src/view/UsersDialog.cpp:118 src/view/PreferencesPanel.cpp:420
#: src/view/PreferencesPanel.cpp:439 src/view/PreferencesPanel.cpp:660
#: src/view/PreferencesPanel.cpp:679 src/view/PreferencesPanel.cpp:725
msgid " already exists"
msgstr ""
#: src/view/SearchPanel.cpp:227
#: src/view/SearchPanel.cpp:222
msgid " entries found"
msgstr ""
@ -35,11 +35,11 @@ msgstr ""
msgid " not found, aborting"
msgstr ""
#: src/view/AccountPanel.cpp:709
#: src/view/AccountPanel.cpp:727
msgid " operations ?"
msgstr ""
#: src/view/PreferencesPanel.cpp:752
#: src/view/PreferencesPanel.cpp:774
msgid " profil ?"
msgstr ""
@ -47,7 +47,7 @@ msgstr ""
msgid "!! Warning !! If there was a bug, the old database will be suppressed !"
msgstr ""
#: src/view/SearchPanel.cpp:229
#: src/view/SearchPanel.cpp:224
msgid "1 entry found"
msgstr ""
@ -59,7 +59,7 @@ msgstr ""
msgid "Account"
msgstr ""
#: src/view/PreferencesPanel.cpp:406 src/view/PreferencesPanel.cpp:425
#: src/view/PreferencesPanel.cpp:420 src/view/PreferencesPanel.cpp:439
msgid "Account "
msgstr ""
@ -83,23 +83,27 @@ msgstr ""
msgid "Amount to"
msgstr ""
#: src/view/PreferencesPanel.cpp:387 src/view/PreferencesPanel.cpp:752
#: src/view/AccountPanel.cpp:704
#: src/view/PreferencesPanel.cpp:401 src/view/PreferencesPanel.cpp:774
#: src/view/AccountPanel.cpp:722
msgid "Are you sure want to delete "
msgstr ""
#: src/view/PreferencesPanel.cpp:619 src/view/grid/GridAccount.cpp:760
#: src/view/PreferencesPanel.cpp:641 src/view/grid/GridAccount.cpp:760
msgid "Are you sure want to delete : \n"
msgstr ""
#: src/view/PreferencesPanel.cpp:308
#: src/view/PreferencesPanel.cpp:315
msgid "Ascending"
msgstr ""
#: src/view/PreferencesPanel.cpp:247
#: src/view/PreferencesPanel.cpp:254
msgid "Background color"
msgstr ""
#: src/view/PreferencesPanel.cpp:187
msgid "Blocked"
msgstr ""
#: src/view/SearchPanel.cpp:76
msgid "Both"
msgstr ""
@ -125,7 +129,7 @@ msgstr ""
msgid "Category"
msgstr ""
#: src/view/PreferencesPanel.cpp:638 src/view/PreferencesPanel.cpp:657
#: src/view/PreferencesPanel.cpp:660 src/view/PreferencesPanel.cpp:679
msgid "Category "
msgstr ""
@ -193,12 +197,12 @@ msgstr ""
msgid "Default"
msgstr ""
#: src/view/PreferencesPanel.cpp:187 src/view/PreferencesPanel.cpp:250
#: src/view/AccountPanel.cpp:563
#: src/view/PreferencesPanel.cpp:188 src/view/PreferencesPanel.cpp:257
#: src/view/AccountPanel.cpp:578
msgid "Delete"
msgstr ""
#: src/view/PreferencesPanel.cpp:309
#: src/view/PreferencesPanel.cpp:316
msgid "Descending"
msgstr ""
@ -209,11 +213,11 @@ msgstr ""
#: src/view/UsersDialog.cpp:88 src/view/UsersDialog.cpp:118
#: src/view/SearchPanel.cpp:140 src/view/SearchPanel.cpp:150
#: src/view/SearchPanel.cpp:164 src/view/SearchPanel.cpp:175
#: src/view/PreferencesPanel.cpp:383 src/view/PreferencesPanel.cpp:406
#: src/view/PreferencesPanel.cpp:425 src/view/PreferencesPanel.cpp:638
#: src/view/PreferencesPanel.cpp:657 src/view/PreferencesPanel.cpp:697
#: src/view/PreferencesPanel.cpp:703 src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:700
#: src/view/PreferencesPanel.cpp:397 src/view/PreferencesPanel.cpp:420
#: src/view/PreferencesPanel.cpp:439 src/view/PreferencesPanel.cpp:660
#: src/view/PreferencesPanel.cpp:679 src/view/PreferencesPanel.cpp:719
#: src/view/PreferencesPanel.cpp:725 src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:718
#: src/view/grid/GridAccount.cpp:1144 src/view/grid/GridAccount.cpp:1151
#: src/view/grid/GridAccount.cpp:1280 src/view/grid/GridAccount.cpp:1286
#: src/view/grid/wxGridCellFormulaEditor.cpp:69 src/model/Database.cpp:38
@ -233,15 +237,15 @@ msgid "Final value"
msgstr ""
#: src/view/SearchPanel.cpp:76 src/view/grid/GridAccount.cpp:300
#: src/model/Database.cpp:329 src/controller/KissCount.cpp:335
#: src/model/Database.cpp:331 src/controller/KissCount.cpp:335
msgid "Fix"
msgstr ""
#: src/view/PreferencesPanel.cpp:249
#: src/view/PreferencesPanel.cpp:256
msgid "Font"
msgstr ""
#: src/view/PreferencesPanel.cpp:248
#: src/view/PreferencesPanel.cpp:255
msgid "Foreground color"
msgstr ""
@ -253,7 +257,7 @@ msgstr ""
msgid "From "
msgstr ""
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:560
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:575
msgid "Generate month"
msgstr ""
@ -293,7 +297,7 @@ msgstr ""
msgid "Invalid formula !"
msgstr ""
#: src/view/PreferencesPanel.cpp:697
#: src/view/PreferencesPanel.cpp:719
msgid "Invalid name"
msgstr ""
@ -309,11 +313,11 @@ msgstr ""
msgid "Invalide date range"
msgstr ""
#: src/view/PreferencesPanel.cpp:383
#: src/view/PreferencesPanel.cpp:397
msgid "It must be at least one account !"
msgstr ""
#: src/view/AccountPanel.cpp:700
#: src/view/AccountPanel.cpp:718
msgid "It must be at least one month !"
msgstr ""
@ -321,8 +325,8 @@ msgstr ""
msgid "Kill me"
msgstr ""
#: src/view/StatsPanel.cpp:302 src/view/PreferencesPanel.cpp:737
#: src/view/PreferencesPanel.cpp:740
#: src/view/StatsPanel.cpp:302 src/view/PreferencesPanel.cpp:759
#: src/view/PreferencesPanel.cpp:762
msgid "KissCount"
msgstr ""
@ -330,20 +334,20 @@ msgstr ""
msgid "Language"
msgstr ""
#: src/view/PreferencesPanel.cpp:740
#: src/view/PreferencesPanel.cpp:762
msgid "Language not changed"
msgstr ""
#: src/view/PreferencesPanel.cpp:737
#: src/view/PreferencesPanel.cpp:759
msgid "Language successfully changed, please go to another panel"
msgstr ""
#: src/view/PreferencesPanel.cpp:71 src/view/PreferencesPanel.cpp:184
#: src/view/PreferencesPanel.cpp:246
#: src/view/PreferencesPanel.cpp:253
msgid "Name"
msgstr ""
#: src/view/PreferencesPanel.cpp:709
#: src/view/PreferencesPanel.cpp:731
msgid "Name changed"
msgstr ""
@ -361,7 +365,7 @@ msgid ""
"\n"
msgstr ""
#: src/view/SearchPanel.cpp:232
#: src/view/SearchPanel.cpp:227
msgid "No entry found"
msgstr ""
@ -419,7 +423,7 @@ msgstr ""
msgid "Please retype new password"
msgstr ""
#: src/view/PreferencesPanel.cpp:711 src/view/PreferencesPanel.cpp:745
#: src/view/PreferencesPanel.cpp:733 src/view/PreferencesPanel.cpp:767
#: src/view/ButtonPanel.cpp:72
msgid "Preferences"
msgstr ""
@ -440,7 +444,7 @@ msgstr ""
msgid "Remains"
msgstr ""
#: src/view/SearchPanel.cpp:83 src/view/SearchPanel.cpp:243
#: src/view/SearchPanel.cpp:83 src/view/SearchPanel.cpp:238
#: src/view/ButtonPanel.cpp:71
msgid "Search"
msgstr ""
@ -486,7 +490,7 @@ msgstr ""
msgid "Unexpected"
msgstr ""
#: src/model/User.cpp:52 src/model/User.cpp:72 src/model/User.cpp:112
#: src/model/User.cpp:52 src/model/User.cpp:72 src/model/User.cpp:120
msgid "Unknown"
msgstr ""
@ -499,7 +503,7 @@ msgid "User"
msgstr ""
#: src/view/UsersDialog.cpp:38 src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:703
#: src/view/PreferencesPanel.cpp:725
msgid "User "
msgstr ""

View File

@ -30,6 +30,7 @@ public:
wxString name;
wxString number;
bool shared;
bool blocked;
bool _default;
bool is_owner;
};

View File

@ -271,6 +271,7 @@ User* Database::LoadUser(const wxString& name)
account.name = set.GetAsString(wxT("name"));
account.number = set.GetAsString(wxT("number"));
account.shared = set.GetBool(wxT("shared"));
account.blocked = set.GetBool(wxT("blocked"));
account._default = set.GetBool(wxT("default_account"));
account.is_owner = true;
user->_accounts.push_back(account);
@ -287,6 +288,7 @@ User* Database::LoadUser(const wxString& name)
account.name = set.GetAsString(wxT("name"));
account.number = set.GetAsString(wxT("number"));
account.shared = set.GetBool(wxT("shared"));
account.blocked = set.GetBool(wxT("blocked"));
account._default = set.GetBool(wxT("default_account"));
account.is_owner = false;
user->_accounts.push_back(account);
@ -754,7 +756,7 @@ wxString Database::AddAccount(User* user, Account& ac)
{
wxString req;
req = wxT("INSERT INTO account ('user', 'name', 'number', 'shared', 'default_account') VALUES ('") ;
req = wxT("INSERT INTO account ('user', 'name', 'number', 'shared', 'blocked', 'default_account') VALUES ('") ;
req += user->_id + wxT("'");
req += wxT(", '") + ac.name + wxT("'");
req += wxT(", '") + ac.number + wxT("'");
@ -762,6 +764,10 @@ wxString Database::AddAccount(User* user, Account& ac)
req += wxT(", '1'") ;
else
req += wxT(", '0'") ;
if (ac.blocked)
req += wxT(", '1'") ;
else
req += wxT(", '0'") ;
if (ac._default)
req += wxT(", '1'") ;
else
@ -783,6 +789,10 @@ void Database::UpdateAccount(Account& ac)
req += wxT(", shared='1'");
else
req += wxT(", shared='0'");
if (ac.blocked)
req += wxT(", blocked='1'");
else
req += wxT(", blocked='0'");
if (ac._default)
req += wxT(", default_account='1'");
else
@ -1389,7 +1399,7 @@ void Database::GetStats(User* user, const wxString& monthFrom, const wxString& y
std::map<wxString, double>* categories)
{
wxSQLite3ResultSet set;
wxString req;
wxString req, req2;
std::vector<Account>::iterator accountIt;
std::vector<Category>::iterator categoryIt;
@ -1412,7 +1422,7 @@ void Database::GetStats(User* user, const wxString& monthFrom, const wxString& y
for (categoryIt = user->_categories.begin(); categoryIt != user->_categories.end(); categoryIt++)
{
req = wxT("SELECT SUM(amount) as amount FROM operation WHERE category='") + categoryIt->id + wxT("'");
req = wxT("SELECT SUM(amount) as amount FROM operation AS o1 WHERE category='") + categoryIt->id + wxT("'");
accountIt = user->_accounts.begin();
req += wxT(" AND (account IN('") + accountIt->id;
accountIt++;
@ -1425,17 +1435,31 @@ void Database::GetStats(User* user, const wxString& monthFrom, const wxString& y
req += wxT(" AND (year > '") + yearFrom + wxT("' OR (year == '") + yearFrom + wxT("' AND month >= '") + monthFrom + wxT("'))");
req += wxT(" AND (year < '") + yearTo + wxT("' OR (year == '") + yearTo + wxT("' AND month <= '") + monthTo + wxT("'))");
req += wxT(" AND (transfert='' OR transfert IS NULL)");
req += wxT(" AND amount < 0");
req += wxT(" AND meta='0'");
EXECUTE_SQL_QUERY(req, set, );
req2 = req + wxT(" AND (transfert='' OR transfert IS NULL)");
req2 += wxT(" AND amount < 0");
EXECUTE_SQL_QUERY(req2, set, );
if (set.NextRow())
{
(*categories)[categoryIt->id] = -set.GetDouble(wxT("amount"));
}
set.Finalize();
// Transfert on blocked accounts must be computed
req2 = req + wxT(" AND transfert != ''");
req2 = req + wxT(" AND (SELECT blocked FROM account WHERE id=o1.account)");
req2 += wxT(" AND amount > 0");
EXECUTE_SQL_QUERY(req2, set, );
if (set.NextRow())
{
(*categories)[categoryIt->id] += set.GetDouble(wxT("amount"));
}
set.Finalize();
}
}
}

View File

@ -102,6 +102,14 @@ const wxFont User::GetCategoryFont(wxString& catId)
return f;
}
Account User::GetAccount(const wxString& accountId)
{
std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++)
if (it->id == accountId)
return *it;
}
wxString User::GetAccountName(const wxString& accountId)
{
std::vector<Account>::iterator it;

View File

@ -51,6 +51,7 @@ public:
wxString GetCategoryName(wxString& catId);
wxString GetCategoryId(wxString& catName);
const wxFont GetCategoryFont(wxString& catId);
Account GetAccount(const wxString& accountId);
wxString GetAccountName(const wxString& accountId);
wxString GetAccountId(wxString& accountName);
int GetCategoriesNumber();

View File

@ -149,7 +149,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
ChangeUser();
//Fit();
Fit();
SetMinSize(wxSize(rect.width-rect.x, rect.height-rect.y-128));
SetScrollbars(10, 10, 100/10, 100/10);
@ -237,7 +237,7 @@ void AccountPanel::ChangeUser()
else
_tree.AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
}
//Fit();
Fit();
if (curYear != -1)
{
_tree.SelectItem(curNode, true);
@ -280,7 +280,7 @@ void AccountPanel::LoadYear(int year, bool showMonth)
}
_tree.Expand(parentNode);
//Fit();
Fit();
if (showMonth)
{
_tree.SelectItem(curMonthNode, true);
@ -356,7 +356,7 @@ void AccountPanel::ShowMonth(int month, int year)
UpdateStats();
//Fit();
Fit();
// SetMinSize(GetSize());
}
@ -412,7 +412,8 @@ void AccountPanel::UpdateStats()
unsigned int day;
bool checkMode = _checkCheckMode->IsChecked();
std::map<wxString, double>* notChecked = NULL;
Account account;
Operation op;
curCredit = curDebit = totalCredit = totalDebit = percents = 0.0;
@ -436,35 +437,49 @@ void AccountPanel::UpdateStats()
{
if (it->meta) continue;
if (it->amount > 0)
op = *it;
// A credit on a blocked account must be considered as a debit
if (op.transfert.Length() && op.amount > 0)
{
if (day >= it->day)
account = user->GetAccount(op.account);
if (account.blocked)
{
if (!it->transfert.Length())
curCredit += it->amount;
if (!checkMode || (checkMode && it->checked))
curAccountAmount[it->account] += it->amount;
op.amount = -op.amount;
op.transfert = wxT("");
}
if (!it->transfert.Length())
totalCredit += it->amount;
if (!checkMode || (checkMode && it->checked))
finalAccountAmount[it->account] += it->amount;
}
if (op.amount >= 0)
{
if (day >= op.day)
{
if (!op.transfert.Length())
curCredit += op.amount;
if (!checkMode || (checkMode && op.checked))
curAccountAmount[op.account] += op.amount;
}
if (!op.transfert.Length())
totalCredit += op.amount;
if (!checkMode || (checkMode && op.checked))
finalAccountAmount[op.account] += op.amount;
}
else
{
if (!it->transfert.Length())
_categoriesValues[_categoriesIndexes[user->GetCategoryName(it->category)]] += -it->amount ;
if (day >= it->day)
if (!op.transfert.Length())
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
if (day >= op.day)
{
if (!it->transfert.Length())
curDebit += -it->amount;
if (!checkMode || (checkMode && it->checked))
curAccountAmount[it->account] += it->amount;
if (!op.transfert.Length())
curDebit += -op.amount;
if (!checkMode || (checkMode && op.checked))
curAccountAmount[op.account] += op.amount;
}
if (!it->transfert.Length())
totalDebit += -it->amount;
if (!checkMode || (checkMode && it->checked))
finalAccountAmount[it->account] += it->amount;
if (!op.transfert.Length())
totalDebit += -op.amount;
if (!checkMode || (checkMode && op.checked))
finalAccountAmount[op.account] += op.amount;
}
}
@ -623,6 +638,7 @@ void AccountPanel::OnTreeChange(wxTreeEvent& event)
}
inModification = false;
Fit();
}
void AccountPanel::GetTreeSelection(int* month, int* year)
@ -682,6 +698,8 @@ void AccountPanel::OnMenuGenerate(wxCommandEvent& event)
GenerateDialog g(_kiss, _wxUI, month, year);
g.ShowModal();
Fit();
}
void AccountPanel::OnMenuDelete(wxCommandEvent& event)
@ -736,6 +754,8 @@ void AccountPanel::OnMenuDelete(wxCommandEvent& event)
month = ops[year][0];
ShowMonth(month, year);
}
Fit();
}
void AccountPanel::GenerateMonth(int month, int year)
@ -808,6 +828,8 @@ void AccountPanel::GenerateMonth(int month, int year)
_tree.SelectItem(node, true);
ShowMonth(month, year);
Fit();
}
void AccountPanel::OnShow(wxShowEvent& event)
@ -816,6 +838,7 @@ void AccountPanel::OnShow(wxShowEvent& event)
_wxUI->SetTitle(_kiss->GetUser()->_name + wxT(" - ") + months[_curMonth] + wxT(" ") + wxString::Format(wxT("%d"), _curYear));
else
_wxUI->SetTitle(_kiss->GetUser()->_name);
Fit();
}
void AccountPanel::OnCalendarChange(wxCalendarEvent& event)

View File

@ -19,7 +19,7 @@
#include "PreferencesPanel.h"
enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_DEFAULT, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT};
enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_DEFAULT, ACCOUNT_BLOCKED, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT};
enum {CATEGORY_NAME, CATEGORY_BACKGROUND_COLOR, CATEGORY_FOREGROUND_COLOR, CATEGORY_FONT, CATEGORY_DELETE, NUMBER_COLS_CATEGORY};
enum {CATEGORIES_GRID_ID=1, ACCOUNTS_GRID_ID, NAME_ID, CHANGE_NAME_ID, CHANGE_PASSWORD_ID, KILL_ME_ID, LANGUAGE_ID,
@ -184,6 +184,7 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->SetColLabelValue(ACCOUNT_NAME, _("Name"));
_accountsGrid->SetColLabelValue(ACCOUNT_NUMBER, _("Number"));
_accountsGrid->SetColLabelValue(ACCOUNT_DEFAULT, _("Default"));
_accountsGrid->SetColLabelValue(ACCOUNT_BLOCKED, _("Blocked"));
_accountsGrid->SetColLabelValue(ACCOUNT_DELETE, _("Delete"));
_accountsGrid->SetDefaultCellFont(font);
@ -200,11 +201,15 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->SetCellEditor(curLine, ACCOUNT_NUMBER, new wxGridCellStarEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
_accountsGrid->SetCellValue(curLine, ACCOUNT_DEFAULT, (it->_default)?wxT("1"):wxT("0"));
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellValue(curLine, ACCOUNT_BLOCKED, (it->blocked)?wxT("1"):wxT("0"));
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
if (!it->is_owner)
@ -212,6 +217,7 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->SetReadOnly(curLine, ACCOUNT_NAME, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_NUMBER, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_BLOCKED, true);
}
}
@ -219,6 +225,7 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->AppendRows();
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_BLOCKED, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DELETE, true);
}
@ -349,6 +356,12 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
else
new_account._default = false;
value = _accountsGrid->GetCellValue(row, ACCOUNT_BLOCKED);
if (value.Length() && value != wxT("0"))
new_account.blocked = true;
else
new_account.blocked = false;
if (col == ACCOUNT_DEFAULT)
{
new_account.id = user->_accounts[row].id;
@ -375,6 +388,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
if (user->GetAccountsNumber() && row < user->GetAccountsNumber())
{
new_account.id = user->_accounts[row].id;
new_account.shared = user->_accounts[row].shared;
if (col == ACCOUNT_DELETE)
{
@ -427,14 +441,21 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
return ;
}
new_account.shared = false;
new_account.blocked = false;
_accountsGrid->SetCellRenderer(row, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(row, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(row, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
_accountsGrid->SetCellAlignment(row, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(row, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(row, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetReadOnly(row, ACCOUNT_DEFAULT, false);
_accountsGrid->SetReadOnly(row, ACCOUNT_BLOCKED, false);
_accountsGrid->SetReadOnly(row, ACCOUNT_DELETE, false);
if (!user->GetAccountsNumber())
@ -447,6 +468,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
_accountsGrid->AppendRows();
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(row+1, ACCOUNT_BLOCKED, true);
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DELETE, true);
_kiss->AddAccount(new_account);

View File

@ -256,6 +256,9 @@ void wxUI::ShowPanel(wxPanel* panel)
panel = _statsPanel;
}
_hbox->Detach(_accountPanel);
_accountPanel->Hide();
_needReload = false;
}