Page 2 of 2

Re: Math error involving .00 and .02

PostPosted: Thu Jan 07, 2016 2:05 pm
by stu
What about doing the math server side?

eg: SELECT 1 + 1 AS SumTotal

Re: Math error involving .00 and .02

PostPosted: Sat Jan 09, 2016 8:43 am
by BRobinsonS
First of All, thank you for all the suggestions for work around regarding the Math function and getting 'pennies' to calculate right.
It was very frustrating and I thought I would have to live with the flaw.

I used variables not Database fields to do the calculations.
So far testing indicates the calculations are performed as expected.

The Subroutine which now seems to work is:

Code: Select all
:UpdateAccountBalance
. update account balance when adding Journal Entry record
dbpFind "NBAccounting" "Gl" "AccountNo" "[NBAccounting.JrDetails.AccountNo]" "ExactMatch=Yes;CaseSensitive=No"

. ONE
IfEx "[NBAccounting.Gl.NormalBalance]= DB AND [NBAccounting.JrDetails.InAmt] > 0"
   SetVar "[vDebitAmt]" "[NBAccounting.JrDetails.InAmt]"
   SetVar "[vDBBalance]" "[NBAccounting.Gl.DBBalance]"
   Math "[vDBBalance]+[vDebitAmt]" "2" "[NBAccounting.Gl.DBBalance]"
EndIf

.TWO
IfEx "[NBAccounting.Gl.NormalBalance]= DB AND [NBAccounting.JrDetails.OutAmt] > 0"
  SetVar "[vCrAmt]" "[NBAccounting.JrDetails.OutAmt]"
  SetVar "[vDBBalance]" "[NBAccounting.Gl.DBBalance]"
  Math "[vDBBalance]-[vCrAmt]" "2" "[NBAccounting.Gl.DBBalance]"
EndIf

.THREE
IfEx "[NBAccounting.Gl.NormalBalance]= CR AND [NBAccounting.JrDetails.InAmt] > 0"
   SetVar "[vDebitAmt]" "[NBAccounting.JrDetails.InAmt]"
   SetVar "[vCRBalance]" "[NBAccounting.Gl.CRBalance]"
   Math "[vCRBalance]-[vDebitAmt]" "2" "[NBAccounting.Gl.CRBalance]"
EndIf

.FOUR
IfEx "[NBAccounting.Gl.NormalBalance]= CR AND [NBAccounting.JrDetails.OutAmt] > 0"
    SetVar "[vCrAmt]" "[NBAccounting.JrDetails.OutAmt]"
    SetVar "[vCRBalance]" "[NBAccounting.Gl.CRBalance]"
    Math "[vCRBalance]+[CrAmt]" "2" "[NBAccounting.Gl.CRBalance]"
EndIf

dbpSaveEdits "NBAccounting" "gl"

Return


Thank you for taking the time to help.