Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Decimal values for currency Post Reply Post New Topic
Author Message
IdiotProgrammer
Newbie
Newbie


Joined: 14 May 2013
Location: South Africa
Online Status: Offline
Posts: 1
Quote IdiotProgrammer Replybullet Topic: Decimal values for currency
     Posted: 14 May 2013 at 10:10pm
guys, please please assist me. We have a product, that "bolts on" to another product. when producing the sales document, we need to deduct the product from the one and place it to the other sales document for the Bolt-on.

This is the string for report 1, which should be deducting the bolt on...
{v_ReportPolicy.Duration} + ' Months ' + {v_ReportPolicy.PlanType} + ' Warranty at R ' + ToText(toNumber({v_ReportPolicy.TotalCost}) - toNumber({v_ReportPolicy.TyreCost}) - toNumber({v_ReportPolicy.MicrodotPrice}) - tonumber({v_ReportPolicy.SOSCost}))

the result it gives, does not deduct the cents, only the whole units of currency.

is there a way around this? what have i done wrong?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 May 2013 at 4:11am
try
ToText(toNumber({v_ReportPolicy.TotalCost}) - toNumber({v_ReportPolicy.TyreCost}) - toNumber({v_ReportPolicy.MicrodotPrice}) - tonumber({v_ReportPolicy.SOSCost}),2)
IP IP Logged
joeg1962
Newbie
Newbie


Joined: 01 Mar 2013
Location: United States
Online Status: Offline
Posts: 35
Quote joeg1962 Replybullet Posted: 15 May 2013 at 4:13am
You need a parameter on ALL of your totext functions.
totext(variable,2) will force 2 decimal places
otherwise, it could round that number

12.53 becomes 13
12.47 becomes 12

CORRECTED: originally typed the tonumber but meant totext


Edited by joeg1962 - 15 May 2013 at 4:30am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 May 2013 at 4:21am
To my knowledge, at least in Version XI, tonumber() will not allow for the use of a condition to indicate the number of decimal points for the conversion. By default it displays without the decimals and rounds only at the time of the display. You can "unround" a converted value by changing the display option in the Format Field options.
ToText() does allow for the use of the condition to define the number of decimal points to display.

Edited by DBlank - 15 May 2013 at 4:22am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum