kts-component-invoice-operate 3.2.121-1 → 3.2.121-2
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/ui/default/GoodsList/hook/useColumns/autoFillFn/index.d.ts +2 -0
- package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.d.ts +1 -1
- package/dist/index.esm.js +163 -31
- package/dist/index.js +163 -31
- package/package.json +1 -1
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +101 -0
- package/src/Invoice/ui/default/GoodsList/ui/TaxIncludedSwitch/index.tsx +2 -1
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +3 -1
|
@@ -35,3 +35,5 @@ export declare const endowCode: (controller: InvoiceController, goods: IGood) =>
|
|
|
35
35
|
export declare const onChangeItemName: (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => Promise<void>;
|
|
36
36
|
/** 修改了 商品编码 */
|
|
37
37
|
export declare const onChangeItemCode: (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => Promise<void>;
|
|
38
|
+
/** 修改了含税开关 重新计算 */
|
|
39
|
+
export declare const onChangeSwitchTax: (controller: InvoiceController, isTaxIncluded: boolean) => Promise<void>;
|
|
@@ -33,5 +33,5 @@ export declare const onSaveEditGood: (...par: any[]) => void;
|
|
|
33
33
|
export declare const endowCode: (controller: InvoiceController, goods: IGood) => Promise<void>;
|
|
34
34
|
/** 修改了 项目名称 */
|
|
35
35
|
export declare const onChangeItemName: (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => Promise<void>;
|
|
36
|
-
/**
|
|
36
|
+
/** 修改了含税开关 重新计算 */
|
|
37
37
|
export declare const onChangeSwitchTax: (controller: InvoiceController, isTaxIncluded: boolean) => Promise<void>;
|
package/dist/index.esm.js
CHANGED
|
@@ -9331,6 +9331,154 @@ var onChangeItemCode = /*#__PURE__*/function () {
|
|
|
9331
9331
|
return _ref18.apply(this, arguments);
|
|
9332
9332
|
};
|
|
9333
9333
|
}();
|
|
9334
|
+
/** 修改了含税开关 重新计算 */
|
|
9335
|
+
|
|
9336
|
+
var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
9337
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(controller, isTaxIncluded) {
|
|
9338
|
+
var calculatingDigits;
|
|
9339
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
9340
|
+
while (1) {
|
|
9341
|
+
switch (_context21.prev = _context21.next) {
|
|
9342
|
+
case 0:
|
|
9343
|
+
calculatingDigits = controller.state.calculatingDigits;
|
|
9344
|
+
_context21.next = 3;
|
|
9345
|
+
return controller.saveEditGood();
|
|
9346
|
+
|
|
9347
|
+
case 3:
|
|
9348
|
+
_context21.next = 5;
|
|
9349
|
+
return controller.wait();
|
|
9350
|
+
|
|
9351
|
+
case 5:
|
|
9352
|
+
_context21.next = 7;
|
|
9353
|
+
return controller.run( /*#__PURE__*/function () {
|
|
9354
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(s) {
|
|
9355
|
+
var _s$goodsListState, needRefresh, newGoodList;
|
|
9356
|
+
|
|
9357
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
9358
|
+
while (1) {
|
|
9359
|
+
switch (_context20.prev = _context20.next) {
|
|
9360
|
+
case 0:
|
|
9361
|
+
if (!s.goodsListState.editGood) {
|
|
9362
|
+
_context20.next = 3;
|
|
9363
|
+
break;
|
|
9364
|
+
}
|
|
9365
|
+
|
|
9366
|
+
message.error({
|
|
9367
|
+
content: '你正在编辑一个货物',
|
|
9368
|
+
key: '你正在编辑一个货物'
|
|
9369
|
+
});
|
|
9370
|
+
return _context20.abrupt("return");
|
|
9371
|
+
|
|
9372
|
+
case 3:
|
|
9373
|
+
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
9374
|
+
|
|
9375
|
+
try {
|
|
9376
|
+
needRefresh = false;
|
|
9377
|
+
|
|
9378
|
+
if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
|
|
9379
|
+
newGoodList = s.goodsListState.goodsList.map(function (good) {
|
|
9380
|
+
var sourceQuantity = good.quantity,
|
|
9381
|
+
sourcePriceExcludeTax = good.priceExcludeTax,
|
|
9382
|
+
sourcePriceIncludeTax = good.priceIncludeTax,
|
|
9383
|
+
sourceLineAmountExcludeTax = good.lineAmountExcludeTax,
|
|
9384
|
+
sourceLineAmountIncludeTax = good.lineAmountIncludeTax,
|
|
9385
|
+
taxRate = good.taxRate;
|
|
9386
|
+
|
|
9387
|
+
if (isTaxIncluded) {
|
|
9388
|
+
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
9389
|
+
if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
|
|
9390
|
+
if (!taxRate && taxRate !== 0) return good;
|
|
9391
|
+
|
|
9392
|
+
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
9393
|
+
console.log('equal');
|
|
9394
|
+
return good;
|
|
9395
|
+
} else {
|
|
9396
|
+
needRefresh = true;
|
|
9397
|
+
console.log('not equal');
|
|
9398
|
+
}
|
|
9399
|
+
|
|
9400
|
+
var quantity = format15(sourceQuantity, calculatingDigits);
|
|
9401
|
+
var priceIncludeTax = format15(sourcePriceIncludeTax, calculatingDigits);
|
|
9402
|
+
var lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
|
|
9403
|
+
var taxAmount = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate);
|
|
9404
|
+
var lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
|
|
9405
|
+
var priceExcludeTax = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
|
|
9406
|
+
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
9407
|
+
lineAmountExcludeTax: lineAmountExcludeTax,
|
|
9408
|
+
lineAmountIncludeTax: lineAmountIncludeTax,
|
|
9409
|
+
taxAmount: taxAmount,
|
|
9410
|
+
priceExcludeTax: priceExcludeTax
|
|
9411
|
+
});
|
|
9412
|
+
} else {
|
|
9413
|
+
var _s$goodsListState$for;
|
|
9414
|
+
|
|
9415
|
+
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
9416
|
+
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
9417
|
+
if (!taxRate && taxRate !== 0) return good;
|
|
9418
|
+
|
|
9419
|
+
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
9420
|
+
console.log('equal');
|
|
9421
|
+
return good;
|
|
9422
|
+
} else {
|
|
9423
|
+
needRefresh = true;
|
|
9424
|
+
console.log('not equal');
|
|
9425
|
+
}
|
|
9426
|
+
|
|
9427
|
+
var _quantity5 = format15(sourceQuantity, calculatingDigits);
|
|
9428
|
+
|
|
9429
|
+
var _priceExcludeTax3 = format15(sourcePriceExcludeTax, calculatingDigits);
|
|
9430
|
+
|
|
9431
|
+
var _lineAmountExcludeTax3 = format2(evaluate("".concat(_priceExcludeTax3, " * ").concat(_quantity5)));
|
|
9432
|
+
|
|
9433
|
+
var _lineAmountIncludeTax3 = format2(evaluate("".concat(_lineAmountExcludeTax3, " * (1+(").concat(taxRate, "/100))")));
|
|
9434
|
+
|
|
9435
|
+
var _priceIncludeTax3 = format15(evaluate("".concat(_lineAmountIncludeTax3, " / ").concat(_quantity5)), calculatingDigits);
|
|
9436
|
+
|
|
9437
|
+
var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
|
|
9438
|
+
|
|
9439
|
+
console.log((_s$goodsListState$for = s.goodsListState.form) === null || _s$goodsListState$for === void 0 ? void 0 : _s$goodsListState$for.getFieldsValue(), 'goodsListState');
|
|
9440
|
+
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
9441
|
+
lineAmountExcludeTax: _lineAmountExcludeTax3,
|
|
9442
|
+
lineAmountIncludeTax: _lineAmountIncludeTax3,
|
|
9443
|
+
taxAmount: _taxAmount,
|
|
9444
|
+
priceIncludeTax: _priceIncludeTax3
|
|
9445
|
+
});
|
|
9446
|
+
}
|
|
9447
|
+
});
|
|
9448
|
+
|
|
9449
|
+
if (needRefresh) {
|
|
9450
|
+
s.goodsListState.goodsList = newGoodList;
|
|
9451
|
+
}
|
|
9452
|
+
}
|
|
9453
|
+
} catch (e) {
|
|
9454
|
+
console.error('切换税率重新计算出错', e, s.goodsListState);
|
|
9455
|
+
}
|
|
9456
|
+
|
|
9457
|
+
case 5:
|
|
9458
|
+
case "end":
|
|
9459
|
+
return _context20.stop();
|
|
9460
|
+
}
|
|
9461
|
+
}
|
|
9462
|
+
}, _callee20);
|
|
9463
|
+
}));
|
|
9464
|
+
|
|
9465
|
+
return function (_x40) {
|
|
9466
|
+
return _ref21.apply(this, arguments);
|
|
9467
|
+
};
|
|
9468
|
+
}());
|
|
9469
|
+
|
|
9470
|
+
case 7:
|
|
9471
|
+
case "end":
|
|
9472
|
+
return _context21.stop();
|
|
9473
|
+
}
|
|
9474
|
+
}
|
|
9475
|
+
}, _callee21);
|
|
9476
|
+
}));
|
|
9477
|
+
|
|
9478
|
+
return function onChangeSwitchTax(_x38, _x39) {
|
|
9479
|
+
return _ref20.apply(this, arguments);
|
|
9480
|
+
};
|
|
9481
|
+
}();
|
|
9334
9482
|
|
|
9335
9483
|
/**
|
|
9336
9484
|
* 删除一个货物
|
|
@@ -10240,28 +10388,7 @@ var TaxIncludedSwitch = (function () {
|
|
|
10240
10388
|
return e.goodsListState.isSwitchTax;
|
|
10241
10389
|
}, []);
|
|
10242
10390
|
var onChange = React.useCallback(function (e) {
|
|
10243
|
-
controller
|
|
10244
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
|
|
10245
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10246
|
-
while (1) {
|
|
10247
|
-
switch (_context.prev = _context.next) {
|
|
10248
|
-
case 0:
|
|
10249
|
-
s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
|
|
10250
|
-
isTaxIncluded: e
|
|
10251
|
-
});
|
|
10252
|
-
|
|
10253
|
-
case 1:
|
|
10254
|
-
case "end":
|
|
10255
|
-
return _context.stop();
|
|
10256
|
-
}
|
|
10257
|
-
}
|
|
10258
|
-
}, _callee);
|
|
10259
|
-
}));
|
|
10260
|
-
|
|
10261
|
-
return function (_x) {
|
|
10262
|
-
return _ref.apply(this, arguments);
|
|
10263
|
-
};
|
|
10264
|
-
}())();
|
|
10391
|
+
onChangeSwitchTax(controller, e);
|
|
10265
10392
|
}, []);
|
|
10266
10393
|
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("label", {
|
|
10267
10394
|
style: {
|
|
@@ -18696,9 +18823,9 @@ var onChangeItemName$1 = /*#__PURE__*/function () {
|
|
|
18696
18823
|
return _ref16.apply(this, arguments);
|
|
18697
18824
|
};
|
|
18698
18825
|
}();
|
|
18699
|
-
/**
|
|
18826
|
+
/** 修改了含税开关 重新计算 */
|
|
18700
18827
|
|
|
18701
|
-
var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
18828
|
+
var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
18702
18829
|
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(controller, isTaxIncluded) {
|
|
18703
18830
|
var calculatingDigits;
|
|
18704
18831
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
@@ -18723,13 +18850,18 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
18723
18850
|
while (1) {
|
|
18724
18851
|
switch (_context18.prev = _context18.next) {
|
|
18725
18852
|
case 0:
|
|
18726
|
-
if (s.goodsListState.editGood) {
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
key: '你正在编辑一个货物'
|
|
18730
|
-
});
|
|
18853
|
+
if (!s.goodsListState.editGood) {
|
|
18854
|
+
_context18.next = 3;
|
|
18855
|
+
break;
|
|
18731
18856
|
}
|
|
18732
18857
|
|
|
18858
|
+
message.error({
|
|
18859
|
+
content: '你正在编辑一个货物',
|
|
18860
|
+
key: '你正在编辑一个货物'
|
|
18861
|
+
});
|
|
18862
|
+
return _context18.abrupt("return");
|
|
18863
|
+
|
|
18864
|
+
case 3:
|
|
18733
18865
|
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
18734
18866
|
|
|
18735
18867
|
try {
|
|
@@ -18814,7 +18946,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
18814
18946
|
console.error('切换税率重新计算出错', e, s.goodsListState);
|
|
18815
18947
|
}
|
|
18816
18948
|
|
|
18817
|
-
case
|
|
18949
|
+
case 5:
|
|
18818
18950
|
case "end":
|
|
18819
18951
|
return _context18.stop();
|
|
18820
18952
|
}
|
|
@@ -18858,7 +18990,7 @@ var TaxIncludedSwitch$1 = (function () {
|
|
|
18858
18990
|
while (1) {
|
|
18859
18991
|
switch (_context.prev = _context.next) {
|
|
18860
18992
|
case 0:
|
|
18861
|
-
onChangeSwitchTax(controller, e);
|
|
18993
|
+
onChangeSwitchTax$1(controller, e);
|
|
18862
18994
|
|
|
18863
18995
|
case 1:
|
|
18864
18996
|
case "end":
|
package/dist/index.js
CHANGED
|
@@ -9341,6 +9341,154 @@ var onChangeItemCode = /*#__PURE__*/function () {
|
|
|
9341
9341
|
return _ref18.apply(this, arguments);
|
|
9342
9342
|
};
|
|
9343
9343
|
}();
|
|
9344
|
+
/** 修改了含税开关 重新计算 */
|
|
9345
|
+
|
|
9346
|
+
var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
9347
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(controller, isTaxIncluded) {
|
|
9348
|
+
var calculatingDigits;
|
|
9349
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
9350
|
+
while (1) {
|
|
9351
|
+
switch (_context21.prev = _context21.next) {
|
|
9352
|
+
case 0:
|
|
9353
|
+
calculatingDigits = controller.state.calculatingDigits;
|
|
9354
|
+
_context21.next = 3;
|
|
9355
|
+
return controller.saveEditGood();
|
|
9356
|
+
|
|
9357
|
+
case 3:
|
|
9358
|
+
_context21.next = 5;
|
|
9359
|
+
return controller.wait();
|
|
9360
|
+
|
|
9361
|
+
case 5:
|
|
9362
|
+
_context21.next = 7;
|
|
9363
|
+
return controller.run( /*#__PURE__*/function () {
|
|
9364
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(s) {
|
|
9365
|
+
var _s$goodsListState, needRefresh, newGoodList;
|
|
9366
|
+
|
|
9367
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
9368
|
+
while (1) {
|
|
9369
|
+
switch (_context20.prev = _context20.next) {
|
|
9370
|
+
case 0:
|
|
9371
|
+
if (!s.goodsListState.editGood) {
|
|
9372
|
+
_context20.next = 3;
|
|
9373
|
+
break;
|
|
9374
|
+
}
|
|
9375
|
+
|
|
9376
|
+
ktsComponentsAntdX3.message.error({
|
|
9377
|
+
content: '你正在编辑一个货物',
|
|
9378
|
+
key: '你正在编辑一个货物'
|
|
9379
|
+
});
|
|
9380
|
+
return _context20.abrupt("return");
|
|
9381
|
+
|
|
9382
|
+
case 3:
|
|
9383
|
+
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
9384
|
+
|
|
9385
|
+
try {
|
|
9386
|
+
needRefresh = false;
|
|
9387
|
+
|
|
9388
|
+
if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
|
|
9389
|
+
newGoodList = s.goodsListState.goodsList.map(function (good) {
|
|
9390
|
+
var sourceQuantity = good.quantity,
|
|
9391
|
+
sourcePriceExcludeTax = good.priceExcludeTax,
|
|
9392
|
+
sourcePriceIncludeTax = good.priceIncludeTax,
|
|
9393
|
+
sourceLineAmountExcludeTax = good.lineAmountExcludeTax,
|
|
9394
|
+
sourceLineAmountIncludeTax = good.lineAmountIncludeTax,
|
|
9395
|
+
taxRate = good.taxRate;
|
|
9396
|
+
|
|
9397
|
+
if (isTaxIncluded) {
|
|
9398
|
+
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
9399
|
+
if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
|
|
9400
|
+
if (!taxRate && taxRate !== 0) return good;
|
|
9401
|
+
|
|
9402
|
+
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && mathjs.equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
9403
|
+
console.log('equal');
|
|
9404
|
+
return good;
|
|
9405
|
+
} else {
|
|
9406
|
+
needRefresh = true;
|
|
9407
|
+
console.log('not equal');
|
|
9408
|
+
}
|
|
9409
|
+
|
|
9410
|
+
var quantity = format15(sourceQuantity, calculatingDigits);
|
|
9411
|
+
var priceIncludeTax = format15(sourcePriceIncludeTax, calculatingDigits);
|
|
9412
|
+
var lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
|
|
9413
|
+
var taxAmount = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate);
|
|
9414
|
+
var lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
|
|
9415
|
+
var priceExcludeTax = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
|
|
9416
|
+
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
9417
|
+
lineAmountExcludeTax: lineAmountExcludeTax,
|
|
9418
|
+
lineAmountIncludeTax: lineAmountIncludeTax,
|
|
9419
|
+
taxAmount: taxAmount,
|
|
9420
|
+
priceExcludeTax: priceExcludeTax
|
|
9421
|
+
});
|
|
9422
|
+
} else {
|
|
9423
|
+
var _s$goodsListState$for;
|
|
9424
|
+
|
|
9425
|
+
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
9426
|
+
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
9427
|
+
if (!taxRate && taxRate !== 0) return good;
|
|
9428
|
+
|
|
9429
|
+
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && mathjs.equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
9430
|
+
console.log('equal');
|
|
9431
|
+
return good;
|
|
9432
|
+
} else {
|
|
9433
|
+
needRefresh = true;
|
|
9434
|
+
console.log('not equal');
|
|
9435
|
+
}
|
|
9436
|
+
|
|
9437
|
+
var _quantity5 = format15(sourceQuantity, calculatingDigits);
|
|
9438
|
+
|
|
9439
|
+
var _priceExcludeTax3 = format15(sourcePriceExcludeTax, calculatingDigits);
|
|
9440
|
+
|
|
9441
|
+
var _lineAmountExcludeTax3 = format2(evaluate("".concat(_priceExcludeTax3, " * ").concat(_quantity5)));
|
|
9442
|
+
|
|
9443
|
+
var _lineAmountIncludeTax3 = format2(evaluate("".concat(_lineAmountExcludeTax3, " * (1+(").concat(taxRate, "/100))")));
|
|
9444
|
+
|
|
9445
|
+
var _priceIncludeTax3 = format15(evaluate("".concat(_lineAmountIncludeTax3, " / ").concat(_quantity5)), calculatingDigits);
|
|
9446
|
+
|
|
9447
|
+
var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
|
|
9448
|
+
|
|
9449
|
+
console.log((_s$goodsListState$for = s.goodsListState.form) === null || _s$goodsListState$for === void 0 ? void 0 : _s$goodsListState$for.getFieldsValue(), 'goodsListState');
|
|
9450
|
+
return _objectSpread2(_objectSpread2({}, good), {}, {
|
|
9451
|
+
lineAmountExcludeTax: _lineAmountExcludeTax3,
|
|
9452
|
+
lineAmountIncludeTax: _lineAmountIncludeTax3,
|
|
9453
|
+
taxAmount: _taxAmount,
|
|
9454
|
+
priceIncludeTax: _priceIncludeTax3
|
|
9455
|
+
});
|
|
9456
|
+
}
|
|
9457
|
+
});
|
|
9458
|
+
|
|
9459
|
+
if (needRefresh) {
|
|
9460
|
+
s.goodsListState.goodsList = newGoodList;
|
|
9461
|
+
}
|
|
9462
|
+
}
|
|
9463
|
+
} catch (e) {
|
|
9464
|
+
console.error('切换税率重新计算出错', e, s.goodsListState);
|
|
9465
|
+
}
|
|
9466
|
+
|
|
9467
|
+
case 5:
|
|
9468
|
+
case "end":
|
|
9469
|
+
return _context20.stop();
|
|
9470
|
+
}
|
|
9471
|
+
}
|
|
9472
|
+
}, _callee20);
|
|
9473
|
+
}));
|
|
9474
|
+
|
|
9475
|
+
return function (_x40) {
|
|
9476
|
+
return _ref21.apply(this, arguments);
|
|
9477
|
+
};
|
|
9478
|
+
}());
|
|
9479
|
+
|
|
9480
|
+
case 7:
|
|
9481
|
+
case "end":
|
|
9482
|
+
return _context21.stop();
|
|
9483
|
+
}
|
|
9484
|
+
}
|
|
9485
|
+
}, _callee21);
|
|
9486
|
+
}));
|
|
9487
|
+
|
|
9488
|
+
return function onChangeSwitchTax(_x38, _x39) {
|
|
9489
|
+
return _ref20.apply(this, arguments);
|
|
9490
|
+
};
|
|
9491
|
+
}();
|
|
9344
9492
|
|
|
9345
9493
|
/**
|
|
9346
9494
|
* 删除一个货物
|
|
@@ -10250,28 +10398,7 @@ var TaxIncludedSwitch = (function () {
|
|
|
10250
10398
|
return e.goodsListState.isSwitchTax;
|
|
10251
10399
|
}, []);
|
|
10252
10400
|
var onChange = React__default['default'].useCallback(function (e) {
|
|
10253
|
-
controller
|
|
10254
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
|
|
10255
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10256
|
-
while (1) {
|
|
10257
|
-
switch (_context.prev = _context.next) {
|
|
10258
|
-
case 0:
|
|
10259
|
-
s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
|
|
10260
|
-
isTaxIncluded: e
|
|
10261
|
-
});
|
|
10262
|
-
|
|
10263
|
-
case 1:
|
|
10264
|
-
case "end":
|
|
10265
|
-
return _context.stop();
|
|
10266
|
-
}
|
|
10267
|
-
}
|
|
10268
|
-
}, _callee);
|
|
10269
|
-
}));
|
|
10270
|
-
|
|
10271
|
-
return function (_x) {
|
|
10272
|
-
return _ref.apply(this, arguments);
|
|
10273
|
-
};
|
|
10274
|
-
}())();
|
|
10401
|
+
onChangeSwitchTax(controller, e);
|
|
10275
10402
|
}, []);
|
|
10276
10403
|
return /*#__PURE__*/React__default['default'].createElement("span", null, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
10277
10404
|
style: {
|
|
@@ -18706,9 +18833,9 @@ var onChangeItemName$1 = /*#__PURE__*/function () {
|
|
|
18706
18833
|
return _ref16.apply(this, arguments);
|
|
18707
18834
|
};
|
|
18708
18835
|
}();
|
|
18709
|
-
/**
|
|
18836
|
+
/** 修改了含税开关 重新计算 */
|
|
18710
18837
|
|
|
18711
|
-
var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
18838
|
+
var onChangeSwitchTax$1 = /*#__PURE__*/function () {
|
|
18712
18839
|
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(controller, isTaxIncluded) {
|
|
18713
18840
|
var calculatingDigits;
|
|
18714
18841
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
@@ -18733,13 +18860,18 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
18733
18860
|
while (1) {
|
|
18734
18861
|
switch (_context18.prev = _context18.next) {
|
|
18735
18862
|
case 0:
|
|
18736
|
-
if (s.goodsListState.editGood) {
|
|
18737
|
-
|
|
18738
|
-
|
|
18739
|
-
key: '你正在编辑一个货物'
|
|
18740
|
-
});
|
|
18863
|
+
if (!s.goodsListState.editGood) {
|
|
18864
|
+
_context18.next = 3;
|
|
18865
|
+
break;
|
|
18741
18866
|
}
|
|
18742
18867
|
|
|
18868
|
+
ktsComponentsAntdX3.message.error({
|
|
18869
|
+
content: '你正在编辑一个货物',
|
|
18870
|
+
key: '你正在编辑一个货物'
|
|
18871
|
+
});
|
|
18872
|
+
return _context18.abrupt("return");
|
|
18873
|
+
|
|
18874
|
+
case 3:
|
|
18743
18875
|
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
18744
18876
|
|
|
18745
18877
|
try {
|
|
@@ -18824,7 +18956,7 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
|
|
|
18824
18956
|
console.error('切换税率重新计算出错', e, s.goodsListState);
|
|
18825
18957
|
}
|
|
18826
18958
|
|
|
18827
|
-
case
|
|
18959
|
+
case 5:
|
|
18828
18960
|
case "end":
|
|
18829
18961
|
return _context18.stop();
|
|
18830
18962
|
}
|
|
@@ -18868,7 +19000,7 @@ var TaxIncludedSwitch$1 = (function () {
|
|
|
18868
19000
|
while (1) {
|
|
18869
19001
|
switch (_context.prev = _context.next) {
|
|
18870
19002
|
case 0:
|
|
18871
|
-
onChangeSwitchTax(controller, e);
|
|
19003
|
+
onChangeSwitchTax$1(controller, e);
|
|
18872
19004
|
|
|
18873
19005
|
case 1:
|
|
18874
19006
|
case "end":
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import evaluate from '../../../../../../tools/evaluate';
|
|
|
10
10
|
import { message } from 'kts-components-antd-x3'
|
|
11
11
|
import { format2, format15, countTaxAmount, countAmountExcludeTax, countPrice } from '../../../../../../tools/calculate';
|
|
12
12
|
import moment from 'moment';
|
|
13
|
+
import { equal } from 'mathjs';
|
|
13
14
|
|
|
14
15
|
export { format2, format15 } from '../../../../../../tools/calculate';
|
|
15
16
|
|
|
@@ -531,3 +532,103 @@ export const onChangeItemCode = async (controller: InvoiceController, form: Wrap
|
|
|
531
532
|
}
|
|
532
533
|
})
|
|
533
534
|
}
|
|
535
|
+
|
|
536
|
+
/** 修改了含税开关 重新计算 */
|
|
537
|
+
export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncluded: boolean) => {
|
|
538
|
+
const calculatingDigits = controller.state.calculatingDigits;
|
|
539
|
+
|
|
540
|
+
await controller.saveEditGood();
|
|
541
|
+
await controller.wait();
|
|
542
|
+
|
|
543
|
+
await controller.run(async s => {
|
|
544
|
+
if (s.goodsListState.editGood) {
|
|
545
|
+
message.error({
|
|
546
|
+
content: '你正在编辑一个货物',
|
|
547
|
+
key: '你正在编辑一个货物',
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
return ;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
s.goodsListState.isTaxIncluded = isTaxIncluded;
|
|
554
|
+
|
|
555
|
+
try {
|
|
556
|
+
let needRefresh = false;
|
|
557
|
+
|
|
558
|
+
if (s.goodsListState?.goodsList && s.goodsListState.goodsList.length) {
|
|
559
|
+
const newGoodList = s.goodsListState.goodsList.map(good => {
|
|
560
|
+
const {
|
|
561
|
+
quantity: sourceQuantity,
|
|
562
|
+
priceExcludeTax: sourcePriceExcludeTax,
|
|
563
|
+
priceIncludeTax: sourcePriceIncludeTax,
|
|
564
|
+
lineAmountExcludeTax: sourceLineAmountExcludeTax,
|
|
565
|
+
lineAmountIncludeTax: sourceLineAmountIncludeTax,
|
|
566
|
+
taxRate } = good;
|
|
567
|
+
if (isTaxIncluded) {
|
|
568
|
+
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
569
|
+
if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
|
|
570
|
+
if (!taxRate && taxRate !== 0) return good;
|
|
571
|
+
if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
|
|
572
|
+
console.log('equal')
|
|
573
|
+
return good
|
|
574
|
+
} else {
|
|
575
|
+
needRefresh = true;
|
|
576
|
+
console.log('not equal')
|
|
577
|
+
}
|
|
578
|
+
const quantity: any = format15(sourceQuantity, calculatingDigits);
|
|
579
|
+
const priceIncludeTax: any = format15(sourcePriceIncludeTax, calculatingDigits);
|
|
580
|
+
|
|
581
|
+
const lineAmountIncludeTax: any = format2(evaluate(`${priceIncludeTax} * ${quantity}`));
|
|
582
|
+
const taxAmount: any = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate as any);
|
|
583
|
+
const lineAmountExcludeTax: any = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
|
|
584
|
+
const priceExcludeTax: any = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
|
|
585
|
+
|
|
586
|
+
return {
|
|
587
|
+
...good,
|
|
588
|
+
lineAmountExcludeTax,
|
|
589
|
+
lineAmountIncludeTax,
|
|
590
|
+
taxAmount,
|
|
591
|
+
priceExcludeTax
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
} else {
|
|
595
|
+
if (!sourceQuantity && sourceQuantity !== 0) return good;
|
|
596
|
+
if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
|
|
597
|
+
if (!taxRate && taxRate !== 0) return good;
|
|
598
|
+
if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
|
|
599
|
+
console.log('equal')
|
|
600
|
+
return good
|
|
601
|
+
} else {
|
|
602
|
+
needRefresh = true;
|
|
603
|
+
console.log('not equal')
|
|
604
|
+
}
|
|
605
|
+
const quantity: any = format15(sourceQuantity, calculatingDigits);
|
|
606
|
+
const priceExcludeTax: any = format15(sourcePriceExcludeTax, calculatingDigits);
|
|
607
|
+
|
|
608
|
+
const lineAmountExcludeTax: any = format2(evaluate(`${priceExcludeTax} * ${quantity}`));
|
|
609
|
+
const lineAmountIncludeTax: any = format2(evaluate(`${lineAmountExcludeTax} * (1+(${taxRate}/100))`));
|
|
610
|
+
const priceIncludeTax: any = format15(evaluate(`${lineAmountIncludeTax} / ${quantity}`), calculatingDigits);
|
|
611
|
+
const taxAmount: any = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
|
|
612
|
+
|
|
613
|
+
console.log(s.goodsListState.form?.getFieldsValue(), 'goodsListState')
|
|
614
|
+
|
|
615
|
+
return {
|
|
616
|
+
...good,
|
|
617
|
+
lineAmountExcludeTax,
|
|
618
|
+
lineAmountIncludeTax,
|
|
619
|
+
taxAmount,
|
|
620
|
+
priceIncludeTax
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
if (needRefresh) {
|
|
627
|
+
s.goodsListState.goodsList = newGoodList;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
} catch(e) {
|
|
631
|
+
console.error('切换税率重新计算出错', e, s.goodsListState)
|
|
632
|
+
}
|
|
633
|
+
})
|
|
634
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Switch } from 'kts-xui';
|
|
4
4
|
import Invoice from '../../../../..';
|
|
5
|
+
import { onChangeSwitchTax } from '../../hook/useColumns/autoFillFn';
|
|
5
6
|
|
|
6
7
|
export default () => {
|
|
7
8
|
|
|
@@ -14,7 +15,7 @@ export default () => {
|
|
|
14
15
|
const isSwitchTax = controller.useMemo(e => e.goodsListState.isSwitchTax, []);
|
|
15
16
|
|
|
16
17
|
const onChange = React.useCallback(e => {
|
|
17
|
-
controller
|
|
18
|
+
onChangeSwitchTax(controller, e)
|
|
18
19
|
}, [])
|
|
19
20
|
|
|
20
21
|
return (
|
|
@@ -525,7 +525,7 @@ export const onChangeItemName = async (controller: InvoiceController, form: Wrap
|
|
|
525
525
|
})
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
/**
|
|
528
|
+
/** 修改了含税开关 重新计算 */
|
|
529
529
|
export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncluded: boolean) => {
|
|
530
530
|
const calculatingDigits = controller.state.calculatingDigits;
|
|
531
531
|
|
|
@@ -538,6 +538,8 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
|
|
|
538
538
|
content: '你正在编辑一个货物',
|
|
539
539
|
key: '你正在编辑一个货物',
|
|
540
540
|
});
|
|
541
|
+
|
|
542
|
+
return ;
|
|
541
543
|
}
|
|
542
544
|
|
|
543
545
|
s.goodsListState.isTaxIncluded = isTaxIncluded;
|