Print Page | Close Window

[SOLVED]Thousand character in the Subtotal of Gro

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=23851
Printed Date: 04 April 2020 at 11:55pm


Topic: [SOLVED]Thousand character in the Subtotal of Gro
Posted By: ylaroye
Subject: [SOLVED]Thousand character in the Subtotal of Gro
Date Posted: 11 May 2019 at 4:41pm
I am disappointed to see that my following proposal for evolution was not retained in version 19.0.0 Beta 1 while it is legitimate and that I proposed the code to implement it. Why?

------------------------------------
In a financial application, there is need to present the amounts with the thousand separator. This can be done for the elements in the ReportControl lines but not for the GroupRow.
I propose an evolution on the SetFormatString method allowing to manage:
- the thousand separator => keyword 'T'
- the decimal separator => keyword 'D'
- the sign '-' (sometimes represented with parentheses: -1234 => (1234)) => keyword 'N'

These 3 elements must be put between '[]' after the '%' and the value of each element is the character just behind the keyword.
Example: 'Subtotal =% [T D, N (]. 02f $'
    T = Blank
    D = Comma
    N = Parenthesis

http://forum.codejock.com/uploads/9311/XTPReportGroupRow.zip" rel="nofollow - uploads/9311/XTPReportGroupRow.zip



Product: XTP 18.6.0 and XTP 19.0.0 Beta 1 on VC++ 6.0
Platform: Windows 10 (64bit)




Replies:
Posted By: agontarenko
Date Posted: 03 June 2019 at 6:11am
Hello,

We added same functionality but by using CURRENCYFMT structure and GetCurrencyFormat function. This allows to get currency string  more flexible.

See BOOL CFormulaDlg::OnInitDialog() function in ReportSample.



Regards,
Artem Gontarenko


Posted By: ylaroye
Date Posted: 03 June 2019 at 7:56am
Hello Artem,

CURRENCYFMT structure and GetCurrencyFormat function are only used in Source\Chart\Utils\XTPChartNumberFormat.cpp and XTPChartNumberFormat.h files.

I haven't seen in Xtreme ToolkitPro v19.0.0.050119 where CURRENCYFMT structure and GetCurrencyFormat function are used for the ReportControl (in "Source" and "Samples" sub-folders).

Can you send me your modified FormulaDlg.cpp/FormulaDlg.h files to understand how you have implemented it?

Regards,

Yves Laroye





Posted By: agontarenko
Date Posted: 03 June 2019 at 9:18am
This changes from FormulaDlg

// FormulaDlg.h

    ~CFormulaDlg();
    CURRENCYFMT m_fmtCurrency;
    int GetLocaleLong(LCTYPE LCType);
   
   
// FormulaDlg.cpp
   
CFormulaDlg::CFormulaDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CFormulaDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CFormulaDlg)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
   
    ZeroMemory(&m_fmtCurrency, sizeof(m_fmtCurrency));
    m_fmtCurrency.lpDecimalSep     = new TCHAR[10];
    m_fmtCurrency.lpThousandSep    = new TCHAR[10];
    m_fmtCurrency.lpCurrencySymbol = new TCHAR[10];
    m_fmtCurrency.Grouping        = 3;
    m_fmtCurrency.NumDigits        = GetLocaleLong(LOCALE_IDIGITS);
    m_fmtCurrency.LeadingZero   = GetLocaleLong(LOCALE_ILZERO);
    m_fmtCurrency.NegativeOrder = GetLocaleLong(LOCALE_INEGCURR);
    m_fmtCurrency.PositiveOrder = GetLocaleLong(LOCALE_ICURRENCY);
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, m_fmtCurrency.lpDecimalSep, 10);
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, m_fmtCurrency.lpCurrencySymbol, 10);
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, m_fmtCurrency.lpThousandSep, 10);
}

CFormulaDlg::~CFormulaDlg()
{
    SAFE_DELETE_AR(m_fmtCurrency.lpDecimalSep);
    SAFE_DELETE_AR(m_fmtCurrency.lpThousandSep);
    SAFE_DELETE_AR(m_fmtCurrency.lpCurrencySymbol);
}

int CFormulaDlg::GetLocaleLong(LCTYPE LCType)
{
    TCHAR szResult[5];

    int nResult = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LCType, szResult, 4);
    ASSERT(nResult == 2);
    UNUSED(nResult);
    return _ttoi(szResult);
}

BOOL CFormulaDlg::OnInitDialog()
{
    ...

        { _T("Pen"), _T("WA"), -200000 },    { _T("Paper"), _T("WA"), 100000 },
        { _T("Books"), _T("WA"), 100000 },
    };

    ...

    BOOL bUseCurrencyFormat = TRUE;
    for (i = 0; i < m_wndReport.GetRows()->GetCount(); i++)
    {
        CXTPReportRow* pRow = m_wndReport.GetRows()->GetAt(i);

        if (pRow->IsGroupRow())
        {
            CXTPReportGroupRow* pGroupRow = reinterpret_cast<CXTPReportGroupRow*>(pRow);
           
            if(bUseCurrencyFormat)
            {
                pGroupRow->SetFormatString(_T(" Subtotal "));
                pGroupRow->SetCurrencyFormat(&m_fmtCurrency);

            }
            else
            {
                pGroupRow->SetFormatString(_T(" Subtotal $=%.02f"));
            }
           
            pGroupRow->SetFormula(_T("SUMSUB(R*C1:R*C8)"));
            pGroupRow->SetCaption(_T("x"));

            bUseCurrencyFormat = !bUseCurrencyFormat;
        }
    }

    return FALSE;
}



You can initiate the m_fmtCurrency structure with different values to get the desired result.

Regards,
Artem Gontarenko


Posted By: agontarenko
Date Posted: 03 June 2019 at 9:23am
FYI. This changes will be available in next beta or final release.
ToolkitPro v19.0.0.050119 not contain this changes

Regards,
Artem Gontarenko


Posted By: ylaroye
Date Posted: 03 June 2019 at 9:26am
Artem,

Thank you for your answer which corresponds to my waiting.
I am looking forward to the new version!

Yves Laroye



Print Page | Close Window