kts-component-invoice-operate 3.2.121-2 → 3.2.122
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/index.d.ts +2 -0
- package/dist/index.esm.js +116 -66
- package/dist/index.js +116 -66
- package/package.json +1 -1
- package/src/Invoice/Invoice-digtal/_test/importGoods/index.tsx +2 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +4 -0
- package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +9 -10
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +6 -8
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +7 -9
package/dist/index.esm.js
CHANGED
|
@@ -1089,6 +1089,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
|
|
|
1089
1089
|
this.deduction = 0;
|
|
1090
1090
|
this.goodMax = void 0;
|
|
1091
1091
|
this.isSwitchTax = void 0;
|
|
1092
|
+
this.isRecalculateWhenSwitchTax = false;
|
|
1092
1093
|
this.isAddDiscount = void 0;
|
|
1093
1094
|
this.isAddRow = true;
|
|
1094
1095
|
this.isRemRow = true;
|
|
@@ -9334,32 +9335,62 @@ var onChangeItemCode = /*#__PURE__*/function () {
|
|
|
9334
9335
|
/** 修改了含税开关 重新计算 */
|
|
9335
9336
|
|
|
9336
9337
|
var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
9337
|
-
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9338
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(controller, isTaxIncluded) {
|
|
9338
9339
|
var calculatingDigits;
|
|
9339
|
-
return _regeneratorRuntime().wrap(function
|
|
9340
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
9340
9341
|
while (1) {
|
|
9341
|
-
switch (
|
|
9342
|
+
switch (_context22.prev = _context22.next) {
|
|
9342
9343
|
case 0:
|
|
9344
|
+
if (controller.state.goodsListState.isRecalculateWhenSwitchTax) {
|
|
9345
|
+
_context22.next = 3;
|
|
9346
|
+
break;
|
|
9347
|
+
}
|
|
9348
|
+
|
|
9349
|
+
controller.pipeline( /*#__PURE__*/function () {
|
|
9350
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(s) {
|
|
9351
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
9352
|
+
while (1) {
|
|
9353
|
+
switch (_context20.prev = _context20.next) {
|
|
9354
|
+
case 0:
|
|
9355
|
+
s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
|
|
9356
|
+
isTaxIncluded: isTaxIncluded
|
|
9357
|
+
});
|
|
9358
|
+
|
|
9359
|
+
case 1:
|
|
9360
|
+
case "end":
|
|
9361
|
+
return _context20.stop();
|
|
9362
|
+
}
|
|
9363
|
+
}
|
|
9364
|
+
}, _callee20);
|
|
9365
|
+
}));
|
|
9366
|
+
|
|
9367
|
+
return function (_x40) {
|
|
9368
|
+
return _ref21.apply(this, arguments);
|
|
9369
|
+
};
|
|
9370
|
+
}())();
|
|
9371
|
+
return _context22.abrupt("return");
|
|
9372
|
+
|
|
9373
|
+
case 3:
|
|
9343
9374
|
calculatingDigits = controller.state.calculatingDigits;
|
|
9344
|
-
|
|
9375
|
+
_context22.next = 6;
|
|
9345
9376
|
return controller.saveEditGood();
|
|
9346
9377
|
|
|
9347
|
-
case
|
|
9348
|
-
|
|
9378
|
+
case 6:
|
|
9379
|
+
_context22.next = 8;
|
|
9349
9380
|
return controller.wait();
|
|
9350
9381
|
|
|
9351
|
-
case
|
|
9352
|
-
|
|
9382
|
+
case 8:
|
|
9383
|
+
_context22.next = 10;
|
|
9353
9384
|
return controller.run( /*#__PURE__*/function () {
|
|
9354
|
-
var
|
|
9355
|
-
var _s$goodsListState, needRefresh,
|
|
9385
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(s) {
|
|
9386
|
+
var _s$goodsListState, needRefresh, newGoodsList;
|
|
9356
9387
|
|
|
9357
|
-
return _regeneratorRuntime().wrap(function
|
|
9388
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
9358
9389
|
while (1) {
|
|
9359
|
-
switch (
|
|
9390
|
+
switch (_context21.prev = _context21.next) {
|
|
9360
9391
|
case 0:
|
|
9361
9392
|
if (!s.goodsListState.editGood) {
|
|
9362
|
-
|
|
9393
|
+
_context21.next = 3;
|
|
9363
9394
|
break;
|
|
9364
9395
|
}
|
|
9365
9396
|
|
|
@@ -9367,7 +9398,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9367
9398
|
content: '你正在编辑一个货物',
|
|
9368
9399
|
key: '你正在编辑一个货物'
|
|
9369
9400
|
});
|
|
9370
|
-
return
|
|
9401
|
+
return _context21.abrupt("return");
|
|
9371
9402
|
|
|
9372
9403
|
case 3:
|
|
9373
9404
|
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
@@ -9376,7 +9407,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9376
9407
|
needRefresh = false;
|
|
9377
9408
|
|
|
9378
9409
|
if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
|
|
9379
|
-
|
|
9410
|
+
newGoodsList = s.goodsListState.goodsList.map(function (good) {
|
|
9380
9411
|
var sourceQuantity = good.quantity,
|
|
9381
9412
|
sourcePriceExcludeTax = good.priceExcludeTax,
|
|
9382
9413
|
sourcePriceIncludeTax = good.priceIncludeTax,
|
|
@@ -9390,11 +9421,9 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9390
9421
|
if (!taxRate && taxRate !== 0) return good;
|
|
9391
9422
|
|
|
9392
9423
|
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
9393
|
-
console.log('equal');
|
|
9394
9424
|
return good;
|
|
9395
9425
|
} else {
|
|
9396
9426
|
needRefresh = true;
|
|
9397
|
-
console.log('not equal');
|
|
9398
9427
|
}
|
|
9399
9428
|
|
|
9400
9429
|
var quantity = format15(sourceQuantity, calculatingDigits);
|
|
@@ -9410,18 +9439,14 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9410
9439
|
priceExcludeTax: priceExcludeTax
|
|
9411
9440
|
});
|
|
9412
9441
|
} else {
|
|
9413
|
-
var _s$goodsListState$for;
|
|
9414
|
-
|
|
9415
9442
|
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
9416
9443
|
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
9417
9444
|
if (!taxRate && taxRate !== 0) return good;
|
|
9418
9445
|
|
|
9419
9446
|
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
9420
|
-
console.log('equal');
|
|
9421
9447
|
return good;
|
|
9422
9448
|
} else {
|
|
9423
9449
|
needRefresh = true;
|
|
9424
|
-
console.log('not equal');
|
|
9425
9450
|
}
|
|
9426
9451
|
|
|
9427
9452
|
var _quantity5 = format15(sourceQuantity, calculatingDigits);
|
|
@@ -9436,7 +9461,6 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9436
9461
|
|
|
9437
9462
|
var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
|
|
9438
9463
|
|
|
9439
|
-
console.log((_s$goodsListState$for = s.goodsListState.form) === null || _s$goodsListState$for === void 0 ? void 0 : _s$goodsListState$for.getFieldsValue(), 'goodsListState');
|
|
9440
9464
|
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
9441
9465
|
lineAmountExcludeTax: _lineAmountExcludeTax3,
|
|
9442
9466
|
lineAmountIncludeTax: _lineAmountIncludeTax3,
|
|
@@ -9447,7 +9471,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9447
9471
|
});
|
|
9448
9472
|
|
|
9449
9473
|
if (needRefresh) {
|
|
9450
|
-
s.goodsListState.goodsList =
|
|
9474
|
+
s.goodsListState.goodsList = newGoodsList;
|
|
9451
9475
|
}
|
|
9452
9476
|
}
|
|
9453
9477
|
} catch (e) {
|
|
@@ -9456,23 +9480,23 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9456
9480
|
|
|
9457
9481
|
case 5:
|
|
9458
9482
|
case "end":
|
|
9459
|
-
return
|
|
9483
|
+
return _context21.stop();
|
|
9460
9484
|
}
|
|
9461
9485
|
}
|
|
9462
|
-
},
|
|
9486
|
+
}, _callee21);
|
|
9463
9487
|
}));
|
|
9464
9488
|
|
|
9465
|
-
return function (
|
|
9466
|
-
return
|
|
9489
|
+
return function (_x41) {
|
|
9490
|
+
return _ref22.apply(this, arguments);
|
|
9467
9491
|
};
|
|
9468
9492
|
}());
|
|
9469
9493
|
|
|
9470
|
-
case
|
|
9494
|
+
case 10:
|
|
9471
9495
|
case "end":
|
|
9472
|
-
return
|
|
9496
|
+
return _context22.stop();
|
|
9473
9497
|
}
|
|
9474
9498
|
}
|
|
9475
|
-
},
|
|
9499
|
+
}, _callee22);
|
|
9476
9500
|
}));
|
|
9477
9501
|
|
|
9478
9502
|
return function onChangeSwitchTax(_x38, _x39) {
|
|
@@ -18826,32 +18850,62 @@ var onChangeItemName$1 = /*#__PURE__*/function () {
|
|
|
18826
18850
|
/** 修改了含税开关 重新计算 */
|
|
18827
18851
|
|
|
18828
18852
|
var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
18829
|
-
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18853
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(controller, isTaxIncluded) {
|
|
18830
18854
|
var calculatingDigits;
|
|
18831
|
-
return _regeneratorRuntime().wrap(function
|
|
18855
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
18832
18856
|
while (1) {
|
|
18833
|
-
switch (
|
|
18857
|
+
switch (_context20.prev = _context20.next) {
|
|
18834
18858
|
case 0:
|
|
18859
|
+
if (controller.state.goodsListState.isRecalculateWhenSwitchTax) {
|
|
18860
|
+
_context20.next = 3;
|
|
18861
|
+
break;
|
|
18862
|
+
}
|
|
18863
|
+
|
|
18864
|
+
controller.pipeline( /*#__PURE__*/function () {
|
|
18865
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(s) {
|
|
18866
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
18867
|
+
while (1) {
|
|
18868
|
+
switch (_context18.prev = _context18.next) {
|
|
18869
|
+
case 0:
|
|
18870
|
+
s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
|
|
18871
|
+
isTaxIncluded: isTaxIncluded
|
|
18872
|
+
});
|
|
18873
|
+
|
|
18874
|
+
case 1:
|
|
18875
|
+
case "end":
|
|
18876
|
+
return _context18.stop();
|
|
18877
|
+
}
|
|
18878
|
+
}
|
|
18879
|
+
}, _callee18);
|
|
18880
|
+
}));
|
|
18881
|
+
|
|
18882
|
+
return function (_x36) {
|
|
18883
|
+
return _ref19.apply(this, arguments);
|
|
18884
|
+
};
|
|
18885
|
+
}())();
|
|
18886
|
+
return _context20.abrupt("return");
|
|
18887
|
+
|
|
18888
|
+
case 3:
|
|
18835
18889
|
calculatingDigits = controller.state.calculatingDigits;
|
|
18836
|
-
|
|
18890
|
+
_context20.next = 6;
|
|
18837
18891
|
return controller.saveEditGood();
|
|
18838
18892
|
|
|
18839
|
-
case
|
|
18840
|
-
|
|
18893
|
+
case 6:
|
|
18894
|
+
_context20.next = 8;
|
|
18841
18895
|
return controller.wait();
|
|
18842
18896
|
|
|
18843
|
-
case
|
|
18844
|
-
|
|
18897
|
+
case 8:
|
|
18898
|
+
_context20.next = 10;
|
|
18845
18899
|
return controller.run( /*#__PURE__*/function () {
|
|
18846
|
-
var
|
|
18847
|
-
var _s$goodsListState, needRefresh,
|
|
18900
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(s) {
|
|
18901
|
+
var _s$goodsListState, needRefresh, newGoodsList;
|
|
18848
18902
|
|
|
18849
|
-
return _regeneratorRuntime().wrap(function
|
|
18903
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
18850
18904
|
while (1) {
|
|
18851
|
-
switch (
|
|
18905
|
+
switch (_context19.prev = _context19.next) {
|
|
18852
18906
|
case 0:
|
|
18853
18907
|
if (!s.goodsListState.editGood) {
|
|
18854
|
-
|
|
18908
|
+
_context19.next = 3;
|
|
18855
18909
|
break;
|
|
18856
18910
|
}
|
|
18857
18911
|
|
|
@@ -18859,7 +18913,7 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18859
18913
|
content: '你正在编辑一个货物',
|
|
18860
18914
|
key: '你正在编辑一个货物'
|
|
18861
18915
|
});
|
|
18862
|
-
return
|
|
18916
|
+
return _context19.abrupt("return");
|
|
18863
18917
|
|
|
18864
18918
|
case 3:
|
|
18865
18919
|
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
@@ -18868,7 +18922,7 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18868
18922
|
needRefresh = false;
|
|
18869
18923
|
|
|
18870
18924
|
if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
|
|
18871
|
-
|
|
18925
|
+
newGoodsList = s.goodsListState.goodsList.map(function (good) {
|
|
18872
18926
|
var sourceQuantity = good.quantity,
|
|
18873
18927
|
sourcePriceExcludeTax = good.priceExcludeTax,
|
|
18874
18928
|
sourcePriceIncludeTax = good.priceIncludeTax,
|
|
@@ -18882,11 +18936,9 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18882
18936
|
if (!taxRate && taxRate !== 0) return good;
|
|
18883
18937
|
|
|
18884
18938
|
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
18885
|
-
console.log('equal');
|
|
18886
18939
|
return good;
|
|
18887
18940
|
} else {
|
|
18888
18941
|
needRefresh = true;
|
|
18889
|
-
console.log('not equal');
|
|
18890
18942
|
}
|
|
18891
18943
|
|
|
18892
18944
|
var quantity = format15(sourceQuantity, calculatingDigits);
|
|
@@ -18902,18 +18954,14 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18902
18954
|
priceExcludeTax: priceExcludeTax
|
|
18903
18955
|
});
|
|
18904
18956
|
} else {
|
|
18905
|
-
var _s$goodsListState$for;
|
|
18906
|
-
|
|
18907
18957
|
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
18908
18958
|
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
18909
18959
|
if (!taxRate && taxRate !== 0) return good;
|
|
18910
18960
|
|
|
18911
18961
|
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
18912
|
-
console.log('equal');
|
|
18913
18962
|
return good;
|
|
18914
18963
|
} else {
|
|
18915
18964
|
needRefresh = true;
|
|
18916
|
-
console.log('not equal');
|
|
18917
18965
|
}
|
|
18918
18966
|
|
|
18919
18967
|
var _quantity5 = format15(sourceQuantity, calculatingDigits);
|
|
@@ -18928,7 +18976,6 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18928
18976
|
|
|
18929
18977
|
var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
|
|
18930
18978
|
|
|
18931
|
-
console.log((_s$goodsListState$for = s.goodsListState.form) === null || _s$goodsListState$for === void 0 ? void 0 : _s$goodsListState$for.getFieldsValue(), 'goodsListState');
|
|
18932
18979
|
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
18933
18980
|
lineAmountExcludeTax: _lineAmountExcludeTax3,
|
|
18934
18981
|
lineAmountIncludeTax: _lineAmountIncludeTax3,
|
|
@@ -18939,7 +18986,7 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18939
18986
|
});
|
|
18940
18987
|
|
|
18941
18988
|
if (needRefresh) {
|
|
18942
|
-
s.goodsListState.goodsList =
|
|
18989
|
+
s.goodsListState.goodsList = newGoodsList;
|
|
18943
18990
|
}
|
|
18944
18991
|
}
|
|
18945
18992
|
} catch (e) {
|
|
@@ -18948,23 +18995,23 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18948
18995
|
|
|
18949
18996
|
case 5:
|
|
18950
18997
|
case "end":
|
|
18951
|
-
return
|
|
18998
|
+
return _context19.stop();
|
|
18952
18999
|
}
|
|
18953
19000
|
}
|
|
18954
|
-
},
|
|
19001
|
+
}, _callee19);
|
|
18955
19002
|
}));
|
|
18956
19003
|
|
|
18957
|
-
return function (
|
|
18958
|
-
return
|
|
19004
|
+
return function (_x37) {
|
|
19005
|
+
return _ref20.apply(this, arguments);
|
|
18959
19006
|
};
|
|
18960
19007
|
}());
|
|
18961
19008
|
|
|
18962
|
-
case
|
|
19009
|
+
case 10:
|
|
18963
19010
|
case "end":
|
|
18964
|
-
return
|
|
19011
|
+
return _context20.stop();
|
|
18965
19012
|
}
|
|
18966
19013
|
}
|
|
18967
|
-
},
|
|
19014
|
+
}, _callee20);
|
|
18968
19015
|
}));
|
|
18969
19016
|
|
|
18970
19017
|
return function onChangeSwitchTax(_x34, _x35) {
|
|
@@ -23584,14 +23631,17 @@ var DrawerBody$3 = function DrawerBody(props) {
|
|
|
23584
23631
|
good.taxRate = values.taxRate;
|
|
23585
23632
|
good.taxFreeType = values.taxFreeType;
|
|
23586
23633
|
good.favouredPolicyMark = values.favouredPolicyMark;
|
|
23587
|
-
good.favouredPolicyName = values.favouredPolicyName;
|
|
23588
|
-
var taxRate = chain$1(bignumber(values.taxRate)).dotDivide(bignumber(100)).add(bignumber(1)).done(); // 是否含税
|
|
23634
|
+
good.favouredPolicyName = values.favouredPolicyName; // 无论是否含税,都保持价税合计不变
|
|
23589
23635
|
|
|
23590
|
-
var lineAmountExcludeTax = chain$1(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
|
|
23591
|
-
var priceExcludeTax = good.priceIncludeTax ? chain$1(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined;
|
|
23592
|
-
good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
|
|
23593
|
-
good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber(), s.calculatingDigits) : undefined) || undefined;
|
|
23594
23636
|
good.taxAmount = countTaxAmount(good.lineAmountIncludeTax || 0, s.goodsListState.deduction, values.taxRate);
|
|
23637
|
+
|
|
23638
|
+
if (good.taxAmount || good.taxAmount === 0) {
|
|
23639
|
+
good.lineAmountExcludeTax = countAmountExcludeTax(good.lineAmountIncludeTax || 0, good.taxAmount);
|
|
23640
|
+
}
|
|
23641
|
+
|
|
23642
|
+
if (good.lineAmountExcludeTax && good.quantity) {
|
|
23643
|
+
good.priceExcludeTax = countPrice(good.lineAmountExcludeTax, good.quantity, controller.state.calculatingDigits);
|
|
23644
|
+
}
|
|
23595
23645
|
});
|
|
23596
23646
|
s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
|
|
23597
23647
|
s.goodsListState.endowCode.endowcodeGoodIndex = [];
|
package/dist/index.js
CHANGED
|
@@ -1099,6 +1099,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
|
|
|
1099
1099
|
this.deduction = 0;
|
|
1100
1100
|
this.goodMax = void 0;
|
|
1101
1101
|
this.isSwitchTax = void 0;
|
|
1102
|
+
this.isRecalculateWhenSwitchTax = false;
|
|
1102
1103
|
this.isAddDiscount = void 0;
|
|
1103
1104
|
this.isAddRow = true;
|
|
1104
1105
|
this.isRemRow = true;
|
|
@@ -9344,32 +9345,62 @@ var onChangeItemCode = /*#__PURE__*/function () {
|
|
|
9344
9345
|
/** 修改了含税开关 重新计算 */
|
|
9345
9346
|
|
|
9346
9347
|
var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
9347
|
-
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9348
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(controller, isTaxIncluded) {
|
|
9348
9349
|
var calculatingDigits;
|
|
9349
|
-
return _regeneratorRuntime().wrap(function
|
|
9350
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
9350
9351
|
while (1) {
|
|
9351
|
-
switch (
|
|
9352
|
+
switch (_context22.prev = _context22.next) {
|
|
9352
9353
|
case 0:
|
|
9354
|
+
if (controller.state.goodsListState.isRecalculateWhenSwitchTax) {
|
|
9355
|
+
_context22.next = 3;
|
|
9356
|
+
break;
|
|
9357
|
+
}
|
|
9358
|
+
|
|
9359
|
+
controller.pipeline( /*#__PURE__*/function () {
|
|
9360
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(s) {
|
|
9361
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
9362
|
+
while (1) {
|
|
9363
|
+
switch (_context20.prev = _context20.next) {
|
|
9364
|
+
case 0:
|
|
9365
|
+
s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
|
|
9366
|
+
isTaxIncluded: isTaxIncluded
|
|
9367
|
+
});
|
|
9368
|
+
|
|
9369
|
+
case 1:
|
|
9370
|
+
case "end":
|
|
9371
|
+
return _context20.stop();
|
|
9372
|
+
}
|
|
9373
|
+
}
|
|
9374
|
+
}, _callee20);
|
|
9375
|
+
}));
|
|
9376
|
+
|
|
9377
|
+
return function (_x40) {
|
|
9378
|
+
return _ref21.apply(this, arguments);
|
|
9379
|
+
};
|
|
9380
|
+
}())();
|
|
9381
|
+
return _context22.abrupt("return");
|
|
9382
|
+
|
|
9383
|
+
case 3:
|
|
9353
9384
|
calculatingDigits = controller.state.calculatingDigits;
|
|
9354
|
-
|
|
9385
|
+
_context22.next = 6;
|
|
9355
9386
|
return controller.saveEditGood();
|
|
9356
9387
|
|
|
9357
|
-
case
|
|
9358
|
-
|
|
9388
|
+
case 6:
|
|
9389
|
+
_context22.next = 8;
|
|
9359
9390
|
return controller.wait();
|
|
9360
9391
|
|
|
9361
|
-
case
|
|
9362
|
-
|
|
9392
|
+
case 8:
|
|
9393
|
+
_context22.next = 10;
|
|
9363
9394
|
return controller.run( /*#__PURE__*/function () {
|
|
9364
|
-
var
|
|
9365
|
-
var _s$goodsListState, needRefresh,
|
|
9395
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(s) {
|
|
9396
|
+
var _s$goodsListState, needRefresh, newGoodsList;
|
|
9366
9397
|
|
|
9367
|
-
return _regeneratorRuntime().wrap(function
|
|
9398
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
9368
9399
|
while (1) {
|
|
9369
|
-
switch (
|
|
9400
|
+
switch (_context21.prev = _context21.next) {
|
|
9370
9401
|
case 0:
|
|
9371
9402
|
if (!s.goodsListState.editGood) {
|
|
9372
|
-
|
|
9403
|
+
_context21.next = 3;
|
|
9373
9404
|
break;
|
|
9374
9405
|
}
|
|
9375
9406
|
|
|
@@ -9377,7 +9408,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9377
9408
|
content: '你正在编辑一个货物',
|
|
9378
9409
|
key: '你正在编辑一个货物'
|
|
9379
9410
|
});
|
|
9380
|
-
return
|
|
9411
|
+
return _context21.abrupt("return");
|
|
9381
9412
|
|
|
9382
9413
|
case 3:
|
|
9383
9414
|
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
@@ -9386,7 +9417,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9386
9417
|
needRefresh = false;
|
|
9387
9418
|
|
|
9388
9419
|
if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
|
|
9389
|
-
|
|
9420
|
+
newGoodsList = s.goodsListState.goodsList.map(function (good) {
|
|
9390
9421
|
var sourceQuantity = good.quantity,
|
|
9391
9422
|
sourcePriceExcludeTax = good.priceExcludeTax,
|
|
9392
9423
|
sourcePriceIncludeTax = good.priceIncludeTax,
|
|
@@ -9400,11 +9431,9 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9400
9431
|
if (!taxRate && taxRate !== 0) return good;
|
|
9401
9432
|
|
|
9402
9433
|
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && mathjs.equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
9403
|
-
console.log('equal');
|
|
9404
9434
|
return good;
|
|
9405
9435
|
} else {
|
|
9406
9436
|
needRefresh = true;
|
|
9407
|
-
console.log('not equal');
|
|
9408
9437
|
}
|
|
9409
9438
|
|
|
9410
9439
|
var quantity = format15(sourceQuantity, calculatingDigits);
|
|
@@ -9420,18 +9449,14 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9420
9449
|
priceExcludeTax: priceExcludeTax
|
|
9421
9450
|
});
|
|
9422
9451
|
} else {
|
|
9423
|
-
var _s$goodsListState$for;
|
|
9424
|
-
|
|
9425
9452
|
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
9426
9453
|
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
9427
9454
|
if (!taxRate && taxRate !== 0) return good;
|
|
9428
9455
|
|
|
9429
9456
|
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && mathjs.equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
9430
|
-
console.log('equal');
|
|
9431
9457
|
return good;
|
|
9432
9458
|
} else {
|
|
9433
9459
|
needRefresh = true;
|
|
9434
|
-
console.log('not equal');
|
|
9435
9460
|
}
|
|
9436
9461
|
|
|
9437
9462
|
var _quantity5 = format15(sourceQuantity, calculatingDigits);
|
|
@@ -9446,7 +9471,6 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9446
9471
|
|
|
9447
9472
|
var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
|
|
9448
9473
|
|
|
9449
|
-
console.log((_s$goodsListState$for = s.goodsListState.form) === null || _s$goodsListState$for === void 0 ? void 0 : _s$goodsListState$for.getFieldsValue(), 'goodsListState');
|
|
9450
9474
|
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
9451
9475
|
lineAmountExcludeTax: _lineAmountExcludeTax3,
|
|
9452
9476
|
lineAmountIncludeTax: _lineAmountIncludeTax3,
|
|
@@ -9457,7 +9481,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9457
9481
|
});
|
|
9458
9482
|
|
|
9459
9483
|
if (needRefresh) {
|
|
9460
|
-
s.goodsListState.goodsList =
|
|
9484
|
+
s.goodsListState.goodsList = newGoodsList;
|
|
9461
9485
|
}
|
|
9462
9486
|
}
|
|
9463
9487
|
} catch (e) {
|
|
@@ -9466,23 +9490,23 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
9466
9490
|
|
|
9467
9491
|
case 5:
|
|
9468
9492
|
case "end":
|
|
9469
|
-
return
|
|
9493
|
+
return _context21.stop();
|
|
9470
9494
|
}
|
|
9471
9495
|
}
|
|
9472
|
-
},
|
|
9496
|
+
}, _callee21);
|
|
9473
9497
|
}));
|
|
9474
9498
|
|
|
9475
|
-
return function (
|
|
9476
|
-
return
|
|
9499
|
+
return function (_x41) {
|
|
9500
|
+
return _ref22.apply(this, arguments);
|
|
9477
9501
|
};
|
|
9478
9502
|
}());
|
|
9479
9503
|
|
|
9480
|
-
case
|
|
9504
|
+
case 10:
|
|
9481
9505
|
case "end":
|
|
9482
|
-
return
|
|
9506
|
+
return _context22.stop();
|
|
9483
9507
|
}
|
|
9484
9508
|
}
|
|
9485
|
-
},
|
|
9509
|
+
}, _callee22);
|
|
9486
9510
|
}));
|
|
9487
9511
|
|
|
9488
9512
|
return function onChangeSwitchTax(_x38, _x39) {
|
|
@@ -18836,32 +18860,62 @@ var onChangeItemName$1 = /*#__PURE__*/function () {
|
|
|
18836
18860
|
/** 修改了含税开关 重新计算 */
|
|
18837
18861
|
|
|
18838
18862
|
var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
18839
|
-
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18863
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(controller, isTaxIncluded) {
|
|
18840
18864
|
var calculatingDigits;
|
|
18841
|
-
return _regeneratorRuntime().wrap(function
|
|
18865
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
18842
18866
|
while (1) {
|
|
18843
|
-
switch (
|
|
18867
|
+
switch (_context20.prev = _context20.next) {
|
|
18844
18868
|
case 0:
|
|
18869
|
+
if (controller.state.goodsListState.isRecalculateWhenSwitchTax) {
|
|
18870
|
+
_context20.next = 3;
|
|
18871
|
+
break;
|
|
18872
|
+
}
|
|
18873
|
+
|
|
18874
|
+
controller.pipeline( /*#__PURE__*/function () {
|
|
18875
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(s) {
|
|
18876
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
18877
|
+
while (1) {
|
|
18878
|
+
switch (_context18.prev = _context18.next) {
|
|
18879
|
+
case 0:
|
|
18880
|
+
s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
|
|
18881
|
+
isTaxIncluded: isTaxIncluded
|
|
18882
|
+
});
|
|
18883
|
+
|
|
18884
|
+
case 1:
|
|
18885
|
+
case "end":
|
|
18886
|
+
return _context18.stop();
|
|
18887
|
+
}
|
|
18888
|
+
}
|
|
18889
|
+
}, _callee18);
|
|
18890
|
+
}));
|
|
18891
|
+
|
|
18892
|
+
return function (_x36) {
|
|
18893
|
+
return _ref19.apply(this, arguments);
|
|
18894
|
+
};
|
|
18895
|
+
}())();
|
|
18896
|
+
return _context20.abrupt("return");
|
|
18897
|
+
|
|
18898
|
+
case 3:
|
|
18845
18899
|
calculatingDigits = controller.state.calculatingDigits;
|
|
18846
|
-
|
|
18900
|
+
_context20.next = 6;
|
|
18847
18901
|
return controller.saveEditGood();
|
|
18848
18902
|
|
|
18849
|
-
case
|
|
18850
|
-
|
|
18903
|
+
case 6:
|
|
18904
|
+
_context20.next = 8;
|
|
18851
18905
|
return controller.wait();
|
|
18852
18906
|
|
|
18853
|
-
case
|
|
18854
|
-
|
|
18907
|
+
case 8:
|
|
18908
|
+
_context20.next = 10;
|
|
18855
18909
|
return controller.run( /*#__PURE__*/function () {
|
|
18856
|
-
var
|
|
18857
|
-
var _s$goodsListState, needRefresh,
|
|
18910
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(s) {
|
|
18911
|
+
var _s$goodsListState, needRefresh, newGoodsList;
|
|
18858
18912
|
|
|
18859
|
-
return _regeneratorRuntime().wrap(function
|
|
18913
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
18860
18914
|
while (1) {
|
|
18861
|
-
switch (
|
|
18915
|
+
switch (_context19.prev = _context19.next) {
|
|
18862
18916
|
case 0:
|
|
18863
18917
|
if (!s.goodsListState.editGood) {
|
|
18864
|
-
|
|
18918
|
+
_context19.next = 3;
|
|
18865
18919
|
break;
|
|
18866
18920
|
}
|
|
18867
18921
|
|
|
@@ -18869,7 +18923,7 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18869
18923
|
content: '你正在编辑一个货物',
|
|
18870
18924
|
key: '你正在编辑一个货物'
|
|
18871
18925
|
});
|
|
18872
|
-
return
|
|
18926
|
+
return _context19.abrupt("return");
|
|
18873
18927
|
|
|
18874
18928
|
case 3:
|
|
18875
18929
|
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
@@ -18878,7 +18932,7 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18878
18932
|
needRefresh = false;
|
|
18879
18933
|
|
|
18880
18934
|
if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
|
|
18881
|
-
|
|
18935
|
+
newGoodsList = s.goodsListState.goodsList.map(function (good) {
|
|
18882
18936
|
var sourceQuantity = good.quantity,
|
|
18883
18937
|
sourcePriceExcludeTax = good.priceExcludeTax,
|
|
18884
18938
|
sourcePriceIncludeTax = good.priceIncludeTax,
|
|
@@ -18892,11 +18946,9 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18892
18946
|
if (!taxRate && taxRate !== 0) return good;
|
|
18893
18947
|
|
|
18894
18948
|
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && mathjs.equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
18895
|
-
console.log('equal');
|
|
18896
18949
|
return good;
|
|
18897
18950
|
} else {
|
|
18898
18951
|
needRefresh = true;
|
|
18899
|
-
console.log('not equal');
|
|
18900
18952
|
}
|
|
18901
18953
|
|
|
18902
18954
|
var quantity = format15(sourceQuantity, calculatingDigits);
|
|
@@ -18912,18 +18964,14 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18912
18964
|
priceExcludeTax: priceExcludeTax
|
|
18913
18965
|
});
|
|
18914
18966
|
} else {
|
|
18915
|
-
var _s$goodsListState$for;
|
|
18916
|
-
|
|
18917
18967
|
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
18918
18968
|
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
18919
18969
|
if (!taxRate && taxRate !== 0) return good;
|
|
18920
18970
|
|
|
18921
18971
|
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && mathjs.equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
18922
|
-
console.log('equal');
|
|
18923
18972
|
return good;
|
|
18924
18973
|
} else {
|
|
18925
18974
|
needRefresh = true;
|
|
18926
|
-
console.log('not equal');
|
|
18927
18975
|
}
|
|
18928
18976
|
|
|
18929
18977
|
var _quantity5 = format15(sourceQuantity, calculatingDigits);
|
|
@@ -18938,7 +18986,6 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18938
18986
|
|
|
18939
18987
|
var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
|
|
18940
18988
|
|
|
18941
|
-
console.log((_s$goodsListState$for = s.goodsListState.form) === null || _s$goodsListState$for === void 0 ? void 0 : _s$goodsListState$for.getFieldsValue(), 'goodsListState');
|
|
18942
18989
|
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
18943
18990
|
lineAmountExcludeTax: _lineAmountExcludeTax3,
|
|
18944
18991
|
lineAmountIncludeTax: _lineAmountIncludeTax3,
|
|
@@ -18949,7 +18996,7 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18949
18996
|
});
|
|
18950
18997
|
|
|
18951
18998
|
if (needRefresh) {
|
|
18952
|
-
s.goodsListState.goodsList =
|
|
18999
|
+
s.goodsListState.goodsList = newGoodsList;
|
|
18953
19000
|
}
|
|
18954
19001
|
}
|
|
18955
19002
|
} catch (e) {
|
|
@@ -18958,23 +19005,23 @@ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
|
18958
19005
|
|
|
18959
19006
|
case 5:
|
|
18960
19007
|
case "end":
|
|
18961
|
-
return
|
|
19008
|
+
return _context19.stop();
|
|
18962
19009
|
}
|
|
18963
19010
|
}
|
|
18964
|
-
},
|
|
19011
|
+
}, _callee19);
|
|
18965
19012
|
}));
|
|
18966
19013
|
|
|
18967
|
-
return function (
|
|
18968
|
-
return
|
|
19014
|
+
return function (_x37) {
|
|
19015
|
+
return _ref20.apply(this, arguments);
|
|
18969
19016
|
};
|
|
18970
19017
|
}());
|
|
18971
19018
|
|
|
18972
|
-
case
|
|
19019
|
+
case 10:
|
|
18973
19020
|
case "end":
|
|
18974
|
-
return
|
|
19021
|
+
return _context20.stop();
|
|
18975
19022
|
}
|
|
18976
19023
|
}
|
|
18977
|
-
},
|
|
19024
|
+
}, _callee20);
|
|
18978
19025
|
}));
|
|
18979
19026
|
|
|
18980
19027
|
return function onChangeSwitchTax(_x34, _x35) {
|
|
@@ -23594,14 +23641,17 @@ var DrawerBody$3 = function DrawerBody(props) {
|
|
|
23594
23641
|
good.taxRate = values.taxRate;
|
|
23595
23642
|
good.taxFreeType = values.taxFreeType;
|
|
23596
23643
|
good.favouredPolicyMark = values.favouredPolicyMark;
|
|
23597
|
-
good.favouredPolicyName = values.favouredPolicyName;
|
|
23598
|
-
var taxRate = mathjs.chain(mathjs.bignumber(values.taxRate)).dotDivide(mathjs.bignumber(100)).add(mathjs.bignumber(1)).done(); // 是否含税
|
|
23644
|
+
good.favouredPolicyName = values.favouredPolicyName; // 无论是否含税,都保持价税合计不变
|
|
23599
23645
|
|
|
23600
|
-
var lineAmountExcludeTax = mathjs.chain(mathjs.bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
|
|
23601
|
-
var priceExcludeTax = good.priceIncludeTax ? mathjs.chain(mathjs.bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined;
|
|
23602
|
-
good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
|
|
23603
|
-
good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber(), s.calculatingDigits) : undefined) || undefined;
|
|
23604
23646
|
good.taxAmount = countTaxAmount(good.lineAmountIncludeTax || 0, s.goodsListState.deduction, values.taxRate);
|
|
23647
|
+
|
|
23648
|
+
if (good.taxAmount || good.taxAmount === 0) {
|
|
23649
|
+
good.lineAmountExcludeTax = countAmountExcludeTax(good.lineAmountIncludeTax || 0, good.taxAmount);
|
|
23650
|
+
}
|
|
23651
|
+
|
|
23652
|
+
if (good.lineAmountExcludeTax && good.quantity) {
|
|
23653
|
+
good.priceExcludeTax = countPrice(good.lineAmountExcludeTax, good.quantity, controller.state.calculatingDigits);
|
|
23654
|
+
}
|
|
23605
23655
|
});
|
|
23606
23656
|
s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
|
|
23607
23657
|
s.goodsListState.endowCode.endowcodeGoodIndex = [];
|
package/package.json
CHANGED
|
@@ -18,6 +18,9 @@ export default class GoodsListState {
|
|
|
18
18
|
/** 是否可以切换(含税/不含税)状态 */
|
|
19
19
|
isSwitchTax?: boolean;
|
|
20
20
|
|
|
21
|
+
/** 切换含税时是否重新计算 */
|
|
22
|
+
isRecalculateWhenSwitchTax = false;
|
|
23
|
+
|
|
21
24
|
/** 是否能添加折扣行 */
|
|
22
25
|
isAddDiscount?: boolean;
|
|
23
26
|
|
|
@@ -110,4 +113,5 @@ export default class GoodsListState {
|
|
|
110
113
|
|
|
111
114
|
/** 商品拖拽数据 */
|
|
112
115
|
drag = new Drag();
|
|
116
|
+
|
|
113
117
|
}
|
|
@@ -6,7 +6,7 @@ import { Input, NumberPicker } from '@formily/antd-components';
|
|
|
6
6
|
import { format15 } from '../GoodsList/hook/useColumns/autoFillFn';
|
|
7
7
|
import { LineAttributeType } from '../../../InvoiceController';
|
|
8
8
|
import IGood from '../../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
|
|
9
|
-
import { countTaxAmount } from '../../../tools/calculate';
|
|
9
|
+
import { countTaxAmount, countAmountExcludeTax, countPrice } from '../../../tools/calculate';
|
|
10
10
|
import { bytesLnegth, cutStr } from '../../../tools/strringFn';
|
|
11
11
|
import {
|
|
12
12
|
SchemaForm,
|
|
@@ -428,16 +428,15 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
|
|
|
428
428
|
good.favouredPolicyMark = values.favouredPolicyMark;
|
|
429
429
|
good.favouredPolicyName = values.favouredPolicyName;
|
|
430
430
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
// 是否含税
|
|
434
|
-
const lineAmountExcludeTax = chain(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
|
|
435
|
-
const priceExcludeTax = good.priceIncludeTax ? chain(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined
|
|
436
|
-
|
|
437
|
-
good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
|
|
438
|
-
good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber(), s.calculatingDigits) : undefined) || undefined;
|
|
439
|
-
|
|
431
|
+
// 无论是否含税,都保持价税合计不变
|
|
440
432
|
good.taxAmount = countTaxAmount(good.lineAmountIncludeTax || 0, s.goodsListState.deduction, values.taxRate);
|
|
433
|
+
if (good.taxAmount || good.taxAmount === 0 ) {
|
|
434
|
+
good.lineAmountExcludeTax = countAmountExcludeTax(good.lineAmountIncludeTax || 0, good.taxAmount);
|
|
435
|
+
}
|
|
436
|
+
if (good.lineAmountExcludeTax && good.quantity) {
|
|
437
|
+
good.priceExcludeTax = countPrice(good.lineAmountExcludeTax, good.quantity, controller.state.calculatingDigits) as any;
|
|
438
|
+
}
|
|
439
|
+
|
|
441
440
|
});
|
|
442
441
|
|
|
443
442
|
s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
|
|
@@ -535,6 +535,10 @@ export const onChangeItemCode = async (controller: InvoiceController, form: Wrap
|
|
|
535
535
|
|
|
536
536
|
/** 修改了含税开关 重新计算 */
|
|
537
537
|
export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncluded: boolean) => {
|
|
538
|
+
if (!controller.state.goodsListState.isRecalculateWhenSwitchTax) {
|
|
539
|
+
controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded } })();
|
|
540
|
+
return
|
|
541
|
+
}
|
|
538
542
|
const calculatingDigits = controller.state.calculatingDigits;
|
|
539
543
|
|
|
540
544
|
await controller.saveEditGood();
|
|
@@ -556,7 +560,7 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
556
560
|
let needRefresh = false;
|
|
557
561
|
|
|
558
562
|
if (s.goodsListState?.goodsList && s.goodsListState.goodsList.length) {
|
|
559
|
-
const
|
|
563
|
+
const newGoodsList = s.goodsListState.goodsList.map(good => {
|
|
560
564
|
const {
|
|
561
565
|
quantity: sourceQuantity,
|
|
562
566
|
priceExcludeTax: sourcePriceExcludeTax,
|
|
@@ -569,11 +573,9 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
569
573
|
if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
|
|
570
574
|
if (!taxRate && taxRate !== 0) return good;
|
|
571
575
|
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
572
|
-
console.log('equal')
|
|
573
576
|
return good
|
|
574
577
|
} else {
|
|
575
578
|
needRefresh = true;
|
|
576
|
-
console.log('not equal')
|
|
577
579
|
}
|
|
578
580
|
const quantity: any = format15(sourceQuantity, calculatingDigits);
|
|
579
581
|
const priceIncludeTax: any = format15(sourcePriceIncludeTax, calculatingDigits);
|
|
@@ -596,11 +598,9 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
596
598
|
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
597
599
|
if (!taxRate && taxRate !== 0) return good;
|
|
598
600
|
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
599
|
-
console.log('equal')
|
|
600
601
|
return good
|
|
601
602
|
} else {
|
|
602
603
|
needRefresh = true;
|
|
603
|
-
console.log('not equal')
|
|
604
604
|
}
|
|
605
605
|
const quantity: any = format15(sourceQuantity, calculatingDigits);
|
|
606
606
|
const priceExcludeTax: any = format15(sourcePriceExcludeTax, calculatingDigits);
|
|
@@ -610,8 +610,6 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
610
610
|
const priceIncludeTax: any = format15(evaluate(`${lineAmountIncludeTax} / ${quantity}`), calculatingDigits);
|
|
611
611
|
const taxAmount: any = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
|
|
612
612
|
|
|
613
|
-
console.log(s.goodsListState.form?.getFieldsValue(), 'goodsListState')
|
|
614
|
-
|
|
615
613
|
return {
|
|
616
614
|
...good,
|
|
617
615
|
lineAmountExcludeTax,
|
|
@@ -624,7 +622,7 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
624
622
|
})
|
|
625
623
|
|
|
626
624
|
if (needRefresh) {
|
|
627
|
-
s.goodsListState.goodsList =
|
|
625
|
+
s.goodsListState.goodsList = newGoodsList;
|
|
628
626
|
}
|
|
629
627
|
}
|
|
630
628
|
} catch(e) {
|
|
@@ -527,6 +527,10 @@ export const onChangeItemName = async (controller: InvoiceController, form: Wrap
|
|
|
527
527
|
|
|
528
528
|
/** 修改了含税开关 重新计算 */
|
|
529
529
|
export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncluded: boolean) => {
|
|
530
|
+
if (!controller.state.goodsListState.isRecalculateWhenSwitchTax) {
|
|
531
|
+
controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded } })();
|
|
532
|
+
return
|
|
533
|
+
}
|
|
530
534
|
const calculatingDigits = controller.state.calculatingDigits;
|
|
531
535
|
|
|
532
536
|
await controller.saveEditGood();
|
|
@@ -548,7 +552,7 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
548
552
|
let needRefresh = false;
|
|
549
553
|
|
|
550
554
|
if (s.goodsListState?.goodsList && s.goodsListState.goodsList.length) {
|
|
551
|
-
const
|
|
555
|
+
const newGoodsList = s.goodsListState.goodsList.map(good => {
|
|
552
556
|
const {
|
|
553
557
|
quantity: sourceQuantity,
|
|
554
558
|
priceExcludeTax: sourcePriceExcludeTax,
|
|
@@ -561,11 +565,9 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
561
565
|
if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
|
|
562
566
|
if (!taxRate && taxRate !== 0) return good;
|
|
563
567
|
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
564
|
-
console.log('equal')
|
|
565
568
|
return good
|
|
566
569
|
} else {
|
|
567
570
|
needRefresh = true;
|
|
568
|
-
console.log('not equal')
|
|
569
571
|
}
|
|
570
572
|
const quantity: any = format15(sourceQuantity, calculatingDigits);
|
|
571
573
|
const priceIncludeTax: any = format15(sourcePriceIncludeTax, calculatingDigits);
|
|
@@ -588,11 +590,9 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
588
590
|
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
589
591
|
if (!taxRate && taxRate !== 0) return good;
|
|
590
592
|
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
591
|
-
console.log('equal')
|
|
592
593
|
return good
|
|
593
594
|
} else {
|
|
594
595
|
needRefresh = true;
|
|
595
|
-
console.log('not equal')
|
|
596
596
|
}
|
|
597
597
|
const quantity: any = format15(sourceQuantity, calculatingDigits);
|
|
598
598
|
const priceExcludeTax: any = format15(sourcePriceExcludeTax, calculatingDigits);
|
|
@@ -602,8 +602,6 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
602
602
|
const priceIncludeTax: any = format15(evaluate(`${lineAmountIncludeTax} / ${quantity}`), calculatingDigits);
|
|
603
603
|
const taxAmount: any = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
|
|
604
604
|
|
|
605
|
-
console.log(s.goodsListState.form?.getFieldsValue(), 'goodsListState')
|
|
606
|
-
|
|
607
605
|
return {
|
|
608
606
|
...good,
|
|
609
607
|
lineAmountExcludeTax,
|
|
@@ -616,11 +614,11 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
616
614
|
})
|
|
617
615
|
|
|
618
616
|
if (needRefresh) {
|
|
619
|
-
s.goodsListState.goodsList =
|
|
617
|
+
s.goodsListState.goodsList = newGoodsList;
|
|
620
618
|
}
|
|
621
619
|
}
|
|
622
620
|
} catch(e) {
|
|
623
621
|
console.error('切换税率重新计算出错', e, s.goodsListState)
|
|
624
622
|
}
|
|
625
623
|
})
|
|
626
|
-
}
|
|
624
|
+
}
|