fix: 金额计算展示保留原始数据精度,去除 toFixed(1) 进位截断并升级至 v1.0.3
This commit is contained in:
@@ -110,7 +110,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 4,
|
||||
"boardInt": "702",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -226,7 +226,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 2,
|
||||
"boardInt": "468",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -342,7 +342,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 1,
|
||||
"boardInt": "195",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -458,7 +458,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 27,
|
||||
"boardInt": "4,428",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -574,7 +574,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 26,
|
||||
"boardInt": "4,056",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -704,7 +704,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 3,
|
||||
"boardInt": "468",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -834,7 +834,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 3,
|
||||
"boardInt": "408",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -950,7 +950,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 1,
|
||||
"boardInt": "156",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -1066,7 +1066,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 1,
|
||||
"boardInt": "176",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -1182,7 +1182,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 6,
|
||||
"boardInt": "312",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -1298,7 +1298,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 6,
|
||||
"boardInt": "312",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -1414,7 +1414,7 @@
|
||||
"isCurrentMonth": false,
|
||||
"recordCount": 3,
|
||||
"boardInt": "156",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 31,
|
||||
@@ -1530,7 +1530,7 @@
|
||||
"isCurrentMonth": false,
|
||||
"recordCount": 3,
|
||||
"boardInt": "156",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 31,
|
||||
@@ -1654,7 +1654,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 1,
|
||||
"boardInt": "117",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -1778,7 +1778,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 1,
|
||||
"boardInt": "283",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "-",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -1894,7 +1894,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 4,
|
||||
"boardInt": "156",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2010,7 +2010,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 1,
|
||||
"boardInt": "156",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2126,7 +2126,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 3,
|
||||
"boardInt": "156",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2242,7 +2242,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 20,
|
||||
"boardInt": "6,400",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2358,7 +2358,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 1,
|
||||
"boardInt": "156",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2494,7 +2494,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 4,
|
||||
"boardInt": "624",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2610,7 +2610,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 0,
|
||||
"boardInt": "0",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2726,7 +2726,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 3,
|
||||
"boardInt": "516",
|
||||
"boardFrac": ".8",
|
||||
"boardFrac": ".75",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2842,7 +2842,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 3,
|
||||
"boardInt": "429",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -2958,7 +2958,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 3,
|
||||
"boardInt": "439",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -3074,7 +3074,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 27,
|
||||
"boardInt": "4,428",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -3190,7 +3190,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 27,
|
||||
"boardInt": "4,478",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
@@ -3306,7 +3306,7 @@
|
||||
"isCurrentMonth": false,
|
||||
"recordCount": 2,
|
||||
"boardInt": "351",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 31,
|
||||
@@ -3422,7 +3422,7 @@
|
||||
"isCurrentMonth": false,
|
||||
"recordCount": 2,
|
||||
"boardInt": "351",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 31,
|
||||
@@ -3538,7 +3538,7 @@
|
||||
"isCurrentMonth": true,
|
||||
"recordCount": 0,
|
||||
"boardInt": "0",
|
||||
"boardFrac": ".0",
|
||||
"boardFrac": "",
|
||||
"boardSign": "",
|
||||
"hourOptions": "6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12",
|
||||
"daysInMonth": 30,
|
||||
|
||||
+13
-11
@@ -425,20 +425,22 @@ test('isCurrentMonth / isSameDay 只认传进来的 now', () => {
|
||||
|
||||
// ───────────────────────── 格式化 ─────────────────────────
|
||||
|
||||
test('金额格式化保留 1 位,null/undefined 当 0', () => {
|
||||
test('金额格式化保留原始数据(分位不截断,不进位),null/undefined 当 0', () => {
|
||||
assert.equal(P.fmt(undefined), '0.0');
|
||||
assert.equal(P.money(null), '¥0.0');
|
||||
assert.equal(P.money(1234.56), '¥1234.6');
|
||||
assert.equal(P.signed(0), '+¥0.0');
|
||||
assert.equal(P.signed(-5), '-¥5.0');
|
||||
assert.equal(P.signed(30), '+¥30.0');
|
||||
assert.equal(P.money(null), '¥0');
|
||||
assert.equal(P.money(1234.56), '¥1234.56');
|
||||
assert.equal(P.money(2018.25), '¥2018.25');
|
||||
assert.equal(P.signed(0), '+¥0');
|
||||
assert.equal(P.signed(-5), '-¥5');
|
||||
assert.equal(P.signed(-50.25), '-¥50.25');
|
||||
assert.equal(P.signed(30), '+¥30');
|
||||
});
|
||||
|
||||
test('moneyParts 从 toFixed(1) 的结果上切,不另算整数部', () => {
|
||||
// 99.96 若用 Math.floor 另算会得到 99,与 money() 的 ¥100.0 打架
|
||||
assert.deepEqual(P.moneyParts(99.96), { sign: '', int: '100', frac: '.0' });
|
||||
assert.deepEqual(P.moneyParts(-1234.56), { sign: '-', int: '1,234', frac: '.6' });
|
||||
assert.deepEqual(P.moneyParts(0), { sign: '', int: '0', frac: '.0' });
|
||||
test('moneyParts 保留原始数据小数位,千分位与小数部拆分对齐', () => {
|
||||
assert.deepEqual(P.moneyParts(99.96), { sign: '', int: '99', frac: '.96' });
|
||||
assert.deepEqual(P.moneyParts(2018.25), { sign: '', int: '2,018', frac: '.25' });
|
||||
assert.deepEqual(P.moneyParts(-1234.56), { sign: '-', int: '1,234', frac: '.56' });
|
||||
assert.deepEqual(P.moneyParts(0), { sign: '', int: '0', frac: '' });
|
||||
assert.deepEqual(P.moneyParts(1234567.8), { sign: '', int: '1,234,567', frac: '.8' });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user