Commit 2e2d569c authored by Stephane Mankowski's avatar Stephane Mankowski

Bad display in dashboard when all accounts of a type are closed

parent 1bc56d3f
......@@ -5,6 +5,7 @@ skrooge (2.22.0)
*Correction: Merge of number of operation
*Correction: Fix Get Hot New Stuff legacy Endpoints
*Correction: Files not able to be checked out on Windows
*Correction: Bad display in dashboard when all accounts of a type are closed
-- Stephane MANKOWSKI <stephane@mankowski.fr>
......
......@@ -331,6 +331,7 @@ void SKGAccountBoardWidget::dataModified(const QString& iTableName, int iIdTrans
html += QStringLiteral("<html><head><style>a {color: #") + color + ";}</style></head><body><table>";
double sumTypeV1 = 0;
double sumV1 = 0;
int nbAdded = 0;
QString currentType;
int nb = listTmp.count();
for (int i = 1; i < nb; ++i) { // Ignore header
......@@ -342,10 +343,11 @@ void SKGAccountBoardWidget::dataModified(const QString& iTableName, int iIdTrans
bool closed = (r.at(4) == QStringLiteral("Y"));
if (type != currentType) {
if (!currentType.isEmpty()) {
if (!currentType.isEmpty() && nbAdded>0) {
html += "<tr><td><b>" % SKGServices::stringToHtml(i18nc("the numerical total of a sum of values", "Total of %1", currentType)) % "</b></td>"
"<td align=\"right\"><b>" % doc->formatMoney(sumTypeV1, primary) % "</b></td></tr>";
sumTypeV1 = 0;
nbAdded = 0;
}
currentType = type;
}
......@@ -367,6 +369,7 @@ void SKGAccountBoardWidget::dataModified(const QString& iTableName, int iIdTrans
}
html += doc->formatMoney(v1, primary);
html += QStringLiteral("</td></tr>");
++nbAdded;
}
sumTypeV1 += v1;
sumV1 += v1;
......
......@@ -327,6 +327,7 @@ QVariantList SKGReportBank::getAccountTable()
double sumV1 = 0;
double sumV2 = 0;
double sumV3 = 0;
int nbAdded = 0;
QString currentType;
int nb = accounts.count();
for (int i = 0; !err && i < nb; ++i) {
......@@ -337,7 +338,7 @@ QVariantList SKGReportBank::getAccountTable()
QString type = account.getAttribute(QStringLiteral("t_TYPENLS"));
bool closed = account.isClosed();
if (type != currentType) {
if (!currentType.isEmpty()) {
if (!currentType.isEmpty() && nbAdded>0) {
table.push_back(QVariantList() << true << i18nc("Noun", "Total of %1", currentType) << sumTypeV1 << sumTypeV2 <<
(100.0 * (sumTypeV2 - sumTypeV1) / qAbs(sumTypeV1)) << sumTypeV3 << sumTypeV2
<< (100.0 * (sumTypeV2 - sumTypeV3) / qAbs(sumTypeV3))
......@@ -345,6 +346,7 @@ QVariantList SKGReportBank::getAccountTable()
sumTypeV1 = 0;
sumTypeV2 = 0;
sumTypeV3 = 0;
nbAdded = 0;
}
currentType = type;
}
......@@ -358,6 +360,7 @@ QVariantList SKGReportBank::getAccountTable()
}
table.push_back(QVariantList() << false << account.getName() << v1 << v2 << (100.0 * (v2 - v1) / qAbs(v1)) << v3 << v2
<< (100.0 * (v2 - v3) / qAbs(v3)) << account.getAttribute(QStringLiteral("t_BANK")) << icon);
nbAdded++;
}
sumTypeV1 += v1;
sumTypeV2 += v2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment