Add shared account management

This commit is contained in:
Grégory Soutadé 2010-10-24 16:04:56 +02:00
parent d800f23029
commit 28c92d3b28
17 changed files with 655 additions and 237 deletions

6
TODO
View File

@ -8,7 +8,6 @@ Can type a letter with a comboboxes
Windows version Windows version
Need packaging Need packaging
Better build system for wxFreeChart (hacked by me) Better build system for wxFreeChart (hacked by me)
Shared accounts
Documentation (en) Documentation (en)
Cool for 0.1: Cool for 0.1:
@ -36,5 +35,6 @@ Undo/redo
=============================================================== ===============================================================
BUGS BUGS
When we broke a transfert into a meta operation and re create it, * When we broke a transfert into a meta operation and re create it,
it's not taken in account by UpdateStats it's not taken in account by UpdateStats

View File

@ -1,7 +1,7 @@
CREATE TABLE kisscount(db_version VARCHAR(20)); CREATE TABLE kisscount(db_version VARCHAR(20));
CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255), password VARCHAR(255)); 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), default_account CHAR(1));
CREATE TABLE shared_account(id REFERENCES account(id), user REFERENCES user(id)); 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 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)); 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));
CREATE TABLE category(id INTEGER PRIMARY KEY, user REFERENCES user(id), parent REFERENCES category(id), name VARCHAR(255), backcolor VARCHAR(10), forecolor VARCHAR(10), font VARCHAR(255)); CREATE TABLE category(id INTEGER PRIMARY KEY, user REFERENCES user(id), parent REFERENCES category(id), name VARCHAR(255), backcolor VARCHAR(10), forecolor VARCHAR(10), font VARCHAR(255));

Binary file not shown.

