How to show currency symbol (¥) in numeric? - handsontable

I was able to get default USD $,using
cellProperties.type = "numeric";
cellProperties.format = "$0,0.00";
How to show CNY ¥ in numeric?
I tried,
cellProperties.type = "numeric";
cellProperties.format = "¥0,0.00"
It shows only number with thousand comma, no any currency symbol, no error. Any help would be appreciated.

Handsontable uses the Numeral.js library to handle its number formatting. As it's written in the docs, the currency symbol (as well as other display options) depend on the "locale" of the cell, configurable via the language: option. To get it running for CHN, include the corresponding translation file and then set the language to 'chn':
<script src="https://docs.handsontable.com/0.24.3/bower_components/numeraljs/languages/chs.js"></script>
Here's a sample JSFiddle snippet to demonstrate your use-case.

Related

Don't show data notices in worksheet

I'm aware of data validations in Axlsx, however I'm not sure that's what I'm looking for here. I don't want to validate any data per se, but want any cell notices (in Excel here) to to be ignored.
For example, a notice I'm seeing on a couple of cells is:
The number in this cell is formatted as text or preceded by an apostrophe.
I tried doing something like this to select the whole worksheet and avoid showing any validation erros, however it didn't work for me:
sheet.add_data_validation("A1:H100", {
showErrorMessage: false
})
Can I use a Data validation to avoid displaying these notices in Excel?
This is one of the error checking options found in Excel Options ► Formulas ► Error checking rules ► Numbers formatted as text or preceded by an apostrophe. (or Alt+F,T,F then Alt+H)
To halt the display of these error control messages through VBA, run the following line of code.
Application.ErrorCheckingOptions.NumberAsText = False

Change Magento decimal field format

