kts-component-invoice-operate 1.2.17 → 1.2.20-b1

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.
@@ -37,7 +37,9 @@ export default class EndowCode {
37
37
  favouredPolicyNameList: string[];
38
38
  /** 免税类型 列表 */
39
39
  taxFreeTypeList: any[];
40
- /** 小规模纳税人 自动赋码缓存 */
40
+ /**
41
+ * 小规模纳税人 自动赋码缓存 、
42
+ * */
41
43
  cache: {
42
44
  [key: string]: any;
43
45
  };
@@ -11,6 +11,14 @@ export default class InvoiceControllerState {
11
11
  * 08 小规模纳税人
12
12
  * */
13
13
  en: '01' | '05' | '04' | '08';
14
+ /**
15
+ * 发票类型
16
+ * 08 - 增值税电子专用发票
17
+ * 10 - 增值税电子普通发票
18
+ * 01 - 增值税纸质专用发票
19
+ * 04 - 增值税纸质普通发票
20
+ */
21
+ invoiceType: '08' | '10' | '01' | '04';
14
22
  /** 购买方 */
15
23
  buyerState: BuyerState;
16
24
  /** 货物信息 */
@@ -19,6 +19,8 @@ export declare const onChangeLineAmountIncludeTax: (...par: any[]) => void;
19
19
  export declare const onChangeLineAmountExcludeTax: (...par: any[]) => void;
20
20
  /** 税率 */
21
21
  export declare const onChangeTaxRate: (...par: any[]) => void;
22
+ /** 小规模纳税人 1% 和 3% 自动赋码免税 */
23
+ export declare function dutyFree(controller: InvoiceController, taxRate: number, form: WrappedFormUtils<any>, record: IGood): number | undefined;
22
24
  /** 含税 => 更新(不含税) */
23
25
  export declare const updateUnitPriceExcludingTax: (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => void;
24
26
  /** 不含税 => 更新(含税) */
package/dist/index.esm.js CHANGED
@@ -354,54 +354,58 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
354
354
  while (1) {
355
355
  switch (_context.prev = _context.next) {
356
356
  case 0:
357
+ _context.next = 2;
358
+ return this.wait();
359
+
360
+ case 2:
357
361
  _errors = new Map();
358
362
  _values = new Map();
359
363
  arr = Array.from(this.formList);
360
364
  i = 0;
361
365
 
362
- case 4:
366
+ case 6:
363
367
  if (!(i < arr.length)) {
364
- _context.next = 16;
368
+ _context.next = 18;
365
369
  break;
366
370
  }
367
371
 
368
372
  key = arr[i][0];
369
- _context.next = 8;
373
+ _context.next = 10;
370
374
  return _validateFields(arr[i][1]);
371
375
 
372
- case 8:
376
+ case 10:
373
377
  _yield$_validateField = _context.sent;
374
378
  errors = _yield$_validateField.errors;
375
379
  values = _yield$_validateField.values;
376
380
  errors && _errors.set(key, errors);
377
381
  _values && _values.set(key, values);
378
382
 
379
- case 13:
383
+ case 15:
380
384
  i++;
381
- _context.next = 4;
385
+ _context.next = 6;
382
386
  break;
383
387
 
384
- case 16:
388
+ case 18:
385
389
  if (!this.state.goodsListState.form) {
386
- _context.next = 25;
390
+ _context.next = 27;
387
391
  break;
388
392
  }
389
393
 
390
- _context.prev = 17;
391
- _context.next = 20;
394
+ _context.prev = 19;
395
+ _context.next = 22;
392
396
  return (_this$state$goodsList = this.state.goodsListState.form) === null || _this$state$goodsList === void 0 ? void 0 : _this$state$goodsList.validateFields();
393
397
 
394
- case 20:
395
- _context.next = 25;
398
+ case 22:
399
+ _context.next = 27;
396
400
  break;
397
401
 
398
- case 22:
399
- _context.prev = 22;
400
- _context.t0 = _context["catch"](17);
402
+ case 24:
403
+ _context.prev = 24;
404
+ _context.t0 = _context["catch"](19);
401
405
 
402
406
  _errors.set('goodsList', _context.t0.errors);
403
407
 
404
- case 25:
408
+ case 27:
405
409
  _values.set('goodsList', this.state.goodsListState.goodsList.slice()); // 金额(含税)
406
410
 
407
411
 
@@ -445,12 +449,12 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
445
449
  values: _values
446
450
  });
447
451
 
448
- case 30:
452
+ case 32:
449
453
  case "end":
450
454
  return _context.stop();
451
455
  }
452
456
  }
453
- }, _callee, this, [[17, 22]]);
457
+ }, _callee, this, [[19, 24]]);
454
458
  }));