View File

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-10-14 20:46+0200\n" "POT-Creation-Date: 2010-10-24 16:03+0200\n"
"PO-Revision-Date: \n" "PO-Revision-Date: \n"
"Last-Translator: Soutadé <soutade@gmail.com>\n" "Last-Translator: Soutadé <soutade@gmail.com>\n"
"Language-Team: \n" "Language-Team: \n"
@ -20,16 +20,16 @@ msgstr ""
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#: src/view/StatsPanel.cpp:282 #: src/view/StatsPanel.cpp:282
#: src/view/PreferencesPanel.cpp:660 #: src/view/PreferencesPanel.cpp:743
msgid " - " msgid " - "
msgstr " - " msgstr " - "
#: src/view/UsersDialog.cpp:118 #: src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:384 #: src/view/PreferencesPanel.cpp:404
#: src/view/PreferencesPanel.cpp:403 #: src/view/PreferencesPanel.cpp:423
#: src/view/PreferencesPanel.cpp:553 #: src/view/PreferencesPanel.cpp:636
#: src/view/PreferencesPanel.cpp:572 #: src/view/PreferencesPanel.cpp:655
#: src/view/PreferencesPanel.cpp:618 #: src/view/PreferencesPanel.cpp:701
msgid " already exists" msgid " already exists"
msgstr " existe déjà " msgstr " existe déjà "
@ -41,11 +41,11 @@ msgstr " entrées trouvées"
msgid " not found, aborting" msgid " not found, aborting"
msgstr " non trouvé, arrêt" msgstr " non trouvé, arrêt"
#: src/view/AccountPanel.cpp:705 #: src/view/AccountPanel.cpp:709
msgid " operations ?" msgid " operations ?"
msgstr " opérations ?" msgstr " opérations ?"
#: src/view/PreferencesPanel.cpp:667 #: src/view/PreferencesPanel.cpp:750
msgid " profil ?" msgid " profil ?"
msgstr " profil ?" msgstr " profil ?"
@ -66,8 +66,8 @@ msgstr "A propos"
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
#: src/view/PreferencesPanel.cpp:384 #: src/view/PreferencesPanel.cpp:404
#: src/view/PreferencesPanel.cpp:403 #: src/view/PreferencesPanel.cpp:423
msgid "Account " msgid "Account "
msgstr "Le compte " msgstr "Le compte "
@ -80,7 +80,7 @@ msgid "Account number"
msgstr "Numéro de compte" msgstr "Numéro de compte"
#: src/view/StatsPanel.cpp:247 #: src/view/StatsPanel.cpp:247
#: src/view/PreferencesPanel.cpp:55 #: src/view/PreferencesPanel.cpp:59
msgid "Accounts" msgid "Accounts"
msgstr "Comptes" msgstr "Comptes"
@ -92,22 +92,22 @@ msgstr "Montant min"
msgid "Amount to" msgid "Amount to"
msgstr "Montant max" msgstr "Montant max"
#: src/view/PreferencesPanel.cpp:365 #: src/view/PreferencesPanel.cpp:385
#: src/view/PreferencesPanel.cpp:667 #: src/view/PreferencesPanel.cpp:750
#: src/view/AccountPanel.cpp:700 #: src/view/AccountPanel.cpp:704
msgid "Are you sure want to delete " msgid "Are you sure want to delete "
msgstr "Etes vous sûr de vouloir supprimer " msgstr "Etes vous sûr de vouloir supprimer "
#: src/view/PreferencesPanel.cpp:534 #: src/view/PreferencesPanel.cpp:617
#: src/view/grid/GridAccount.cpp:743 #: src/view/grid/GridAccount.cpp:745
msgid "Are you sure want to delete : \n" msgid "Are you sure want to delete : \n"
msgstr "Etes vous sûr de vouloir supprimer : \n" msgstr "Etes vous sûr de vouloir supprimer : \n"
#: src/view/PreferencesPanel.cpp:280 #: src/view/PreferencesPanel.cpp:306
msgid "Ascending" msgid "Ascending"
msgstr "Croissant" msgstr "Croissant"
#: src/view/PreferencesPanel.cpp:221 #: src/view/PreferencesPanel.cpp:247
msgid "Background color" msgid "Background color"
msgstr "Couleur d'arrière plan" msgstr "Couleur d'arrière plan"
@ -117,17 +117,17 @@ msgstr "Couleur d'arrière plan"
msgid "Cancel" msgid "Cancel"
msgstr "Annuler" msgstr "Annuler"
#: src/view/grid/GridAccount.cpp:1067 #: src/view/grid/GridAccount.cpp:1129
#: src/view/grid/GridAccount.cpp:1074 #: src/view/grid/GridAccount.cpp:1136
msgid "Cannot group these operations" msgid "Cannot group these operations"
msgstr "Impossible de grouper ces opérations" msgstr "Impossible de grouper ces opérations"
#: src/view/grid/GridAccount.cpp:1202 #: src/view/grid/GridAccount.cpp:1263
#: src/view/grid/GridAccount.cpp:1208 #: src/view/grid/GridAccount.cpp:1269
msgid "Cannot ungroup these operations" msgid "Cannot ungroup these operations"
msgstr "Impossible de dégrouper ces opérations" msgstr "Impossible de dégrouper ces opérations"
#: src/view/PreferencesPanel.cpp:56 #: src/view/PreferencesPanel.cpp:60
msgid "Categories" msgid "Categories"
msgstr "Catégories" msgstr "Catégories"
@ -136,16 +136,16 @@ msgstr "Catégories"
msgid "Category" msgid "Category"
msgstr "Catégorie" msgstr "Catégorie"
#: src/view/PreferencesPanel.cpp:553 #: src/view/PreferencesPanel.cpp:636
#: src/view/PreferencesPanel.cpp:572 #: src/view/PreferencesPanel.cpp:655
msgid "Category " msgid "Category "
msgstr "Catégorie" msgstr "Catégorie"
#: src/view/PreferencesPanel.cpp:72 #: src/view/PreferencesPanel.cpp:77
msgid "Change Name" msgid "Change Name"
msgstr "Changer de nom" msgstr "Changer de nom"
#: src/view/PreferencesPanel.cpp:73 #: src/view/PreferencesPanel.cpp:78
msgid "Change Password" msgid "Change Password"
msgstr "Changer le mot de passe" msgstr "Changer le mot de passe"
@ -202,17 +202,17 @@ msgstr "Date max"
msgid "Debit" msgid "Debit"
msgstr "Débit" msgstr "Débit"
#: src/view/PreferencesPanel.cpp:166 #: src/view/PreferencesPanel.cpp:186
msgid "Default" msgid "Default"
msgstr "Défaut" msgstr "Défaut"
#: src/view/PreferencesPanel.cpp:167 #: src/view/PreferencesPanel.cpp:187
#: src/view/PreferencesPanel.cpp:224 #: src/view/PreferencesPanel.cpp:250
#: src/view/AccountPanel.cpp:559 #: src/view/AccountPanel.cpp:563
msgid "Delete" msgid "Delete"
msgstr "Supprimer" msgstr "Supprimer"
#: src/view/PreferencesPanel.cpp:281 #: src/view/PreferencesPanel.cpp:307
msgid "Descending" msgid "Descending"
msgstr "Décroissant" msgstr "Décroissant"
@ -227,21 +227,21 @@ msgstr "Description"
#: src/view/SearchPanel.cpp:145 #: src/view/SearchPanel.cpp:145
#: src/view/SearchPanel.cpp:159 #: src/view/SearchPanel.cpp:159
#: src/view/SearchPanel.cpp:170 #: src/view/SearchPanel.cpp:170
#: src/view/PreferencesPanel.cpp:361 #: src/view/PreferencesPanel.cpp:381
#: src/view/PreferencesPanel.cpp:384 #: src/view/PreferencesPanel.cpp:404
#: src/view/PreferencesPanel.cpp:403 #: src/view/PreferencesPanel.cpp:423
#: src/view/PreferencesPanel.cpp:553 #: src/view/PreferencesPanel.cpp:636
#: src/view/PreferencesPanel.cpp:572 #: src/view/PreferencesPanel.cpp:655
#: src/view/PreferencesPanel.cpp:612 #: src/view/PreferencesPanel.cpp:695
#: src/view/PreferencesPanel.cpp:618 #: src/view/PreferencesPanel.cpp:701
#: src/view/PasswordDialog.cpp:72 #: src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78 #: src/view/PasswordDialog.cpp:78
#: src/view/AccountPanel.cpp:696 #: src/view/AccountPanel.cpp:700
#: src/view/grid/GridAccount.cpp:1067 #: src/view/grid/GridAccount.cpp:1129
#: src/view/grid/GridAccount.cpp:1074 #: src/view/grid/GridAccount.cpp:1136
#: src/view/grid/GridAccount.cpp:1202 #: src/view/grid/GridAccount.cpp:1263
#: src/view/grid/GridAccount.cpp:1208 #: src/view/grid/GridAccount.cpp:1269
#: src/view/grid/wxGridCellFormulaEditor.cpp:68 #: src/view/grid/wxGridCellFormulaEditor.cpp:69
#: src/model/Database.cpp:38 #: src/model/Database.cpp:38
#: src/model/Database.cpp:55 #: src/model/Database.cpp:55
#: src/model/Database.cpp:95 #: src/model/Database.cpp:95
@ -262,16 +262,16 @@ msgid "Final value"
msgstr "Valeur finale" msgstr "Valeur finale"
#: src/view/grid/GridAccount.cpp:300 #: src/view/grid/GridAccount.cpp:300
#: src/model/Database.cpp:312 #: src/model/Database.cpp:329
#: src/controller/KissCount.cpp:305 #: src/controller/KissCount.cpp:335
msgid "Fix" msgid "Fix"
msgstr "Fixe" msgstr "Fixe"
#: src/view/PreferencesPanel.cpp:223 #: src/view/PreferencesPanel.cpp:249
msgid "Font" msgid "Font"
msgstr "Police" msgstr "Police"
#: src/view/PreferencesPanel.cpp:222 #: src/view/PreferencesPanel.cpp:248
msgid "Foreground color" msgid "Foreground color"
msgstr "Couleur d'avant plan" msgstr "Couleur d'avant plan"
@ -284,11 +284,11 @@ msgid "From "
msgstr "A partir de " msgstr "A partir de "
#: src/view/GenerateDialog.cpp:31 #: src/view/GenerateDialog.cpp:31
#: src/view/AccountPanel.cpp:556 #: src/view/AccountPanel.cpp:560
msgid "Generate month" msgid "Generate month"
msgstr "Générer mois" msgstr "Générer mois"
#: src/controller/KissCount.cpp:307 #: src/controller/KissCount.cpp:337
msgid "Groceries" msgid "Groceries"
msgstr "Courses" msgstr "Courses"
@ -296,7 +296,7 @@ msgstr "Courses"
msgid "Group" msgid "Group"
msgstr "Grouper" msgstr "Grouper"
#: src/controller/KissCount.cpp:309 #: src/controller/KissCount.cpp:339
msgid "Hobbies" msgid "Hobbies"
msgstr "Loisirs" msgstr "Loisirs"
@ -320,11 +320,11 @@ msgstr "Montant max invalide"
msgid "Invalid date range" msgid "Invalid date range"
msgstr "Intervalle de temps invalide" msgstr "Intervalle de temps invalide"
#: src/view/grid/wxGridCellFormulaEditor.cpp:68 #: src/view/grid/wxGridCellFormulaEditor.cpp:69
msgid "Invalid formula !" msgid "Invalid formula !"
msgstr "Formule invalide !" msgstr "Formule invalide !"
#: src/view/PreferencesPanel.cpp:612 #: src/view/PreferencesPanel.cpp:695
msgid "Invalid name" msgid "Invalid name"
msgstr "Nom invalide" msgstr "Nom invalide"
@ -340,43 +340,43 @@ msgstr "Mot de passe invalide"
msgid "Invalide date range" msgid "Invalide date range"
msgstr "Intervalle de temps invalide" msgstr "Intervalle de temps invalide"
#: src/view/PreferencesPanel.cpp:361 #: src/view/PreferencesPanel.cpp:381
msgid "It must be at least one account !" msgid "It must be at least one account !"
msgstr "Il doit y avoir au moins un compte !" msgstr "Il doit y avoir au moins un compte !"
#: src/view/AccountPanel.cpp:696 #: src/view/AccountPanel.cpp:700
msgid "It must be at least one month !" msgid "It must be at least one month !"
msgstr "Il doit rester au mois un mois" msgstr "Il doit rester au mois un mois"
#: src/view/PreferencesPanel.cpp:74 #: src/view/PreferencesPanel.cpp:79
msgid "Kill me" msgid "Kill me"
msgstr "Kill me" msgstr "Kill me"
#: src/view/StatsPanel.cpp:302 #: src/view/StatsPanel.cpp:302
#: src/view/PreferencesPanel.cpp:652 #: src/view/PreferencesPanel.cpp:735
#: src/view/PreferencesPanel.cpp:655 #: src/view/PreferencesPanel.cpp:738
msgid "KissCount" msgid "KissCount"
msgstr "KissCount" msgstr "KissCount"
#: src/view/PreferencesPanel.cpp:57 #: src/view/PreferencesPanel.cpp:61
msgid "Language" msgid "Language"
msgstr "Langue" msgstr "Langue"
#: src/view/PreferencesPanel.cpp:655 #: src/view/PreferencesPanel.cpp:738
msgid "Language not changed" msgid "Language not changed"
msgstr "Langue non changée" msgstr "Langue non changée"
#: src/view/PreferencesPanel.cpp:652 #: src/view/PreferencesPanel.cpp:735
msgid "Language successfully changed, please go to another panel" msgid "Language successfully changed, please go to another panel"
msgstr "Langue changée, allez sur un autre panneau pour rendre le changement effectif" msgstr "Langue changée, allez sur un autre panneau pour rendre le changement effectif"
#: src/view/PreferencesPanel.cpp:66 #: src/view/PreferencesPanel.cpp:71
#: src/view/PreferencesPanel.cpp:163 #: src/view/PreferencesPanel.cpp:184
#: src/view/PreferencesPanel.cpp:220 #: src/view/PreferencesPanel.cpp:246
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
#: src/view/PreferencesPanel.cpp:624 #: src/view/PreferencesPanel.cpp:707
msgid "Name changed" msgid "Name changed"
msgstr "Nom changé" msgstr "Nom changé"
@ -401,7 +401,7 @@ msgstr ""
msgid "No entry found" msgid "No entry found"
msgstr "Pas d'entrée trouvée" msgstr "Pas d'entrée trouvée"
#: src/view/PreferencesPanel.cpp:164 #: src/view/PreferencesPanel.cpp:185
msgid "Number" msgid "Number"
msgstr "Numéro de compte" msgstr "Numéro de compte"
@ -415,11 +415,11 @@ msgstr "OK"
msgid "Old password " msgid "Old password "
msgstr "Ancien mot de passe" msgstr "Ancien mot de passe"
#: src/controller/KissCount.cpp:311 #: src/controller/KissCount.cpp:341
msgid "Operating exepense" msgid "Operating exepense"
msgstr "Frais de fonctionnement" msgstr "Frais de fonctionnement"
#: src/view/PreferencesPanel.cpp:58 #: src/view/PreferencesPanel.cpp:62
msgid "Operation order" msgid "Operation order"
msgstr "Ordre des opérations" msgstr "Ordre des opérations"
@ -427,7 +427,7 @@ msgstr "Ordre des opérations"
msgid "Operations" msgid "Operations"
msgstr "Opérations" msgstr "Opérations"
#: src/controller/KissCount.cpp:315 #: src/controller/KissCount.cpp:345
msgid "Other" msgid "Other"
msgstr "Autres" msgstr "Autres"
@ -453,8 +453,8 @@ msgstr ""
msgid "Please retype new password" msgid "Please retype new password"
msgstr "Re entrez le mot de passe" msgstr "Re entrez le mot de passe"
#: src/view/PreferencesPanel.cpp:626 #: src/view/PreferencesPanel.cpp:709
#: src/view/PreferencesPanel.cpp:660 #: src/view/PreferencesPanel.cpp:743
#: src/view/ButtonPanel.cpp:72 #: src/view/ButtonPanel.cpp:72
msgid "Preferences" msgid "Preferences"
msgstr "Préférences" msgstr "Préférences"
@ -486,9 +486,9 @@ msgstr "Chercher"
msgid "Serie 1" msgid "Serie 1"
msgstr "Série 1" msgstr "Série 1"
#: src/view/PreferencesPanel.cpp:165 #: src/view/PreferencesPanel.cpp:63
msgid "Shared" msgid "Shared with"
msgstr "Partagé" msgstr "Partagé avec"
#: src/view/StatsPanel.cpp:282 #: src/view/StatsPanel.cpp:282
#: src/view/ButtonPanel.cpp:70 #: src/view/ButtonPanel.cpp:70
@ -522,13 +522,13 @@ msgstr "Dégrouper"
msgid "Unable to open Database" msgid "Unable to open Database"
msgstr "Impossible d'ouvrir la base de données" msgstr "Impossible d'ouvrir la base de données"
#: src/controller/KissCount.cpp:313 #: src/controller/KissCount.cpp:343
msgid "Unexpected" msgid "Unexpected"
msgstr "Exceptionnel" msgstr "Exceptionnel"
#: src/model/User.cpp:46 #: src/model/User.cpp:52
#: src/model/User.cpp:61 #: src/model/User.cpp:72
#: src/model/User.cpp:92 #: src/model/User.cpp:112
msgid "Unknown" msgid "Unknown"
msgstr "Inconnu" msgstr "Inconnu"
@ -536,13 +536,13 @@ msgstr "Inconnu"
msgid "Update failed !\n" msgid "Update failed !\n"
msgstr "La mise à jour à échouée !\n" msgstr "La mise à jour à échouée !\n"
#: src/view/PreferencesPanel.cpp:54 #: src/view/PreferencesPanel.cpp:58
msgid "User" msgid "User"
msgstr "Utilisateur" msgstr "Utilisateur"
#: src/view/UsersDialog.cpp:38 #: src/view/UsersDialog.cpp:38
#: src/view/UsersDialog.cpp:118 #: src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:618 #: src/view/PreferencesPanel.cpp:701
msgid "User " msgid "User "
msgstr "Utilisateur" msgstr "Utilisateur"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-10-14 20:46+0200\n" "POT-Creation-Date: 2010-10-24 16:03+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,13 +17,13 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: src/view/StatsPanel.cpp:282 src/view/PreferencesPanel.cpp:660 #: src/view/StatsPanel.cpp:282 src/view/PreferencesPanel.cpp:743
msgid " - " msgid " - "
msgstr "" msgstr ""
#: src/view/UsersDialog.cpp:118 src/view/PreferencesPanel.cpp:384 #: src/view/UsersDialog.cpp:118 src/view/PreferencesPanel.cpp:404
#: src/view/PreferencesPanel.cpp:403 src/view/PreferencesPanel.cpp:553 #: src/view/PreferencesPanel.cpp:423 src/view/PreferencesPanel.cpp:636
#: src/view/PreferencesPanel.cpp:572 src/view/PreferencesPanel.cpp:618 #: src/view/PreferencesPanel.cpp:655 src/view/PreferencesPanel.cpp:701
msgid " already exists" msgid " already exists"
msgstr "" msgstr ""
@ -35,11 +35,11 @@ msgstr ""
msgid " not found, aborting" msgid " not found, aborting"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:705 #: src/view/AccountPanel.cpp:709
msgid " operations ?" msgid " operations ?"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:667 #: src/view/PreferencesPanel.cpp:750
msgid " profil ?" msgid " profil ?"
msgstr "" msgstr ""
@ -59,7 +59,7 @@ msgstr ""
msgid "Account" msgid "Account"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:384 src/view/PreferencesPanel.cpp:403 #: src/view/PreferencesPanel.cpp:404 src/view/PreferencesPanel.cpp:423
msgid "Account " msgid "Account "
msgstr "" msgstr ""
@ -71,7 +71,7 @@ msgstr ""
msgid "Account number" msgid "Account number"
msgstr "" msgstr ""
#: src/view/StatsPanel.cpp:247 src/view/PreferencesPanel.cpp:55 #: src/view/StatsPanel.cpp:247 src/view/PreferencesPanel.cpp:59
msgid "Accounts" msgid "Accounts"
msgstr "" msgstr ""
@ -83,20 +83,20 @@ msgstr ""
msgid "Amount to" msgid "Amount to"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:365 src/view/PreferencesPanel.cpp:667 #: src/view/PreferencesPanel.cpp:385 src/view/PreferencesPanel.cpp:750
#: src/view/AccountPanel.cpp:700 #: src/view/AccountPanel.cpp:704
msgid "Are you sure want to delete " msgid "Are you sure want to delete "
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:534 src/view/grid/GridAccount.cpp:743 #: src/view/PreferencesPanel.cpp:617 src/view/grid/GridAccount.cpp:745
msgid "Are you sure want to delete : \n" msgid "Are you sure want to delete : \n"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:280 #: src/view/PreferencesPanel.cpp:306
msgid "Ascending" msgid "Ascending"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:221 #: src/view/PreferencesPanel.cpp:247
msgid "Background color" msgid "Background color"
msgstr "" msgstr ""
@ -105,15 +105,15 @@ msgstr ""
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: src/view/grid/GridAccount.cpp:1067 src/view/grid/GridAccount.cpp:1074 #: src/view/grid/GridAccount.cpp:1129 src/view/grid/GridAccount.cpp:1136
msgid "Cannot group these operations" msgid "Cannot group these operations"
msgstr "" msgstr ""
#: src/view/grid/GridAccount.cpp:1202 src/view/grid/GridAccount.cpp:1208 #: src/view/grid/GridAccount.cpp:1263 src/view/grid/GridAccount.cpp:1269
msgid "Cannot ungroup these operations" msgid "Cannot ungroup these operations"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:56 #: src/view/PreferencesPanel.cpp:60
msgid "Categories" msgid "Categories"
msgstr "" msgstr ""
@ -121,15 +121,15 @@ msgstr ""
msgid "Category" msgid "Category"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:553 src/view/PreferencesPanel.cpp:572 #: src/view/PreferencesPanel.cpp:636 src/view/PreferencesPanel.cpp:655
msgid "Category " msgid "Category "
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:72 #: src/view/PreferencesPanel.cpp:77
msgid "Change Name" msgid "Change Name"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:73 #: src/view/PreferencesPanel.cpp:78
msgid "Change Password" msgid "Change Password"
msgstr "" msgstr ""
@ -185,16 +185,16 @@ msgstr ""
msgid "Debit" msgid "Debit"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:166 #: src/view/PreferencesPanel.cpp:186
msgid "Default" msgid "Default"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:167 src/view/PreferencesPanel.cpp:224 #: src/view/PreferencesPanel.cpp:187 src/view/PreferencesPanel.cpp:250
#: src/view/AccountPanel.cpp:559 #: src/view/AccountPanel.cpp:563
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:281 #: src/view/PreferencesPanel.cpp:307
msgid "Descending" msgid "Descending"
msgstr "" msgstr ""
@ -205,14 +205,14 @@ msgstr ""
#: src/view/UsersDialog.cpp:88 src/view/UsersDialog.cpp:118 #: src/view/UsersDialog.cpp:88 src/view/UsersDialog.cpp:118
#: src/view/SearchPanel.cpp:135 src/view/SearchPanel.cpp:145 #: src/view/SearchPanel.cpp:135 src/view/SearchPanel.cpp:145
#: src/view/SearchPanel.cpp:159 src/view/SearchPanel.cpp:170 #: src/view/SearchPanel.cpp:159 src/view/SearchPanel.cpp:170
#: src/view/PreferencesPanel.cpp:361 src/view/PreferencesPanel.cpp:384 #: src/view/PreferencesPanel.cpp:381 src/view/PreferencesPanel.cpp:404
#: src/view/PreferencesPanel.cpp:403 src/view/PreferencesPanel.cpp:553 #: src/view/PreferencesPanel.cpp:423 src/view/PreferencesPanel.cpp:636
#: src/view/PreferencesPanel.cpp:572 src/view/PreferencesPanel.cpp:612 #: src/view/PreferencesPanel.cpp:655 src/view/PreferencesPanel.cpp:695
#: src/view/PreferencesPanel.cpp:618 src/view/PasswordDialog.cpp:72 #: src/view/PreferencesPanel.cpp:701 src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:696 #: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:700
#: src/view/grid/GridAccount.cpp:1067 src/view/grid/GridAccount.cpp:1074 #: src/view/grid/GridAccount.cpp:1129 src/view/grid/GridAccount.cpp:1136
#: src/view/grid/GridAccount.cpp:1202 src/view/grid/GridAccount.cpp:1208 #: src/view/grid/GridAccount.cpp:1263 src/view/grid/GridAccount.cpp:1269
#: src/view/grid/wxGridCellFormulaEditor.cpp:68 src/model/Database.cpp:38 #: src/view/grid/wxGridCellFormulaEditor.cpp:69 src/model/Database.cpp:38
#: src/model/Database.cpp:55 src/model/Database.cpp:95 #: src/model/Database.cpp:55 src/model/Database.cpp:95
#: src/model/Database.cpp:102 src/model/Database.cpp:120 #: src/model/Database.cpp:102 src/model/Database.cpp:120
#: src/model/Database.cpp:147 src/model/Database.cpp:155 #: src/model/Database.cpp:147 src/model/Database.cpp:155
@ -228,16 +228,16 @@ msgstr ""
msgid "Final value" msgid "Final value"
msgstr "" msgstr ""
#: src/view/grid/GridAccount.cpp:300 src/model/Database.cpp:312 #: src/view/grid/GridAccount.cpp:300 src/model/Database.cpp:329
#: src/controller/KissCount.cpp:305 #: src/controller/KissCount.cpp:335
msgid "Fix" msgid "Fix"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:223 #: src/view/PreferencesPanel.cpp:249
msgid "Font" msgid "Font"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:222 #: src/view/PreferencesPanel.cpp:248
msgid "Foreground color" msgid "Foreground color"
msgstr "" msgstr ""
@ -249,11 +249,11 @@ msgstr ""
msgid "From " msgid "From "
msgstr "" msgstr ""
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:556 #: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:560
msgid "Generate month" msgid "Generate month"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:307 #: src/controller/KissCount.cpp:337
msgid "Groceries" msgid "Groceries"
msgstr "" msgstr ""
@ -261,7 +261,7 @@ msgstr ""
msgid "Group" msgid "Group"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:309 #: src/controller/KissCount.cpp:339
msgid "Hobbies" msgid "Hobbies"
msgstr "" msgstr ""
@ -285,11 +285,11 @@ msgstr ""
msgid "Invalid date range" msgid "Invalid date range"
msgstr "" msgstr ""
#: src/view/grid/wxGridCellFormulaEditor.cpp:68 #: src/view/grid/wxGridCellFormulaEditor.cpp:69
msgid "Invalid formula !" msgid "Invalid formula !"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:612 #: src/view/PreferencesPanel.cpp:695
msgid "Invalid name" msgid "Invalid name"
msgstr "" msgstr ""
@ -305,41 +305,41 @@ msgstr ""
msgid "Invalide date range" msgid "Invalide date range"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:361 #: src/view/PreferencesPanel.cpp:381
msgid "It must be at least one account !" msgid "It must be at least one account !"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:696 #: src/view/AccountPanel.cpp:700
msgid "It must be at least one month !" msgid "It must be at least one month !"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:74 #: src/view/PreferencesPanel.cpp:79
msgid "Kill me" msgid "Kill me"
msgstr "" msgstr ""
#: src/view/StatsPanel.cpp:302 src/view/PreferencesPanel.cpp:652 #: src/view/StatsPanel.cpp:302 src/view/PreferencesPanel.cpp:735
#: src/view/PreferencesPanel.cpp:655 #: src/view/PreferencesPanel.cpp:738
msgid "KissCount" msgid "KissCount"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:57 #: src/view/PreferencesPanel.cpp:61
msgid "Language" msgid "Language"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:655 #: src/view/PreferencesPanel.cpp:738
msgid "Language not changed" msgid "Language not changed"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:652 #: src/view/PreferencesPanel.cpp:735
msgid "Language successfully changed, please go to another panel" msgid "Language successfully changed, please go to another panel"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:66 src/view/PreferencesPanel.cpp:163 #: src/view/PreferencesPanel.cpp:71 src/view/PreferencesPanel.cpp:184
#: src/view/PreferencesPanel.cpp:220 #: src/view/PreferencesPanel.cpp:246
msgid "Name" msgid "Name"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:624 #: src/view/PreferencesPanel.cpp:707
msgid "Name changed" msgid "Name changed"
msgstr "" msgstr ""
@ -361,7 +361,7 @@ msgstr ""
msgid "No entry found" msgid "No entry found"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:164 #: src/view/PreferencesPanel.cpp:185
msgid "Number" msgid "Number"
msgstr "" msgstr ""
@ -374,11 +374,11 @@ msgstr ""
msgid "Old password " msgid "Old password "
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:311 #: src/controller/KissCount.cpp:341
msgid "Operating exepense" msgid "Operating exepense"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:58 #: src/view/PreferencesPanel.cpp:62
msgid "Operation order" msgid "Operation order"
msgstr "" msgstr ""
@ -386,7 +386,7 @@ msgstr ""
msgid "Operations" msgid "Operations"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:315 #: src/controller/KissCount.cpp:345
msgid "Other" msgid "Other"
msgstr "" msgstr ""
@ -409,7 +409,7 @@ msgstr ""
msgid "Please retype new password" msgid "Please retype new password"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:626 src/view/PreferencesPanel.cpp:660 #: src/view/PreferencesPanel.cpp:709 src/view/PreferencesPanel.cpp:743
#: src/view/ButtonPanel.cpp:72 #: src/view/ButtonPanel.cpp:72
msgid "Preferences" msgid "Preferences"
msgstr "" msgstr ""
@ -439,8 +439,8 @@ msgstr ""
msgid "Serie 1" msgid "Serie 1"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:165 #: src/view/PreferencesPanel.cpp:63
msgid "Shared" msgid "Shared with"
msgstr "" msgstr ""
#: src/view/StatsPanel.cpp:282 src/view/ButtonPanel.cpp:70 #: src/view/StatsPanel.cpp:282 src/view/ButtonPanel.cpp:70
@ -472,11 +472,11 @@ msgstr ""
msgid "Unable to open Database" msgid "Unable to open Database"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:313 #: src/controller/KissCount.cpp:343
msgid "Unexpected" msgid "Unexpected"
msgstr "" msgstr ""
#: src/model/User.cpp:46 src/model/User.cpp:61 src/model/User.cpp:92 #: src/model/User.cpp:52 src/model/User.cpp:72 src/model/User.cpp:112
msgid "Unknown" msgid "Unknown"
msgstr "" msgstr ""
@ -484,12 +484,12 @@ msgstr ""
msgid "Update failed !\n" msgid "Update failed !\n"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:54 #: src/view/PreferencesPanel.cpp:58
msgid "User" msgid "User"
msgstr "" msgstr ""
#: src/view/UsersDialog.cpp:38 src/view/UsersDialog.cpp:118 #: src/view/UsersDialog.cpp:38 src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:618 #: src/view/PreferencesPanel.cpp:701
msgid "User " msgid "User "
msgstr "" msgstr ""

