Inline formatting of currency in expression of text box

Stimulsoft Reports.PHP discussion
brobar
Posts: 24
Joined: Wed Mar 23, 2011 6:31 pm

Inline formatting of currency in expression of text box

Post by brobar »

I have a text component that has a paragraph of text that I'm displaying and has a database variable in the text that displays a total monetary value. Here is an example:

The expression in my text box is:
PAYMENT TERMS: Buyer shall pay Seller the cash purchase price of {quoteTable.projTotal} for the Equipment and Services, due in installments as follows:
So you can see the quoteTable.projTotal value being pulled from the database and injected into the text box, which comes out looking like this:

PAYMENT TERMS: Buyer shall pay Seller the cash purchase price of 343096.92 for the Equipment and Services, due in installments as follows:

However I need to format that quoteTable.projTotal value into a currency format so it would look like this:

PAYMENT TERMS: Buyer shall pay Seller the cash purchase price of $343,096.92 for the Equipment and Services, due in installments as follows:

Is there a function that I could use inline in the expression of this text box that would format that value into currency?

Thanks for the assistance!

Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Inline formatting of currency in expression of text box

Post by Vladimir »

Hello,

You can use the following expression:

Code: Select all

PAYMENT TERMS: Buyer shall pay Seller the cash purchase price of {Format("{0:C}", quoteTable.projTotal)} for the Equipment and Services, due in installments as follows:
Thank you.
brobar
Posts: 24
Joined: Wed Mar 23, 2011 6:31 pm

Inline formatting of currency in expression of text box

Post by brobar »

Vladimir wrote:Hello,

You can use the following expression:

Code: Select all

PAYMENT TERMS: Buyer shall pay Seller the cash purchase price of {Format("{0:C}", quoteTable.projTotal)} for the Equipment and Services, due in installments as follows:
Thank you.
Thanks for the reply. That got me much closer. It is now spitting out.

PAYMENT TERMS: Buyer shall pay Seller the cash purchase price of $343 096.92 for the Equipment and Services, due in installments as follows:

So it added the dollar sign to the left like it should but for some reason it adds a space where the comma should be. Is there any way to tweak that Format function to where it uses a comma "," instead of a space " " so it would spit out $343,096.92 instead of $343 096.92?

Thanks again. I really appreciate the assistance.
brobar
Posts: 24
Joined: Wed Mar 23, 2011 6:31 pm

Inline formatting of currency in expression of text box

Post by brobar »

Same thing happens if I use {Format("{0:N}", quoteTable.projTotal)} replacing the C with an N. Of course that won't give me the ($) dollar sign but I just wanted to see if it would format the number with commas and it doesn't. It spits it out as: 343 096.92. Any idea why it wouldn't be utilizing commas for currency or number formats? Is this a locale thing that I can change within stimulsoft or is it possibly a locale thing within my web server? If this is a server issue and not a application issue... any idea where I can check locale settings on a MAMP server to get that corrected?

Thanks,

*** EDIT ***
I checked the languages & text formats on my Mac and they are set correctly to the US Dollar and show that it should format correctly with the dollar sign AND comma so it isn't that:
Image

Any other ideas?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Inline formatting of currency in expression of text box

Post by Vladimir »

Hello,

In the future, inline-formatting will be expanded. As an alternative, currently you can use the following expression:

{Replace(Format("{0:N}", quoteTable.projTotal), " ", ",")}

Thank you.
brobar
Posts: 24
Joined: Wed Mar 23, 2011 6:31 pm

Inline formatting of currency in expression of text box

Post by brobar »

Vladimir wrote:Hello,

In the future, inline-formatting will be expanded. As an alternative, currently you can use the following expression:

{Replace(Format("{0:N}", quoteTable.projTotal), " ", ",")}

Thank you.
Perfect! Works like a charm! Thanks so much!
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Inline formatting of currency in expression of text box

Post by Andrew »

Hello,

Great!

If you have any other questions regarding Stimulsoft Reports products then please let us know.

Thank you.
alex.coles
Posts: 14
Joined: Mon Feb 03, 2020 2:19 pm

Re: Inline formatting of currency in expression of text box

Post by alex.coles »

Is there any way to use the local setting, as you would with a standard currency field? I'm always seeing $ instead of my local currency. When using a standard currently field ticking Use Local Setting gives me the correct currency.
Stimulsoft.Reports.JS - Version: 2019.4.2 - Build date: 2019.11.13
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: Inline formatting of currency in expression of text box

Post by Lech Kulikowski »

Hello,

Could you explain your issue in more detail?

Also, please clarify which product and version are you use?

Thank you.
alex.coles
Posts: 14
Joined: Mon Feb 03, 2020 2:19 pm

Re: Inline formatting of currency in expression of text box

Post by alex.coles »

I am using the following as an expression:

Code: Select all

Was: {Format("{0:C}", data_items.price)}
but it comes out as

Code: Select all

Was: $2.49
on the report.

I have other fields that are numeric and set to type 'Currency' with the 'Use Local' property set to true and they show '£' correctly (without the Local property they revert to '$' so suspect this is not being used in the inline conversion).

Stimulsoft.Reports.JS
Version: 2019.4.2
Build date: 2019.11.13
Stimulsoft.Reports.JS - Version: 2019.4.2 - Build date: 2019.11.13
Post Reply