kts-component-invoice-operate 1.2.15 → 1.2.18

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.
@@ -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;
22
24
  /** 含税 => 更新(不含税) */
23
25
  export declare const updateUnitPriceExcludingTax: (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => void;
24
26
  /** 不含税 => 更新(含税) */
package/dist/index.esm.js CHANGED
@@ -498,6 +498,10 @@ var ImportGoods = function ImportGoods() {
498
498
  title: '计量单位',
499
499
  dataIndex: 'unit',
500
500
  key: 'unit'
501
+ }, {
502
+ title: '税率(%)',
503
+ dataIndex: 'taxRate',
504
+ key: 'taxRate'
501
505
  }, {
502
506
  title: '单价(含税)',
503
507
  dataIndex: 'priceIncludeTax',
@@ -707,6 +711,7 @@ var InvoiceControllerState = function InvoiceControllerState() {
707
711
 
708
712
  this.model = 'default';
709
713
  this.en = '01';
714
+ this.invoiceType = '08';
710
715
  this.buyerState = new BuyerState();
711
716
  this.goodsListState = new GoodsListState();
712
717
  };
@@ -8817,10 +8822,12 @@ var onChangeTaxRate = lazyFn$1(function (controller, form, record) {
8817
8822
  /** 小规模纳税人 1% 和 3% 自动赋码免税 */
8818
8823
 
8819
8824
  function dutyFree(controller, taxRate, form, record) {
8820
- var cache = controller.state.goodsListState.endowCode.cache; // 4月1日至12月31日
8825
+ var cache = controller.state.goodsListState.endowCode.cache;
8826
+ var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
8821
8827
 
8822
8828
  if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
8823
- if (controller.state.en !== '08') return taxRate; // 选择的 1或者3
8829
+ if (controller.state.en !== '08') return taxRate;
8830
+ if (invoiceType !== '10' && invoiceType !== '04') return taxRate; // 选择的 1或者3
8824
8831
 
8825
8832
  if (taxRate === 1 || taxRate === 3) {
8826
8833
  // 是否处理过
@@ -8829,11 +8836,13 @@ function dutyFree(controller, taxRate, form, record) {
8829
8836
  } else {
8830
8837
  cache[record.$index] = {
8831
8838
  favouredPolicyName: record.favouredPolicyName,
8832
- favouredPolicyMark: record.favouredPolicyMark
8839
+ favouredPolicyMark: record.favouredPolicyMark,
8840
+ taxFreeType: record.taxFreeType
8833
8841
  };
8834
8842
  record.favouredPolicyName = '免税';
8835
- record.favouredPolicyMark = 1;
8836
8843
  record.taxRate = 0;
8844
+ record.favouredPolicyMark = 1;
8845
+ record.taxFreeType = 1;
8837
8846
  form.setFieldsValue({
8838
8847
  taxRate: 0
8839
8848
  });
@@ -8842,7 +8851,8 @@ function dutyFree(controller, taxRate, form, record) {
8842
8851
  } else {
8843
8852
  if (cache[record.$index] && cache[record.$index] !== true) {
8844
8853
  record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8845
- record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8854
+ record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8855
+ record.taxFreeType = cache[record.$index].taxFreeType;
8846
8856
  cache[record.$index] = true;
8847
8857
  }
8848
8858
 
@@ -8851,7 +8861,6 @@ function dutyFree(controller, taxRate, form, record) {
8851
8861
  }
8852
8862
  /** 含税 => 更新(不含税) */
8853
8863
 
8854
-
8855
8864
  var updateUnitPriceExcludingTax = function updateUnitPriceExcludingTax(controller, form, record) {
8856
8865
  form.validateFields( /*#__PURE__*/function () {
8857
8866
  var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(err, values) {
@@ -11359,7 +11368,7 @@ var DrawerBody$2 = function DrawerBody() {
11359
11368
  onRow: function onRow(record) {
11360
11369
  return {
11361
11370
  onClick: function onClick() {
11362
- controller.pipeline( /*#__PURE__*/function () {
11371
+ controller.run( /*#__PURE__*/function () {
11363
11372
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(s) {
11364
11373
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
11365
11374
  while (1) {
@@ -11409,6 +11418,8 @@ var DrawerBody$2 = function DrawerBody() {
11409
11418
  return _context2.abrupt("return");
11410
11419
 
11411
11420
  case 12:
11421
+ if (s.goodsListState.editGood.taxRate) s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, record);
11422
+
11412
11423
  if ("".concat(s.goodsListState.editGood.priceIncludeTax) === '0') {
11413
11424
  s.goodsListState.editGood.priceIncludeTax = undefined;
11414
11425
  s.goodsListState.editGood.priceExcludeTax = undefined;
@@ -11422,7 +11433,7 @@ var DrawerBody$2 = function DrawerBody() {
11422
11433
  s.goodsListState.importGoods.isVisibleDrawer = false;
11423
11434
  s.goodsListState.isTaxIncluded ? updateUnitPriceExcludingTax(controller, s.goodsListState.form) : updateUnitPriceTax(controller, s.goodsListState.form);
11424
11435
 
11425
- case 18:
11436
+ case 19:
11426
11437
  case "end":
11427
11438
  return _context2.stop();
11428
11439
  }
@@ -11433,7 +11444,7 @@ var DrawerBody$2 = function DrawerBody() {
11433
11444
  return function (_x2) {
11434
11445
  return _ref2.apply(this, arguments);
11435
11446
  };
11436
- }())();
11447
+ }());
11437
11448
  }
11438
11449
  };
11439
11450
  }
package/dist/index.js CHANGED
@@ -508,6 +508,10 @@ var ImportGoods = function ImportGoods() {
508
508
  title: '计量单位',
509
509
  dataIndex: 'unit',
510
510
  key: 'unit'
511
+ }, {
512
+ title: '税率(%)',
513
+ dataIndex: 'taxRate',
514
+ key: 'taxRate'
511
515
  }, {
512
516
  title: '单价(含税)',
513
517
  dataIndex: 'priceIncludeTax',
@@ -717,6 +721,7 @@ var InvoiceControllerState = function InvoiceControllerState() {
717
721
 
718
722
  this.model = 'default';
719
723
  this.en = '01';
724
+ this.invoiceType = '08';
720
725
  this.buyerState = new BuyerState();
721
726
  this.goodsListState = new GoodsListState();
722
727
  };
@@ -8827,10 +8832,12 @@ var onChangeTaxRate = lazyFn$1(function (controller, form, record) {
8827
8832
  /** 小规模纳税人 1% 和 3% 自动赋码免税 */
8828
8833
 
8829
8834
  function dutyFree(controller, taxRate, form, record) {
8830
- var cache = controller.state.goodsListState.endowCode.cache; // 4月1日至12月31日
8835
+ var cache = controller.state.goodsListState.endowCode.cache;
8836
+ var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
8831
8837
 
8832
8838
  if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
8833
- if (controller.state.en !== '08') return taxRate; // 选择的 1或者3
8839
+ if (controller.state.en !== '08') return taxRate;
8840
+ if (invoiceType !== '10' && invoiceType !== '04') return taxRate; // 选择的 1或者3
8834
8841
 
8835
8842
  if (taxRate === 1 || taxRate === 3) {
8836
8843
  // 是否处理过
@@ -8839,11 +8846,13 @@ function dutyFree(controller, taxRate, form, record) {
8839
8846
  } else {
8840
8847
  cache[record.$index] = {
8841
8848
  favouredPolicyName: record.favouredPolicyName,
8842
- favouredPolicyMark: record.favouredPolicyMark
8849
+ favouredPolicyMark: record.favouredPolicyMark,
8850
+ taxFreeType: record.taxFreeType
8843
8851
  };
8844
8852
  record.favouredPolicyName = '免税';
8845
- record.favouredPolicyMark = 1;
8846
8853
  record.taxRate = 0;
8854
+ record.favouredPolicyMark = 1;
8855
+ record.taxFreeType = 1;
8847
8856
  form.setFieldsValue({
8848
8857
  taxRate: 0
8849
8858
  });
@@ -8852,7 +8861,8 @@ function dutyFree(controller, taxRate, form, record) {
8852
8861
  } else {
8853
8862
  if (cache[record.$index] && cache[record.$index] !== true) {
8854
8863
  record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8855
- record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8864
+ record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8865
+ record.taxFreeType = cache[record.$index].taxFreeType;
8856
8866
  cache[record.$index] = true;
8857
8867
  }
8858
8868
 
@@ -8861,7 +8871,6 @@ function dutyFree(controller, taxRate, form, record) {
8861
8871
  }
8862
8872
  /** 含税 => 更新(不含税) */
8863
8873
 
8864
-
8865
8874
  var updateUnitPriceExcludingTax = function updateUnitPriceExcludingTax(controller, form, record) {
8866
8875
  form.validateFields( /*#__PURE__*/function () {
8867
8876
  var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(err, values) {
@@ -11369,7 +11378,7 @@ var DrawerBody$2 = function DrawerBody() {
11369
11378
  onRow: function onRow(record) {
11370
11379
  return {
11371
11380
  onClick: function onClick() {
11372
- controller.pipeline( /*#__PURE__*/function () {
11381
+ controller.run( /*#__PURE__*/function () {
11373
11382
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(s) {
11374
11383
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
11375
11384
  while (1) {
@@ -11419,6 +11428,8 @@ var DrawerBody$2 = function DrawerBody() {
11419
11428
  return _context2.abrupt("return");
11420
11429
 
11421
11430
  case 12:
11431
+ if (s.goodsListState.editGood.taxRate) s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, record);
11432
+
11422
11433
  if ("".concat(s.goodsListState.editGood.priceIncludeTax) === '0') {
11423
11434
  s.goodsListState.editGood.priceIncludeTax = undefined;
11424
11435
  s.goodsListState.editGood.priceExcludeTax = undefined;
@@ -11432,7 +11443,7 @@ var DrawerBody$2 = function DrawerBody() {
11432
11443
  s.goodsListState.importGoods.isVisibleDrawer = false;
11433
11444
  s.goodsListState.isTaxIncluded ? updateUnitPriceExcludingTax(controller, s.goodsListState.form) : updateUnitPriceTax(controller, s.goodsListState.form);
11434
11445
 
11435
- case 18:
11446
+ case 19:
11436
11447
  case "end":
11437
11448
  return _context2.stop();
11438
11449
  }
@@ -11443,7 +11454,7 @@ var DrawerBody$2 = function DrawerBody() {
11443
11454
  return function (_x2) {
11444
11455
  return _ref2.apply(this, arguments);
11445
11456
  };
11446
- }())();
11457
+ }());
11447
11458
  }
11448
11459
  };
11449
11460
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "1.2.15",
3
+ "version": "1.2.18",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -36,6 +36,11 @@ export default class ImportGoods<ColumnType = any> {
36
36
  dataIndex: 'unit',
37
37
  key: 'unit',
38
38
  },
39
+ {
40
+ title: '税率(%)',
41
+ dataIndex: 'taxRate',
42
+ key: 'taxRate',
43
+ },
39
44
  {
40
45
  title: '单价(含税)',
41
46
  dataIndex: 'priceIncludeTax',
@@ -4,7 +4,7 @@ import BuyerState from './BuyerState';
4
4
  export default class InvoiceControllerState {
5
5
 
6
6
  /** 组件模式 */
7
- model: 'default' | 'prefab' = 'default'
7
+ model: 'default' | 'prefab' = 'default';
8
8
 
9
9
  /**
10
10
  * 企业类型
@@ -15,6 +15,15 @@ export default class InvoiceControllerState {
15
15
  * */
16
16
  en: '01' | '05' | '04' | '08' = '01';
17
17
 
18
+ /**
19
+ * 发票类型
20
+ * 08 - 增值税电子专用发票
21
+ * 10 - 增值税电子普通发票
22
+ * 01 - 增值税纸质专用发票
23
+ * 04 - 增值税纸质普通发票
24
+ */
25
+ invoiceType: '08' | '10' | '01' | '04' = '08';
26
+
18
27
  /** 购买方 */
19
28
  buyerState = new BuyerState();
20
29
 
@@ -8,15 +8,9 @@ export default () => {
8
8
  // 初始化控制器
9
9
  const controller = React.useMemo(() => new MyInvoiceController(), []);
10
10
 
11
- // 开始搜索
12
- const onSumbit = React.useCallback(controller.pipeline(async (s, inputVal?: any) => {
13
- console.log('inputVal ===>', inputVal, s.goodsListState.importGoods.pagination);
14
- s.goodsListState.importGoods.dataSource = [];
15
- }), [])
16
-
17
11
  return (
18
12
  <>
19
- <Button onClick={async () => { console.log('===> 当前组件状态', await controller.validateFields()); }} >获取数据</Button>
13
+ <Button style={{ marginBottom: 10 }} onClick={async () => { console.log('===> 当前组件状态', await controller.validateFields()); }} >获取数据</Button>
20
14
  <Invoice controller={controller} />
21
15
  </>
22
16
  );
@@ -36,6 +30,9 @@ class MyInvoiceController extends Invoice.InvoiceController {
36
30
  key: 'affix',
37
31
  },
38
32
  ];
33
+
34
+ this.state.en = '08'
35
+ this.state.invoiceType = '10'
39
36
  }
40
37
 
41
38
  // 重写 的 获取商品列表
@@ -273,13 +273,15 @@ export const onChangeTaxRate = lazyFn(
273
273
  );
274
274
 
275
275
  /** 小规模纳税人 1% 和 3% 自动赋码免税 */
276
- function dutyFree(controller: InvoiceController, taxRate: number, form: WrappedFormUtils<any>, record: IGood) {
276
+ export function dutyFree(controller: InvoiceController, taxRate: number, form: WrappedFormUtils<any>, record: IGood) {
277
277
 
278
278
  const cache = controller.state.goodsListState.endowCode.cache;
279
+ const invoiceType = controller.state.invoiceType;
279
280
 
280
281
  // 4月1日至12月31日
281
282
  if (moment().valueOf() > moment('2022-12-31 23:59').valueOf()) return taxRate;
282
283
  if (controller.state.en !== '08') return taxRate;
284
+ if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
283
285
 
284
286
  // 选择的 1或者3
285
287
  if (taxRate === 1 || taxRate === 3) {
@@ -287,17 +289,19 @@ function dutyFree(controller: InvoiceController, taxRate: number, form: WrappedF
287
289
  if (cache[record.$index]) {
288
290
  return taxRate;
289
291
  } else {
290
- cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark, }
292
+ cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark,taxFreeType:record.taxFreeType }
291
293
  record.favouredPolicyName = '免税';
292
- record.favouredPolicyMark = 1;
293
294
  record.taxRate = 0;
295
+ record.favouredPolicyMark = 1;
296
+ record.taxFreeType = 1 as any;
294
297
  form.setFieldsValue({ taxRate: 0 });
295
298
  return 0;
296
299
  }
297
300
  } else {
298
301
  if (cache[record.$index] && cache[record.$index] !== true) {
299
302
  record.favouredPolicyName = cache[record.$index].favouredPolicyName;
300
- record.favouredPolicyName = cache[record.$index].favouredPolicyName;
303
+ record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
304
+ record.taxFreeType = cache[record.$index].taxFreeType;
301
305
  cache[record.$index] = true;
302
306
  }
303
307
  return taxRate;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Drawer, message, Table } from 'kts-components-antd-x3';
3
3
  import Invoice from '../../';
4
- import { updateUnitPriceExcludingTax, updateUnitPriceTax, format15 } from '../GoodsList/hook/useColumns/autoFillFn';
4
+ import { updateUnitPriceExcludingTax, updateUnitPriceTax, dutyFree, format15 } from '../GoodsList/hook/useColumns/autoFillFn';
5
5
  import { countAmountIncludeTax } from '../../tools/calculate'
6
6
  import { IGood } from '../../InvoiceController';
7
7
  import evaluate from '../../tools/evaluate';
@@ -64,7 +64,7 @@ const DrawerBody = () => {
64
64
  onRow={record => {
65
65
  return {
66
66
  onClick: () => {
67
- controller.pipeline(
67
+ controller.run(
68
68
  async s => {
69
69
  Object.keys(record).filter(e => !record[e] && record[e] !== 0).forEach(e => { delete record[e] });
70
70
 
@@ -82,6 +82,9 @@ const DrawerBody = () => {
82
82
  s.goodsListState.editGood = { ...s.goodsListState.editGood, ...record };
83
83
  if (!s.goodsListState.editGood) return;
84
84
 
85
+ if(s.goodsListState.editGood.taxRate)
86
+ s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, record)
87
+
85
88
  if (`${s.goodsListState.editGood.priceIncludeTax}` === '0') {
86
89
  s.goodsListState.editGood.priceIncludeTax = undefined;
87
90
  s.goodsListState.editGood.priceExcludeTax = undefined;
@@ -101,8 +104,8 @@ const DrawerBody = () => {
101
104
  ? updateUnitPriceExcludingTax(controller, s.goodsListState.form, record)
102
105
  : updateUnitPriceTax(controller, s.goodsListState.form, record)
103
106
  }
104
- )();
105
- },
107
+ )
108
+ }
106
109
  };
107
110
  }}
108
111
  />