kts-component-invoice-operate 3.1.2 → 3.1.4

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 (117) hide show
  1. package/.dumi/theme/builtins/API.tsx +66 -66
  2. package/.editorconfig +16 -16
  3. package/.fatherrc.ts +4 -4
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +8 -8
  7. package/README.md +5 -5
  8. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.d.ts +2 -2
  9. package/dist/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.d.ts +1 -1
  10. package/dist/index.esm.js +2715 -3859
  11. package/dist/index.js +2715 -3859
  12. package/docs/index.md +5 -5
  13. package/docs-dist/umi.js +1 -1
  14. package/index.html +12 -12
  15. package/package.json +59 -59
  16. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +94 -94
  17. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +88 -88
  18. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +90 -90
  19. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IColumnsReplenish/index.ts +10 -10
  20. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +72 -72
  21. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ImportGoods/index.ts +80 -80
  22. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +5 -5
  23. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +9 -9
  24. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +88 -88
  25. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +42 -42
  26. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  27. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +125 -125
  28. package/src/Invoice/InvoiceController/fns/delGood.ts +43 -43
  29. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +23 -23
  30. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +23 -23
  31. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  32. package/src/Invoice/InvoiceController/fns/setGoods.ts +10 -10
  33. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  34. package/src/Invoice/InvoiceController/index.ts +61 -61
  35. package/src/Invoice/_test/buyerNameSearch/index.tsx +41 -41
  36. package/src/Invoice/_test/deduction/index.tsx +935 -935
  37. package/src/Invoice/_test/draft/index.tsx +40 -40
  38. package/src/Invoice/_test/easiest/index.tsx +5 -5
  39. package/src/Invoice/_test/endowCode/index.tsx +1095 -1095
  40. package/src/Invoice/_test/goodsMenuExpand/index.tsx +32 -32
  41. package/src/Invoice/_test/importBuyer/index.tsx +74 -74
  42. package/src/Invoice/_test/importGoods/index.tsx +515 -515
  43. package/src/Invoice/_test/invoiceType/index.tsx +59 -59
  44. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  45. package/src/Invoice/_test/replaceHead/index.tsx +22 -22
  46. package/src/Invoice/_test/retrieveData/index.tsx +22 -22
  47. package/src/Invoice/_test/seller/index.tsx +28 -28
  48. package/src/Invoice/_test/setDataSource/index.tsx +22 -22
  49. package/src/Invoice/_test/unit/index.tsx +19 -19
  50. package/src/Invoice/index.less +12 -12
  51. package/src/Invoice/index.md +53 -53
  52. package/src/Invoice/index.tsx +104 -104
  53. package/src/Invoice/tools/calculate/index.ts +97 -97
  54. package/src/Invoice/tools/coolingFn/index.ts +17 -17
  55. package/src/Invoice/tools/evaluate/index.ts +7 -7
  56. package/src/Invoice/tools/idGenerator/index.ts +2 -2
  57. package/src/Invoice/tools/itemName/index.ts +46 -46
  58. package/src/Invoice/tools/lazyFn/index.ts +19 -19
  59. package/src/Invoice/tools/strringFn/index.ts +40 -40
  60. package/src/Invoice/ui/AddComparisonDrawer/index.tsx +149 -149
  61. package/src/Invoice/ui/Buyer/index.less +219 -219
  62. package/src/Invoice/ui/Buyer/index.tsx +114 -114
  63. package/src/Invoice/ui/Buyer/ui/BuyerNameInput/index.tsx +166 -166
  64. package/src/Invoice/ui/Buyer/ui/ImportBuyerButton/index.tsx +21 -21
  65. package/src/Invoice/ui/EndowCodeDrawer/index.less +8 -8
  66. package/src/Invoice/ui/EndowCodeDrawer/index.tsx +441 -441
  67. package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +490 -490
  68. package/src/Invoice/ui/GoodsList/hook/useColumns/index.tsx +603 -603
  69. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  70. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +34 -34
  71. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  72. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  73. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  74. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +35 -35
  75. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  76. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  77. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  78. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  79. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  80. package/src/Invoice/ui/GoodsList/hook/useDeduction/index.tsx +24 -24
  81. package/src/Invoice/ui/GoodsList/hook/useOnRow/index.tsx +39 -39
  82. package/src/Invoice/ui/GoodsList/hook/useRowSelection/index.tsx +111 -111
  83. package/src/Invoice/ui/GoodsList/hook/useToGenerateId/index.ts +8 -8
  84. package/src/Invoice/ui/GoodsList/hook/useWindowClick/index.tsx +23 -23
  85. package/src/Invoice/ui/GoodsList/index.less +170 -170
  86. package/src/Invoice/ui/GoodsList/index.tsx +177 -177
  87. package/src/Invoice/ui/GoodsList/ui/AddRowButton/index.tsx +61 -61
  88. package/src/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.less +21 -21
  89. package/src/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +244 -244
  90. package/src/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  91. package/src/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +66 -66
  92. package/src/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +58 -58
  93. package/src/Invoice/ui/GoodsList/ui/BulkMenu/index.tsx +37 -37
  94. package/src/Invoice/ui/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  95. package/src/Invoice/ui/GoodsList/ui/Search/index.less +10 -10
  96. package/src/Invoice/ui/GoodsList/ui/Search/index.tsx +50 -50
  97. package/src/Invoice/ui/GoodsList/ui/Statistics/index.less +18 -18
  98. package/src/Invoice/ui/GoodsList/ui/Statistics/index.tsx +109 -109
  99. package/src/Invoice/ui/GoodsList/ui/TableRow/index.tsx +27 -27
  100. package/src/Invoice/ui/GoodsList/ui/TableVirtual/index.less +38 -38
  101. package/src/Invoice/ui/GoodsList/ui/TableVirtual/index.tsx +105 -105
  102. package/src/Invoice/ui/GoodsList/ui/TableVirtual.o/index.less +44 -44
  103. package/src/Invoice/ui/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  104. package/src/Invoice/ui/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  105. package/src/Invoice/ui/ImportBuyerDrawer/index.tsx +75 -75
  106. package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +174 -174
  107. package/src/Invoice/ui/InvoiceHeader/index.less +68 -68
  108. package/src/Invoice/ui/InvoiceHeader/index.tsx +246 -246
  109. package/src/Invoice/ui/Seller/index.less +113 -113
  110. package/src/Invoice/ui/Seller/index.tsx +98 -98
  111. package/src/Invoice/ui/Sign/index.less +14 -14
  112. package/src/Invoice/ui/Sign/index.tsx +71 -71
  113. package/src/index.ts +6 -6
  114. package/tsconfig.json +31 -31
  115. package/typings.d.ts +3 -3
  116. package/yarn.e.lock +14331 -14331
  117. package/yarn.o.lock +14800 -14800
