kts-component-invoice-operate 3.2.19 → 3.2.21

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/index.esm.js CHANGED
@@ -10216,12 +10216,100 @@ function ItemNameInput(props) {
10216
10216
  };
10217
10217
  }(), [autoComplete.onItemNameSearch]);
10218
10218
  var onChangeAutoComplete = React.useCallback(function (itemName) {
10219
- var _controller$state$goo;
10220
-
10221
- var good = options.filter(function (e) {
10219
+ // const good = options.filter(e=>e.itemName === itemName)[0];
10220
+ // good && controller.state.goodsListState.form?.setFieldsValue(removeNullUndefined(good));
10221
+ var record = options.filter(function (e) {
10222
10222
  return e.itemName === itemName;
10223
- });
10224
- (_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(good);
10223
+ })[0];
10224
+ debugger;
10225
+ if (!record) return;
10226
+ controller.run( /*#__PURE__*/function () {
10227
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
10228
+ var between, editGood;
10229
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
10230
+ while (1) {
10231
+ switch (_context2.prev = _context2.next) {
10232
+ case 0:
10233
+ Object.keys(record).filter(function (e) {
10234
+ return !record[e] && record[e] !== 0;
10235
+ }).forEach(function (e) {
10236
+ delete record[e];
10237
+ }); // 没用 被编辑的货物 和 form 就退出
10238
+
10239
+ if (!(!s.goodsListState.editGood || !s.goodsListState.form)) {
10240
+ _context2.next = 3;
10241
+ break;
10242
+ }
10243
+
10244
+ return _context2.abrupt("return");
10245
+
10246
+ case 3:
10247
+ // 导入时清空之前输入的值,使用导入的单价和税率(参考税局系统)
10248
+ record.quantity = undefined;
10249
+ record.lineAmountExcludeTax = undefined;
10250
+ record.lineAmountIncludeTax = undefined; // 中间数据
10251
+
10252
+ between = _objectSpread2({}, record);
10253
+ between.itemName = record.itemName;
10254
+ between.itemNameOther = record.itemName; // 设置编辑货物
10255
+
10256
+ editGood = s.goodsListState.editGood = _objectSpread2(_objectSpread2({}, s.goodsListState.editGood), between);
10257
+
10258
+ if (editGood.taxRate) {
10259
+ editGood.taxRate = dutyFree(controller, editGood.taxRate, s.goodsListState.form, editGood);
10260
+ }
10261
+
10262
+ if ("".concat(editGood.priceIncludeTax) === '0') {
10263
+ editGood.priceIncludeTax = undefined;
10264
+ editGood.priceExcludeTax = undefined;
10265
+ } else {
10266
+ editGood.priceExcludeTax = getPriceExcludeTax(editGood, record, s.calculatingDigits);
10267
+ }
10268
+
10269
+ if (editGood.quantity && editGood.priceIncludeTax) {
10270
+ editGood.lineAmountIncludeTax = countAmountIncludeTax(editGood.quantity, editGood.priceIncludeTax, s.calculatingDigits);
10271
+ } // 导入FORM里
10272
+
10273
+
10274
+ if (s.goodsListState.isMyShow) {
10275
+ s.goodsListState.form.setFieldsValue(_objectSpread2(_objectSpread2({}, editGood), {}, {
10276
+ itemName: editGood.itemNameSelf,
10277
+ itemModelName: editGood.itemModelNameSelf
10278
+ }));
10279
+ } else {
10280
+ s.goodsListState.form.setFieldsValue(_objectSpread2({}, editGood));
10281
+ }
10282
+
10283
+ s.goodsListState.importGoods.isVisibleDrawer = false;
10284
+
10285
+ if (!s.goodsListState.isTaxIncluded) {
10286
+ _context2.next = 20;
10287
+ break;
10288
+ }
10289
+
10290
+ _context2.next = 18;
10291
+ return updateUnitPriceExcludingTax(controller, s.goodsListState.form, record);
10292
+
10293
+ case 18:
10294
+ _context2.next = 22;
10295
+ break;
10296
+
10297
+ case 20:
10298
+ _context2.next = 22;
10299
+ return updateUnitPriceTax(controller, s.goodsListState.form, record);
10300
+
10301
+ case 22:
10302
+ case "end":
10303
+ return _context2.stop();
10304
+ }
10305
+ }
10306
+ }, _callee2);
10307
+ }));
10308
+
10309
+ return function (_x2) {
10310
+ return _ref2.apply(this, arguments);
10311
+ };
10312
+ }());
10225
10313
  }, [options, controller]);
