Why currency code is "000" from calling [Answers logAddToCartWithPrice] - google-fabric

enter image description here
I use [Answers logAddToCartWithPrice] to log purchase, but in log the currency code is 000, why?
may be I pass the nil to logAddToCartWithPrice's currency argument?

Mike from Fabric here. If a nil value is set for the currency code, then we switch to 000 so that the date can be processed correctly without affecting other currency's that have a valid code.

Related

consistent formattedValue of currency in backoffice and spartacus

We're having some difficulty with the provided formattedValue of the Product's Price.
Having USD, for example as the active currency.
The Product's formattedValue is of this format: US$421.08
How do we catch this exact format in frontend?
Is there an available spartacus method that translates a value with the assigned format?
Angular's currency pipe doesn't do the trick either.
I only managed to display it as $421.08
You can create your custom pipe https://angular.io/guide/pipes#custom-pipes and handle the logic on what you want it to be displayed.
For example, pass in the formatted value and the current currency iso string taken from currency.service - getActive() to concat both to display US$421.08, or any other mutation.

SOLIDITY CODING -- _totalSupply 0

enter image description here
Add 4 lines of code ALL of it are success!
But check wallet.ethereum.org can't find LC TOKEN and also ropsten.etherscan does not appear to be a valid Token Contract address
You have an underscore in between 'constant' and 'totalSupply'. As a result, you have a variable, displayed above decimals, that is named 'constant_totalSupply'. If you remove this underscore, I think this code should work as expected.

Want to verify character count of textbox

I am trying to validate the character count of a text field using TestNG, & I am not getting how to do so.
Here's my code what I have done, where upper limit is 50:-
I know I am doing something wrong but unable to understand what.
You are inserting a text of length 51. If you wanted to insert a text of length 50, change the <= to <. Then your first if i.e if (n==50) would pass.
However, if what you are trying to validate whether your textfield can autotruncate a higher length string to 50, then, it might be that it is not behaving correctly since the char length is obviously not 50 so either it is truncating more or it is not truncating less, in which case it is a valid failure and should be taken up as a bug to the dev owner.

Handling measurement units in NSTextField

I am creating a test application to calculate the area of a rectangle.This application uses NSTextField control to get the length and breadth of rectangle.
The user is expected to enter a string value which will include units of length as well (Sample Values 2.5 inches, 1500 mm).
I want NSTextField to convert the value in centimeters (cm) automatically so that it displays the converted value (in cm) as soon as the text field looses focus.
For Eg:
User Enters length as: 1500 mm
As soon as user goes to next text field to enter breadth, the length field displays
Displayed Value: 150 cm
How can we achieve this?
I think you want to use the delegate method, controlTextDidEndEditing:, which is sent to your text field's delegate when the editing is finished. Once you get the string from the field editor, you'll need to parse it somehow to find the units (how you parse it depends on what all you need to find). If you have a small number of things you're hunting for, like cm, mm, m, then you could probably just use rangeOfString: and test for 0 length to find out what units were entered. BTW, you should do your math correctly too -- 1500mm = 150 cm
I would consider a different approach, using a UIPicker to display the available units, and have them enter the number separately.
Otherwise, you'll have to do all this parsing. Don't see the point of parsing. Plus, if they make a mistake spelling the units, or use different ways of indicating it, then you would have to account for that as well. Depends on your application, but if the user has to type the units out anyway, it might be more convenient for them to use a UIPicker.

Clean up string data before saving in database as integer

I have an integer column called dollars in my database table and I am attempting to save values such as $1000 in the database. However, attempting to save the string $1000 with the dollar sign in an integer column will cause an automatic conversion to the integer 0.
To prevent this from happening, I tried to add a before_save callback to my clean_data method in my model to remove the dollar sign. But it seems that rails has already attempted to save the entire $1000 string in the database before clean_data is called.
I wonder if there is a better way to remove the dollar sign from the values before saving to the database as an integer?
Here's my code:
In the create action of the bids_controller.rb, doing this will allow the database to save the value $1000 from the form properly:
# Remove dollar sign
if params[:bid][:dollars][0] == "$"
params[:bid][:dollars] = params[:bid][:dollars].delete('$')
end
#bid = Bid.new(params[:bid])
#bid.save
However, if I were to remove the if-end fragment from the controller and clean the data in the Bid model, like this:
before_save :clean_data
def clean_data
puts self.dollars
self.dollars = self.dollars.delete('$')
end
I will get the value 0 for puts self.dollars before the clean_data method has a chance to remove the dollar sign.
My hypothesis is that rails has attempted to "hold" the data in the database before either clean_data or save is called, and this "hold" causes the data to be converted to 0 since the integer column isn't able to save the dollar sign.
Thank you very much for your help! :)
Take a look at the tr method.
"$1000".tr("$", "") # => "1000"
You should be able to do this on the string variable prior to saving it to the database.