kts-component-invoice-operate 3.2.108 → 3.2.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /** 格式化 保留2位小数 */
2
2
  export declare const format2: (value: number | string) => number | "";
3
3
  /** 格式化 保留15位数字 */
4
- export declare const format15: (value: number | string, defaultFractionDigits?: number) => number | "";
4
+ export declare const format15: (value: number | string, defaultFractionDigits?: number) => number | "" | undefined;
5
5
  /**
6
6
  * 金额(含税) = 数量 * 单价(含税)
7
7
  * @param quantity 数量
package/dist/index.esm.js CHANGED
@@ -1389,7 +1389,7 @@ var format15 = function format15(value) {
1389
1389
  if ("".concat(value) === 'NaN') return '';
1390
1390
  if (typeof value === 'string') value = parseFloat(value);
1391
1391
  var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
1392
- return parseFloat(value.toFixed(fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits));
1392
+ return onScientificNotation(value, fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits);
1393
1393
  };
1394
1394
  /**
1395
1395
  * 金额(含税) = 数量 * 单价(含税)
@@ -1456,6 +1456,22 @@ function countQuantity(amount, price, calculatingDigits) {
1456
1456
  if (!price && price !== 0) return undefined;
1457
1457
  return format15(chain$1(bignumber(amount)).divide(bignumber(price)).done().toNumber(), calculatingDigits);
1458
1458
  }
1459
+ /** 不用可续计数法 */
1460
+
1461
+ function onScientificNotation(e, fractionDigits) {
1462
+ debugger;
1463
+ var arr = e.toFixed(fractionDigits).split('');
1464
+
1465
+ for (; arr.length > 0;) {
1466
+ if (arr[arr.length - 1] === '0' || arr[arr.length - 1] === '.') {
1467
+ arr.pop();
1468
+ } else {
1469
+ return arr.join('');
1470
+ }
1471
+ }
1472
+
1473
+ return '0';
1474
+ }
1459
1475
 
