Now fixed operations is not necessary bound to fix category
This commit is contained in:
parent
1fbb920cb3
commit
ea6a320416
|
@ -1617,7 +1617,10 @@ void Database::GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||||
{
|
{
|
||||||
for (categoryIt = user->_categories.begin(); categoryIt != user->_categories.end(); categoryIt++)
|
for (categoryIt = user->_categories.begin(); categoryIt != user->_categories.end(); categoryIt++)
|
||||||
{
|
{
|
||||||
req = "SELECT SUM(amount) as amount FROM operation AS o1 WHERE category='" + QString::number(categoryIt->id) + "'";
|
if (categoryIt->id == 1)
|
||||||
|
req = "SELECT SUM(amount) as amount FROM operation AS o1 WHERE (category='" + QString::number(categoryIt->id) + "' OR fix_cost='1')";
|
||||||
|
else
|
||||||
|
req = "SELECT SUM(amount) as amount FROM operation AS o1 WHERE category='" + QString::number(categoryIt->id) + "'";
|
||||||
accountIt = user->_accounts.begin();
|
accountIt = user->_accounts.begin();
|
||||||
req += " AND (account IN('" + QString::number(accountIt->id);
|
req += " AND (account IN('" + QString::number(accountIt->id);
|
||||||
accountIt++;
|
accountIt++;
|
||||||
|
|
|
@ -632,7 +632,11 @@ void AccountPanel::UpdateStats()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((!op.transfert || force_debit) && user->GetCategoryName(op.category) != _("Unknown"))
|
if ((!op.transfert || force_debit) && user->GetCategoryName(op.category) != _("Unknown"))
|
||||||
|
{
|
||||||
|
if (op.fix_cost && op.category != 1)
|
||||||
|
_categoriesValues[0] += -op.amount ;
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||||
|
}
|
||||||
|
|
||||||
if (!op.transfert || force_debit)
|
if (!op.transfert || force_debit)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,8 @@ CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QS
|
||||||
|
|
||||||
_pie->setMargins(QMargins(5, 5, 5, 5));
|
_pie->setMargins(QMargins(5, 5, 5, 5));
|
||||||
|
|
||||||
for(i=0; i<nbCategories; i++)
|
/* Ignore fix category */
|
||||||
|
for(i=1; i<nbCategories; i++)
|
||||||
{
|
{
|
||||||
slice = series->append(_categories[i], 0);
|
slice = series->append(_categories[i], 0);
|
||||||
if (i < wxUI::MAX_CATEGORY)
|
if (i < wxUI::MAX_CATEGORY)
|
||||||
|
@ -149,11 +150,12 @@ void CostRepartitionBanner::UpdateCosts(int *categoriesValues, int totalDebit)
|
||||||
if (!i)
|
if (!i)
|
||||||
_statsGrid->item(i, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
_statsGrid->item(i, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_statsGrid->item(i+1, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
_statsGrid->item(i+1, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
||||||
|
|
||||||
slices[i]->setValue(categoriesValues[i] / 100);
|
slices[i-1]->setValue(categoriesValues[i] / 100);
|
||||||
|
slices[i-1]->setLabelVisible(categoriesValues[i] != 0.0);
|
||||||
slices[i]->setLabelVisible(categoriesValues[i] != 0.0);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value = totalDebit - categoriesValues[0];
|
value = totalDebit - categoriesValues[0];
|
||||||
|
|
|
@ -216,10 +216,8 @@ void SearchPanel::OnButtonChangeAccount()
|
||||||
static void ChangeCategory(Operation* op, void** params)
|
static void ChangeCategory(Operation* op, void** params)
|
||||||
{
|
{
|
||||||
int* category = (int*) params[0];
|
int* category = (int*) params[0];
|
||||||
bool* fix = (bool*) params[1];
|
|
||||||
|
|
||||||
op->category = *category;
|
op->category = *category;
|
||||||
op->fix_cost = * fix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchPanel::OnButtonChangeCategory()
|
void SearchPanel::OnButtonChangeCategory()
|
||||||
|
@ -231,8 +229,7 @@ void SearchPanel::OnButtonChangeCategory()
|
||||||
std::vector<Operation>::iterator it;
|
std::vector<Operation>::iterator it;
|
||||||
QString res;
|
QString res;
|
||||||
int category;
|
int category;
|
||||||
bool fix;
|
void * params[] = {&category};
|
||||||
void * params[] = {&category, &fix};
|
|
||||||
|
|
||||||
if (!_operations) return;
|
if (!_operations) return;
|
||||||
|
|
||||||
|
@ -248,12 +245,10 @@ void SearchPanel::OnButtonChangeCategory()
|
||||||
{
|
{
|
||||||
a = categories.indexOf(res);
|
a = categories.indexOf(res);
|
||||||
category = user->_categories[a-1].id ;
|
category = user->_categories[a-1].id ;
|
||||||
fix = user->_categories[a-1].fix_cost;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
category = 0;
|
category = 0;
|
||||||
fix = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_grid->MassUpdate(rows, true, ChangeCategory, params);
|
_grid->MassUpdate(rows, true, ChangeCategory, params);
|
||||||
|
|
|
@ -431,9 +431,6 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
|
|
||||||
if (fix)
|
if (fix)
|
||||||
{
|
{
|
||||||
item = new QTableWidgetItem(_("Fix"));
|
|
||||||
setItem(line, CATEGORY, item);
|
|
||||||
SET_READ_ONLY(item);
|
|
||||||
_fixCosts++;
|
_fixCosts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,8 +456,8 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
|
|
||||||
if (!op.meta)
|
if (!op.meta)
|
||||||
setItem(line, ACCOUNT, new QTableWidgetItem(user->GetAccountName(op.account)));
|
setItem(line, ACCOUNT, new QTableWidgetItem(user->GetAccountName(op.account)));
|
||||||
if (!fix && !op.meta)
|
if (!op.meta)
|
||||||
setItem(line, CATEGORY, new QTableWidgetItem(_(cat.name.toStdString().c_str())));
|
setItem(line, CATEGORY, new QTableWidgetItem(_(cat.name.toStdString().c_str())));
|
||||||
|
|
||||||
if (tag.id)
|
if (tag.id)
|
||||||
setItem(line, TAG, new QTableWidgetItem(_(tag.name.toStdString().c_str())));
|
setItem(line, TAG, new QTableWidgetItem(_(tag.name.toStdString().c_str())));
|
||||||
|
@ -481,10 +478,15 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
setItem(line, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)amount/100)));
|
setItem(line, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)amount/100)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line <= _fixCosts)
|
||||||
|
cat = user->GetCategory(1);
|
||||||
|
|
||||||
if (op.category)
|
if (op.category)
|
||||||
color = cat.backcolor;
|
color = cat.backcolor;
|
||||||
else
|
else
|
||||||
color = view::OWN_GREEN;
|
{
|
||||||
|
color = (op.fix_cost) ? view::OWN_YELLOW : view::OWN_GREEN;
|
||||||
|
}
|
||||||
|
|
||||||
if (op.checked)
|
if (op.checked)
|
||||||
{
|
{
|
||||||
|
@ -705,6 +707,7 @@ void GridAccount::CheckOperation(Operation& op, int line, bool check, bool force
|
||||||
QColor color;
|
QColor color;
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
|
Category cat;
|
||||||
|
|
||||||
if (!force)
|
if (!force)
|
||||||
{
|
{
|
||||||
|
@ -718,7 +721,12 @@ void GridAccount::CheckOperation(Operation& op, int line, bool check, bool force
|
||||||
checkBox->setCheckState(check ? Qt::Checked : Qt::Unchecked);
|
checkBox->setCheckState(check ? Qt::Checked : Qt::Unchecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
color = user->GetCategory(op.category).backcolor;
|
if (line <= _fixCosts)
|
||||||
|
cat = user->GetCategory(1);
|
||||||
|
else
|
||||||
|
cat = user->GetCategory(op.category);
|
||||||
|
|
||||||
|
color = cat.backcolor;
|
||||||
|
|
||||||
if (check)
|
if (check)
|
||||||
{
|
{
|
||||||
|
@ -1147,7 +1155,14 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
(_displayedOperations)[row] = new_op;
|
(_displayedOperations)[row] = new_op;
|
||||||
cat = user->GetCategory(new_op.category);
|
cat = user->GetCategory(new_op.category);
|
||||||
CheckOperation(new_op, row, new_op.checked, true);
|
CheckOperation(new_op, row, new_op.checked, true);
|
||||||
SET_ROW_FONT(row, user->GetCategoryFont(cat.id));
|
if (row <= _fixCosts)
|
||||||
|
{
|
||||||
|
SET_ROW_FONT(row, user->GetCategoryFont(0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SET_ROW_FONT(row, user->GetCategoryFont(cat.id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add an operation
|
// Add an operation
|
||||||
|
|
Loading…
Reference in New Issue
Block a user