kts-component-invoice-operate 3.1.17 → 3.1.19
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/index.d.ts +3 -0
- package/dist/Invoice/tools/calculate/index.d.ts +7 -0
- package/dist/index.esm.js +45 -19
- package/dist/index.js +45 -19
- package/package.json +1 -1
- package/src/Invoice/index.tsx +5 -0
- package/src/Invoice/tools/calculate/index.ts +15 -0
- package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +1 -0
- package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +4 -6
package/dist/Invoice/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import InvoiceController from './InvoiceController';
|
|
|
4
4
|
import GoodsList from './ui/GoodsList';
|
|
5
5
|
import Seller from './ui/Seller';
|
|
6
6
|
import Buyer from './ui/Buyer';
|
|
7
|
+
import * as calculator from './tools/calculate';
|
|
7
8
|
/** 发票组件的上下文 */
|
|
8
9
|
export declare const InvoiceContext: React.Context<InvoiceController>;
|
|
9
10
|
export interface IInvoiceProps {
|
|
@@ -37,6 +38,8 @@ export default class Invoice extends React.PureComponent<IInvoiceProps> {
|
|
|
37
38
|
static readonly Buyer: typeof Buyer;
|
|
38
39
|
/** 货物索引生成器 */
|
|
39
40
|
static idGenerator: () => string;
|
|
41
|
+
/** 金额计算方法 */
|
|
42
|
+
static calculator: typeof calculator;
|
|
40
43
|
/** 获取控制器钩子 */
|
|
41
44
|
static useInvoiceController: () => InvoiceController;
|
|
42
45
|
render(): JSX.Element;
|
|
@@ -31,3 +31,10 @@ export declare function countTaxAmount(amountIncludeTax: string | number, deduct
|
|
|
31
31
|
* @returns 单价
|
|
32
32
|
*/
|
|
33
33
|
export declare function countPrice(amount: string | number, quantity: string | number, calculatingDigits?: number): number | undefined | '';
|
|
34
|
+
/**
|
|
35
|
+
* 数量 = 金额/单价
|
|
36
|
+
* @param amount 金额
|
|
37
|
+
* @param price 单价
|
|
38
|
+
* @returns 数量
|
|
39
|
+
*/
|
|
40
|
+
export declare function countQuantity(amount: string | number, price: string | number, calculatingDigits?: number): number | undefined | '';
|
package/dist/index.esm.js
CHANGED
|
@@ -1135,6 +1135,28 @@ function countPrice(amount, quantity, calculatingDigits) {
|
|
|
1135
1135
|
if (!quantity && quantity !== 0) return undefined;
|
|
1136
1136
|
return format15(chain$1(bignumber(amount)).divide(bignumber(quantity)).done().toNumber(), calculatingDigits);
|
|
1137
1137
|
}
|
|
1138
|
+
/**
|
|
1139
|
+
* 数量 = 金额/单价
|
|
1140
|
+
* @param amount 金额
|
|
1141
|
+
* @param price 单价
|
|
1142
|
+
* @returns 数量
|
|
1143
|
+
*/
|
|
1144
|
+
function countQuantity(amount, price, calculatingDigits) {
|
|
1145
|
+
if (!amount && amount !== 0) return undefined;
|
|
1146
|
+
if (!price && price !== 0) return undefined;
|
|
1147
|
+
return format15(chain$1(bignumber(amount)).divide(bignumber(price)).done().toNumber(), calculatingDigits);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
var calculator = /*#__PURE__*/Object.freeze({
|
|
1151
|
+
__proto__: null,
|
|
1152
|
+
format2: format2,
|
|
1153
|
+
format15: format15,
|
|
1154
|
+
countAmountIncludeTax: countAmountIncludeTax,
|
|
1155
|
+
countAmountExcludeTax: countAmountExcludeTax,
|
|
1156
|
+
countTaxAmount: countTaxAmount,
|
|
1157
|
+
countPrice: countPrice,
|
|
1158
|
+
countQuantity: countQuantity
|
|
1159
|
+
});
|
|
1138
1160
|
|
|
1139
1161
|
/**
|
|
1140
1162
|
* 设置当前的编辑货物
|
|
@@ -8665,11 +8687,14 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
|
|
|
8665
8687
|
if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
|
|
8666
8688
|
taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
|
|
8667
8689
|
}
|
|
8668
|
-
|
|
8690
|
+
form.setFieldsValue({
|
|
8691
|
+
taxAmount: taxAmount
|
|
8692
|
+
});
|
|
8693
|
+
_context9.next = 6;
|
|
8669
8694
|
return controller.setEditGood({
|
|
8670
8695
|
taxAmount: taxAmount
|
|
8671
8696
|
});
|
|
8672
|
-
case
|
|
8697
|
+
case 6:
|
|
8673
8698
|
// 计算 金额(不含税)
|
|
8674
8699
|
if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
|
|
8675
8700
|
lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
|
|
@@ -8677,11 +8702,11 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
|
|
|
8677
8702
|
form.setFieldsValue({
|
|
8678
8703
|
lineAmountExcludeTax: lineAmountExcludeTax
|
|
8679
8704
|
});
|
|
8680
|
-
_context9.next =
|
|
8705
|
+
_context9.next = 10;
|
|
8681
8706
|
return controller.setEditGood({
|
|
8682
8707
|
lineAmountExcludeTax: lineAmountExcludeTax
|
|
8683
8708
|
});
|
|
8684
|
-
case
|
|
8709
|
+
case 10:
|
|
8685
8710
|
// 单价(不含税)
|
|
8686
8711
|
if (lineAmountExcludeTax && !promptErr(err.quantity)) {
|
|
8687
8712
|
priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
|
|
@@ -8689,11 +8714,11 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
|
|
|
8689
8714
|
form.setFieldsValue({
|
|
8690
8715
|
priceExcludeTax: priceExcludeTax
|
|
8691
8716
|
});
|
|
8692
|
-
_context9.next =
|
|
8717
|
+
_context9.next = 14;
|
|
8693
8718
|
return controller.setEditGood({
|
|
8694
8719
|
priceExcludeTax: priceExcludeTax
|
|
8695
8720
|
});
|
|
8696
|
-
case
|
|
8721
|
+
case 14:
|
|
8697
8722
|
case "end":
|
|
8698
8723
|
return _context9.stop();
|
|
8699
8724
|
}
|
|
@@ -11921,12 +11946,10 @@ var DrawerBody$2 = function DrawerBody() {
|
|
|
11921
11946
|
}
|
|
11922
11947
|
return _context2.abrupt("return");
|
|
11923
11948
|
case 8:
|
|
11924
|
-
|
|
11925
|
-
|
|
11926
|
-
|
|
11927
|
-
|
|
11928
|
-
record.lineAmountIncludeTax = s.goodsListState.editGood.lineAmountIncludeTax;
|
|
11929
|
-
}
|
|
11949
|
+
// 导入时清空之前输入的值,使用导入的单价和税率(参考税局系统)
|
|
11950
|
+
record.quantity = undefined;
|
|
11951
|
+
record.lineAmountExcludeTax = undefined;
|
|
11952
|
+
record.lineAmountIncludeTax = undefined;
|
|
11930
11953
|
// 中间数据
|
|
11931
11954
|
between = _objectSpread2({}, record);
|
|
11932
11955
|
between.itemName = getItemName(record, s.goodsListState.editGood);
|
|
@@ -11956,18 +11979,18 @@ var DrawerBody$2 = function DrawerBody() {
|
|
|
11956
11979
|
}
|
|
11957
11980
|
s.goodsListState.importGoods.isVisibleDrawer = false;
|
|
11958
11981
|
if (!s.goodsListState.isTaxIncluded) {
|
|
11959
|
-
_context2.next =
|
|
11982
|
+
_context2.next = 25;
|
|
11960
11983
|
break;
|
|
11961
11984
|
}
|
|
11962
|
-
_context2.next =
|
|
11985
|
+
_context2.next = 23;
|
|
11963
11986
|
return updateUnitPriceExcludingTax(controller, s.goodsListState.form, record);
|
|
11964
|
-
case 21:
|
|
11965
|
-
_context2.next = 25;
|
|
11966
|
-
break;
|
|
11967
11987
|
case 23:
|
|
11968
|
-
_context2.next =
|
|
11969
|
-
|
|
11988
|
+
_context2.next = 27;
|
|
11989
|
+
break;
|
|
11970
11990
|
case 25:
|
|
11991
|
+
_context2.next = 27;
|
|
11992
|
+
return updateUnitPriceTax(controller, s.goodsListState.form, record);
|
|
11993
|
+
case 27:
|
|
11971
11994
|
case "end":
|
|
11972
11995
|
return _context2.stop();
|
|
11973
11996
|
}
|
|
@@ -12832,6 +12855,8 @@ var Invoice = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
12832
12855
|
|
|
12833
12856
|
/** 货物索引生成器 */
|
|
12834
12857
|
|
|
12858
|
+
/** 金额计算方法 */
|
|
12859
|
+
|
|
12835
12860
|
/** 获取控制器钩子 */
|
|
12836
12861
|
|
|
12837
12862
|
function render() {
|
|
@@ -12847,6 +12872,7 @@ Invoice.Seller = Buyer;
|
|
|
12847
12872
|
Invoice.Sign = Sign;
|
|
12848
12873
|
Invoice.Buyer = Buyer$1;
|
|
12849
12874
|
Invoice.idGenerator = idGenerator;
|
|
12875
|
+
Invoice.calculator = calculator;
|
|
12850
12876
|
Invoice.useInvoiceController = function () {
|
|
12851
12877
|
return React.useContext(InvoiceContext);
|
|
12852
12878
|
};
|
package/dist/index.js
CHANGED
|
@@ -1145,6 +1145,28 @@ function countPrice(amount, quantity, calculatingDigits) {
|
|
|
1145
1145
|
if (!quantity && quantity !== 0) return undefined;
|
|
1146
1146
|
return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(quantity)).done().toNumber(), calculatingDigits);
|
|
1147
1147
|
}
|
|
1148
|
+
/**
|
|
1149
|
+
* 数量 = 金额/单价
|
|
1150
|
+
* @param amount 金额
|
|
1151
|
+
* @param price 单价
|
|
1152
|
+
* @returns 数量
|
|
1153
|
+
*/
|
|
1154
|
+
function countQuantity(amount, price, calculatingDigits) {
|
|
1155
|
+
if (!amount && amount !== 0) return undefined;
|
|
1156
|
+
if (!price && price !== 0) return undefined;
|
|
1157
|
+
return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(price)).done().toNumber(), calculatingDigits);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
var calculator = /*#__PURE__*/Object.freeze({
|
|
1161
|
+
__proto__: null,
|
|
1162
|
+
format2: format2,
|
|
1163
|
+
format15: format15,
|
|
1164
|
+
countAmountIncludeTax: countAmountIncludeTax,
|
|
1165
|
+
countAmountExcludeTax: countAmountExcludeTax,
|
|
1166
|
+
countTaxAmount: countTaxAmount,
|
|
1167
|
+
countPrice: countPrice,
|
|
1168
|
+
countQuantity: countQuantity
|
|
1169
|
+
});
|
|
1148
1170
|
|
|
1149
1171
|
/**
|
|
1150
1172
|
* 设置当前的编辑货物
|
|
@@ -8675,11 +8697,14 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
|
|
|
8675
8697
|
if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
|
|
8676
8698
|
taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
|
|
8677
8699
|
}
|
|
8678
|
-
|
|
8700
|
+
form.setFieldsValue({
|
|
8701
|
+
taxAmount: taxAmount
|
|
8702
|
+
});
|
|
8703
|
+
_context9.next = 6;
|
|
8679
8704
|
return controller.setEditGood({
|
|
8680
8705
|
taxAmount: taxAmount
|
|
8681
8706
|
});
|
|
8682
|
-
case
|
|
8707
|
+
case 6:
|
|
8683
8708
|
// 计算 金额(不含税)
|
|
8684
8709
|
if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
|
|
8685
8710
|
lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
|
|
@@ -8687,11 +8712,11 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
|
|
|
8687
8712
|
form.setFieldsValue({
|
|
8688
8713
|
lineAmountExcludeTax: lineAmountExcludeTax
|
|
8689
8714
|
});
|
|
8690
|
-
_context9.next =
|
|
8715
|
+
_context9.next = 10;
|
|
8691
8716
|
return controller.setEditGood({
|
|
8692
8717
|
lineAmountExcludeTax: lineAmountExcludeTax
|
|
8693
8718
|
});
|
|
8694
|
-
case
|
|
8719
|
+
case 10:
|
|
8695
8720
|
// 单价(不含税)
|
|
8696
8721
|
if (lineAmountExcludeTax && !promptErr(err.quantity)) {
|
|
8697
8722
|
priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
|
|
@@ -8699,11 +8724,11 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
|
|
|
8699
8724
|
form.setFieldsValue({
|
|
8700
8725
|
priceExcludeTax: priceExcludeTax
|
|
8701
8726
|
});
|
|
8702
|
-
_context9.next =
|
|
8727
|
+
_context9.next = 14;
|
|
8703
8728
|
return controller.setEditGood({
|
|
8704
8729
|
priceExcludeTax: priceExcludeTax
|
|
8705
8730
|
});
|
|
8706
|
-
case
|
|
8731
|
+
case 14:
|
|
8707
8732
|
case "end":
|
|
8708
8733
|
return _context9.stop();
|
|
8709
8734
|
}
|
|
@@ -11931,12 +11956,10 @@ var DrawerBody$2 = function DrawerBody() {
|
|
|
11931
11956
|
}
|
|
11932
11957
|
return _context2.abrupt("return");
|
|
11933
11958
|
case 8:
|
|
11934
|
-
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
record.lineAmountIncludeTax = s.goodsListState.editGood.lineAmountIncludeTax;
|
|
11939
|
-
}
|
|
11959
|
+
// 导入时清空之前输入的值,使用导入的单价和税率(参考税局系统)
|
|
11960
|
+
record.quantity = undefined;
|
|
11961
|
+
record.lineAmountExcludeTax = undefined;
|
|
11962
|
+
record.lineAmountIncludeTax = undefined;
|
|
11940
11963
|
// 中间数据
|
|
11941
11964
|
between = _objectSpread2({}, record);
|
|
11942
11965
|
between.itemName = getItemName(record, s.goodsListState.editGood);
|
|
@@ -11966,18 +11989,18 @@ var DrawerBody$2 = function DrawerBody() {
|
|
|
11966
11989
|
}
|
|
11967
11990
|
s.goodsListState.importGoods.isVisibleDrawer = false;
|
|
11968
11991
|
if (!s.goodsListState.isTaxIncluded) {
|
|
11969
|
-
_context2.next =
|
|
11992
|
+
_context2.next = 25;
|
|
11970
11993
|
break;
|
|
11971
11994
|
}
|
|
11972
|
-
_context2.next =
|
|
11995
|
+
_context2.next = 23;
|
|
11973
11996
|
return updateUnitPriceExcludingTax(controller, s.goodsListState.form, record);
|
|
11974
|
-
case 21:
|
|
11975
|
-
_context2.next = 25;
|
|
11976
|
-
break;
|
|
11977
11997
|
case 23:
|
|
11978
|
-
_context2.next =
|
|
11979
|
-
|
|
11998
|
+
_context2.next = 27;
|
|
11999
|
+
break;
|
|
11980
12000
|
case 25:
|
|
12001
|
+
_context2.next = 27;
|
|
12002
|
+
return updateUnitPriceTax(controller, s.goodsListState.form, record);
|
|
12003
|
+
case 27:
|
|
11981
12004
|
case "end":
|
|
11982
12005
|
return _context2.stop();
|
|
11983
12006
|
}
|
|
@@ -12842,6 +12865,8 @@ var Invoice = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
12842
12865
|
|
|
12843
12866
|
/** 货物索引生成器 */
|
|
12844
12867
|
|
|
12868
|
+
/** 金额计算方法 */
|
|
12869
|
+
|
|
12845
12870
|
/** 获取控制器钩子 */
|
|
12846
12871
|
|
|
12847
12872
|
function render() {
|
|
@@ -12857,6 +12882,7 @@ Invoice.Seller = Buyer;
|
|
|
12857
12882
|
Invoice.Sign = Sign;
|
|
12858
12883
|
Invoice.Buyer = Buyer$1;
|
|
12859
12884
|
Invoice.idGenerator = idGenerator;
|
|
12885
|
+
Invoice.calculator = calculator;
|
|
12860
12886
|
Invoice.useInvoiceController = function () {
|
|
12861
12887
|
return React__default['default'].useContext(InvoiceContext);
|
|
12862
12888
|
};
|
package/package.json
CHANGED
package/src/Invoice/index.tsx
CHANGED
|
@@ -12,6 +12,8 @@ import ImportGoodsDrawer from './ui/ImportGoodsDrawer';
|
|
|
12
12
|
import EndowCodeDrawer from './ui/EndowCodeDrawer';
|
|
13
13
|
import AddComparisonDrawer from './ui/AddComparisonDrawer';
|
|
14
14
|
import idGenerator from './tools/idGenerator';
|
|
15
|
+
import * as calculator from './tools/calculate';
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
/** 发票组件的上下文 */
|
|
17
19
|
export const InvoiceContext = React.createContext<InvoiceController>(
|
|
@@ -63,6 +65,9 @@ export default class Invoice extends React.PureComponent<IInvoiceProps> {
|
|
|
63
65
|
/** 货物索引生成器 */
|
|
64
66
|
static idGenerator = idGenerator;
|
|
65
67
|
|
|
68
|
+
/** 金额计算方法 */
|
|
69
|
+
static calculator = calculator;
|
|
70
|
+
|
|
66
71
|
/** 获取控制器钩子 */
|
|
67
72
|
static useInvoiceController = () => { return React.useContext(InvoiceContext) };
|
|
68
73
|
|
|
@@ -92,6 +92,21 @@ export function countPrice(amount: string | number, quantity: string | number, c
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* 数量 = 金额/单价
|
|
97
|
+
* @param amount 金额
|
|
98
|
+
* @param price 单价
|
|
99
|
+
* @returns 数量
|
|
100
|
+
*/
|
|
101
|
+
export function countQuantity(amount: string | number, price: string | number, calculatingDigits?: number): number | undefined | '' {
|
|
102
|
+
if (!amount && amount !== 0) return undefined;
|
|
103
|
+
if (!price && price !== 0) return undefined;
|
|
104
|
+
|
|
105
|
+
return format15(chain(bignumber(amount)).divide(bignumber(price))
|
|
106
|
+
.done()
|
|
107
|
+
.toNumber(), calculatingDigits)
|
|
108
|
+
}
|
|
109
|
+
|
|
95
110
|
|
|
96
111
|
|
|
97
112
|
|
|
@@ -377,6 +377,7 @@ export const updateUnitPriceExcludingTax = async (controller: InvoiceController,
|
|
|
377
377
|
if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
|
|
378
378
|
taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
|
|
379
379
|
}
|
|
380
|
+
form.setFieldsValue({ taxAmount });
|
|
380
381
|
await controller.setEditGood({ taxAmount });
|
|
381
382
|
|
|
382
383
|
// 计算 金额(不含税)
|
|
@@ -70,12 +70,10 @@ const DrawerBody = () => {
|
|
|
70
70
|
// 没用 被编辑的货物 和 form 就退出
|
|
71
71
|
if (!s.goodsListState.editGood || !s.goodsListState.form) return;
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
record.lineAmountIncludeTax = s.goodsListState.editGood.lineAmountIncludeTax;
|
|
78
|
-
}
|
|
73
|
+
// 导入时清空之前输入的值,使用导入的单价和税率(参考税局系统)
|
|
74
|
+
record.quantity = undefined;
|
|
75
|
+
record.lineAmountExcludeTax = undefined;
|
|
76
|
+
record.lineAmountIncludeTax = undefined;
|
|
79
77
|
|
|
80
78
|
// 中间数据
|
|
81
79
|
const between = { ...record };
|