kts-component-invoice-operate 3.2.61 → 3.2.62

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.
Files changed (19) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.d.ts +2 -1
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  3. package/dist/Invoice/tools/coolingFn/index.d.ts +1 -1
  4. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +1 -1
  5. package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.d.ts +6 -0
  6. package/dist/index.esm.js +211 -4
  7. package/dist/index.js +211 -4
  8. package/package.json +1 -1
  9. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +2 -1
  10. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +4 -1
  11. package/src/Invoice/_test/endowCode/index.tsx +54 -3
  12. package/src/Invoice/tools/coolingFn/index.ts +1 -1
  13. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +4 -0
  14. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +5 -1
  15. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +1 -1
  16. package/src/Invoice/ui/default/GoodsList/index.tsx +7 -0
  17. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.tsx +104 -0
  18. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +8 -1
  19. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +0 -2
@@ -1,6 +1,7 @@
1
1
  declare enum LineAttributeType {
2
2
  正常 = 0,
3
3
  折扣行 = 1,
4
- 被折扣行 = 2
4
+ 被折扣行 = 2,
5
+ 折让行 = 3
5
6
  }
6
7
  export default LineAttributeType;
@@ -70,6 +70,8 @@ export default class GoodsListState {
70
70
  isMergeDetails: boolean;
71
71
  /** 是否可以合并折扣 */
72
72
  isMergeDiscount: boolean;
73
+ /** 是否可以销售折让 */
74
+ isSalesDiscount: boolean;
73
75
  /** 正在 添加商品对照 的货物 */
74
76
  addComparisonIndex?: string;
75
77
  /** 商品拖拽数据 */
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * 有冷却时间的函数
3
- * @param fn 方法
4
3
  * @param key 方法key
5
4
  * @param delayed 冷却时间
5
+ * @param fn 方法
6
6
  */
7
7
  declare const _default: (key: string | undefined, delayed: number | undefined, fn: Function) => void;
8
8
  export default _default;
@@ -3,5 +3,5 @@ declare const _default: (goods: IGood) => {
3
3
  key: string;
4
4
  title: string;
5
5
  onClick: () => Promise<void>;
6
- };
6
+ } | undefined;
7
7
  export default _default;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ /** 销售折让 */
3
+ export default function uaeSalesDiscount(): {
4
+ /** 按钮 */
5
+ button: JSX.Element;
6
+ };
package/dist/index.esm.js CHANGED
@@ -916,6 +916,7 @@ var LineAttributeType;
916
916
  LineAttributeType[LineAttributeType["\u6B63\u5E38"] = 0] = "\u6B63\u5E38";
917
917
  LineAttributeType[LineAttributeType["\u6298\u6263\u884C"] = 1] = "\u6298\u6263\u884C";
918
918
  LineAttributeType[LineAttributeType["\u88AB\u6298\u6263\u884C"] = 2] = "\u88AB\u6298\u6263\u884C";
919
+ LineAttributeType[LineAttributeType["\u6298\u8BA9\u884C"] = 3] = "\u6298\u8BA9\u884C";
919
920
  })(LineAttributeType || (LineAttributeType = {}));
920
921
 
921
922
  var LineAttributeType$1 = LineAttributeType;
@@ -1029,6 +1030,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1029
1030
  this.isVisibleDrawer = false;
1030
1031
  this.isMergeDetails = false;
1031
1032
  this.isMergeDiscount = false;
1033
+ this.isSalesDiscount = false;
1032
1034
  this.addComparisonIndex = void 0;
1033
1035
  this.drag = new Drag();
1034
1036
  });
@@ -10248,6 +10250,10 @@ var useDelItem = (function (goods) {
10248
10250
  controller.delGood(goods.$index);
10249
10251
  }, [controller, goods.$index]);
10250
10252
 
10253
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10254
+ return undefined;
10255
+ }
10256
+
10251
10257
  if (goods.lineAttribute === LineAttributeType$1.被折扣行) {
10252
10258
  return undefined;
10253
10259
  }
@@ -10435,6 +10441,11 @@ var useEndowCode = (function (goods) {
10435
10441
  }
10436
10442
  }, _callee);
10437
10443
  })), [controller, goods]);
