FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse MakeTotals() not adding negative numbers
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

xBrowse MakeTotals() not adding negative numbers

Posted: Thu Feb 26, 2015 03:44 PM
To All

I have an xBrowse that uses :MakeTotals() on the 'Balance' field and it was brought to my attention the total does not add up correctly when there is a negative number in the column ..

In the screenshot below there is one invoice ( on top ) with a positive value of $99.00 and one with a credit balance of -150.00 and the balance should be -51.00 not zero.

Thanks
Rick Lipkin

Code (fw): Select all Collapse
REDEFINE xBROWSE oLbxA        ;
         RECORDSET oRsInvoice        ;
         COLUMNS "REPAIR NUMBER",    ;
                 "TRANSACTION TYPE", ;
                 "INVOICED DATE",    ;
                 "TOTAL",            ;
                 "BALANCE"           ;
         COLSIZES 80,80,80,80,80     ;
         HEADERS "Invoice #",        ;
                 "Type",             ;
                 "Date",             ;
                 "Total",            ;
                 "Balance"           ;
         ID 132 of oFld:aDialogs[1]  ;
         AUTOCOLS FOOTERS LINES CELL

       oLbxA:nMarqueeStyle := MARQSTYLE_HIGHLROW
       oLbxA:lRecordSelector := .f.

       WITH OBJECT oLbxA
            :Balance:nFooterType  := AGGR_SUM
            :MakeTotals()
       END


Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse MakeTotals() not adding negative numbers

Posted: Fri Feb 27, 2015 01:42 AM
MakeTotals() does take into account both positive and negative values. Here is a small program to test.
Code (fw): Select all Collapse
function main()

   local oDlg, oFont, oBrw
   local aData := { { "One", 1000 }, { "Two", -500 }, { "Three", 200 } }

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 260,200 PIXEL FONT oFont
   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS ;
      LINES NOBORDER FOOTERS

   WITH OBJECT oBrw
      :aCols[ 2 ]:nFooterType := AGGR_SUM
      :MakeTotals()
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil




Please provide a small sample which we can compile and test at our end.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion