kts-component-invoice-operate 3.2.103 → 3.2.105
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/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.d.ts +1 -0
- package/dist/index.esm.js +281 -158
- package/dist/index.js +281 -158
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/fns/mergeDetails.ts +76 -43
- package/src/Invoice/_test/endowCode/index.tsx +118 -118
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +2 -1
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +25 -1
package/package.json
CHANGED
|
@@ -6,54 +6,87 @@ import { IGood, InvoiceControllerState, LineAttributeType } from '..';
|
|
|
6
6
|
import { format15 } from '../../tools/calculate';
|
|
7
7
|
|
|
8
8
|
export default async function mergeDetails(state: InvoiceControllerState, selectedGoodIndex?: string[]) {
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
if (state.goodsListState.editGood || !selectedGoodIndex || selectedGoodIndex.length < 2) return;
|
|
11
11
|
|
|
12
|
-
// const goodsList = state.goodsListState.selectedGoodIndex.map(e => state.goodsListState.goodsMap.get(e)).filter(e => !!e) as IGood[];
|
|
13
|
-
// const goodsList = state.goodsListState.goodsList.filter(e => state.goodsListState.selectedGoodIndex.indexOf(e.$index) >= 0)
|
|
14
12
|
const goodsList = state.goodsListState.goodsList.filter(e => selectedGoodIndex.indexOf(e.$index) >= 0);
|
|
15
13
|
if (goodsList.length < 2) return;
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// 计算税额
|
|
43
|
-
sum.taxAmount = chain(bignumber(sum.lineAmountIncludeTax)).subtract(bignumber(sum.lineAmountExcludeTax)).done().toNumber()
|
|
44
|
-
|
|
45
|
-
// 校验数据 是否数量和金额是否同号
|
|
46
|
-
await checkSameNumber(sum);
|
|
15
|
+
grouping(goodsList).forEach(merge);
|
|
16
|
+
|
|
17
|
+
/** 分组 */
|
|
18
|
+
function grouping(goodsList: IGood[]): IGood[][] {
|
|
19
|
+
const grouped: any = {};
|
|
20
|
+
goodsList.forEach(good => {
|
|
21
|
+
const key = (() => {
|
|
22
|
+
switch (good.lineAttribute) {
|
|
23
|
+
case LineAttributeType.折让行:
|
|
24
|
+
return LineAttributeType.折让行
|
|
25
|
+
case LineAttributeType.赠品行:
|
|
26
|
+
return LineAttributeType.赠品行
|
|
27
|
+
default:
|
|
28
|
+
return LineAttributeType.正常
|
|
29
|
+
}
|
|
30
|
+
})()
|
|
31
|
+
|
|
32
|
+
if (!grouped[key]) {
|
|
33
|
+
grouped[key] = [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
grouped[key].push({ ...good, lineAttribute: key });
|
|
37
|
+
})
|
|
38
|
+
return Object.values(grouped);
|
|
39
|
+
}
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
/** 合并 */
|
|
42
|
+
async function merge(goodsList: IGood[]) {
|
|
43
|
+
if (goodsList.length < 2) return;
|
|
44
|
+
|
|
45
|
+
const selectedGoodIndex = goodsList.map(e => e.$index);
|
|
46
|
+
try {
|
|
47
|
+
// 创建合并后的商品对象
|
|
48
|
+
let sum: IGood = {
|
|
49
|
+
$index: idGenerator(),
|
|
50
|
+
lineAttribute: goodsList[0].lineAttribute,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 存在税率不一样的明细,不能合并
|
|
54
|
+
await checkTaxTate(goodsList);
|
|
55
|
+
|
|
56
|
+
// 填充行明细信息
|
|
57
|
+
sum = await fillingInformationGood(goodsList, sum);
|
|
58
|
+
|
|
59
|
+
// 合并数量
|
|
60
|
+
sum.quantity = await mergeQuantity(goodsList);
|
|
61
|
+
|
|
62
|
+
// 合并金额(不含税)
|
|
63
|
+
sum.lineAmountExcludeTax = await mergeLineAmountExcludeTax(goodsList);
|
|
64
|
+
|
|
65
|
+
// 合并金额(含税)
|
|
66
|
+
sum.lineAmountIncludeTax = await mergeLineAmountIncludeTax(goodsList);
|
|
67
|
+
|
|
68
|
+
// 计算单价(不含税)
|
|
69
|
+
sum.priceExcludeTax = await calculatePriceExcludeTax(sum, state.calculatingDigits);
|
|
70
|
+
|
|
71
|
+
// 计算单价(含税)
|
|
72
|
+
sum.priceIncludeTax = await calculatePriceIncludeTax(sum, state.calculatingDigits);
|
|
73
|
+
|
|
74
|
+
// 计算税额
|
|
75
|
+
sum.taxAmount = chain(bignumber(sum.lineAmountIncludeTax)).subtract(bignumber(sum.lineAmountExcludeTax)).done().toNumber()
|
|
76
|
+
|
|
77
|
+
// 校验数据 是否数量和金额是否同号
|
|
78
|
+
await checkSameNumber(sum);
|
|
79
|
+
|
|
80
|
+
const p = state.goodsListState.goodsList.indexOf(goodsList[0]);
|
|
81
|
+
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(e => selectedGoodIndex.indexOf(e.$index) < 0);
|
|
82
|
+
state.goodsListState.goodsList.splice(p, 0, sum);
|
|
83
|
+
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(e => e.lineAmountExcludeTax !== 0);
|
|
84
|
+
state.goodsListState.goodsMap = new Map();
|
|
85
|
+
state.goodsListState.goodsList.forEach(e => { state.goodsListState.goodsMap.set(e.$index, e) });
|
|
86
|
+
state.goodsListState.selectedGoodIndex = [];
|
|
87
|
+
} catch (error: any) {
|
|
88
|
+
showError(error)
|
|
89
|
+
}
|
|
57
90
|
}
|
|
58
91
|
}
|
|
59
92
|
|
|
@@ -104,7 +137,7 @@ async function fillingInformationGood(goodsList: IGood[], sum: IGood) {
|
|
|
104
137
|
|
|
105
138
|
const goods = goodsList[findMaxIndex(goodsList.map(e => e.lineAmountIncludeTax || 0))]
|
|
106
139
|
|
|
107
|
-
return { ...goods, lineAttribute:
|
|
140
|
+
return { ...goods, lineAttribute: sum.lineAttribute };
|
|
108
141
|
}
|
|
109
142
|
|
|
110
143
|
/** 存在税率不一样的明细,不能合并 */
|
|
@@ -140,129 +140,129 @@ for (let i = 0; i <= 10000; i++) {
|
|
|
140
140
|
|
|
141
141
|
const lines: any[] = [
|
|
142
142
|
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
143
|
+
"serialNumber": "1714491422279110656",
|
|
144
|
+
"lineNumber": 1,
|
|
145
|
+
"taxCode": "3070401000000000000",
|
|
146
|
+
"taxName": "信息技术服务",
|
|
147
|
+
"specification": null,
|
|
148
|
+
"itemName": "技术服务费",
|
|
149
|
+
"itemCode": "z",
|
|
150
|
+
"unit": "套",
|
|
151
|
+
"quantity": 1.0000000000001,
|
|
152
|
+
"taxRate": 0.06,
|
|
153
|
+
"priceExcludeTax": 2,
|
|
154
|
+
"priceIncludeTax": 2.12,
|
|
155
|
+
"amountTax": 0.3,
|
|
156
|
+
"lineAmountExcludeTax": 5,
|
|
157
|
+
"lineAmountIncludeTax": 5.3,
|
|
158
|
+
"lineAttribute": LineAttributeType.被折扣行,
|
|
159
|
+
"discountGroup": "1714491422291693568",
|
|
160
|
+
"favouredPolicyMark": false,
|
|
161
|
+
"favouredPolicyName": null,
|
|
162
|
+
"zeroTaxRateFlag": null,
|
|
163
|
+
"referenceLines": null,
|
|
164
|
+
"version": 0,
|
|
165
|
+
"taxAmount": 1
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
168
|
+
"serialNumber": "1714491422279110656",
|
|
169
|
+
"lineNumber": 2,
|
|
170
|
+
"taxCode": "3070401000000000000",
|
|
171
|
+
"taxName": "信息技术服务",
|
|
172
|
+
"specification": "",
|
|
173
|
+
"itemName": "技术服务费",
|
|
174
|
+
"itemCode": "z",
|
|
175
|
+
"unit": "",
|
|
176
|
+
"quantity": null,
|
|
177
|
+
"taxRate": 0.06,
|
|
178
|
+
"priceExcludeTax": null,
|
|
179
|
+
"priceIncludeTax": null,
|
|
180
|
+
"amountTax": -0.06,
|
|
181
|
+
"lineAmountExcludeTax": 5,
|
|
182
|
+
"lineAmountIncludeTax": 5.3,
|
|
183
|
+
"lineAttribute": LineAttributeType.折扣行,
|
|
184
|
+
"discountGroup": "1714491422291693568",
|
|
185
|
+
"favouredPolicyMark": false,
|
|
186
|
+
"favouredPolicyName": null,
|
|
187
|
+
"zeroTaxRateFlag": null,
|
|
188
|
+
"referenceLines": null,
|
|
189
|
+
"version": 0,
|
|
190
|
+
"taxAmount": 1
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
193
|
+
"serialNumber": "1714491422279110656",
|
|
194
|
+
"lineNumber": 3,
|
|
195
|
+
"taxCode": "3070401000000000000",
|
|
196
|
+
"taxName": "信息技术服务",
|
|
197
|
+
"specification": null,
|
|
198
|
+
"itemName": "技术服务费",
|
|
199
|
+
"itemCode": "z",
|
|
200
|
+
"unit": "套",
|
|
201
|
+
"quantity": 1,
|
|
202
|
+
"taxRate": 0.06,
|
|
203
|
+
"priceExcludeTax": 2,
|
|
204
|
+
"priceIncludeTax": 2.12,
|
|
205
|
+
"amountTax": 0.12,
|
|
206
|
+
"lineAmountExcludeTax": 5,
|
|
207
|
+
"lineAmountIncludeTax": 5.3,
|
|
208
|
+
"lineAttribute": LineAttributeType.正常,
|
|
209
|
+
"discountGroup": null,
|
|
210
|
+
"favouredPolicyMark": false,
|
|
211
|
+
"favouredPolicyName": null,
|
|
212
|
+
"zeroTaxRateFlag": null,
|
|
213
|
+
"referenceLines": null,
|
|
214
|
+
"version": 0,
|
|
215
|
+
"taxAmount": 1
|
|
216
216
|
},
|
|
217
217
|
{
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
218
|
+
"serialNumber": "1714491422279110656",
|
|
219
|
+
"lineNumber": 3,
|
|
220
|
+
"taxCode": "3070401000000000000",
|
|
221
|
+
"taxName": "信息技术服务",
|
|
222
|
+
"specification": null,
|
|
223
|
+
"itemName": "技术服务费",
|
|
224
|
+
"itemCode": "z",
|
|
225
|
+
"unit": "套",
|
|
226
|
+
"quantity": 1,
|
|
227
|
+
"taxRate": 0.06,
|
|
228
|
+
"priceExcludeTax": 2,
|
|
229
|
+
"priceIncludeTax": 2.12,
|
|
230
|
+
"amountTax": 0.12,
|
|
231
|
+
"lineAmountExcludeTax": 5,
|
|
232
|
+
"lineAmountIncludeTax": 5.3,
|
|
233
|
+
"lineAttribute": LineAttributeType.折让行,
|
|
234
|
+
"discountGroup": null,
|
|
235
|
+
"favouredPolicyMark": false,
|
|
236
|
+
"favouredPolicyName": null,
|
|
237
|
+
"zeroTaxRateFlag": null,
|
|
238
|
+
"referenceLines": null,
|
|
239
|
+
"version": 0,
|
|
240
|
+
"taxAmount": 1
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
243
|
+
"serialNumber": "1714491422279110656",
|
|
244
|
+
"lineNumber": 3,
|
|
245
|
+
"taxCode": "3070401000000000000",
|
|
246
|
+
"taxName": "信息技术服务",
|
|
247
|
+
"specification": null,
|
|
248
|
+
"itemName": "技术服务费",
|
|
249
|
+
"itemCode": "z",
|
|
250
|
+
"unit": "套",
|
|
251
|
+
"quantity": 1,
|
|
252
|
+
"taxRate": 0.06,
|
|
253
|
+
"priceExcludeTax": 2,
|
|
254
|
+
"priceIncludeTax": 2.12,
|
|
255
|
+
"amountTax": 0.12,
|
|
256
|
+
"lineAmountExcludeTax": 5,
|
|
257
|
+
"lineAmountIncludeTax": 5.3,
|
|
258
|
+
"lineAttribute": LineAttributeType.折让行,
|
|
259
|
+
"discountGroup": null,
|
|
260
|
+
"favouredPolicyMark": false,
|
|
261
|
+
"favouredPolicyName": null,
|
|
262
|
+
"zeroTaxRateFlag": null,
|
|
263
|
+
"referenceLines": null,
|
|
264
|
+
"version": 0,
|
|
265
|
+
"taxAmount": 1
|
|
266
266
|
},
|
|
267
267
|
{
|
|
268
268
|
"serialNumber": "1714491422279110656",
|
|
@@ -271,7 +271,7 @@ const lines: any[] = [
|
|
|
271
271
|
"taxName": "信息技术服务",
|
|
272
272
|
"specification": null,
|
|
273
273
|
"itemName": "技术服务费",
|
|
274
|
-
"itemCode":
|
|
274
|
+
"itemCode": "z",
|
|
275
275
|
"unit": "套",
|
|
276
276
|
"quantity": 1,
|
|
277
277
|
"taxRate": 0.06,
|
|
@@ -288,8 +288,8 @@ const lines: any[] = [
|
|
|
288
288
|
"referenceLines": null,
|
|
289
289
|
"version": 0,
|
|
290
290
|
"shorthand": "布料",
|
|
291
|
-
taxAmount:1
|
|
292
|
-
}
|
|
291
|
+
"taxAmount": 1
|
|
292
|
+
}
|
|
293
293
|
]
|
|
294
294
|
|
|
295
295
|
const moke = [
|
|
@@ -120,6 +120,7 @@ export default (form: WrappedFormUtils) => {
|
|
|
120
120
|
]
|
|
121
121
|
})(
|
|
122
122
|
<ItemNameInput
|
|
123
|
+
editGood={editGood}
|
|
123
124
|
shorthand={editGood.shorthand}
|
|
124
125
|
suffix={
|
|
125
126
|
<Tooltip title="点击从商品管理中添加商品信息">
|
|
@@ -646,4 +647,4 @@ function ucoding(v: string): string {
|
|
|
646
647
|
/** 解码 */
|
|
647
648
|
function dcoding(v: string): string {
|
|
648
649
|
return v.split('U').map(e => e ? String.fromCharCode(parseInt(e.replace('E', ''))) : '').join('');
|
|
649
|
-
}
|
|
650
|
+
}
|
|
@@ -8,6 +8,7 @@ export default function ItemNameInput(props: {
|
|
|
8
8
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void,
|
|
9
9
|
suffix?: React.ReactNode,
|
|
10
10
|
value?: string,
|
|
11
|
+
editGood?: any,
|
|
11
12
|
shorthand?: string
|
|
12
13
|
}) {
|
|
13
14
|
|
|
@@ -17,11 +18,34 @@ export default function ItemNameInput(props: {
|
|
|
17
18
|
|
|
18
19
|
const [options, setOptions] = React.useState<IGood[]>([])
|
|
19
20
|
|
|
21
|
+
const [selectLine, setSelectLine] = React.useState<any>(null);
|
|
22
|
+
|
|
20
23
|
const onChange = React.useCallback((e: ChangeEvent<HTMLInputElement>) => {
|
|
21
24
|
const event = { ...e };
|
|
22
25
|
props.onChange && props.onChange(event);
|
|
23
26
|
}, [])
|
|
24
27
|
|
|
28
|
+
const onBlur = React.useCallback(async (searchText: any) => {
|
|
29
|
+
try {
|
|
30
|
+
if (autoComplete.onItemNameBlur) {
|
|
31
|
+
if (!selectLine?.shorthand) {
|
|
32
|
+
const taxCategoryData: any = await autoComplete.onItemNameBlur(searchText);
|
|
33
|
+
if (taxCategoryData && taxCategoryData[0]) {
|
|
34
|
+
const params = {
|
|
35
|
+
...props.editGood,
|
|
36
|
+
taxClassificationCode: taxCategoryData[0].taxCategoryCode,
|
|
37
|
+
shorthand: taxCategoryData[0].shorthand
|
|
38
|
+
}
|
|
39
|
+
controller.importGoodsDrawer(params);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
setSelectLine(null);
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}, [autoComplete.onItemNameBlur, selectLine, props.editGood])
|
|
48
|
+
|
|
25
49
|
const onChangeAutoComplete = React.useCallback(itemName => {
|
|
26
50
|
const record = options.filter(e => e.itemName === itemName)[0] as any;
|
|
27
51
|
if (!record) return;
|
|
@@ -47,7 +71,7 @@ export default function ItemNameInput(props: {
|
|
|
47
71
|
<div className='kts-invoice-operate-goods-list-itemName-input'>
|
|
48
72
|
{props.shorthand && <span style={{ alignSelf: 'center', fontSize: 12 }} >*{props.shorthand}*</span>}
|
|
49
73
|
<AutoComplete onSearch={onSearch} value={props.value} options={options.map(e => ({ value: e.itemName }))} onSelect={onChangeAutoComplete} >
|
|
50
|
-
<Input style={{ height: '100%' }} onChange={onChange} suffix={props.suffix} />
|
|
74
|
+
<Input style={{ height: '100%' }} onChange={onChange} suffix={props.suffix} onBlur={onBlur} />
|
|
51
75
|
</AutoComplete>
|
|
52
76
|
</div>
|
|
53
77
|
)
|