kts-component-invoice-operate 3.2.108 → 3.2.110
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.
- package/dist/Invoice/tools/calculate/index.d.ts +1 -1
- package/dist/index.esm.js +30 -12
- package/dist/index.js +30 -12
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/fns/mergeDetails.ts +6 -5
- package/src/Invoice/_test/endowCode/index.tsx +6 -4
- package/src/Invoice/tools/calculate/index.ts +17 -4
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +1 -1
|
@@ -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
|
|
1392
|
+
return onScientificNotation(value, fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits);
|
|
1393
1393
|
};
|
|
1394
1394
|
/**
|
|
1395
1395
|
* 金额(含税) = 数量 * 单价(含税)
|
|
@@ -1456,6 +1456,24 @@ 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
|
+
var arr = e.toFixed(fractionDigits).split('');
|
|
1463
|
+
|
|
1464
|
+
for (; arr.length > 0;) {
|
|
1465
|
+
if (arr[arr.length - 1] === '0') {
|
|
1466
|
+
arr.pop();
|
|
1467
|
+
} else if (arr[arr.length - 1] === '.') {
|
|
1468
|
+
arr.pop();
|
|
1469
|
+
return arr.join('');
|
|
1470
|
+
} else {
|
|
1471
|
+
return arr.join('');
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
return '0';
|
|
1476
|
+
}
|
|
1459
1477
|
|
|
1460
1478
|
var calculator = /*#__PURE__*/Object.freeze({
|
|
1461
1479
|
__proto__: null,
|
|
@@ -1855,7 +1873,7 @@ function _mergeDetails() {
|
|
|
1855
1873
|
case 9:
|
|
1856
1874
|
sum = _context.sent;
|
|
1857
1875
|
_context.next = 12;
|
|
1858
|
-
return mergeQuantity(goodsList);
|
|
1876
|
+
return mergeQuantity(goodsList, state.calculatingDigits);
|
|
1859
1877
|
|
|
1860
1878
|
case 12:
|
|
1861
1879
|
sum.quantity = _context.sent;
|
|
@@ -1917,7 +1935,7 @@ function _mergeDetails() {
|
|
|
1917
1935
|
return _merge.apply(this, arguments);
|
|
1918
1936
|
};
|
|
1919
1937
|
|
|
1920
|
-
merge = function _merge2(
|
|
1938
|
+
merge = function _merge2(_x15) {
|
|
1921
1939
|
return _merge.apply(this, arguments);
|
|
1922
1940
|
};
|
|
1923
1941
|
|
|
@@ -2036,10 +2054,10 @@ function _calculatePriceExcludeTax() {
|
|
|
2036
2054
|
return _context4.abrupt("return", undefined);
|
|
2037
2055
|
|
|
2038
2056
|
case 2:
|
|
2039
|
-
value =
|
|
2057
|
+
value = chain$1(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
|
|
2040
2058
|
return _context4.abrupt("return", format15(value, calculatingDigits) || undefined);
|
|
2041
2059
|
|
|
2042
|
-
case
|
|
2060
|
+
case 4:
|
|
2043
2061
|
case "end":
|
|
2044
2062
|
return _context4.stop();
|
|
2045
2063
|
}
|
|
@@ -2107,14 +2125,14 @@ function _mergeLineAmountExcludeTax() {
|
|
|
2107
2125
|
return _mergeLineAmountExcludeTax.apply(this, arguments);
|
|
2108
2126
|
}
|
|
2109
2127
|
|
|
2110
|
-
function mergeQuantity(_x9) {
|
|
2128
|
+
function mergeQuantity(_x9, _x10) {
|
|
2111
2129
|
return _mergeQuantity.apply(this, arguments);
|
|
2112
2130
|
}
|
|
2113
2131
|
/** 填充行明细信息 */
|
|
2114
2132
|
|
|
2115
2133
|
|
|
2116
2134
|
function _mergeQuantity() {
|
|
2117
|
-
_mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList) {
|
|
2135
|
+
_mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList, calculatingDigits) {
|
|
2118
2136
|
var sum;
|
|
2119
2137
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
2120
2138
|
while (1) {
|
|
@@ -2124,7 +2142,7 @@ function _mergeQuantity() {
|
|
|
2124
2142
|
goodsList.forEach(function (e) {
|
|
2125
2143
|
sum = sum.add(bignumber(e.quantity || 0));
|
|
2126
2144
|
});
|
|
2127
|
-
return _context7.abrupt("return", sum.done().toNumber() || undefined);
|
|
2145
|
+
return _context7.abrupt("return", format15(sum.done().toNumber() || undefined, calculatingDigits));
|
|
2128
2146
|
|
|
2129
2147
|
case 3:
|
|
2130
2148
|
case "end":
|
|
@@ -2136,7 +2154,7 @@ function _mergeQuantity() {
|
|
|
2136
2154
|
return _mergeQuantity.apply(this, arguments);
|
|
2137
2155
|
}
|
|
2138
2156
|
|
|
2139
|
-
function fillingInformationGood(
|
|
2157
|
+
function fillingInformationGood(_x11, _x12) {
|
|
2140
2158
|
return _fillingInformationGood.apply(this, arguments);
|
|
2141
2159
|
}
|
|
2142
2160
|
/** 存在税率不一样的明细,不能合并 */
|
|
@@ -2167,7 +2185,7 @@ function _fillingInformationGood() {
|
|
|
2167
2185
|
return _fillingInformationGood.apply(this, arguments);
|
|
2168
2186
|
}
|
|
2169
2187
|
|
|
2170
|
-
function checkTaxTate(
|
|
2188
|
+
function checkTaxTate(_x13) {
|
|
2171
2189
|
return _checkTaxTate.apply(this, arguments);
|
|
2172
2190
|
}
|
|
2173
2191
|
/** 校验数据 是否数量和金额是否同号 */
|
|
@@ -2211,7 +2229,7 @@ function _checkTaxTate() {
|
|
|
2211
2229
|
return _checkTaxTate.apply(this, arguments);
|
|
2212
2230
|
}
|
|
2213
2231
|
|
|
2214
|
-
function checkSameNumber(
|
|
2232
|
+
function checkSameNumber(_x14) {
|
|
2215
2233
|
return _checkSameNumber.apply(this, arguments);
|
|
2216
2234
|
}
|
|
2217
2235
|
/** 显示错误信息 */
|
|
@@ -13656,7 +13674,7 @@ var useColumns = (function (form) {
|
|
|
13656
13674
|
style: {
|
|
13657
13675
|
padding: '0 10px'
|
|
13658
13676
|
}
|
|
13659
|
-
});
|
|
13677
|
+
}, e);
|
|
13660
13678
|
}
|
|
13661
13679
|
}
|
|
13662
13680
|
}, {
|
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
|
|
1402
|
+
return onScientificNotation(value, fractionDigits > defaultFractionDigits ? defaultFractionDigits : fractionDigits);
|
|
1403
1403
|
};
|
|
1404
1404
|
/**
|
|
1405
1405
|
* 金额(含税) = 数量 * 单价(含税)
|
|
@@ -1466,6 +1466,24 @@ 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
|
+
var arr = e.toFixed(fractionDigits).split('');
|
|
1473
|
+
|
|
1474
|
+
for (; arr.length > 0;) {
|
|
1475
|
+
if (arr[arr.length - 1] === '0') {
|
|
1476
|
+
arr.pop();
|
|
1477
|
+
} else if (arr[arr.length - 1] === '.') {
|
|
1478
|
+
arr.pop();
|
|
1479
|
+
return arr.join('');
|
|
1480
|
+
} else {
|
|
1481
|
+
return arr.join('');
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
return '0';
|
|
1486
|
+
}
|
|
1469
1487
|
|
|
1470
1488
|
var calculator = /*#__PURE__*/Object.freeze({
|
|
1471
1489
|
__proto__: null,
|
|
@@ -1865,7 +1883,7 @@ function _mergeDetails() {
|
|
|
1865
1883
|
case 9:
|
|
1866
1884
|
sum = _context.sent;
|
|
1867
1885
|
_context.next = 12;
|
|
1868
|
-
return mergeQuantity(goodsList);
|
|
1886
|
+
return mergeQuantity(goodsList, state.calculatingDigits);
|
|
1869
1887
|
|
|
1870
1888
|
case 12:
|
|
1871
1889
|
sum.quantity = _context.sent;
|
|
@@ -1927,7 +1945,7 @@ function _mergeDetails() {
|
|
|
1927
1945
|
return _merge.apply(this, arguments);
|
|
1928
1946
|
};
|
|
1929
1947
|
|
|
1930
|
-
merge = function _merge2(
|
|
1948
|
+
merge = function _merge2(_x15) {
|
|
1931
1949
|
return _merge.apply(this, arguments);
|
|
1932
1950
|
};
|
|
1933
1951
|
|
|
@@ -2046,10 +2064,10 @@ function _calculatePriceExcludeTax() {
|
|
|
2046
2064
|
return _context4.abrupt("return", undefined);
|
|
2047
2065
|
|
|
2048
2066
|
case 2:
|
|
2049
|
-
value =
|
|
2067
|
+
value = mathjs.chain(mathjs.bignumber(sum.lineAmountExcludeTax)).divide(mathjs.bignumber(sum.quantity)).done().toNumber();
|
|
2050
2068
|
return _context4.abrupt("return", format15(value, calculatingDigits) || undefined);
|
|
2051
2069
|
|
|
2052
|
-
case
|
|
2070
|
+
case 4:
|
|
2053
2071
|
case "end":
|
|
2054
2072
|
return _context4.stop();
|
|
2055
2073
|
}
|
|
@@ -2117,14 +2135,14 @@ function _mergeLineAmountExcludeTax() {
|
|
|
2117
2135
|
return _mergeLineAmountExcludeTax.apply(this, arguments);
|
|
2118
2136
|
}
|
|
2119
2137
|
|
|
2120
|
-
function mergeQuantity(_x9) {
|
|
2138
|
+
function mergeQuantity(_x9, _x10) {
|
|
2121
2139
|
return _mergeQuantity.apply(this, arguments);
|
|
2122
2140
|
}
|
|
2123
2141
|
/** 填充行明细信息 */
|
|
2124
2142
|
|
|
2125
2143
|
|
|
2126
2144
|
function _mergeQuantity() {
|
|
2127
|
-
_mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList) {
|
|
2145
|
+
_mergeQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(goodsList, calculatingDigits) {
|
|
2128
2146
|
var sum;
|
|
2129
2147
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
2130
2148
|
while (1) {
|
|
@@ -2134,7 +2152,7 @@ function _mergeQuantity() {
|
|
|
2134
2152
|
goodsList.forEach(function (e) {
|
|
2135
2153
|
sum = sum.add(mathjs.bignumber(e.quantity || 0));
|
|
2136
2154
|
});
|
|
2137
|
-
return _context7.abrupt("return", sum.done().toNumber() || undefined);
|
|
2155
|
+
return _context7.abrupt("return", format15(sum.done().toNumber() || undefined, calculatingDigits));
|
|
2138
2156
|
|
|
2139
2157
|
case 3:
|
|
2140
2158
|
case "end":
|
|
@@ -2146,7 +2164,7 @@ function _mergeQuantity() {
|
|
|
2146
2164
|
return _mergeQuantity.apply(this, arguments);
|
|
2147
2165
|
}
|
|
2148
2166
|
|
|
2149
|
-
function fillingInformationGood(
|
|
2167
|
+
function fillingInformationGood(_x11, _x12) {
|
|
2150
2168
|
return _fillingInformationGood.apply(this, arguments);
|
|
2151
2169
|
}
|
|
2152
2170
|
/** 存在税率不一样的明细,不能合并 */
|
|
@@ -2177,7 +2195,7 @@ function _fillingInformationGood() {
|
|
|
2177
2195
|
return _fillingInformationGood.apply(this, arguments);
|
|
2178
2196
|
}
|
|
2179
2197
|
|
|
2180
|
-
function checkTaxTate(
|
|
2198
|
+
function checkTaxTate(_x13) {
|
|
2181
2199
|
return _checkTaxTate.apply(this, arguments);
|
|
2182
2200
|
}
|
|
2183
2201
|
/** 校验数据 是否数量和金额是否同号 */
|
|
@@ -2221,7 +2239,7 @@ function _checkTaxTate() {
|
|
|
2221
2239
|
return _checkTaxTate.apply(this, arguments);
|
|
2222
2240
|
}
|
|
2223
2241
|
|
|
2224
|
-
function checkSameNumber(
|
|
2242
|
+
function checkSameNumber(_x14) {
|
|
2225
2243
|
return _checkSameNumber.apply(this, arguments);
|
|
2226
2244
|
}
|
|
2227
2245
|
/** 显示错误信息 */
|
|
@@ -13666,7 +13684,7 @@ var useColumns = (function (form) {
|
|
|
13666
13684
|
style: {
|
|
13667
13685
|
padding: '0 10px'
|
|
13668
13686
|
}
|
|
13669
|
-
});
|
|
13687
|
+
}, e);
|
|
13670
13688
|
}
|
|
13671
13689
|
}
|
|
13672
13690
|
}, {
|
package/package.json
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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":
|
|
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":
|
|
178
|
+
"quantity": -1,
|
|
177
179
|
"taxRate": 0.06,
|
|
178
180
|
"priceExcludeTax": null,
|
|
179
181
|
"priceIncludeTax": null,
|
|
180
182
|
"amountTax": -0.06,
|
|
181
|
-
"lineAmountExcludeTax":
|
|
182
|
-
"lineAmountIncludeTax":
|
|
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
|
|
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,17 @@ 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
|
+
const arr = e.toFixed(fractionDigits).split('');
|
|
115
|
+
for (; arr.length > 0;) {
|
|
116
|
+
if (arr[arr.length - 1] === '0') {
|
|
117
|
+
arr.pop();
|
|
118
|
+
} else if (arr[arr.length - 1] === '.') {
|
|
119
|
+
arr.pop(); return arr.join('');
|
|
120
|
+
} else {
|
|
121
|
+
return arr.join('');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return '0';
|
|
125
|
+
}
|
|
@@ -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' }}
|
|
555
|
+
return <span style={{ padding: '0 10px' }}>{e}</span>
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
},
|