kts-component-invoice-operate 1.2.20 → 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 CHANGED
@@ -646,7 +646,7 @@ var GoodsListState = function GoodsListState() {
646
646
  this.form = void 0;
647
647
  this.unitList = [];
648
648
  this.defaultRate = 3;
649
- this.taxRateList = [0, 3, 5, 6, 9, 12];
649
+ this.taxRateList = [0, 3, 5, 6, 9, 13];
650
650
  this.goodsList = [];
651
651
  this.goodsMap = new Map();
652
652
  this.goodsMenuExpand = [];
@@ -872,6 +872,77 @@ var idGenerator = (function () {
872
872
  return ++id;
873
873
  });
874
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
+
875
946
  /**
876
947
  * 设置当前的编辑货物
877
948
  */
@@ -935,7 +1006,7 @@ var addGoodDiscount = /*#__PURE__*/(function () {
935
1006
  amountSum = amountSum.add(bignumber(lineAmountExcludeTax));
936
1007
  /** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
937
1008
 
938
- 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());
939
1010
  }
940
1011
  /** 税额 */
941
1012
 
@@ -2046,7 +2117,7 @@ var DrawerBody = decorator(Form.create())(function (props) {
2046
2117
  });
2047
2118
  });
2048
2119
  }, 300), [form, lineAmountSum]);
2049
- /** 折扣率变化 */
2120
+ /** 折扣变化 */
2050
2121
 
2051
2122
  var onChangeDiscolineAmountunt = React.useCallback(lazyFn(function (e) {
2052
2123
  form.validateFields(function (err, values) {
@@ -2471,77 +2542,6 @@ var useAddDiscount = (function (goods) {
2471
2542
  }, [onClick, goods.lineAttribute]);
2472
2543
  });
2473
2544
 
2474
- /** 格式化 保留2位小数 */
2475
-
2476
- var format2 = function format2(value) {
2477
- if (value === Infinity) return '';
2478
- if ("".concat(value) === 'NaN') return '';
2479
- if (typeof value === 'string') value = parseFloat(value);
2480
- return parseFloat(value.toFixed(2));
2481
- };
2482
- /** 格式化 保留15位数字 */
2483
-
2484
- var format15 = function format15(value) {
2485
- if (value === Infinity) return '';
2486
- if ("".concat(value) === 'NaN') return '';
2487
- if (typeof value === 'string') value = parseFloat(value);
2488
- var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
2489
- return parseFloat(value.toFixed(fractionDigits > 8 ? 8 : fractionDigits));
2490
- };
2491
- /**
2492
- * 金额(含税) = 数量 * 单价(含税)
2493
- * @param quantity 数量
2494
- * @param priceIncludeTax 单价(含税)
2495
- * @returns 金额(含税)
2496
- */
2497
-
2498
- function countAmountIncludeTax(quantity, priceIncludeTax) {
2499
- if (!quantity && quantity !== 0) return undefined;
2500
- if (!priceIncludeTax && priceIncludeTax !== 0) return undefined;
2501
- quantity = format15(quantity);
2502
- priceIncludeTax = format15(priceIncludeTax);
2503
- return parseFloat(chain$1(bignumber(priceIncludeTax)).multiply(bignumber(quantity)).done().toNumber().toFixed(2)); // return parseFloat(evaluate(`${priceIncludeTax} * ${quantity}`).toFixed(2));
2504
- }
2505
- /**
2506
- * 不含税金额 = 含税金额-税额
2507
- * @param amountIncludeTax 含税金额
2508
- * @param taxAmount 税额
2509
- * @returns 不含税金额
2510
- */
2511
-
2512
- function countAmountExcludeTax(amountIncludeTax, taxAmount) {
2513
- if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
2514
- if (!taxAmount && taxAmount !== 0) return undefined;
2515
- return chain$1(bignumber(amountIncludeTax)).subtract(bignumber(taxAmount)).done().toNumber();
2516
- }
2517
- /**
2518
- * 税额 = (含税金额-扣除额)/(1+税率)*税率
2519
- * @param amountIncludeTax 含税金额
2520
- * @param deduction 扣除额
2521
- * @param taxRate 税率
2522
- * @returns 税额
2523
- */
2524
-
2525
- function countTaxAmount(amountIncludeTax, deduction, taxRate) {
2526
- if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
2527
- if (!deduction && deduction !== 0) return undefined;
2528
- if (!taxRate && taxRate !== 0) return undefined;
2529
- var taxRateBu = chain$1(bignumber(taxRate)).divide(bignumber(100)).done();
2530
- return parseFloat(chain$1(bignumber(amountIncludeTax)).subtract(bignumber(deduction)).divide(chain$1(bignumber(1)).add(taxRateBu).done()).multiply(taxRateBu).done().toNumber().toFixed(2));
2531
- }
2532
- /**
2533
- * 单价 = 金额/数量
2534
- * @param amount 金额
2535
- * @param quantity 数量
2536
- * @returns 单价
2537
- */
2538
-
2539
- function countPrice(amount, quantity) {
2540
- if (!amount && amount !== 0) return undefined;
2541
- if (!quantity && quantity !== 0) return undefined;
2542
- return format15(chain$1(bignumber(amount)).divide(bignumber(quantity)).done().toNumber());
2543
- }
2544
-
2545
2545
  //! moment.js
2546
2546
  //! version : 2.29.1
2547
2547
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
@@ -8840,6 +8840,11 @@ function dutyFree(controller, taxRate, form, record) {
8840
8840
  var cache = controller.state.goodsListState.endowCode.cache;
8841
8841
  var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
8842
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);
8843
8848
  if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
8844
8849
  if (controller.state.en !== '08') return taxRate;
8845
8850
  if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
@@ -8858,30 +8863,7 @@ function dutyFree(controller, taxRate, form, record) {
8858
8863
  taxRate: 0
8859
8864
  });
8860
8865
  return 0;
8861
- } // 选择的 1或者3
8862
- // if (taxRate === 1 || taxRate === 3) {
8863
- // 是否处理过
8864
- // if (cache[record.$index]) {
8865
- // return taxRate;
8866
- // } else {
8867
- // cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark,taxFreeType:record.taxFreeType }
8868
- // record.favouredPolicyName = '免税';
8869
- // record.taxRate = 0;
8870
- // record.favouredPolicyMark = 1;
8871
- // record.taxFreeType = 1 as any;
8872
- // form.setFieldsValue({ taxRate: 0 });
8873
- // return 0;
8874
- // }
8875
- // } else {
8876
- // if (cache[record.$index] && cache[record.$index] !== true) {
8877
- // record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8878
- // record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8879
- // record.taxFreeType = cache[record.$index].taxFreeType;
8880
- // cache[record.$index] = true;
8881
- // }
8882
- // return taxRate;
8883
- // }
8884
-
8866
+ }
8885
8867
  }
