kts-component-invoice-operate 3.2.264 → 3.2.266
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/DifferenceInputModal/demo.d.ts +4 -0
- package/dist/DifferenceInputModal/index.d.ts +73 -0
- package/dist/Invoice/Invoice-digtal/_test/differenceInput/index.d.ts +4 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/DifferenceInputState/index.d.ts +11 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/index.d.ts +3 -0
- package/dist/Invoice/InvoiceController/hooks/index.d.ts +3 -0
- package/dist/Invoice/_test/differenceInput/index.d.ts +4 -0
- package/dist/Invoice/tools/calculate/index.d.ts +1 -1
- package/dist/Invoice/ui/digtal/DifferenceInput/index.d.ts +3 -0
- package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +1481 -319
- package/dist/index.js +1478 -315
- package/package.json +1 -1
- package/src/DifferenceInputModal/demo.tsx +22 -0
- package/src/DifferenceInputModal/index.less +102 -0
- package/src/DifferenceInputModal/index.md +5 -0
- package/src/DifferenceInputModal/index.tsx +520 -0
- package/src/Invoice/Invoice-digtal/_test/differenceInput/index.tsx +31 -0
- package/src/Invoice/Invoice-digtal/index.md +12 -9
- package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +9 -2
- package/src/Invoice/InvoiceController/InvoiceControllerState/DifferenceInputState/index.ts +16 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +3 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +4 -0
- package/src/Invoice/InvoiceController/fns/saveEditGood.ts +1 -0
- package/src/Invoice/InvoiceController/hooks/index.ts +63 -0
- package/src/Invoice/_test/differenceInput/index.tsx +25 -0
- package/src/Invoice/index.md +3 -0
- package/src/Invoice/index.tsx +21 -6
- package/src/Invoice/tools/calculate/index.ts +2 -3
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +2 -1
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +19 -6
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +8 -2
- package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +4 -1
- package/src/Invoice/ui/default/GoodsList/index.tsx +1 -1
- package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +4 -0
- package/src/Invoice/ui/digtal/DifferenceInput/index.tsx +69 -0
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +2 -2
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +34 -21
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +15 -4
- package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +4 -1
- package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +7 -7
- package/src/TaxClassificationCodeModal/index.tsx +2 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Invoice from '../../..';
|
|
3
|
+
import 'antd/dist/antd.css';
|
|
4
|
+
import { Button } from 'kts-components-antd-x4';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
|
|
8
|
+
const controller = React.useMemo(() => new Invoice.InvoiceController(), []);
|
|
9
|
+
const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
|
|
10
|
+
const [loading, setLoading] = React.useState(false);
|
|
11
|
+
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
controller.run(async s => {
|
|
14
|
+
|
|
15
|
+
})
|
|
16
|
+
}, [controller])
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
<Button loading={loading} onClick={ async () => {
|
|
21
|
+
setLoading(true);
|
|
22
|
+
await controller.pipeline(async (s) => {
|
|
23
|
+
s.differenceInputState.enabled = !s.differenceInputState.enabled;
|
|
24
|
+
})();
|
|
25
|
+
setLoading(false);
|
|
26
|
+
}}>{enabled ? '关闭差额开票' : '开启差额开票'}</Button>
|
|
27
|
+
|
|
28
|
+
<Invoice invoiceType='digtal' controller={controller} />
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# 数电
|
|
2
2
|
|
|
3
3
|
## 简单用法
|
|
4
|
-
<code src="./_test/pay/index.tsx"></code>
|
|
4
|
+
<!-- <code src="./_test/pay/index.tsx"></code> -->
|
|
5
5
|
<!-- <code src="./_test/easiest/index.tsx"></code> -->
|
|
6
6
|
|
|
7
|
-
## 旅客运输发票
|
|
8
|
-
<code src="./_test/passenger/index.tsx"></code>
|
|
7
|
+
<!-- ## 旅客运输发票
|
|
8
|
+
<code src="./_test/passenger/index.tsx"></code> -->
|
|
9
9
|
|
|
10
10
|
<!-- ## 不动产经营租赁服务
|
|
11
11
|
<code src="./_test/realEstateInfo/index.tsx"></code> -->
|
|
12
12
|
|
|
13
|
-
## 不动产销售
|
|
14
|
-
<code src="./_test/realEstateSales/index.tsx"></code>
|
|
13
|
+
<!-- ## 不动产销售
|
|
14
|
+
<code src="./_test/realEstateSales/index.tsx"></code> -->
|
|
15
15
|
|
|
16
16
|
<!-- ## 建筑服务
|
|
17
17
|
<code src="./_test/architecture/index.tsx"></code> -->
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
## 导入项目
|
|
40
|
-
<code src="./_test/importGoods/index.tsx"></code>
|
|
39
|
+
<!-- ## 导入项目
|
|
40
|
+
<code src="./_test/importGoods/index.tsx"></code> -->
|
|
41
41
|
|
|
42
42
|
<!-- ## 预制模式
|
|
43
43
|
<code src="./_test/prefab/index.tsx"></code>
|
|
@@ -46,5 +46,8 @@
|
|
|
46
46
|
<code src="./_test/lineCredit/index.tsx"></code> -->
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
## 货物运输服务
|
|
50
|
-
<code src="./_test/freight/index.tsx"></code>
|
|
49
|
+
<!-- ## 货物运输服务 -->
|
|
50
|
+
<!-- <code src="./_test/freight/index.tsx"></code> -->
|
|
51
|
+
|
|
52
|
+
## 差额开票
|
|
53
|
+
<code src="./_test/differenceInput/index.tsx"></code>
|
|
@@ -45,8 +45,15 @@ export default class InvoiceControllerForm extends GreyReactBox<InvoiceControlle
|
|
|
45
45
|
_errors.set('goodsList', error.errors);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
_values.set('goodsList', this.state.goodsListState.goodsList.slice()
|
|
48
|
+
|
|
49
|
+
_values.set('goodsList', this.state.goodsListState.goodsList.slice().map(e => {
|
|
50
|
+
return {
|
|
51
|
+
...e,
|
|
52
|
+
deductAmount: this.state?.differenceInputState?.data?.deductTotal || 0,
|
|
53
|
+
amountIncludeTax: this.state?.differenceInputState?.data?.amountIncludeTax || 0
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
|
|
50
57
|
//货物运输列表
|
|
51
58
|
if (this.state.freightListState.form) {
|
|
52
59
|
try {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IData } from '../../../../DifferenceInputModal';
|
|
2
|
+
|
|
3
|
+
export default class DifferenceInputState {
|
|
4
|
+
|
|
5
|
+
/** 是否启用差额开票 */
|
|
6
|
+
enabled = false;
|
|
7
|
+
|
|
8
|
+
/** 差额开票弹框是否打开 */
|
|
9
|
+
open = false;
|
|
10
|
+
|
|
11
|
+
/** 差额开票数据 */
|
|
12
|
+
data?: IData;
|
|
13
|
+
|
|
14
|
+
/** 含税销售额 */
|
|
15
|
+
amountIncludeTax?: number;
|
|
16
|
+
}
|
|
@@ -137,6 +137,9 @@ export default class GoodsListState {
|
|
|
137
137
|
/** 煤炭种类赋值商品索引 */
|
|
138
138
|
meiTanGoodIndex?: string[] = [];
|
|
139
139
|
|
|
140
|
+
/** 是否可以点击组件外保存行 */
|
|
141
|
+
isSaveRowOutside = true;
|
|
142
|
+
|
|
140
143
|
/** 煤炭时校验函数 */
|
|
141
144
|
verifyMeiTanFn: (record: any) => Promise<boolean> = async record => {
|
|
142
145
|
const { taxClassificationCode } = record;
|
|
@@ -7,6 +7,7 @@ import { IInvoiceTypeModalProps } from '../../../InvoiceTypeModal';
|
|
|
7
7
|
import { TaxClassificationProps } from '../../../TaxClassificationCodeModal';
|
|
8
8
|
import AutoComplete from './AutoComplete';
|
|
9
9
|
import PassengerListState from './PassengerListState';
|
|
10
|
+
import DifferenceInputState from './DifferenceInputState';
|
|
10
11
|
|
|
11
12
|
export default class InvoiceControllerState {
|
|
12
13
|
|
|
@@ -78,5 +79,8 @@ export default class InvoiceControllerState {
|
|
|
78
79
|
*/
|
|
79
80
|
passengerListState = new PassengerListState();
|
|
80
81
|
|
|
82
|
+
/** 差额开票 */
|
|
83
|
+
differenceInputState = new DifferenceInputState();
|
|
84
|
+
|
|
81
85
|
addGoodsCheck?: any;
|
|
82
86
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import InvoiceController from "../";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { chain, bignumber } from 'mathjs';
|
|
4
|
+
import { countAmountExcludeTax, countTaxAmount } from "../../tools/calculate";
|
|
5
|
+
|
|
6
|
+
/** 切换是否启用差额开票重新计算税额 */
|
|
7
|
+
export const useRecalculateTax = (invoiceController: InvoiceController) => {
|
|
8
|
+
const differenceInputEnabled = invoiceController.useMemo(s => s.differenceInputState.enabled, [])
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
console.log('切换是否启用差额开票重新计算税额 - 重新计算税额===>')
|
|
11
|
+
if (invoiceController.state.goodsListState.editGood) {
|
|
12
|
+
const editGood = invoiceController.state.goodsListState.editGood;
|
|
13
|
+
const form = invoiceController.state.goodsListState.form;
|
|
14
|
+
const isTaxIncluded = invoiceController.state.goodsListState.isTaxIncluded
|
|
15
|
+
if (isTaxIncluded) {
|
|
16
|
+
// 含税
|
|
17
|
+
const lineAmountIncludeTax = form?.getFieldValue('lineAmountIncludeTax') || 0; //含税金额
|
|
18
|
+
const taxRate = form?.getFieldValue('taxRate') || 0; //税率
|
|
19
|
+
const taxAmount = countTaxAmount(lineAmountIncludeTax, 0, taxRate) || 0; //税额
|
|
20
|
+
const lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount) || 0; // 不含税金额
|
|
21
|
+
|
|
22
|
+
form?.setFieldsValue({ taxAmount, lineAmountExcludeTax });
|
|
23
|
+
invoiceController.run(async s => {
|
|
24
|
+
s.goodsListState.editGood = {
|
|
25
|
+
...editGood,
|
|
26
|
+
taxAmount,
|
|
27
|
+
lineAmountExcludeTax,
|
|
28
|
+
};
|
|
29
|
+
})
|
|
30
|
+
} else {
|
|
31
|
+
// 不含税
|
|
32
|
+
const lineAmountIncludeTax = editGood.lineAmountIncludeTax || 0;
|
|
33
|
+
const taxRate = form?.getFieldValue('taxRate') || 0; //税率
|
|
34
|
+
const taxAmount = countTaxAmount(lineAmountIncludeTax, 0, taxRate) || 0; //税额
|
|
35
|
+
const lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount) || 0; // 不含税金额
|
|
36
|
+
|
|
37
|
+
form?.setFieldsValue({ taxAmount, lineAmountExcludeTax });
|
|
38
|
+
invoiceController.run(async s => {
|
|
39
|
+
s.goodsListState.editGood = {
|
|
40
|
+
...editGood,
|
|
41
|
+
taxAmount,
|
|
42
|
+
lineAmountExcludeTax,
|
|
43
|
+
};
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
invoiceController.run(async s => {
|
|
48
|
+
const good = s.goodsListState.goodsList[0];
|
|
49
|
+
if (!good) return;
|
|
50
|
+
const lineAmountIncludeTax = good.lineAmountIncludeTax || 0;
|
|
51
|
+
const taxRate = good.taxRate || 0;
|
|
52
|
+
const taxAmount = countTaxAmount(lineAmountIncludeTax, 0, taxRate) || 0; //税额
|
|
53
|
+
const lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount) || 0; // 不含税金额
|
|
54
|
+
|
|
55
|
+
s.goodsListState.goodsList[0] = {
|
|
56
|
+
...good,
|
|
57
|
+
taxAmount,
|
|
58
|
+
lineAmountExcludeTax,
|
|
59
|
+
};
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
}, [differenceInputEnabled]);
|
|
63
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Invoice from '../..';
|
|
3
|
+
import 'antd/dist/antd.css';
|
|
4
|
+
import { Button } from 'kts-components-antd-x4';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
|
|
8
|
+
const controller = React.useMemo(() => new Invoice.InvoiceController(), []);
|
|
9
|
+
const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
|
|
10
|
+
const [loading, setLoading] = React.useState(false);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div>
|
|
14
|
+
<Button loading={loading} onClick={ async () => {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
await controller.pipeline(async (s) => {
|
|
17
|
+
s.differenceInputState.enabled = !s.differenceInputState.enabled;
|
|
18
|
+
})();
|
|
19
|
+
setLoading(false);
|
|
20
|
+
}}>{enabled ? '关闭差额开票' : '开启差额开票'}</Button>
|
|
21
|
+
|
|
22
|
+
<Invoice invoiceType='default' controller={controller} />
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
25
|
+
};
|
package/src/Invoice/index.md
CHANGED
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
## 设置数据源 赋码 税收分类编码列表
|
|
49
49
|
<code src="./_test/endowCode/index.tsx"></code>
|
|
50
50
|
|
|
51
|
+
## 差额开票
|
|
52
|
+
<code src="./_test/differenceInput/index.tsx"></code>
|
|
53
|
+
|
|
51
54
|
<!-- <API name="Invoice 发票组件 API" exports='["default"]' src="./index.tsx" ></API>
|
|
52
55
|
<API name="InvoiceHeader 发票头 API" exports='["default"]' src="./ui/default/InvoiceHeader/index.tsx"></API>
|
|
53
56
|
<API name="GoodsList 商品列表 API" exports='["default"]' src="./ui/default/GoodsList/index.tsx"></API>
|
package/src/Invoice/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import './index.less';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import InvoiceController from './InvoiceController';
|
|
5
|
+
import { useRecalculateTax } from './InvoiceController/hooks';
|
|
5
6
|
import useToGenerateId from './tools/useToGenerateId';
|
|
6
7
|
import idGenerator from './tools/idGenerator';
|
|
7
8
|
import * as calculator from './tools/calculate';
|
|
@@ -31,6 +32,7 @@ import EndowCodeDrawer from './ui/default/EndowCodeDrawer';
|
|
|
31
32
|
import AddComparisonDrawer from './ui/default/AddComparisonDrawer';
|
|
32
33
|
import MeiTanModal from './ui/default/MeiTanModal';
|
|
33
34
|
import PassengerList from './ui/digtal/PassengerList';
|
|
35
|
+
import DifferenceInput from './ui/digtal/DifferenceInput';
|
|
34
36
|
// import { create, all } from 'mathjs';
|
|
35
37
|
// const config = {
|
|
36
38
|
// number: 'BigNumber',
|
|
@@ -154,12 +156,10 @@ const Main = (props: IInvoiceProps) => {
|
|
|
154
156
|
const [key, setKey] = React.useState(0);
|
|
155
157
|
|
|
156
158
|
useToGenerateId(controller);
|
|
157
|
-
|
|
159
|
+
useRecalculateTax(controller);
|
|
160
|
+
// useClearGoodsList(controller);
|
|
161
|
+
|
|
158
162
|
React.useEffect(() => { setKey(key + 1) }, [controller]);
|
|
159
|
-
// React.useEffect(() => {
|
|
160
|
-
// setKey(key + 1)
|
|
161
|
-
// controller.state.stakeholder.enables = ['taxAmount']
|
|
162
|
-
// }, [controller]);
|
|
163
163
|
|
|
164
164
|
return (
|
|
165
165
|
<InvoiceContext.Provider key={key} value={controller}>
|
|
@@ -177,7 +177,8 @@ const Main = (props: IInvoiceProps) => {
|
|
|
177
177
|
<ImportGoodsDrawer />{/* 导入货品的抽屉 */}
|
|
178
178
|
<EndowCodeDrawer />{/* 给货品赋码的抽屉 */}
|
|
179
179
|
<AddComparisonDrawer />{/* 添加商品对照的抽屉 */}
|
|
180
|
-
<
|
|
180
|
+
<DifferenceInput />{/* 差额录入弹框 */}
|
|
181
|
+
<MeiTanModal /> {/* 煤炭类弹框 */}
|
|
181
182
|
</InvoiceContext.Provider>
|
|
182
183
|
);
|
|
183
184
|
};
|
|
@@ -190,6 +191,8 @@ const Digtal = (props: IInvoiceProps) => {
|
|
|
190
191
|
const [key, setKey] = React.useState(0);
|
|
191
192
|
|
|
192
193
|
useToGenerateId(controller);
|
|
194
|
+
useRecalculateTax(controller);
|
|
195
|
+
// useClearGoodsList(controller);
|
|
193
196
|
|
|
194
197
|
React.useEffect(() => { setKey(key + 1) }, [controller]);
|
|
195
198
|
|
|
@@ -208,9 +211,21 @@ const Digtal = (props: IInvoiceProps) => {
|
|
|
208
211
|
<ImportGoodsDrawer />{ /** 导入货品的抽屉 */}
|
|
209
212
|
<ImportPassengerDrawer />{ /** 导入旅客运输的抽屉 */}
|
|
210
213
|
<EndowCodeDrawer />{ /** 给货品赋码的抽屉 */}
|
|
214
|
+
<DifferenceInput />{/* 差额录入弹框 */}
|
|
211
215
|
<MeiTanModal /> {/* 煤炭类弹框 */}
|
|
212
216
|
</InvoiceContext.Provider>
|
|
213
217
|
)
|
|
214
218
|
}
|
|
215
219
|
|
|
216
220
|
|
|
221
|
+
// 切换到差额开票清楚商品列表
|
|
222
|
+
// function useClearGoodsList(controller: InvoiceController) {
|
|
223
|
+
// const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
|
|
224
|
+
// React.useEffect(() => {
|
|
225
|
+
// controller.run(async (s) => {
|
|
226
|
+
// if (enabled) {
|
|
227
|
+
// s.goodsListState.goodsList = [];
|
|
228
|
+
// }
|
|
229
|
+
// })
|
|
230
|
+
// }, [controller, enabled]);
|
|
231
|
+
// }
|
|
@@ -40,7 +40,7 @@ export function countAmountIncludeTax(quantity?: number | string, priceIncludeTa
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* 不含税金额 =
|
|
43
|
+
* 不含税金额 = 含税金额 - 税额
|
|
44
44
|
* @param amountIncludeTax 含税金额
|
|
45
45
|
* @param taxAmount 税额
|
|
46
46
|
* @returns 不含税金额
|
|
@@ -62,13 +62,12 @@ export function countAmountExcludeTax(amountIncludeTax: string | number, taxAmou
|
|
|
62
62
|
export function countTaxAmount(amountIncludeTax: string | number, deduction: number, taxRate: number): number | undefined {
|
|
63
63
|
|
|
64
64
|
if (!amountIncludeTax && amountIncludeTax !== 0) return undefined;
|
|
65
|
-
if (!deduction && deduction !== 0) return undefined;
|
|
66
65
|
if (!taxRate && taxRate !== 0) return undefined;
|
|
67
66
|
|
|
68
67
|
const taxRateBu = chain(bignumber(taxRate)).divide(bignumber(100)).done();
|
|
69
68
|
|
|
70
69
|
return parseFloat(chain(bignumber(amountIncludeTax))
|
|
71
|
-
.subtract(bignumber(deduction))
|
|
70
|
+
.subtract(bignumber(deduction || 0))
|
|
72
71
|
.divide(chain(bignumber(1)).add(taxRateBu).done())
|
|
73
72
|
.multiply(taxRateBu)
|
|
74
73
|
.done()
|
|
@@ -293,6 +293,7 @@ export const onChangeLineAmountExcludeTax = lazyFn(
|
|
|
293
293
|
export const onChangeTaxRate = lazyFn(
|
|
294
294
|
(controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
|
|
295
295
|
|
|
296
|
+
console.log('计算税率===>')
|
|
296
297
|
form.validateFields(async (err, values) => {
|
|
297
298
|
err = err || {};
|
|
298
299
|
if (promptErr(err.taxRate) || (!values.taxRate && values.taxRate !== 0)) return;
|
|
@@ -384,7 +385,7 @@ export const updateUnitPriceExcludingTax = async (controller: InvoiceController,
|
|
|
384
385
|
let priceExcludeTax;
|
|
385
386
|
|
|
386
387
|
/** 扣除额 */
|
|
387
|
-
const deduction = controller.state.goodsListState.deduction;
|
|
388
|
+
const deduction = controller.state.goodsListState.deduction || 0;
|
|
388
389
|
|
|
389
390
|
const { editGood } = controller.state.goodsListState
|
|
390
391
|
|
|
@@ -81,6 +81,9 @@ export default (form: WrappedFormUtils) => {
|
|
|
81
81
|
/** 扣除额 */
|
|
82
82
|
const deduction = controller.useMemo((e) => e.goodsListState.deduction, []);
|
|
83
83
|
|
|
84
|
+
/** 差额开票是否启用 */
|
|
85
|
+
const differenceInputStateEnabled = controller.useMemo((e) => e.differenceInputState.enabled, []);
|
|
86
|
+
|
|
84
87
|
/** 计算中启动字段 */
|
|
85
88
|
const changeField = controller.useMemo((e) => e.calculatingField, []);
|
|
86
89
|
|
|
@@ -352,6 +355,7 @@ export default (form: WrappedFormUtils) => {
|
|
|
352
355
|
<MyInput
|
|
353
356
|
style={{ textAlign: 'right' }}
|
|
354
357
|
maxLength={25}
|
|
358
|
+
disabled={differenceInputStateEnabled}
|
|
355
359
|
loading={isCipher(changeField, 'priceIncludeTax')}
|
|
356
360
|
onChange={() => {
|
|
357
361
|
setChangeField('priceIncludeTax');
|
|
@@ -396,6 +400,7 @@ export default (form: WrappedFormUtils) => {
|
|
|
396
400
|
<MyInput
|
|
397
401
|
style={{ textAlign: 'right' }}
|
|
398
402
|
maxLength={25}
|
|
403
|
+
disabled={differenceInputStateEnabled}
|
|
399
404
|
loading={isCipher(changeField, 'priceExcludeTax')}
|
|
400
405
|
onChange={() => {
|
|
401
406
|
setChangeField('priceExcludeTax');
|
|
@@ -446,16 +451,20 @@ export default (form: WrappedFormUtils) => {
|
|
|
446
451
|
<MyInput
|
|
447
452
|
style={{ textAlign: 'right' }}
|
|
448
453
|
loading={isCipher(changeField, 'lineAmountIncludeTax')}
|
|
454
|
+
readOnly={differenceInputStateEnabled}
|
|
449
455
|
onChange={() => {
|
|
450
456
|
setChangeField('lineAmountIncludeTax');
|
|
451
457
|
onChangeLineAmountIncludeTax(controller, form, record);
|
|
452
458
|
}}
|
|
459
|
+
onClick={differenceInputStateEnabled ? (() => {
|
|
460
|
+
controller.run(async (s) => { s.differenceInputState.open = true });
|
|
461
|
+
}) : undefined}
|
|
453
462
|
/>,
|
|
454
463
|
)}
|
|
455
464
|
</Form.Item>
|
|
456
465
|
);
|
|
457
466
|
} else {
|
|
458
|
-
return <span style={{ padding: '0 10px' }}>{formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
|
|
467
|
+
return <span style={{ padding: '0 10px' }}>{formatSearch((isNaN(parseFloat(value)) ? 0 : parseFloat(value)).toFixed(2), searchValue)}</span>;
|
|
459
468
|
}
|
|
460
469
|
},
|
|
461
470
|
},
|
|
@@ -466,7 +475,7 @@ export default (form: WrappedFormUtils) => {
|
|
|
466
475
|
align: 'right',
|
|
467
476
|
width: 119,
|
|
468
477
|
render: (value: string, record: IGood) => {
|
|
469
|
-
if (editGood?.$index === record.$index && model !== 'prefab') {
|
|
478
|
+
if (editGood?.$index === record.$index && model !== 'prefab' && !differenceInputStateEnabled) {
|
|
470
479
|
return (
|
|
471
480
|
<Form.Item>
|
|
472
481
|
{getFieldDecorator('lineAmountExcludeTax', {
|
|
@@ -487,7 +496,11 @@ export default (form: WrappedFormUtils) => {
|
|
|
487
496
|
})(
|
|
488
497
|
<MyInput
|
|
489
498
|
style={{ textAlign: 'right' }}
|
|
499
|
+
readOnly={differenceInputStateEnabled}
|
|
490
500
|
loading={isCipher(changeField, 'lineAmountExcludeTax')}
|
|
501
|
+
onClick={differenceInputStateEnabled ? (() => {
|
|
502
|
+
controller.run(async (s) => { s.differenceInputState.open = true });
|
|
503
|
+
}) : undefined}
|
|
491
504
|
onChange={() => {
|
|
492
505
|
setChangeField('lineAmountExcludeTax');
|
|
493
506
|
onChangeLineAmountExcludeTax(controller, form, record);
|
|
@@ -497,8 +510,7 @@ export default (form: WrappedFormUtils) => {
|
|
|
497
510
|
</Form.Item>
|
|
498
511
|
);
|
|
499
512
|
} else {
|
|
500
|
-
|
|
501
|
-
return <span style={{ padding: '0 10px' }}>{value === '' ? '' : formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
|
|
513
|
+
return <span style={{ padding: '0 10px' }}>{value === '' ? '' : formatSearch((isNaN(parseFloat(value)) ? 0 : parseFloat(value)).toFixed(2), searchValue)}</span>;
|
|
502
514
|
}
|
|
503
515
|
},
|
|
504
516
|
},
|
|
@@ -571,10 +583,11 @@ export default (form: WrappedFormUtils) => {
|
|
|
571
583
|
//不含税金额
|
|
572
584
|
// const lineAmountExcludeTax = lineAmountIncludeTax-value;
|
|
573
585
|
const lineAmountExcludeTax = editGood?.lineAmountExcludeTax || 0;
|
|
586
|
+
const deduction = controller.state.goodsListState.deduction || 0;
|
|
574
587
|
const taxRate = editGood?.taxRate;
|
|
575
588
|
if (lineAmountExcludeTax && (taxRate || taxRate === 0) && lineAmountIncludeTax) {
|
|
576
589
|
// const total = bignumber(lineAmountExcludeTax * taxRate / 100);
|
|
577
|
-
const total =chain(bignumber(lineAmountExcludeTax)).multiply(bignumber(taxRate || 0)).divide(bignumber(100));
|
|
590
|
+
const total = chain(bignumber(lineAmountExcludeTax)).subtract(bignumber(deduction)).multiply(bignumber(taxRate || 0)).divide(bignumber(100));
|
|
578
591
|
// if (Number(Math.abs(Number(total) - Number(value)).toFixed(4)) <= 0.01) {
|
|
579
592
|
if (Math.abs(total.subtract(bignumber(value || 0)).done().toNumber()) <= 0.06) {
|
|
580
593
|
callback();
|
|
@@ -672,7 +685,7 @@ export default (form: WrappedFormUtils) => {
|
|
|
672
685
|
ellipsis: true,
|
|
673
686
|
};
|
|
674
687
|
}) as any[];
|
|
675
|
-
}, [isTaxIncluded, editGood, goodsList, controller, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, columnshide, isStart]);
|
|
688
|
+
}, [isTaxIncluded, editGood, goodsList, controller, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, columnshide, isStart, differenceInputStateEnabled]);
|
|
676
689
|
|
|
677
690
|
return controller.setColumnsConfig ? controller.setColumnsConfig(columns) : columns;
|
|
678
691
|
};
|
|
@@ -10,10 +10,10 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
|
|
|
10
10
|
|
|
11
11
|
const controller = Invoice.useInvoiceController();
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const rootElement = controller.useMemo(s => s.rootElement, []);
|
|
14
14
|
|
|
15
15
|
const autoComplete = controller.useMemo(s => s.autoComplete, [])
|
|
16
|
-
|
|
16
|
+
// const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
|
|
17
17
|
const [options, setOptions] = React.useState<IGood[]>([]);
|
|
18
18
|
|
|
19
19
|
const [selectLine, setSelectLine] = React.useState<any>(null);
|
|
@@ -40,6 +40,12 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
|
|
|
40
40
|
}
|
|
41
41
|
setSelectLine(null);
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
console.log('onBlur ===>', controller.state.differenceInputState.enabled)
|
|
45
|
+
// 失去焦点时,打开差额开票弹窗
|
|
46
|
+
if (controller.state.differenceInputState.enabled) {
|
|
47
|
+
controller.run(async (s) => { s.differenceInputState.open = true });
|
|
48
|
+
}
|
|
43
49
|
} catch (error) {
|
|
44
50
|
throw error;
|
|
45
51
|
}
|
|
@@ -13,7 +13,10 @@ export default function useWindowClick(controller: InvoiceController) {
|
|
|
13
13
|
|
|
14
14
|
/** 点击组件外部 保存正在编辑的货物 */
|
|
15
15
|
React.useEffect(() => {
|
|
16
|
-
const click = () => {
|
|
16
|
+
const click = () => {
|
|
17
|
+
if (!controller.state.goodsListState?.isSaveRowOutside) return;
|
|
18
|
+
setTimeout(controller.saveEditGood)
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
window.addEventListener('click', click);
|
|
19
22
|
return () => {
|
|
@@ -77,7 +77,7 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
|
|
|
77
77
|
/** 表格行事件 */
|
|
78
78
|
const onRow = useOnRow();
|
|
79
79
|
|
|
80
|
-
useDeduction(controller, props.deduction);
|
|
80
|
+
// useDeduction(controller, props.deduction);
|
|
81
81
|
useWindowClick(controller);
|
|
82
82
|
|
|
83
83
|
/** 批量赋码 */
|
|
@@ -22,6 +22,9 @@ export default (props: any) => {
|
|
|
22
22
|
/** 产品最大数 */
|
|
23
23
|
const goodMax = controller.useMemo(s => s.goodsListState.goodMax, []);
|
|
24
24
|
|
|
25
|
+
/** 是否是差额开票模式 */
|
|
26
|
+
const isDifferenceInput = controller.useMemo(s => s.differenceInputState.enabled, []);
|
|
27
|
+
|
|
25
28
|
/** 按钮是否禁用 */
|
|
26
29
|
const disabled = React.useMemo(() => typeof goodMax === 'number' ? goodsNum >= goodMax : !!searchValue, [goodMax, goodsNum, searchValue])
|
|
27
30
|
|
|
@@ -39,6 +42,7 @@ export default (props: any) => {
|
|
|
39
42
|
if (isAddRow === false) return <></>;
|
|
40
43
|
if (model === 'prefab') return <></>;
|
|
41
44
|
if (model === 'readOnly') return <></>;
|
|
45
|
+
// if (isDifferenceInput && goodsNum >= 1) return <></>;
|
|
42
46
|
|
|
43
47
|
return (
|
|
44
48
|
<Button onClick={onClick} disabled={disabled}>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
import { DifferenceInputModal, IData } from "../../../../DifferenceInputModal";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import Invoice from "../../../index";
|
|
5
|
+
import { bignumber, chain } from "mathjs";
|
|
6
|
+
import { onChangeLineAmountIncludeTax, onChangeLineAmountExcludeTax } from '../../../ui/default/GoodsList/hook/useColumns/autoFillFn';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
|
|
10
|
+
const controller = Invoice.useInvoiceController();
|
|
11
|
+
const open = controller.useMemo((s) => s.differenceInputState.open && s.differenceInputState.enabled && !s.goodsListState.importGoods.isVisibleDrawer, []);
|
|
12
|
+
const data = controller.useMemo((s) => s.differenceInputState.data, []);
|
|
13
|
+
|
|
14
|
+
/** 计算中启动字段 */
|
|
15
|
+
const setChangeField = React.useCallback((value: string) => controller.run(async s => { s.calculatingField = value }), []);
|
|
16
|
+
|
|
17
|
+
const value = React.useMemo(() => {
|
|
18
|
+
return {
|
|
19
|
+
rows: data?.rows || [],
|
|
20
|
+
projectCode: data?.projectCode || '',
|
|
21
|
+
deductTotal: data?.deductTotal || 0,
|
|
22
|
+
amountIncludeTax: controller.state.goodsListState.form?.getFieldValue('lineAmountIncludeTax') || 0,
|
|
23
|
+
}
|
|
24
|
+
}, [data, open]);
|
|
25
|
+
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
controller.state.goodsListState.isSaveRowOutside = !open;
|
|
28
|
+
if (open) {
|
|
29
|
+
controller.run(async (s) => {
|
|
30
|
+
if (!s.differenceInputState.data) return;
|
|
31
|
+
s.differenceInputState.data.amountIncludeTax = s.goodsListState.form?.getFieldValue('lineAmountIncludeTax');
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}, [open]);
|
|
35
|
+
|
|
36
|
+
console.log('DifferenceInput data ===>', data)
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<DifferenceInputModal
|
|
40
|
+
value={value}
|
|
41
|
+
open={open}
|
|
42
|
+
onCancel={() => {
|
|
43
|
+
controller.run(async (s) => { s.differenceInputState.open = false });
|
|
44
|
+
}}
|
|
45
|
+
onOk={async (data: IData) => {
|
|
46
|
+
await controller.run(async (s) => { s.goodsListState.isTaxIncluded = true });
|
|
47
|
+
await controller.wait();
|
|
48
|
+
await controller.run(async (s) => {
|
|
49
|
+
s.differenceInputState.data = data;
|
|
50
|
+
s.goodsListState.deduction = data.deductTotal;
|
|
51
|
+
s.differenceInputState.open = false;
|
|
52
|
+
s.differenceInputState.amountIncludeTax = data.amountIncludeTax;
|
|
53
|
+
|
|
54
|
+
const amountIncludeTax = data.amountIncludeTax || 0;
|
|
55
|
+
// const deductTotal = data.deductTotal || 0;
|
|
56
|
+
const form = s.goodsListState.form;
|
|
57
|
+
const record = s.goodsListState.editGood;
|
|
58
|
+
|
|
59
|
+
if (s.goodsListState.goodsList && s.goodsListState.goodsList.length > 0) {
|
|
60
|
+
s.goodsListState.editGood = record;
|
|
61
|
+
s.goodsListState.form?.setFieldsValue({ lineAmountIncludeTax: amountIncludeTax });
|
|
62
|
+
setChangeField('lineAmountIncludeTax');
|
|
63
|
+
await onChangeLineAmountIncludeTax(controller, form, record);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -75,7 +75,7 @@ export const onChangeQuantity = lazyFn(
|
|
|
75
75
|
// 是否含税
|
|
76
76
|
if (controller.state.goodsListState.isTaxIncluded) {
|
|
77
77
|
// 含税
|
|
78
|
-
if (!err.priceIncludeTax && values.priceIncludeTax) {
|
|
78
|
+
if (!err.priceIncludeTax && values.priceIncludeTax && !controller.state.differenceInputState.enabled) {
|
|
79
79
|
// 可以找到 单价(含税)
|
|
80
80
|
const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
|
|
81
81
|
const lineAmountIncludeTax = format2(evaluate(`${priceIncludeTax} * ${quantity}`));
|
|
@@ -95,7 +95,7 @@ export const onChangeQuantity = lazyFn(
|
|
|
95
95
|
await updateUnitPriceExcludingTax(controller, form, record);
|
|
96
96
|
} else {
|
|
97
97
|
// 不含税
|
|
98
|
-
if (!err.priceExcludeTax && values.priceExcludeTax) {
|
|
98
|
+
if (!err.priceExcludeTax && values.priceExcludeTax && !controller.state.differenceInputState.enabled) {
|
|
99
99
|
// 可以找到 单价(不含税)
|
|
100
100
|
const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
|
|
101
101
|
const lineAmountExcludeTax = format2(evaluate(`${quantity} * ${priceExcludeTax}`));
|