Crystal Reports Localaization Won't Change Currency Symbol - localization

I'm working with a Crystal Reports export with different localization. For this example, I'm trying to set the localization to French which uses Euros.
I set the localization with the following C# code:
ReportDocument report = new ReportDocument();
report.ReportClientDocument.LocaleID = CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrench;
report.ReportClientDocument.PreferredViewingLocaleID = CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrench;
report.ReportClientDocument.ProductLocaleID = CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrench;
When I export the report the following value is displayed:
135,00 $
Notice that the format of the number changed correctly, but the currency symbol didn't.
I've been searching for a solution but pretty much everything focuses on changing the currency at design time, but I need to be able to change it at run time depending on some other values that the user selects.
I've seen some hints around using parameters to pass in a value and using a formula in the designer but I'm not familiar enough with Crystal Reports to figure it out.
I'm using Crystal Reports 10.5 with Visual Studio 2010 and .Net 3.5.
Any help or tips is appreciated.

I figured it out and based on the research that I've done I think that this is the only way to do it.
I'm pretty sure that the symbol doesn't change on purpose. Following the logic that a report is used for only one type of currency, even though the format will change with culture, the actual currency value is the same. $100 is always a $100 no matter what language the report is viewed in and this way, the report doesn't have to worry about converting the data to different amount.
In my application, the data is stored as just a number and the currency is determined by other values in the database and the code.
But to get to the point, I specified the locale of the report based on the code in my question. Then to change the currency, symbol I had to go into the report designer and format the currency questions.
In the 'Number' tab of the Format Editor, make sure the 'Display Currency Symbol' box is checked. Then click on the 'Customize' button and the 'Currency Symbol' tab. Go to the Formula Workshop for the currency symbol and then put in the following code:
Local StringVar locale := LowerCase(ContentLocale);
if locale = "fr_fr" then
"€"
else if (locale = "en_gb") then
"£"
else if(locale = "en_us" OR locale = "en_ca") then
"$"
else
""
This is just an example of the languages that I'm supporting but right now, but I think it gets the point across. Also note that Crystal uses underscores in the locale IDs instead of hyphens.
Kind of a log winded answer but hopefully this will help someone else.

Related

Is it safe to localize the "#" (pound sign, hashtag) as an ordinal indicator? (e.g. "#1", "#2")

We have a list of numbered reports that we display in our app - the numbering is important since the number of the report indicates the order it was created in, and gives the user a unique identifier to discuss the report with other users.
In a coworker's pull request, they're displaying text in labels in the UI for the cells which represent the reports with something like this:
label.text = "#\(report.userFacingNumber)"
This has the effect of numbering the reports correctly in english (i.e. "#1", "#2", etc) but I'm not sure that this will make sense in other languages.
Is the pound sign universal for indicating the ordinal of a list item? If not, is there an example language where this doesn't localize correctly that I could use to prove my point?
Is there a way in Swift/Foundation to correctly localize this ordinal listing?
"Is the pound sign universal for indicating the ordinal of a list item?"
No it is not. Many languages use N° or other symbols.
See:
https://en.wikipedia.org/wiki/Numero_sign
https://en.wikipedia.org/wiki/Number_sign#Usage_in_North_America
"Is there a way in Swift/Foundation to correctly localize this ordinal listing?"
Maybe there is a NumberFormatter that does this correctly, but I am not sure.
Your best bet is likely to omit the symbol.

Convert text to number in Google Sheets

I'm reading currency values from a website and I'd like to do some calculations with these numbers. They come in this format:
$7,821.24
Here's an example file:
https://docs.google.com/spreadsheets/d/1vHEH_m16KXcDh7hY_BVG9lur1huFjWOnx5bWtgrdGdA/edit?usp=sharing
Now for some reason neither VALUE() and TO_PURE_NUMBER work for me (Can't parse to numberic value, telling me it's a text value).
My guess is that the comma and the $-sign confuse the formula, is there anything I can do to format this correctly? The dollar sign always appears in the values but the comma only appears separating thousands of values.
I just started using Sheets for this so I absolutely have no clue. Would really appreciate if someone could help me out.
Thanks for your time!
Issue:
It's a locale problem. The value coming from IMPORTXML is formatted as in United States locale, so your spreadsheet (which uses a different format) cannot convert it.
Solution #1. Changing locale:
If the spreadsheet locale is changed to United States or others with the same format (via selecting File > Spreadsheet settings and setting the mentioned locale), the retrieved value will be a number, and you can work with it without using any other formula.
Solution #2. Formula:
If changing the locale is not an option, one possible way to convert the value to a valid number in your locale is the following formula:
=SUBSTITUTE(SUBSTITUTE(RIGHT(A2;LEN(A2)-1);",";"");".";",")
Changing locale didn't work in my case. But I was able to split the number which google sheet isn't detecting as a real number. So split it with "," and "." and any currency sign you may have, and then combine individual values for desired output

