Fix a bug with blocked account computation

This commit is contained in:
Grégory Soutadé 2010-11-05 19:25:11 +01:00
parent 27b5740b5c
commit 115bf8f305
3 changed files with 29 additions and 17 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-11-01 11:34+0100\n"
"POT-Creation-Date: 2010-11-03 20:33+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -35,7 +35,7 @@ msgstr ""
msgid " not found, aborting"
msgstr ""
#: src/view/AccountPanel.cpp:727
#: src/view/AccountPanel.cpp:724
msgid " operations ?"
msgstr ""
@ -84,11 +84,11 @@ msgid "Amount to"
msgstr ""
#: src/view/PreferencesPanel.cpp:401 src/view/PreferencesPanel.cpp:774
#: src/view/AccountPanel.cpp:722
#: src/view/AccountPanel.cpp:719
msgid "Are you sure want to delete "
msgstr ""
#: src/view/PreferencesPanel.cpp:641 src/view/grid/GridAccount.cpp:760
#: src/view/PreferencesPanel.cpp:641 src/view/grid/GridAccount.cpp:761
msgid "Are you sure want to delete : \n"
msgstr ""
@ -113,11 +113,11 @@ msgstr ""
msgid "Cancel"
msgstr ""
#: src/view/grid/GridAccount.cpp:1144 src/view/grid/GridAccount.cpp:1151
#: src/view/grid/GridAccount.cpp:1145 src/view/grid/GridAccount.cpp:1152
msgid "Cannot group these operations"
msgstr ""
#: src/view/grid/GridAccount.cpp:1280 src/view/grid/GridAccount.cpp:1286
#: src/view/grid/GridAccount.cpp:1271 src/view/grid/GridAccount.cpp:1277
msgid "Cannot ungroup these operations"
msgstr ""
@ -217,9 +217,9 @@ msgstr ""
#: src/view/PreferencesPanel.cpp:439 src/view/PreferencesPanel.cpp:660
#: src/view/PreferencesPanel.cpp:679 src/view/PreferencesPanel.cpp:719
#: src/view/PreferencesPanel.cpp:725 src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:718
#: src/view/grid/GridAccount.cpp:1144 src/view/grid/GridAccount.cpp:1151
#: src/view/grid/GridAccount.cpp:1280 src/view/grid/GridAccount.cpp:1286
#: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:715
#: src/view/grid/GridAccount.cpp:1145 src/view/grid/GridAccount.cpp:1152
#: src/view/grid/GridAccount.cpp:1271 src/view/grid/GridAccount.cpp:1277
#: 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:102 src/model/Database.cpp:120
@ -236,7 +236,7 @@ msgstr ""
msgid "Final value"
msgstr ""
#: src/view/SearchPanel.cpp:76 src/view/grid/GridAccount.cpp:300
#: src/view/SearchPanel.cpp:76 src/view/grid/GridAccount.cpp:301
#: src/model/Database.cpp:331 src/controller/KissCount.cpp:335
msgid "Fix"
msgstr ""
@ -317,7 +317,7 @@ msgstr ""
msgid "It must be at least one account !"
msgstr ""
#: src/view/AccountPanel.cpp:718
#: src/view/AccountPanel.cpp:715
msgid "It must be at least one month !"
msgstr ""

View File

@ -462,7 +462,7 @@ void Database::LinkOrUnlinkOperation(Operation& op)
if (op.transfert.Length())
{
// No one or not linked
if (!GetOperation(op.transfert, &linked) || op.description != linked.description || op.amount != -linked.amount)
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("'") ;
EXECUTE_SQL_UPDATE(req, );
@ -486,6 +486,9 @@ void Database::LinkOrUnlinkOperation(Operation& op)
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("'");
req += wxT(" AND meta='0'");
req += wxT(" AND account !='") + op.account + wxT("'");
req += wxT(" AND id !='") + op.id + wxT("'");
req += wxT(" AND (transfert='' OR transfert IS NULL)");
EXECUTE_SQL_QUERY(req, set, );

View File

@ -414,6 +414,7 @@ void AccountPanel::UpdateStats()
std::map<wxString, double>* notChecked = NULL;
Account account;
Operation op;
bool blocked_account ;
curCredit = curDebit = totalCredit = totalDebit = percents = 0.0;
@ -438,6 +439,7 @@ void AccountPanel::UpdateStats()
if (it->meta) continue;
op = *it;
blocked_account = false;
// A credit on a blocked account must be considered as a debit
if (op.transfert.Length() && op.amount > 0)
@ -448,11 +450,15 @@ void AccountPanel::UpdateStats()
{
op.amount = -op.amount;
op.transfert = wxT("");
blocked_account = true;
}
}
if (op.amount >= 0)
{
if (!op.transfert.Length())
totalCredit += op.amount;
if (day >= op.day)
{
if (!op.transfert.Length())
@ -460,8 +466,6 @@ void AccountPanel::UpdateStats()
if (!checkMode || (checkMode && op.checked))
curAccountAmount[op.account] += op.amount;
}
if (!op.transfert.Length())
totalCredit += op.amount;
if (!checkMode || (checkMode && op.checked))
finalAccountAmount[op.account] += op.amount;
}
@ -469,6 +473,13 @@ void AccountPanel::UpdateStats()
{
if (!op.transfert.Length())
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
if (!op.transfert.Length())
totalDebit += -op.amount;
if (blocked_account)
op.amount = -op.amount;
if (day >= op.day)
{
if (!op.transfert.Length())
@ -476,8 +487,6 @@ void AccountPanel::UpdateStats()
if (!checkMode || (checkMode && op.checked))
curAccountAmount[op.account] += op.amount;
}
if (!op.transfert.Length())
totalDebit += -op.amount;
if (!checkMode || (checkMode && op.checked))
finalAccountAmount[op.account] += op.amount;
}