Source language: Translate to:

Math error involving .00 and .02

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Re: Math error involving .00 and .02

Postby stu » Thu Jan 07, 2016 2:05 pm

What about doing the math server side?

eg: SELECT 1 + 1 AS SumTotal
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Math error involving .00 and .02

Postby BRobinsonS » Sat Jan 09, 2016 8:43 am

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.
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Previous

Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 2 guests