kts-component-invoice-operate 1.2.19 → 1.2.21
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/index.esm.js +102 -116
- package/dist/index.js +102 -116
- package/docs/index.md +2 -2
- package/docs-dist/umi.js +1 -1
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +3 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +1 -1
- package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +4 -3
- package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +6 -24
- package/src/Invoice/ui/GoodsList/ui/AddDiscountRowButton/index.tsx +6 -16
package/dist/index.esm.js
CHANGED
|
@@ -354,54 +354,58 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
|
|
|
354
354
|
while (1) {
|
|
355
355
|
switch (_context.prev = _context.next) {
|
|
356
356
|
case 0:
|
|
357
|
+
_context.next = 2;
|
|
358
|
+
return this.wait();
|
|
359
|
+
|
|
360
|
+
case 2:
|
|
357
361
|
_errors = new Map();
|
|
358
362
|
_values = new Map();
|
|
359
363
|
arr = Array.from(this.formList);
|
|
360
364
|
i = 0;
|
|
361
365
|
|
|
362
|
-
case
|
|
366
|
+
case 6:
|
|
363
367
|
if (!(i < arr.length)) {
|
|
364
|
-
_context.next =
|
|
368
|
+
_context.next = 18;
|
|
365
369
|
break;
|
|
366
370
|
}
|
|
367
371
|
|
|
368
372
|
key = arr[i][0];
|
|
369
|
-
_context.next =
|
|
373
|
+
_context.next = 10;
|
|
370
374
|
return _validateFields(arr[i][1]);
|
|
371
375
|
|
|
372
|
-
case
|
|
376
|
+
case 10:
|
|
373
377
|
_yield$_validateField = _context.sent;
|
|
374
378
|
errors = _yield$_validateField.errors;
|
|
375
379
|
values = _yield$_validateField.values;
|
|
376
380
|
errors && _errors.set(key, errors);
|
|
377
381
|
_values && _values.set(key, values);
|
|
378
382
|
|
|
379
|
-
case
|
|
383
|
+
case 15:
|
|
380
384
|
i++;
|
|
381
|
-
_context.next =
|
|
385
|
+
_context.next = 6;
|
|
382
386
|
break;
|
|
383
387
|
|
|
384
|
-
case
|
|
388
|
+
case 18:
|
|
385
389
|
if (!this.state.goodsListState.form) {
|
|
386
|
-
_context.next =
|
|
390
|
+
_context.next = 27;
|
|
387
391
|
break;
|
|
388
392
|
}
|
|
389
393
|
|
|
390
|
-
_context.prev =
|
|
391
|
-
_context.next =
|
|
394
|
+
_context.prev = 19;
|
|
395
|
+
_context.next = 22;
|
|
392
396
|
return (_this$state$goodsList = this.state.goodsListState.form) === null || _this$state$goodsList === void 0 ? void 0 : _this$state$goodsList.validateFields();
|
|
393
397
|
|
|
394
|
-
case
|
|
395
|
-
_context.next =
|
|
398
|
+
case 22:
|
|
399
|
+
_context.next = 27;
|
|
396
400
|
break;
|
|
397
401
|
|
|
398
|
-
case
|
|
399
|
-
_context.prev =
|
|
400
|
-
_context.t0 = _context["catch"](
|
|
402
|
+
case 24:
|
|
403
|
+
_context.prev = 24;
|
|
404
|
+
_context.t0 = _context["catch"](19);
|
|
401
405
|
|
|
402
406
|
_errors.set('goodsList', _context.t0.errors);
|
|
403
407
|
|
|
404
|
-
case
|
|
408
|
+
case 27:
|
|
405
409
|
_values.set('goodsList', this.state.goodsListState.goodsList.slice()); // 金额(含税)
|
|
406
410
|
|
|
407
411
|
|
|
@@ -445,12 +449,12 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
|
|
|
445
449
|
values: _values
|
|
446
450
|
});
|
|
447
451
|
|
|
448
|
-
case
|
|
452
|
+
case 32:
|
|
449
453
|
case "end":
|
|
450
454
|
return _context.stop();
|
|
451
455
|
}
|
|
452
456
|
}
|
|
453
|
-
}, _callee, this, [[
|
|
457
|
+
}, _callee, this, [[19, 24]]);
|
|
454
458
|
}));
|
|
455
459
|
|
|
456
460
|
function validateFields() {
|
|
@@ -642,7 +646,7 @@ var GoodsListState = function GoodsListState() {
|
|
|
642
646
|
this.form = void 0;
|
|
643
647
|
this.unitList = [];
|
|
644
648
|
this.defaultRate = 3;
|
|
645
|
-
this.taxRateList = [0, 3, 5, 6, 9,
|
|
649
|
+
this.taxRateList = [0, 3, 5, 6, 9, 13];
|
|
646
650
|
this.goodsList = [];
|
|
647
651
|
this.goodsMap = new Map();
|
|
648
652
|
this.goodsMenuExpand = [];
|
|
@@ -868,6 +872,77 @@ var idGenerator = (function () {
|
|
|
868
872
|
return ++id;
|
|
869
873
|
});
|
|
870
874
|
|
|
875
|
+
/** 格式化 保留2位小数 */
|
|
876
|
+
|
|
877
|
+
var format2 = function format2(value) {
|
|
878
|
+
if (value === Infinity) return '';
|
|
879
|
+
if ("".concat(value) === 'NaN') return '';
|
|
880
|
+
if (typeof value === 'string') value = parseFloat(value);
|
|
881
|
+
return parseFloat(value.toFixed(2));
|
|
882
|
+
};
|
|
883
|
+
/** 格式化 保留15位数字 */
|
|
884
|
+
|
|
885
|
+
var format15 = function format15(value) {
|
|
886
|
+
if (value === Infinity) return '';
|
|
887
|
+
if ("".concat(value) === 'NaN') return '';
|
|
888
|
+
if (typeof value === 'string') value = parseFloat(value);
|
|
889
|
+
var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
|
|
890
|
+
return parseFloat(value.toFixed(fractionDigits > 8 ? 8 : fractionDigits));
|
|
891
|
+
};
|
|
892
|
+
/**
|
|
893
|
+
* 金额(含税) = 数量 * 单价(含税)
|
|
894
|
+
* @param quantity 数量
|
|
895
|
+
* @param priceIncludeTax 单价(含税)
|
|
896
|
+
* @returns 金额(含税)
|
|
897
|
+
*/
|
|
898
|
+
|
|
899
|
+
function countAmountIncludeTax(quantity, priceIncludeTax) {
|
|
900
|
+
if (!quantity && quantity !== 0) return undefined;
|
|
901
|
+
if (!priceIncludeTax && priceIncludeTax !== 0) return undefined;
|
|
902
|
+
quantity = format15(quantity);
|
|
903
|
+
priceIncludeTax = format15(priceIncludeTax);
|
|
904
|
+
return parseFloat(chain$1(bignumber(priceIncludeTax)).multiply(bignumber(quantity)).done().toNumber().toFixed(2)); // return parseFloat(evaluate(`${priceIncludeTax} * ${quantity}`).toFixed(2));
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* 不含税金额 = 含税金额-税额
|
|
908
|
+
* @param amountIncludeTax 含税金额
|
|
909
|
+
* @param taxAmount 税额
|
|
910
|
+
* @returns 不含税金额
|
|
911
|
+
*/
|
|
912
|
+
|
|
913
|
+
function countAmountExcludeTax(amountIncludeTax, taxAmount) {
|
|
914
|
+
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
915
|
+
if (!taxAmount && taxAmount !== 0) return undefined;
|
|
916
|
+
return chain$1(bignumber(amountIncludeTax)).subtract(bignumber(taxAmount)).done().toNumber();
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* 税额 = (含税金额-扣除额)/(1+税率)*税率
|
|
920
|
+
* @param amountIncludeTax 含税金额
|
|
921
|
+
* @param deduction 扣除额
|
|
922
|
+
* @param taxRate 税率
|
|
923
|
+
* @returns 税额
|
|
924
|
+
*/
|
|
925
|
+
|
|
926
|
+
function countTaxAmount(amountIncludeTax, deduction, taxRate) {
|
|
927
|
+
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
928
|
+
if (!deduction && deduction !== 0) return undefined;
|
|
929
|
+
if (!taxRate && taxRate !== 0) return undefined;
|
|
930
|
+
var taxRateBu = chain$1(bignumber(taxRate)).divide(bignumber(100)).done();
|
|
931
|
+
return parseFloat(chain$1(bignumber(amountIncludeTax)).subtract(bignumber(deduction)).divide(chain$1(bignumber(1)).add(taxRateBu).done()).multiply(taxRateBu).done().toNumber().toFixed(2));
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* 单价 = 金额/数量
|
|
935
|
+
* @param amount 金额
|
|
936
|
+
* @param quantity 数量
|
|
937
|
+
* @returns 单价
|
|
938
|
+
*/
|
|
939
|
+
|
|
940
|
+
function countPrice(amount, quantity) {
|
|
941
|
+
if (!amount && amount !== 0) return undefined;
|
|
942
|
+
if (!quantity && quantity !== 0) return undefined;
|
|
943
|
+
return format15(chain$1(bignumber(amount)).divide(bignumber(quantity)).done().toNumber());
|
|
944
|
+
}
|
|
945
|
+
|
|
871
946
|
/**
|
|
872
947
|
* 设置当前的编辑货物
|
|
873
948
|
*/
|
|
@@ -931,7 +1006,7 @@ var addGoodDiscount = /*#__PURE__*/(function () {
|
|
|
931
1006
|
amountSum = amountSum.add(bignumber(lineAmountExcludeTax));
|
|
932
1007
|
/** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
|
|
933
1008
|
|
|
934
|
-
lineAmountIncludeTax = chain$1(bignumber(lineAmountExcludeTax)).multiply(chain$1(bignumber(1)).add(taxRate).done()).done().toNumber();
|
|
1009
|
+
lineAmountIncludeTax = format2(chain$1(bignumber(lineAmountExcludeTax)).multiply(chain$1(bignumber(1)).add(taxRate).done()).done().toNumber());
|
|
935
1010
|
}
|
|
936
1011
|
/** 税额 */
|
|
937
1012
|
|
|
@@ -2042,7 +2117,7 @@ var DrawerBody = decorator(Form.create())(function (props) {
|
|
|
2042
2117
|
});
|
|
2043
2118
|
});
|
|
2044
2119
|
}, 300), [form, lineAmountSum]);
|
|
2045
|
-
/**
|
|
2120
|
+
/** 折扣变化 */
|
|
2046
2121
|
|
|
2047
2122
|
var onChangeDiscolineAmountunt = React.useCallback(lazyFn(function (e) {
|
|
2048
2123
|
form.validateFields(function (err, values) {
|
|
@@ -2467,77 +2542,6 @@ var useAddDiscount = (function (goods) {
|
|
|
2467
2542
|
}, [onClick, goods.lineAttribute]);
|
|
2468
2543
|
});
|
|
2469
2544
|
|
|
2470
|
-
/** 格式化 保留2位小数 */
|
|
2471
|
-
|
|
2472
|
-
var format2 = function format2(value) {
|
|
2473
|
-
if (value === Infinity) return '';
|
|
2474
|
-
if ("".concat(value) === 'NaN') return '';
|
|
2475
|
-
if (typeof value === 'string') value = parseFloat(value);
|
|
2476
|
-
return parseFloat(value.toFixed(2));
|
|
2477
|
-
};
|
|
2478
|
-
/** 格式化 保留15位数字 */
|
|
2479
|
-
|
|
2480
|
-
var format15 = function format15(value) {
|
|
2481
|
-
if (value === Infinity) return '';
|
|
2482
|
-
if ("".concat(value) === 'NaN') return '';
|
|
2483
|
-
if (typeof value === 'string') value = parseFloat(value);
|
|
2484
|
-
var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
|
|
2485
|
-
return parseFloat(value.toFixed(fractionDigits > 8 ? 8 : fractionDigits));
|
|
2486
|
-
};
|
|
2487
|
-
/**
|
|
2488
|
-
* 金额(含税) = 数量 * 单价(含税)
|
|
2489
|
-
* @param quantity 数量
|
|
2490
|
-
* @param priceIncludeTax 单价(含税)
|
|
2491
|
-
* @returns 金额(含税)
|
|
2492
|
-
*/
|
|
2493
|
-
|
|
2494
|
-
function countAmountIncludeTax(quantity, priceIncludeTax) {
|
|
2495
|
-
if (!quantity && quantity !== 0) return undefined;
|
|
2496
|
-
if (!priceIncludeTax && priceIncludeTax !== 0) return undefined;
|
|
2497
|
-
quantity = format15(quantity);
|
|
2498
|
-
priceIncludeTax = format15(priceIncludeTax);
|
|
2499
|
-
return parseFloat(chain$1(bignumber(priceIncludeTax)).multiply(bignumber(quantity)).done().toNumber().toFixed(2)); // return parseFloat(evaluate(`${priceIncludeTax} * ${quantity}`).toFixed(2));
|
|
2500
|
-
}
|
|
2501
|
-
/**
|
|
2502
|
-
* 不含税金额 = 含税金额-税额
|
|
2503
|
-
* @param amountIncludeTax 含税金额
|
|
2504
|
-
* @param taxAmount 税额
|
|
2505
|
-
* @returns 不含税金额
|
|
2506
|
-
*/
|
|
2507
|
-
|
|
2508
|
-
function countAmountExcludeTax(amountIncludeTax, taxAmount) {
|
|
2509
|
-
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
2510
|
-
if (!taxAmount && taxAmount !== 0) return undefined;
|
|
2511
|
-
return chain$1(bignumber(amountIncludeTax)).subtract(bignumber(taxAmount)).done().toNumber();
|
|
2512
|
-
}
|
|
2513
|
-
/**
|
|
2514
|
-
* 税额 = (含税金额-扣除额)/(1+税率)*税率
|
|
2515
|
-
* @param amountIncludeTax 含税金额
|
|
2516
|
-
* @param deduction 扣除额
|
|
2517
|
-
* @param taxRate 税率
|
|
2518
|
-
* @returns 税额
|
|
2519
|
-
*/
|
|
2520
|
-
|
|
2521
|
-
function countTaxAmount(amountIncludeTax, deduction, taxRate) {
|
|
2522
|
-
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
2523
|
-
if (!deduction && deduction !== 0) return undefined;
|
|
2524
|
-
if (!taxRate && taxRate !== 0) return undefined;
|
|
2525
|
-
var taxRateBu = chain$1(bignumber(taxRate)).divide(bignumber(100)).done();
|
|
2526
|
-
return parseFloat(chain$1(bignumber(amountIncludeTax)).subtract(bignumber(deduction)).divide(chain$1(bignumber(1)).add(taxRateBu).done()).multiply(taxRateBu).done().toNumber().toFixed(2));
|
|
2527
|
-
}
|
|
2528
|
-
/**
|
|
2529
|
-
* 单价 = 金额/数量
|
|
2530
|
-
* @param amount 金额
|
|
2531
|
-
* @param quantity 数量
|
|
2532
|
-
* @returns 单价
|
|
2533
|
-
*/
|
|
2534
|
-
|
|
2535
|
-
function countPrice(amount, quantity) {
|
|
2536
|
-
if (!amount && amount !== 0) return undefined;
|
|
2537
|
-
if (!quantity && quantity !== 0) return undefined;
|
|
2538
|
-
return format15(chain$1(bignumber(amount)).divide(bignumber(quantity)).done().toNumber());
|
|
2539
|
-
}
|
|
2540
|
-
|
|
2541
2545
|
//! moment.js
|
|
2542
2546
|
//! version : 2.29.1
|
|
2543
2547
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
@@ -8836,6 +8840,11 @@ function dutyFree(controller, taxRate, form, record) {
|
|
|
8836
8840
|
var cache = controller.state.goodsListState.endowCode.cache;
|
|
8837
8841
|
var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
|
|
8838
8842
|
|
|
8843
|
+
console.log('===> 小规模纳税人免税逻辑');
|
|
8844
|
+
console.log('===> invoiceType', invoiceType);
|
|
8845
|
+
console.log('===> en', controller.state.en);
|
|
8846
|
+
console.log('===> taxRate', taxRate);
|
|
8847
|
+
console.log('===> state', controller.state);
|
|
8839
8848
|
if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
|
|
8840
8849
|
if (controller.state.en !== '08') return taxRate;
|
|
8841
8850
|
if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
|
|
@@ -8854,30 +8863,7 @@ function dutyFree(controller, taxRate, form, record) {
|
|
|
8854
8863
|
taxRate: 0
|
|
8855
8864
|
});
|
|
8856
8865
|
return 0;
|
|
8857
|
-
}
|
|
8858
|
-
// if (taxRate === 1 || taxRate === 3) {
|
|
8859
|
-
// 是否处理过
|
|
8860
|
-
// if (cache[record.$index]) {
|
|
8861
|
-
// return taxRate;
|
|
8862
|
-
// } else {
|
|
8863
|
-
// cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark,taxFreeType:record.taxFreeType }
|
|
8864
|
-
// record.favouredPolicyName = '免税';
|
|
8865
|
-
// record.taxRate = 0;
|
|
8866
|
-
// record.favouredPolicyMark = 1;
|
|
8867
|
-
// record.taxFreeType = 1 as any;
|
|
8868
|
-
// form.setFieldsValue({ taxRate: 0 });
|
|
8869
|
-
// return 0;
|
|
8870
|
-
// }
|
|
8871
|
-
// } else {
|
|
8872
|
-
// if (cache[record.$index] && cache[record.$index] !== true) {
|
|
8873
|
-
// record.favouredPolicyName = cache[record.$index].favouredPolicyName;
|
|
8874
|
-
// record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
|
|
8875
|
-
// record.taxFreeType = cache[record.$index].taxFreeType;
|
|
8876
|
-
// cache[record.$index] = true;
|
|
8877
|
-
// }
|
|
8878
|
-
// return taxRate;
|
|
8879
|
-
// }
|
|
8880
|
-
|
|
8866
|
+
}
|
|
8881
8867
|
}
|
|
8882
8868
|
/** 含税 => 更新(不含税) */
|
|
8883
8869
|
|
package/dist/index.js
CHANGED
|
@@ -364,54 +364,58 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
|
|
|
364
364
|
while (1) {
|
|
365
365
|
switch (_context.prev = _context.next) {
|
|
366
366
|
case 0:
|
|
367
|
+
_context.next = 2;
|
|
368
|
+
return this.wait();
|
|
369
|
+
|
|
370
|
+
case 2:
|
|
367
371
|
_errors = new Map();
|
|
368
372
|
_values = new Map();
|
|
369
373
|
arr = Array.from(this.formList);
|
|
370
374
|
i = 0;
|
|
371
375
|
|
|
372
|
-
case
|
|
376
|
+
case 6:
|
|
373
377
|
if (!(i < arr.length)) {
|
|
374
|
-
_context.next =
|
|
378
|
+
_context.next = 18;
|
|
375
379
|
break;
|
|
376
380
|
}
|
|
377
381
|
|
|
378
382
|
key = arr[i][0];
|
|
379
|
-
_context.next =
|
|
383
|
+
_context.next = 10;
|
|
380
384
|
return _validateFields(arr[i][1]);
|
|
381
385
|
|
|
382
|
-
case
|
|
386
|
+
case 10:
|
|
383
387
|
_yield$_validateField = _context.sent;
|
|
384
388
|
errors = _yield$_validateField.errors;
|
|
385
389
|
values = _yield$_validateField.values;
|
|
386
390
|
errors && _errors.set(key, errors);
|
|
387
391
|
_values && _values.set(key, values);
|
|
388
392
|
|
|
389
|
-
case
|
|
393
|
+
case 15:
|
|
390
394
|
i++;
|
|
391
|
-
_context.next =
|
|
395
|
+
_context.next = 6;
|
|
392
396
|
break;
|
|
393
397
|
|
|
394
|
-
case
|
|
398
|
+
case 18:
|
|
395
399
|
if (!this.state.goodsListState.form) {
|
|
396
|
-
_context.next =
|
|
400
|
+
_context.next = 27;
|
|
397
401
|
break;
|
|
398
402
|
}
|
|
399
403
|
|
|
400
|
-
_context.prev =
|
|
401
|
-
_context.next =
|
|
404
|
+
_context.prev = 19;
|
|
405
|
+
_context.next = 22;
|
|
402
406
|
return (_this$state$goodsList = this.state.goodsListState.form) === null || _this$state$goodsList === void 0 ? void 0 : _this$state$goodsList.validateFields();
|
|
403
407
|
|
|
404
|
-
case
|
|
405
|
-
_context.next =
|
|
408
|
+
case 22:
|
|
409
|
+
_context.next = 27;
|
|
406
410
|
break;
|
|
407
411
|
|
|
408
|
-
case
|
|
409
|
-
_context.prev =
|
|
410
|
-
_context.t0 = _context["catch"](
|
|
412
|
+
case 24:
|
|
413
|
+
_context.prev = 24;
|
|
414
|
+
_context.t0 = _context["catch"](19);
|
|
411
415
|
|
|
412
416
|
_errors.set('goodsList', _context.t0.errors);
|
|
413
417
|
|
|
414
|
-
case
|
|
418
|
+
case 27:
|
|
415
419
|
_values.set('goodsList', this.state.goodsListState.goodsList.slice()); // 金额(含税)
|
|
416
420
|
|
|
417
421
|
|
|
@@ -455,12 +459,12 @@ var InvoiceControllerForm = /*#__PURE__*/function (_GreyReactBox) {
|
|
|
455
459
|
values: _values
|
|
456
460
|
});
|
|
457
461
|
|
|
458
|
-
case
|
|
462
|
+
case 32:
|
|
459
463
|
case "end":
|
|
460
464
|
return _context.stop();
|
|
461
465
|
}
|
|
462
466
|
}
|
|
463
|
-
}, _callee, this, [[
|
|
467
|
+
}, _callee, this, [[19, 24]]);
|
|
464
468
|
}));
|
|
465
469
|
|
|
466
470
|
function validateFields() {
|
|
@@ -652,7 +656,7 @@ var GoodsListState = function GoodsListState() {
|
|
|
652
656
|
this.form = void 0;
|
|
653
657
|
this.unitList = [];
|
|
654
658
|
this.defaultRate = 3;
|
|
655
|
-
this.taxRateList = [0, 3, 5, 6, 9,
|
|
659
|
+
this.taxRateList = [0, 3, 5, 6, 9, 13];
|
|
656
660
|
this.goodsList = [];
|
|
657
661
|
this.goodsMap = new Map();
|
|
658
662
|
this.goodsMenuExpand = [];
|
|
@@ -878,6 +882,77 @@ var idGenerator = (function () {
|
|
|
878
882
|
return ++id;
|
|
879
883
|
});
|
|
880
884
|
|
|
885
|
+
/** 格式化 保留2位小数 */
|
|
886
|
+
|
|
887
|
+
var format2 = function format2(value) {
|
|
888
|
+
if (value === Infinity) return '';
|
|
889
|
+
if ("".concat(value) === 'NaN') return '';
|
|
890
|
+
if (typeof value === 'string') value = parseFloat(value);
|
|
891
|
+
return parseFloat(value.toFixed(2));
|
|
892
|
+
};
|
|
893
|
+
/** 格式化 保留15位数字 */
|
|
894
|
+
|
|
895
|
+
var format15 = function format15(value) {
|
|
896
|
+
if (value === Infinity) return '';
|
|
897
|
+
if ("".concat(value) === 'NaN') return '';
|
|
898
|
+
if (typeof value === 'string') value = parseFloat(value);
|
|
899
|
+
var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
|
|
900
|
+
return parseFloat(value.toFixed(fractionDigits > 8 ? 8 : fractionDigits));
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* 金额(含税) = 数量 * 单价(含税)
|
|
904
|
+
* @param quantity 数量
|
|
905
|
+
* @param priceIncludeTax 单价(含税)
|
|
906
|
+
* @returns 金额(含税)
|
|
907
|
+
*/
|
|
908
|
+
|
|
909
|
+
function countAmountIncludeTax(quantity, priceIncludeTax) {
|
|
910
|
+
if (!quantity && quantity !== 0) return undefined;
|
|
911
|
+
if (!priceIncludeTax && priceIncludeTax !== 0) return undefined;
|
|
912
|
+
quantity = format15(quantity);
|
|
913
|
+
priceIncludeTax = format15(priceIncludeTax);
|
|
914
|
+
return parseFloat(mathjs.chain(mathjs.bignumber(priceIncludeTax)).multiply(mathjs.bignumber(quantity)).done().toNumber().toFixed(2)); // return parseFloat(evaluate(`${priceIncludeTax} * ${quantity}`).toFixed(2));
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* 不含税金额 = 含税金额-税额
|
|
918
|
+
* @param amountIncludeTax 含税金额
|
|
919
|
+
* @param taxAmount 税额
|
|
920
|
+
* @returns 不含税金额
|
|
921
|
+
*/
|
|
922
|
+
|
|
923
|
+
function countAmountExcludeTax(amountIncludeTax, taxAmount) {
|
|
924
|
+
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
925
|
+
if (!taxAmount && taxAmount !== 0) return undefined;
|
|
926
|
+
return mathjs.chain(mathjs.bignumber(amountIncludeTax)).subtract(mathjs.bignumber(taxAmount)).done().toNumber();
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* 税额 = (含税金额-扣除额)/(1+税率)*税率
|
|
930
|
+
* @param amountIncludeTax 含税金额
|
|
931
|
+
* @param deduction 扣除额
|
|
932
|
+
* @param taxRate 税率
|
|
933
|
+
* @returns 税额
|
|
934
|
+
*/
|
|
935
|
+
|
|
936
|
+
function countTaxAmount(amountIncludeTax, deduction, taxRate) {
|
|
937
|
+
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
938
|
+
if (!deduction && deduction !== 0) return undefined;
|
|
939
|
+
if (!taxRate && taxRate !== 0) return undefined;
|
|
940
|
+
var taxRateBu = mathjs.chain(mathjs.bignumber(taxRate)).divide(mathjs.bignumber(100)).done();
|
|
941
|
+
return parseFloat(mathjs.chain(mathjs.bignumber(amountIncludeTax)).subtract(mathjs.bignumber(deduction)).divide(mathjs.chain(mathjs.bignumber(1)).add(taxRateBu).done()).multiply(taxRateBu).done().toNumber().toFixed(2));
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* 单价 = 金额/数量
|
|
945
|
+
* @param amount 金额
|
|
946
|
+
* @param quantity 数量
|
|
947
|
+
* @returns 单价
|
|
948
|
+
*/
|
|
949
|
+
|
|
950
|
+
function countPrice(amount, quantity) {
|
|
951
|
+
if (!amount && amount !== 0) return undefined;
|
|
952
|
+
if (!quantity && quantity !== 0) return undefined;
|
|
953
|
+
return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(quantity)).done().toNumber());
|
|
954
|
+
}
|
|
955
|
+
|
|
881
956
|
/**
|
|
882
957
|
* 设置当前的编辑货物
|
|
883
958
|
*/
|
|
@@ -941,7 +1016,7 @@ var addGoodDiscount = /*#__PURE__*/(function () {
|
|
|
941
1016
|
amountSum = amountSum.add(mathjs.bignumber(lineAmountExcludeTax));
|
|
942
1017
|
/** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
|
|
943
1018
|
|
|
944
|
-
lineAmountIncludeTax = mathjs.chain(mathjs.bignumber(lineAmountExcludeTax)).multiply(mathjs.chain(mathjs.bignumber(1)).add(taxRate).done()).done().toNumber();
|
|
1019
|
+
lineAmountIncludeTax = format2(mathjs.chain(mathjs.bignumber(lineAmountExcludeTax)).multiply(mathjs.chain(mathjs.bignumber(1)).add(taxRate).done()).done().toNumber());
|
|
945
1020
|
}
|
|
946
1021
|
/** 税额 */
|
|
947
1022
|
|
|
@@ -2052,7 +2127,7 @@ var DrawerBody = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(funct
|
|
|
2052
2127
|
});
|
|
2053
2128
|
});
|
|
2054
2129
|
}, 300), [form, lineAmountSum]);
|
|
2055
|
-
/**
|
|
2130
|
+
/** 折扣变化 */
|
|
2056
2131
|
|
|
2057
2132
|
var onChangeDiscolineAmountunt = React__default['default'].useCallback(lazyFn(function (e) {
|
|
2058
2133
|
form.validateFields(function (err, values) {
|
|
@@ -2477,77 +2552,6 @@ var useAddDiscount = (function (goods) {
|
|
|
2477
2552
|
}, [onClick, goods.lineAttribute]);
|
|
2478
2553
|
});
|
|
2479
2554
|
|
|
2480
|
-
/** 格式化 保留2位小数 */
|
|
2481
|
-
|
|
2482
|
-
var format2 = function format2(value) {
|
|
2483
|
-
if (value === Infinity) return '';
|
|
2484
|
-
if ("".concat(value) === 'NaN') return '';
|
|
2485
|
-
if (typeof value === 'string') value = parseFloat(value);
|
|
2486
|
-
return parseFloat(value.toFixed(2));
|
|
2487
|
-
};
|
|
2488
|
-
/** 格式化 保留15位数字 */
|
|
2489
|
-
|
|
2490
|
-
var format15 = function format15(value) {
|
|
2491
|
-
if (value === Infinity) return '';
|
|
2492
|
-
if ("".concat(value) === 'NaN') return '';
|
|
2493
|
-
if (typeof value === 'string') value = parseFloat(value);
|
|
2494
|
-
var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
|
|
2495
|
-
return parseFloat(value.toFixed(fractionDigits > 8 ? 8 : fractionDigits));
|
|
2496
|
-
};
|
|
2497
|
-
/**
|
|
2498
|
-
* 金额(含税) = 数量 * 单价(含税)
|
|
2499
|
-
* @param quantity 数量
|
|
2500
|
-
* @param priceIncludeTax 单价(含税)
|
|
2501
|
-
* @returns 金额(含税)
|
|
2502
|
-
*/
|
|
2503
|
-
|
|
2504
|
-
function countAmountIncludeTax(quantity, priceIncludeTax) {
|
|
2505
|
-
if (!quantity && quantity !== 0) return undefined;
|
|
2506
|
-
if (!priceIncludeTax && priceIncludeTax !== 0) return undefined;
|
|
2507
|
-
quantity = format15(quantity);
|
|
2508
|
-
priceIncludeTax = format15(priceIncludeTax);
|
|
2509
|
-
return parseFloat(mathjs.chain(mathjs.bignumber(priceIncludeTax)).multiply(mathjs.bignumber(quantity)).done().toNumber().toFixed(2)); // return parseFloat(evaluate(`${priceIncludeTax} * ${quantity}`).toFixed(2));
|
|
2510
|
-
}
|
|
2511
|
-
/**
|
|
2512
|
-
* 不含税金额 = 含税金额-税额
|
|
2513
|
-
* @param amountIncludeTax 含税金额
|
|
2514
|
-
* @param taxAmount 税额
|
|
2515
|
-
* @returns 不含税金额
|
|
2516
|
-
*/
|
|
2517
|
-
|
|
2518
|
-
function countAmountExcludeTax(amountIncludeTax, taxAmount) {
|
|
2519
|
-
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
2520
|
-
if (!taxAmount && taxAmount !== 0) return undefined;
|
|
2521
|
-
return mathjs.chain(mathjs.bignumber(amountIncludeTax)).subtract(mathjs.bignumber(taxAmount)).done().toNumber();
|
|
2522
|
-
}
|
|
2523
|
-
/**
|
|
2524
|
-
* 税额 = (含税金额-扣除额)/(1+税率)*税率
|
|
2525
|
-
* @param amountIncludeTax 含税金额
|
|
2526
|
-
* @param deduction 扣除额
|
|
2527
|
-
* @param taxRate 税率
|
|
2528
|
-
* @returns 税额
|
|
2529
|
-
*/
|
|
2530
|
-
|
|
2531
|
-
function countTaxAmount(amountIncludeTax, deduction, taxRate) {
|
|
2532
|
-
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
2533
|
-
if (!deduction && deduction !== 0) return undefined;
|
|
2534
|
-
if (!taxRate && taxRate !== 0) return undefined;
|
|
2535
|
-
var taxRateBu = mathjs.chain(mathjs.bignumber(taxRate)).divide(mathjs.bignumber(100)).done();
|
|
2536
|
-
return parseFloat(mathjs.chain(mathjs.bignumber(amountIncludeTax)).subtract(mathjs.bignumber(deduction)).divide(mathjs.chain(mathjs.bignumber(1)).add(taxRateBu).done()).multiply(taxRateBu).done().toNumber().toFixed(2));
|
|
2537
|
-
}
|
|
2538
|
-
/**
|
|
2539
|
-
* 单价 = 金额/数量
|
|
2540
|
-
* @param amount 金额
|
|
2541
|
-
* @param quantity 数量
|
|
2542
|
-
* @returns 单价
|
|
2543
|
-
*/
|
|
2544
|
-
|
|
2545
|
-
function countPrice(amount, quantity) {
|
|
2546
|
-
if (!amount && amount !== 0) return undefined;
|
|
2547
|
-
if (!quantity && quantity !== 0) return undefined;
|
|
2548
|
-
return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(quantity)).done().toNumber());
|
|
2549
|
-
}
|
|
2550
|
-
|
|
2551
2555
|
//! moment.js
|
|
2552
2556
|
//! version : 2.29.1
|
|
2553
2557
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
@@ -8846,6 +8850,11 @@ function dutyFree(controller, taxRate, form, record) {
|
|
|
8846
8850
|
var cache = controller.state.goodsListState.endowCode.cache;
|
|
8847
8851
|
var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
|
|
8848
8852
|
|
|
8853
|
+
console.log('===> 小规模纳税人免税逻辑');
|
|
8854
|
+
console.log('===> invoiceType', invoiceType);
|
|
8855
|
+
console.log('===> en', controller.state.en);
|
|
8856
|
+
console.log('===> taxRate', taxRate);
|
|
8857
|
+
console.log('===> state', controller.state);
|
|
8849
8858
|
if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
|
|
8850
8859
|
if (controller.state.en !== '08') return taxRate;
|
|
8851
8860
|
if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
|
|
@@ -8864,30 +8873,7 @@ function dutyFree(controller, taxRate, form, record) {
|
|
|
8864
8873
|
taxRate: 0
|
|
8865
8874
|
});
|
|
8866
8875
|
return 0;
|
|
8867
|
-
}
|
|
8868
|
-
// if (taxRate === 1 || taxRate === 3) {
|
|
8869
|
-
// 是否处理过
|
|
8870
|
-
// if (cache[record.$index]) {
|
|
8871
|
-
// return taxRate;
|
|
8872
|
-
// } else {
|
|
8873
|
-
// cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark,taxFreeType:record.taxFreeType }
|
|
8874
|
-
// record.favouredPolicyName = '免税';
|
|
8875
|
-
// record.taxRate = 0;
|
|
8876
|
-
// record.favouredPolicyMark = 1;
|
|
8877
|
-
// record.taxFreeType = 1 as any;
|
|
8878
|
-
// form.setFieldsValue({ taxRate: 0 });
|
|
8879
|
-
// return 0;
|
|
8880
|
-
// }
|
|
8881
|
-
// } else {
|
|
8882
|
-
// if (cache[record.$index] && cache[record.$index] !== true) {
|
|
8883
|
-
// record.favouredPolicyName = cache[record.$index].favouredPolicyName;
|
|
8884
|
-
// record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
|
|
8885
|
-
// record.taxFreeType = cache[record.$index].taxFreeType;
|
|
8886
|
-
// cache[record.$index] = true;
|
|
8887
|
-
// }
|
|
8888
|
-
// return taxRate;
|
|
8889
|
-
// }
|
|
8890
|
-
|
|
8876
|
+
}
|
|
8891
8877
|
}
|
|
8892
8878
|
/** 含税 => 更新(不含税) */
|
|
8893
8879
|
|
package/docs/index.md
CHANGED