number_to_currency Removing the Decimal Point - ruby-on-rails-3

Is there any way to change the value in the display to the following:
$100.25 to 10025
Need this to be in this format to go through a payment gateway.

You can use the String.delete method:
"$100.25".delete("$.")
=> 10025

Related

Printing watson entity found in text (input)

I have a situation, where user asks for "I want to buy us dolars". I have already defined the intent for the question "I want to buy". What I need, is to identify which currency user is talking about (buying).
For that, I created an Entity "money", with a value "currency", and its synonyms (us dollar, euros, ienes, ....).
The issue is, that the node recognizes #items:buying and #money:currency. How can I get which currency was found, and use it onto the context/output?
I tried using and also
but it always returns an empty value.
entities[0] returns me only the buying stuff, the first recognized thing. I need the second, specifically by name, in order to customize my conversation flow.
Thanks a lot.
To resolve this, first switch on #sys-currency system entity.
After that, this example should work once training is complete.
Condition: #sys-currency
Response: Currency: <? #sys-currency.unit ?>. Total: <? #sys-currency ?>
However it assumes that you are writing the currency correctly. For example:
20 USD
$20
20 dollars
More details here:
https://www.ibm.com/watson/developercloud/doc/conversation/system-entities.html#sys-currency-entity
To address the other point of finding the value of the recognised text of the entity, you would use:
<? entities[0].literal ?>

Pentaho cuts double values from Table Input

I have a Problem that I could not fix up to now. When I do a "Select" at a Table-Input the double values are not returned completely and are always cut. Here are some examples:
15.0420 => 15 // 12.6000 => 12,6 // 4.1176 => 4,1 // 0.1123 => 0,1 // 0.0012 => 0
I seems like, that minimum two numbers are shown and max one number after the comma. However it is very important to get the right figures.
I use pentaho 6.1, and mariaDB 5.5.49.
Thanks for every help.
Best regards,
Dave
Finally I adjusted the configuration of the Default Number Format. Under "Edit->Edit the kettle.properties file", I set the "KETTLE_DEFAULT_NUMBER_FORMAT" with the format '#.####'. Now it is working!

eBay API aspectFilter with MaxPrice parameter returns 0 results

I am using the following URL to fetch car listing. But when I add the MaxPrice parameter It shows 0 items. But on the site there are 12 items that have price below my value.
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.12.0&SERVICE-NAME=FindingService&SECURITY-APPNAME=prosoftda-d112-4c99-9bec-8a09c902a7a&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=50&categoryId=6001&outputSelector=PictureURLSuperSize&REST-PAYLOAD=true
&aspectFilter(0).aspectName=Make&aspectFilter(0).aspectValueName=Audi
&aspectFilter(1).aspectName=Model&aspectFilter(1).aspectValueName=Q7
&aspectFilter(2).aspectName=Model+Year&aspectFilter(2).aspectValueName=2013
&aspectFilter(3).aspectName=MaxPrice&aspectFilter(3).aspectValueName=50000.00
When I remove MaxPrice parameter the URL works perfectly.
Btw, I got the solution for this question:
To pass the price value need to pass as ItemFilter. not with the AspectFilter.
I replace the string :
&aspectFilter(3).aspectName=MaxPrice&aspectFilter(3).aspectValueName=50000.00
By the string :
&itemFilter(0).name=MaxPrice&itemFilter(0).value=500000.00
So It works now. As Price parameter is related to attribute so need to pass with the ItemFilter.
So final URL Is:
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.12.0&SERVICE-NAME=FindingService&SECURITY-APPNAME=prosoftda-d112-4c99-9bec-8a09c902a7a&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=50&categoryId=6001&outputSelector=PictureURLSuperSize&REST-PAYLOAD=true
&aspectFilter(0).aspectName=Make&aspectFilter(0).aspectValueName=Audi
&aspectFilter(1).aspectName=Model&aspectFilter(1).aspectValueName=Q7
&aspectFilter(2).aspectName=Model+Year&aspectFilter(2).aspectValueName=2013
&itemFilter(0).name=MaxPrice&itemFilter(0).value=500000.00
Thanks. may be this can help someone who is finding the same question.
I have no experience with this API so this is just a shot in the dark. But I found this link:
http://developer.ebay.com/DevZone/finding/CallRef/findItemsAdvanced.html
From what Ive read within that MaxPrice is more of an "itemFilter" (things such as maxPrice, bestOfferOnly, featuredSeller) than an "aspectFilter" (things such as Make, Model, Optical Zoom).
Further down it also states that some itemFilters need a paramName, such as maxPrice
For example, if you use the MaxPrice itemFilter, you will need to specify
a parameter Name of Currency with a parameter Value that specifies the type
of currency desired.
Again never used this API but seems relevant to me.

Rails number_to_currency precision doesn't work - is it a bug?

I'm trying to use number_to_currency to get two digits after the decimal dot in Rails 3, but I can get only one. My DB field is defined like this:
t.decimal "amount", :precision => 5, :scale => 2
In my template I have:
#{number_to_currency(#purch.amount)}
And yet as the result I get: PLN 34,7
In the DB I can clearly see: 34.70
I would like to see my second zero - is it a feature or am I missing something?
Thanks!
The answer is to check the following setting in one's locale configuration file:
currency:
format:
strip_insignificant_zeros: false
Since you seem to be using a custom locale, try forcing the behavior you want by explicitly setting the options of number_to_currency:
number_to_currency(#purch.amount, :precision => 2)
You can also set these options in the locale file for your language. Take a look at http://guides.rubyonrails.org/i18n.html

basic modification of default model output with scope

I find myself doing the same things over and over again just to make one small modification to standard model output. I have a series of tables that I store information about products, etc. and all of which store prices. The prices are stored in US dollars but the output depends on the currency the user wants which is stored in a their session.
Examples:
Product Detail Blah Price
Hammer Red More 5.00
Nail Blue Stuff 3.99
Is there a simple robust way to modify the output so that when i call:
Product.all
I could attach something like
Product.all.currency('EUR')
Product.find(22).currency('EUR')
Product.find(:all, :conditions => 'etc etc').currency('EUR')
or
Product.all.currency(0.69)
and simply multiply all of the items in the Price column? Could named_scope do this?
try reordering your chaining like:
Product.currency(0.69).all
I have not tested that, but you may have issue with other arbitrary conditions since your :select contains *
Nevermind...
named_scope :currency, :select => '*, price * 0.63 AS price'
seemed to work except I can't chain it to normal finds as I would like.