Skip to content

Commit

Permalink
处理某些有小数的情况下,转金额出现零结尾的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
汪航洋 committed Jul 2, 2021
1 parent c64b6ad commit 6cf341f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ function toMoney(num, options) {
}
zs_str = CL.call(this, _num, options) + this.m_u.charAt(0);
} else {
_decimal = utils.clearZero(_decimal, "0", "$");//去除尾部的0
_decimal = _decimal.substr(0, this.m_u.length-1);
_decimal = utils.clearZero(_decimal, "0", "$"); //去除尾部的0
if (_decimal) {
var mark_0;
for (var i = 0; i < this.m_u.length - 1; i++) {
Expand Down
1 change: 1 addition & 0 deletions test/testData.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
["00.1", "人民币壹角"],
["01.1", "人民币壹元壹角"],
["1.10", "人民币壹元壹角"],
["1.101", "人民币壹元壹角"],
["10.01", "人民币壹拾元零壹分"],
["10.012", "人民币壹拾元零壹分"],
["100111.11", "人民币壹拾万零壹佰壹拾壹元壹角壹分"]
Expand Down

0 comments on commit 6cf341f

Please sign in to comment.