kts-component-invoice-operate 3.2.20 → 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
10223
  })[0];
10224
- good && ((_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(removeNullUndefined(good)));
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,19 +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
+ // }
10250
10346
 
10251
- function removeNullUndefined(obj) {
10252
- var filteredObj = {};
10347
+ /** 货物单价,不含税 */
10253
10348
 
10254
- for (var key in obj) {
10255
- if (obj[key] !== null && obj[key] !== undefined) {
10256
- filteredObj[key] = obj[key];
10257
- }
10258
- }
10349
+ var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
10350
+ if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
10259
10351
 
10260
- return filteredObj;
10261
- }
10352
+ return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")), calculatingDigits);
10353
+ };
10262
10354
 
10263
10355
  /** 拆分全称加简称 */
10264
10356
  var getSN = function getSN(value) {
@@ -19650,7 +19742,7 @@ var DrawerBody$2 = function DrawerBody() {
19650
19742
  editGood.priceIncludeTax = undefined;
19651
19743
  editGood.priceExcludeTax = undefined;
19652
19744
  } else {
19653
- editGood.priceExcludeTax = getPriceExcludeTax(editGood, record, s.calculatingDigits);
19745
+ editGood.priceExcludeTax = getPriceExcludeTax$1(editGood, record, s.calculatingDigits);
19654
19746
  }
19655
19747
 
19656
19748
  if (editGood.quantity && editGood.priceIncludeTax) {
@@ -19712,7 +19804,7 @@ var DrawerBody$2 = function DrawerBody() {
19712
19804
  /** 货物单价,不含税 */
19713
19805
 
19714
19806
 
19715
- var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
19807
+ var getPriceExcludeTax$1 = function getPriceExcludeTax(s, record, calculatingDigits) {
19716
19808
  if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
19717
19809
 
19718
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
10233
  })[0];
10234
- good && ((_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(removeNullUndefined(good)));
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,19 +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
+ // }
10260
10356
 
10261
- function removeNullUndefined(obj) {
10262
- var filteredObj = {};
10357
+ /** 货物单价,不含税 */
10263
10358
 
10264
- for (var key in obj) {
10265
- if (obj[key] !== null && obj[key] !== undefined) {
10266
- filteredObj[key] = obj[key];
10267
- }
10268
- }
10359
+ var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
10360
+ if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
10269
10361
 
10270
- return filteredObj;
10271
- }
10362
+ return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")), calculatingDigits);
10363
+ };
10272
10364
 
10273
10365
  /** 拆分全称加简称 */
10274
10366
  var getSN = function getSN(value) {
@@ -19660,7 +19752,7 @@ var DrawerBody$2 = function DrawerBody() {
19660
19752
  editGood.priceIncludeTax = undefined;
19661
19753
  editGood.priceExcludeTax = undefined;
19662
19754
  } else {
19663
- editGood.priceExcludeTax = getPriceExcludeTax(editGood, record, s.calculatingDigits);
19755
+ editGood.priceExcludeTax = getPriceExcludeTax$1(editGood, record, s.calculatingDigits);
19664
19756
  }
19665
19757
 
19666
19758
  if (editGood.quantity && editGood.priceIncludeTax) {
@@ -19722,7 +19814,7 @@ var DrawerBody$2 = function DrawerBody() {
19722
19814
  /** 货物单价,不含税 */
19723
19815
 
19724
19816
 
19725
- var getPriceExcludeTax = function getPriceExcludeTax(s, record, calculatingDigits) {
19817
+ var getPriceExcludeTax$1 = function getPriceExcludeTax(s, record, calculatingDigits) {
19726
19818
  if (!s.taxRate && s.taxRate !== 0 || !record.priceIncludeTax && record.priceIncludeTax !== 0) return; // 单价(含税)/(1+税率) = 单价(不含税)
19727
19819
 
19728
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.20",
3
+ "version": "3.2.21",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -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)[0];
34
- good && controller.state.goodsListState.form?.setFieldsValue(removeNullUndefined(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 (
@@ -45,14 +104,22 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
45
104
  }
46
105
 
47
106
 
48
- function removeNullUndefined(obj: Record<string, any>): Record<string, any> {
49
- const filteredObj: Record<string, any> = {};
50
-
51
- for (const key in obj) {
52
- if (obj[key] !== null && obj[key] !== undefined) {
53
- filteredObj[key] = obj[key];
54
- }
55
- }
56
-
57
- return filteredObj;
58
- }
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
+ };