From bf417a503df59519c4ef535b7d06d462c506dff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Mon, 14 Feb 2011 20:56:59 +0100 Subject: [PATCH] Add virtual accounts (potential bugs) --- ChangeLog | 3 +- init.sql | 2 +- src/controller/KissCount.cpp | 10 +++- src/controller/KissCount.h | 1 + src/model/Account.h | 1 + src/model/Database.cpp | 102 ++++++++++++++++++++++++++++------ src/model/Database.h | 7 ++- src/model/Database_Update.cpp | 10 +++- src/model/Operation.h | 1 + src/model/User.cpp | 7 +++ src/view/AccountPanel.cpp | 11 +++- src/view/PreferencesPanel.cpp | 16 +++++- src/view/grid/GridAccount.cpp | 4 ++ www/index.php | 2 +- 14 files changed, 150 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8dddf06..f23b3bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -v0.2_dev (13/02/2011) +v0.2_dev (14/02/2011) ** User ** Better use of sizers (so better interface!) @@ -8,6 +8,7 @@ v0.2_dev (13/02/2011) Possibility to choose a replacement when deleting accounts and categories Possibility to find operations with unknown category/account Possibility to work on multiple operations (rename, change category, change account) + Add virtual accounts ** Dev ** Use a factory to create panels (prepare for plug-in) diff --git a/init.sql b/init.sql index 86d246d..56b957e 100755 --- a/init.sql +++ b/init.sql @@ -3,7 +3,7 @@ CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255), password VARCHAR(2 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)); +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), virtual 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), fix_cost CHAR(1)); CREATE TABLE preference(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), value VARCHAR(255)); INSERT INTO kisscount ("db_version") VALUES ("2"); \ No newline at end of file diff --git a/src/controller/KissCount.cpp b/src/controller/KissCount.cpp index 9c33bd4..53f3bae 100644 --- a/src/controller/KissCount.cpp +++ b/src/controller/KissCount.cpp @@ -104,7 +104,7 @@ void KissCount::UpdateOperation(Operation& op) op.transfert = wxT(""); _user->LinkOrUnlinkOperation(op); - _db->UpdateOperation(op); + _db->UpdateOperation(_user, op); // Link _user->LinkOrUnlinkOperation(op); @@ -127,7 +127,7 @@ void KissCount::DeleteOperation(Operation& op) op.transfert = wxT(""); _user->LinkOrUnlinkOperation(op); } - _db->DeleteOperation(op); + _db->DeleteOperation(_user, op); } void KissCount::DeleteOperations(int month, int year) @@ -310,6 +310,7 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year op.checked = false; op.id = AddOperation(op); op.childs.clear(); + op._virtual = false; if (op.meta) meta[it->id] = op.id; (*_user->_operations[yearTo])[monthTo].push_back(op); @@ -494,6 +495,11 @@ std::map* KissCount::GetNotChecked(int month, int year) return _db->GetNotChecked(_user, month, year); } +std::map* KissCount::GetVirtualAmount(int month, int year) +{ + return _db->GetVirtualAmount(_user, month, year); +} + wxFont KissCount::ExtractFont(wxString strFont) { long int pos, pointSize, family, style, weight; diff --git a/src/controller/KissCount.h b/src/controller/KissCount.h index b27fbda..229af3f 100644 --- a/src/controller/KissCount.h +++ b/src/controller/KissCount.h @@ -97,6 +97,7 @@ public: std::map* categories); std::map* GetNotChecked(int month, int year); + std::map* GetVirtualAmount(int month, int year); static wxFont ExtractFont(wxString strFont); static wxString CompactFont(const wxFont& font); diff --git a/src/model/Account.h b/src/model/Account.h index ce94877..211759a 100644 --- a/src/model/Account.h +++ b/src/model/Account.h @@ -33,6 +33,7 @@ public: bool blocked; bool _default; bool is_owner; + bool _virtual; }; #endif diff --git a/src/model/Database.cpp b/src/model/Database.cpp index 05baac6..6b5e8a9 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -222,6 +222,7 @@ User* Database::LoadUser(const wxString& name) account.shared = set.GetBool(wxT("shared")); account.blocked = set.GetBool(wxT("blocked")); account._default = set.GetBool(wxT("default_account")); + account._virtual = set.GetBool(wxT("virtual")); account.is_owner = true; user->_accounts.push_back(account); } @@ -239,6 +240,7 @@ User* Database::LoadUser(const wxString& name) account.shared = set.GetBool(wxT("shared")); account.blocked = set.GetBool(wxT("blocked")); account._default = set.GetBool(wxT("default_account")); + account._virtual = set.GetBool(wxT("virtual")); account.is_owner = false; user->_accounts.push_back(account); } @@ -339,6 +341,7 @@ void Database::LoadYear(User* user, int year) op.transfert = set.GetAsString(wxT("transfert")); op.formula = set.GetAsString(wxT("formula")); op.meta = set.GetBool(wxT("meta")); + op._virtual = set.GetBool(wxT("virtual")); (*user->_operations[op.year])[op.month].push_back(op); } @@ -427,26 +430,30 @@ bool Database::GetOperation(const wxString& id, Operation* op) 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->formula = set.GetAsString(wxT("formula")); op->meta = set.GetBool(wxT("meta")); + op->_virtual = set.GetBool(wxT("virtual")); return true; } -void Database::LinkOrUnlinkOperation(Operation& op) +void Database::LinkOrUnlinkOperation(User* user, Operation& op) { Operation linked; wxString req; wxSQLite3ResultSet set; + Account account, account2; + bool _virtual; if (op.transfert.Length()) { // No one or not linked if (!GetOperation(op.transfert, &linked) || op.description != linked.description || op.amount != -linked.amount || op.account == linked.account) { - req = wxT("UPDATE operation SET transfert='' where id='") + op.id + wxT("'") ; + req = wxT("UPDATE operation SET transfert='' virtual='0' WHERE id='") + op.id + wxT("'") ; EXECUTE_SQL_UPDATE(req, ); op.transfert = wxT(""); + op._virtual = 0; return; } } @@ -459,11 +466,11 @@ void Database::LinkOrUnlinkOperation(Operation& op) if (set.NextRow()) { - req = wxT("UPDATE operation SET transfert='' where id='") + set.GetAsString(wxT("id")) + wxT("'") ; + req = wxT("UPDATE operation SET transfert='', virtual='0' WHERE id='") + set.GetAsString(wxT("id")) + wxT("'") ; EXECUTE_SQL_UPDATE(req, ); } - req = wxT("SELECT id FROM operation WHERE description=\"") + op.description + wxT("\""); + req = wxT("SELECT id, account FROM operation WHERE description=\"") + op.description + wxT("\""); req += wxT(" AND month='") + wxString::Format(wxT("%d"), op.month) + wxT("'"); req += wxT(" AND year='") + wxString::Format(wxT("%d"), op.year) + wxT("'"); req += wxT(" AND amount='") + DoubleToString(-op.amount) + wxT("'"); @@ -473,6 +480,8 @@ void Database::LinkOrUnlinkOperation(Operation& op) EXECUTE_SQL_QUERY(req, set, ); + op._virtual = false; + // Don't need to link if (!set.NextRow()) return ; @@ -481,19 +490,37 @@ void Database::LinkOrUnlinkOperation(Operation& op) op.transfert = linked.id; - req = wxT("UPDATE operation SET transfert='") + linked.id + wxT("' where id='") + op.id + wxT("'") ; + account = user->GetAccount(op.account); + account2 = user->GetAccount(set.GetAsString(wxT("account"))); + + _virtual = account._virtual || account2._virtual; + + req = wxT("UPDATE operation SET transfert='") + linked.id + wxT("'"); + if (_virtual) + req += wxT(", virtual='1'"); + else + req += wxT(", virtual='0'"); + req += wxT(" WHERE id='") + op.id + wxT("'") ; + EXECUTE_SQL_UPDATE(req, ); - req = wxT("UPDATE operation SET transfert='") + op.id + wxT("' where id='") + linked.id + wxT("'") ; + req = wxT("UPDATE operation SET transfert='") + op.id + wxT("'") ; + if (_virtual) + req += wxT(", virtual='1'"); + else + req += wxT(", virtual='0'"); + req += wxT(" WHERE id='") + linked.id + wxT("'") ; EXECUTE_SQL_UPDATE(req, ); + + op._virtual = _virtual; } } -void Database::UpdateOperation(Operation& op) +void Database::UpdateOperation(User* user, Operation& op) { wxString req; - LinkOrUnlinkOperation(op); + LinkOrUnlinkOperation(user, op); ESCAPE_CHARS(op.description); @@ -519,12 +546,16 @@ void Database::UpdateOperation(Operation& op) req += wxT(", meta='1'"); else req += wxT(", meta='0'"); + if (op._virtual) + req += wxT(", virtual='1'"); + else + req += wxT(", virtual='0'"); req += wxT(", formula='") + op.formula + wxT("'"); req += wxT(" WHERE id='") + op.id + wxT("'"); EXECUTE_SQL_UPDATE(req, ); - LinkOrUnlinkOperation(op); + LinkOrUnlinkOperation(user, op); } wxString Database::AddOperation(User* user, Operation& op) @@ -534,7 +565,7 @@ wxString Database::AddOperation(User* user, Operation& op) ESCAPE_CHARS(op.description); - req = wxT("INSERT INTO operation ('user', 'parent', 'account', 'year', 'month', 'day', 'amount', 'description', 'category', 'fix_cost', 'formula', 'transfert', 'meta') VALUES ('") ; + req = wxT("INSERT INTO operation ('user', 'parent', 'account', 'year', 'month', 'day', 'amount', 'description', 'category', 'fix_cost', 'formula', 'transfert', 'meta', 'virtual') VALUES ('") ; req += user->_id + wxT("'"); req += wxT(", '") + op.parent + wxT("'"); req += wxT(", '") + op.account + wxT("'"); @@ -554,6 +585,10 @@ wxString Database::AddOperation(User* user, Operation& op) req += wxT(", '1'") ; else req += wxT(", '0'") ; + if (op._virtual) + req += wxT(", '1'") ; + else + req += wxT(", '0'") ; req += wxT(")"); EXECUTE_SQL_UPDATE(req, wxT("0")); @@ -562,19 +597,19 @@ wxString Database::AddOperation(User* user, Operation& op) op.id = res; - LinkOrUnlinkOperation(op); + LinkOrUnlinkOperation(user, op); return res; } -void Database::DeleteOperation(Operation& op) +void Database::DeleteOperation(User* user, Operation& op) { wxString req; req = wxT("DELETE FROM operation WHERE id='") + op.id + wxT("'"); EXECUTE_SQL_UPDATE(req, ); - LinkOrUnlinkOperation(op); + LinkOrUnlinkOperation(user, op); } void Database::DeleteOperations(User* user, int month, int year) @@ -638,8 +673,9 @@ bool Database::LoadOperation(User* user, const wxString& id) 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.formula = set.GetAsString(wxT("formula")); op.meta = set.GetBool(wxT("meta")); + op._virtual = set.GetBool(wxT("virtual")); if (user->_operations[op.year]) { @@ -747,7 +783,7 @@ wxString Database::AddAccount(User* user, Account& ac) { wxString req; - req = wxT("INSERT INTO account ('user', 'name', 'number', 'shared', 'blocked', 'default_account') VALUES ('") ; + req = wxT("INSERT INTO account ('user', 'name', 'number', 'shared', 'blocked', 'default_account', 'virtual') VALUES ('") ; req += user->_id + wxT("'"); req += wxT(", '") + ac.name + wxT("'"); req += wxT(", '") + ac.number + wxT("'"); @@ -763,6 +799,10 @@ wxString Database::AddAccount(User* user, Account& ac) req += wxT(", '1'") ; else req += wxT(", '0'") ; + if (ac._virtual) + req += wxT(", '1'") ; + else + req += wxT(", '0'") ; req += wxT(")"); EXECUTE_SQL_UPDATE(req, wxT("0")); @@ -788,6 +828,10 @@ void Database::UpdateAccount(Account& ac) req += wxT(", default_account='1'"); else req += wxT(", default_account='0'"); + if (ac._virtual) + req += wxT(", virtual='1'"); + else + req += wxT(", virtual='0'"); req += wxT(" WHERE id='") + ac.id + wxT("'"); EXECUTE_SQL_UPDATE(req, ); @@ -1595,6 +1639,32 @@ std::map* Database::GetNotChecked(User* user, int month, int y return res; } +std::map* Database::GetVirtualAmount(User* user, int month, int year) +{ + std::vector::iterator accountIt; + std::map* res = new std::map; + wxSQLite3ResultSet set; + wxString req; + + for (accountIt = user->_accounts.begin() ;accountIt != user->_accounts.end(); accountIt++) + { + req = wxT("SELECT SUM(amount) AS amount FROM operation WHERE account='") + accountIt->id + wxT("'"); + req += wxT(" AND virtual='1'"); + req += wxT(" AND meta='0'"); + req += wxT(" AND (year < '") + wxString::Format(wxT("%d"), year) + wxT("'") ; + req += wxT(" OR (year == '") + wxString::Format(wxT("%d"), year) + wxT("'") ; + req += wxT(" AND month < '") + wxString::Format(wxT("%d"), month) + wxT("'") ; + req += wxT("))"); + + EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, delete res, delete res); + + if (set.NextRow()) + (*res)[accountIt->id] = set.GetDouble(wxT("amount")); + } + + return res; +} + std::map Database::getSharedAccountOwners(const wxString& account) { std::map res; diff --git a/src/model/Database.h b/src/model/Database.h index 8ac25df..c10f4f7 100644 --- a/src/model/Database.h +++ b/src/model/Database.h @@ -107,9 +107,9 @@ public: User* LoadUser(const wxString& name); void LoadYear(User* user, int year); - void UpdateOperation(Operation& op); + void UpdateOperation(User* user, Operation& op); wxString AddOperation(User* user, Operation& op); - void DeleteOperation(Operation& op); + void DeleteOperation(User* user, Operation& op); void DeleteOperations(User* user, int month, int year); bool LoadOperation(User* user, const wxString& id); double MetaAmount(const wxString& id); @@ -158,6 +158,7 @@ public: wxString getSharedAccountOwner(const wxString& account); std::map* GetNotChecked(User* user, int month, int year); + std::map* GetVirtualAmount(User* user, int month, int year); /* Database Update */ @@ -169,7 +170,7 @@ private: void CreateDatabase(); wxString HashPassword(const wxString& password); - void LinkOrUnlinkOperation(Operation& op); + void LinkOrUnlinkOperation(User* user, Operation& op); }; #endif diff --git a/src/model/Database_Update.cpp b/src/model/Database_Update.cpp index b391901..65d861d 100644 --- a/src/model/Database_Update.cpp +++ b/src/model/Database_Update.cpp @@ -55,7 +55,15 @@ static void Version_1_to_2(wxSQLite3Database& _db) req = wxT("UPDATE account SET virtual='0'"); UPDATE_TABLE("1", "2", "5"); - + + /* Operation */ + req = wxT("ALTER TABLE operation ADD virtual CHAR(1)"); + + UPDATE_TABLE("1", "2", "6"); + + req = wxT("UPDATE operation SET virtual='0'"); + + UPDATE_TABLE("1", "2", "7"); } static update_func updates[] = { diff --git a/src/model/Operation.h b/src/model/Operation.h index 0328bb2..a0f22b5 100644 --- a/src/model/Operation.h +++ b/src/model/Operation.h @@ -36,6 +36,7 @@ public: wxString transfert; wxString formula; bool meta; + bool _virtual; std::vector childs; } ; diff --git a/src/model/User.cpp b/src/model/User.cpp index 6c16bca..e168932 100644 --- a/src/model/User.cpp +++ b/src/model/User.cpp @@ -168,6 +168,7 @@ wxLanguage User::GetLanguage() void User::LinkOrUnlinkOperation(Operation& op) { std::vector::iterator it; + Account account, account2; // Not Linked if (!op.transfert.Length()) @@ -177,6 +178,7 @@ void User::LinkOrUnlinkOperation(Operation& op) if (it->id != op.id && it->transfert == op.id) { it->transfert = wxT(""); + it->_virtual = false; return; } } @@ -188,11 +190,16 @@ void User::LinkOrUnlinkOperation(Operation& op) { if (it->id != op.id && it->id == op.transfert) { + account = GetAccount(it->account); + account2 = GetAccount(op.account); it->transfert = op.id; + it->_virtual = account._virtual || account2._virtual; + op._virtual = account._virtual || account2._virtual; return; } } op.transfert = wxT(""); + op._virtual = false; } } diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index f7bc5b4..4e8ebf0 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -434,6 +434,7 @@ void AccountPanel::UpdateStats() unsigned int day; bool checkMode = _checkCheckMode->IsChecked(); std::map* notChecked = NULL; + std::map* virtuals = NULL; Account account; Operation op; bool blocked_account ; @@ -443,6 +444,7 @@ void AccountPanel::UpdateStats() if (checkMode) { notChecked = _kiss->GetNotChecked(_curMonth, _curYear); + virtuals = _kiss->GetVirtualAmount(_curMonth, _curYear); } day = _calendar->GetDate().GetDay()-1; @@ -454,6 +456,12 @@ void AccountPanel::UpdateStats() { curAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first]; finalAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first]; + + if (virtuals) + { + curAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first]; + finalAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first]; + } } for (it=_curOperations->begin(); it!=_curOperations->end(); it++) @@ -547,7 +555,7 @@ void AccountPanel::UpdateStats() else { value = _accountsInitValues[accountIt->id]; - value2 = (*notChecked)[accountIt->id]; + value2 = (*notChecked)[accountIt->id] + (*virtuals)[accountIt->id]; _accountsGrid->SetCellValue(i, ACCOUNT_INIT, wxString::Format(wxT("%.2lf (%.2lf)"), value, value-value2)); value = curAccountAmount[accountIt->id]; @@ -563,6 +571,7 @@ void AccountPanel::UpdateStats() _accountsGrid->AutoSizeColumn(ACCOUNT_FINAL, true); if (notChecked) delete notChecked; + if (virtuals) delete virtuals; _statsGrid->AutoSizeColumn(1, true); diff --git a/src/view/PreferencesPanel.cpp b/src/view/PreferencesPanel.cpp index 3098b89..6013280 100644 --- a/src/view/PreferencesPanel.cpp +++ b/src/view/PreferencesPanel.cpp @@ -19,7 +19,7 @@ #include "PreferencesPanel.h" -enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_DEFAULT, ACCOUNT_BLOCKED, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT}; +enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_DEFAULT, ACCOUNT_VIRTUAL, 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, @@ -196,6 +196,7 @@ void PreferencesPanel::InitAccounts(User* user) _accountsGrid->SetColLabelValue(ACCOUNT_NAME, _("Name")); _accountsGrid->SetColLabelValue(ACCOUNT_NUMBER, _("Number")); _accountsGrid->SetColLabelValue(ACCOUNT_DEFAULT, _("Default")); + _accountsGrid->SetColLabelValue(ACCOUNT_VIRTUAL, _("Virtual")); _accountsGrid->SetColLabelValue(ACCOUNT_BLOCKED, _("Blocked")); _accountsGrid->SetColLabelValue(ACCOUNT_DELETE, _("Delete")); _accountsGrid->SetDefaultCellFont(font); @@ -224,6 +225,8 @@ void PreferencesPanel::AddAccount(int line, Account ac) _accountsGrid->SetCellEditor(line, ACCOUNT_NUMBER, new wxGridCellStarEditor ()); _accountsGrid->SetCellRenderer(line, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellEditor(line, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ()); + _accountsGrid->SetCellRenderer(line, ACCOUNT_VIRTUAL, new wxGridCellBoolRenderer ()); + _accountsGrid->SetCellEditor(line, ACCOUNT_VIRTUAL, new wxGridCellFastBoolEditor ()); _accountsGrid->SetCellRenderer(line, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellEditor(line, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ()); _accountsGrid->SetCellRenderer(line, ACCOUNT_DELETE, new wxGridCellBoolRenderer ()); @@ -232,6 +235,7 @@ void PreferencesPanel::AddAccount(int line, Account ac) _accountsGrid->SetCellValue(line, ACCOUNT_BLOCKED, (ac.blocked)?wxT("1"):wxT("0")); _accountsGrid->SetCellAlignment(line, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE); + _accountsGrid->SetCellAlignment(line, ACCOUNT_VIRTUAL, wxALIGN_CENTRE, wxALIGN_CENTRE); _accountsGrid->SetCellAlignment(line, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE); _accountsGrid->SetCellAlignment(line, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE); @@ -240,11 +244,13 @@ void PreferencesPanel::AddAccount(int line, Account ac) _accountsGrid->SetReadOnly(line, ACCOUNT_NAME, true); _accountsGrid->SetReadOnly(line, ACCOUNT_NUMBER, true); _accountsGrid->SetReadOnly(line, ACCOUNT_DEFAULT, true); + _accountsGrid->SetReadOnly(line, ACCOUNT_VIRTUAL, true); _accountsGrid->SetReadOnly(line, ACCOUNT_BLOCKED, true); } else { _accountsGrid->SetReadOnly(line, ACCOUNT_DEFAULT, false); + _accountsGrid->SetReadOnly(line, ACCOUNT_VIRTUAL, false); _accountsGrid->SetReadOnly(line, ACCOUNT_BLOCKED, false); _accountsGrid->SetReadOnly(line, ACCOUNT_DELETE, false); } @@ -252,6 +258,7 @@ void PreferencesPanel::AddAccount(int line, Account ac) else { _accountsGrid->SetReadOnly(line, ACCOUNT_DEFAULT, true); + _accountsGrid->SetReadOnly(line, ACCOUNT_VIRTUAL, true); _accountsGrid->SetReadOnly(line, ACCOUNT_BLOCKED, true); _accountsGrid->SetReadOnly(line, ACCOUNT_DELETE, true); @@ -402,6 +409,12 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event) else new_account._default = false; + value = _accountsGrid->GetCellValue(row, ACCOUNT_VIRTUAL); + if (value.Length() && value != wxT("0")) + new_account._virtual = true; + else + new_account._virtual = false; + value = _accountsGrid->GetCellValue(row, ACCOUNT_BLOCKED); if (value.Length() && value != wxT("0")) new_account.blocked = true; @@ -507,6 +520,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event) new_account.shared = false; new_account.blocked = false; new_account.is_owner = true; + new_account._virtual = false; AddAccount(row, new_account); _kiss->AddAccount(new_account); diff --git a/src/view/grid/GridAccount.cpp b/src/view/grid/GridAccount.cpp index b90885b..ca836f5 100644 --- a/src/view/grid/GridAccount.cpp +++ b/src/view/grid/GridAccount.cpp @@ -901,6 +901,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event) new_op.meta = cur_op.meta; new_op.parent = cur_op.parent; new_op.childs = cur_op.childs; + new_op._virtual = cur_op._virtual; if (cur_op.day != new_op.day) { @@ -929,6 +930,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event) fix_op = true; new_op.fix_cost = true; new_op.meta = false; + new_op._virtual = false; for(i=0; i\n"; echo "\n"; echo "

\n"; - echo "
KissCount © 2010 Grégory Soutadé
\n"; + echo "
KissCount © 2010-2011 Grégory Soutadé
\n"; die(); } else