kts-component-invoice-operate 3.2.88 → 3.2.90

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/README.md CHANGED
@@ -6,4 +6,4 @@
6
6
  南湖:https://lanhuapp.com/web/#/item/project/detailDetach?pid=7daf94b0-9aa7-4372-89a7-226f389b021d&project_id=7daf94b0-9aa7-4372-89a7-226f389b021d&image_id=3bc42812-5718-4aa5-b088-5bc7e0c9a62f&fromEditor=true
7
7
 
8
8
 
9
- node 16.20.2
9
+ node 16.20.2
package/dist/index.esm.js CHANGED
@@ -2274,8 +2274,8 @@ function _mergeDiscount() {
2274
2274
  sum.quantity = good.quantity;
2275
2275
 
2276
2276
  if (sum.quantity) {
2277
- sum.priceExcludeTax = chain$1(bignumber(good.lineAmountExcludeTax)).divide(bignumber(good.quantity)).done().toNumber();
2278
- sum.priceIncludeTax = chain$1(bignumber(good.lineAmountIncludeTax)).divide(bignumber(good.quantity)).done().toNumber();
2277
+ sum.priceExcludeTax = chain$1(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
2278
+ sum.priceIncludeTax = chain$1(bignumber(sum.lineAmountIncludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
2279
2279
  }
2280
2280
 
2281
2281
  goodsList.splice(i, 2, sum);
@@ -15210,34 +15210,24 @@ function useSalesGifts() {
15210
15210
  }, _callee, null, [[1, 12, 15, 18]]);
15211
15211
  })), [controller, giveaways]);
15212
15212
  var onClickManual = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
15213
- var _controller$state$goo, goodsMap, selectedGoodIndex, giveaways, content, _iterator2, _step2, g;
15213
+ var _controller$state$goo, goodsMap, _selectedGoodIndex, _giveaways, _iterator2, _step2, g;
15214
15214
 
15215
15215
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
15216
15216
  while (1) {
15217
15217
  switch (_context2.prev = _context2.next) {
15218
15218
  case 0:
15219
- _controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
15220
- giveaways = selectedGoodIndex.map(function (e) {
15219
+ _context2.prev = 0;
15220
+ _controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, _selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
15221
+ _giveaways = _selectedGoodIndex.map(function (e) {
15221
15222
  return goodsMap.get(e);
15222
15223
  }).filter(function (e) {
15223
15224
  return !!e;
15224
15225
  });
15225
-
15226
- if (!(giveaways.some(function (e) {
15227
- return e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行;
15228
- }) === false)) {
15229
- _context2.next = 5;
15230
- break;
15231
- }
15232
-
15233
- content = '只能选择‘赠品行’和‘正常行’';
15234
- return _context2.abrupt("return", message.error({
15235
- content: content,
15236
- key: content
15237
- }));
15226
+ _context2.next = 5;
15227
+ return checkLineAttribute(_giveaways);
15238
15228
 
15239
15229
  case 5:
15240
- _iterator2 = _createForOfIteratorHelper(giveaways);
15230
+ _iterator2 = _createForOfIteratorHelper(_giveaways);
15241
15231
  _context2.prev = 6;
15242
15232
 
15243
15233
  _iterator2.s();
@@ -15278,13 +15268,19 @@ function useSalesGifts() {
15278
15268
 
15279
15269
  case 22:
15280
15270
  controller.state.goodsListState.selectedGoodIndex = [];
15271
+ _context2.next = 27;
15272
+ break;
15281
15273
 
15282
- case 23:
15274
+ case 25:
15275
+ _context2.prev = 25;
15276
+ _context2.t1 = _context2["catch"](0);
15277
+
15278
+ case 27:
15283
15279
  case "end":
15284
15280
  return _context2.stop();
15285
15281
  }
15286
15282
  }
15287
- }, _callee2, null, [[6, 16, 19, 22]]);
15283
+ }, _callee2, null, [[0, 25], [6, 16, 19, 22]]);
15288
15284
  })), [controller]);
