kts-component-invoice-operate 3.2.61 → 3.2.63
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/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.d.ts +2 -1
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
- package/dist/Invoice/tools/coolingFn/index.d.ts +1 -1
- package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +1 -1
- package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.d.ts +6 -0
- package/dist/index.esm.js +227 -4
- package/dist/index.js +227 -4
- package/package.json +2 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +2 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +4 -1
- package/src/Invoice/_test/endowCode/index.tsx +54 -3
- package/src/Invoice/tools/coolingFn/index.ts +1 -1
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +4 -0
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +5 -1
- package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +1 -1
- package/src/Invoice/ui/default/GoodsList/index.tsx +7 -0
- package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.tsx +110 -0
- package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +8 -1
- package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +0 -2
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
|
|
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
|
|
14010
|
+
case 10:
|
|
13985
14011
|
case "end":
|
|
13986
14012
|
return _context.stop();
|
|
13987
14013
|
}
|
|
@@ -14597,6 +14623,200 @@ 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, content, concession, _content, discountGood, totalDiscoline, discolinesSum, totalAmount, discolines, surplus, i;
|
|
14641
|
+
|
|
14642
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
14643
|
+
while (1) {
|
|
14644
|
+
switch (_context3.prev = _context3.next) {
|
|
14645
|
+
case 0:
|
|
14646
|
+
selectedGood = selectedGoodIndex.map(function (e) {
|
|
14647
|
+
return goodsMap.get(e);
|
|
14648
|
+
});
|
|
14649
|
+
|
|
14650
|
+
if (!(selectedGood.filter(function (e) {
|
|
14651
|
+
return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折扣行 || (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.被折扣行;
|
|
14652
|
+
}).length > 0)) {
|
|
14653
|
+
_context3.next = 5;
|
|
14654
|
+
break;
|
|
14655
|
+
}
|
|
14656
|
+
|
|
14657
|
+
content = '不能选择折扣行和被折扣行';
|
|
14658
|
+
message.error({
|
|
14659
|
+
content: content,
|
|
14660
|
+
key: content
|
|
14661
|
+
});
|
|
14662
|
+
return _context3.abrupt("return");
|
|
14663
|
+
|
|
14664
|
+
case 5:
|
|
14665
|
+
/** 折让行 */
|
|
14666
|
+
concession = selectedGood.filter(function (e) {
|
|
14667
|
+
return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折让行;
|
|
14668
|
+
})[0];
|
|
14669
|
+
|
|
14670
|
+
if (concession) {
|
|
14671
|
+
_context3.next = 10;
|
|
14672
|
+
break;
|
|
14673
|
+
}
|
|
14674
|
+
|
|
14675
|
+
_content = '未选择折让行';
|
|
14676
|
+
message.error({
|
|
14677
|
+
content: _content,
|
|
14678
|
+
key: _content
|
|
14679
|
+
});
|
|
14680
|
+
return _context3.abrupt("return");
|
|
14681
|
+
|
|
14682
|
+
case 10:
|
|
14683
|
+
/** 准备添加折扣的货物列表 */
|
|
14684
|
+
discountGood = selectedGood.filter(function (e) {
|
|
14685
|
+
return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
|
|
14686
|
+
});
|
|
14687
|
+
/** 折扣总金额 */
|
|
14688
|
+
|
|
14689
|
+
totalDiscoline = chain$1(bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
|
|
14690
|
+
discolinesSum = chain$1(bignumber(0));
|
|
14691
|
+
/** 总金额 */
|
|
14692
|
+
|
|
14693
|
+
totalAmount = function () {
|
|
14694
|
+
var sum = 0;
|
|
14695
|
+
discountGood.forEach(function (e) {
|
|
14696
|
+
var _e$lineAmountIncludeT;
|
|
14697
|
+
|
|
14698
|
+
sum += (_e$lineAmountIncludeT = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT !== void 0 ? _e$lineAmountIncludeT : 0;
|
|
14699
|
+
});
|
|
14700
|
+
return sum;
|
|
14701
|
+
}(); // 每行的折扣金额
|
|
14702
|
+
|
|
14703
|
+
|
|
14704
|
+
discolines = discountGood.map(function (e, i) {
|
|
14705
|
+
var _e$lineAmountIncludeT2;
|
|
14706
|
+
|
|
14707
|
+
// 折扣金额占比
|
|
14708
|
+
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)); // 折扣金额
|
|
14709
|
+
|
|
14710
|
+
var value = totalDiscoline.multiply(share.done()).multiply(bignumber(100)).round().divide(bignumber(100)).done();
|
|
14711
|
+
discolinesSum = discolinesSum.add(value);
|
|
14712
|
+
return value.toNumber();
|
|
14713
|
+
}); // 剩余折扣金额
|
|
14714
|
+
|
|
14715
|
+
surplus = totalDiscoline.subtract(discolinesSum.done()); // 补充剩余折扣金
|
|
14716
|
+
|
|
14717
|
+
i = 0;
|
|
14718
|
+
|
|
14719
|
+
case 17:
|
|
14720
|
+
if (!(i < discolines.length)) {
|
|
14721
|
+
_context3.next = 25;
|
|
14722
|
+
break;
|
|
14723
|
+
}
|
|
14724
|
+
|
|
14725
|
+
if (!surplus.smaller(0.01).done()) {
|
|
14726
|
+
_context3.next = 20;
|
|
14727
|
+
break;
|
|
14728
|
+
}
|
|
14729
|
+
|
|
14730
|
+
return _context3.abrupt("break", 25);
|
|
14731
|
+
|
|
14732
|
+
case 20:
|
|
14733
|
+
discolines[i] = chain$1(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
|
|
14734
|
+
surplus = surplus.subtract(bignumber(0.01));
|
|
14735
|
+
|
|
14736
|
+
case 22:
|
|
14737
|
+
i++;
|
|
14738
|
+
_context3.next = 17;
|
|
14739
|
+
break;
|
|
14740
|
+
|
|
14741
|
+
case 25:
|
|
14742
|
+
_context3.next = 27;
|
|
14743
|
+
return controller.run( /*#__PURE__*/function () {
|
|
14744
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
|
|
14745
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14746
|
+
while (1) {
|
|
14747
|
+
switch (_context.prev = _context.next) {
|
|
14748
|
+
case 0:
|
|
14749
|
+
s.goodsListState.goodsList = s.goodsListState.goodsList.filter(function (e) {
|
|
14750
|
+
return e.$index !== concession.$index;
|
|
14751
|
+
});
|
|
14752
|
+
|
|
14753
|
+
case 1:
|
|
14754
|
+
case "end":
|
|
14755
|
+
return _context.stop();
|
|
14756
|
+
}
|
|
14757
|
+
}
|
|
14758
|
+
}, _callee);
|
|
14759
|
+
}));
|
|
14760
|
+
|
|
14761
|
+
return function (_x) {
|
|
14762
|
+
return _ref2.apply(this, arguments);
|
|
14763
|
+
};
|
|
14764
|
+
}());
|
|
14765
|
+
|
|
14766
|
+
case 27:
|
|
14767
|
+
_context3.next = 29;
|
|
14768
|
+
return controller.run( /*#__PURE__*/function () {
|
|
14769
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
|
|
14770
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
14771
|
+
while (1) {
|
|
14772
|
+
switch (_context2.prev = _context2.next) {
|
|
14773
|
+
case 0:
|
|
14774
|
+
s.goodsListState.selectedGoodIndex = [];
|
|
14775
|
+
|
|
14776
|
+
case 1:
|
|
14777
|
+
case "end":
|
|
14778
|
+
return _context2.stop();
|
|
14779
|
+
}
|
|
14780
|
+
}
|
|
14781
|
+
}, _callee2);
|
|
14782
|
+
}));
|
|
14783
|
+
|
|
14784
|
+
return function (_x2) {
|
|
14785
|
+
return _ref3.apply(this, arguments);
|
|
14786
|
+
};
|
|
14787
|
+
}());
|
|
14788
|
+
|
|
14789
|
+
case 29:
|
|
14790
|
+
_context3.next = 31;
|
|
14791
|
+
return controller.addGoodDiscountV2(discolines.map(function (e, i) {
|
|
14792
|
+
var _discountGood$i;
|
|
14793
|
+
|
|
14794
|
+
return {
|
|
14795
|
+
$index: (_discountGood$i = discountGood[i]) === null || _discountGood$i === void 0 ? void 0 : _discountGood$i.$index,
|
|
14796
|
+
discolineAmountunt: e
|
|
14797
|
+
};
|
|
14798
|
+
}));
|
|
14799
|
+
|
|
14800
|
+
case 31:
|
|
14801
|
+
case "end":
|
|
14802
|
+
return _context3.stop();
|
|
14803
|
+
}
|
|
14804
|
+
}
|
|
14805
|
+
}, _callee3);
|
|
14806
|
+
})), [controller, selectedGoodIndex, goodsMap]);
|
|
14807
|
+
var button = React.useMemo(function () {
|
|
14808
|
+
if (!isSalesDiscount) return React.createElement(React.Fragment, null);
|
|
14809
|
+
return React.createElement(Button, {
|
|
14810
|
+
onClick: onClick,
|
|
14811
|
+
disabled: selectedGoodIndex.length <= 1
|
|
14812
|
+
}, "\u9500\u552E\u6298\u8BA9");
|
|
14813
|
+
}, [selectedGoodIndex.length, isSalesDiscount]);
|
|
14814
|
+
return {
|
|
14815
|
+
/** 按钮 */
|
|
14816
|
+
button: button
|
|
14817
|
+
};
|
|
14818
|
+
}
|
|
14819
|
+
|
|
14600
14820
|
var GoodsList = /*#__PURE__*/function (_React$Component) {
|
|
14601
14821
|
_inherits(GoodsList, _React$Component);
|
|
14602
14822
|
|
|
@@ -14659,6 +14879,9 @@ var Main = decorator(Form.create())(function (props) {
|
|
|
14659
14879
|
/** 全单合并折扣 */
|
|
14660
14880
|
|
|
14661
14881
|
var mergeDiscount = useMergeDiscount();
|
|
14882
|
+
/** 销售折让 */
|
|
14883
|
+
|
|
14884
|
+
var salesDiscount = uaeSalesDiscount();
|
|
14662
14885
|
/** 清空自动赋码缓存 */
|
|
14663
14886
|
|
|
14664
14887
|
React.useEffect(function () {
|
|
@@ -14816,7 +15039,7 @@ var Main = decorator(Form.create())(function (props) {
|
|
|
14816
15039
|
className: "kts-invoice-operate-goods-list-able"
|
|
14817
15040
|
}, React.createElement("div", {
|
|
14818
15041
|
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", {
|
|
15042
|
+
}, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, React.createElement(Search, null)), React.createElement("div", {
|
|
14820
15043
|
className: "kts-invoice-operate-goods-list-able-extend"
|
|
14821
15044
|
}, props.menuExpansion, React.createElement(DescribeSwitch, null), React.createElement(TaxIncludedSwitch, null))), React.createElement("div", {
|
|
14822
15045
|
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
|
|
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
|
|
14020
|
+
case 10:
|
|
13995
14021
|
case "end":
|
|
13996
14022
|
return _context.stop();
|
|
13997
14023
|
}
|
|
@@ -14607,6 +14633,200 @@ 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, content, concession, _content, discountGood, totalDiscoline, discolinesSum, totalAmount, discolines, surplus, i;
|
|
14651
|
+
|
|
14652
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
14653
|
+
while (1) {
|
|
14654
|
+
switch (_context3.prev = _context3.next) {
|
|
14655
|
+
case 0:
|
|
14656
|
+
selectedGood = selectedGoodIndex.map(function (e) {
|
|
14657
|
+
return goodsMap.get(e);
|
|
14658
|
+
});
|
|
14659
|
+
|
|
14660
|
+
if (!(selectedGood.filter(function (e) {
|
|
14661
|
+
return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折扣行 || (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.被折扣行;
|
|
14662
|
+
}).length > 0)) {
|
|
14663
|
+
_context3.next = 5;
|
|
14664
|
+
break;
|
|
14665
|
+
}
|
|
14666
|
+
|
|
14667
|
+
content = '不能选择折扣行和被折扣行';
|
|
14668
|
+
ktsComponentsAntdX3.message.error({
|
|
14669
|
+
content: content,
|
|
14670
|
+
key: content
|
|
14671
|
+
});
|
|
14672
|
+
return _context3.abrupt("return");
|
|
14673
|
+
|
|
14674
|
+
case 5:
|
|
14675
|
+
/** 折让行 */
|
|
14676
|
+
concession = selectedGood.filter(function (e) {
|
|
14677
|
+
return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折让行;
|
|
14678
|
+
})[0];
|
|
14679
|
+
|
|
14680
|
+
if (concession) {
|
|
14681
|
+
_context3.next = 10;
|
|
14682
|
+
break;
|
|
14683
|
+
}
|
|
14684
|
+
|
|
14685
|
+
_content = '未选择折让行';
|
|
14686
|
+
ktsComponentsAntdX3.message.error({
|
|
14687
|
+
content: _content,
|
|
14688
|
+
key: _content
|
|
14689
|
+
});
|
|
14690
|
+
return _context3.abrupt("return");
|
|
14691
|
+
|
|
14692
|
+
case 10:
|
|
14693
|
+
/** 准备添加折扣的货物列表 */
|
|
14694
|
+
discountGood = selectedGood.filter(function (e) {
|
|
14695
|
+
return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
|
|
14696
|
+
});
|
|
14697
|
+
/** 折扣总金额 */
|
|
14698
|
+
|
|
14699
|
+
totalDiscoline = mathjs.chain(mathjs.bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
|
|
14700
|
+
discolinesSum = mathjs.chain(mathjs.bignumber(0));
|
|
14701
|
+
/** 总金额 */
|
|
14702
|
+
|
|
14703
|
+
totalAmount = function () {
|
|
14704
|
+
var sum = 0;
|
|
14705
|
+
discountGood.forEach(function (e) {
|
|
14706
|
+
var _e$lineAmountIncludeT;
|
|
14707
|
+
|
|
14708
|
+
sum += (_e$lineAmountIncludeT = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT !== void 0 ? _e$lineAmountIncludeT : 0;
|
|
14709
|
+
});
|
|
14710
|
+
return sum;
|
|
14711
|
+
}(); // 每行的折扣金额
|
|
14712
|
+
|
|
14713
|
+
|
|
14714
|
+
discolines = discountGood.map(function (e, i) {
|
|
14715
|
+
var _e$lineAmountIncludeT2;
|
|
14716
|
+
|
|
14717
|
+
// 折扣金额占比
|
|
14718
|
+
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)); // 折扣金额
|
|
14719
|
+
|
|
14720
|
+
var value = totalDiscoline.multiply(share.done()).multiply(mathjs.bignumber(100)).round().divide(mathjs.bignumber(100)).done();
|
|
14721
|
+
discolinesSum = discolinesSum.add(value);
|
|
14722
|
+
return value.toNumber();
|
|
14723
|
+
}); // 剩余折扣金额
|
|
14724
|
+
|
|
14725
|
+
surplus = totalDiscoline.subtract(discolinesSum.done()); // 补充剩余折扣金
|
|
14726
|
+
|
|
14727
|
+
i = 0;
|
|
14728
|
+
|
|
14729
|
+
case 17:
|
|
14730
|
+
if (!(i < discolines.length)) {
|
|
14731
|
+
_context3.next = 25;
|
|
14732
|
+
break;
|
|
14733
|
+
}
|
|
14734
|
+
|
|
14735
|
+
if (!surplus.smaller(0.01).done()) {
|
|
14736
|
+
_context3.next = 20;
|
|
14737
|
+
break;
|
|
14738
|
+
}
|
|
14739
|
+
|
|
14740
|
+
return _context3.abrupt("break", 25);
|
|
14741
|
+
|
|
14742
|
+
case 20:
|
|
14743
|
+
discolines[i] = mathjs.chain(mathjs.bignumber(discolines[i])).add(mathjs.bignumber(0.01)).done().toNumber();
|
|
14744
|
+
surplus = surplus.subtract(mathjs.bignumber(0.01));
|
|
14745
|
+
|
|
14746
|
+
case 22:
|
|
14747
|
+
i++;
|
|
14748
|
+
_context3.next = 17;
|
|
14749
|
+
break;
|
|
14750
|
+
|
|
14751
|
+
case 25:
|
|
14752
|
+
_context3.next = 27;
|
|
14753
|
+
return controller.run( /*#__PURE__*/function () {
|
|
14754
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
|
|
14755
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14756
|
+
while (1) {
|
|
14757
|
+
switch (_context.prev = _context.next) {
|
|
14758
|
+
case 0:
|
|
14759
|
+
s.goodsListState.goodsList = s.goodsListState.goodsList.filter(function (e) {
|
|
14760
|
+
return e.$index !== concession.$index;
|
|
14761
|
+
});
|
|
14762
|
+
|
|
14763
|
+
case 1:
|
|
14764
|
+
case "end":
|
|
14765
|
+
return _context.stop();
|
|
14766
|
+
}
|
|
14767
|
+
}
|
|
14768
|
+
}, _callee);
|
|
14769
|
+
}));
|
|
14770
|
+
|
|
14771
|
+
return function (_x) {
|
|
14772
|
+
return _ref2.apply(this, arguments);
|
|
14773
|
+
};
|
|
14774
|
+
}());
|
|
14775
|
+
|
|
14776
|
+
case 27:
|
|
14777
|
+
_context3.next = 29;
|
|
14778
|
+
return controller.run( /*#__PURE__*/function () {
|
|
14779
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
|
|
14780
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
14781
|
+
while (1) {
|
|
14782
|
+
switch (_context2.prev = _context2.next) {
|
|
14783
|
+
case 0:
|
|
14784
|
+
s.goodsListState.selectedGoodIndex = [];
|
|
14785
|
+
|
|
14786
|
+
case 1:
|
|
14787
|
+
case "end":
|
|
14788
|
+
return _context2.stop();
|
|
14789
|
+
}
|
|
14790
|
+
}
|
|
14791
|
+
}, _callee2);
|
|
14792
|
+
}));
|
|
14793
|
+
|
|
14794
|
+
return function (_x2) {
|
|
14795
|
+
return _ref3.apply(this, arguments);
|
|
14796
|
+
};
|
|
14797
|
+
}());
|
|
14798
|
+
|
|
14799
|
+
case 29:
|
|
14800
|
+
_context3.next = 31;
|
|
14801
|
+
return controller.addGoodDiscountV2(discolines.map(function (e, i) {
|
|
14802
|
+
var _discountGood$i;
|
|
14803
|
+
|
|
14804
|
+
return {
|
|
14805
|
+
$index: (_discountGood$i = discountGood[i]) === null || _discountGood$i === void 0 ? void 0 : _discountGood$i.$index,
|
|
14806
|
+
discolineAmountunt: e
|
|
14807
|
+
};
|
|
14808
|
+
}));
|
|
14809
|
+
|
|
14810
|
+
case 31:
|
|
14811
|
+
case "end":
|
|
14812
|
+
return _context3.stop();
|
|
14813
|
+
}
|
|
14814
|
+
}
|
|
14815
|
+
}, _callee3);
|
|
14816
|
+
})), [controller, selectedGoodIndex, goodsMap]);
|
|
14817
|
+
var button = React__default['default'].useMemo(function () {
|
|
14818
|
+
if (!isSalesDiscount) return React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
14819
|
+
return React__default['default'].createElement(ktsComponentsAntdX3.Button, {
|
|
14820
|
+
onClick: onClick,
|
|
14821
|
+
disabled: selectedGoodIndex.length <= 1
|
|
14822
|
+
}, "\u9500\u552E\u6298\u8BA9");
|
|
14823
|
+
}, [selectedGoodIndex.length, isSalesDiscount]);
|
|
14824
|
+
return {
|
|
14825
|
+
/** 按钮 */
|
|
14826
|
+
button: button
|
|
14827
|
+
};
|
|
14828
|
+
}
|
|
14829
|
+
|
|
14610
14830
|
var GoodsList = /*#__PURE__*/function (_React$Component) {
|
|
14611
14831
|
_inherits(GoodsList, _React$Component);
|
|
14612
14832
|
|
|
@@ -14669,6 +14889,9 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
|
|
|
14669
14889
|
/** 全单合并折扣 */
|
|
14670
14890
|
|
|
14671
14891
|
var mergeDiscount = useMergeDiscount();
|
|
14892
|
+
/** 销售折让 */
|
|
14893
|
+
|
|
14894
|
+
var salesDiscount = uaeSalesDiscount();
|
|
14672
14895
|
/** 清空自动赋码缓存 */
|
|
14673
14896
|
|
|
14674
14897
|
React__default['default'].useEffect(function () {
|
|
@@ -14826,7 +15049,7 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
|
|
|
14826
15049
|
className: "kts-invoice-operate-goods-list-able"
|
|
14827
15050
|
}, React__default['default'].createElement("div", {
|
|
14828
15051
|
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", {
|
|
15052
|
+
}, 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
15053
|
className: "kts-invoice-operate-goods-list-able-extend"
|
|
14831
15054
|
}, props.menuExpansion, React__default['default'].createElement(DescribeSwitch, null), React__default['default'].createElement(TaxIncludedSwitch, null))), React__default['default'].createElement("div", {
|
|
14832
15055
|
className: classNames__default['default']('kts-invoice-operate-goods-list-table', {
|
package/package.json
CHANGED
|
@@ -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}
|
|
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":
|
|
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":
|
|
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
|
|
package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx
CHANGED
|
@@ -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
|
}
|
package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx
CHANGED
|
@@ -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
|
|
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,110 @@
|
|
|
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
|
+
if (selectedGood.filter(e => e?.lineAttribute === LineAttributeType.折扣行 || e?.lineAttribute === LineAttributeType.被折扣行).length > 0) {
|
|
23
|
+
const content = '不能选择折扣行和被折扣行';
|
|
24
|
+
message.error({ content, key: content })
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 折让行 */
|
|
29
|
+
const concession = selectedGood.filter(e => e?.lineAttribute === LineAttributeType.折让行)[0];
|
|
30
|
+
if (!concession) {
|
|
31
|
+
const content = '未选择折让行';
|
|
32
|
+
message.error({ content, key: content })
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** 准备添加折扣的货物列表 */
|
|
37
|
+
const discountGood = selectedGood.filter(e => e?.lineAttribute !== LineAttributeType.折让行);
|
|
38
|
+
|
|
39
|
+
/** 折扣总金额 */
|
|
40
|
+
const totalDiscoline = chain(bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
|
|
41
|
+
|
|
42
|
+
let discolinesSum = chain(bignumber(0));
|
|
43
|
+
|
|
44
|
+
/** 总金额 */
|
|
45
|
+
const totalAmount = (() => {
|
|
46
|
+
let sum = 0;
|
|
47
|
+
discountGood.forEach(e => { sum += e?.lineAmountIncludeTax ?? 0 });
|
|
48
|
+
return sum;
|
|
49
|
+
})()
|
|
50
|
+
|
|
51
|
+
// 每行的折扣金额
|
|
52
|
+
const discolines: number[] = discountGood.map((e, i) => {
|
|
53
|
+
// 折扣金额占比
|
|
54
|
+
const share = chain(bignumber(e?.lineAmountIncludeTax ?? 0))
|
|
55
|
+
.divide(bignumber(totalAmount));
|
|
56
|
+
|
|
57
|
+
// 折扣金额
|
|
58
|
+
const value = totalDiscoline
|
|
59
|
+
.multiply(share.done())
|
|
60
|
+
|
|
61
|
+
.multiply(bignumber(100))
|
|
62
|
+
.round()
|
|
63
|
+
.divide(bignumber(100))
|
|
64
|
+
|
|
65
|
+
.done();
|
|
66
|
+
|
|
67
|
+
discolinesSum = discolinesSum.add(value);
|
|
68
|
+
return value.toNumber();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// 剩余折扣金额
|
|
72
|
+
let surplus = totalDiscoline.subtract(discolinesSum.done());
|
|
73
|
+
|
|
74
|
+
// 补充剩余折扣金
|
|
75
|
+
for (let i = 0; i < discolines.length; i++) {
|
|
76
|
+
if (surplus.smaller(0.01).done()) break;
|
|
77
|
+
discolines[i] = chain(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
|
|
78
|
+
surplus = surplus.subtract(bignumber(0.01));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 清楚折让行
|
|
82
|
+
await controller.run(async s => { s.goodsListState.goodsList = s.goodsListState.goodsList.filter(e => e.$index !== concession.$index) })
|
|
83
|
+
await controller.run(async s => { s.goodsListState.selectedGoodIndex = [] });
|
|
84
|
+
|
|
85
|
+
// 给一组货物添加折扣行
|
|
86
|
+
await controller.addGoodDiscountV2(discolines.map((e, i) => {
|
|
87
|
+
return {
|
|
88
|
+
$index: discountGood[i]?.$index as string,
|
|
89
|
+
discolineAmountunt: e as number,
|
|
90
|
+
}
|
|
91
|
+
}))
|
|
92
|
+
}, [controller, selectedGoodIndex, goodsMap])
|
|
93
|
+
|
|
94
|
+
const button = React.useMemo(() => {
|
|
95
|
+
if (!isSalesDiscount) return <></>;
|
|
96
|
+
return (
|
|
97
|
+
<Button
|
|
98
|
+
onClick={onClick}
|
|
99
|
+
disabled={selectedGoodIndex.length <= 1}
|
|
100
|
+
>
|
|
101
|
+
销售折让
|
|
102
|
+
</Button>
|
|
103
|
+
)
|
|
104
|
+
}, [selectedGoodIndex.length, isSalesDiscount])
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
/** 按钮 */
|
|
108
|
+
button,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -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
|
|