10444
+
10445
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10446
+ return undefined;
10447
+ }
10448
+
10438
10449
  return {
10439
10450
  key: 'endowCode',
10440
10451
  title: '赋码',
@@ -13843,7 +13854,7 @@ var useRowSelection = (function () {
13843
13854
  case 0:
13844
13855
  s.goodsListState.selectedGoodIndex.forEach(function ($index) {
13845
13856
  var goods = s.goodsListState.goodsMap.get($index);
13846
- if (!goods || goods.lineAttribute === LineAttributeType$1.正常) return; // 数组位置
13857
+ if (!goods || goods.lineAttribute !== LineAttributeType$1.折扣行 && goods.lineAttribute !== LineAttributeType$1.被折扣行) return; // 数组位置
13847
13858
 
13848
13859
  var t = s.goodsListState.goodsList.indexOf(goods);
13849
13860
  goods.lineAttribute === LineAttributeType$1.折扣行 ? t-- : t++;
@@ -13900,9 +13911,9 @@ styleInject(css_248z$a);
13900
13911
  var keys$1 = {};
13901
13912
  /**
13902
13913
  * 有冷却时间的函数
13903
- * @param fn 方法
13904
13914
  * @param key 方法key
13905
13915
  * @param delayed 冷却时间
13916
+ * @param fn 方法
13906
13917
  */
13907
13918
 
13908
13919
  var coolingFn = (function () {
@@ -13978,10 +13989,25 @@ var useEndowCodeButton = (function () {
13978
13989
  return _context.abrupt("return");
13979
13990
 
13980
13991
  case 6:
13992
+ if (!(s.goodsListState.selectedGoodIndex.map(function (e) {
13993
+ return s.goodsListState.goodsMap.get(e);
13994
+ }).every(function (e) {
13995
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
13996
+ }) === false)) {
13997
+ _context.next = 9;
13998
+ break;
13999
+ }
14000
+
14001
+ coolingFn('折让行不能赋码', 3000, function () {
14002
+ message.error('折让行不能赋码');
14003
+ });
14004
+ return _context.abrupt("return");
14005
+
14006
+ case 9:
13981
14007
  // 设置赋码
13982
14008
  s.goodsListState.endowCode.endowcodeGoodIndex = s.goodsListState.selectedGoodIndex;
13983
14009
 
13984
- case 7:
14010
+ case 10:
13985
14011
  case "end":
13986
14012
  return _context.stop();
13987
14013
  }
@@ -14597,6 +14623,184 @@ function useMergeDiscount() {
14597
14623
  };
14598
14624
  }
14599
14625
 
14626
+ /** 销售折让 */
14627
+
14628
+ function uaeSalesDiscount() {
14629
+ var controller = Invoice.useInvoiceController();
14630
+ var selectedGoodIndex = controller.useMemo(function (s) {
14631
+ return s.goodsListState.selectedGoodIndex;
14632
+ }, []);
14633
+ var goodsMap = controller.useMemo(function (s) {
14634
+ return s.goodsListState.goodsMap;
14635
+ }, []);
14636
+ var isSalesDiscount = controller.useMemo(function (s) {
14637
+ return s.goodsListState.isSalesDiscount;
14638
+ }, []);
14639
+ var onClick = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
14640
+ var selectedGood, concession, content, discountGood, totalDiscoline, discolinesSum, totalAmount, discolines, surplus, i;
14641
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
14642
+ while (1) {
14643
+ switch (_context3.prev = _context3.next) {
14644
+ case 0:
14645
+ selectedGood = selectedGoodIndex.map(function (e) {
14646
+ return goodsMap.get(e);
14647
+ });
14648
+ /** 折让行 */
14649
+
14650
+ concession = selectedGood.filter(function (e) {
14651
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折让行;
14652
+ })[0];
14653
+
14654
+ if (concession) {
14655
+ _context3.next = 6;
14656
+ break;
14657
+ }
14658
+
14659
+ content = '未选择折让行';
14660
+ message.error({
14661
+ content: content,
14662
+ key: content
14663
+ });
14664
+ return _context3.abrupt("return");
14665
+
14666
+ case 6:
14667
+ /** 准备添加折扣的货物列表 */
14668
+ discountGood = selectedGood.filter(function (e) {
14669
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
14670
+ });
14671
+ /** 折扣总金额 */
14672
+
14673
+ totalDiscoline = chain$1(bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
14674
+ discolinesSum = chain$1(bignumber(0));
14675
+ /** 总金额 */
14676
+
14677
+ totalAmount = function () {
14678
+ var sum = 0;
14679
+ discountGood.forEach(function (e) {
14680
+ var _e$lineAmountIncludeT;
14681
+
14682
+ sum += (_e$lineAmountIncludeT = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT !== void 0 ? _e$lineAmountIncludeT : 0;
14683
+ });
14684
+ return sum;
14685
+ }(); // 每行的折扣金额
14686
+
14687
+
14688
+ discolines = discountGood.map(function (e, i) {
14689
+ var _e$lineAmountIncludeT2;
14690
+
14691
+ // 折扣金额占比
14692
+ var share = chain$1(bignumber((_e$lineAmountIncludeT2 = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT2 !== void 0 ? _e$lineAmountIncludeT2 : 0)).divide(bignumber(totalAmount)); // 折扣金额
14693
+
14694
+ var value = totalDiscoline.multiply(share.done()).multiply(bignumber(100)).round().divide(bignumber(100)).done();
14695
+ discolinesSum = discolinesSum.add(value);
14696
+ return value.toNumber();
14697
+ }); // 剩余折扣金额
14698
+
14699
+ surplus = totalDiscoline.subtract(discolinesSum.done()); // 补充剩余折扣金
14700
+
14701
+ i = 0;
14702
+
14703
+ case 13:
14704
+ if (!(i < discolines.length)) {
14705
+ _context3.next = 21;
14706
+ break;
14707
+ }
14708
+
14709
+ if (!surplus.smaller(0.01).done()) {
14710
+ _context3.next = 16;
14711
+ break;
14712
+ }
14713
+
14714
+ return _context3.abrupt("break", 21);
14715
+
14716
+ case 16:
14717
+ discolines[i] = chain$1(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
14718
+ surplus = surplus.subtract(bignumber(0.01));
14719
+
14720
+ case 18:
14721
+ i++;
14722
+ _context3.next = 13;
14723
+ break;
14724
+
14725
+ case 21:
14726
+ _context3.next = 23;
14727
+ return controller.run( /*#__PURE__*/function () {
14728
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
14729
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14730
+ while (1) {
14731
+ switch (_context.prev = _context.next) {
14732
+ case 0:
14733
+ s.goodsListState.goodsList = s.goodsListState.goodsList.filter(function (e) {
14734
+ return e.$index !== concession.$index;
14735
+ });
14736
+
14737
+ case 1:
14738
+ case "end":
14739
+ return _context.stop();
14740
+ }
14741
+ }
14742
+ }, _callee);
14743
+ }));
14744
+
14745
+ return function (_x) {
14746
+ return _ref2.apply(this, arguments);
14747
+ };
14748
+ }());
14749
+
14750
+ case 23:
14751
+ _context3.next = 25;
14752
+ return controller.run( /*#__PURE__*/function () {
14753
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
14754
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14755
+ while (1) {
14756
+ switch (_context2.prev = _context2.next) {
14757
+ case 0:
14758
+ s.goodsListState.selectedGoodIndex = [];
14759
+
14760
+ case 1:
14761
+ case "end":
14762
+ return _context2.stop();
14763
+ }
14764
+ }
14765
+ }, _callee2);
14766
+ }));
14767
+
14768
+ return function (_x2) {
14769
+ return _ref3.apply(this, arguments);
14770
+ };
14771
+ }());
14772
+
14773
+ case 25:
14774
+ _context3.next = 27;
14775
+ return controller.addGoodDiscountV2(discolines.map(function (e, i) {
14776
+ var _discountGood$i;
14777
+
14778
+ return {
14779
+ $index: (_discountGood$i = discountGood[i]) === null || _discountGood$i === void 0 ? void 0 : _discountGood$i.$index,
14780
+ discolineAmountunt: e
14781
+ };
14782
+ }));
14783
+
14784
+ case 27:
14785
+ case "end":
14786
+ return _context3.stop();
14787
+ }
14788
+ }
14789
+ }, _callee3);
14790
+ })), [controller, selectedGoodIndex, goodsMap]);
14791
+ var button = React.useMemo(function () {
14792
+ if (!isSalesDiscount) return React.createElement(React.Fragment, null);
14793
+ return React.createElement(Button, {
14794
+ onClick: onClick,
14795
+ disabled: selectedGoodIndex.length <= 1
14796
+ }, "\u9500\u552E\u6298\u8BA9");
14797
+ }, [selectedGoodIndex.length, isSalesDiscount]);
14798
+ return {
14799
+ /** 按钮 */
14800
+ button: button
14801
+ };
14802
+ }
14803
+
14600
14804
  var GoodsList = /*#__PURE__*/function (_React$Component) {
14601
14805
  _inherits(GoodsList, _React$Component);
14602
14806
 
@@ -14659,6 +14863,9 @@ var Main = decorator(Form.create())(function (props) {
14659
14863
  /** 全单合并折扣 */
14660
14864
 
14661
14865
  var mergeDiscount = useMergeDiscount();
14866
+ /** 销售折让 */
14867
+
14868
+ var salesDiscount = uaeSalesDiscount();
14662
14869
  /** 清空自动赋码缓存 */
14663
14870
 
14664
14871
  React.useEffect(function () {
@@ -14816,7 +15023,7 @@ var Main = decorator(Form.create())(function (props) {
14816
15023
  className: "kts-invoice-operate-goods-list-able"
14817
15024
  }, React.createElement("div", {
14818
15025
  className: "kts-invoice-operate-goods-list-able-list"
14819
- }, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, React.createElement(Search, null)), React.createElement("div", {
15026
+ }, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, React.createElement(Search, null)), React.createElement("div", {
14820
15027
  className: "kts-invoice-operate-goods-list-able-extend"
14821
15028
  }, props.menuExpansion, React.createElement(DescribeSwitch, null), React.createElement(TaxIncludedSwitch, null))), React.createElement("div", {
14822
15029
  className: classNames('kts-invoice-operate-goods-list-table', {
package/dist/index.js CHANGED
@@ -926,6 +926,7 @@ var LineAttributeType;
926
926
  LineAttributeType[LineAttributeType["\u6B63\u5E38"] = 0] = "\u6B63\u5E38";
927
927
  LineAttributeType[LineAttributeType["\u6298\u6263\u884C"] = 1] = "\u6298\u6263\u884C";
928
928
  LineAttributeType[LineAttributeType["\u88AB\u6298\u6263\u884C"] = 2] = "\u88AB\u6298\u6263\u884C";
929
+ LineAttributeType[LineAttributeType["\u6298\u8BA9\u884C"] = 3] = "\u6298\u8BA9\u884C";
929
930
  })(LineAttributeType || (LineAttributeType = {}));
930
931
 
931
932
  var LineAttributeType$1 = LineAttributeType;
@@ -1039,6 +1040,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1039
1040
  this.isVisibleDrawer = false;
1040
1041
  this.isMergeDetails = false;
1041
1042
  this.isMergeDiscount = false;
1043
+ this.isSalesDiscount = false;
1042
1044
  this.addComparisonIndex = void 0;
1043
1045
  this.drag = new Drag();
1044
1046
  });
@@ -10258,6 +10260,10 @@ var useDelItem = (function (goods) {
10258
10260
  controller.delGood(goods.$index);
10259
10261
  }, [controller, goods.$index]);
10260
10262
 
10263
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10264
+ return undefined;
10265
+ }
10266
+
10261
10267
  if (goods.lineAttribute === LineAttributeType$1.被折扣行) {
10262
10268
  return undefined;
10263
10269
  }
@@ -10445,6 +10451,11 @@ var useEndowCode = (function (goods) {
10445
10451
  }
10446
10452
  }, _callee);
10447
10453
  })), [controller, goods]);
