kts-component-invoice-operate 1.2.17 → 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
  // 是否处理过
@@ -8854,7 +8861,6 @@ function dutyFree(controller, taxRate, form, record) {
8854
8861
  }
8855
8862
  /** 含税 => 更新(不含税) */
8856
8863
 
8857
-
8858
8864
  var updateUnitPriceExcludingTax = function updateUnitPriceExcludingTax(controller, form, record) {
8859
8865
  form.validateFields( /*#__PURE__*/function () {
8860
8866
  var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(err, values) {
@@ -11362,7 +11368,7 @@ var DrawerBody$2 = function DrawerBody() {
11362
11368
  onRow: function onRow(record) {
11363
11369
  return {
11364
11370
  onClick: function onClick() {
11365
- controller.pipeline( /*#__PURE__*/function () {
11371
+ controller.run( /*#__PURE__*/function () {
11366
11372
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(s) {
11367
11373
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
11368
11374
  while (1) {
@@ -11412,6 +11418,8 @@ var DrawerBody$2 = function DrawerBody() {
11412
11418
  return _context2.abrupt("return");
11413
11419
 
11414
11420
  case 12:
11421
+ if (s.goodsListState.editGood.taxRate) s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, record);
11422
+
11415
11423
  if ("".concat(s.goodsListState.editGood.priceIncludeTax) === '0') {
11416
11424
  s.goodsListState.editGood.priceIncludeTax = undefined;
11417
11425
  s.goodsListState.editGood.priceExcludeTax = undefined;
@@ -11425,7 +11433,7 @@ var DrawerBody$2 = function DrawerBody() {
11425
11433
  s.goodsListState.importGoods.isVisibleDrawer = false;
11426
11434
  s.goodsListState.isTaxIncluded ? updateUnitPriceExcludingTax(controller, s.goodsListState.form) : updateUnitPriceTax(controller, s.goodsListState.form);
11427
11435
 
11428
- case 18:
11436
+ case 19:
11429
11437
  case "end":
11430
11438
  return _context2.stop();
11431
11439
  }
@@ -11436,7 +11444,7 @@ var DrawerBody$2 = function DrawerBody() {
11436
11444
  return function (_x2) {
11437
11445
  return _ref2.apply(this, arguments);
11438
11446
  };
11439
- }())();
11447
+ }());
11440
11448
  }
11441
11449
  };
11442
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
  // 是否处理过
@@ -8864,7 +8871,6 @@ function dutyFree(controller, taxRate, form, record) {
8864
8871
  }
8865
8872
  /** 含税 => 更新(不含税) */
8866
8873
 
8867
-
8868
8874
  var updateUnitPriceExcludingTax = function updateUnitPriceExcludingTax(controller, form, record) {
8869
8875
  form.validateFields( /*#__PURE__*/function () {
8870
8876
  var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(err, values) {
@@ -11372,7 +11378,7 @@ var DrawerBody$2 = function DrawerBody() {
11372
11378
  onRow: function onRow(record) {
11373
11379
  return {
11374
11380
  onClick: function onClick() {
11375
- controller.pipeline( /*#__PURE__*/function () {
11381
+ controller.run( /*#__PURE__*/function () {
11376
11382
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(s) {
11377
11383
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
11378
11384
  while (1) {
@@ -11422,6 +11428,8 @@ var DrawerBody$2 = function DrawerBody() {
11422
11428
  return _context2.abrupt("return");
11423
11429
 
11424
11430
  case 12:
11431
+ if (s.goodsListState.editGood.taxRate) s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, record);
11432
+
11425
11433
  if ("".concat(s.goodsListState.editGood.priceIncludeTax) === '0') {
11426
11434
  s.goodsListState.editGood.priceIncludeTax = undefined;
11427
11435
  s.goodsListState.editGood.priceExcludeTax = undefined;
@@ -11435,7 +11443,7 @@ var DrawerBody$2 = function DrawerBody() {
11435
11443
  s.goodsListState.importGoods.isVisibleDrawer = false;
11436
11444
  s.goodsListState.isTaxIncluded ? updateUnitPriceExcludingTax(controller, s.goodsListState.form) : updateUnitPriceTax(controller, s.goodsListState.form);
11437
11445
 
11438
- case 18:
11446
+ case 19:
11439
11447
  case "end":
11440
11448
  return _context2.stop();
11441
11449
  }
@@ -11446,7 +11454,7 @@ var DrawerBody$2 = function DrawerBody() {
11446
11454
  return function (_x2) {
11447
11455
  return _ref2.apply(this, arguments);
11448
11456
  };
11449
- }())();
11457
+ }());
11450
11458
  }
11451
11459
  };
11452
11460
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "1.2.17",
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) {
@@ -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
  />