Filemaker if dropdown contains text alter calculation

I am fairly sure stuff like this has been answered but I am losing my hair at the moment with this. I am using Filemaker Pro 13
I have been landed with the job of updating some templates, I have done this before but all I was doing was updating the visual side of things. Now I am wanted to dynamically update some labels and calculations depending on a 'Company selected(drop down with custom values that are all text).
Currently all costs are multiplied by 2. So if original cost = $4 then customer cost is $8. However if 'Company 4' is selected rather than being multiplied by 2 it needs to be multiplied by 1.5.
I currently have two functions that I am trying to use this functionality on a field box.
First function:
If (Company: = "Comp4"; 1;0)
Second function:
If (${Function1}; ${$Cost}*1.5; ${$Cost}*2 )
This does not work, hence the answering of this question. As far as I could understand if statements work as (Condintion; If true do X; Else do Y;). This may be the problem? I do come from a programming background but this program is irritating me beyond belief at the moment.
If this has been answered before then I offer my sincerest apologies.
Thank you for any answers or help pointing me into the right direction.
Edit: Just tried this:
If (ValueCount(FilterValues(Company;"Comp4"));${$Cost}*1.5; ${$Cost}*2)
This was to no avail. Ideally if I could fit this into one function that would be great but so far I am still failing.
Edit 2:
With regards to the function / functions not working. I would often only get the ${$Cost}*2 side of things would happen however the ${$Cost}*1.5 would not even when "Comp4" was selected. This made me think that it was either the system was not detecting "Comp4" was selected or I need to look elsewhere to find the value I need to look at.
Edit 3: Real values and calculations used
Currently used and working so to speak ( Just does the *2 aspect of things)
Field Name: x2$Charges
Calculation: ${$Charges}*2. - $Charges is the 'cost' fields (10 of them).
What I want to do is when a specific company is selected rather than doing cost *2 I want to do cost *1.5.
The check for said company is :
Field Name: x2CheckSSL
Calculation: If(Sales Rep.|Distributor: = "SSL";1.5;2)
Where Sales Rep.|Distributor: is 'Company'
It's difficult to tell what is wrong with your syntax, because we don't know the exact names of your fields. Also, "this does not work" is not a good description of a problem.
The fact that you have constructs like ${$Cost} indicates that you have invalid field names.
If you had fields named Company and Cost, then a calculation field (defined in the same table as these two fields) =
If ( Company = "Comp4" ; 1.5 ; 2 ) * Cost
should provide the expected result.
On a more general level, this is not a good approach to take. All of these factors {"Comp4", 1.5, 2} are data and should not be hard-coded into a calculation formula.
Properly, every company should have a markup value stored in its own record, and this would be looked up into a field when you select a company. Alternatively, only some (preferred) companies would have a markup, while others would use a default value stored in a preferences table.
In addition, the Company field in this table (Invoices?) should really be CompanyID and store only the (meaningless) ID of the selected company.
Added:
This is a suggestion how to perform a quick fix to your current problem, following the clarifications made in comments.
The following fields are being assumed:
• $Charges - Number[10]
• Sales Rep.|Distributor: - Text
• x2$Charges - Calculation[10] = [see formula below]
Change the calculation formula of x2$Charges to =
If ( Extend (Sales Rep.|Distributor: ) = "SSL" ; 1.5 ; 2 ) * ${$Charges}
There is no need for the x2CheckSSL field.
IMPORTANT:
You should not use repeating fields for this. I suggest that as soon as possible you rewrite your solution and fix the flaws dscovered here, namely:
Rename your fields to valid (and reasonable*) names ;
Convert repeating fields to records in a related table;
Use lookups instead of hard-coding data in calculations.
(*) e.g. not names that end with ":"
IF statement works exactly as you described and I do not see why you need two different functions. I do not understand your syntax - ${$Cost}. Are you trying to add "$" to your output?
Let's say you have a field for selection as "slelect_company" in Companies table/layout and you stored cost in a variable called $cost
You calculation will be:
If (Companies::slelect_company = "Comp4"; $Cost*1.5; $Cost*2 )
If you set the field to output result, use formatting to add $ sign
If you set the label on the layout to show the output, use this:
If (Companies::slelect_company = "Comp4"; "$" & $Cost*1.5; "$" & $Cost*2 )
If you have more than one check, you can use Case - similar to switch in the other languages
Rather than putting your calculation in a function try creating a new calculation field and put your calculation there. When the record is committed you will see the value of this calculation field change and you will know if your function is working.
To do this
Go to File->Manage->Database
Type in a new field name and select "calculation" as the type and press create.
Enter your calculation e.g. if(Companies::select_company = "Comp4"; Companies::Cost * 1.5; Companies::Cost * 2)
The calculation engine will tell you what the errors are when you try to press okay after typing the calculation.
If it never detects the condition "Comp4" then there is an error in your string comparison, perhaps a trailing space, or an uppercase character or similar.