View File

@ -138,6 +138,16 @@ void KissCount::DeleteOperations(int month, int year)
} }
} }
double KissCount::MetaAmount(const wxString& id)
{
return _db->MetaAmount(id);
}
double KissCount::MetaPositiveAmount(const wxString& id)
{
return _db->MetaPositiveAmount(id);
}
void KissCount::SetAccountAmount(int month, int year, const wxString& accountId, double amount) void KissCount::SetAccountAmount(int month, int year, const wxString& accountId, double amount)
{ {
_db->SetAccountAmount(month, year, accountId, amount); _db->SetAccountAmount(month, year, accountId, amount);
@ -181,6 +191,21 @@ void KissCount::AddSharedAccount(Account& ac, const wxString& granted)
_db->AddSharedAccount(ac, granted); _db->AddSharedAccount(ac, granted);
} }
void KissCount::RemoveSharedAccount(Account& ac, const wxString& granted)
{
_db->RemoveSharedAccount(ac, granted);
}
std::map<wxString, wxString> KissCount::getSharedAccountOwners(const wxString& account)
{
return _db->getSharedAccountOwners(account);
}
wxString KissCount::getSharedAccountOwner(const wxString& account)
{
return _db->getSharedAccountOwner(account);
}
wxString KissCount::AddCategory(Category& category) wxString KissCount::AddCategory(Category& category)
{ {
wxString id; wxString id;

View File

@ -55,6 +55,8 @@ public:
void UpdateOperation(Operation& op); void UpdateOperation(Operation& op);
void DeleteOperation(Operation& op); void DeleteOperation(Operation& op);
void DeleteOperations(int month, int year); void DeleteOperations(int month, int year);
double MetaAmount(const wxString& id);
double MetaPositiveAmount(const wxString& id);
double GetAccountAmount(const wxString& id, int month, int year); double GetAccountAmount(const wxString& id, int month, int year);
void SetAccountAmount(int month, int year, const wxString& accountId, double value); void SetAccountAmount(int month, int year, const wxString& accountId, double value);
@ -62,6 +64,9 @@ public:
void UpdateAccount(Account& ac); void UpdateAccount(Account& ac);
void DeleteAccount(Account& ac); void DeleteAccount(Account& ac);
void AddSharedAccount(Account& ac, const wxString& granted); void AddSharedAccount(Account& ac, const wxString& granted);
void RemoveSharedAccount(Account& ac, const wxString& granted);
std::map<wxString, wxString> getSharedAccountOwners(const wxString& account);
wxString getSharedAccountOwner(const wxString& account);
wxString AddCategory(Category& category); wxString AddCategory(Category& category);
void UpdateCategory(Category& category); void UpdateCategory(Category& category);
@ -87,8 +92,8 @@ public:
std::map<wxString, double>* GetNotChecked(int month, int year); std::map<wxString, double>* GetNotChecked(int month, int year);
wxFont ExtractFont(wxString strFont); static wxFont ExtractFont(wxString strFont);
wxString CompactFont(const wxFont& font); static wxString CompactFont(const wxFont& font);
private: private:
wxUI* _wxUI; wxUI* _wxUI;

View File

@ -211,7 +211,7 @@ std::list<wxString> Database::GetUsers()
while (set.NextRow()) while (set.NextRow())
{ {
res.push_front(set.GetAsString(0)); res.push_back(set.GetAsString(0));
} }
set.Finalize(); set.Finalize();
@ -251,7 +251,7 @@ User* Database::LoadUser(const wxString& name)
if (!set.NextRow()) if (!set.NextRow())
return NULL; return NULL;
user = new User(); user = new User(this);
user->_id = set.GetAsString(wxT("id")); user->_id = set.GetAsString(wxT("id"));
user->_name = set.GetAsString(wxT("name")); user->_name = set.GetAsString(wxT("name"));
@ -277,7 +277,7 @@ User* Database::LoadUser(const wxString& name)
} }
set.Finalize(); set.Finalize();
req = wxT("SELECT * FROM account WHERE id IN (SELECT id FROM shared_account WHERE user='") + user->_id + wxT("') ORDER BY name ASC"); req = wxT("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='") + user->_id + wxT("') ORDER BY name ASC");
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;}); EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
@ -621,7 +621,103 @@ void Database::DeleteOperations(User* user, int month, int year)
req += wxT(" AND month='") + wxString::Format(wxT("%d"), month) + wxT("'"); req += wxT(" AND month='") + wxString::Format(wxT("%d"), month) + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
}
bool Database::LoadOperation(User* user, const wxString& id)
{
wxSQLite3ResultSet set;
wxString req;
bool ret = false;
std::vector<Operation>::iterator it;
req = wxT("SELECT * FROM operation WHERE id='") + id + wxT("'");
EXECUTE_SQL_QUERY(req, set, false);
if (set.NextRow())
{
Operation op;
op.id = set.GetAsString(wxT("id"));
op.parent = set.GetAsString(wxT("parent"));
op.account = set.GetAsString(wxT("account"));
op.day = set.GetInt(wxT("day"));
op.month = set.GetInt(wxT("month"));
op.year = set.GetInt(wxT("year"));
op.amount = set.GetDouble(wxT("amount"));
op.description = set.GetAsString(wxT("description"));
op.category = set.GetAsString(wxT("category"));
op.fix_cost = set.GetBool(wxT("fix_cost"));
op.checked = set.GetBool(wxT("checked"));
op.transfert = set.GetAsString(wxT("transfert"));
op.formula = set.GetAsString(wxT("formula"));
op.meta = set.GetBool(wxT("meta"));
for (it = (*user->_operations[op.year])[op.month].begin();
it != (*user->_operations[op.year])[op.month].end();
it++)
{
if (!op.fix_cost && it->fix_cost) continue;
if (op.fix_cost && !it->fix_cost)
{
it--;
break;
}
if (it->day > op.day)
{
it--;
break;
}
}
if (it == (*user->_operations[op.year])[op.month].end())
(*user->_operations[op.year])[op.month].push_back(op);
else
(*user->_operations[op.year])[op.month].insert(it, op);
// if (op.fix_cost)
// else
// (*user->_operations[op.year])[op.month].push_back(op);
ret = true;
}
set.Finalize();
return ret;
}
// We may not have access to all operations if we have a shared account
double Database::MetaAmount(const wxString& id)
{
wxSQLite3ResultSet set;
wxString req;
double res = 0.0;
req = wxT("SELECT SUM(amount) as amount FROM operation WHERE parent='") + id + wxT("'");
EXECUTE_SQL_QUERY(req, set, false);
if (set.NextRow())
res = set.GetDouble(wxT("amount"));
set.Finalize();
return res;
}
// Idem
double Database::MetaPositiveAmount(const wxString& id)
{
wxSQLite3ResultSet set;
wxString req;
double res = 0.0;
req = wxT("SELECT SUM(amount) as amount FROM operation WHERE amount > 0 AND parent='") + id + wxT("'");
EXECUTE_SQL_QUERY(req, set, false);
if (set.NextRow())
res = set.GetDouble(wxT("amount"));
set.Finalize();
return res;
} }
void Database::SetAccountAmount(int month, int year, const wxString& accountId, double amount) void Database::SetAccountAmount(int month, int year, const wxString& accountId, double amount)
@ -697,7 +793,7 @@ void Database::UpdateAccount(Account& ac)
if (!ac.shared && ac.is_owner) if (!ac.shared && ac.is_owner)
{ {
req = wxT("DELETE FROM shared_account WHERE id='") + ac.id + wxT("'"); req = wxT("DELETE FROM shared_account WHERE account='") + ac.id + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
} }
@ -706,45 +802,66 @@ void Database::UpdateAccount(Account& ac)
void Database::DeleteAccount(User* user, Account& ac) void Database::DeleteAccount(User* user, Account& ac)
{ {
wxString req; wxString req;
wxSQLite3ResultSet set;
if (ac.is_owner) if (ac.is_owner)
{ {
if (ac.shared) if (ac.shared)
{ {
req = wxT("DELETE FROM shared_account WHERE id='") + ac.id + wxT("'"); req = wxT("DELETE FROM shared_account WHERE account='") + ac.id + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
} }
req = wxT("DELETE FROM account WHERE id='") + ac.id + wxT("'"); req = wxT("DELETE FROM account WHERE id='") + ac.id + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
}
else req = wxT("DELETE FROM account_amount WHERE account='") + ac.id + wxT("'");
{
req = wxT("DELETE FROM shared_account WHERE user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
req = wxT("SELECT COUNT(user) AS cnt FROM shared_account WHERE id='") + ac.id + wxT("'");
EXECUTE_SQL_QUERY(req, set, );
if (!set.GetInt(wxT("cnt")))
{
ac.shared = false;
UpdateAccount(ac);
}
} }
else
RemoveSharedAccount(ac, user->_id);
} }
void Database::AddSharedAccount(Account& ac, const wxString& granted) void Database::AddSharedAccount(Account& ac, const wxString& granted)
{ {
wxString req; wxString req;
wxSQLite3ResultSet set;
req = wxT("INSERT INTO shared_account ('id', 'user') VALUES ('") + ac.id + wxT("', '") + granted + wxT("'"); req = wxT("SELECT id FROM user WHERE name='") + granted + wxT("'");
EXECUTE_SQL_QUERY(req, set, );
req = wxT("INSERT INTO shared_account ('account', 'user') VALUES ('") + ac.id + wxT("', '") + set.GetAsString(wxT("id")) + wxT("')");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
if (!ac.shared)
{
ac.shared = true;
UpdateAccount(ac);
}
}
void Database::RemoveSharedAccount(Account& ac, const wxString& granted)
{
wxString req;
wxSQLite3ResultSet set;
req = wxT("DELETE FROM shared_account WHERE user='") + granted + wxT("' AND account='") + ac.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
req = wxT("SELECT COUNT(user) AS cnt FROM shared_account WHERE account='") + ac.id + wxT("'");
EXECUTE_SQL_QUERY(req, set, );
if (!set.GetInt(wxT("cnt")))
{
ac.shared = false;
UpdateAccount(ac);
}
} }
wxString Database::AddCategory(User* user, Category& category) wxString Database::AddCategory(User* user, Category& category)
@ -817,6 +934,35 @@ void Database::DeleteCategory(User* user, Category& category)
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
} }
bool Database::LoadCategory(const wxString& id, const wxString& name, Category& category)
{
wxSQLite3ResultSet set;
wxString req;
bool ret = false ;
if (id.Length())
req = wxT("SELECT * FROM category WHERE id='") + id + wxT("'");
else
req = wxT("SELECT * FROM category WHERE name='") + name + wxT("'");
EXECUTE_SQL_QUERY(req, set, false);
if (set.NextRow())
{
category.id = set.GetAsString(wxT("id"));
category.parent = set.GetAsString(wxT("parent"));
category.name = set.GetAsString(wxT("name"));
category.backcolor = wxColour(set.GetAsString(wxT("backcolor")));
category.forecolor = wxColour(set.GetAsString(wxT("forecolor")));
category.font = set.GetAsString(wxT("font"));
ret = true;
}
set.Finalize();
return ret;
}
std::map<int, std::vector<int> > Database::GetAllOperations(User* user) std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
{ {
wxString req, req2, reqUnion; wxString req, req2, reqUnion;
@ -1016,33 +1162,26 @@ void Database::KillMe(User* user)
if (!user->_accounts.empty()) if (!user->_accounts.empty())
{ {
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++)
DeleteAccount(user, *it);
it = user->_accounts.begin(); it = user->_accounts.begin();
req = wxT("DELETE FROM account_amount WHERE account IN('") + it->id; if (it->is_owner)
req = wxT("DELETE FROM operation WHERE account IN('") + it->id;
else
req = wxT("DELETE FROM operation WHERE account IN('-1");
it++; it++;
for (;it != user->_accounts.end(); it++) for (;it != user->_accounts.end(); it++)
{ {
req += wxT("', '") + it->id ; if (it->is_owner)
req += wxT("', '") + it->id ;
} }
req += wxT("')"); req += wxT("')");
req += wxT(" OR (user='") + user->_id + wxT("' AND account='')");
EXECUTE_SQL_UPDATE(req, );
it = user->_accounts.begin();
req = wxT("DELETE FROM operation WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += wxT("', '") + it->id ;
}
req += wxT("')");
req += wxT(" OR user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
} }
req = wxT("DELETE FROM account WHERE user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
req = wxT("DELETE FROM category WHERE user='") + user->_id + wxT("'"); req = wxT("DELETE FROM category WHERE user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
@ -1281,7 +1420,7 @@ void Database::GetStats(User* user, const wxString& monthFrom, const wxString& y
std::map<wxString, double>* Database::GetNotChecked(User* user, int month, int year) std::map<wxString, double>* Database::GetNotChecked(User* user, int month, int year)
{ {
std::vector<Account>::iterator accountIt; std::vector<Account>::iterator accountIt;
std::map<wxString, double>* res = new std::map<wxString, double>; std::map<wxString, double>* res = new std::map<wxString, double>;
wxSQLite3ResultSet set; wxSQLite3ResultSet set;
wxString req; wxString req;
@ -1304,3 +1443,44 @@ std::vector<Account>::iterator accountIt;
return res; return res;
} }
std::map<wxString, wxString> Database::getSharedAccountOwners(const wxString& account)
{
std::map<wxString, wxString> res;
wxSQLite3ResultSet set, set2;
wxString req;
req = wxT("SELECT user FROM shared_account WHERE account='") + account + wxT("'");
EXECUTE_SQL_QUERY(req, set, res);
while(set.NextRow())
{
req = wxT("SELECT name FROM user WHERE id='") + set.GetAsString(wxT("user")) + wxT("'");
EXECUTE_SQL_QUERY(req, set2, res);
res[set2.GetAsString(wxT("name"))] = set.GetAsString(wxT("user"));
}
return res;
}
wxString Database::getSharedAccountOwner(const wxString& account)
{
wxSQLite3ResultSet set, set2;
wxString req;
req = wxT("SELECT user FROM account WHERE id='") + account + wxT("'");
EXECUTE_SQL_QUERY(req, set, wxT(""));
while(set.NextRow())
{
req = wxT("SELECT name FROM user WHERE id='") + set.GetAsString(wxT("user")) + wxT("'");
EXECUTE_SQL_QUERY(req, set2, wxT(""));
}
return set2.GetAsString(wxT("name"));
}

View File

@ -34,6 +34,7 @@
#define INIT_SCRIPT "init.sql" #define INIT_SCRIPT "init.sql"
class KissCount; class KissCount;
class User;
class Database class Database
{ {
@ -50,6 +51,10 @@ public:
wxString AddOperation(User* user, Operation& op); wxString AddOperation(User* user, Operation& op);
void DeleteOperation(Operation& op); void DeleteOperation(Operation& op);
void DeleteOperations(User* user, int month, int year); void DeleteOperations(User* user, int month, int year);
bool LoadOperation(User* user, const wxString& id);
double MetaAmount(const wxString& id);
double MetaPositiveAmount(const wxString& id);
double GetAccountAmount(const wxString& id, int month, int year); double GetAccountAmount(const wxString& id, int month, int year);
void SetAccountAmount(int month, int year, const wxString& accountId, double amount); void SetAccountAmount(int month, int year, const wxString& accountId, double amount);
@ -57,10 +62,12 @@ public:
void UpdateAccount(Account& ac); void UpdateAccount(Account& ac);
void DeleteAccount(User* user, Account& ac); void DeleteAccount(User* user, Account& ac);
void AddSharedAccount(Account& ac, const wxString& granted); void AddSharedAccount(Account& ac, const wxString& granted);
void RemoveSharedAccount(Account& ac, const wxString& granted);
wxString AddCategory(User* user, Category& category); wxString AddCategory(User* user, Category& category);
void UpdateCategory(Category& category); void UpdateCategory(Category& category);
void DeleteCategory(User* user, Category& category); void DeleteCategory(User* user, Category& category);
bool LoadCategory(const wxString& id, const wxString& name, Category& category);
std::map<int, std::vector<int> > GetAllOperations(User* user); std::map<int, std::vector<int> > GetAllOperations(User* user);
void GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo); void GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo);
@ -82,6 +89,9 @@ public:
void KillMe(User* user); void KillMe(User* user);
bool GetOperation(const wxString& id, Operation* op); bool GetOperation(const wxString& id, Operation* op);
std::map<wxString, wxString> getSharedAccountOwners(const wxString& account);
wxString getSharedAccountOwner(const wxString& account);
std::map<wxString, double>* GetNotChecked(User* user, int month, int year); std::map<wxString, double>* GetNotChecked(User* user, int month, int year);
private: private:

View File

@ -19,6 +19,9 @@
#include "User.h" #include "User.h"
User::User(Database* db) : _db(db)
{}
User::~User() User::~User()
{ {
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it; std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
@ -41,6 +44,9 @@ Category User::GetCategory(wxString& catId)
if (it->id == catId) if (it->id == catId)
return *it; return *it;
if (_db->LoadCategory(catId, wxT(""), cat))
return cat;
cat.id = wxT("0"); cat.id = wxT("0");
cat.parent = wxT("0"); cat.parent = wxT("0");
cat.name = _("Unknown"); cat.name = _("Unknown");
@ -53,32 +59,46 @@ Category User::GetCategory(wxString& catId)
wxString User::GetCategoryName(wxString& catId) wxString User::GetCategoryName(wxString& catId)
{ {
Category cat;
std::vector<Category>::iterator it; std::vector<Category>::iterator it;
for (it=_categories.begin(); it !=_categories.end(); it++) for (it=_categories.begin(); it !=_categories.end(); it++)
if (it->id == catId) if (it->id == catId)
return it->name; return it->name;
if (_db->LoadCategory(catId, wxT(""), cat))
return cat.name;
return _("Unknown") ; return _("Unknown") ;
} }
wxString User::GetCategoryId(wxString& catName) wxString User::GetCategoryId(wxString& catName)
{ {
std::vector<Category>::iterator it; std::vector<Category>::iterator it;
Category cat;
for (it=_categories.begin(); it !=_categories.end(); it++) for (it=_categories.begin(); it !=_categories.end(); it++)
if (it->name == catName) if (it->name == catName)
return it->id; return it->id;
if ( _db->LoadCategory(wxT(""), catName, cat))
return cat.id;
return wxT("0") ; return wxT("0") ;
} }
const wxFont& User::GetCategoryFont(wxString& catId) const wxFont User::GetCategoryFont(wxString& catId)
{ {
wxFont f; wxFont f;
Category cat;
for (unsigned int i=0; i<_categories.size(); i++) for (unsigned int i=0; i<_categories.size(); i++)
if (_categories[i].id == catId) if (_categories[i].id == catId)
return _categoriesFonts[i]; return _categoriesFonts[i];
if (_db->LoadCategory(catId, wxT(""), cat))
return KissCount::ExtractFont(cat.font);
return f; return f;
} }
@ -176,9 +196,14 @@ void User::Group(const Operation& op)
// Already into childs // Already into childs
if (it2 != it->childs.end()) return; if (it2 != it->childs.end()) return;
it->childs.push_back(op.id); it->childs.push_back(op.id);
break; return;
} }
} }
if (_db->LoadOperation(this, op.parent))
{
(*_operations[op.year])[op.month][(*_operations[op.year])[op.month].size()-1].childs.push_back(op.id);
}
} }
void User::UnGroup(const Operation& op) void User::UnGroup(const Operation& op)

View File

@ -28,10 +28,14 @@
#include "Category.h" #include "Category.h"
#include "Account.h" #include "Account.h"
#include "Operation.h" #include "Operation.h"
#include "Database.h"
class Database;
class User class User
{ {
public: public:
User(Database* db);
~User(); ~User();
wxString _id; wxString _id;
@ -46,7 +50,7 @@ public:
Category GetCategory(wxString& catId); Category GetCategory(wxString& catId);
wxString GetCategoryName(wxString& catId); wxString GetCategoryName(wxString& catId);
wxString GetCategoryId(wxString& catName); wxString GetCategoryId(wxString& catName);
const wxFont& GetCategoryFont(wxString& catId); const wxFont GetCategoryFont(wxString& catId);
wxString GetAccountName(const wxString& accountId); wxString GetAccountName(const wxString& accountId);
wxString GetAccountId(wxString& accountName); wxString GetAccountId(wxString& accountName);
int GetCategoriesNumber(); int GetCategoriesNumber();
@ -57,6 +61,9 @@ public:
void Group(const Operation& op); void Group(const Operation& op);
void UnGroup(const Operation& op); void UnGroup(const Operation& op);
void ResolveGroups(int year); void ResolveGroups(int year);
private:
Database* _db;
}; };
#endif #endif

View File

@ -20,7 +20,14 @@
#ifndef MODEL_H #ifndef MODEL_H
#define MODEL_H #define MODEL_H
class User;
class Database;
class Account;
class Operation;
#include "User.h" #include "User.h"
#include "Database.h" #include "Database.h"
#include "Account.h"
#include "Operation.h"
#endif #endif

View File

@ -19,11 +19,11 @@
#include "PreferencesPanel.h" #include "PreferencesPanel.h"
enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_SHARED, ACCOUNT_DEFAULT, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT}; enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_DEFAULT, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT};
enum {CATEGORY_NAME, CATEGORY_BACKGROUND_COLOR, CATEGORY_FOREGROUND_COLOR, CATEGORY_FONT, CATEGORY_DELETE, NUMBER_COLS_CATEGORY}; 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, enum {CATEGORIES_GRID_ID=1, ACCOUNTS_GRID_ID, NAME_ID, CHANGE_NAME_ID, CHANGE_PASSWORD_ID, KILL_ME_ID, LANGUAGE_ID,
OPERATION_ORDER_ID}; OPERATION_ORDER_ID, SHARED_WITH_ID};
BEGIN_EVENT_TABLE(PreferencesPanel, wxPanel) BEGIN_EVENT_TABLE(PreferencesPanel, wxPanel)
EVT_BUTTON(CHANGE_NAME_ID, PreferencesPanel::OnChangeName) EVT_BUTTON(CHANGE_NAME_ID, PreferencesPanel::OnChangeName)
@ -31,24 +31,28 @@ EVT_BUTTON(CHANGE_PASSWORD_ID, PreferencesPanel::OnChangePassword)
EVT_BUTTON(KILL_ME_ID, PreferencesPanel::OnKillMe) EVT_BUTTON(KILL_ME_ID, PreferencesPanel::OnKillMe)
EVT_GRID_CMD_CELL_CHANGE(CATEGORIES_GRID_ID, PreferencesPanel::OnCategoryModified) EVT_GRID_CMD_CELL_CHANGE(CATEGORIES_GRID_ID, PreferencesPanel::OnCategoryModified)
EVT_GRID_CMD_CELL_CHANGE(ACCOUNTS_GRID_ID, PreferencesPanel::OnAccountModified) EVT_GRID_CMD_CELL_CHANGE(ACCOUNTS_GRID_ID, PreferencesPanel::OnAccountModified)
EVT_GRID_CMD_SELECT_CELL(ACCOUNTS_GRID_ID, PreferencesPanel::OnAccountCellChanged)
EVT_COMBOBOX(OPERATION_ORDER_ID, PreferencesPanel::OnOperationOrderChange) EVT_COMBOBOX(OPERATION_ORDER_ID, PreferencesPanel::OnOperationOrderChange)
EVT_COMBOBOX(LANGUAGE_ID, PreferencesPanel::OnLanguageChange) EVT_COMBOBOX(LANGUAGE_ID, PreferencesPanel::OnLanguageChange)
EVT_CHECKLISTBOX(SHARED_WITH_ID, PreferencesPanel::OnSharedChange)
EVT_SHOW(PreferencesPanel::OnShow) EVT_SHOW(PreferencesPanel::OnShow)
END_EVENT_TABLE() END_EVENT_TABLE()
PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent) PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _sharedWith(NULL), _curAccountRow(-1)
{ {
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL);
//wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); //wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
wxStaticBox* staticUser, *staticAccount, *staticCategories, *staticLanguage, *staticOperationOrder; wxStaticBox* staticUser, *staticAccount, *staticCategories, *staticLanguage, *staticOperationOrder, *staticSharedWith;
User* user = _kiss->GetUser(); User* user = _kiss->GetUser();
wxGridBagSizer *gridBagSizer; wxGridBagSizer *gridBagSizer;
wxStaticText* label; wxStaticText* label;
wxButton* buttonChangeName, *buttonChangePassword, *killMe; wxButton* buttonChangeName, *buttonChangePassword, *killMe;
wxStaticBoxSizer * staticBoxSizer; wxStaticBoxSizer * staticBoxSizer;
std::list<wxString> users;
std::list<wxString>::iterator it;
SetSizer(vbox); SetSizer(vbox);
staticUser = new wxStaticBox(this, wxID_ANY, _("User")); staticUser = new wxStaticBox(this, wxID_ANY, _("User"));
@ -56,6 +60,7 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
staticCategories = new wxStaticBox(this, wxID_ANY, _("Categories")); staticCategories = new wxStaticBox(this, wxID_ANY, _("Categories"));
staticLanguage = new wxStaticBox(this, wxID_ANY, _("Language")); staticLanguage = new wxStaticBox(this, wxID_ANY, _("Language"));
staticOperationOrder = new wxStaticBox(this, wxID_ANY, _("Operation order")); staticOperationOrder = new wxStaticBox(this, wxID_ANY, _("Operation order"));
staticSharedWith = new wxStaticBox(this, wxID_ANY, _("Shared with"));
// User // User
staticBoxSizer = new wxStaticBoxSizer (staticUser, wxVERTICAL); staticBoxSizer = new wxStaticBoxSizer (staticUser, wxVERTICAL);
@ -84,9 +89,9 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
staticBoxSizer = new wxStaticBoxSizer (staticAccount, wxVERTICAL); staticBoxSizer = new wxStaticBoxSizer (staticAccount, wxVERTICAL);
{ {
int clicks[] = {ACCOUNT_SHARED, ACCOUNT_DEFAULT, ACCOUNT_DELETE}; int clicks[] = {ACCOUNT_DEFAULT, ACCOUNT_DELETE};
_accountsGrid = new wxMyGrid(this, ACCOUNTS_GRID_ID, clicks, 3); _accountsGrid = new wxMyGrid(this, ACCOUNTS_GRID_ID, clicks, 2);
} }
InitAccounts(user); InitAccounts(user);
@ -96,6 +101,22 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
hbox1->Add(staticBoxSizer); hbox1->Add(staticBoxSizer);
hbox1->Add(-1, 20); hbox1->Add(-1, 20);
staticBoxSizer = new wxStaticBoxSizer (staticSharedWith, wxVERTICAL);
_sharedWith = new wxCheckListBox(this, SHARED_WITH_ID);
staticBoxSizer->Add(_sharedWith);
users = _kiss->GetUsers();
for(it=users.begin(); it!=users.end(); it++)
if (*it != user->_name)
_sharedWith->Append(*it);
_sharedWith->Enable(false);
hbox1->Add(staticBoxSizer);
hbox1->Add(-1, 20);
// Categories // Categories
staticBoxSizer = new wxStaticBoxSizer (staticCategories, wxVERTICAL); staticBoxSizer = new wxStaticBoxSizer (staticCategories, wxVERTICAL);
@ -109,12 +130,12 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
InitCategories(user); InitCategories(user);
hbox1->Add(staticBoxSizer);
hbox1->Add(-1, 20);
vbox->Add(hbox1); vbox->Add(hbox1);
vbox->Add(-1, 20); vbox->Add(-1, 20);
vbox->Add(staticBoxSizer);
vbox->Add(-1, 20);
// Operation Order // Operation Order
staticBoxSizer = new wxStaticBoxSizer (staticOperationOrder, wxVERTICAL); staticBoxSizer = new wxStaticBoxSizer (staticOperationOrder, wxVERTICAL);
@ -162,7 +183,6 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->SetRowLabelSize(0); _accountsGrid->SetRowLabelSize(0);
_accountsGrid->SetColLabelValue(ACCOUNT_NAME, _("Name")); _accountsGrid->SetColLabelValue(ACCOUNT_NAME, _("Name"));
_accountsGrid->SetColLabelValue(ACCOUNT_NUMBER, _("Number")); _accountsGrid->SetColLabelValue(ACCOUNT_NUMBER, _("Number"));
_accountsGrid->SetColLabelValue(ACCOUNT_SHARED, _("Shared"));
_accountsGrid->SetColLabelValue(ACCOUNT_DEFAULT, _("Default")); _accountsGrid->SetColLabelValue(ACCOUNT_DEFAULT, _("Default"));
_accountsGrid->SetColLabelValue(ACCOUNT_DELETE, _("Delete")); _accountsGrid->SetColLabelValue(ACCOUNT_DELETE, _("Delete"));
_accountsGrid->SetDefaultCellFont(font); _accountsGrid->SetDefaultCellFont(font);
@ -177,22 +197,20 @@ void PreferencesPanel::InitAccounts(User* user)
else else
_accountsGrid->SetCellValue(curLine, ACCOUNT_NUMBER, it->number); _accountsGrid->SetCellValue(curLine, ACCOUNT_NUMBER, it->number);
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_SHARED, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellEditor(curLine, ACCOUNT_NUMBER, new wxGridCellStarEditor ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_SHARED, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellRenderer(curLine, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ()); _accountsGrid->SetCellEditor(curLine, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DELETE, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellRenderer(curLine, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DELETE, new wxGridCellBoolEditor ()); _accountsGrid->SetCellEditor(curLine, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
_accountsGrid->SetCellValue(curLine, ACCOUNT_SHARED, (it->shared)?wxT("1"):wxT("0"));
_accountsGrid->SetCellValue(curLine, ACCOUNT_DEFAULT, (it->_default)?wxT("1"):wxT("0")); _accountsGrid->SetCellValue(curLine, ACCOUNT_DEFAULT, (it->_default)?wxT("1"):wxT("0"));
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_SHARED, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE); _accountsGrid->SetCellAlignment(curLine, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE); _accountsGrid->SetCellAlignment(curLine, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
if (!it->is_owner) if (!it->is_owner)
{ {
_accountsGrid->SetReadOnly(curLine, ACCOUNT_SHARED, true); _accountsGrid->SetReadOnly(curLine, ACCOUNT_NAME, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_NUMBER, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true); _accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
} }
} }
@ -200,7 +218,6 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->AutoSizeColumns(true); _accountsGrid->AutoSizeColumns(true);
_accountsGrid->AppendRows(); _accountsGrid->AppendRows();
_accountsGrid->SetReadOnly(curLine, ACCOUNT_SHARED, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true); _accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DELETE, true); _accountsGrid->SetReadOnly(curLine, ACCOUNT_DELETE, true);
} }
@ -297,7 +314,7 @@ void PreferencesPanel::InitOperationOrder(User* user)
void PreferencesPanel::OnAccountModified(wxGridEvent& event) void PreferencesPanel::OnAccountModified(wxGridEvent& event)
{ {
int op_complete = 2; int op_complete = 1;
wxString value ; wxString value ;
Account new_account, account; Account new_account, account;
User* user = _kiss->GetUser(); User* user = _kiss->GetUser();
@ -324,12 +341,6 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
op_complete--; op_complete--;
} }
value = _accountsGrid->GetCellValue(row, ACCOUNT_SHARED);
if (value.Length() && value != wxT("0"))
new_account.shared = true;
else
new_account.shared = false;
value = _accountsGrid->GetCellValue(row, ACCOUNT_DEFAULT); value = _accountsGrid->GetCellValue(row, ACCOUNT_DEFAULT);
if (value.Length() && value != wxT("0")) if (value.Length() && value != wxT("0"))
new_account._default = true; new_account._default = true;
@ -414,17 +425,13 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
return ; return ;
} }
_accountsGrid->SetCellRenderer(row, ACCOUNT_SHARED, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_SHARED, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(row, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellRenderer(row, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ()); _accountsGrid->SetCellEditor(row, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(row, ACCOUNT_DELETE, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellRenderer(row, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_DELETE, new wxGridCellBoolEditor ()); _accountsGrid->SetCellEditor(row, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
_accountsGrid->SetCellAlignment(row, ACCOUNT_SHARED, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(row, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE); _accountsGrid->SetCellAlignment(row, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(row, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE); _accountsGrid->SetCellAlignment(row, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetReadOnly(row, ACCOUNT_SHARED, false);
_accountsGrid->SetReadOnly(row, ACCOUNT_DEFAULT, false); _accountsGrid->SetReadOnly(row, ACCOUNT_DEFAULT, false);
_accountsGrid->SetReadOnly(row, ACCOUNT_DELETE, false); _accountsGrid->SetReadOnly(row, ACCOUNT_DELETE, false);
@ -437,7 +444,6 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
_accountsGrid->AutoSizeColumns(true); _accountsGrid->AutoSizeColumns(true);
_accountsGrid->AppendRows(); _accountsGrid->AppendRows();
_accountsGrid->SetReadOnly(row+1, ACCOUNT_SHARED, true);
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DEFAULT, true); _accountsGrid->SetReadOnly(row+1, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DELETE, true); _accountsGrid->SetReadOnly(row+1, ACCOUNT_DELETE, true);
@ -449,6 +455,74 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
inModification = false; inModification = false;
} }
void PreferencesPanel::OnAccountCellChanged(wxGridEvent& event)
{
User* user = _kiss->GetUser();
int row = event.GetRow();
std::map<wxString, wxString>::iterator it;
int i;
bool own;
wxString owner;
if (!_sharedWith || _curAccountRow == row)
{
event.Skip();
return ;
}
_curAccountRow = row ;
if (row >= (int) user->_accounts.size())
{
for(i=0; i<(int)_sharedWith->GetCount(); i++)
_sharedWith->Check(i, false);
own = false;
}
else
{
_sharedOwners = _kiss->getSharedAccountOwners(user->_accounts[row].id);
owner = _kiss->getSharedAccountOwner(user->_accounts[row].id);
for(i=0; i<(int)_sharedWith->GetCount(); i++)
{
_sharedWith->Check(i, _sharedOwners[_sharedWith->GetString(i)].Length() > 0 ||
_sharedWith->GetString(i) == owner);
}
own = user->_accounts[row].is_owner;
}
_sharedWith->Enable(own);
event.Skip();
}
void PreferencesPanel::OnSharedChange(wxCommandEvent& event)
{
User* user = _kiss->GetUser();
// Event is fired before change
if (_sharedWith->IsChecked(event.GetSelection()))
{
if (!user->_accounts[_curAccountRow].shared)
_accountsGrid->SetCellValue(_curAccountRow, ACCOUNT_NUMBER,
user->_accounts[_curAccountRow].number + wxT("*"));
_kiss->AddSharedAccount(user->_accounts[_curAccountRow],
_sharedWith->GetString(event.GetSelection()));
}
else
{
_kiss->RemoveSharedAccount(user->_accounts[_curAccountRow],
_sharedOwners[_sharedWith->GetString(
event.GetSelection())]);
if (!user->_accounts[_curAccountRow].shared)
_accountsGrid->SetCellValue(_curAccountRow, ACCOUNT_NUMBER, user->_accounts[_curAccountRow].number);
}
_wxUI->NeedReload();
event.Skip();
}
void PreferencesPanel::OnCategoryModified(wxGridEvent& event) void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
{ {
int op_complete = 1; int op_complete = 1;

View File

@ -36,6 +36,7 @@
#include <model/model.h> #include <model/model.h>
#include "PasswordDialog.h" #include "PasswordDialog.h"
#include "SupportedLanguages.h" #include "SupportedLanguages.h"
#include "wxGridCellStarEditor.h"
class wxUI; class wxUI;
class KissCount; class KissCount;
@ -47,6 +48,8 @@ public:
void ChangeUser(); void ChangeUser();
void OnAccountModified(wxGridEvent& event); void OnAccountModified(wxGridEvent& event);
void OnAccountCellChanged(wxGridEvent& event);
void OnSharedChange(wxCommandEvent& event);
void OnCategoryModified(wxGridEvent& event); void OnCategoryModified(wxGridEvent& event);
void OnChangeName(wxCommandEvent& event); void OnChangeName(wxCommandEvent& event);
void OnChangePassword(wxCommandEvent& event); void OnChangePassword(wxCommandEvent& event);
@ -63,6 +66,9 @@ private:
wxTextCtrl* _name; wxTextCtrl* _name;
wxBitmapComboBox* _language; wxBitmapComboBox* _language;
wxComboBox* _operationOrder; wxComboBox* _operationOrder;
wxCheckListBox* _sharedWith;
int _curAccountRow;
std::map<wxString, wxString> _sharedOwners;
void InitAccounts(User* user); void InitAccounts(User* user);
void InitCategories(User* user); void InitCategories(User* user);

View File

@ -352,13 +352,7 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
if (op.meta && !op.amount) if (op.meta && !op.amount)
{ {
amount = 0; amount = _kiss->MetaPositiveAmount(op.id);
for(it2=op.childs.begin(); it2!=op.childs.end(); it2++)
{
op2 = GetOperation(*it2);
if (op2.amount > 0)
amount += op2.amount;
}
SetCellValue(line, DEBIT, wxString::Format(wxT("%.2lf"), amount)); SetCellValue(line, DEBIT, wxString::Format(wxT("%.2lf"), amount));
SetCellValue(line, CREDIT, wxString::Format(wxT("%.2lf"), amount)); SetCellValue(line, CREDIT, wxString::Format(wxT("%.2lf"), amount));
@ -979,13 +973,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
if (!_displayedOperations[row].amount) if (!_displayedOperations[row].amount)
{ {
amount = 0; amount = _kiss->MetaPositiveAmount(new_op.id);
for(it=new_op.childs.begin(); it!=new_op.childs.end(); it++)
{
op2 = GetOperation(*it);
if (op2.amount > 0)
amount += op2.amount;
}
SetCellValue(row, DEBIT, wxString::Format(wxT("%.2lf"), amount)); SetCellValue(row, DEBIT, wxString::Format(wxT("%.2lf"), amount));
SetCellValue(row, CREDIT, wxString::Format(wxT("%.2lf"), amount)); SetCellValue(row, CREDIT, wxString::Format(wxT("%.2lf"), amount));
@ -1030,7 +1018,6 @@ void GridAccount::UpdateMeta(Operation& op)
op.month = op_.month; op.month = op_.month;
op.day = op_.day; op.day = op_.day;
} }
op.amount += op_.amount;
op.checked &= op_.checked; op.checked &= op_.checked;
if (!op.description.Length() && op_.description.Length()) if (!op.description.Length() && op_.description.Length())
op.description = op_.description; op.description = op_.description;
@ -1053,6 +1040,8 @@ void GridAccount::UpdateMeta(Operation& op)
if (updateCat) if (updateCat)
op.category = category; op.category = category;
op.amount = _kiss->MetaAmount(op.id);
UpdateOperation(op); UpdateOperation(op);
} }

View File

@ -0,0 +1,53 @@
/*
Copyright 2010 Grégory Soutadé
This file is part of KissCount.
KissCount 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.
KissCount 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 KissCount. If not, see <http://www.gnu.org/licenses/>.
*/
#include "wxGridCellStarEditor.h"
void wxGridCellStarEditor::BeginEdit (int row, int col, wxGrid *grid) {
static bool inModification = false;
wxString value;
if (inModification) return ;
inModification = true;
value = grid->GetCellValue(row, col);
_has_star = (value[value.Length()-1] == '*');
if (_has_star)
grid->SetCellValue(row, col, value.RemoveLast());
wxGridCellTextEditor::BeginEdit(row, col, grid);
inModification = false;
}
bool wxGridCellStarEditor::EndEdit (int row, int col, wxGrid *grid/*, const wxString &oldval, wxString *newval*/)
{
wxString res = GetValue();
bool ret;
ret = wxGridCellTextEditor::EndEdit(row, col, grid);
if (_has_star)
grid->SetCellValue(row, col, res + wxT("*"));
return ret;
}

View File

@ -0,0 +1,37 @@
/*
Copyright 2010 Grégory Soutadé
This file is part of KissCount.
KissCount 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.
KissCount 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 KissCount. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WXGRIDCELLSTAREDITOR_H
#define WXGRIDCELLSTAREDITOR_H
#include <wx/wx.h>
#include <wx/grid.h>
#include <wx/dc.h>
class wxGridCellStarEditor : public wxGridCellTextEditor
{
public:
void BeginEdit (int row, int col, wxGrid *grid);
bool EndEdit (int row, int col, wxGrid *grid/*, const wxString &oldval, wxString *newval*/);
private:
bool _has_star;
};
#endif