You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
980 B
JavaScript
33 lines
980 B
JavaScript
export const pembulatan500 = function (number) {
|
|
if (typeof number === 'number') {
|
|
let num = number.toString();
|
|
if (num.length > 3) {
|
|
let numPart = Number(num.substring(num.length - 3, num.length));
|
|
let numbers = Number(num) - numPart;
|
|
if (numPart > 500) {
|
|
return numbers + 1000;
|
|
} else {
|
|
if(numPart > 0){
|
|
return numbers + 500;
|
|
}else{
|
|
return numbers;
|
|
}
|
|
}
|
|
} else {
|
|
if (Number(num) > 500) {
|
|
return 1000;
|
|
} else {
|
|
if(num > 0){
|
|
return 500;
|
|
}else{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (typeof Swal != 'undefined') {
|
|
Swal('Info', 'data pembulatan 500 tidak berformat number');
|
|
}
|
|
throw 'data bukan number';
|
|
}
|
|
} |