ExpressQuantumGrid Excel export of FMTBCD fields without currency symbol and format ",0.00"

According to this DevExpress Knowledge Base entry for the ExpressQuantumGrid, Excel-Exports from a cxGrid formats FMTBCD-Fields with a currency-Symbol it is necessary to use calculated fields of type TFloatField to export FMTBCD fields wihtout the currency symbol to Excel. The example code in the Knowledge Base works as expected.
However I also need to add a precision of two decimal digits in the exported file for the calculated field.
I tried to use Properties=CalcEdit with DisplayFormat=",0.00" but the export does not use the DisplayFormat of the grid column
I tried to set the DisplayFormat of the calculated field, but the export does not use the DisplayFormat of the data field
Using version 6.54. (I will also open a support case).
I had a similar problem wanting to export money values without the currency symbol. The only way I could do it, in the end, was to modify the source code.
I took a copy of cxGridExportLink.pas and put it in a project specific directory. Then changed line 767 (I'm using their subscription number 53 at the moment. Not sure what version that is) but it is the following line:
if (IsCurrencyItem(AItem)...
... then
VarCast(Result, AValue, varCurrency); // <--- This line
I changed varCurrency to varDouble and rebuilt my program. You'll also need a copy of cxVer.inc in the same directory.
This may well affect your 2 decimal digits requirement but it's the only way I found and it works well, so far, for us.
The issue is in the Knowledge database (since 2006):
Export - Excel - export numeric data as numbers with the same format as in the grid
Maybe it will be fixed in the future.

.NET Currency exponent ISO_4217

I'm developing something for international use. Wondering if anyone can shed any light on whether the CultureInfo class has support for finding currency exponents for particular countries, or whether I need to feed this data in at the database level.
I can't see any property that represents this at the minute, so if anyone knows definitively if it exists, before I look for it / buy it from ISO.
Currency Exponent is the minor units of the currency.
http://en.wikipedia.org/wiki/ISO_4217 - e.g. UK is "2"
Take a look at this blog post on getting CultureInfo for a region. Basically, Window and .NET know about the user's region but not their currency. A region implies a currency, but a country can have more than currency. For example, a person in Cambodia would more than likely want to enter and use USD than Riel. If possible, when capturing any currency amount in a multi-currency system you should capture the currency ISO code.
If you just want to make a quick guess, you can create a CultureInfo object and use it's NumberDecimalDigits property. The also creates a problem when countries switch currencies. For example, if Belarus joins the EU, then it's currency would change from BYR to EUR. It's currency symbol and exponent will be out of date.
I looked at this question and provided a solution which may or may not meet your needs here: http://www.codeproject.com/KB/recipes/MoneyTypeForCLR.aspx#CurrencyType
The short of it: I implemented the ISO spec as a custom type using the spec itself to generate the values. Obviously this would need to be regularly updated in production...

Resources