Rounding issue
Posted: Sun Jan 19, 2020 4:47 am
This code just will not round properly.
method EditFocusChange(oEditFocusChangeEvent) class InvoicingScr
local oControl as Control
local lGotFocus as logic
Local nGSTInc, nGSTPaid
oControl := IIf(oEditFocusChangeEvent == NULL_OBJECT, NULL_OBJECT, oEditFocusChangeEvent:Control)
lGotFocus := IIf(oEditFocusChangeEvent == NULL_OBJECT, FALSE, oEditFocusChangeEvent:GotFocus)
super:EditFocusChange(oEditFocusChangeEvent)
//Put your changes here
nGSTPaid := gGSTRate/100
nGSTInc := 1 + nGSTPaid
SetDecimal(2)
SetFixed(true)
IF AllTrim(self:oDCComboBoxEx11:CurrentItem) == "No GST"
self:oDCTOTPR1:CurrentText := Str(Round((((self:oDCQTY1:VALUE) * (self:oDCUNITPR1:VALUE)) *1),2))
self:oDCGST1:CurrentText := "0.00"
else
self:oDCTOTPR1:CurrentText := Str(Round(( ((self:oDCQTY1:VALUE) * (self:oDCUNITPR1:VALUE)) * nGSTInc),2),,2)
self:oDCGST1:CurrentText := Str(Round((((self:oDCQTY1:VALUE) * (self:oDCUNITPR1:VALUE))* nGSTPaid), 2),,2)
endif
? Round(((self:oDCQTY1:VALUE * self:oDCUNITPR1:VALUE) * nGSTInc),2)
? Str(Round(((self:oDCQTY1:VALUE * self:oDCUNITPR1:VALUE) * nGSTInc),2),,2)
SetFixed(.f.)
Return nil
Using the following variables for example:
GSTRate = 10
self:oDCQTY1:VALUE = 1
self:oDCUNITPR1:VALUE = 804.55
I keep getting 885.01 I need this to be 885.00 what am I missing please. The screenshot shows the Terminal Output for the code above:
Thanks again.
.
method EditFocusChange(oEditFocusChangeEvent) class InvoicingScr
local oControl as Control
local lGotFocus as logic
Local nGSTInc, nGSTPaid
oControl := IIf(oEditFocusChangeEvent == NULL_OBJECT, NULL_OBJECT, oEditFocusChangeEvent:Control)
lGotFocus := IIf(oEditFocusChangeEvent == NULL_OBJECT, FALSE, oEditFocusChangeEvent:GotFocus)
super:EditFocusChange(oEditFocusChangeEvent)
//Put your changes here
nGSTPaid := gGSTRate/100
nGSTInc := 1 + nGSTPaid
SetDecimal(2)
SetFixed(true)
IF AllTrim(self:oDCComboBoxEx11:CurrentItem) == "No GST"
self:oDCTOTPR1:CurrentText := Str(Round((((self:oDCQTY1:VALUE) * (self:oDCUNITPR1:VALUE)) *1),2))
self:oDCGST1:CurrentText := "0.00"
else
self:oDCTOTPR1:CurrentText := Str(Round(( ((self:oDCQTY1:VALUE) * (self:oDCUNITPR1:VALUE)) * nGSTInc),2),,2)
self:oDCGST1:CurrentText := Str(Round((((self:oDCQTY1:VALUE) * (self:oDCUNITPR1:VALUE))* nGSTPaid), 2),,2)
endif
? Round(((self:oDCQTY1:VALUE * self:oDCUNITPR1:VALUE) * nGSTInc),2)
? Str(Round(((self:oDCQTY1:VALUE * self:oDCUNITPR1:VALUE) * nGSTInc),2),,2)
SetFixed(.f.)
Return nil
Using the following variables for example:
GSTRate = 10
self:oDCQTY1:VALUE = 1
self:oDCUNITPR1:VALUE = 804.55
I keep getting 885.01 I need this to be 885.00 what am I missing please. The screenshot shows the Terminal Output for the code above:
Thanks again.
.