10226
10314
  return React.createElement("div", {
10227
10315
  className: 'kts-invoice-operate-goods-list-itemName-input'
@@ -10246,7 +10334,23 @@ function ItemNameInput(props) {
10246
10334
  value: props.value,
10247
10335
  onChange: onChange
10248
10336
  })));
10249
- }
10337
+ } // function removeNullUndefined(obj: Record<string, any>): Record<string, any> {
10338
+ // const filteredObj: Record<string, any> = {};
10339
+ // for (const key in obj) {
10340
+ // if (obj[key] !== null && obj[key] !== undefined) {
10341
+ // filteredObj[key] = obj[key];
10342
+ // }
10343
+ // }
10344
+ // return filteredObj;
10345
+ // }
10346
+
10347
+ /** 货物单价,不含税 */
10348
+
10349
+ var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
10350
+ if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
10351
+
10352
+ return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")), calculatingDigits);
10353
+ };
10250
10354
 
10251
10355
  /** 拆分全称加简称 */
10252
10356
  var getSN = function getSN(value) {
@@ -19638,7 +19742,7 @@ var DrawerBody$2 = function DrawerBody() {
19638
19742
  editGood.priceIncludeTax = undefined;
19639
19743
  editGood.priceExcludeTax = undefined;
19640
19744
  } else {
19641
- editGood.priceExcludeTax = getPriceExcludeTax(editGood, record, s.calculatingDigits);
19745
+ editGood.priceExcludeTax = getPriceExcludeTax$1(editGood, record, s.calculatingDigits);
19642
19746
  }
19643
19747
 
19644
19748
  if (editGood.quantity && editGood.priceIncludeTax) {
@@ -19700,7 +19804,7 @@ var DrawerBody$2 = function DrawerBody() {
19700
19804
  /** 货物单价,不含税 */
19701
19805
 
19702
19806
 
19703
- var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
19807
+ var getPriceExcludeTax$1 = function getPriceExcludeTax(s, record, calculatingDigits) {
19704
19808
  if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
19705
19809
 
19706
19810
  return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")), calculatingDigits);
package/dist/index.js CHANGED
@@ -10226,12 +10226,100 @@ function ItemNameInput(props) {
10226
10226
  };
10227
10227
  }(), [autoComplete.onItemNameSearch]);
10228
10228
  var onChangeAutoComplete = React__default['default'].useCallback(function (itemName) {
10229
- var _controller$state$goo;
10230
-
10231
- var good = options.filter(function (e) {
10229
+ // const good = options.filter(e=>e.itemName === itemName)[0];
10230
+ // good && controller.state.goodsListState.form?.setFieldsValue(removeNullUndefined(good));
10231
+ var record = options.filter(function (e) {
10232
10232
  return e.itemName === itemName;
10233
- });
10234
- (_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(good);
10233
+ })[0];
10234
+ debugger;
10235
+ if (!record) return;
10236
+ controller.run( /*#__PURE__*/function () {
10237
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
10238
+ var between, editGood;
10239
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
10240
+ while (1) {
10241
+ switch (_context2.prev = _context2.next) {
10242
+ case 0:
10243
+ Object.keys(record).filter(function (e) {
10244
+ return !record[e] && record[e] !== 0;
10245
+ }).forEach(function (e) {
10246
+ delete record[e];
10247
+ }); // 没用 被编辑的货物 和 form 就退出
10248
+
10249
+ if (!(!s.goodsListState.editGood || !s.goodsListState.form)) {
10250
+ _context2.next = 3;
10251
+ break;
10252
+ }
10253
+
10254
+ return _context2.abrupt("return");
10255
+
10256
+ case 3:
10257
+ // 导入时清空之前输入的值,使用导入的单价和税率(参考税局系统)
10258
+ record.quantity = undefined;
10259
+ record.lineAmountExcludeTax = undefined;
10260
+ record.lineAmountIncludeTax = undefined; // 中间数据
10261
+
10262
+ between = _objectSpread2({}, record);
10263
+ between.itemName = record.itemName;
10264
+ between.itemNameOther = record.itemName; // 设置编辑货物
10265
+
10266
+ editGood = s.goodsListState.editGood = _objectSpread2(_objectSpread2({}, s.goodsListState.editGood), between);
10267
+
10268
+ if (editGood.taxRate) {
10269
+ editGood.taxRate = dutyFree(controller, editGood.taxRate, s.goodsListState.form, editGood);
10270
+ }
10271
+
10272
+ if ("".concat(editGood.priceIncludeTax) === '0') {
10273
+ editGood.priceIncludeTax = undefined;
10274
+ editGood.priceExcludeTax = undefined;
10275
+ } else {
10276
+ editGood.priceExcludeTax = getPriceExcludeTax(editGood, record, s.calculatingDigits);
10277
+ }
10278
+
10279
+ if (editGood.quantity && editGood.priceIncludeTax) {
10280
+ editGood.lineAmountIncludeTax = countAmountIncludeTax(editGood.quantity, editGood.priceIncludeTax, s.calculatingDigits);
10281
+ } // 导入FORM里
10282
+
10283
+
10284
+ if (s.goodsListState.isMyShow) {
10285
+ s.goodsListState.form.setFieldsValue(_objectSpread2(_objectSpread2({}, editGood), {}, {
10286
+ itemName: editGood.itemNameSelf,
10287
+ itemModelName: editGood.itemModelNameSelf
10288
+ }));
10289
+ } else {
10290
+ s.goodsListState.form.setFieldsValue(_objectSpread2({}, editGood));
10291
+ }
10292
+
10293
+ s.goodsListState.importGoods.isVisibleDrawer = false;
10294
+
10295
+ if (!s.goodsListState.isTaxIncluded) {
10296
+ _context2.next = 20;
10297
+ break;
10298
+ }
10299
+
10300
+ _context2.next = 18;
10301
+ return updateUnitPriceExcludingTax(controller, s.goodsListState.form, record);
10302
+
10303
+ case 18:
10304
+ _context2.next = 22;
10305
+ break;
10306
+
10307
+ case 20:
10308
+ _context2.next = 22;
10309
+ return updateUnitPriceTax(controller, s.goodsListState.form, record);
10310
+
10311
+ case 22:
10312
+ case "end":
10313
+ return _context2.stop();
10314
+ }
10315
+ }
10316
+ }, _callee2);
10317
+ }));
10318
+
10319
+ return function (_x2) {
10320
+ return _ref2.apply(this, arguments);
10321
+ };
10322
+ }());
10235
10323
  }, [options, controller]);