15289
15285
  var items = React.useMemo(function () {
15290
15286
  return [{
@@ -15313,6 +15309,22 @@ function useSalesGifts() {
15313
15309
  button: button
15314
15310
  };
15315
15311
  }
15312
+ /** 只能选择‘赠品行’和‘正常行’ */
15313
+
15314
+ function checkLineAttribute(giveaways) {
15315
+ giveaways.forEach(function (e) {
15316
+ if (e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行) {
15317
+ return;
15318
+ } else {
15319
+ var content = '只能选择‘赠品行’和‘正常行’';
15320
+ message.error({
15321
+ content: content,
15322
+ key: content
15323
+ });
15324
+ throw new Error(content);
15325
+ }
15326
+ });
15327
+ }
15316
15328
 
15317
15329
  var GoodsList = /*#__PURE__*/function (_React$Component) {
15318
15330
  _inherits(GoodsList, _React$Component);
package/dist/index.js CHANGED
@@ -2284,8 +2284,8 @@ function _mergeDiscount() {
2284
2284
  sum.quantity = good.quantity;
2285
2285
 
2286
2286
  if (sum.quantity) {
2287
- sum.priceExcludeTax = mathjs.chain(mathjs.bignumber(good.lineAmountExcludeTax)).divide(mathjs.bignumber(good.quantity)).done().toNumber();
2288
- sum.priceIncludeTax = mathjs.chain(mathjs.bignumber(good.lineAmountIncludeTax)).divide(mathjs.bignumber(good.quantity)).done().toNumber();
2287
+ sum.priceExcludeTax = mathjs.chain(mathjs.bignumber(sum.lineAmountExcludeTax)).divide(mathjs.bignumber(sum.quantity)).done().toNumber();
2288
+ sum.priceIncludeTax = mathjs.chain(mathjs.bignumber(sum.lineAmountIncludeTax)).divide(mathjs.bignumber(sum.quantity)).done().toNumber();
2289
2289
  }
2290
2290
 
2291
2291
  goodsList.splice(i, 2, sum);
@@ -15220,34 +15220,24 @@ function useSalesGifts() {
15220
15220
  }, _callee, null, [[1, 12, 15, 18]]);
15221
15221
  })), [controller, giveaways]);
15222
15222
  var onClickManual = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
15223
- var _controller$state$goo, goodsMap, selectedGoodIndex, giveaways, content, _iterator2, _step2, g;
15223
+ var _controller$state$goo, goodsMap, _selectedGoodIndex, _giveaways, _iterator2, _step2, g;
15224
15224
 
15225
15225
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
15226
15226
  while (1) {
15227
15227
  switch (_context2.prev = _context2.next) {
15228
15228
  case 0:
15229
- _controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
15230
- giveaways = selectedGoodIndex.map(function (e) {
15229
+ _context2.prev = 0;
15230
+ _controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, _selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
15231
+ _giveaways = _selectedGoodIndex.map(function (e) {
15231
15232
  return goodsMap.get(e);
15232
15233
  }).filter(function (e) {
15233
15234
  return !!e;
15234
15235
  });
15235
-
15236
- if (!(giveaways.some(function (e) {
15237
- return e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行;
15238
- }) === false)) {
15239
- _context2.next = 5;
15240
- break;
15241
- }
15242
-
15243
- content = '只能选择‘赠品行’和‘正常行’';
15244
- return _context2.abrupt("return", ktsComponentsAntdX3.message.error({
15245
- content: content,
15246
- key: content
15247
- }));
15236
+ _context2.next = 5;
15237
+ return checkLineAttribute(_giveaways);
15248
15238
 
15249
15239
  case 5:
15250
- _iterator2 = _createForOfIteratorHelper(giveaways);
15240
+ _iterator2 = _createForOfIteratorHelper(_giveaways);
15251
15241
  _context2.prev = 6;
15252
15242
 
15253
15243
  _iterator2.s();
@@ -15288,13 +15278,19 @@ function useSalesGifts() {
15288
15278
 
15289
15279
  case 22:
15290
15280
  controller.state.goodsListState.selectedGoodIndex = [];
15281
+ _context2.next = 27;
15282
+ break;
15291
15283
 
15292
- case 23:
15284
+ case 25:
15285
+ _context2.prev = 25;
15286
+ _context2.t1 = _context2["catch"](0);
15287
+
15288
+ case 27:
15293
15289
  case "end":
15294
15290
  return _context2.stop();
15295
15291
  }
15296
15292
  }
15297
- }, _callee2, null, [[6, 16, 19, 22]]);
15293
+ }, _callee2, null, [[0, 25], [6, 16, 19, 22]]);
15298
15294
  })), [controller]);