1460
1476
  var calculator = /*#__PURE__*/Object.freeze({
1461
1477
  __proto__: null,
@@ -1855,7 +1871,7 @@ function _mergeDetails() {
1855
1871
  case 9:
1856
1872
  sum = _context.sent;
1857
1873
  _context.next = 12;
1858
- return mergeQuantity(goodsList);
1874
+ return mergeQuantity(goodsList, state.calculatingDigits);
1859
1875
 
1860
1876
  case 12:
1861
1877
  sum.quantity = _context.sent;
@@ -1917,7 +1933,7 @@ function _mergeDetails() {
1917
1933
  return _merge.apply(this, arguments);
1918
1934
  };
1919
1935
 
1920
- merge = function _merge2(_x14) {
1936
+ merge = function _merge2(_x15) {
1921
1937
  return _merge.apply(this, arguments);
1922
1938
  };
1923
1939
 
@@ -2036,10 +2052,10 @@ function _calculatePriceExcludeTax() {
2036
2052
  return _context4.abrupt("return", undefined);
2037
2053
 
2038
2054
  case 2:
2039
- value = format15(chain$1(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber());
2055
+ value = chain$1(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
2040
2056
  return _context4.abrupt("return", format15(value, calculatingDigits) || undefined);
2041
2057
 
2042
- case 5:
2058
+ case 4:
2043
2059
  case "end":
2044
2060
  return _context4.stop();
2045
2061
  }
@@ -2107,14 +2123,14 @@ function _mergeLineAmountExcludeTax() {
2107
2123
  return _mergeLineAmountExcludeTax.apply(this, arguments);
2108
2124
  }
2109
2125
 
2110
- function mergeQuantity(_x9) {
2126
+ function mergeQuantity(_x9, _x10) {
2111
2127
  return _mergeQuantity.apply(this, arguments);
2112
2128
  }
2113
2129
  /** 填充行明细信息 */
2114
2130
 
2115
2131
 
2116
2132
  function _mergeQuantity() {
2117
- _mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList) {
2133
+ _mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList, calculatingDigits) {
2118
2134
  var sum;
2119
2135
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
2120
2136
  while (1) {
@@ -2124,7 +2140,7 @@ function _mergeQuantity() {
2124
2140
  goodsList.forEach(function (e) {
2125
2141
  sum = sum.add(bignumber(e.quantity || 0));
2126
2142
  });
2127
- return _context7.abrupt("return", sum.done().toNumber() || undefined);
2143
+ return _context7.abrupt("return", format15(sum.done().toNumber() || undefined, calculatingDigits));
2128
2144
 
2129
2145
  case 3:
2130
2146
  case "end":
@@ -2136,7 +2152,7 @@ function _mergeQuantity() {
2136
2152
  return _mergeQuantity.apply(this, arguments);
2137
2153
  }
2138
2154
 
2139
- function fillingInformationGood(_x10, _x11) {
2155
+ function fillingInformationGood(_x11, _x12) {
2140
2156
  return _fillingInformationGood.apply(this, arguments);
2141
2157
  }
2142
2158
  /** 存在税率不一样的明细,不能合并 */
@@ -2167,7 +2183,7 @@ function _fillingInformationGood() {
2167
2183
  return _fillingInformationGood.apply(this, arguments);
2168
2184
  }
2169
2185
 
2170
- function checkTaxTate(_x12) {
2186
+ function checkTaxTate(_x13) {
2171
2187
  return _checkTaxTate.apply(this, arguments);
2172
2188
  }
2173
2189
  /** 校验数据 是否数量和金额是否同号 */
@@ -2211,7 +2227,7 @@ function _checkTaxTate() {
2211
2227
  return _checkTaxTate.apply(this, arguments);
2212
2228
  }
2213
2229
 
2214
- function checkSameNumber(_x13) {
2230
+ function checkSameNumber(_x14) {
2215
2231
  return _checkSameNumber.apply(this, arguments);
2216
2232
  }
2217
2233
  /** 显示错误信息 */
@@ -13656,7 +13672,7 @@ var useColumns = (function (form) {
13656
13672
  style: {
13657
13673
  padding: '0 10px'
13658
13674
  }
13659
- });
13675
+ }, e);
13660
13676
  }
13661
13677
  }
13662
13678
  }, {
package/dist/index.js CHANGED
@@ -1399,7 +1399,7 @@ var format15 = function format15(value) {
1399
1399
  if ("".concat(value) === 'NaN') return '';
1400
1400
  if (typeof value === 'string') value = parseFloat(value);
1401
1401
  var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
1402
- return parseFloat(value.toFixed(fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits));
1402
+ return onScientificNotation(value, fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits);
1403
1403
  };
1404
1404
  /**
1405
1405
  * 金额(含税) = 数量 * 单价(含税)
@@ -1466,6 +1466,22 @@ function countQuantity(amount, price, calculatingDigits) {
1466
1466
  if (!price && price !== 0) return undefined;
1467
1467
  return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(price)).done().toNumber(), calculatingDigits);
1468
1468
  }
1469
+ /** 不用可续计数法 */
1470
+
1471
+ function onScientificNotation(e, fractionDigits) {
1472
+ debugger;
1473
+ var arr = e.toFixed(fractionDigits).split('');
1474
+
1475
+ for (; arr.length > 0;) {
1476
+ if (arr[arr.length - 1] === '0' || arr[arr.length - 1] === '.') {
1477
+ arr.pop();
1478
+ } else {
1479
+ return arr.join('');
1480
+ }
1481
+ }
1482
+
1483
+ return '0';
1484
+ }
1469
1485
 
1470
1486
  var calculator = /*#__PURE__*/Object.freeze({
1471
1487
  __proto__: null,
@@ -1865,7 +1881,7 @@ function _mergeDetails() {
1865
1881
  case 9:
1866
1882
  sum = _context.sent;
1867
1883
  _context.next = 12;
1868
- return mergeQuantity(goodsList);
1884
+ return mergeQuantity(goodsList, state.calculatingDigits);
1869
1885
 
1870
1886
  case 12:
1871
1887
  sum.quantity = _context.sent;
@@ -1927,7 +1943,7 @@ function _mergeDetails() {
1927
1943
  return _merge.apply(this, arguments);
1928
1944
  };
1929
1945
 
1930
- merge = function _merge2(_x14) {
1946
+ merge = function _merge2(_x15) {
1931
1947
  return _merge.apply(this, arguments);
1932
1948
  };
1933
1949
 
@@ -2046,10 +2062,10 @@ function _calculatePriceExcludeTax() {
2046
2062
  return _context4.abrupt("return", undefined);
2047
2063
 
2048
2064
  case 2:
2049
- value = format15(mathjs.chain(mathjs.bignumber(sum.lineAmountExcludeTax)).divide(mathjs.bignumber(sum.quantity)).done().toNumber());
2065
+ value = mathjs.chain(mathjs.bignumber(sum.lineAmountExcludeTax)).divide(mathjs.bignumber(sum.quantity)).done().toNumber();
2050
2066
  return _context4.abrupt("return", format15(value, calculatingDigits) || undefined);
2051
2067
 
2052
- case 5:
2068
+ case 4:
2053
2069
  case "end":
2054
2070
  return _context4.stop();
2055
2071
  }
@@ -2117,14 +2133,14 @@ function _mergeLineAmountExcludeTax() {
2117
2133
  return _mergeLineAmountExcludeTax.apply(this, arguments);
2118
2134
  }
2119
2135
 
2120
- function mergeQuantity(_x9) {
2136
+ function mergeQuantity(_x9, _x10) {
2121
2137
  return _mergeQuantity.apply(this, arguments);
2122
2138
  }
2123
2139
  /** 填充行明细信息 */
2124
2140
 
2125
2141
 
2126
2142
  function _mergeQuantity() {
2127
- _mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList) {
2143
+ _mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList, calculatingDigits) {
2128
2144
  var sum;
2129
2145
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
2130
2146
  while (1) {
@@ -2134,7 +2150,7 @@ function _mergeQuantity() {
2134
2150
  goodsList.forEach(function (e) {
2135
2151
  sum = sum.add(mathjs.bignumber(e.quantity || 0));
2136
2152
  });
2137
- return _context7.abrupt("return", sum.done().toNumber() || undefined);
2153
+ return _context7.abrupt("return", format15(sum.done().toNumber() || undefined, calculatingDigits));
2138
2154
 
2139
2155
  case 3:
2140
2156
  case "end":
@@ -2146,7 +2162,7 @@ function _mergeQuantity() {
2146
2162
  return _mergeQuantity.apply(this, arguments);
2147
2163
  }
2148
2164
 
2149
- function fillingInformationGood(_x10, _x11) {
2165
+ function fillingInformationGood(_x11, _x12) {
2150
2166
  return _fillingInformationGood.apply(this, arguments);
2151
2167
  }
2152
2168
  /** 存在税率不一样的明细,不能合并 */
@@ -2177,7 +2193,7 @@ function _fillingInformationGood() {
2177
2193
  return _fillingInformationGood.apply(this, arguments);
2178
2194
  }
2179
2195
 
2180
- function checkTaxTate(_x12) {
2196
+ function checkTaxTate(_x13) {
2181
2197
  return _checkTaxTate.apply(this, arguments);
2182
2198
  }
2183
2199
  /** 校验数据 是否数量和金额是否同号 */
@@ -2221,7 +2237,7 @@ function _checkTaxTate() {
2221
2237
  return _checkTaxTate.apply(this, arguments);
2222
2238
  }
2223
2239
 
2224
- function checkSameNumber(_x13) {
2240
+ function checkSameNumber(_x14) {
2225
2241
  return _checkSameNumber.apply(this, arguments);
2226
2242
  }
2227
2243
  /** 显示错误信息 */
@@ -13666,7 +13682,7 @@ var useColumns = (function (form) {
13666
13682
  style: {
13667
13683
  padding: '0 10px'
13668
13684
  }
13669
- });
13685
+ }, e);
13670
13686
  }
13671
13687
  }
13672
13688
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.108",
3
+ "version": "3.2.109",
4
4
  "scripts": {
5
5
  "dev": "dumi dev",
6
6
  "start": "dumi dev",
@@ -57,7 +57,7 @@ export default async function mergeDetails(state: InvoiceControllerState, select
57
57
  sum = await fillingInformationGood(goodsList, sum);
58
58
 
59
59
  // 合并数量
60
- sum.quantity = await mergeQuantity(goodsList);
60
+ sum.quantity = await mergeQuantity(goodsList, state.calculatingDigits);
61
61
 
62
62
  // 合并金额(不含税)
63
63
  sum.lineAmountExcludeTax = await mergeLineAmountExcludeTax(goodsList);
@@ -100,8 +100,8 @@ async function calculatePriceIncludeTax(sum: IGood, calculatingDigits?: number)
100
100
  /** 计算单价(不含税) */
101
101
  async function calculatePriceExcludeTax(sum: IGood, calculatingDigits?: number) {
102
102
  if (!sum.quantity) return undefined;
103
- const value = format15(chain(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber());
104
- return format15(value, calculatingDigits) || undefined;;
103
+ const value = chain(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
104
+ return format15(value, calculatingDigits) || undefined;
105
105
  }
106
106
 
107
107
  /** 合并金额(含税) */
@@ -123,12 +123,13 @@ async function mergeLineAmountExcludeTax(goodsList: IGood[]) {
123
123
  }
124
124
 
125
125
  /** 合并数量 */
126
- async function mergeQuantity(goodsList: IGood[]) {
126
+ async function mergeQuantity(goodsList: IGood[], calculatingDigits?: number) {
127
127
  let sum = chain(bignumber(0));
128
128
  goodsList.forEach(e => {
129
129
  sum = sum.add(bignumber(e.quantity || 0))
130
130
  })
131
- return sum.done().toNumber() || undefined;
131
+
132
+ return format15(sum.done().toNumber() || undefined, calculatingDigits) as any;
132
133
  }
133
134
 
134
135
  /** 填充行明细信息 */
@@ -69,6 +69,7 @@ class MyController1 extends Invoice.InvoiceController {
69
69
  this.state.goodsListState.isMergeDiscount = true;
70
70
  this.state.goodsListState.isSalesGifts = true;
71
71
  this.state.goodsListState.drag.isStart = true;
72
+ this.state.calculatingDigits = 15;
72
73
  this.state.goodsListState.columnshide = [];
73
74
  }
74
75
 
@@ -99,6 +100,7 @@ class MyController2 extends Invoice.InvoiceController {
99
100
  this.state.goodsListState.isMergeDiscount = true;
100
101
  this.state.goodsListState.isSalesGifts = true;
101
102
  this.state.goodsListState.drag.isStart = true;
103
+ this.state.calculatingDigits = 15;
102
104
  this.state.goodsListState.columnshide = [];
103
105
  }
104
106
 
@@ -150,7 +152,7 @@ const lines: any[] = [
150
152
  "unit": "套",
151
153
  "quantity": 1.0000000000001,
152
154
  "taxRate": 0.06,
153
- "priceExcludeTax": 2,
155
+ "priceExcludeTax": 0.0000000000001,
154
156
  "priceIncludeTax": 2.12,
155
157
  "amountTax": 0.3,
156
158
  "lineAmountExcludeTax": 5,
@@ -173,13 +175,13 @@ const lines: any[] = [
173
175
  "itemName": "技术服务费",
174
176
  "itemCode": "z",
175
177
  "unit": "",
176
- "quantity": null,
178
+ "quantity": -1,
177
179
  "taxRate": 0.06,
178
180
  "priceExcludeTax": null,
179
181
  "priceIncludeTax": null,
180
182
  "amountTax": -0.06,
181
- "lineAmountExcludeTax": 5,
182
- "lineAmountIncludeTax": 5.3,
183
+ "lineAmountExcludeTax": 2,
184
+ "lineAmountIncludeTax": 2.3,
183
185
  "lineAttribute": LineAttributeType.折扣行,
184
186
  "discountGroup": "1714491422291693568",
185
187
  "favouredPolicyMark": false,
@@ -1,5 +1,5 @@
1
1
 
2
- import { chain, bignumber } from 'mathjs';
2
+ import { chain, bignumber, number } from 'mathjs';
3
3
 
4
4
 
5
5
  /** 格式化 保留2位小数 */
@@ -18,7 +18,7 @@ export const format15 = (value: number | string, defaultFractionDigits: number =
18
18
  if (typeof value === 'string') value = parseFloat(value);
19
19
 
20
20
  const fractionDigits = 15 - `${value || 0}`.indexOf('.');
21
- return parseFloat(value.toFixed(fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits));
21
+ return onScientificNotation(value, fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits) as number | undefined | '';
22
22
  };
23
23
 
24
24
 
@@ -60,7 +60,7 @@ export function countAmountExcludeTax(amountIncludeTax: string | number, taxAmou
60
60
  * @returns 税额
61
61
  */
62
62
  export function countTaxAmount(amountIncludeTax: string | number, deduction: number, taxRate: number): number | undefined {
63
-
63
+
64
64
  if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
65
65
  if (!deduction && deduction !== 0) return undefined;
66
66
  if (!taxRate && taxRate !== 0) return undefined;
@@ -109,4 +109,16 @@ export function countQuantity(amount: string | number, price: string | number, c
109
109
 
110
110
 
111
111
 
112
-
112
+ /** 不用可续计数法 */
113
+ function onScientificNotation(e: number, fractionDigits: number) {
114
+ debugger;
115
+ const arr = e.toFixed(fractionDigits).split('');
116
+ for (; arr.length > 0;) {
117
+ if (arr[arr.length - 1] === '0' || arr[arr.length - 1] === '.') {
118
+ arr.pop();
119
+ } else {
120
+ return arr.join('');
121
+ }
122
+ }
123
+ return '0';
124
+ }
@@ -552,7 +552,7 @@ export default (form: WrappedFormUtils) => {
552
552
  case LineAttributeType.正常:
553
553
  return <span style={{ padding: '0 10px' }}>正常行</span>
554
554
  default:
555
- return <span style={{ padding: '0 10px' }}></span>
555
+ return <span style={{ padding: '0 10px' }}>{e}</span>
556
556
  }
557
557
  }
558
558
  },