kts-component-invoice-operate 3.2.265 → 3.2.267

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.
Files changed (29) hide show
  1. package/dist/DifferenceInputModal/index.d.ts +8 -2
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/DifferenceInputState/index.d.ts +2 -0
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  4. package/dist/Invoice/InvoiceController/hooks/index.d.ts +3 -0
  5. package/dist/Invoice/tools/calculate/index.d.ts +1 -1
  6. package/dist/index.esm.js +695 -288
  7. package/dist/index.js +695 -288
  8. package/package.json +1 -1
  9. package/src/DifferenceInputModal/index.tsx +87 -17
  10. package/src/Invoice/Invoice-digtal/index.md +9 -9
  11. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +2 -1
  12. package/src/Invoice/InvoiceController/InvoiceControllerState/DifferenceInputState/index.ts +3 -0
  13. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +3 -0
  14. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +1 -0
  15. package/src/Invoice/InvoiceController/hooks/index.ts +76 -0
  16. package/src/Invoice/index.tsx +3 -0
  17. package/src/Invoice/tools/calculate/index.ts +2 -3
  18. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +4 -2
  19. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +2 -1
  20. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +19 -6
  21. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +5 -4
  22. package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +4 -1
  23. package/src/Invoice/ui/default/GoodsList/index.tsx +1 -1
  24. package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +1 -1
  25. package/src/Invoice/ui/digtal/DifferenceInput/index.tsx +33 -3
  26. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +2 -2
  27. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +34 -21
  28. package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +4 -1
  29. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +1 -1
@@ -2,6 +2,8 @@
2
2
  import { DifferenceInputModal, IData } from "../../../../DifferenceInputModal";
3
3
  import React from "react";
4
4
  import Invoice from "../../../index";
5
+ import { bignumber, chain } from "mathjs";
6
+ import { onChangeLineAmountIncludeTax, onChangeLineAmountExcludeTax } from '../../../ui/default/GoodsList/hook/useColumns/autoFillFn';
5
7
 