15299
15295
  var items = React__default['default'].useMemo(function () {
15300
15296
  return [{
@@ -15323,6 +15319,22 @@ function useSalesGifts() {
15323
15319
  button: button
15324
15320
  };
15325
15321
  }
15322
+ /** 只能选择‘赠品行’和‘正常行’ */
15323
+
15324
+ function checkLineAttribute(giveaways) {
15325
+ giveaways.forEach(function (e) {
15326
+ if (e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行) {
15327
+ return;
15328
+ } else {
15329
+ var content = '只能选择‘赠品行’和‘正常行’';
15330
+ ktsComponentsAntdX3.message.error({
15331
+ content: content,
15332
+ key: content
15333
+ });
15334
+ throw new Error(content);
15335
+ }
15336
+ });
15337
+ }
15326
15338
 
15327
15339
  var GoodsList = /*#__PURE__*/function (_React$Component) {
15328
15340
  _inherits(GoodsList, _React$Component);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.88",
3
+ "version": "3.2.90",
4
4
  "scripts": {
5
5
  "dev": "dumi dev",
6
6
  "start": "dumi dev",
@@ -13,13 +13,13 @@ export default async function mergeDiscount(state: InvoiceControllerState) {
13
13
  if (good.lineAttribute * 1 === LineAttributeType.被折扣行) {
14
14
  const sum: IGood = { ...good, $index: idGenerator(), lineAttribute: LineAttributeType.正常, discountGroup: undefined };
15
15
  const zk = goodsList[i + 1];
16
-
16
+
17
17
  sum.lineAmountExcludeTax = chain(bignumber(good.lineAmountExcludeTax)).subtract(bignumber(Math.abs(zk.lineAmountExcludeTax || 0))).done().toNumber();
18
18
  sum.lineAmountIncludeTax = chain(bignumber(good.lineAmountIncludeTax)).subtract(bignumber(Math.abs(zk.lineAmountIncludeTax || 0))).done().toNumber();
19
19
  sum.quantity = good.quantity;
20
20
  if (sum.quantity) {
21
- sum.priceExcludeTax = chain(bignumber(good.lineAmountExcludeTax)).divide(bignumber(good.quantity)).done().toNumber();
22
- sum.priceIncludeTax = chain(bignumber(good.lineAmountIncludeTax)).divide(bignumber(good.quantity)).done().toNumber();
21
+ sum.priceExcludeTax = chain(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
22
+ sum.priceIncludeTax = chain(bignumber(sum.lineAmountIncludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
23
23
  }
24
24
 
25
25
  goodsList.splice(i, 2, sum);
@@ -66,6 +66,8 @@ class MyController1 extends Invoice.InvoiceController {
66
66
  this.state.model = 'default'
67
67
  this.state.goodsListState.isMergeDetails = true;
68
68
  this.state.goodsListState.isSalesDiscount = true;
69
+ this.state.goodsListState.isMergeDiscount = true;
70
+ this.state.goodsListState.isSalesGifts = true;
69
71
  this.state.goodsListState.drag.isStart = true;
70
72
  this.state.goodsListState.columnshide = [];
71
73
  }
@@ -94,6 +96,8 @@ class MyController2 extends Invoice.InvoiceController {
94
96
  this.state.model = 'prefab'
95
97
  this.state.goodsListState.isMergeDetails = true;
96
98
  this.state.goodsListState.isSalesDiscount = true;
99
+ this.state.goodsListState.isMergeDiscount = true;
100
+ this.state.goodsListState.isSalesGifts = true;
97
101
  this.state.goodsListState.drag.isStart = true;
98
102
  this.state.goodsListState.columnshide = [];
99
103
  }
@@ -1,7 +1,6 @@
1
1
 
2
2
  import React from "react"
3
3
  import { Button, message } from "kts-components-antd-x3"
4
- import { chain, bignumber } from 'mathjs';
5
4
  import Invoice from '../../../../../../..'
6
5
  import { IGood, LineAttributeType } from "../../../../../../../InvoiceController";
7
6
  import { Dropdown, MenuProps } from "kts-xui";
@@ -27,19 +26,20 @@ export default function useSalesGifts() {
27
26
  }, [controller, giveaways])
28
27
 
29
28
  const onClickManual = React.useCallback(async () => {
30
- const { goodsMap, selectedGoodIndex } = controller.state.goodsListState;
31
- const giveaways = selectedGoodIndex.map(e => goodsMap.get(e) as IGood).filter(e => !!e);
29
+ try {
30
+ const { goodsMap, selectedGoodIndex } = controller.state.goodsListState;
31
+ const giveaways = selectedGoodIndex.map(e => goodsMap.get(e) as IGood).filter(e => !!e);
32
32
 
33
- if (giveaways.some(e => e.lineAttribute === LineAttributeType.正常 || e.lineAttribute === LineAttributeType.赠品行) === false) {
34
- const content = '只能选择‘赠品行’和‘正常行’';
35
- return message.error({ content, key: content });
36
- }
33
+ await checkLineAttribute(giveaways);
37
34
 
38
- for (let g of giveaways) {
39
- await controller.addGoodDiscountV2([{ $index: g.$index, discolineAmountunt: g.lineAmountIncludeTax || 0 }]);
40
- }
35
+ for (let g of giveaways) {
36
+ await controller.addGoodDiscountV2([{ $index: g.$index, discolineAmountunt: g.lineAmountIncludeTax || 0 }]);
37
+ }
41
38
 
42
- controller.state.goodsListState.selectedGoodIndex = [];
39
+ controller.state.goodsListState.selectedGoodIndex = [];
40
+ } catch (error) {
41
+
42
+ }
43
43
  }, [controller])
44
44
 
45
45
  const items: MenuProps['items'] = React.useMemo(() => {
@@ -73,4 +73,17 @@ export default function useSalesGifts() {
73
73
  /** 按钮 */
74
74
  button,
75
75
  }
76
+ }
77
+
78
+ /** 只能选择‘赠品行’和‘正常行’ */
79
+ function checkLineAttribute(giveaways: IGood[]) {
80
+ giveaways.forEach(e => {
81
+ if (e.lineAttribute === LineAttributeType.正常 || e.lineAttribute === LineAttributeType.赠品行) {
82
+ return;
83
+ } else {
84
+ const content = '只能选择‘赠品行’和‘正常行’';
85
+ message.error({ content, key: content });
86
+ throw new Error(content);
87
+ }
88
+ })
76
89
  }