I need to change Magento's default decimal format. I mean, when I save '1' to a decimal field, it becomes '10000.0000' with this '.0000' in the end.
I need to change it to another format, which uses ',' instead of '.' to separate decimal (and currency) numbers.
This is the Brazilian standard and it's not being used even after changing the store language. This change should be reflected mainly in the admin side.
Thanks a lot!
==Edited==
I haven't solved the problem yet. I'm using PT-BR (Brazilian Portuguese) as default language and it still using the wrong decimal character.
It seems Magento have some not-localized price formatting (I mean, hard-coded) in a few points of code. For example: magento\js\prototype\validation.js at line 426 have:
|| (!isNaN(parseNumber(v)) && /^\s*-?\d*(\,\d*)?\s*$/.test(v));
but instead it needs to be
|| (!isNaN(parseNumber(v)) && /^\s*-?\d*(\,\d*)?\s*$/.test(v));
to fit into PT-BR format (or other locales to).
Am I right? Does anybody could fix this issue?
if you want to check in admin area for this change
you go to in admin left bottom drop down
and select
Português (Portugal) / português (Portugal)
it will show you currency as you want. Also if you doesn't install you package go to
http://www.magentocommerce.com/translations/list/19
download your package and add it to your
locale folder and select from configuration for front end also
hope this will sure help you.
I've applied the following change to the file magento\js\prototype\validation.js (line 426):
|| (!isNaN(parseNumber(v)) && /^\s*-?\d*(\,\d*)?\s*$/.test(v));
and also, changed the file lib/Varien/Data/Form/Element/Abstract.php by adding the first if statement:
public function getEscapedValue($index=null)
{
$value = $this->getValue($index);
if(is_numeric($value)){
$value= number_format($value, 3, ",", ".");
}
...
this changes have solved the problem so far. Do you see any side-effect?
Comments are welcome! Thanks!
Newer versions of Magento are based on Zend Framework currency locale format so the best way to do this is to change the language.xml from the Zend directory, more information is on this great article.

Removing .00 in configurable attribute price in Magento

The currency I'm using in the Magento site I'm creating is Japanese Yen which does not have decimals in their currency. I've managed to remove it from my product page and cart.
By modifying app/code/local/Mage/Directory/Model/Currency.php inside format function like so:
$locale = Mage::app()->getLocale()->getLocaleCode();
if($locale != 'ja_JP') {
return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
} else {
return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
}
However, in the dropdown attribute I created, the decimal still shows. Like so:
White - ¥3000.00
Blue - ¥5000.00
In my dropdown attribute, how can I drop .00 at the end of the price? Also, is it possible to drop decimal for the admin without altering the database?
I've tried searching but sadly, Magento does not have a direct feature that would handle this. Or at least I haven't come across said feature.
You can add this piece of code on beginning of formatTxt method in the same class you was editing:
if(Mage::app()->getLocale()->getLocaleCode() == 'ja_JP') {
$options['precision'] = 0;
}
This will change the precision for prices in almost every place inside Magento (like Catalog, Checkout, even Administration).
Check code of free ET_CurrencyManager extension to find a solution. You need to modify more that one funstion in Mage_Directory_Model_Currency. Also you need to modify precision for JS scripts too in Mage_Core_Model_Locale::getJsPriceFormat.
Or just use this extension to avoid core files modifications.
In fact the Zend local format for JA (Japnese) is wrong, see file:-
httpdocs/lib/Zend/Locale/Data/ja.xml
Line: 2953 (or just search for "0.00")
Update to the following:-
<currencyFormats>
<currencyFormatLength>
<currencyFormat>
<pattern>¤#,##0</pattern>
</currencyFormat>
</currencyFormatLength>
</currencyFormats>
This will completely change the YEN display price to have zero decimals within the JA Locale.
A couple of words of warning...
The admin area if viewed in any locale other than ja_JP will allow a
decimal price to be entered, entering a YEN price with a decimal
position of anything other tha ".00" will result in a checkout price
mismatch error.
It appears that Magento will always send prices to
PayPal with two decimal positions and this will cause price mismatch
errors when applying coupon or Sale discounts (Mage 1.6) - I'm
currently working through this issues on this and testing against
1.9 Version.
Okay, so I managed to remove .00 by modifying configurable.js and product.js. It's not a direct solution but a workaround.
For each file, I split the price string removing any decimal points(.) and numbers succeeding it by using the split function of javascript. So I added something like so:
var a = price.split(.);
return a[0];
Using that, all the decimals have been dropped from my prices. Thanks for all your time and help.

Choosing form fields by label using Mechanize?

I originally wrote 800 lines to do this, site by site. However, on talking to a couple of people, it seems like my code is way longer than it needs to be.
So, I've got an idea of what you'd do in Python, with a particular Egg, but I'm working with Ruby. So, does anyone have any idea how to enter details in a form field, based on what the label for it is, rather than the id/name? Using Mechanize.
Let's say your html looks like:
<label>Foo</label>
<input name="foo_field">
You can get the name of the input following a specific label:
name = page.at('label[text()="Foo"] ~ *[name]')[:name]
#=> "foo_field"
and use that to set the form value
form[name] = 'bar'

Telerik MVC CurrencyTextBox - Custom value formatting

(First off, I have already posted this on the Telerik forums (link), but this site gets more traffic, so I'm hoping to get some help sooner.)
I am trying to achieve some custom value formatting with the CurrencyTextBox, but the way that the control handles values is making things decidedly hard.
What I want to do is this: if the user enters a value that does not contain a "." character, it will format that value as cents instead of dollars. So if a user enters "16", I want the control to display (and contain a value of) $0.16. If the user enters a value with a ".", I would like the control to function as normal. If the user enters "16.", "16.0" or "16.00", I want the control to display (and contain a value of) "$16.00". This application will be used by people in the retail business and this is how they expect inputs for price values to function.
However, whether I subscribe to the OnChange event or even the "blur" event on the textbox itself, it is stripping the "." character if there is either nothing after it or only 0's after it. Example: If I enter in a value of "16.", "16.0" or "16.00", the value pulled from the textbox in javascript will be "16". And since I have to check for the presence of the "." character, this breaks my logic to properly format the value.
So I'm looking for some help or suggestions. Here is the javascript that I have right now to properly format the value as required. As you can see, if the value does not contain a "." character, the value is divided by 100, which is exactly what I want. Stripping this character is killing my logic. :)
$('custom-price').find('input').live('blur', function (e) {
var sender = $(this).data('tTextBox');
var priceVal = $(this).val(); // $(this).attr('value') also returns the value with the character stripped, FYI
if (priceVal.indexOf(".") == -1) {
priceVal = priceVal / 100;
}
sender.value(priceVal);
});
Try the same using ascii code for "." operator (46). OnKeyPress if you find ascii code 46 change the format for control..
Regards,
Dhaval Shukla

Resources