kts-component-invoice-operate 3.2.9 → 3.2.10

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
@@ -17740,6 +17740,7 @@ var useAddDiscountRowButton$1 = (function () {
17740
17740
  while (1) {
17741
17741
  switch (_context.prev = _context.next) {
17742
17742
  case 0:
17743
+ // 不能给编辑状态的行增加折扣!
17743
17744
  isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
17744
17745
 
17745
17746
  if (!isOk) {
@@ -17772,6 +17773,7 @@ var useAddDiscountRowButton$1 = (function () {
17772
17773
  return _context.abrupt("return");
17773
17774
 
17774
17775
  case 7:
17776
+ // 不允许重复添加折扣
17775
17777
  isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
17776
17778
  var _s$goodsListState$goo2;
17777
17779
 
@@ -17790,43 +17792,61 @@ var useAddDiscountRowButton$1 = (function () {
17790
17792
  return _context.abrupt("return");
17791
17793
 
17792
17794
  case 11:
17795
+ if (!(areAllValuesEqual(s.goodsListState.selectedGoodIndex.map(function (e) {
17796
+ var _s$goodsListState$goo3;
17797
+
17798
+ return (_s$goodsListState$goo3 = s.goodsListState.goodsMap.get(e)) === null || _s$goodsListState$goo3 === void 0 ? void 0 : _s$goodsListState$goo3.taxRate;
17799
+ })) === false)) {
17800
+ _context.next = 14;
17801
+ break;
17802
+ }
17803
+
17804
+ message$1.error({
17805
+ content: '存在不同税率,不允许同时添加折扣',
17806
+ key: '存在不同税率,不允许同时添加折扣'
17807
+ });
17808
+ return _context.abrupt("return");
17809
+
17810
+ case 14:
17811
+ // 添加折扣时项目金额不能为空或零
17793
17812
  isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
17794
17813
  var good = s.goodsListState.goodsMap.get($index);
17795
- return !good || good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType;
17814
+ return "".concat(good === null || good === void 0 ? void 0 : good.lineAmountIncludeTax) === '0';
17796
17815
  });
17797
17816
 
17798
17817
  if (!isOk) {
17799
- _context.next = 15;
17818
+ _context.next = 18;
17800
17819
  break;
17801
17820
  }
17802
17821
 
17803
17822
  message$1.error({
17804
- content: '零税率需要设置免税类型,请在赋码中设置!',
17805
- key: '零税率需要设置免税类型,请在赋码中设置!'
17823
+ content: '添加折扣时项目金额不能为空或零',
17824
+ key: '添加折扣时项目金额不能为空或零'
17806
17825
  });
17807
17826
  return _context.abrupt("return");
17808
17827
 
17809
- case 15:
17828
+ case 18:
17829
+ // 零税率需要设置免税类型,请在赋码中设置!
17810
17830
  isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
17811
17831
  var good = s.goodsListState.goodsMap.get($index);
17812
- return "".concat(good === null || good === void 0 ? void 0 : good.lineAmountIncludeTax) === '0';
17832
+ return !good || good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType;
17813
17833
  });
17814
17834
 
17815
17835
  if (!isOk) {
17816
- _context.next = 19;
17836
+ _context.next = 22;
17817
17837
  break;
17818
17838
  }
17819
17839
 
17820
17840
  message$1.error({
17821
- content: '金额为0不能添加折扣行',
17822
- key: '金额为0不能添加折扣行'
17841
+ content: '零税率需要设置免税类型,请在赋码中设置!',
17842
+ key: '零税率需要设置免税类型,请在赋码中设置!'
17823
17843
  });
17824
17844
  return _context.abrupt("return");
17825
17845
 
17826
- case 19:
17846
+ case 22:
17827
17847
  s.goodsListState.discountGoodIndex = s.goodsListState.selectedGoodIndex.slice();
17828
17848
 
17829
- case 20:
17849
+ case 23:
17830
17850
  case "end":
17831
17851
  return _context.stop();
17832
17852
  }
@@ -18224,6 +18244,18 @@ function isContinuityNum(array) {
18224
18244
 
18225
18245
  return isContinuation;
18226
18246
  }
18247
+ /** 数组的值是否相等 */
18248
+
18249
+
18250
+ function areAllValuesEqual(arr) {
18251
+ for (var i = 1; i < arr.length; i++) {
18252
+ if (arr[i] !== arr[0]) {
18253
+ return false;
18254
+ }
18255
+ }
18256
+
18257
+ return true;
18258
+ }
18227
18259
 
18228
18260
  var useEndowCodeButton$1 = (function () {
18229
18261
  var controller = Invoice.useInvoiceController();
package/dist/index.js CHANGED
@@ -17750,6 +17750,7 @@ var useAddDiscountRowButton$1 = (function () {
17750
17750
  while (1) {
17751
17751
  switch (_context.prev = _context.next) {
17752
17752
  case 0:
17753
+ // 不能给编辑状态的行增加折扣!
17753
17754
  isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
17754
17755
 
17755
17756
  if (!isOk) {
@@ -17782,6 +17783,7 @@ var useAddDiscountRowButton$1 = (function () {
17782
17783
  return _context.abrupt("return");
17783
17784
 
17784
17785
  case 7:
17786
+ // 不允许重复添加折扣
17785
17787
  isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
17786
17788
  var _s$goodsListState$goo2;
17787
17789
 
@@ -17800,43 +17802,61 @@ var useAddDiscountRowButton$1 = (function () {
17800
17802
  return _context.abrupt("return");
17801
17803
 
17802
17804
  case 11:
17805
+ if (!(areAllValuesEqual(s.goodsListState.selectedGoodIndex.map(function (e) {
17806
+ var _s$goodsListState$goo3;
17807
+
17808
+ return (_s$goodsListState$goo3 = s.goodsListState.goodsMap.get(e)) === null || _s$goodsListState$goo3 === void 0 ? void 0 : _s$goodsListState$goo3.taxRate;
17809
+ })) === false)) {
17810
+ _context.next = 14;
17811
+ break;
17812
+ }
17813
+
17814
+ ktsXui.message.error({
17815
+ content: '存在不同税率,不允许同时添加折扣',
17816
+ key: '存在不同税率,不允许同时添加折扣'
17817
+ });
17818
+ return _context.abrupt("return");
17819
+
17820
+ case 14:
17821
+ // 添加折扣时项目金额不能为空或零
17803
17822
  isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
17804
17823
  var good = s.goodsListState.goodsMap.get($index);
17805
- return !good || good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType;
17824
+ return "".concat(good === null || good === void 0 ? void 0 : good.lineAmountIncludeTax) === '0';
17806
17825
  });
17807
17826
 
17808
17827
  if (!isOk) {
17809
- _context.next = 15;
17828
+ _context.next = 18;
17810
17829
  break;
17811
17830
  }
17812
17831
 
17813
17832
  ktsXui.message.error({
17814
- content: '零税率需要设置免税类型,请在赋码中设置!',
17815
- key: '零税率需要设置免税类型,请在赋码中设置!'
17833
+ content: '添加折扣时项目金额不能为空或零',
17834
+ key: '添加折扣时项目金额不能为空或零'
17816
17835
  });
17817
17836
  return _context.abrupt("return");
17818
17837
 
17819
- case 15:
17838
+ case 18:
17839
+ // 零税率需要设置免税类型,请在赋码中设置!
17820
17840
  isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
17821
17841
  var good = s.goodsListState.goodsMap.get($index);
17822
- return "".concat(good === null || good === void 0 ? void 0 : good.lineAmountIncludeTax) === '0';
17842
+ return !good || good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType;
17823
17843
  });
17824
17844
 
17825
17845
  if (!isOk) {
17826
- _context.next = 19;
17846
+ _context.next = 22;
17827
17847
  break;
17828
17848
  }
17829
17849
 
17830
17850
  ktsXui.message.error({
17831
- content: '金额为0不能添加折扣行',
17832
- key: '金额为0不能添加折扣行'
17851
+ content: '零税率需要设置免税类型,请在赋码中设置!',
17852
+ key: '零税率需要设置免税类型,请在赋码中设置!'
17833
17853
  });
17834
17854
  return _context.abrupt("return");
17835
17855
 
17836
- case 19:
17856
+ case 22:
17837
17857
  s.goodsListState.discountGoodIndex = s.goodsListState.selectedGoodIndex.slice();
17838
17858
 
17839
- case 20:
17859
+ case 23:
17840
17860
  case "end":
17841
17861
  return _context.stop();
17842
17862
  }
@@ -18234,6 +18254,18 @@ function isContinuityNum(array) {
18234
18254
 
18235
18255
  return isContinuation;
18236
18256
  }
18257
+ /** 数组的值是否相等 */
18258
+
18259
+
18260
+ function areAllValuesEqual(arr) {
18261
+ for (var i = 1; i < arr.length; i++) {
18262
+ if (arr[i] !== arr[0]) {
18263
+ return false;
18264
+ }
18265
+ }
18266
+
18267
+ return true;
18268
+ }
18237
18269
 
18238
18270
  var useEndowCodeButton$1 = (function () {
18239
18271
  var controller = Invoice.useInvoiceController();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.9",
3
+ "version": "3.2.10",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -2,4 +2,15 @@ import React from 'react';
2
2
  import Invoice from '../../..';
3
3
  import 'antd/dist/antd.css';
4
4
 
5
- export default () => <Invoice invoiceType='digtal' />;
5
+ export default () => {
6
+ return (
7
+ <Invoice
8
+ invoiceType='digtal'
9
+ invoiceHeader={
10
+ <Invoice.InvoiceHeader
11
+ title='自定义'
12
+ />
13
+ }
14
+ />
15
+ )
16
+ };
@@ -36,38 +36,49 @@ export default () => {
36
36
  await controller.wait();
37
37
  await controller.run(async s => {
38
38
 
39
+ // 不能给编辑状态的行增加折扣!
39
40
  let isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
40
41
  if (isOk) {
41
42
  message.error({ content: '不能给编辑状态的行增加折扣!', key: '不能给编辑状态的行增加折扣!' });
42
43
  return;
43
44
  }
44
45
 
46
+ // 项目不连续,不允许添加折扣
45
47
  if (!isContinuityNum(s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)?.serialNo || -2).sort((a, b) => a - b))) {
46
48
  message.error({ content: '项目不连续,不允许添加折扣', key: '项目不连续,不允许添加折扣' });
47
49
  return;
48
50
  }
49
51
 
52
+ // 不允许重复添加折扣
50
53
  isOk = s.goodsListState.selectedGoodIndex.some($index => s.goodsListState.goodsMap.get($index)?.lineAttribute !== LineAttributeType.正常)
51
54
  if (isOk) {
52
55
  message.error({ content: '不允许重复添加折扣', key: '不允许重复添加折扣' });
53
56
  return;
54
57
  }
55
58
 
59
+ // 存在不同税率,不允许同时添加折扣
60
+ if (areAllValuesEqual(s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)?.taxRate)) === false) {
61
+ message.error({ content: '存在不同税率,不允许同时添加折扣', key: '存在不同税率,不允许同时添加折扣' });
62
+ return;
63
+ }
64
+
65
+ // 添加折扣时项目金额不能为空或零
56
66
  isOk = s.goodsListState.selectedGoodIndex.some($index => {
57
67
  const good = s.goodsListState.goodsMap.get($index);
58
- return !good || (good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType)
68
+ return `${good?.lineAmountIncludeTax}` === '0'
59
69
  })
60
70
  if (isOk) {
61
- message.error({ content: '零税率需要设置免税类型,请在赋码中设置!', key: '零税率需要设置免税类型,请在赋码中设置!' });
71
+ message.error({ content: '添加折扣时项目金额不能为空或零', key: '添加折扣时项目金额不能为空或零' });
62
72
  return;
63
73
  }
64
74
 
75
+ // 零税率需要设置免税类型,请在赋码中设置!
65
76
  isOk = s.goodsListState.selectedGoodIndex.some($index => {
66
77
  const good = s.goodsListState.goodsMap.get($index);
67
- return `${good?.lineAmountIncludeTax}` === '0'
78
+ return !good || (good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType)
68
79
  })
69
80
  if (isOk) {
70
- message.error({ content: '金额为0不能添加折扣行', key: '金额为0不能添加折扣行' });
81
+ message.error({ content: '零税率需要设置免税类型,请在赋码中设置!', key: '零税率需要设置免税类型,请在赋码中设置!' });
71
82
  return;
72
83
  }
73
84
 
@@ -318,3 +329,12 @@ function isContinuityNum(array: number[]) {
318
329
  return isContinuation;
319
330
  }
320
331
 
332
+ /** 数组的值是否相等 */
333
+ function areAllValuesEqual(arr: any[]) {
334
+ for (let i = 1; i < arr.length; i++) {
335
+ if (arr[i] !== arr[0]) {
336
+ return false;
337
+ }
338
+ }
339
+ return true;
340
+ }