Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Rounding error in Grid Summary

    Hello,
    I'm using SmartClient v9.0p_2014-01-03/LGPL Deployment.
    I have created a grid with total summaries, and configured my datasource to display only two decimals. But some calculated fields are showing extra decimals.
    The problem can be reproduced with this code:
    Code:
    <!DOCTYPE html>
    <html>
    <head>
        <title>Rounding error</title>
        <script type="text/javascript">//<![CDATA[
        var isomorphicDir = "js/isomorphic/";
        //]]></script>
        <meta charset="UTF-8">
        <script src="js/isomorphic/system/modules/ISC_Core.js" type="text/javascript">//<![CDATA[//]]></script>
        <script src="js/isomorphic/system/modules/ISC_Foundation.js" type="text/javascript">//<![CDATA[//]]></script>
        <script src="js/isomorphic/system/modules/ISC_Containers.js" type="text/javascript">//<![CDATA[//]]></script>
        <script src="js/isomorphic/system/modules/ISC_Grids.js" type="text/javascript">//<![CDATA[//]]></script>
        <script src="js/isomorphic/system/modules/ISC_Forms.js" type="text/javascript">//<![CDATA[//]]></script>
        <script src="js/isomorphic/system/modules/ISC_DataBinding.js" type="text/javascript">//<![CDATA[//]]></script>
        <script src="js/isomorphic/skins/Simplicity/load_skin.js" type="text/javascript">//<![CDATA[//]]></script>
        <link href="js/isomorphic/skins/Simplicity/skin_styles.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
    <script type="text/javascript">
        //<![CDATA[
        var data = [{
            "AA_EXERCICIO": "2011",
            "PROGRAMATRABALHO": "GROUP ONE",
            "NO_ESFERA": "SPHERE ONE",
            "NO_NATUREZA": "DIARIES",
            "NO_FONTE": "SOURCE ONE",
            "CO_UG": "190103",
            "NO_UG": "REGION ONE",
            "CO_GESTAO": "00001",
            "NO_GESTAO": "TREASURE",
            "VR_LEI": 1000,
            "VR_ALTERACAO": 1637.06,
            "VR_MOVIMENTACAO": 0,
            "VR_BLOQUEADO": 0,
            "VR_DESPESA_AUTORIZADA": 2637.06,
            "VR_EMPENHADO": 2637.06,
            "VR_LIQUIDADO": 2637.06,
            "R___": 1
        },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "OTHER SERVICES",
                "NO_FONTE": "DIRECT PAYMENT",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 100000,
                "VR_ALTERACAO": -100000,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 0,
                "VR_EMPENHADO": 0,
                "VR_LIQUIDADO": 0,
                "R___": 2
            },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "FLIGHT TICKETS",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 1000,
                "VR_ALTERACAO": -1000,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 0,
                "VR_EMPENHADO": 0,
                "VR_LIQUIDADO": 0,
                "R___": 3
            },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "GROCERY",
                "NO_FONTE": "DIRECT PAYMENT",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 100000,
                "VR_ALTERACAO": 100000,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 178236,
                "VR_DESPESA_AUTORIZADA": 200000,
                "VR_EMPENHADO": 20552.10,
                "VR_LIQUIDADO": 20552.10,
                "R___": 4
            },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "OTHER SERVICES",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 2972000,
                "VR_ALTERACAO": 659805.28,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 247105,
                "VR_DESPESA_AUTORIZADA": 3631805.28,
                "VR_EMPENHADO": 3384699.03,
                "VR_LIQUIDADO": 2955925.74,
                "R___": 5
            },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "GROCERY",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 100000,
                "VR_ALTERACAO": -2131.06,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 62126,
                "VR_DESPESA_AUTORIZADA": 97868.94,
                "VR_EMPENHADO": 35742.18,
                "VR_LIQUIDADO": 25420.58,
                "R___": 6
            },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "OTHER PERSONAL SERVICES",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 1000,
                "VR_ALTERACAO": -1000,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 0,
                "VR_EMPENHADO": 0,
                "VR_LIQUIDADO": 0,
                "R___": 7
            },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "REFUNDS",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 0,
                "VR_ALTERACAO": 77127.72,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 77127.72,
                "VR_EMPENHADO": 77124.54,
                "VR_LIQUIDADO": 77124.54,
                "R___": 8
            },
            {
                "AA_EXERCICIO": "2011",
                "PROGRAMATRABALHO": "GROUP ONE",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "EQUIPMENT",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 100000,
                "VR_ALTERACAO": -93461,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 6539,
                "VR_EMPENHADO": 6539,
                "VR_LIQUIDADO": 6539,
                "R___": 9
            },
            {
                "AA_EXERCICIO": "2012",
                "PROGRAMATRABALHO": "GROUP TWO",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "OBRIGATIONS",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 1277108,
                "VR_ALTERACAO": -329241.50,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 947866.50,
                "VR_EMPENHADO": 943965.76,
                "VR_LIQUIDADO": 943811.15,
                "R___": 10
            },
            {
                "AA_EXERCICIO": "2012",
                "PROGRAMATRABALHO": "GROUP TWO",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "MILITARY STUFF",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 0,
                "VR_ALTERACAO": 9993.94,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 9993.94,
                "VR_EMPENHADO": 9993.94,
                "VR_LIQUIDADO": 9993.94,
                "R___": 11
            },
            {
                "AA_EXERCICIO": "2012",
                "PROGRAMATRABALHO": "GROUP TWO",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "OTHER ASSISTANCE",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 0,
                "VR_ALTERACAO": 0,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 0,
                "VR_EMPENHADO": 0,
                "VR_LIQUIDADO": 0,
                "R___": 12
            },
            {
                "AA_EXERCICIO": "2012",
                "PROGRAMATRABALHO": "GROUP TWO",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "CIVILIANS COST",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 4600000,
                "VR_ALTERACAO": 287467.35,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 4887467.35,
                "VR_EMPENHADO": 4887371.10,
                "VR_LIQUIDADO": 4886371.10,
                "R___": 13
            },
            {
                "AA_EXERCICIO": "2012",
                "PROGRAMATRABALHO": "GROUP TWO",
                "NO_ESFERA": "SPHERE ONE",
                "NO_NATUREZA": "OTHER CIVILIANS COST",
                "NO_FONTE": "SOURCE ONE",
                "CO_UG": "190103",
                "NO_UG": "REGION ONE",
                "CO_GESTAO": "00001",
                "NO_GESTAO": "TREASURE",
                "VR_LEI": 0,
                "VR_ALTERACAO": 21310.21,
                "VR_MOVIMENTACAO": 0,
                "VR_BLOQUEADO": 0,
                "VR_DESPESA_AUTORIZADA": 21310.21,
                "VR_EMPENHADO": 21309.65,
                "VR_LIQUIDADO": 21309.65,
                "R___": 14
            }];
        isc.RestDataSource.create({
            ID: "DetalhamentoDeDespesasDetalhe",
            fields: [
                { name: "AA_EXERCICIO", type: "text", title: "Year", hidden: true},
                { name: "CO_UG", type: "text", title: "Code", hidden: true },
                { name: "NO_UG", type: "text", title: "Unit", hidden: true },
                { name: "CO_GESTAO", type: "text", title: "Management", hidden:true },
                { name: "NO_GESTAO", type: "text", title: "Management", hidden:true},
                { name: "PROGRAMATRABALHO", type: "text", title: "Program", hidden: true},
    
                { name: "NO_ESFERA", type: "text", title: "Sphere" },
                { name: "NO_NATUREZA", type: "text", title: "Nature" },
                { name: "NO_FONTE", type: "text", title: "Source" },
                { name: "VR_LEI", type: "localeFloat", title: "Law", decimalPad: 2 },
                { name: "VR_ALTERACAO", type: "localeFloat", title: "Alteration", decimalPad: 2 },
                { name: "VR_MOVIMENTACAO", type: "localeFloat", title: "Movement", decimalPad: 2 },
                { name: "VR_BLOQUEADO", type: "localeFloat", title: "Blocked", decimalPad: 2 },
                { name: "VR_DESPESA_AUTORIZADA", type: "localeFloat", title: "Authorized", decimalPad: 2 },
                { name: "VR_EMPENHADO", type: "localeFloat", title: "Endeavour", decimalPad: 2 },
                { name: "VR_LIQUIDADO", type: "localeFloat", title: "Liquid", decimalPad: 2 }
    
            ],
            dataFormat: "json"
        });
        isc.ListGrid.create({
            dataSource: "DetalhamentoDeDespesasDetalhe",
            height: 300,
            width: 1200,
            groupStartOpen: "all",
            showFilterEditor: true,
            showGridSummary: true,
            showGroupSummary: true,
            autoFetchData: false,
            groupByField: "PROGRAMATRABALHO",
            fields: [
                { name: "NO_ESFERA" },
                { name: "NO_NATUREZA" },
                { name: "NO_FONTE", getGroupSummary: function() {return "Subtotal";}, showGroupSummary:true,
                    getGridSummary: function () { return "Total"; }, showGridSummary: true,canSort: false },
                { name: "VR_LEI", showGridSummary: true, showGroupSummary:true},
                { name: "VR_ALTERACAO", showGridSummary: true, showGroupSummary:true },
                { name: "VR_MOVIMENTACAO", showGridSummary: true, showGroupSummary:true },
                { name: "VR_BLOQUEADO", showGridSummary: true, showGroupSummary:true },
                { name: "VR_DESPESA_AUTORIZADA", showGridSummary: true, showGroupSummary:true },
                { name: "VR_EMPENHADO", showGridSummary: true, showGroupSummary:true },
                { name: "VR_LIQUIDADO", showGridSummary: true, showGroupSummary:true }
            ],
            data: data
        });
        //]]>
    </script>
    </body>
    </html>

    #2
    You are setting decimalPad, but the behavior you seem to be looking for comes from setting decimalPrecision.

    Comment


      #3
      You're totally right. With decimalPrecision, this works great!
      Thanks.

      Comment

      Working...
      X