455
459
 
456
460
  function validateFields() {
@@ -498,6 +502,10 @@ var ImportGoods = function ImportGoods() {
498
502
  title: '计量单位',
499
503
  dataIndex: 'unit',
500
504
  key: 'unit'
505
+ }, {
506
+ title: '税率(%)',
507
+ dataIndex: 'taxRate',
508
+ key: 'taxRate'
501
509
  }, {
502
510
  title: '单价(含税)',
503
511
  dataIndex: 'priceIncludeTax',
@@ -707,6 +715,7 @@ var InvoiceControllerState = function InvoiceControllerState() {
707
715
 
708
716
  this.model = 'default';
709
717
  this.en = '01';
718
+ this.invoiceType = '08';
710
719
  this.buyerState = new BuyerState();
711
720
  this.goodsListState = new GoodsListState();
712
721
  };
@@ -8786,15 +8795,26 @@ var onChangeTaxRate = lazyFn$1(function (controller, form, record) {
8786
8795
 
8787
8796
  case 3:
8788
8797
  taxRate = parseFloat(values.taxRate);
8789
- taxRate = dutyFree(controller, taxRate, form, record); // 小规模纳税人
8790
-
8791
- _context6.next = 7;
8798
+ _context6.next = 6;
8792
8799
  return controller.setEditGood({
8793
8800
  taxRate: taxRate
8794
8801
  });
8795
8802
 
8796
- case 7:
8797
- // 是否含税
8803
+ case 6:
8804
+ // 去掉赋码
8805
+ (function () {
8806
+ var cache = controller.state.goodsListState.endowCode.cache;
8807
+ var record = controller.state.goodsListState.editGood;
8808
+
8809
+ if (record && cache[record.$index]) {
8810
+ record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8811
+ record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8812
+ record.taxFreeType = cache[record.$index].taxFreeType;
8813
+ cache[record.$index] = undefined;
8814
+ }
8815
+ })(); // 是否含税
8816
+
8817
+
8798
8818
  if (controller.state.goodsListState.isTaxIncluded) {
8799
8819
  updateUnitPriceExcludingTax(controller, form);
8800
8820
  } else {
@@ -8817,44 +8837,36 @@ var onChangeTaxRate = lazyFn$1(function (controller, form, record) {
8817
8837
  /** 小规模纳税人 1% 和 3% 自动赋码免税 */
8818
8838
 
8819
8839
  function dutyFree(controller, taxRate, form, record) {
8820
- var cache = controller.state.goodsListState.endowCode.cache; // 4月1日至12月31日
8821
-
8840
+ var cache = controller.state.goodsListState.endowCode.cache;
8841
+ var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
8842
+
8843
+ console.log('===> 小规模纳税人免税逻辑');
8844
+ console.log('===> invoiceType', invoiceType);
8845
+ console.log('===> en', controller.state.en);
8846
+ console.log('===> taxRate', taxRate);
8847
+ console.log('===> state', controller.state);
8822
8848
  if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
8823
- if (controller.state.en !== '08') return taxRate; // 选择的 1或者3
8849
+ if (controller.state.en !== '08') return taxRate;
8850
+ if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
8824
8851
 
8825
8852
  if (taxRate === 1 || taxRate === 3) {
8826
- // 是否处理过
8827
- if (cache[record.$index]) {
8828
- return taxRate;
8829
- } else {
8830
- cache[record.$index] = {
8831
- favouredPolicyName: record.favouredPolicyName,
8832
- favouredPolicyMark: record.favouredPolicyMark,
8833
- taxFreeType: record.taxFreeType
8834
- };
8835
- record.favouredPolicyName = '免税';
8836
- record.taxRate = 0;
8837
- record.favouredPolicyMark = 1;
8838
- record.taxFreeType = 1;
8839
- form.setFieldsValue({
8840
- taxRate: 0
8841
- });
8842
- return 0;
8843
- }
8844
- } else {
8845
- if (cache[record.$index] && cache[record.$index] !== true) {
8846
- record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8847
- record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8848
- record.taxFreeType = cache[record.$index].taxFreeType;
8849
- cache[record.$index] = true;
8850
- }
8851
-
8852
- return taxRate;
8853
+ cache[record.$index] = {
8854
+ favouredPolicyName: record.favouredPolicyName,
8855
+ favouredPolicyMark: record.favouredPolicyMark,
8856
+ taxFreeType: record.taxFreeType
8857
+ };
8858
+ record.favouredPolicyName = '免税';
8859
+ record.taxRate = 0;
8860
+ record.favouredPolicyMark = 1;
8861
+ record.taxFreeType = 1;
8862
+ form.setFieldsValue({
8863
+ taxRate: 0
8864
+ });
8865
+ return 0;
8853
8866
  }
8854
8867
  }
8855
8868
  /** 含税 => 更新(不含税) */
8856
8869
 
8857
-
8858
8870
  var updateUnitPriceExcludingTax = function updateUnitPriceExcludingTax(controller, form, record) {
8859
8871
  form.validateFields( /*#__PURE__*/function () {
8860
8872
  var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(err, values) {
@@ -11362,7 +11374,7 @@ var DrawerBody$2 = function DrawerBody() {
11362
11374
  onRow: function onRow(record) {
11363
11375
  return {
11364
11376
  onClick: function onClick() {
11365
- controller.pipeline( /*#__PURE__*/function () {
11377
+ controller.run( /*#__PURE__*/function () {
11366
11378
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(s) {
11367
11379
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
11368
11380
  while (1) {
@@ -11412,6 +11424,8 @@ var DrawerBody$2 = function DrawerBody() {
11412
11424
  return _context2.abrupt("return");
11413
11425
 
11414
11426
  case 12:
11427
+ if (s.goodsListState.editGood.taxRate) s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, s.goodsListState.editGood);
11428
+
11415
11429
  if ("".concat(s.goodsListState.editGood.priceIncludeTax) === '0') {
11416
11430
  s.goodsListState.editGood.priceIncludeTax = undefined;
11417
11431
  s.goodsListState.editGood.priceExcludeTax = undefined;
@@ -11425,7 +11439,7 @@ var DrawerBody$2 = function DrawerBody() {
11425
11439
  s.goodsListState.importGoods.isVisibleDrawer = false;
11426
11440
  s.goodsListState.isTaxIncluded ? updateUnitPriceExcludingTax(controller, s.goodsListState.form) : updateUnitPriceTax(controller, s.goodsListState.form);
11427
11441
 
11428
- case 18:
11442
+ case 19:
11429
11443
  case "end":
11430
11444
  return _context2.stop();
11431
11445
  }
@@ -11436,7 +11450,7 @@ var DrawerBody$2 = function DrawerBody() {
11436
11450
  return function (_x2) {
11437
11451
  return _ref2.apply(this, arguments);
11438
11452
  };
11439
- }())();
11453
+ }());
11440
11454
  }
11441
11455
  };
11442
11456
  }
package/dist/index.js CHANGED
@@ -364,54 +364,58 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
364
364
  while (1) {
365
365
  switch (_context.prev = _context.next) {
366
366
  case 0:
367
+ _context.next = 2;
368
+ return this.wait();
369
+
370
+ case 2:
367
371
  _errors = new Map();
368
372
  _values = new Map();
369
373
  arr = Array.from(this.formList);
370
374
  i = 0;
371
375
 
372
- case 4:
376
+ case 6:
373
377
  if (!(i < arr.length)) {
374
- _context.next = 16;
378
+ _context.next = 18;
375
379
  break;
376
380
  }
377
381
 
378
382
  key = arr[i][0];
379
- _context.next = 8;
383
+ _context.next = 10;
380
384
  return _validateFields(arr[i][1]);
381
385
 
382
- case 8:
386
+ case 10:
383
387
  _yield$_validateField = _context.sent;
384
388
  errors = _yield$_validateField.errors;
385
389
  values = _yield$_validateField.values;
386
390
  errors && _errors.set(key, errors);
387
391
  _values && _values.set(key, values);
388
392
 
389
- case 13:
393
+ case 15:
390
394
  i++;
391
- _context.next = 4;
395
+ _context.next = 6;
392
396
  break;
393
397
 
394
- case 16:
398
+ case 18:
395
399
  if (!this.state.goodsListState.form) {
396
- _context.next = 25;
400
+ _context.next = 27;
397
401
  break;
398
402
  }
399
403
 
400
- _context.prev = 17;
401
- _context.next = 20;
404
+ _context.prev = 19;
405
+ _context.next = 22;
402
406
  return (_this$state$goodsList = this.state.goodsListState.form) === null || _this$state$goodsList === void 0 ? void 0 : _this$state$goodsList.validateFields();
403
407
 
404
- case 20:
405
- _context.next = 25;
408
+ case 22:
409
+ _context.next = 27;
406
410
  break;
407
411
 
408
- case 22:
409
- _context.prev = 22;
410
- _context.t0 = _context["catch"](17);
412
+ case 24:
413
+ _context.prev = 24;
414
+ _context.t0 = _context["catch"](19);
411
415
 
412
416
  _errors.set('goodsList', _context.t0.errors);
413
417
 
414
- case 25:
418
+ case 27:
415
419
  _values.set('goodsList', this.state.goodsListState.goodsList.slice()); // 金额(含税)
416
420
 
417
421
 
@@ -455,12 +459,12 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
455
459
  values: _values
456
460
  });
457
461
 
458
- case 30:
462
+ case 32:
459
463
  case "end":
460
464
  return _context.stop();
461
465
  }
462
466
  }
463
- }, _callee, this, [[17, 22]]);
467
+ }, _callee, this, [[19, 24]]);
464
468
  }));
465
469
 
466
470
  function validateFields() {
@@ -508,6 +512,10 @@ var ImportGoods = function ImportGoods() {
508
512
  title: '计量单位',
509
513
  dataIndex: 'unit',
510
514
  key: 'unit'
515
+ }, {
516
+ title: '税率(%)',
517
+ dataIndex: 'taxRate',
518
+ key: 'taxRate'
511
519
  }, {
512
520
  title: '单价(含税)',
513
521
  dataIndex: 'priceIncludeTax',
@@ -717,6 +725,7 @@ var InvoiceControllerState = function InvoiceControllerState() {
717
725
 
718
726
  this.model = 'default';
719
727
  this.en = '01';
728
+ this.invoiceType = '08';
720
729
  this.buyerState = new BuyerState();
721
730
  this.goodsListState = new GoodsListState();
722
731
  };
@@ -8796,15 +8805,26 @@ var onChangeTaxRate = lazyFn$1(function (controller, form, record) {
8796
8805
 
8797
8806
  case 3:
8798
8807
  taxRate = parseFloat(values.taxRate);
8799
- taxRate = dutyFree(controller, taxRate, form, record); // 小规模纳税人
8800
-
8801
- _context6.next = 7;
8808
+ _context6.next = 6;
8802
8809
  return controller.setEditGood({
8803
8810
  taxRate: taxRate
8804
8811
  });
8805
8812
 
8806
- case 7:
8807
- // 是否含税
8813
+ case 6:
8814
+ // 去掉赋码
8815
+ (function () {
8816
+ var cache = controller.state.goodsListState.endowCode.cache;
8817
+ var record = controller.state.goodsListState.editGood;
8818
+
8819
+ if (record && cache[record.$index]) {
8820
+ record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8821
+ record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8822
+ record.taxFreeType = cache[record.$index].taxFreeType;
8823
+ cache[record.$index] = undefined;
8824
+ }
8825
+ })(); // 是否含税
8826
+
8827
+
8808
8828
  if (controller.state.goodsListState.isTaxIncluded) {
8809
8829
  updateUnitPriceExcludingTax(controller, form);
8810
8830
  } else {
@@ -8827,44 +8847,36 @@ var onChangeTaxRate = lazyFn$1(function (controller, form, record) {
8827
8847
  /** 小规模纳税人 1% 和 3% 自动赋码免税 */
8828
8848
 
8829
8849
  function dutyFree(controller, taxRate, form, record) {
8830
- var cache = controller.state.goodsListState.endowCode.cache; // 4月1日至12月31日
8831
-
8850
+ var cache = controller.state.goodsListState.endowCode.cache;
8851
+ var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
8852
+
8853
+ console.log('===> 小规模纳税人免税逻辑');
8854
+ console.log('===> invoiceType', invoiceType);
8855
+ console.log('===> en', controller.state.en);
8856
+ console.log('===> taxRate', taxRate);
8857
+ console.log('===> state', controller.state);
8832
8858
  if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
8833
- if (controller.state.en !== '08') return taxRate; // 选择的 1或者3
8859
+ if (controller.state.en !== '08') return taxRate;
8860
+ if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
8834
8861
 
8835
8862
  if (taxRate === 1 || taxRate === 3) {
8836
- // 是否处理过
8837
- if (cache[record.$index]) {
8838
- return taxRate;
8839
- } else {
8840
- cache[record.$index] = {
8841
- favouredPolicyName: record.favouredPolicyName,
8842
- favouredPolicyMark: record.favouredPolicyMark,
8843
- taxFreeType: record.taxFreeType
8844
- };
8845
- record.favouredPolicyName = '免税';
8846
- record.taxRate = 0;
8847
- record.favouredPolicyMark = 1;
8848
- record.taxFreeType = 1;
8849
- form.setFieldsValue({
8850
- taxRate: 0
8851
- });
8852
- return 0;
8853
- }
8854
- } else {
8855
- if (cache[record.$index] && cache[record.$index] !== true) {
8856
- record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8857
- record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8858
- record.taxFreeType = cache[record.$index].taxFreeType;
8859
- cache[record.$index] = true;
8860
- }
8861
-
8862
- return taxRate;
8863
+ cache[record.$index] = {
8864
+ favouredPolicyName: record.favouredPolicyName,
8865
+ favouredPolicyMark: record.favouredPolicyMark,
8866
+ taxFreeType: record.taxFreeType
8867
+ };
8868
+ record.favouredPolicyName = '免税';
8869
+ record.taxRate = 0;
8870
+ record.favouredPolicyMark = 1;
8871
+ record.taxFreeType = 1;
8872
+ form.setFieldsValue({
8873
+ taxRate: 0
8874
+ });
8875
+ return 0;
8863
8876
  }
8864
8877
  }
8865
8878
  /** 含税 => 更新(不含税) */
8866
8879
 
8867
-
8868
8880
  var updateUnitPriceExcludingTax = function updateUnitPriceExcludingTax(controller, form, record) {
8869
8881
  form.validateFields( /*#__PURE__*/function () {
8870
8882
  var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(err, values) {
@@ -11372,7 +11384,7 @@ var DrawerBody$2 = function DrawerBody() {
11372
11384
  onRow: function onRow(record) {
11373
11385
  return {
11374
11386
  onClick: function onClick() {
11375
- controller.pipeline( /*#__PURE__*/function () {
11387
+ controller.run( /*#__PURE__*/function () {
11376
11388
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(s) {
11377
11389
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
11378
11390
  while (1) {
@@ -11422,6 +11434,8 @@ var DrawerBody$2 = function DrawerBody() {
11422
11434
  return _context2.abrupt("return");
11423
11435
 
11424
11436
  case 12:
11437
+ if (s.goodsListState.editGood.taxRate) s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, s.goodsListState.editGood);
11438
+
11425
11439
  if ("".concat(s.goodsListState.editGood.priceIncludeTax) === '0') {
11426
11440
  s.goodsListState.editGood.priceIncludeTax = undefined;
11427
11441
  s.goodsListState.editGood.priceExcludeTax = undefined;
@@ -11435,7 +11449,7 @@ var DrawerBody$2 = function DrawerBody() {
11435
11449
  s.goodsListState.importGoods.isVisibleDrawer = false;
11436
11450
  s.goodsListState.isTaxIncluded ? updateUnitPriceExcludingTax(controller, s.goodsListState.form) : updateUnitPriceTax(controller, s.goodsListState.form);
11437
11451
 
11438
- case 18:
11452
+ case 19:
11439
11453
  case "end":
11440
11454
  return _context2.stop();
11441
11455
  }
@@ -11446,7 +11460,7 @@ var DrawerBody$2 = function DrawerBody() {
11446
11460
  return function (_x2) {
11447
11461
  return _ref2.apply(this, arguments);
11448
11462
  };
11449
- }())();
11463
+ }());
11450
11464
  }
11451
11465
  };
11452
11466
  }
package/docs/index.md CHANGED
@@ -1,5 +1,5 @@
1
- # 发票编辑组件
1
+ # 发票编辑组件-
2
2
 
3
3
  npm 地址:https://www.npmjs.com/package/kts-component-invoice-operate
4
4
 
5
- ### 版本 1.2.11
5
+ ### 版本 1.2.20