10236
10324
  return React__default['default'].createElement("div", {
10237
10325
  className: 'kts-invoice-operate-goods-list-itemName-input'
@@ -10256,7 +10344,23 @@ function ItemNameInput(props) {
10256
10344
  value: props.value,
10257
10345
  onChange: onChange
10258
10346
  })));
10259
- }
10347
+ } // function removeNullUndefined(obj: Record<string, any>): Record<string, any> {
10348
+ // const filteredObj: Record<string, any> = {};
10349
+ // for (const key in obj) {
10350
+ // if (obj[key] !== null && obj[key] !== undefined) {
10351
+ // filteredObj[key] = obj[key];
10352
+ // }
10353
+ // }
10354
+ // return filteredObj;
10355
+ // }
10356
+
10357
+ /** 货物单价,不含税 */
10358
+
10359
+ var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
10360
+ if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
10361
+
10362
+ return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")), calculatingDigits);
10363
+ };
10260
10364
 
10261
10365
  /** 拆分全称加简称 */
10262
10366
  var getSN = function getSN(value) {
@@ -19648,7 +19752,7 @@ var DrawerBody$2 = function DrawerBody() {
19648
19752
  editGood.priceIncludeTax = undefined;
19649
19753
  editGood.priceExcludeTax = undefined;
19650
19754
  } else {
19651
- editGood.priceExcludeTax = getPriceExcludeTax(editGood, record, s.calculatingDigits);
19755
+ editGood.priceExcludeTax = getPriceExcludeTax$1(editGood, record, s.calculatingDigits);
19652
19756
  }
19653
19757
 
19654
19758
  if (editGood.quantity && editGood.priceIncludeTax) {
@@ -19710,7 +19814,7 @@ var DrawerBody$2 = function DrawerBody() {
19710
19814
  /** 货物单价,不含税 */
19711
19815
 
19712
19816
 
19713
- var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
19817
+ var getPriceExcludeTax$1 = function getPriceExcludeTax(s, record, calculatingDigits) {
19714
19818
  if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
19715
19819
 
19716
19820
  return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")), calculatingDigits);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.19",
3
+ "version": "3.2.21",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -20,11 +20,50 @@ class MyInvoiceController extends InvoiceController {
20
20
  constructor() {
21
21
  super();
22
22
  this.state.autoComplete.onItemNameSearch = async text => {
23
- const sum: { value: string }[] = []
24
- for (let index = 0; index < 10; index++) {
25
- sum.push({ value: `xxxx${index}` })
26
- }
27
- return sum;
23
+ return [
24
+ {
25
+ "itemName": "呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵",
26
+ "taxClassificationCode": "1010112070000000000",
27
+ "itemModelName": null,
28
+ "shorthand": "蔬菜",
29
+ "taxRate": undefined
30
+ },
31
+ {
32
+ "itemName": "稻谷",
33
+ "taxClassificationCode": "1010101040000000000",
34
+ "itemModelName": null,
35
+ "shorthand": "谷物",
36
+ "taxRate": 3
37
+ },
38
+ {
39
+ "itemName": "苹果",
40
+ "taxClassificationCode": "1090111090000000000",
41
+ "itemModelName": null,
42
+ "shorthand": "小型起重设备",
43
+ "taxRate": null
44
+ },
45
+ {
46
+ "itemName": "银丝",
47
+ "taxClassificationCode": "1080411120000000000",
48
+ "itemModelName": null,
49
+ "shorthand": "金属制品",
50
+ "taxRate": 3
51
+ },
52
+ {
53
+ "itemName": "布料",
54
+ "taxClassificationCode": "1100101011100000000",
55
+ "itemModelName": null,
56
+ "shorthand": "发电",
57
+ "taxRate": 2
58
+ },
59
+ {
60
+ "itemName": "苹果",
61
+ "taxClassificationCode": "1010115010100000000",
62
+ "itemModelName": null,
63
+ "shorthand": "水果",
64
+ "taxRate": 3
65
+ }
66
+ ] as any
28
67
  }
29
68
  }
30
69
 
@@ -2,8 +2,11 @@
2
2
  import { Input } from 'kts-components-antd-x3';
3
3
  import React, { ChangeEvent } from 'react';
4
4
  import { AutoComplete } from 'kts-xui';
5
+ import { countAmountIncludeTax } from '../../../../../../../tools/calculate'
5
6
  import { IGood, Invoice } from '../../../../../../../..';
6
7
  import './index.less';
8
+ import { dutyFree, format15, updateUnitPriceExcludingTax, updateUnitPriceTax } from '../../autoFillFn';
9
+ import evaluate from '../../../../../../../tools/evaluate';
7
10
 
8
11
  export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLInputElement>) => void, value?: string, shorthand?: string }) {
9
12
 
@@ -30,8 +33,64 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
30
33
  }, [autoComplete.onItemNameSearch])
31
34
 
32
35
  const onChangeAutoComplete = React.useCallback(itemName => {
33
- const good = options.filter(e=>e.itemName === itemName);
34
- controller.state.goodsListState.form?.setFieldsValue(good);
36
+ // const good = options.filter(e=>e.itemName === itemName)[0];
37
+ // good && controller.state.goodsListState.form?.setFieldsValue(removeNullUndefined(good));
38
+
39
+ const record = options.filter(e => e.itemName === itemName)[0] as any;
40
+ debugger;
41
+ if (!record) return;
42
+ controller.run(async s => {
43
+ Object.keys(record).filter(e => !record[e] && record[e] !== 0).forEach(e => { delete record[e] });
44
+
45
+ // 没用 被编辑的货物 和 form 就退出
46
+ if (!s.goodsListState.editGood || !s.goodsListState.form) return;
47
+
48
+ // 导入时清空之前输入的值,使用导入的单价和税率(参考税局系统)
49
+ record.quantity = undefined;
50
+ record.lineAmountExcludeTax = undefined;
51
+ record.lineAmountIncludeTax = undefined;
52
+
53
+ // 中间数据
54
+ const between = { ...record };
55
+ between.itemName = record.itemName;
56
+ between.itemNameOther = record.itemName;
57
+
58
+ // 设置编辑货物
59
+ const editGood: IGood = s.goodsListState.editGood = { ...s.goodsListState.editGood, ...between };
60
+
61
+ if (editGood.taxRate) {
62
+ editGood.taxRate = dutyFree(controller, editGood.taxRate, s.goodsListState.form, editGood)
63
+ }
64
+
65
+ if (`${editGood.priceIncludeTax}` === '0') {
66
+ editGood.priceIncludeTax = undefined;
67
+ editGood.priceExcludeTax = undefined;
68
+ } else {
69
+ editGood.priceExcludeTax = getPriceExcludeTax(editGood, record, s.calculatingDigits) as number;
70
+ }
71
+
72
+ if (editGood.quantity && editGood.priceIncludeTax) {
73
+ editGood.lineAmountIncludeTax = countAmountIncludeTax(editGood.quantity, editGood.priceIncludeTax, s.calculatingDigits);
74
+ }
75
+
76
+ // 导入FORM里
77
+ if (s.goodsListState.isMyShow) {
78
+ s.goodsListState.form.setFieldsValue({
79
+ ...editGood,
80
+ itemName: editGood.itemNameSelf,
81
+ itemModelName: editGood.itemModelNameSelf,
82
+ });
83
+ } else {
84
+ s.goodsListState.form.setFieldsValue({
85
+ ...editGood,
86
+ });
87
+ }
88
+
89
+ s.goodsListState.importGoods.isVisibleDrawer = false;
90
+ s.goodsListState.isTaxIncluded
91
+ ? await updateUnitPriceExcludingTax(controller, s.goodsListState.form, record)
92
+ : await updateUnitPriceTax(controller, s.goodsListState.form, record)
93
+ })
35
94
  }, [options, controller])
36
95
 
37
96
  return (
@@ -43,3 +102,24 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
43
102
  </div>
44
103
  )
45
104
  }
105
+
106
+
107
+ // function removeNullUndefined(obj: Record<string, any>): Record<string, any> {
108
+ // const filteredObj: Record<string, any> = {};
109
+
110
+ // for (const key in obj) {
111
+ // if (obj[key] !== null && obj[key] !== undefined) {
112
+ // filteredObj[key] = obj[key];
113
+ // }
114
+ // }
115
+
116
+ // return filteredObj;
117
+ // }
118
+
119
+ /** 货物单价,不含税 */
120
+ const getPriceExcludeTax = (s: IGood, record: any, calculatingDigits?: number) => {
121
+ if ((!s.taxRate && s.taxRate !== 0) || (!record.priceIncludeTax && record.priceIncludeTax !== 0)) return;
122
+
123
+ // 单价(含税)/(1+税率) = 单价(不含税)
124
+ return format15(evaluate(`${record.priceIncludeTax} / (1+${s.taxRate}/100)`), calculatingDigits);
125
+ };