10454
+
10455
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10456
+ return undefined;
10457
+ }
10458
+
10448
10459
  return {
10449
10460
  key: 'endowCode',
10450
10461
  title: '赋码',
@@ -13853,7 +13864,7 @@ var useRowSelection = (function () {
13853
13864
  case 0:
13854
13865
  s.goodsListState.selectedGoodIndex.forEach(function ($index) {
13855
13866
  var goods = s.goodsListState.goodsMap.get($index);
13856
- if (!goods || goods.lineAttribute === LineAttributeType$1.正常) return; // 数组位置
13867
+ if (!goods || goods.lineAttribute !== LineAttributeType$1.折扣行 && goods.lineAttribute !== LineAttributeType$1.被折扣行) return; // 数组位置
13857
13868
 
13858
13869
  var t = s.goodsListState.goodsList.indexOf(goods);
13859
13870
  goods.lineAttribute === LineAttributeType$1.折扣行 ? t-- : t++;
@@ -13910,9 +13921,9 @@ styleInject(css_248z$a);
13910
13921
  var keys$1 = {};
13911
13922
  /**
13912
13923
  * 有冷却时间的函数
13913
- * @param fn 方法
13914
13924
  * @param key 方法key
13915
13925
  * @param delayed 冷却时间
13926
+ * @param fn 方法
13916
13927
  */
13917
13928
 
13918
13929
  var coolingFn = (function () {
@@ -13988,10 +13999,25 @@ var useEndowCodeButton = (function () {
13988
13999
  return _context.abrupt("return");
13989
14000
 
13990
14001
  case 6:
14002
+ if (!(s.goodsListState.selectedGoodIndex.map(function (e) {
14003
+ return s.goodsListState.goodsMap.get(e);
14004
+ }).every(function (e) {
14005
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
14006
+ }) === false)) {
14007
+ _context.next = 9;
14008
+ break;
14009
+ }
14010
+
14011
+ coolingFn('折让行不能赋码', 3000, function () {
14012
+ ktsComponentsAntdX3.message.error('折让行不能赋码');
14013
+ });
14014
+ return _context.abrupt("return");
14015
+
14016
+ case 9:
13991
14017
  // 设置赋码
13992
14018
  s.goodsListState.endowCode.endowcodeGoodIndex = s.goodsListState.selectedGoodIndex;
13993
14019
 
13994
- case 7:
14020
+ case 10:
13995
14021
  case "end":
13996
14022
  return _context.stop();
13997
14023
  }
@@ -14607,6 +14633,184 @@ function useMergeDiscount() {
14607
14633
  };
14608
14634
  }
14609
14635
 
14636
+ /** 销售折让 */
14637
+
14638
+ function uaeSalesDiscount() {
14639
+ var controller = Invoice.useInvoiceController();
14640
+ var selectedGoodIndex = controller.useMemo(function (s) {
14641
+ return s.goodsListState.selectedGoodIndex;
14642
+ }, []);
14643
+ var goodsMap = controller.useMemo(function (s) {
14644
+ return s.goodsListState.goodsMap;
14645
+ }, []);
14646
+ var isSalesDiscount = controller.useMemo(function (s) {
14647
+ return s.goodsListState.isSalesDiscount;
14648
+ }, []);
14649
+ var onClick = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
14650
+ var selectedGood, concession, content, discountGood, totalDiscoline, discolinesSum, totalAmount, discolines, surplus, i;
14651
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
14652
+ while (1) {
14653
+ switch (_context3.prev = _context3.next) {
14654
+ case 0:
14655
+ selectedGood = selectedGoodIndex.map(function (e) {
14656
+ return goodsMap.get(e);
14657
+ });
14658
+ /** 折让行 */
14659
+
14660
+ concession = selectedGood.filter(function (e) {
14661
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折让行;
14662
+ })[0];
14663
+
14664
+ if (concession) {
14665
+ _context3.next = 6;
14666
+ break;
14667
+ }
14668
+
14669
+ content = '未选择折让行';
14670
+ ktsComponentsAntdX3.message.error({
14671
+ content: content,
14672
+ key: content
14673
+ });
14674
+ return _context3.abrupt("return");
14675
+
14676
+ case 6:
14677
+ /** 准备添加折扣的货物列表 */
14678
+ discountGood = selectedGood.filter(function (e) {
14679
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
14680
+ });
14681
+ /** 折扣总金额 */
14682
+
14683
+ totalDiscoline = mathjs.chain(mathjs.bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
14684
+ discolinesSum = mathjs.chain(mathjs.bignumber(0));
14685
+ /** 总金额 */
14686
+
14687
+ totalAmount = function () {
14688
+ var sum = 0;
14689
+ discountGood.forEach(function (e) {
14690
+ var _e$lineAmountIncludeT;
14691
+
14692
+ sum += (_e$lineAmountIncludeT = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT !== void 0 ? _e$lineAmountIncludeT : 0;
14693
+ });
14694
+ return sum;
14695
+ }(); // 每行的折扣金额
14696
+
14697
+
14698
+ discolines = discountGood.map(function (e, i) {
14699
+ var _e$lineAmountIncludeT2;
14700
+
14701
+ // 折扣金额占比
14702
+ var share = mathjs.chain(mathjs.bignumber((_e$lineAmountIncludeT2 = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT2 !== void 0 ? _e$lineAmountIncludeT2 : 0)).divide(mathjs.bignumber(totalAmount)); // 折扣金额
14703
+
14704
+ var value = totalDiscoline.multiply(share.done()).multiply(mathjs.bignumber(100)).round().divide(mathjs.bignumber(100)).done();
14705
+ discolinesSum = discolinesSum.add(value);
14706
+ return value.toNumber();
14707
+ }); // 剩余折扣金额
14708
+
14709
+ surplus = totalDiscoline.subtract(discolinesSum.done()); // 补充剩余折扣金
14710
+
14711
+ i = 0;
14712
+
14713
+ case 13:
14714
+ if (!(i < discolines.length)) {
14715
+ _context3.next = 21;
14716
+ break;
14717
+ }
14718
+
14719
+ if (!surplus.smaller(0.01).done()) {
14720
+ _context3.next = 16;
14721
+ break;
14722
+ }
14723
+
14724
+ return _context3.abrupt("break", 21);
14725
+
14726
+ case 16:
14727
+ discolines[i] = mathjs.chain(mathjs.bignumber(discolines[i])).add(mathjs.bignumber(0.01)).done().toNumber();
14728
+ surplus = surplus.subtract(mathjs.bignumber(0.01));
14729
+
14730
+ case 18:
14731
+ i++;
14732
+ _context3.next = 13;
14733
+ break;
14734
+
14735
+ case 21:
14736
+ _context3.next = 23;
14737
+ return controller.run( /*#__PURE__*/function () {
14738
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
14739
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14740
+ while (1) {
14741
+ switch (_context.prev = _context.next) {
14742
+ case 0:
14743
+ s.goodsListState.goodsList = s.goodsListState.goodsList.filter(function (e) {
14744
+ return e.$index !== concession.$index;
14745
+ });
14746
+
14747
+ case 1:
14748
+ case "end":
14749
+ return _context.stop();
14750
+ }
14751
+ }
14752
+ }, _callee);
14753
+ }));
14754
+
14755
+ return function (_x) {
14756
+ return _ref2.apply(this, arguments);
14757
+ };
14758
+ }());
14759
+
14760
+ case 23:
14761
+ _context3.next = 25;
14762
+ return controller.run( /*#__PURE__*/function () {
14763
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
14764
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14765
+ while (1) {
14766
+ switch (_context2.prev = _context2.next) {
14767
+ case 0:
14768
+ s.goodsListState.selectedGoodIndex = [];
14769
+
14770
+ case 1:
14771
+ case "end":
14772
+ return _context2.stop();
14773
+ }
14774
+ }
14775
+ }, _callee2);
14776
+ }));
14777
+
14778
+ return function (_x2) {
14779
+ return _ref3.apply(this, arguments);
14780
+ };
14781
+ }());
14782
+
14783
+ case 25:
14784
+ _context3.next = 27;
14785
+ return controller.addGoodDiscountV2(discolines.map(function (e, i) {
14786
+ var _discountGood$i;
14787
+
14788
+ return {
14789
+ $index: (_discountGood$i = discountGood[i]) === null || _discountGood$i === void 0 ? void 0 : _discountGood$i.$index,
14790
+ discolineAmountunt: e
14791
+ };
14792
+ }));
14793
+
14794
+ case 27:
14795
+ case "end":
14796
+ return _context3.stop();
14797
+ }
14798
+ }
14799
+ }, _callee3);
14800
+ })), [controller, selectedGoodIndex, goodsMap]);
14801
+ var button = React__default['default'].useMemo(function () {
14802
+ if (!isSalesDiscount) return React__default['default'].createElement(React__default['default'].Fragment, null);
14803
+ return React__default['default'].createElement(ktsComponentsAntdX3.Button, {
14804
+ onClick: onClick,
14805
+ disabled: selectedGoodIndex.length <= 1
14806
+ }, "\u9500\u552E\u6298\u8BA9");
14807
+ }, [selectedGoodIndex.length, isSalesDiscount]);
14808
+ return {
14809
+ /** 按钮 */
14810
+ button: button
14811
+ };
14812
+ }
14813
+
14610
14814
  var GoodsList = /*#__PURE__*/function (_React$Component) {
14611
14815
  _inherits(GoodsList, _React$Component);
14612
14816
 
@@ -14669,6 +14873,9 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
14669
14873
  /** 全单合并折扣 */
14670
14874
 
14671
14875
  var mergeDiscount = useMergeDiscount();
14876
+ /** 销售折让 */
14877
+
14878
+ var salesDiscount = uaeSalesDiscount();
14672
14879
  /** 清空自动赋码缓存 */
14673
14880
 
14674
14881
  React__default['default'].useEffect(function () {
@@ -14826,7 +15033,7 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
14826
15033
  className: "kts-invoice-operate-goods-list-able"
14827
15034
  }, React__default['default'].createElement("div", {
14828
15035
  className: "kts-invoice-operate-goods-list-able-list"
14829
- }, React__default['default'].createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, React__default['default'].createElement(Search, null)), React__default['default'].createElement("div", {
15036
+ }, React__default['default'].createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, React__default['default'].createElement(Search, null)), React__default['default'].createElement("div", {
14830
15037
  className: "kts-invoice-operate-goods-list-able-extend"
14831
15038
  }, props.menuExpansion, React__default['default'].createElement(DescribeSwitch, null), React__default['default'].createElement(TaxIncludedSwitch, null))), React__default['default'].createElement("div", {
14832
15039
  className: classNames__default['default']('kts-invoice-operate-goods-list-table', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.61",
3
+ "version": "3.2.62",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -1,6 +1,7 @@
1
1
  enum LineAttributeType {
2
2
  正常 = 0,
3
3
  折扣行 = 1,
4
- 被折扣行 = 2
4
+ 被折扣行 = 2,
5
+ 折让行 = 3,
5
6
  }
6
7
  export default LineAttributeType;
@@ -43,7 +43,7 @@ export default class GoodsListState {
43
43
  columnsReplenish: { [key: string]: IColumnsReplenish } = {};
44
44
 
45
45
  /** 商品表格隐藏列 */
46
- columnshide:string[] = ['itemCode'];
46
+ columnshide: string[] = ['itemCode'];
47
47
 
48
48
  /** 单位列表 */
49
49
  unitList: string[] = [];
@@ -99,6 +99,9 @@ export default class GoodsListState {
99
99
  /** 是否可以合并折扣 */
100
100
  isMergeDiscount = false;
101
101
 
102
+ /** 是否可以销售折让 */
103
+ isSalesDiscount = false;
104
+
102
105
  /** 正在 添加商品对照 的货物 */
103
106
  addComparisonIndex?: string;
104
107
 
@@ -53,7 +53,7 @@ export default () => {
53
53
  <Switch checkedChildren="预制" unCheckedChildren="默认" onChange={e => { e ? setController(controller2) : setController(controller1) }} ></Switch>
54
54
  <Button onClick={controller.pipeline(async s => { s.goodsListState.endowCode.getReadOnlyTaxRate = s.goodsListState.endowCode.readOnlyTaxRateMap.DRAFT })} >税率(草稿)</Button>
55
55
  <Button onClick={controller.pipeline(async s => { s.goodsListState.endowCode.getReadOnlyTaxRate = () => true })} >税率(预制)</Button>
56
- <Invoice controller={controller} invoiceType='digtal' />
56
+ <Invoice controller={controller} />
57
57
  </div>
58
58
  );
59
59
  };
@@ -149,7 +149,7 @@ const lines: any[] = [
149
149
  "itemName": "*配电控制设备*公牛(BULL)",
150
150
  "lineAmountExcludeTax": 443365.88,
151
151
  "lineAmountIncludeTax": 501003.53,
152
- "lineAttribute": "2",
152
+ "lineAttribute": 0,
153
153
  "lineDiscountExcludeTax": 4433.66,
154
154
  "lineDiscountRate": null,
155
155
  "lineId": "1740823580142206976",
@@ -200,7 +200,7 @@ const lines: any[] = [
200
200
  "itemName": "*配电控制设备*公牛(BULL)",
201
201
  "lineAmountExcludeTax": -4433.66,
202
202
  "lineAmountIncludeTax": -5010.04,
203
- "lineAttribute": "1",
203
+ "lineAttribute": 0,
204
204
  "lineDiscountExcludeTax": null,
205
205
  "lineDiscountRate": null,
206
206
  "lineId": "1740823580142206976",
@@ -234,6 +234,57 @@ const lines: any[] = [
234
234
  "taxRate": 13,
235
235
  "unit": "",
236
236
  "zeroTaxRateFlag": null
237
+ },
238
+ {
239
+ "buyersItemCode": null,
240
+ "buyersItemModelName": "GN-G32Z104",
241
+ "buyersItemName": "打折",
242
+ "buyersItemUnit": null,
243
+ "discount": null,
244
+ "discountGroup": "31b6d887-4877-4926-abe8-ab49ef6902da",
245
+ "dispatchDocumentReference": null,
246
+ "dispatchLineReference": null,
247
+ "favouredPolicyMark": "0",
248
+ "favouredPolicyName": null,
249
+ "id": "40823568750477313",
250
+ "itemModelName": "",
251
+ "itemName": "打折",
252
+ "lineAmountExcludeTax": -100,
253
+ "lineAmountIncludeTax": -100,
254
+ "lineAttribute": 3,
255
+ "lineDiscountExcludeTax": null,
256
+ "lineDiscountRate": null,
257
+ "lineId": "1740823580142206976",
258
+ "lineOrder": 2,
259
+ "materialCode": null,
260
+ "noticeCodeNo": null,
261
+ "noticeLineId": null,
262
+ "orderLineId": null,
263
+ "orderLineReference": null,
264
+ "orderNo": null,
265
+ "orderReference": null,
266
+ "priceExcludeTax": null,
267
+ "priceIncludeTax": null,
268
+ "quantity": null,
269
+ "receiptDocumentReference": null,
270
+ "receiptLineReference": null,
271
+ "reconciliationDocumentReference": null,
272
+ "reconciliationSheetLineReference": null,
273
+ "relationReferences": null,
274
+ "requisitionLineNo": null,
275
+ "sellersItemCode": null,
276
+ "sellersItemModelName": null,
277
+ "sellersItemName": "*配电控制设备*1",
278
+ "sellersItemUnit": null,
279
+ "specialManagement": null,
280
+ "statementCode": null,
281
+ "statementLineId": null,
282
+ "taxAmount": -576.38,
283
+ "taxClassificationCode": "1090407030000000000",
284
+ "taxDiscount": null,
285
+ "taxRate": 0,
286
+ "unit": "",
287
+ "zeroTaxRateFlag": null
237
288
  }
238
289
  ]
239
290
 
@@ -4,9 +4,9 @@ const keys: { [key: string]: any } = {}
4
4
 
5
5
  /**
6
6
  * 有冷却时间的函数
7
- * @param fn 方法
8
7
  * @param key 方法key
9
8
  * @param delayed 冷却时间
9
+ * @param fn 方法
10
10
  */
11
11
  export default (key: string = 'default', delayed: number = 200, fn: Function) => {
12
12
  if (keys[key]) {
@@ -17,6 +17,10 @@ export default (goods: IGood) => {
17
17
  controller.delGood(goods.$index);
18
18
  }, [controller, goods.$index]);
19
19
 
20
+ if (goods.lineAttribute === LineAttributeType.折让行) {
21
+ return undefined;
22
+ }
23
+
20
24
  if (goods.lineAttribute === LineAttributeType.被折扣行) {
21
25
  return undefined;
22
26
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  // import { Button } from 'kts-components-antd-x3';
3
3
  import Invoice from '../../../../../../../../..';
4
- import { IGood } from '../../../../../../../../../InvoiceController';
4
+ import { IGood, LineAttributeType } from '../../../../../../../../../InvoiceController';
5
5
  import { endowCode } from '../../../../autoFillFn';
6
6
 
7
7
  // const { Text } = Typography;
@@ -14,6 +14,10 @@ export default (goods: IGood) => {
14
14
  endowCode(controller, goods);
15
15
  }, [controller, goods]);
16
16
 
17
+ if (goods.lineAttribute === LineAttributeType.折让行) {
18
+ return undefined;
19
+ }
20
+
17
21
  return {
18
22
  key: 'endowCode',
19
23
  title: '赋码',
@@ -84,7 +84,7 @@ export default () => {
84
84
  await controller.pipeline(async s => {
85
85
  s.goodsListState.selectedGoodIndex.forEach($index => {
86
86
  const goods = s.goodsListState.goodsMap.get($index);
87
- if (!goods || goods.lineAttribute === LineAttributeType.正常) return;
87
+ if (!goods || (goods.lineAttribute !== LineAttributeType.折扣行 && goods.lineAttribute !== LineAttributeType.被折扣行)) return;
88
88
 
89
89
  // 数组位置
90
90
  let t = s.goodsListState.goodsList.indexOf(goods);
@@ -29,6 +29,7 @@ import useDelRowButton from './ui/BulkMenu/hooks/useDelRowButton';
29
29
  import useAddDiscountRowButton from './ui/BulkMenu/hooks/useAddDiscountRowButton';
30
30
  import useMergeDetails from './ui/BulkMenu/hooks/useMergeDetails';
31
31
  import useMergeDiscount from './ui/BulkMenu/hooks/useMergeDiscount';
32
+ import uaeSalesDiscount from './ui/BulkMenu/hooks/uaeSalesDiscount';
32
33
 
33
34
  export interface IGoodsListProps {
34
35
  /** 扩展部分 */
@@ -91,6 +92,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
91
92
  /** 全单合并折扣 */
92
93
  const mergeDiscount = useMergeDiscount()
93
94
 
95
+ /** 销售折让 */
96
+ const salesDiscount = uaeSalesDiscount()
97
+
94
98
  /** 清空自动赋码缓存 */
95
99
  React.useEffect(() => {
96
100
  controller.run(async s => { s.goodsListState.endowCode.cache = {} });
@@ -149,6 +153,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
149
153
  {/* 添加折扣行 */}
150
154
  {addDiscountRowButton.drawer}
151
155
 
156
+ {/* 销售折让 */}
157
+ {salesDiscount.button}
158
+
152
159
  {/* 搜索 */}
153
160
  <Search />
154
161
  </div>
@@ -0,0 +1,104 @@
1
+
2
+ import React from "react"
3
+ import { Button, message } from "kts-components-antd-x3"
4
+ import { chain, bignumber } from 'mathjs';
5
+ import Invoice from '../../../../../../..'
6
+ import { LineAttributeType } from "../../../../../../../InvoiceController";
7
+
8
+ /** 销售折让 */
9
+ export default function uaeSalesDiscount() {
10
+
11
+ const controller = Invoice.useInvoiceController();
12
+
13
+ const selectedGoodIndex = controller.useMemo(s => s.goodsListState.selectedGoodIndex, []);
14
+
15
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
16
+
17
+ const isSalesDiscount = controller.useMemo(s => s.goodsListState.isSalesDiscount, []);
18
+
19
+ const onClick = React.useCallback(async () => {
20
+ const selectedGood = selectedGoodIndex.map(e => goodsMap.get(e));
21
+
22
+ /** 折让行 */
23
+ const concession = selectedGood.filter(e => e?.lineAttribute === LineAttributeType.折让行)[0];
24
+ if (!concession) {
25
+ const content = '未选择折让行';
26
+ message.error({ content, key: content })
27
+ return;
28
+ }
29
+
30
+ /** 准备添加折扣的货物列表 */
31
+ const discountGood = selectedGood.filter(e => e?.lineAttribute !== LineAttributeType.折让行);
32
+
33
+ /** 折扣总金额 */
34
+ const totalDiscoline = chain(bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
35
+
36
+ let discolinesSum = chain(bignumber(0));
37
+
38
+ /** 总金额 */
39
+ const totalAmount = (() => {
40
+ let sum = 0;
41
+ discountGood.forEach(e => { sum += e?.lineAmountIncludeTax ?? 0 });
42
+ return sum;
43
+ })()
44
+
45
+ // 每行的折扣金额
46
+ const discolines: number[] = discountGood.map((e, i) => {
47
+ // 折扣金额占比
48
+ const share = chain(bignumber(e?.lineAmountIncludeTax ?? 0))
49
+ .divide(bignumber(totalAmount));
50
+
51
+ // 折扣金额
52
+ const value = totalDiscoline
53
+ .multiply(share.done())
54
+
55
+ .multiply(bignumber(100))
56
+ .round()
57
+ .divide(bignumber(100))
58
+
59
+ .done();
60
+
61
+ discolinesSum = discolinesSum.add(value);
62
+ return value.toNumber();
63
+ });
64
+
65
+ // 剩余折扣金额
66
+ let surplus = totalDiscoline.subtract(discolinesSum.done());
67
+
68
+ // 补充剩余折扣金
69
+ for (let i = 0; i < discolines.length; i++) {
70
+ if (surplus.smaller(0.01).done()) break;
71
+ discolines[i] = chain(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
72
+ surplus = surplus.subtract(bignumber(0.01));
73
+ }
74
+
75
+ // 清楚折让行
76
+ await controller.run(async s => { s.goodsListState.goodsList = s.goodsListState.goodsList.filter(e => e.$index !== concession.$index) })
77
+ await controller.run(async s => { s.goodsListState.selectedGoodIndex = [] });
78
+
79
+ // 给一组货物添加折扣行
80
+ await controller.addGoodDiscountV2(discolines.map((e, i) => {
81
+ return {
82
+ $index: discountGood[i]?.$index as string,
83
+ discolineAmountunt: e as number,
84
+ }
85
+ }))
86
+ }, [controller, selectedGoodIndex, goodsMap])
87
+
88
+ const button = React.useMemo(() => {
89
+ if (!isSalesDiscount) return <></>;
90
+ return (
91
+ <Button
92
+ onClick={onClick}
93
+ disabled={selectedGoodIndex.length <= 1}
94
+ >
95
+ 销售折让
96
+ </Button>
97
+ )
98
+ }, [selectedGoodIndex.length, isSalesDiscount])
99
+
100
+ return {
101
+ /** 按钮 */
102
+ button,
103
+ }
104
+ }
@@ -2,9 +2,10 @@ import React from 'react';
2
2
  import Invoice from '../../../../../../..';
3
3
  import { message, Menu, Button } from 'kts-components-antd-x3';
4
4
  import coolingFn from '../../../../../../../tools/coolingFn';
5
+ import { LineAttributeType } from '../../../../../../../InvoiceController';
5
6
 
6
7
  export default () => {
7
-
8
+
8
9
  const controller = Invoice.useInvoiceController();
9
10
 
10
11
  const model = controller.useMemo(s => s.model, []);
@@ -31,6 +32,12 @@ export default () => {
31
32
  return;
32
33
  }
33
34
 
35
+ // 折让行 不能赋码
36
+ if (s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)).every(e => e?.lineAttribute !== LineAttributeType.折让行) === false) {
37
+ coolingFn('折让行不能赋码', 3000, () => { message.error('折让行不能赋码') });
38
+ return;
39
+ }
40
+
34
41
  // 设置赋码
35
42
  s.goodsListState.endowCode.endowcodeGoodIndex = s.goodsListState.selectedGoodIndex;
36
43
  })();
@@ -1,9 +1,7 @@
1
1
 
2
2
  import React from "react";
3
3
  import { chain, bignumber } from 'mathjs';
4
- import Icon from '@ant-design/icons';
5
4
  import { Button, Drawer, Form, InputNumber, Radio, message, Space } from "kts-xui";
6
- import { ReactComponent as AddSvg } from './svg/add.svg';
7
5
  import Invoice from "../../../../../../..";
8
6
  import { LineAttributeType } from "../../../../../../../InvoiceController";
9
7