8886
8868
  /** 含税 => 更新(不含税) */
8887
8869
 
package/dist/index.js CHANGED
@@ -656,7 +656,7 @@ var GoodsListState = function GoodsListState() {
656
656
  this.form = void 0;
657
657
  this.unitList = [];
658
658
  this.defaultRate = 3;
659
- this.taxRateList = [0, 3, 5, 6, 9, 12];
659
+ this.taxRateList = [0, 3, 5, 6, 9, 13];
660
660
  this.goodsList = [];
661
661
  this.goodsMap = new Map();
662
662
  this.goodsMenuExpand = [];
@@ -882,6 +882,77 @@ var idGenerator = (function () {
882
882
  return ++id;
883
883
  });
884
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
+
885
956
  /**
886
957
  * 设置当前的编辑货物
887
958
  */
@@ -945,7 +1016,7 @@ var addGoodDiscount = /*#__PURE__*/(function () {
945
1016
  amountSum = amountSum.add(mathjs.bignumber(lineAmountExcludeTax));
946
1017
  /** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
947
1018
 
948
- 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());
949
1020
  }
950
1021
  /** 税额 */
951
1022
 
@@ -2056,7 +2127,7 @@ var DrawerBody = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(funct
2056
2127
  });
2057
2128
  });
2058
2129
  }, 300), [form, lineAmountSum]);
2059
- /** 折扣率变化 */
2130
+ /** 折扣变化 */
2060
2131
 
