fix: remove duplicate functions

This commit is contained in:
prssanna 2020-12-07 14:43:41 +05:30
parent 9ab759bafb
commit 3b37ddcebe

View file

@ -24,50 +24,4 @@ Object.assign(frappe.utils, {
<div class="summary-value ${color}">${value}</div>
</div>`);
},
shorten_number(number, country) {
country = (country == 'India') ? country : '';
const number_system = get_number_system(country);
let x = Math.abs(Math.round(number));
for (const map of number_system) {
const condition = map.condition ? map.condition(x) : x >= map.divisor;
if (condition) {
return (number / map.divisor).toFixed(2) + ' ' + map.symbol;
}
}
return number.toFixed(2);
},
get_number_system(country) {
let number_system_map = {
'India':
[{
divisor: 1.0e+7,
symbol: 'Cr'
},
{
divisor: 1.0e+5,
symbol: 'Lakh'
}],
'':
[{
divisor: 1.0e+12,
symbol: 'T'
},
{
divisor: 1.0e+9,
symbol: 'B'
},
{
divisor: 1.0e+6,
symbol: 'M'
},
{
divisor: 1.0e+3,
symbol: 'K',
condition: (num) => num.toFixed().length > 5
}]
};
return number_system_map[country];
}
});