Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Setting Currencies

Douglas Lima   ( User )

Commented 5 years ago

Hello guys,


I am having trouble using JP - Yen. In Japan, you do not use "Precision" or "the Japanese yen doesn't use a minor unit".


Example:


var number = 123456.789;


// the Japanese yen doesn't use a minor unit


console.log(new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(number));


// expected output: "¥123,457"


 


Then when editing an Expenses->Payments post, the system deletes the decimal values, for example:


Value ¥1,596


https://prntscr.com/n3dk4y


 


With the form open(Edit Payments):


https://prnt.sc/n3dnv0


 


 

Douglas Lima   ( User )

Commented 5 years ago

The toLocaleString() method returns a string with a language-sensitive representation of this number:


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString


 


function eJapan(x){


  return x.toLocaleString('ja-JP');


}


 


console.log(eJapan(123456));


// expected output: "123,456"


 


console.log(eJapan("123456"));


// expected output: "123456"


 


console.log(eJapan(NaN));


// expected output: "NaN"


 


/*CONSOLE LOG RETURN*/


> "123,456" > "123456" > "NaN"


 


https://prnt.sc/n3dpb5

Please login or register to leave a response.

Showing 1 to 2 of 2 discussions