2061
2132
  var onChangeDiscolineAmountunt = React__default['default'].useCallback(lazyFn(function (e) {
2062
2133
  form.validateFields(function (err, values) {
@@ -2481,77 +2552,6 @@ var useAddDiscount = (function (goods) {
2481
2552
  }, [onClick, goods.lineAttribute]);
2482
2553
  });
2483
2554
 
2484
- /** 格式化 保留2位小数 */
2485
-
2486
- var format2 = function format2(value) {
2487
- if (value === Infinity) return '';
2488
- if ("".concat(value) === 'NaN') return '';
2489
- if (typeof value === 'string') value = parseFloat(value);
2490
- return parseFloat(value.toFixed(2));
2491
- };
2492
- /** 格式化 保留15位数字 */
2493
-
2494
- var format15 = function format15(value) {
2495
- if (value === Infinity) return '';
2496
- if ("".concat(value) === 'NaN') return '';
2497
- if (typeof value === 'string') value = parseFloat(value);
2498
- var fractionDigits = 15 - "".concat(value || 0).indexOf('.');
2499
- return parseFloat(value.toFixed(fractionDigits > 8 ? 8 : fractionDigits));
2500
- };
2501
- /**
2502
- * 金额(含税) = 数量 * 单价(含税)
2503
- * @param quantity 数量
2504
- * @param priceIncludeTax 单价(含税)
2505
- * @returns 金额(含税)
2506
- */
2507
-
2508
- function countAmountIncludeTax(quantity, priceIncludeTax) {
2509
- if (!quantity && quantity !== 0) return undefined;
2510
- if (!priceIncludeTax && priceIncludeTax !== 0) return undefined;
2511
- quantity = format15(quantity);
2512
- priceIncludeTax = format15(priceIncludeTax);
2513
- return parseFloat(mathjs.chain(mathjs.bignumber(priceIncludeTax)).multiply(mathjs.bignumber(quantity)).done().toNumber().toFixed(2)); // return parseFloat(evaluate(`${priceIncludeTax} * ${quantity}`).toFixed(2));
2514
- }
2515
- /**
2516
- * 不含税金额 = 含税金额-税额
2517
- * @param amountIncludeTax 含税金额
2518
- * @param taxAmount 税额
2519
- * @returns 不含税金额
2520
- */
2521
-
2522
- function countAmountExcludeTax(amountIncludeTax, taxAmount) {
2523
- if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
2524
- if (!taxAmount && taxAmount !== 0) return undefined;
2525
- return mathjs.chain(mathjs.bignumber(amountIncludeTax)).subtract(mathjs.bignumber(taxAmount)).done().toNumber();
2526
- }
2527
- /**
2528
- * 税额 = (含税金额-扣除额)/(1+税率)*税率
2529
- * @param amountIncludeTax 含税金额
2530
- * @param deduction 扣除额
2531
- * @param taxRate 税率
2532
- * @returns 税额
2533
- */
2534
-
2535
- function countTaxAmount(amountIncludeTax, deduction, taxRate) {
2536
- if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
2537
- if (!deduction && deduction !== 0) return undefined;
2538
- if (!taxRate && taxRate !== 0) return undefined;
2539
- var taxRateBu = mathjs.chain(mathjs.bignumber(taxRate)).divide(mathjs.bignumber(100)).done();
2540
- 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));
2541
- }
2542
- /**
2543
- * 单价 = 金额/数量
2544
- * @param amount 金额
2545
- * @param quantity 数量
2546
- * @returns 单价
2547
- */
2548
-
2549
- function countPrice(amount, quantity) {
2550
- if (!amount && amount !== 0) return undefined;
2551
- if (!quantity && quantity !== 0) return undefined;
2552
- return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(quantity)).done().toNumber());
2553
- }
2554
-
2555
2555
  //! moment.js
2556
2556
  //! version : 2.29.1
2557
2557
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
@@ -8850,6 +8850,11 @@ function dutyFree(controller, taxRate, form, record) {
8850
8850
  var cache = controller.state.goodsListState.endowCode.cache;
8851
8851
  var invoiceType = controller.state.invoiceType; // 4月1日至12月31日
8852
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);
8853
8858
  if (hooks().valueOf() > hooks('2022-12-31 23:59').valueOf()) return taxRate;
8854
8859
  if (controller.state.en !== '08') return taxRate;
8855
8860
  if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
@@ -8868,30 +8873,7 @@ function dutyFree(controller, taxRate, form, record) {
8868
8873
  taxRate: 0
8869
8874
  });
8870
8875
  return 0;
8871
- } // 选择的 1或者3
8872
- // if (taxRate === 1 || taxRate === 3) {
8873
- // 是否处理过
8874
- // if (cache[record.$index]) {
8875
- // return taxRate;
8876
- // } else {
8877
- // cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark,taxFreeType:record.taxFreeType }
8878
- // record.favouredPolicyName = '免税';
8879
- // record.taxRate = 0;
8880
- // record.favouredPolicyMark = 1;
8881
- // record.taxFreeType = 1 as any;
8882
- // form.setFieldsValue({ taxRate: 0 });
8883
- // return 0;
8884
- // }
8885
- // } else {
8886
- // if (cache[record.$index] && cache[record.$index] !== true) {
8887
- // record.favouredPolicyName = cache[record.$index].favouredPolicyName;
8888
- // record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
8889
- // record.taxFreeType = cache[record.$index].taxFreeType;
8890
- // cache[record.$index] = true;
8891
- // }
8892
- // return taxRate;
8893
- // }
8894
-
8876
+ }
8895
8877
  }
8896
8878
  /** 含税 => 更新(不含税) */
8897
8879
 
package/docs/index.md CHANGED
@@ -1,5 +1,5 @@
1
- # 发票编辑组件
1
+ # 发票编辑组件-
2
2
 
3
3
  npm 地址:https://www.npmjs.com/package/kts-component-invoice-operate
4
4
 
5
- ### 版本 1.2.19
5
+ ### 版本 1.2.20