Skip to content

Commit

Permalink
fix(moneymanagerex#4987): trans report bool presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Whalley committed Aug 29, 2022
1 parent 208c574 commit a19203c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/reports/transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ void mmReportTransactions::displayTotals(std::map<int, double> total, std::map<i
hb.addTotalRow(_("Grand Total:"), noOfCols, v);
}

void mmReportTransactions::UDFCFormatHelper(Model_CustomField::FIELDTYPE type, int ref, wxString data, double val, int scale)
{
if (type == Model_CustomField::FIELDTYPE::DECIMAL || type == Model_CustomField::FIELDTYPE::INTEGER)
hb.addMoneyCell(val, scale);
else if (ref != -1)
{
if (type == Model_CustomField::FIELDTYPE::BOOLEAN)
{
bool v = wxString("TRUE|true|1").Contains(data);
hb.addTableCell(v ? "&check;" : "&cross;", false, true);
} else
hb.addTableCell(type == Model_CustomField::FIELDTYPE::DATE && !data.empty() ? mmGetDateForDisplay(data) : data);
}
}

wxString mmReportTransactions::getHTMLText()
{
Run(m_transDialog);
Expand Down Expand Up @@ -190,6 +205,10 @@ table {
case Model_CustomField::FIELDTYPE::DECIMAL:
case Model_CustomField::FIELDTYPE::INTEGER:
nameCSS.Append(" text-right");
break;
case Model_CustomField::FIELDTYPE::BOOLEAN:
nameCSS.Append(" center");
break;
}
hb.addTableHeaderCell(name, nameCSS);
}
Expand Down Expand Up @@ -324,30 +343,15 @@ table {
}

if (showColumnById(11))
if (UDFC01_Type == Model_CustomField::FIELDTYPE::DECIMAL || UDFC01_Type == Model_CustomField::FIELDTYPE::INTEGER)
hb.addMoneyCell(transaction.UDFC01_val, UDFC01_Scale);
else if (udfc01_ref_id != -1)
hb.addTableCell(UDFC01_Type == Model_CustomField::FIELDTYPE::DATE && !transaction.UDFC01.empty() ? mmGetDateForDisplay(transaction.UDFC01) : transaction.UDFC01);
UDFCFormatHelper(UDFC01_Type, udfc01_ref_id, transaction.UDFC01, transaction.UDFC01_val, UDFC01_Scale);
if (showColumnById(12))
if (UDFC02_Type == Model_CustomField::FIELDTYPE::DECIMAL || UDFC02_Type == Model_CustomField::FIELDTYPE::INTEGER)
hb.addMoneyCell(transaction.UDFC02_val, UDFC02_Scale);
else if (udfc02_ref_id != -1)
hb.addTableCell(UDFC02_Type == Model_CustomField::FIELDTYPE::DATE && !transaction.UDFC02.empty() ? mmGetDateForDisplay(transaction.UDFC02) : transaction.UDFC02);
UDFCFormatHelper(UDFC02_Type, udfc02_ref_id, transaction.UDFC02, transaction.UDFC02_val, UDFC02_Scale);
if (showColumnById(13))
if (UDFC03_Type == Model_CustomField::FIELDTYPE::DECIMAL || UDFC03_Type == Model_CustomField::FIELDTYPE::INTEGER)
hb.addMoneyCell(transaction.UDFC03_val, UDFC03_Scale);
else if (udfc03_ref_id != -1)
hb.addTableCell(UDFC03_Type == Model_CustomField::FIELDTYPE::DATE && !transaction.UDFC03.empty() ? mmGetDateForDisplay(transaction.UDFC03) : transaction.UDFC03);
UDFCFormatHelper(UDFC03_Type, udfc03_ref_id, transaction.UDFC03, transaction.UDFC03_val, UDFC03_Scale);
if (showColumnById(14))
if (UDFC04_Type == Model_CustomField::FIELDTYPE::DECIMAL || UDFC04_Type == Model_CustomField::FIELDTYPE::INTEGER)
hb.addMoneyCell(transaction.UDFC04_val, UDFC04_Scale);
else if (udfc04_ref_id != -1)
hb.addTableCell(UDFC04_Type == Model_CustomField::FIELDTYPE::DATE && !transaction.UDFC04.empty() ? mmGetDateForDisplay(transaction.UDFC04) : transaction.UDFC04);
UDFCFormatHelper(UDFC04_Type, udfc04_ref_id, transaction.UDFC04, transaction.UDFC04_val, UDFC04_Scale);
if (showColumnById(15))
if (UDFC05_Type == Model_CustomField::FIELDTYPE::DECIMAL || UDFC05_Type == Model_CustomField::FIELDTYPE::INTEGER)
hb.addMoneyCell(transaction.UDFC05_val, UDFC05_Scale);
else if (udfc05_ref_id != -1)
hb.addTableCell(UDFC05_Type == Model_CustomField::FIELDTYPE::DATE && !transaction.UDFC05.empty() ? mmGetDateForDisplay(transaction.UDFC05) : transaction.UDFC05);
UDFCFormatHelper(UDFC05_Type, udfc05_ref_id, transaction.UDFC05, transaction.UDFC05_val, UDFC05_Scale);
}
hb.endTableRow();
}
Expand Down
1 change: 1 addition & 0 deletions src/reports/transactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class mmReportTransactions : public mmPrintableBase
wxSharedPtr<mmFilterTransactionsDialog> m_transDialog;
bool showColumnById(int num);
void displayTotals(std::map<int, double> total, std::map<int, double> total_in_base_curr, int noOfCols);
void UDFCFormatHelper(Model_CustomField::FIELDTYPE type, int ref, wxString data, double val, int scale);

mmHTMLBuilder hb;
int m_noOfCols;
Expand Down

0 comments on commit a19203c

Please sign in to comment.