6
8
  export default () => {
7
9
 
@@ -9,15 +11,28 @@ export default () => {
9
11
  const open = controller.useMemo((s) => s.differenceInputState.open && s.differenceInputState.enabled && !s.goodsListState.importGoods.isVisibleDrawer, []);
10
12
  const data = controller.useMemo((s) => s.differenceInputState.data, []);
11
13
 
14
+ /** 计算中启动字段 */
15
+ const setChangeField = React.useCallback((value: string) => controller.run(async s => { s.calculatingField = value }), []);
16
+
12
17
  const value = React.useMemo(() => {
13
18
  return {
14
19
  rows: data?.rows || [],
15
20
  projectCode: data?.projectCode || '',
16
- voucherTotal: data?.voucherTotal || 0,
17
21
  deductTotal: data?.deductTotal || 0,
22
+ amountIncludeTax: controller.state.goodsListState.form?.getFieldValue('lineAmountIncludeTax') || 0,
18
23
  }
19
24
  }, [data, open]);
20
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
+
21
36
  console.log('DifferenceInput data ===>', data)
22
37
 
23
38
  return (
@@ -27,11 +42,26 @@ export default () => {
27
42
  onCancel={() => {
28
43
  controller.run(async (s) => { s.differenceInputState.open = false });
29
44
  }}
30
- onOk={(data: IData) => {
31
- controller.run(async (s) => {
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) => {
32
49
  s.differenceInputState.data = data;
33
50
  s.goodsListState.deduction = data.deductTotal;
34
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
+ }
35
65
  });
36
66
  }}
37
67
  />
@@ -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}`));
@@ -70,6 +70,9 @@ export default (form: WrappedFormUtils) => {
70
70
  /** 扣除额 */
71
71
  const deduction = controller.useMemo((e) => e.goodsListState.deduction, []);
72
72
 
73
+ /** 差额开票是否启用 */
74
+ const differenceInputStateEnabled = controller.useMemo((e) => e.differenceInputState.enabled, []);
75
+
73
76
  /** 计算中启动字段 */
74
77
  const changeField = controller.useMemo((e) => e.calculatingField, []);
75
78
 
@@ -123,21 +126,22 @@ export default (form: WrappedFormUtils) => {
123
126
  initialValue: isMyShow ? record.itemNameSelf : record.itemName,
124
127
  rules: [
125
128
  ...getReplenishRules('itemName'),
126
- {
127
- validator: async (_, __, callback) => {
128
- if (isValidateGood) {
129
- await controller.wait();
130
- const value = controller.state.goodsListState.editGood;
131
- if (!value?.itemName && !value?.itemNameSelf) {
132
- callback('项目名称不能为空');
133
- } else {
134
- return;
135
- }
136
- } else {
137
- callback();
138
- }
139
- }
140
- }
129
+ { required: isValidateGood, message: '项目名称不能为空' },
130
+ // {
131
+ // validator: async (_, __, callback) => {
132
+ // if (isValidateGood) {
133
+ // await controller.wait();
134
+ // const value = controller.state.goodsListState.editGood;
135
+ // if (!value?.itemName && !value?.itemNameSelf) {
136
+ // callback('项目名称不能为空');
137
+ // } else {
138
+ // return;
139
+ // }
140
+ // } else {
141
+ // callback();
142
+ // }
143
+ // }
144
+ // }
141
145
  ]
142
146
  })(
143
147
  <ItemNameInput
@@ -318,6 +322,7 @@ export default (form: WrappedFormUtils) => {
318
322
  <MyInput
319
323
  style={{ textAlign: 'right' }}
320
324
  maxLength={25}
325
+ disabled={differenceInputStateEnabled}
321
326
  loading={isCipher(changeField, 'priceIncludeTax')}
322
327
  onChange={() => {
323
328
  setChangeField('priceIncludeTax');
@@ -362,6 +367,7 @@ export default (form: WrappedFormUtils) => {
362
367
  <MyInput
363
368
  style={{ textAlign: 'right' }}
364
369
  maxLength={25}
370
+ disabled={differenceInputStateEnabled}
365
371
  loading={isCipher(changeField, 'priceExcludeTax')}
366
372
  onChange={() => {
367
373
  setChangeField('priceExcludeTax');
@@ -412,10 +418,14 @@ export default (form: WrappedFormUtils) => {
412
418
  <MyInput
413
419
  style={{ textAlign: 'right' }}
414
420
  loading={isCipher(changeField, 'lineAmountIncludeTax')}
421
+ readOnly={differenceInputStateEnabled}
415
422
  onChange={() => {
416
423
  setChangeField('lineAmountIncludeTax');
417
424
  onChangeLineAmountIncludeTax(controller, form, record);
418
425
  }}
426
+ onClick={differenceInputStateEnabled ? (() => {
427
+ controller.run(async (s) => { s.differenceInputState.open = true });
428
+ }) : undefined}
419
429
  />,
420
430
  )}
421
431
  </Form.Item>
@@ -454,10 +464,14 @@ export default (form: WrappedFormUtils) => {
454
464
  <MyInput
455
465
  style={{ textAlign: 'right' }}
456
466
  loading={isCipher(changeField, 'lineAmountExcludeTax')}
467
+ readOnly={differenceInputStateEnabled}
457
468
  onChange={() => {
458
469
  setChangeField('lineAmountExcludeTax');
459
470
  onChangeLineAmountExcludeTax(controller, form, record);
460
471
  }}
472
+ onClick={differenceInputStateEnabled ? (() => {
473
+ controller.run(async (s) => { s.differenceInputState.open = true });
474
+ }) : undefined}
461
475
  />,
462
476
  )}
463
477
  </Form.Item>
@@ -537,17 +551,16 @@ export default (form: WrappedFormUtils) => {
537
551
  const lineAmountIncludeTax = editGood?.lineAmountIncludeTax || 0;
538
552
  //不含税金额
539
553
  // const lineAmountExcludeTax = lineAmountIncludeTax-value;
554
+ const deduction = controller.state.goodsListState.deduction || 0;
540
555
  const lineAmountExcludeTax = editGood?.lineAmountExcludeTax || 0;
541
556
  const taxRate = editGood?.taxRate;
542
- if (lineAmountExcludeTax && (taxRate || taxRate === 0) && lineAmountIncludeTax) {
543
- // const total = bignumber(lineAmountExcludeTax * taxRate / 100);
544
- const total = chain(bignumber(lineAmountExcludeTax)).multiply(bignumber(taxRate || 0)).divide(bignumber(100));
545
- // if (Number(Math.abs(Number(total) - Number(value)).toFixed(4)) <= 0.01) {
557
+ if (lineAmountExcludeTax && (taxRate || taxRate === 0) && lineAmountIncludeTax) {
558
+ const total = chain(bignumber(lineAmountExcludeTax)).subtract(bignumber(deduction || 0)).multiply(bignumber(taxRate || 0)).divide(bignumber(100));
546
559
  if (Math.abs(total.subtract(bignumber(value || 0)).done().toNumber()) <= 0.06) {
547
560
  callback();
548
561
  } else {
549
562
  callback('第' + (record.serialNo) + '行税额校验不通过!')
550
- }
563
+ }
551
564
  } else {
552
565
  callback();
553
566
  }
@@ -605,7 +618,7 @@ export default (form: WrappedFormUtils) => {
605
618
  ellipsis: true,
606
619
  };
607
620
  }) as any[];
608
- }, [isTaxIncluded, editGood, controller, taxRateList, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart, calculateType]);
621
+ }, [isTaxIncluded, editGood, controller, taxRateList, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart, calculateType, differenceInputStateEnabled]);
609
622
 
610
623
  // React.useEffect(() => {
611
624
  // clearTimeout(t)
@@ -13,7 +13,10 @@ export default function useWindowClick(controller: InvoiceController) {
13
13
 
14
14
  /** 点击组件外部 保存正在编辑的货物 */
15
15
  React.useEffect(() => {
16
- const click = () => { setTimeout(controller.saveEditGood) };
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 () => {
@@ -38,7 +38,7 @@ export default () => {
38
38
  if (isAddRow === false) return <></>;
39
39
  if (model === 'prefab') return <></>;
40
40
  if (model === 'readOnly') return <></>;
41
- if (isDifferenceInput && goodsNum >= 1) return <></>;
41
+ // if (isDifferenceInput && goodsNum >= 1) return <></>;
42
42
 
43
43
  return (
44
44
  <Button size='small' type='primary' onClick={onClick} disabled={disabled}>