docTienThanhChu static method
Implementation
static String docTienThanhChu(
double soTien, {
int roundDecimal = 2,
bool lienHe = true,
bool rutGon = false,
}) {
int i;
if (soTien > 8999999999999999) {
return soTien.toString();
}
if (soTien <= 0 && lienHe) {
return Message.getMessage('GIA_LIEN_HE');
}
var tienSo = Common.tienSo;
var tienDonVi = Common.getTienDonVi(rutGon);
for (i = 0; i < tienSo.length; i++) {
if (soTien / tienSo[i] > double.maxFinite ||
soTien / tienSo[i] < double.minPositive) {
return soTien.toString();
}
if (soTien >= tienSo[i]) {
if (soTien % tienSo[i] > 0) {
if (roundDecimal > 0) {
var r = round((soTien / tienSo[i]), roundDecimal);
if (r == 0 && lienHe) {
return Message.getMessage('GIA_LIEN_HE');
}
return '$r ${tienDonVi[i]}';
} else {
double lastValue = (soTien / tienSo[i]);
if (lastValue == 0 && lienHe) {
return Message.getMessage('GIA_LIEN_HE');
}
return '$lastValue ${tienDonVi[i]}';
}
} else {
int iSoTien = toInt((soTien / tienSo[i]).toString());
if (iSoTien == 0 && lienHe) {
return Message.getMessage('GIA_LIEN_HE');
}
return '$iSoTien ${tienDonVi[i]}';
}
}
}
if (soTien == 0 && lienHe) {
return Message.getMessage('GIA_LIEN_HE');
}
return soTien.toString();
}