@@ -1,88 +1,88 @@
1
- import IGood from './IGood';
2
- import ImportGoods from './ImportGoods';
3
- import EndowCode from './EndowCode';
4
- import ProductComparison from './ProductComparison';
5
- import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
6
- import InvoiceController from '../..';
7
- import IColumnsReplenish from './IColumnsReplenish';
8
-
9
- export default class GoodsListState {
10
-
11
- /** 扣除额 */
12
- deduction = 0;
13
-
14
- /** 产品最大数 */
15
- goodMax?: number;
16
-
17
- /** 是否可以切换(含税/不含税)状态 */
18
- isSwitchTax?: boolean;
19
-
20
- /** 是否能添加折扣行 */
21
- isAddDiscount?: boolean;
22
-
23
- /** 是否含税 */
24
- isTaxIncluded = true;
25
-
26
- /** 是否显示我方 */
27
- isMyShow = false;
28
-
29
- /** 正在编辑的货物 */
30
- editGood?: IGood;
31
-
32
- /** 被编辑行的form对象 */
33
- form?: WrappedFormUtils;
34
-
35
- /** 商品表格补充配置 */
36
- columnsReplenish: { [key: string]: IColumnsReplenish } = {};
37
-
38
- /** 单位列表 */
39
- unitList: string[] = [];
40
-
41
- /** 默认税率 */
42
- defaultRate = 3;
43
-
44
- /** 税率列表 */
45
- taxRateList: number[] = [0, 3, 5, 6, 9, 13];
46
-
47
- /** 搜索条件 */
48
- searchValue = '';
49
-
50
- /** 货物列表 */
51
- goodsList: IGood[] = [];
52
-
53
- /** 货物字典 */
54
- goodsMap = new Map<string, IGood>();
55
-
56
- /** 货物菜单扩展 */
57
- goodsMenuExpand: ((index: string, controller: InvoiceController) => React.ReactNode)[] = [];
58
-
59
- /** 金额含税(受控,输入后不再自动计算) */
60
- amountIncludeTax?: number;
61
-
62
- /** 金额不含税(受控,输入后不再自动计算) */
63
- amountExcludeTax?: number;
64
-
65
- /** 税额(受控,输入后不再自动计算) */
66
- amountTax?: number;
67
-
68
- /** 列表选中的货物索引列表 */
69
- selectedGoodIndex: string[] = [];
70
-
71
- /** 准备添加折扣的货物索引列表 */
72
- discountGoodIndex: string[] = [];
73
-
74
- /** 货物赋码的相关数据 */
75
- endowCode = new EndowCode();
76
-
77
- /** 导入商品的相关数据 */
78
- importGoods = new ImportGoods();
79
-
80
- /** 商品对照 相关 */
81
- productComparison = new ProductComparison();
82
-
83
- /** 是否显购买示导入抽屉 */
84
- isVisibleDrawer = false;
85
-
86
- /** 正在 添加商品对照 的货物 */
87
- addComparisonIndex?: string;
88
- }
1
+ import IGood from './IGood';
2
+ import ImportGoods from './ImportGoods';
3
+ import EndowCode from './EndowCode';
4
+ import ProductComparison from './ProductComparison';
5
+ import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
6
+ import InvoiceController from '../..';
7
+ import IColumnsReplenish from './IColumnsReplenish';
8
+
9
+ export default class GoodsListState {
10
+
11
+ /** 扣除额 */
12
+ deduction = 0;
13
+
14
+ /** 产品最大数 */
15
+ goodMax?: number;
16
+
17
+ /** 是否可以切换(含税/不含税)状态 */
18
+ isSwitchTax?: boolean;
19
+
20
+ /** 是否能添加折扣行 */
21
+ isAddDiscount?: boolean;
22
+
23
+ /** 是否含税 */
24
+ isTaxIncluded = true;
25
+
26
+ /** 是否显示我方 */
27
+ isMyShow = false;
28
+
29
+ /** 正在编辑的货物 */
30
+ editGood?: IGood;
31
+
32
+ /** 被编辑行的form对象 */
33
+ form?: WrappedFormUtils;
34
+
35
+ /** 商品表格补充配置 */
36
+ columnsReplenish: { [key: string]: IColumnsReplenish } = {};
37
+
38
+ /** 单位列表 */
39
+ unitList: string[] = [];
40
+
41
+ /** 默认税率 */
42
+ defaultRate = 3;
43
+
44
+ /** 税率列表 */
45
+ taxRateList: number[] = [0, 3, 5, 6, 9, 13];
46
+
47
+ /** 搜索条件 */
48
+ searchValue = '';
49
+
50
+ /** 货物列表 */
51
+ goodsList: IGood[] = [];
52
+
53
+ /** 货物字典 */
54
+ goodsMap = new Map<string, IGood>();
55
+
56
+ /** 货物菜单扩展 */
57
+ goodsMenuExpand: ((index: string, controller: InvoiceController) => React.ReactNode)[] = [];
58
+
59
+ /** 金额含税(受控,输入后不再自动计算) */
60
+ amountIncludeTax?: number;
61
+
62
+ /** 金额不含税(受控,输入后不再自动计算) */
63
+ amountExcludeTax?: number;
64
+
65
+ /** 税额(受控,输入后不再自动计算) */
66
+ amountTax?: number;
67
+
68
+ /** 列表选中的货物索引列表 */
69
+ selectedGoodIndex: string[] = [];
70
+
71
+ /** 准备添加折扣的货物索引列表 */
72
+ discountGoodIndex: string[] = [];
73
+
74
+ /** 货物赋码的相关数据 */
75
+ endowCode = new EndowCode();
76
+
77
+ /** 导入商品的相关数据 */
78
+ importGoods = new ImportGoods();
79
+
80
+ /** 商品对照 相关 */
81
+ productComparison = new ProductComparison();
82
+
83
+ /** 是否显购买示导入抽屉 */
84
+ isVisibleDrawer = false;
85
+
86
+ /** 正在 添加商品对照 的货物 */
87
+ addComparisonIndex?: string;
88
+ }
@@ -1,42 +1,42 @@
1
- import GoodsListState from './GoodsListState';
2
- import BuyerState from './BuyerState';
3
-
4
- export default class InvoiceControllerState {
5
-
6
- /**
7
- * 组件模式
8
- * prefab 预制
9
- * readOnly 只读
10
- * */
11
- model: 'default' | 'prefab' | 'readOnly' = 'default';
12
-
13
- /**
14
- * 企业类型
15
- * 01 一般纳税人
16
- * 05 转登记纳税人
17
- * 04 代开企业
18
- * 08 小规模纳税人
19
- * */
20
- en: '01' | '05' | '04' | '08' = '01';
21
-
22
- /**
23
- * 发票类型
24
- * 08 - 增值税电子专用发票
25
- * 10 - 增值税电子普通发票
26
- * 01 - 增值税纸质专用发票
27
- * 04 - 增值税纸质普通发票
28
- */
29
- invoiceType: '08' | '10' | '01' | '04' = '08';
30
-
31
- /** 购买方 */
32
- buyerState = new BuyerState();
33
-
34
- /** 货物信息 */
35
- goodsListState = new GoodsListState();
36
-
37
- /** 计算中启动字段 */
38
- calculating?: string;
39
-
40
- /** 组件根结构 */
41
- rootElement?: HTMLDivElement | null = null;
42
- }
1
+ import GoodsListState from './GoodsListState';
2
+ import BuyerState from './BuyerState';
3
+
4
+ export default class InvoiceControllerState {
5
+
6
+ /**
7
+ * 组件模式
8
+ * prefab 预制
9
+ * readOnly 只读
10
+ * */
11
+ model: 'default' | 'prefab' | 'readOnly' = 'default';
12
+
13
+ /**
14
+ * 企业类型
15
+ * 01 一般纳税人
16
+ * 05 转登记纳税人
17
+ * 04 代开企业
18
+ * 08 小规模纳税人
19
+ * */
20
+ en: '01' | '05' | '04' | '08' = '01';
21
+
22
+ /**
23
+ * 发票类型
24
+ * 08 - 增值税电子专用发票
25
+ * 10 - 增值税电子普通发票
26
+ * 01 - 增值税纸质专用发票
27
+ * 04 - 增值税纸质普通发票
28
+ */
29
+ invoiceType: '08' | '10' | '01' | '04' = '08';
30
+
31
+ /** 购买方 */
32
+ buyerState = new BuyerState();
33
+
34
+ /** 货物信息 */
35
+ goodsListState = new GoodsListState();
36
+
37
+ /** 计算中启动字段 */
38
+ calculating?: string;
39
+
40
+ /** 组件根结构 */
41
+ rootElement?: HTMLDivElement | null = null;
42
+ }
@@ -1,11 +1,11 @@
1
- import { InvoiceControllerState } from '../';
2
- import idGenerator from '../../tools/idGenerator';
3
-
4
- /**
5
- * 添加的编辑货物
6
- */
7
- export default async (state: InvoiceControllerState, options?: any) => {
8
- options.$index = idGenerator();
9
- state.goodsListState.goodsList = [...state.goodsListState.goodsList, options];
10
- return options;
11
- };
1
+ import { InvoiceControllerState } from '../';
2
+ import idGenerator from '../../tools/idGenerator';
3
+
4
+ /**
5
+ * 添加的编辑货物
6
+ */
7
+ export default async (state: InvoiceControllerState, options?: any) => {
8
+ options.$index = idGenerator();
9
+ state.goodsListState.goodsList = [...state.goodsListState.goodsList, options];
10
+ return options;
11
+ };
@@ -1,125 +1,125 @@
1
- /**
2
- *
3
- * 折扣率 含税金额 不含税金额
4
- *
5
- * 含税折扣额 = -1 * (含税金额 * 折扣率)
6
- * 不含税扣额 = 含税折扣额 / (1+税率)
7
- * 折扣税额 = 含税折扣额 - 不含税扣额
8
- */
9
-
10
- import { v4 as uuidv4 } from 'uuid';
11
- import { chain, bignumber } from 'mathjs';
12
- import { InvoiceControllerState } from '../';
13
- import LineAttributeType from '../InvoiceControllerState/GoodsListState/LineAttributeType';
14
- import idGenerator from '../../tools/idGenerator';
15
- import { format2 } from '../../../Invoice/tools/calculate';
16
-
17
- export interface IOptions {
18
- /** 需要添加的 索引列表 */
19
- indexList: string[];
20
-
21
- /** 折扣 */
22
- discount: number;
23
-
24
- /** 折扣 金额 */
25
- discolineAmountunt: number;
26
- }
27
-
28
- /**
29
- * 设置当前的编辑货物
30
- */
31
- export default async (state: InvoiceControllerState, options?: IOptions) => {
32
- if (!options) return;
33
-
34
- const { indexList = [] } = options;
35
- const discount = chain(bignumber(options.discount || 0)).dotDivide(bignumber(100)).done();
36
- const goodsMap = state.goodsListState.goodsMap;
37
- const goodsList = state.goodsListState.goodsList;
38
- const discountGroup = uuidv4();
39
- let amountSum = bignumber(0);
40
-
41
- for (let t = 0; t < indexList.length; t++) {
42
- const $index = indexList[t];
43
- const good = goodsMap.get($index);
44
-
45
- if (!good || good.lineAttribute !== LineAttributeType.正常) continue;
46
-
47
- const i = goodsList.indexOf(good);
48
-
49
- let lineAmountIncludeTax = 0;
50
- let lineAmountExcludeTax = 0;
51
-
52
- const taxRate = chain(bignumber(good.taxRate)).dotDivide(bignumber(100)).done();
53
- if (state.goodsListState.isTaxIncluded) {
54
- /** 金额(含税) -1 * ${good.lineAmountIncludeTax} * ${discount}*/
55
- lineAmountIncludeTax = (() => {
56
- if (t === indexList.length - 1) {
57
- return chain(bignumber(options.discolineAmountunt)).add(amountSum).multiply(-1).done().toNumber();
58
- } else {
59
- return chain(bignumber(-1))
60
- .multiply(bignumber(good.lineAmountIncludeTax))
61
- .multiply(discount)
62
- .done()
63
- .toNumber()
64
- .toFixed(2);
65
- }
66
- })()
67
- amountSum = amountSum.add(bignumber(lineAmountIncludeTax));
68
-
69
- /** 金额(不含税) ${lineAmountIncludeTax} / (1+${good.taxRate}/100)*/
70
- lineAmountExcludeTax = 1 * chain(bignumber(lineAmountIncludeTax))
71
- .dotDivide(chain(bignumber(1)).add(taxRate).done())
72
- .done()
73
- .toNumber()
74
- .toFixed(2)
75
- } else {
76
-
77
- /** 金额(不含税) -1 * ${good.lineAmountIncludeTax} * ${discount}*/
78
- lineAmountExcludeTax = (() => {
79
- if (t === indexList.length - 1) {
80
- return chain(bignumber(options.discolineAmountunt)).add(amountSum).multiply(-1).done().toNumber();
81
- } else {
82
- return chain(bignumber(-1))
83
- .multiply(bignumber(good.lineAmountExcludeTax))
84
- .multiply(discount)
85
- .done()
86
- .toNumber()
87
- .toFixed(2);
88
- }
89
- })()
90
- amountSum = amountSum.add(bignumber(lineAmountExcludeTax));
91
-
92
- /** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
93
- lineAmountIncludeTax = format2(chain(bignumber(lineAmountExcludeTax))
94
- .multiply(chain(bignumber(1)).add(taxRate).done())
95
- .done().toNumber()) as number
96
- }
97
-
98
- /** 税额 */
99
- const taxAmount = chain(bignumber(lineAmountIncludeTax))
100
- .subtract(bignumber(lineAmountExcludeTax))
101
- .done()
102
- .toNumber();
103
-
104
-
105
- good.discountGroup = discountGroup;
106
- good.lineAttribute = LineAttributeType.被折扣行;
107
- goodsList.splice(i + 1, 0, {
108
- $index: idGenerator(),
109
- lineAttribute: LineAttributeType.折扣行,
110
- taxClassificationCode: good.taxClassificationCode,
111
- taxRate: good.taxRate,
112
- itemName: good.itemName,
113
- itemNameSelf: good.itemNameSelf,
114
- favouredPolicyMark: good.favouredPolicyMark,
115
- favouredPolicyName: good.favouredPolicyName,
116
- taxFreeType: good.taxFreeType,
117
- discountGroup,
118
- lineAmountIncludeTax,
119
- lineAmountExcludeTax,
120
- taxAmount,
121
- });
122
- }
123
-
124
- state.goodsListState.goodsList = goodsList.slice();
125
- };
1
+ /**
2
+ *
3
+ * 折扣率 含税金额 不含税金额
4
+ *
5
+ * 含税折扣额 = -1 * (含税金额 * 折扣率)
6
+ * 不含税扣额 = 含税折扣额 / (1+税率)
7
+ * 折扣税额 = 含税折扣额 - 不含税扣额
8
+ */
9
+
10
+ import { v4 as uuidv4 } from 'uuid';
11
+ import { chain, bignumber } from 'mathjs';
12
+ import { InvoiceControllerState } from '../';
13
+ import LineAttributeType from '../InvoiceControllerState/GoodsListState/LineAttributeType';
14
+ import idGenerator from '../../tools/idGenerator';
15
+ import { format2 } from '../../../Invoice/tools/calculate';
16
+
17
+ export interface IOptions {
18
+ /** 需要添加的 索引列表 */
19
+ indexList: string[];
20
+
21
+ /** 折扣 */
22
+ discount: number;
23
+
24
+ /** 折扣 金额 */
25
+ discolineAmountunt: number;
26
+ }
27
+
28
+ /**
29
+ * 设置当前的编辑货物
30
+ */
31
+ export default async (state: InvoiceControllerState, options?: IOptions) => {
32
+ if (!options) return;
33
+
34
+ const { indexList = [] } = options;
35
+ const discount = chain(bignumber(options.discount || 0)).dotDivide(bignumber(100)).done();
36
+ const goodsMap = state.goodsListState.goodsMap;
37
+ const goodsList = state.goodsListState.goodsList;
38
+ const discountGroup = uuidv4();
39
+ let amountSum = bignumber(0);
40
+
41
+ for (let t = 0; t < indexList.length; t++) {
42
+ const $index = indexList[t];
43
+ const good = goodsMap.get($index);
44
+
45
+ if (!good || good.lineAttribute !== LineAttributeType.正常) continue;
46
+
47
+ const i = goodsList.indexOf(good);
48
+
49
+ let lineAmountIncludeTax = 0;
50
+ let lineAmountExcludeTax = 0;
51
+
52
+ const taxRate = chain(bignumber(good.taxRate)).dotDivide(bignumber(100)).done();
53
+ if (state.goodsListState.isTaxIncluded) {
54
+ /** 金额(含税) -1 * ${good.lineAmountIncludeTax} * ${discount}*/
55
+ lineAmountIncludeTax = (() => {
56
+ if (t === indexList.length - 1) {
57
+ return chain(bignumber(options.discolineAmountunt)).add(amountSum).multiply(-1).done().toNumber();
58
+ } else {
59
+ return chain(bignumber(-1))
60
+ .multiply(bignumber(good.lineAmountIncludeTax))
61
+ .multiply(discount)
62
+ .done()
63
+ .toNumber()
64
+ .toFixed(2);
65
+ }
66
+ })()
67
+ amountSum = amountSum.add(bignumber(lineAmountIncludeTax));
68
+
69
+ /** 金额(不含税) ${lineAmountIncludeTax} / (1+${good.taxRate}/100)*/
70
+ lineAmountExcludeTax = 1 * chain(bignumber(lineAmountIncludeTax))
71
+ .dotDivide(chain(bignumber(1)).add(taxRate).done())
72
+ .done()
73
+ .toNumber()
74
+ .toFixed(2)
75
+ } else {
76
+
77
+ /** 金额(不含税) -1 * ${good.lineAmountIncludeTax} * ${discount}*/
78
+ lineAmountExcludeTax = (() => {
79
+ if (t === indexList.length - 1) {
80
+ return chain(bignumber(options.discolineAmountunt)).add(amountSum).multiply(-1).done().toNumber();
81
+ } else {
82
+ return chain(bignumber(-1))
83
+ .multiply(bignumber(good.lineAmountExcludeTax))
84
+ .multiply(discount)
85
+ .done()
86
+ .toNumber()
87
+ .toFixed(2);
88
+ }
89
+ })()
90
+ amountSum = amountSum.add(bignumber(lineAmountExcludeTax));
91
+
92
+ /** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
93
+ lineAmountIncludeTax = format2(chain(bignumber(lineAmountExcludeTax))
94
+ .multiply(chain(bignumber(1)).add(taxRate).done())
95
+ .done().toNumber()) as number
96
+ }
97
+
98
+ /** 税额 */
99
+ const taxAmount = chain(bignumber(lineAmountIncludeTax))
100
+ .subtract(bignumber(lineAmountExcludeTax))
101
+ .done()
102
+ .toNumber();
103
+
104
+
105
+ good.discountGroup = discountGroup;
106
+ good.lineAttribute = LineAttributeType.被折扣行;
107
+ goodsList.splice(i + 1, 0, {
108
+ $index: idGenerator(),
109
+ lineAttribute: LineAttributeType.折扣行,
110
+ taxClassificationCode: good.taxClassificationCode,
111
+ taxRate: good.taxRate,
112
+ itemName: good.itemName,
113
+ itemNameSelf: good.itemNameSelf,
114
+ favouredPolicyMark: good.favouredPolicyMark,
115
+ favouredPolicyName: good.favouredPolicyName,
116
+ taxFreeType: good.taxFreeType,
117
+ discountGroup,
118
+ lineAmountIncludeTax,
119
+ lineAmountExcludeTax,
120
+ taxAmount,
121
+ });
122
+ }
123
+
124
+ state.goodsListState.goodsList = goodsList.slice();
125
+ };
@@ -1,43 +1,43 @@
1
- import { InvoiceControllerState, IGood } from '../';
2
- import LineAttributeType from '../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
3
-
4
- /**
5
- * 设置当前的编辑货物
6
- */
7
- export default async (state: InvoiceControllerState, $index?: string) => {
8
- if (!$index) return;
9
-
10
- const goods = state.goodsListState.goodsList.filter( (e) => e.$index === $index)[0];
11
- if (!goods) return;
12
- if (
13
- state.goodsListState.editGood &&
14
- state.goodsListState.editGood.$index === $index
15
- ) {
16
- state.goodsListState.editGood = undefined;
17
- }
18
-
19
- if (goods.lineAttribute === LineAttributeType.正常) {
20
- state.goodsListState.selectedGoodIndex =
21
- state.goodsListState.selectedGoodIndex.filter((e) => e !== $index);
22
- state.goodsListState.goodsList = state.goodsListState.goodsList.filter(
23
- (e) => e.$index !== $index,
24
- );
25
- }
26
-
27
- if (goods.lineAttribute === LineAttributeType.折扣行) {
28
- state.goodsListState.goodsList = state.goodsListState.goodsList.filter(
29
- (e) => {
30
- if (e.discountGroup !== goods.discountGroup) return true;
31
- if (e.lineAttribute === LineAttributeType.折扣行) {
32
- state.goodsListState.selectedGoodIndex =
33
- state.goodsListState.selectedGoodIndex.filter((e) => e !== $index);
34
- return false;
35
- }
36
- if (e.lineAttribute === LineAttributeType.被折扣行) {
37
- e.lineAttribute = LineAttributeType.正常;
38
- return true;
39
- }
40
- },
41
- );
42
- }
43
- };
1
+ import { InvoiceControllerState, IGood } from '../';
2
+ import LineAttributeType from '../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
3
+
4
+ /**
5
+ * 设置当前的编辑货物
6
+ */
7
+ export default async (state: InvoiceControllerState, $index?: string) => {
8
+ if (!$index) return;
9
+
10
+ const goods = state.goodsListState.goodsList.filter( (e) => e.$index === $index)[0];
11
+ if (!goods) return;
12
+ if (
13
+ state.goodsListState.editGood &&
14
+ state.goodsListState.editGood.$index === $index
15
+ ) {
16
+ state.goodsListState.editGood = undefined;
17
+ }
18
+
19
+ if (goods.lineAttribute === LineAttributeType.正常) {
20
+ state.goodsListState.selectedGoodIndex =
21
+ state.goodsListState.selectedGoodIndex.filter((e) => e !== $index);
22
+ state.goodsListState.goodsList = state.goodsListState.goodsList.filter(
23
+ (e) => e.$index !== $index,
24
+ );
25
+ }
26
+
27
+ if (goods.lineAttribute === LineAttributeType.折扣行) {
28
+ state.goodsListState.goodsList = state.goodsListState.goodsList.filter(
29
+ (e) => {
30
+ if (e.discountGroup !== goods.discountGroup) return true;
31
+ if (e.lineAttribute === LineAttributeType.折扣行) {
32
+ state.goodsListState.selectedGoodIndex =
33
+ state.goodsListState.selectedGoodIndex.filter((e) => e !== $index);
34
+ return false;
35
+ }
36
+ if (e.lineAttribute === LineAttributeType.被折扣行) {
37
+ e.lineAttribute = LineAttributeType.正常;
38
+ return true;
39
+ }
40
+ },
41
+ );
42
+ }
43
+ };
@@ -1,24 +1,24 @@
1
-
2
- import IGood from "../InvoiceControllerState/GoodsListState/IGood";
3
-
4
- /**
5
- * 计算搜索商品
6
- * @param goodsList 被搜索列表
7
- * @param search 搜索条件
8
- * @param isTaxIncluded 是否含税
9
- * @returns
10
- */
11
- export default function getGoodsSearch(goodsList: IGood[], search: string, isTaxIncluded: boolean) {
12
- if (!search) return goodsList;
13
- return goodsList.filter(e => {
14
- if ((e.itemName?.indexOf(search) ?? -1) >= 0) {
15
- return true;
16
- } else if ((e.itemModelName?.indexOf(search) ?? -1) >= 0) {
17
- return true
18
- } else if (`${isTaxIncluded ? e.lineAmountIncludeTax?.toFixed(2) : e.lineAmountExcludeTax?.toFixed(2)}`.indexOf(search) >= 0) {
19
- return true
20
- } else {
21
- return false;
22
- }
23
- })
1
+
2
+ import IGood from "../InvoiceControllerState/GoodsListState/IGood";
3
+
4
+ /**
5
+ * 计算搜索商品
6
+ * @param goodsList 被搜索列表
7
+ * @param search 搜索条件
8
+ * @param isTaxIncluded 是否含税
9
+ * @returns
10
+ */
11
+ export default function getGoodsSearch(goodsList: IGood[], search: string, isTaxIncluded: boolean) {
12
+ if (!search) return goodsList;
13
+ return goodsList.filter(e => {
14
+ if ((e.itemName?.indexOf(search) ?? -1) >= 0) {
15
+ return true;
16
+ } else if ((e.itemModelName?.indexOf(search) ?? -1) >= 0) {
17
+ return true
18
+ } else if (`${isTaxIncluded ? e.lineAmountIncludeTax?.toFixed(2) : e.lineAmountExcludeTax?.toFixed(2)}`.indexOf(search) >= 0) {
19
+ return true
20
+ } else {
21
+ return false;
22
+ }
23
+ })
24
24
  }