kts-component-invoice-operate 3.2.256 → 3.2.258

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 (292) 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/.vscode/settings.json +13 -13
  8. package/BRANCH.md +4 -4
  9. package/README.md +12 -12
  10. package/dist/Invoice/Invoice-digtal/_test/realEstateSales/index.d.ts +4 -0
  11. package/dist/Invoice/index.d.ts +2 -0
  12. package/dist/Invoice/ui/digtal/RealEstateSales/index.d.ts +15 -0
  13. package/dist/Invoice/ui/digtal/Stakeholder/index.d.ts +2 -0
  14. package/dist/index.esm.js +397 -35
  15. package/dist/index.js +397 -35
  16. package/docs/index.md +5 -5
  17. package/docs-dist/404.html +33 -33
  18. package/docs-dist/index.html +33 -33
  19. package/docs-dist/static/arrowDown.22c7885c.svg +3 -0
  20. package/docs-dist/static/arrowDown.a1cbf0d8.svg +2 -2
  21. package/docs-dist/static/arrowUp.4c482054.svg +2 -2
  22. package/docs-dist/static/arrowUp.d707a3e4.svg +3 -0
  23. package/docs-dist/static/download.18f10f45.svg +1 -0
  24. package/docs-dist/static/fork.43eb4ffa.svg +12 -0
  25. package/docs-dist/static/fork.5431267d.svg +11 -11
  26. package/docs-dist/static/plus.0e60e9ea.svg +12 -0
  27. package/docs-dist/static/plus.384f41d9.svg +12 -0
  28. package/docs-dist/static/plus.44013ce3.svg +11 -11
  29. package/docs-dist/static/plus.4fd1af30.svg +11 -11
  30. package/docs-dist/static/upload.d7ea1893.svg +1 -0
  31. package/docs-dist/umi.css +18 -18
  32. package/index.html +12 -12
  33. package/package.json +62 -62
  34. package/src/Invoice/Invoice-digtal/_test/architecture/index.tsx +21 -21
  35. package/src/Invoice/Invoice-digtal/_test/disabled/index.tsx +40 -40
  36. package/src/Invoice/Invoice-digtal/_test/easiest/index.tsx +214 -214
  37. package/src/Invoice/Invoice-digtal/_test/freight/index.tsx +14592 -14580
  38. package/src/Invoice/Invoice-digtal/_test/header/index.tsx +84 -84
  39. package/src/Invoice/Invoice-digtal/_test/importGoods/index.tsx +1635 -1635
  40. package/src/Invoice/Invoice-digtal/_test/importStakeholder/index.tsx +18 -18
  41. package/src/Invoice/Invoice-digtal/_test/lineCredit/index.tsx +19 -19
  42. package/src/Invoice/Invoice-digtal/_test/pay/index.tsx +14644 -14644
  43. package/src/Invoice/Invoice-digtal/_test/prefab/index.tsx +150 -150
  44. package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +55 -55
  45. package/src/Invoice/Invoice-digtal/_test/realEstateInfo/index.tsx +83 -83
  46. package/src/Invoice/Invoice-digtal/_test/realEstateSales/index.tsx +77 -0
  47. package/src/Invoice/Invoice-digtal/_test/stakeholder/index.tsx +12 -12
  48. package/src/Invoice/Invoice-digtal/_test/typeSelection/index.tsx +29 -29
  49. package/src/Invoice/Invoice-digtal/index.md +46 -43
  50. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +117 -117
  51. package/src/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.ts +26 -26
  52. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +88 -88
  53. package/src/Invoice/InvoiceController/InvoiceControllerState/FreightListState/IColumnsReplenish/index.ts +10 -10
  54. package/src/Invoice/InvoiceController/InvoiceControllerState/FreightListState/IGood/index.ts +33 -33
  55. package/src/Invoice/InvoiceController/InvoiceControllerState/FreightListState/ImportGoods/index.ts +81 -81
  56. package/src/Invoice/InvoiceController/InvoiceControllerState/FreightListState/index.ts +39 -39
  57. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +15 -15
  58. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +104 -104
  59. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IColumnsReplenish/index.ts +10 -10
  60. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +93 -93
  61. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ImportGoods/index.ts +84 -84
  62. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +7 -7
  63. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +9 -9
  64. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +150 -150
  65. package/src/Invoice/InvoiceController/InvoiceControllerState/PayListState/IColumnsReplenish/index.ts +10 -10
  66. package/src/Invoice/InvoiceController/InvoiceControllerState/PayListState/IGood/index.ts +35 -35
  67. package/src/Invoice/InvoiceController/InvoiceControllerState/PayListState/ImportGoods/index.ts +81 -81
  68. package/src/Invoice/InvoiceController/InvoiceControllerState/PayListState/index.ts +39 -39
  69. package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +13 -13
  70. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +76 -76
  71. package/src/Invoice/InvoiceController/fns/addFreight.ts +11 -11
  72. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  73. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +126 -126
  74. package/src/Invoice/InvoiceController/fns/addGoodDiscountV2.ts +86 -86
  75. package/src/Invoice/InvoiceController/fns/addPay.ts +11 -11
  76. package/src/Invoice/InvoiceController/fns/delFreight.ts +38 -38
  77. package/src/Invoice/InvoiceController/fns/delGood.ts +41 -41
  78. package/src/Invoice/InvoiceController/fns/delPay.ts +38 -38
  79. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +26 -26
  80. package/src/Invoice/InvoiceController/fns/importGoodsDrawer.ts +86 -86
  81. package/src/Invoice/InvoiceController/fns/itemBlur.ts +47 -47
  82. package/src/Invoice/InvoiceController/fns/mergeDetails.ts +201 -201
  83. package/src/Invoice/InvoiceController/fns/mergeDiscount.ts +35 -35
  84. package/src/Invoice/InvoiceController/fns/saveEditFreight.ts +24 -24
  85. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +24 -24
  86. package/src/Invoice/InvoiceController/fns/saveEditPay.ts +23 -23
  87. package/src/Invoice/InvoiceController/fns/setEditFreight.ts +16 -16
  88. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  89. package/src/Invoice/InvoiceController/fns/setEditPay.ts +16 -16
  90. package/src/Invoice/InvoiceController/fns/setFreight.ts +10 -10
  91. package/src/Invoice/InvoiceController/fns/setGoods.ts +10 -10
  92. package/src/Invoice/InvoiceController/fns/setPay.ts +10 -10
  93. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  94. package/src/Invoice/InvoiceController/index.ts +127 -127
  95. package/src/Invoice/_test/buyerNameSearch/index.tsx +42 -42
  96. package/src/Invoice/_test/children/index.tsx +214 -214
  97. package/src/Invoice/_test/deduction/index.tsx +956 -956
  98. package/src/Invoice/_test/draft/index.tsx +40 -40
  99. package/src/Invoice/_test/easiest/index.tsx +5 -5
  100. package/src/Invoice/_test/endowCode/index.tsx +1158 -1158
  101. package/src/Invoice/_test/goodsMenuExpand/index.tsx +32 -32
  102. package/src/Invoice/_test/importBuyer/index.tsx +75 -75
  103. package/src/Invoice/_test/importGoods/index.tsx +1375 -1375
  104. package/src/Invoice/_test/invoiceType/index.tsx +59 -59
  105. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  106. package/src/Invoice/_test/replaceHead/index.tsx +22 -22
  107. package/src/Invoice/_test/retrieveData/index.tsx +22 -22
  108. package/src/Invoice/_test/seller/index.tsx +28 -28
  109. package/src/Invoice/_test/setDataSource/index.tsx +73 -73
  110. package/src/Invoice/_test/unit/index.tsx +19 -19
  111. package/src/Invoice/index.less +31 -31
  112. package/src/Invoice/index.md +56 -56
  113. package/src/Invoice/index.tsx +211 -207
  114. package/src/Invoice/tools/calculate/index.ts +144 -144
  115. package/src/Invoice/tools/coolingFn/index.ts +17 -17
  116. package/src/Invoice/tools/evaluate/index.ts +7 -7
  117. package/src/Invoice/tools/idGenerator/index.ts +2 -2
  118. package/src/Invoice/tools/itemName/index.ts +55 -55
  119. package/src/Invoice/tools/lazyFn/index.ts +19 -19
  120. package/src/Invoice/tools/mounting/index.ts +13 -13
  121. package/src/Invoice/tools/strringFn/index.ts +40 -40
  122. package/src/Invoice/tools/useToGenerateId/index.ts +12 -12
  123. package/src/Invoice/tools/utils/index.ts +1 -1
  124. package/src/Invoice/tools/utils/money/index.ts +20 -20
  125. package/src/Invoice/ui/default/AddComparisonDrawer/index.tsx +149 -149
  126. package/src/Invoice/ui/default/Buyer/index.less +219 -219
  127. package/src/Invoice/ui/default/Buyer/index.tsx +114 -114
  128. package/src/Invoice/ui/default/Buyer/ui/BuyerNameInput/index.tsx +166 -166
  129. package/src/Invoice/ui/default/Buyer/ui/ImportBuyerButton/index.tsx +21 -21
  130. package/src/Invoice/ui/default/EndowCodeDrawer/index.less +8 -8
  131. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +620 -620
  132. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +690 -690
  133. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +773 -773
  134. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  135. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +205 -205
  136. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/index.tsx +57 -57
  137. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.less +18 -18
  138. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.tsx +49 -49
  139. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +17 -17
  140. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +91 -91
  141. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  142. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  143. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +118 -118
  144. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/dist/index.js +32 -32
  145. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  146. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +25 -25
  147. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  148. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +99 -99
  149. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  150. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  151. package/src/Invoice/ui/default/GoodsList/hook/useDeduction/index.tsx +24 -24
  152. package/src/Invoice/ui/default/GoodsList/hook/useOnRow/index.tsx +52 -52
  153. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +120 -120
  154. package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +23 -23
  155. package/src/Invoice/ui/default/GoodsList/index.less +185 -185
  156. package/src/Invoice/ui/default/GoodsList/index.tsx +207 -207
  157. package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +72 -72
  158. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.less +21 -21
  159. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +244 -244
  160. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  161. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +69 -69
  162. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +65 -65
  163. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +91 -91
  164. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDiscount/index.tsx +36 -36
  165. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useSalesDiscount/index.tsx +109 -109
  166. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useSalesGifts/index.tsx +94 -94
  167. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/index.tsx +37 -37
  168. package/src/Invoice/ui/default/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  169. package/src/Invoice/ui/default/GoodsList/ui/Search/index.less +10 -10
  170. package/src/Invoice/ui/default/GoodsList/ui/Search/index.tsx +52 -52
  171. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.less +18 -18
  172. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.tsx +114 -114
  173. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.less +40 -40
  174. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +71 -71
  175. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.less +38 -38
  176. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.tsx +130 -130
  177. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.less +44 -44
  178. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  179. package/src/Invoice/ui/default/GoodsList/ui/TaxIncludedSwitch/index.tsx +31 -31
  180. package/src/Invoice/ui/default/ImportBuyerDrawer/index.tsx +75 -75
  181. package/src/Invoice/ui/default/ImportGoodsDrawer/index.tsx +207 -207
  182. package/src/Invoice/ui/default/InvoiceHeader/index.less +68 -68
  183. package/src/Invoice/ui/default/InvoiceHeader/index.tsx +246 -246
  184. package/src/Invoice/ui/default/MeiTanModal/index.less +39 -39
  185. package/src/Invoice/ui/default/MeiTanModal/index.tsx +165 -165
  186. package/src/Invoice/ui/default/Seller/index.less +113 -113
  187. package/src/Invoice/ui/default/Seller/index.tsx +98 -98
  188. package/src/Invoice/ui/default/Sign/index.less +14 -14
  189. package/src/Invoice/ui/default/Sign/index.tsx +71 -71
  190. package/src/Invoice/ui/digtal/Architecture/index.less +22 -22
  191. package/src/Invoice/ui/digtal/Architecture/index.tsx +227 -227
  192. package/src/Invoice/ui/digtal/FreightList/hook/useColumns/dist/index.js +616 -616
  193. package/src/Invoice/ui/digtal/FreightList/hook/useColumns/index.tsx +246 -246
  194. package/src/Invoice/ui/digtal/FreightList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  195. package/src/Invoice/ui/digtal/FreightList/hook/useOnRow/index.tsx +37 -37
  196. package/src/Invoice/ui/digtal/FreightList/hook/useRowSelection/index.tsx +119 -119
  197. package/src/Invoice/ui/digtal/FreightList/hook/useWindowClick/index.tsx +23 -23
  198. package/src/Invoice/ui/digtal/FreightList/index.less +72 -72
  199. package/src/Invoice/ui/digtal/FreightList/index.tsx +129 -129
  200. package/src/Invoice/ui/digtal/FreightList/ui/AddRowButton/index.tsx +74 -74
  201. package/src/Invoice/ui/digtal/FreightList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -50
  202. package/src/Invoice/ui/digtal/FreightList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +36 -36
  203. package/src/Invoice/ui/digtal/FreightList/ui/TableRow/index.less +28 -28
  204. package/src/Invoice/ui/digtal/FreightList/ui/TableRow/index.tsx +20 -20
  205. package/src/Invoice/ui/digtal/FreightList/ui/TableVirtual/index.less +38 -38
  206. package/src/Invoice/ui/digtal/FreightList/ui/TableVirtual/index.tsx +108 -108
  207. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +690 -690
  208. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/dist/index.js +616 -616
  209. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +720 -720
  210. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/svg/plus.svg +11 -11
  211. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  212. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.tsx +205 -205
  213. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  214. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +87 -87
  215. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  216. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  217. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  218. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  219. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  220. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  221. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  222. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  223. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  224. package/src/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.tsx +51 -51
  225. package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +121 -121
  226. package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +23 -23
  227. package/src/Invoice/ui/digtal/GoodsList/index.less +56 -56
  228. package/src/Invoice/ui/digtal/GoodsList/index.tsx +181 -181
  229. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +87 -87
  230. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +340 -340
  231. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/svg/add.svg +11 -11
  232. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  233. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -50
  234. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +37 -37
  235. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +82 -82
  236. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +57 -57
  237. package/src/Invoice/ui/digtal/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  238. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.less +11 -11
  239. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.tsx +60 -60
  240. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.less +53 -53
  241. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.tsx +100 -100
  242. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/svg/fork.svg +11 -11
  243. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.less +28 -28
  244. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +52 -52
  245. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.less +38 -38
  246. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.tsx +113 -113
  247. package/src/Invoice/ui/digtal/GoodsList/ui/TaxIncludedSwitch/index.tsx +34 -34
  248. package/src/Invoice/ui/digtal/InvoiceHeader/index.less +57 -57
  249. package/src/Invoice/ui/digtal/InvoiceHeader/index.tsx +77 -77
  250. package/src/Invoice/ui/digtal/PayList/hook/useColumns/dist/index.js +616 -616
  251. package/src/Invoice/ui/digtal/PayList/hook/useColumns/index.tsx +168 -168
  252. package/src/Invoice/ui/digtal/PayList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  253. package/src/Invoice/ui/digtal/PayList/hook/useOnRow/index.tsx +37 -37
  254. package/src/Invoice/ui/digtal/PayList/hook/useRowSelection/index.tsx +119 -119
  255. package/src/Invoice/ui/digtal/PayList/hook/useWindowClick/index.tsx +19 -19
  256. package/src/Invoice/ui/digtal/PayList/index.less +72 -72
  257. package/src/Invoice/ui/digtal/PayList/index.tsx +132 -132
  258. package/src/Invoice/ui/digtal/PayList/ui/AddRowButton/index.tsx +74 -74
  259. package/src/Invoice/ui/digtal/PayList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -50
  260. package/src/Invoice/ui/digtal/PayList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +36 -36
  261. package/src/Invoice/ui/digtal/PayList/ui/TableRow/index.less +28 -28
  262. package/src/Invoice/ui/digtal/PayList/ui/TableRow/index.tsx +20 -20
  263. package/src/Invoice/ui/digtal/PayList/ui/TableVirtual/index.less +38 -38
  264. package/src/Invoice/ui/digtal/PayList/ui/TableVirtual/index.tsx +108 -108
  265. package/src/Invoice/ui/digtal/RealEstateInfo/index.less +21 -21
  266. package/src/Invoice/ui/digtal/RealEstateInfo/index.tsx +451 -451
  267. package/src/Invoice/ui/digtal/RealEstateSales/index.less +22 -0
  268. package/src/Invoice/ui/digtal/RealEstateSales/index.tsx +301 -0
  269. package/src/Invoice/ui/digtal/Sign/index.less +48 -48
  270. package/src/Invoice/ui/digtal/Sign/index.tsx +99 -99
  271. package/src/Invoice/ui/digtal/StakeFarmerholder/index.less +99 -99
  272. package/src/Invoice/ui/digtal/StakeFarmerholder/index.tsx +1102 -1102
  273. package/src/Invoice/ui/digtal/StakeFarmerholder/svg/arrowDown.svg +2 -2
  274. package/src/Invoice/ui/digtal/StakeFarmerholder/svg/arrowUp.svg +2 -2
  275. package/src/Invoice/ui/digtal/StakeFarmerholder/svg/plus.svg +11 -11
  276. package/src/Invoice/ui/digtal/Stakeholder/index.less +99 -99
  277. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +458 -453
  278. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowDown.svg +2 -2
  279. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowUp.svg +2 -2
  280. package/src/Invoice/ui/digtal/Stakeholder/svg/plus.svg +11 -11
  281. package/src/InvoiceTypeModal/_test/easiest/index.tsx +31 -31
  282. package/src/InvoiceTypeModal/dist/index.js +92 -92
  283. package/src/InvoiceTypeModal/index.less +7 -7
  284. package/src/InvoiceTypeModal/index.md +5 -5
  285. package/src/InvoiceTypeModal/index.tsx +161 -161
  286. package/src/TaxClassificationCodeModal/_test/easiest/index.tsx +184 -184
  287. package/src/TaxClassificationCodeModal/index.less +17 -17
  288. package/src/TaxClassificationCodeModal/index.md +6 -6
  289. package/src/TaxClassificationCodeModal/index.tsx +152 -152
  290. package/src/index.ts +13 -13
  291. package/tsconfig.json +31 -31
  292. package/typings.d.ts +3 -3
@@ -1,690 +1,690 @@
1
- /**
2
- * 数量 保留15位数字
3
- * 单价 保留15位数字
4
- * 金额 小数点后 2位
5
- * 税额 小数点后 2位
6
- */
7
- import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
8
- import InvoiceController, { IGood, LineAttributeType } from '../../../../../../InvoiceController';
9
- import evaluate from '../../../../../../tools/evaluate';
10
- import { message } from 'kts-components-antd-x3'
11
- import { format2, format15, countTaxAmount, countAmountExcludeTax, countPrice } from '../../../../../../tools/calculate';
12
- import moment from 'moment';
13
- import { equal } from 'mathjs';
14
- import { chain, bignumber } from 'mathjs';
15
-
16
- export { format2, format15 } from '../../../../../../tools/calculate';
17
-
18
-
19
-
20
- /** 延迟函数 */
21
- const lazyFn = (fn: Function, delayed: number = 200) => {
22
- let timer: any;
23
- return (...par: any[]) => {
24
- clearTimeout(timer);
25
- timer = setTimeout(() => {
26
- timer = undefined;
27
- fn.apply(null, par);
28
- }, delayed);
29
- };
30
- };
31
-
32
- let promptErrV: any = {}
33
-
34
- /** 提示错误 */
35
- const promptErr = (err: any) => {
36
- if (!err) return false;
37
- if (err.errors[0].message === 'lineAmountIncludeTax need to revalidate') return true;
38
- if (err.errors[0].message === 'lineAmountExcludeTax need to revalidate') return true;
39
- if (err.errors[0].message === 'priceIncludeTax need to revalidate') return true;
40
- if (err.errors[0].message === 'priceExcludeTax need to revalidate') return true;
41
-
42
- if (new Date().getTime() - promptErrV.t > 2000 || err.errors[0].message !== promptErrV.m) {
43
- promptErrV.t = new Date().getTime();
44
- promptErrV.m = err.errors[0].message;
45
- message.error({ content: err.errors[0].message, duration: 2 });
46
- }
47
-
48
- return true;
49
- }
50
-
51
- /** 清除计算中启动字段 */
52
- export const clearCalculatingField = async (controller: InvoiceController) => controller.run(async s => s.calculatingField = '');
53
-
54
- /** 数量改变了 */
55
- export const onChangeQuantity = lazyFn(
56
- (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
57
- form.validateFields(async (err, values) => {
58
- err = err || {};
59
-
60
- if (!values.quantity && values.quantity !== 0) {
61
- await controller.setEditGood({ quantity: undefined });
62
- await clearCalculatingField(controller);
63
- return;
64
- }
65
- if (err.quantity) {
66
- await clearCalculatingField(controller);
67
- return
68
- };
69
-
70
- const calculatingDigits = controller.state.calculatingDigits;
71
- const quantity = format15(values.quantity, calculatingDigits);
72
- await controller.setEditGood({ quantity });
73
- form.setFieldsValue({ quantity });
74
-
75
- // 是否含税
76
- if (controller.state.goodsListState.isTaxIncluded) {
77
- // 含税
78
- if (!err.priceIncludeTax && values.priceIncludeTax) {
79
- // 可以找到 单价(含税)
80
- const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
81
- const lineAmountIncludeTax = format2(evaluate(`${priceIncludeTax} * ${quantity}`));
82
- form.setFieldsValue({ lineAmountIncludeTax });
83
- await controller.setEditGood({ lineAmountIncludeTax });
84
- } else if (!err.lineAmountIncludeTax && values.lineAmountIncludeTax) {
85
- // 可以找到 金额(含税)
86
- const lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
87
- const priceIncludeTax = format15(
88
- evaluate(`${lineAmountIncludeTax} / ${quantity}`),
89
- calculatingDigits);
90
- form.setFieldsValue({ priceIncludeTax });
91
- await controller.setEditGood({ priceIncludeTax });
92
- }
93
-
94
- // 更新不含税
95
- await updateUnitPriceExcludingTax(controller, form, record);
96
- } else {
97
- // 不含税
98
- if (!err.priceExcludeTax && values.priceExcludeTax) {
99
- // 可以找到 单价(不含税)
100
- const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
101
- const lineAmountExcludeTax = format2(evaluate(`${quantity} * ${priceExcludeTax}`));
102
- form.setFieldsValue({ lineAmountExcludeTax });
103
- await controller.setEditGood({ lineAmountExcludeTax, quantity });
104
- } else if (!err.lineAmountExcludeTax && values.lineAmountExcludeTax) {
105
- // 可以找到 金额(不含税)
106
- const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
107
- const priceExcludeTax = format15(evaluate(`${lineAmountExcludeTax} / ${quantity}`), calculatingDigits);
108
- form.setFieldsValue({ priceExcludeTax });
109
- await controller.setEditGood({ priceExcludeTax, quantity });
110
- }
111
-
112
- // 更新含税
113
- await updateUnitPriceTax(controller, form, record);
114
- }
115
-
116
- // 清楚 计算中启动字段
117
- await clearCalculatingField(controller);
118
- });
119
- },
120
- 1000,
121
- );
122
-
123
- /** 单价(含税) */
124
- export const onChangePriceIncludeTax = lazyFn(
125
- (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
126
- form.validateFields(async (err, values) => {
127
- err = err || {};
128
-
129
- if (!values.priceIncludeTax && values.priceIncludeTax !== 0) {
130
- await controller.setEditGood({ priceIncludeTax: undefined, priceExcludeTax: undefined });
131
- await clearCalculatingField(controller);
132
- return;
133
- }
134
- if (err.priceIncludeTax) {
135
- await clearCalculatingField(controller);
136
- return;
137
- }
138
-
139
- const calculatingDigits = controller.state.calculatingDigits;
140
- const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
141
- await controller.setEditGood({ priceIncludeTax });
142
- form.setFieldsValue({ priceIncludeTax });
143
-
144
- // 是否有数量
145
- if (!err.quantity && values.quantity) {
146
- const quantity = format15(values.quantity, calculatingDigits);
147
- const lineAmountIncludeTax = format2(evaluate(`${quantity} * ${priceIncludeTax}`));
148
- form.setFieldsValue({ lineAmountIncludeTax });
149
- await controller.setEditGood({ lineAmountIncludeTax });
150
- } else if (!err.lineAmountIncludeTax && values.lineAmountIncludeTax) {
151
- const lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
152
- const quantity = format15(evaluate(`${lineAmountIncludeTax} / ${priceIncludeTax}`), calculatingDigits);
153
- form.setFieldsValue({ quantity });
154
- await controller.setEditGood({ quantity });
155
- }
156
-
157
- // 更新不含税
158
- await updateUnitPriceExcludingTax(controller, form, record);
159
-
160
- // 清楚 计算中启动字段
161
- await clearCalculatingField(controller);
162
- });
163
- },
164
- 1000,
165
- );
166
-
167
- /** 单价(不含税) */
168
- export const onChangePriceExcludeTax = lazyFn(
169
- (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
170
- form.validateFields(async (err, values) => {
171
- err = err || {};
172
-
173
- if (!values.priceExcludeTax && values.priceExcludeTax !== 0) {
174
- await controller.setEditGood({ priceIncludeTax: undefined, priceExcludeTax: undefined });
175
- await clearCalculatingField(controller);
176
- return;
177
- }
178
- if (err.priceExcludeTax) {
179
- await clearCalculatingField(controller);
180
- return;
181
- }
182
-
183
- const calculatingDigits = controller.state.calculatingDigits;
184
- const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
185
- await controller.setEditGood({ priceExcludeTax });
186
- form.setFieldsValue({ priceExcludeTax });
187
-
188
- // 是否有数量
189
- if (!err.quantity && values.quantity) {
190
- const quantity = format15(values.quantity, calculatingDigits);
191
- const lineAmountExcludeTax = format2(evaluate(`${quantity} * ${priceExcludeTax}`));
192
- form.setFieldsValue({ lineAmountExcludeTax });
193
- await controller.setEditGood({ lineAmountExcludeTax });
194
- } else if (!err.lineAmountExcludeTax && values.lineAmountExcludeTax) {
195
- const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
196
- const quantity = format15(
197
- evaluate(`${lineAmountExcludeTax} / ${priceExcludeTax}`),
198
- calculatingDigits
199
- );
200
- form.setFieldsValue({ quantity });
201
- await controller.setEditGood({ quantity });
202
- }
203
-
204
- // 更新含税
205
- await updateUnitPriceTax(controller, form, record);
206
-
207
- // 清楚 计算中启动字段
208
- await clearCalculatingField(controller);
209
- });
210
- },
211
- 1000,
212
- );
213
-
214
- /** 金额(含税) */
215
- export const onChangeLineAmountIncludeTax = lazyFn(
216
- (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
217
- form.validateFields(async (err, values) => {
218
-
219
- err = err || {};
220
- if (promptErr(err.lineAmountIncludeTax) || !values.lineAmountIncludeTax) {
221
- // 更新不含税
222
- await controller.setEditGood({ lineAmountIncludeTax: undefined, lineAmountExcludeTax: undefined });
223
- await updateUnitPriceExcludingTax(controller, form, record);
224
- await clearCalculatingField(controller);
225
- return;
226
- }
227
-
228
- const calculatingDigits = controller.state.calculatingDigits;
229
- const lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
230
- await controller.setEditGood({ lineAmountIncludeTax });
231
- form.setFieldsValue({ lineAmountIncludeTax });
232
-
233
- // 是否有数量
234
- if (!err.quantity && values.quantity) {
235
- const quantity = format15(values.quantity, calculatingDigits);
236
- const priceIncludeTax = format15(evaluate(`${lineAmountIncludeTax} / ${quantity}`), calculatingDigits);
237
- form.setFieldsValue({ priceIncludeTax });
238
- await controller.setEditGood({ priceIncludeTax });
239
- } else if (!err.priceIncludeTax && (values.priceIncludeTax || values.priceIncludeTax === 0)) {
240
- const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
241
- const quantity = format15(evaluate(`${lineAmountIncludeTax} / ${priceIncludeTax}`), calculatingDigits);
242
- form.setFieldsValue({ quantity });
243
- await controller.setEditGood({ quantity });
244
- }
245
-
246
- // 更新不含税
247
- await updateUnitPriceExcludingTax(controller, form, record);
248
-
249
- // 清楚 计算中启动字段
250
- await clearCalculatingField(controller);
251
- });
252
- },
253
- 1000,
254
- );
255
-
256
- /** 金额(不含税) */
257
- export const onChangeLineAmountExcludeTax = lazyFn(
258
- (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
259
- form.validateFields(async (err, values) => {
260
- err = err || {};
261
- if (promptErr(err.lineAmountExcludeTax) || !values.lineAmountExcludeTax) {
262
- // 更新含税
263
- await controller.setEditGood({ lineAmountIncludeTax: undefined, lineAmountExcludeTax: undefined });
264
- await updateUnitPriceTax(controller, form, record);
265
- await clearCalculatingField(controller);
266
- return;
267
- }
268
- const calculatingDigits = controller.state.calculatingDigits;
269
- const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
270
- await controller.setEditGood({ lineAmountExcludeTax });
271
- form.setFieldsValue({ lineAmountExcludeTax });
272
-
273
- // 是否有数量
274
- if (!err.quantity && values.quantity) {
275
- const quantity = format15(values.quantity, calculatingDigits);
276
- const priceExcludeTax = format15(evaluate(`${lineAmountExcludeTax} / ${quantity}`), calculatingDigits);
277
- form.setFieldsValue({ priceExcludeTax });
278
- await controller.setEditGood({ priceExcludeTax });
279
- } else if (!err.priceExcludeTax && values.priceExcludeTax) {
280
- const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
281
- const quantity = format15(evaluate(`${lineAmountExcludeTax} / ${priceExcludeTax}`), calculatingDigits);
282
- form.setFieldsValue({ quantity });
283
- await controller.setEditGood({ quantity });
284
- }
285
-
286
- // 更新含税
287
- await updateUnitPriceTax(controller, form, record);
288
-
289
- // 清楚 计算中启动字段
290
- await clearCalculatingField(controller);
291
- });
292
- },
293
- 1000,
294
- );
295
-
296
- /** 税率 */
297
- export const onChangeTaxRate = lazyFn(
298
- (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
299
-
300
- form.validateFields(async (err, values) => {
301
- err = err || {};
302
- if (promptErr(err.taxRate) || (!values.taxRate && values.taxRate !== 0)) return;
303
-
304
- let taxRate = parseFloat(values.taxRate);
305
- await controller.setEditGood({ taxRate });
306
-
307
- // 去掉赋码
308
- (() => {
309
- const cache = controller.state.goodsListState.endowCode.cache;
310
- const record = controller.state.goodsListState.editGood;
311
- if (record && cache[record.$index]) {
312
- record.favouredPolicyName = cache[record.$index].favouredPolicyName;
313
- record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
314
- record.taxFreeType = cache[record.$index].taxFreeType;
315
- cache[record.$index] = undefined;
316
- }
317
- })()
318
-
319
- switch (controller.state.goodsListState.calculateType) {
320
- case '1':
321
- await updateUnitPriceExcludingTax(controller, form, record);
322
- break;
323
-
324
- case '2':
325
- await updateUnitPriceTax(controller, form, record);
326
- break;
327
-
328
- case '3':
329
- default:
330
- // 是否含税
331
- if (controller.state.goodsListState.isTaxIncluded) {
332
- await updateUnitPriceExcludingTax(controller, form, record);
333
- } else {
334
- await updateUnitPriceTax(controller, form, record);
335
- }
336
- break;
337
- }
338
-
339
- // 清楚 计算中启动字段
340
- await clearCalculatingField(controller);
341
- });
342
- },
343
- 1000,
344
- );
345
-
346
- /** 税额 */
347
- export const onChangeTaxAmount = lazyFn(
348
- (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
349
-
350
- /** 金额(不含税) */
351
- let lineAmountExcludeTax;
352
-
353
- form.validateFields(async (err, values) => {
354
- err = err || {};
355
-
356
- const record = controller.state.goodsListState.editGood;
357
-
358
- // 校验是否有含税金额
359
- if (err.lineAmountIncludeTax && (!record?.lineAmountIncludeTax && record?.lineAmountIncludeTax !== 0)) {
360
- await clearCalculatingField(controller);
361
- return;
362
- }
363
-
364
- // 计数不含税金额
365
- // lineAmountExcludeTax = countAmountExcludeTax(record?.lineAmountIncludeTax || 0, values.taxAmount);
366
- // form.setFieldsValue({ lineAmountExcludeTax });
367
- // const priceExcludeTax: any = countPrice(lineAmountExcludeTax || '', record?.quantity || '', controller.state.calculatingDigits);
368
-
369
- // await controller.setEditGood({ lineAmountExcludeTax, taxAmount: values.taxAmount, priceExcludeTax });
370
- // form.setFieldsValue({ priceExcludeTax });
371
-
372
- // 计算含税金额
373
- const lineAmountIncludeTax = chain(bignumber(record?.lineAmountExcludeTax || 0)).add(bignumber(values.taxAmount || 0)).done().toNumber();
374
- form.setFieldsValue({ lineAmountIncludeTax });
375
-
376
- await controller.setEditGood({ taxAmount: values.taxAmount, lineAmountIncludeTax });
377
-
378
- // 清楚 计算中启动字段
379
- await clearCalculatingField(controller);
380
- })
381
- },
382
- 1000,
383
- )
384
-
385
- /** 小规模纳税人 1% 和 3% 自动赋码免税 */
386
- export function dutyFree(controller: InvoiceController, taxRate: number, form: WrappedFormUtils<any>, record: IGood) {
387
-
388
- const cache = controller.state.goodsListState.endowCode.cache;
389
- const invoiceType = controller.state.invoiceType;
390
-
391
- // 4月1日至12月31日
392
- console.log('===> 小规模纳税人免税逻辑');
393
- console.log('===> invoiceType', invoiceType);
394
- console.log('===> en', controller.state.en);
395
- console.log('===> taxRate', taxRate);
396
- console.log('===> state', controller.state);
397
-
398
- if (moment().valueOf() > moment('2022-12-31 23:59').valueOf()) return taxRate;
399
- if (controller.state.en !== '08') return taxRate;
400
- if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
401
-
402
- if (taxRate === 1 || taxRate === 3) {
403
- cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark, taxFreeType: record.taxFreeType }
404
- record.favouredPolicyName = '免税';
405
- record.taxRate = 0;
406
- record.favouredPolicyMark = 1;
407
- record.taxFreeType = 1 as any;
408
- form.setFieldsValue({ taxRate: 0 });
409
- return 0;
410
- }
411
- }
412
-
413
- /** 含税 => 更新(不含税) */
414
- export const updateUnitPriceExcludingTax = async (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
415
- return new Promise((resolve) => {
416
- form.validateFields(async (err, values) => {
417
- console.log('含税 => 更新(不含税')
418
-
419
- err = err || {};
420
-
421
- /** 税额 */
422
- let taxAmount;
423
-
424
- /** 金额(不含税) */
425
- let lineAmountExcludeTax;
426
-
427
- /** 不含税单价 */
428
- let priceExcludeTax;
429
-
430
- /** 扣除额 */
431
- const deduction = controller.state.goodsListState.deduction;
432
-
433
- const { editGood } = controller.state.goodsListState
434
-
435
- // 计算税额
436
- if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
437
- taxAmount = countTaxAmount(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, deduction, values.taxRate);
438
- }
439
- form.setFieldsValue({ taxAmount });
440
- await controller.setEditGood({ taxAmount });
441
-
442
- // 计算 金额(不含税)
443
- if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
444
- lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, taxAmount);
445
- }
446
- form.setFieldsValue({ lineAmountExcludeTax });
447
- await controller.setEditGood({ lineAmountExcludeTax });
448
-
449
- // 单价(不含税)
450
- if (lineAmountExcludeTax && !promptErr(err.quantity)) {
451
- priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || editGood?.quantity, controller.state.calculatingDigits);
452
- }
453
- form.setFieldsValue({ priceExcludeTax });
454
- await controller.setEditGood({ priceExcludeTax });
455
- });
456
-
457
- resolve(undefined)
458
- })
459
- };
460
-
461
- /** 不含税 => 更新(含税) */
462
- export const updateUnitPriceTax = async (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
463
- return new Promise((resolve) => {
464
- form.validateFields(async (err, values) => {
465
- console.log('不含税 => 更新(含税)')
466
-
467
- err = err || {};
468
-
469
- if (
470
- !err.taxRat &&
471
- (values.taxRate || values.taxRate === 0) &&
472
- !promptErr(err.lineAmountExcludeTax) &&
473
- (values.lineAmountExcludeTax || values.lineAmountExcludeTax === 0)
474
- ) {
475
-
476
- const calculatingDigits = controller.state.calculatingDigits;
477
- // 金额(含税)= 金额(不含税)* (1+ 税率)
478
- const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
479
- const lineAmountIncludeTax = format2(evaluate(`${lineAmountExcludeTax} * (1+(${values.taxRate}/100))`));
480
- await controller.setEditGood({ lineAmountIncludeTax });
481
-
482
- // 单价(含税) = 金额(含税) / (數量)
483
- // 是否有数量
484
- if (!err.quantity && values.quantity) {
485
- const priceIncludeTax = format15(evaluate(`${lineAmountIncludeTax} / ${values.quantity}`), calculatingDigits);
486
- await controller.setEditGood({ priceIncludeTax });
487
- }
488
-
489
- // 税额 = 金额(含税)-金额(不含税)
490
- // const taxAmount = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
491
- const taxAmount = format2(evaluate(`${lineAmountExcludeTax} * ${values.taxRate}/100`));
492
- form.setFieldsValue({ taxAmount });
493
- await controller.setEditGood({ taxAmount });
494
- } else {
495
- form.setFieldsValue({ taxAmount: undefined });
496
- await controller.setEditGood({ taxAmount: undefined });
497
- }
498
- // 单价(含税) = 单价(不含税) * (1+税率)
499
- // if (
500
- // !err.taxRat &&
501
- // (values.taxRate || values.taxRate === 0) &&
502
- // !promptErr(err.priceExcludeTax) &&
503
- // (values.priceExcludeTax || values.priceExcludeTax === 0)
504
- // ) {
505
- // const priceExcludeTax = format15(values.priceExcludeTax);
506
- // const priceIncludeTax = format15(evaluate(`${priceExcludeTax} * (1+(${values.taxRate}/100))`));
507
- // await controller.setEditGood({ priceIncludeTax });
508
- // }
509
-
510
- resolve(undefined)
511
- });
512
- })
513
- };
514
-
515
- /** 保存到编辑货物 */
516
- export const onSaveEditGood = lazyFn(
517
- (
518
- controller: InvoiceController,
519
- form: WrappedFormUtils,
520
- record: IGood,
521
- id: string,
522
- ) => {
523
- form.validateFields(async (err, values) => {
524
- err = err || {};
525
- if (err[id]) return;
526
-
527
- const v = {} as any;
528
- v[id] = values[id];
529
- await controller.setEditGood({ ...v });
530
- });
531
- },
532
- 1000,
533
- );
534
-
535
- /** 单调赋码 */
536
- export const endowCode = async (controller: InvoiceController, goods: IGood) => {
537
- await controller.wait();
538
- await controller.saveEditGood();
539
- await controller.pipeline(async (s) => {
540
- if (s.goodsListState.form && s.goodsListState.editGood?.$index === goods?.$index) {
541
- const err: any = s.goodsListState.form.getFieldsError();
542
- for (let key in err) {
543
- if (!err[key]) continue;
544
- message.error(err[key][0]);
545
- return;
546
- }
547
- }
548
-
549
- let g = s.goodsListState.goodsMap.get(goods.$index) as any;
550
- let i = s.goodsListState.goodsList.indexOf(g);
551
-
552
- switch (goods.lineAttribute) {
553
- case LineAttributeType.正常:
554
- s.goodsListState.endowCode.endowcodeGoodIndex = [goods.$index];
555
- break;
556
-
557
- case LineAttributeType.折扣行:
558
-
559
- s.goodsListState.endowCode.endowcodeGoodIndex = [goods.$index, s.goodsListState.goodsList[i - 1].$index];
560
- break;
561
-
562
- case LineAttributeType.被折扣行:
563
- s.goodsListState.endowCode.endowcodeGoodIndex = [goods.$index, s.goodsListState.goodsList[i + 1].$index];
564
- break;
565
- }
566
- })();
567
- }
568
-
569
- /** 修改了 项目名称 */
570
- export const onChangeItemName = async (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => {
571
- controller.run(async s => {
572
- const value = form.getFieldsValue().itemName;
573
-
574
- if (s.goodsListState.isMyShow) {
575
- await controller.setEditGood({ itemNameSelf: value });
576
- record.itemName && await controller.setEditGood({ itemName: record.itemName });
577
- } else {
578
- await controller.setEditGood({ itemName: value });
579
- record.itemNameSelf && await controller.setEditGood({ itemNameSelf: record.itemNameSelf });
580
- }
581
- })
582
- }
583
-
584
- /** 修改了含税开关 重新计算 */
585
- export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncluded: boolean) => {
586
- if (!controller.state.goodsListState.isRecalculateWhenSwitchTax) {
587
- controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded } })();
588
- return
589
- }
590
- const calculatingDigits = controller.state.calculatingDigits;
591
-
592
- await controller.saveEditGood();
593
- await controller.wait();
594
-
595
- await controller.run(async s => {
596
- if (s.goodsListState.editGood) {
597
- // message.error({
598
- // content: '你正在编辑一个货物',
599
- // key: '你正在编辑一个货物',
600
- // });
601
-
602
- // return;
603
- await controller.state.goodsListState.form?.validateFields(async (err: any, values: any) => {
604
- if (err) {
605
- const firstError: any = Object.values(err)[0];
606
- message.error({
607
- content: firstError.errors[0].message,
608
- key: '你正在编辑一个货物',
609
- });
610
- return;
611
- }
612
- });
613
- }
614
-
615
- s.goodsListState.isTaxIncluded = isTaxIncluded;
616
-
617
- try {
618
- let needRefresh = false;
619
-
620
- if (s.goodsListState?.goodsList && s.goodsListState.goodsList.length) {
621
- const newGoodsList = s.goodsListState.goodsList.map(good => {
622
- const {
623
- quantity: sourceQuantity,
624
- priceExcludeTax: sourcePriceExcludeTax,
625
- priceIncludeTax: sourcePriceIncludeTax,
626
- lineAmountExcludeTax: sourceLineAmountExcludeTax,
627
- lineAmountIncludeTax: sourceLineAmountIncludeTax,
628
- taxRate } = good;
629
- if (isTaxIncluded) {
630
- if (!sourceQuantity && sourceQuantity !== 0) return good;
631
- if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
632
- if (!taxRate && taxRate !== 0) return good;
633
- if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
634
- return good
635
- } else {
636
- needRefresh = true;
637
- }
638
- const quantity: any = format15(sourceQuantity, calculatingDigits);
639
- const priceIncludeTax: any = format15(sourcePriceIncludeTax, calculatingDigits);
640
-
641
- const lineAmountIncludeTax: any = format2(evaluate(`${priceIncludeTax} * ${quantity}`));
642
- const taxAmount: any = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate as any);
643
- const lineAmountExcludeTax: any = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
644
- const priceExcludeTax: any = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
645
-
646
- return {
647
- ...good,
648
- lineAmountExcludeTax,
649
- lineAmountIncludeTax,
650
- taxAmount,
651
- priceExcludeTax
652
- }
653
-
654
- } else {
655
- if (!sourceQuantity && sourceQuantity !== 0) return good;
656
- if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
657
- if (!taxRate && taxRate !== 0) return good;
658
- if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
659
- return good
660
- } else {
661
- needRefresh = true;
662
- }
663
- const quantity: any = format15(sourceQuantity, calculatingDigits);
664
- const priceExcludeTax: any = format15(sourcePriceExcludeTax, calculatingDigits);
665
-
666
- const lineAmountExcludeTax: any = format2(evaluate(`${priceExcludeTax} * ${quantity}`));
667
- const lineAmountIncludeTax: any = format2(evaluate(`${lineAmountExcludeTax} * (1+(${taxRate}/100))`));
668
- const priceIncludeTax: any = format15(evaluate(`${lineAmountIncludeTax} / ${quantity}`), calculatingDigits);
669
- const taxAmount: any = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
670
-
671
- return {
672
- ...good,
673
- lineAmountExcludeTax,
674
- lineAmountIncludeTax,
675
- taxAmount,
676
- priceIncludeTax
677
- }
678
- }
679
-
680
- })
681
-
682
- if (needRefresh) {
683
- s.goodsListState.goodsList = newGoodsList;
684
- }
685
- }
686
- } catch (e) {
687
- console.error('切换税率重新计算出错', e, s.goodsListState)
688
- }
689
- })
690
- }
1
+ /**
2
+ * 数量 保留15位数字
3
+ * 单价 保留15位数字
4
+ * 金额 小数点后 2位
5
+ * 税额 小数点后 2位
6
+ */
7
+ import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
8
+ import InvoiceController, { IGood, LineAttributeType } from '../../../../../../InvoiceController';
9
+ import evaluate from '../../../../../../tools/evaluate';
10
+ import { message } from 'kts-components-antd-x3'
11
+ import { format2, format15, countTaxAmount, countAmountExcludeTax, countPrice } from '../../../../../../tools/calculate';
12
+ import moment from 'moment';
13
+ import { equal } from 'mathjs';
14
+ import { chain, bignumber } from 'mathjs';
15
+
16
+ export { format2, format15 } from '../../../../../../tools/calculate';
17
+
18
+
19
+
20
+ /** 延迟函数 */
21
+ const lazyFn = (fn: Function, delayed: number = 200) => {
22
+ let timer: any;
23
+ return (...par: any[]) => {
24
+ clearTimeout(timer);
25
+ timer = setTimeout(() => {
26
+ timer = undefined;
27
+ fn.apply(null, par);
28
+ }, delayed);
29
+ };
30
+ };
31
+
32
+ let promptErrV: any = {}
33
+
34
+ /** 提示错误 */
35
+ const promptErr = (err: any) => {
36
+ if (!err) return false;
37
+ if (err.errors[0].message === 'lineAmountIncludeTax need to revalidate') return true;
38
+ if (err.errors[0].message === 'lineAmountExcludeTax need to revalidate') return true;
39
+ if (err.errors[0].message === 'priceIncludeTax need to revalidate') return true;
40
+ if (err.errors[0].message === 'priceExcludeTax need to revalidate') return true;
41
+
42
+ if (new Date().getTime() - promptErrV.t > 2000 || err.errors[0].message !== promptErrV.m) {
43
+ promptErrV.t = new Date().getTime();
44
+ promptErrV.m = err.errors[0].message;
45
+ message.error({ content: err.errors[0].message, duration: 2 });
46
+ }
47
+
48
+ return true;
49
+ }
50
+
51
+ /** 清除计算中启动字段 */
52
+ export const clearCalculatingField = async (controller: InvoiceController) => controller.run(async s => s.calculatingField = '');
53
+
54
+ /** 数量改变了 */
55
+ export const onChangeQuantity = lazyFn(
56
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
57
+ form.validateFields(async (err, values) => {
58
+ err = err || {};
59
+
60
+ if (!values.quantity && values.quantity !== 0) {
61
+ await controller.setEditGood({ quantity: undefined });
62
+ await clearCalculatingField(controller);
63
+ return;
64
+ }
65
+ if (err.quantity) {
66
+ await clearCalculatingField(controller);
67
+ return
68
+ };
69
+
70
+ const calculatingDigits = controller.state.calculatingDigits;
71
+ const quantity = format15(values.quantity, calculatingDigits);
72
+ await controller.setEditGood({ quantity });
73
+ form.setFieldsValue({ quantity });
74
+
75
+ // 是否含税
76
+ if (controller.state.goodsListState.isTaxIncluded) {
77
+ // 含税
78
+ if (!err.priceIncludeTax && values.priceIncludeTax) {
79
+ // 可以找到 单价(含税)
80
+ const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
81
+ const lineAmountIncludeTax = format2(evaluate(`${priceIncludeTax} * ${quantity}`));
82
+ form.setFieldsValue({ lineAmountIncludeTax });
83
+ await controller.setEditGood({ lineAmountIncludeTax });
84
+ } else if (!err.lineAmountIncludeTax && values.lineAmountIncludeTax) {
85
+ // 可以找到 金额(含税)
86
+ const lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
87
+ const priceIncludeTax = format15(
88
+ evaluate(`${lineAmountIncludeTax} / ${quantity}`),
89
+ calculatingDigits);
90
+ form.setFieldsValue({ priceIncludeTax });
91
+ await controller.setEditGood({ priceIncludeTax });
92
+ }
93
+
94
+ // 更新不含税
95
+ await updateUnitPriceExcludingTax(controller, form, record);
96
+ } else {
97
+ // 不含税
98
+ if (!err.priceExcludeTax && values.priceExcludeTax) {
99
+ // 可以找到 单价(不含税)
100
+ const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
101
+ const lineAmountExcludeTax = format2(evaluate(`${quantity} * ${priceExcludeTax}`));
102
+ form.setFieldsValue({ lineAmountExcludeTax });
103
+ await controller.setEditGood({ lineAmountExcludeTax, quantity });
104
+ } else if (!err.lineAmountExcludeTax && values.lineAmountExcludeTax) {
105
+ // 可以找到 金额(不含税)
106
+ const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
107
+ const priceExcludeTax = format15(evaluate(`${lineAmountExcludeTax} / ${quantity}`), calculatingDigits);
108
+ form.setFieldsValue({ priceExcludeTax });
109
+ await controller.setEditGood({ priceExcludeTax, quantity });
110
+ }
111
+
112
+ // 更新含税
113
+ await updateUnitPriceTax(controller, form, record);
114
+ }
115
+
116
+ // 清楚 计算中启动字段
117
+ await clearCalculatingField(controller);
118
+ });
119
+ },
120
+ 1000,
121
+ );
122
+
123
+ /** 单价(含税) */
124
+ export const onChangePriceIncludeTax = lazyFn(
125
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
126
+ form.validateFields(async (err, values) => {
127
+ err = err || {};
128
+
129
+ if (!values.priceIncludeTax && values.priceIncludeTax !== 0) {
130
+ await controller.setEditGood({ priceIncludeTax: undefined, priceExcludeTax: undefined });
131
+ await clearCalculatingField(controller);
132
+ return;
133
+ }
134
+ if (err.priceIncludeTax) {
135
+ await clearCalculatingField(controller);
136
+ return;
137
+ }
138
+
139
+ const calculatingDigits = controller.state.calculatingDigits;
140
+ const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
141
+ await controller.setEditGood({ priceIncludeTax });
142
+ form.setFieldsValue({ priceIncludeTax });
143
+
144
+ // 是否有数量
145
+ if (!err.quantity && values.quantity) {
146
+ const quantity = format15(values.quantity, calculatingDigits);
147
+ const lineAmountIncludeTax = format2(evaluate(`${quantity} * ${priceIncludeTax}`));
148
+ form.setFieldsValue({ lineAmountIncludeTax });
149
+ await controller.setEditGood({ lineAmountIncludeTax });
150
+ } else if (!err.lineAmountIncludeTax && values.lineAmountIncludeTax) {
151
+ const lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
152
+ const quantity = format15(evaluate(`${lineAmountIncludeTax} / ${priceIncludeTax}`), calculatingDigits);
153
+ form.setFieldsValue({ quantity });
154
+ await controller.setEditGood({ quantity });
155
+ }
156
+
157
+ // 更新不含税
158
+ await updateUnitPriceExcludingTax(controller, form, record);
159
+
160
+ // 清楚 计算中启动字段
161
+ await clearCalculatingField(controller);
162
+ });
163
+ },
164
+ 1000,
165
+ );
166
+
167
+ /** 单价(不含税) */
168
+ export const onChangePriceExcludeTax = lazyFn(
169
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
170
+ form.validateFields(async (err, values) => {
171
+ err = err || {};
172
+
173
+ if (!values.priceExcludeTax && values.priceExcludeTax !== 0) {
174
+ await controller.setEditGood({ priceIncludeTax: undefined, priceExcludeTax: undefined });
175
+ await clearCalculatingField(controller);
176
+ return;
177
+ }
178
+ if (err.priceExcludeTax) {
179
+ await clearCalculatingField(controller);
180
+ return;
181
+ }
182
+
183
+ const calculatingDigits = controller.state.calculatingDigits;
184
+ const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
185
+ await controller.setEditGood({ priceExcludeTax });
186
+ form.setFieldsValue({ priceExcludeTax });
187
+
188
+ // 是否有数量
189
+ if (!err.quantity && values.quantity) {
190
+ const quantity = format15(values.quantity, calculatingDigits);
191
+ const lineAmountExcludeTax = format2(evaluate(`${quantity} * ${priceExcludeTax}`));
192
+ form.setFieldsValue({ lineAmountExcludeTax });
193
+ await controller.setEditGood({ lineAmountExcludeTax });
194
+ } else if (!err.lineAmountExcludeTax && values.lineAmountExcludeTax) {
195
+ const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
196
+ const quantity = format15(
197
+ evaluate(`${lineAmountExcludeTax} / ${priceExcludeTax}`),
198
+ calculatingDigits
199
+ );
200
+ form.setFieldsValue({ quantity });
201
+ await controller.setEditGood({ quantity });
202
+ }
203
+
204
+ // 更新含税
205
+ await updateUnitPriceTax(controller, form, record);
206
+
207
+ // 清楚 计算中启动字段
208
+ await clearCalculatingField(controller);
209
+ });
210
+ },
211
+ 1000,
212
+ );
213
+
214
+ /** 金额(含税) */
215
+ export const onChangeLineAmountIncludeTax = lazyFn(
216
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
217
+ form.validateFields(async (err, values) => {
218
+
219
+ err = err || {};
220
+ if (promptErr(err.lineAmountIncludeTax) || !values.lineAmountIncludeTax) {
221
+ // 更新不含税
222
+ await controller.setEditGood({ lineAmountIncludeTax: undefined, lineAmountExcludeTax: undefined });
223
+ await updateUnitPriceExcludingTax(controller, form, record);
224
+ await clearCalculatingField(controller);
225
+ return;
226
+ }
227
+
228
+ const calculatingDigits = controller.state.calculatingDigits;
229
+ const lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
230
+ await controller.setEditGood({ lineAmountIncludeTax });
231
+ form.setFieldsValue({ lineAmountIncludeTax });
232
+
233
+ // 是否有数量
234
+ if (!err.quantity && values.quantity) {
235
+ const quantity = format15(values.quantity, calculatingDigits);
236
+ const priceIncludeTax = format15(evaluate(`${lineAmountIncludeTax} / ${quantity}`), calculatingDigits);
237
+ form.setFieldsValue({ priceIncludeTax });
238
+ await controller.setEditGood({ priceIncludeTax });
239
+ } else if (!err.priceIncludeTax && (values.priceIncludeTax || values.priceIncludeTax === 0)) {
240
+ const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
241
+ const quantity = format15(evaluate(`${lineAmountIncludeTax} / ${priceIncludeTax}`), calculatingDigits);
242
+ form.setFieldsValue({ quantity });
243
+ await controller.setEditGood({ quantity });
244
+ }
245
+
246
+ // 更新不含税
247
+ await updateUnitPriceExcludingTax(controller, form, record);
248
+
249
+ // 清楚 计算中启动字段
250
+ await clearCalculatingField(controller);
251
+ });
252
+ },
253
+ 1000,
254
+ );
255
+
256
+ /** 金额(不含税) */
257
+ export const onChangeLineAmountExcludeTax = lazyFn(
258
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
259
+ form.validateFields(async (err, values) => {
260
+ err = err || {};
261
+ if (promptErr(err.lineAmountExcludeTax) || !values.lineAmountExcludeTax) {
262
+ // 更新含税
263
+ await controller.setEditGood({ lineAmountIncludeTax: undefined, lineAmountExcludeTax: undefined });
264
+ await updateUnitPriceTax(controller, form, record);
265
+ await clearCalculatingField(controller);
266
+ return;
267
+ }
268
+ const calculatingDigits = controller.state.calculatingDigits;
269
+ const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
270
+ await controller.setEditGood({ lineAmountExcludeTax });
271
+ form.setFieldsValue({ lineAmountExcludeTax });
272
+
273
+ // 是否有数量
274
+ if (!err.quantity && values.quantity) {
275
+ const quantity = format15(values.quantity, calculatingDigits);
276
+ const priceExcludeTax = format15(evaluate(`${lineAmountExcludeTax} / ${quantity}`), calculatingDigits);
277
+ form.setFieldsValue({ priceExcludeTax });
278
+ await controller.setEditGood({ priceExcludeTax });
279
+ } else if (!err.priceExcludeTax && values.priceExcludeTax) {
280
+ const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
281
+ const quantity = format15(evaluate(`${lineAmountExcludeTax} / ${priceExcludeTax}`), calculatingDigits);
282
+ form.setFieldsValue({ quantity });
283
+ await controller.setEditGood({ quantity });
284
+ }
285
+
286
+ // 更新含税
287
+ await updateUnitPriceTax(controller, form, record);
288
+
289
+ // 清楚 计算中启动字段
290
+ await clearCalculatingField(controller);
291
+ });
292
+ },
293
+ 1000,
294
+ );
295
+
296
+ /** 税率 */
297
+ export const onChangeTaxRate = lazyFn(
298
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
299
+
300
+ form.validateFields(async (err, values) => {
301
+ err = err || {};
302
+ if (promptErr(err.taxRate) || (!values.taxRate && values.taxRate !== 0)) return;
303
+
304
+ let taxRate = parseFloat(values.taxRate);
305
+ await controller.setEditGood({ taxRate });
306
+
307
+ // 去掉赋码
308
+ (() => {
309
+ const cache = controller.state.goodsListState.endowCode.cache;
310
+ const record = controller.state.goodsListState.editGood;
311
+ if (record && cache[record.$index]) {
312
+ record.favouredPolicyName = cache[record.$index].favouredPolicyName;
313
+ record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
314
+ record.taxFreeType = cache[record.$index].taxFreeType;
315
+ cache[record.$index] = undefined;
316
+ }
317
+ })()
318
+
319
+ switch (controller.state.goodsListState.calculateType) {
320
+ case '1':
321
+ await updateUnitPriceExcludingTax(controller, form, record);
322
+ break;
323
+
324
+ case '2':
325
+ await updateUnitPriceTax(controller, form, record);
326
+ break;
327
+
328
+ case '3':
329
+ default:
330
+ // 是否含税
331
+ if (controller.state.goodsListState.isTaxIncluded) {
332
+ await updateUnitPriceExcludingTax(controller, form, record);
333
+ } else {
334
+ await updateUnitPriceTax(controller, form, record);
335
+ }
336
+ break;
337
+ }
338
+
339
+ // 清楚 计算中启动字段
340
+ await clearCalculatingField(controller);
341
+ });
342
+ },
343
+ 1000,
344
+ );
345
+
346
+ /** 税额 */
347
+ export const onChangeTaxAmount = lazyFn(
348
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
349
+
350
+ /** 金额(不含税) */
351
+ let lineAmountExcludeTax;
352
+
353
+ form.validateFields(async (err, values) => {
354
+ err = err || {};
355
+
356
+ const record = controller.state.goodsListState.editGood;
357
+
358
+ // 校验是否有含税金额
359
+ if (err.lineAmountIncludeTax && (!record?.lineAmountIncludeTax && record?.lineAmountIncludeTax !== 0)) {
360
+ await clearCalculatingField(controller);
361
+ return;
362
+ }
363
+
364
+ // 计数不含税金额
365
+ // lineAmountExcludeTax = countAmountExcludeTax(record?.lineAmountIncludeTax || 0, values.taxAmount);
366
+ // form.setFieldsValue({ lineAmountExcludeTax });
367
+ // const priceExcludeTax: any = countPrice(lineAmountExcludeTax || '', record?.quantity || '', controller.state.calculatingDigits);
368
+
369
+ // await controller.setEditGood({ lineAmountExcludeTax, taxAmount: values.taxAmount, priceExcludeTax });
370
+ // form.setFieldsValue({ priceExcludeTax });
371
+
372
+ // 计算含税金额
373
+ const lineAmountIncludeTax = chain(bignumber(record?.lineAmountExcludeTax || 0)).add(bignumber(values.taxAmount || 0)).done().toNumber();
374
+ form.setFieldsValue({ lineAmountIncludeTax });
375
+
376
+ await controller.setEditGood({ taxAmount: values.taxAmount, lineAmountIncludeTax });
377
+
378
+ // 清楚 计算中启动字段
379
+ await clearCalculatingField(controller);
380
+ })
381
+ },
382
+ 1000,
383
+ )
384
+
385
+ /** 小规模纳税人 1% 和 3% 自动赋码免税 */
386
+ export function dutyFree(controller: InvoiceController, taxRate: number, form: WrappedFormUtils<any>, record: IGood) {
387
+
388
+ const cache = controller.state.goodsListState.endowCode.cache;
389
+ const invoiceType = controller.state.invoiceType;
390
+
391
+ // 4月1日至12月31日
392
+ console.log('===> 小规模纳税人免税逻辑');
393
+ console.log('===> invoiceType', invoiceType);
394
+ console.log('===> en', controller.state.en);
395
+ console.log('===> taxRate', taxRate);
396
+ console.log('===> state', controller.state);
397
+
398
+ if (moment().valueOf() > moment('2022-12-31 23:59').valueOf()) return taxRate;
399
+ if (controller.state.en !== '08') return taxRate;
400
+ if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
401
+
402
+ if (taxRate === 1 || taxRate === 3) {
403
+ cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark, taxFreeType: record.taxFreeType }
404
+ record.favouredPolicyName = '免税';
405
+ record.taxRate = 0;
406
+ record.favouredPolicyMark = 1;
407
+ record.taxFreeType = 1 as any;
408
+ form.setFieldsValue({ taxRate: 0 });
409
+ return 0;
410
+ }
411
+ }
412
+
413
+ /** 含税 => 更新(不含税) */
414
+ export const updateUnitPriceExcludingTax = async (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
415
+ return new Promise((resolve) => {
416
+ form.validateFields(async (err, values) => {
417
+ console.log('含税 => 更新(不含税')
418
+
419
+ err = err || {};
420
+
421
+ /** 税额 */
422
+ let taxAmount;
423
+
424
+ /** 金额(不含税) */
425
+ let lineAmountExcludeTax;
426
+
427
+ /** 不含税单价 */
428
+ let priceExcludeTax;
429
+
430
+ /** 扣除额 */
431
+ const deduction = controller.state.goodsListState.deduction;
432
+
433
+ const { editGood } = controller.state.goodsListState
434
+
435
+ // 计算税额
436
+ if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
437
+ taxAmount = countTaxAmount(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, deduction, values.taxRate);
438
+ }
439
+ form.setFieldsValue({ taxAmount });
440
+ await controller.setEditGood({ taxAmount });
441
+
442
+ // 计算 金额(不含税)
443
+ if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
444
+ lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, taxAmount);
445
+ }
446
+ form.setFieldsValue({ lineAmountExcludeTax });
447
+ await controller.setEditGood({ lineAmountExcludeTax });
448
+
449
+ // 单价(不含税)
450
+ if (lineAmountExcludeTax && !promptErr(err.quantity)) {
451
+ priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || editGood?.quantity, controller.state.calculatingDigits);
452
+ }
453
+ form.setFieldsValue({ priceExcludeTax });
454
+ await controller.setEditGood({ priceExcludeTax });
455
+ });
456
+
457
+ resolve(undefined)
458
+ })
459
+ };
460
+
461
+ /** 不含税 => 更新(含税) */
462
+ export const updateUnitPriceTax = async (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
463
+ return new Promise((resolve) => {
464
+ form.validateFields(async (err, values) => {
465
+ console.log('不含税 => 更新(含税)')
466
+
467
+ err = err || {};
468
+
469
+ if (
470
+ !err.taxRat &&
471
+ (values.taxRate || values.taxRate === 0) &&
472
+ !promptErr(err.lineAmountExcludeTax) &&
473
+ (values.lineAmountExcludeTax || values.lineAmountExcludeTax === 0)
474
+ ) {
475
+
476
+ const calculatingDigits = controller.state.calculatingDigits;
477
+ // 金额(含税)= 金额(不含税)* (1+ 税率)
478
+ const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
479
+ const lineAmountIncludeTax = format2(evaluate(`${lineAmountExcludeTax} * (1+(${values.taxRate}/100))`));
480
+ await controller.setEditGood({ lineAmountIncludeTax });
481
+
482
+ // 单价(含税) = 金额(含税) / (數量)
483
+ // 是否有数量
484
+ if (!err.quantity && values.quantity) {
485
+ const priceIncludeTax = format15(evaluate(`${lineAmountIncludeTax} / ${values.quantity}`), calculatingDigits);
486
+ await controller.setEditGood({ priceIncludeTax });
487
+ }
488
+
489
+ // 税额 = 金额(含税)-金额(不含税)
490
+ // const taxAmount = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
491
+ const taxAmount = format2(evaluate(`${lineAmountExcludeTax} * ${values.taxRate}/100`));
492
+ form.setFieldsValue({ taxAmount });
493
+ await controller.setEditGood({ taxAmount });
494
+ } else {
495
+ form.setFieldsValue({ taxAmount: undefined });
496
+ await controller.setEditGood({ taxAmount: undefined });
497
+ }
498
+ // 单价(含税) = 单价(不含税) * (1+税率)
499
+ // if (
500
+ // !err.taxRat &&
501
+ // (values.taxRate || values.taxRate === 0) &&
502
+ // !promptErr(err.priceExcludeTax) &&
503
+ // (values.priceExcludeTax || values.priceExcludeTax === 0)
504
+ // ) {
505
+ // const priceExcludeTax = format15(values.priceExcludeTax);
506
+ // const priceIncludeTax = format15(evaluate(`${priceExcludeTax} * (1+(${values.taxRate}/100))`));
507
+ // await controller.setEditGood({ priceIncludeTax });
508
+ // }
509
+
510
+ resolve(undefined)
511
+ });
512
+ })
513
+ };
514
+
515
+ /** 保存到编辑货物 */
516
+ export const onSaveEditGood = lazyFn(
517
+ (
518
+ controller: InvoiceController,
519
+ form: WrappedFormUtils,
520
+ record: IGood,
521
+ id: string,
522
+ ) => {
523
+ form.validateFields(async (err, values) => {
524
+ err = err || {};
525
+ if (err[id]) return;
526
+
527
+ const v = {} as any;
528
+ v[id] = values[id];
529
+ await controller.setEditGood({ ...v });
530
+ });
531
+ },
532
+ 1000,
533
+ );
534
+
535
+ /** 单调赋码 */
536
+ export const endowCode = async (controller: InvoiceController, goods: IGood) => {
537
+ await controller.wait();
538
+ await controller.saveEditGood();
539
+ await controller.pipeline(async (s) => {
540
+ if (s.goodsListState.form && s.goodsListState.editGood?.$index === goods?.$index) {
541
+ const err: any = s.goodsListState.form.getFieldsError();
542
+ for (let key in err) {
543
+ if (!err[key]) continue;
544
+ message.error(err[key][0]);
545
+ return;
546
+ }
547
+ }
548
+
549
+ let g = s.goodsListState.goodsMap.get(goods.$index) as any;
550
+ let i = s.goodsListState.goodsList.indexOf(g);
551
+
552
+ switch (goods.lineAttribute) {
553
+ case LineAttributeType.正常:
554
+ s.goodsListState.endowCode.endowcodeGoodIndex = [goods.$index];
555
+ break;
556
+
557
+ case LineAttributeType.折扣行:
558
+
559
+ s.goodsListState.endowCode.endowcodeGoodIndex = [goods.$index, s.goodsListState.goodsList[i - 1].$index];
560
+ break;
561
+
562
+ case LineAttributeType.被折扣行:
563
+ s.goodsListState.endowCode.endowcodeGoodIndex = [goods.$index, s.goodsListState.goodsList[i + 1].$index];
564
+ break;
565
+ }
566
+ })();
567
+ }
568
+
569
+ /** 修改了 项目名称 */
570
+ export const onChangeItemName = async (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => {
571
+ controller.run(async s => {
572
+ const value = form.getFieldsValue().itemName;
573
+
574
+ if (s.goodsListState.isMyShow) {
575
+ await controller.setEditGood({ itemNameSelf: value });
576
+ record.itemName && await controller.setEditGood({ itemName: record.itemName });
577
+ } else {
578
+ await controller.setEditGood({ itemName: value });
579
+ record.itemNameSelf && await controller.setEditGood({ itemNameSelf: record.itemNameSelf });
580
+ }
581
+ })
582
+ }
583
+
584
+ /** 修改了含税开关 重新计算 */
585
+ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncluded: boolean) => {
586
+ if (!controller.state.goodsListState.isRecalculateWhenSwitchTax) {
587
+ controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded } })();
588
+ return
589
+ }
590
+ const calculatingDigits = controller.state.calculatingDigits;
591
+
592
+ await controller.saveEditGood();
593
+ await controller.wait();
594
+
595
+ await controller.run(async s => {
596
+ if (s.goodsListState.editGood) {
597
+ // message.error({
598
+ // content: '你正在编辑一个货物',
599
+ // key: '你正在编辑一个货物',
600
+ // });
601
+
602
+ // return;
603
+ await controller.state.goodsListState.form?.validateFields(async (err: any, values: any) => {
604
+ if (err) {
605
+ const firstError: any = Object.values(err)[0];
606
+ message.error({
607
+ content: firstError.errors[0].message,
608
+ key: '你正在编辑一个货物',
609
+ });
610
+ return;
611
+ }
612
+ });
613
+ }
614
+
615
+ s.goodsListState.isTaxIncluded = isTaxIncluded;
616
+
617
+ try {
618
+ let needRefresh = false;
619
+
620
+ if (s.goodsListState?.goodsList && s.goodsListState.goodsList.length) {
621
+ const newGoodsList = s.goodsListState.goodsList.map(good => {
622
+ const {
623
+ quantity: sourceQuantity,
624
+ priceExcludeTax: sourcePriceExcludeTax,
625
+ priceIncludeTax: sourcePriceIncludeTax,
626
+ lineAmountExcludeTax: sourceLineAmountExcludeTax,
627
+ lineAmountIncludeTax: sourceLineAmountIncludeTax,
628
+ taxRate } = good;
629
+ if (isTaxIncluded) {
630
+ if (!sourceQuantity && sourceQuantity !== 0) return good;
631
+ if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
632
+ if (!taxRate && taxRate !== 0) return good;
633
+ if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
634
+ return good
635
+ } else {
636
+ needRefresh = true;
637
+ }
638
+ const quantity: any = format15(sourceQuantity, calculatingDigits);
639
+ const priceIncludeTax: any = format15(sourcePriceIncludeTax, calculatingDigits);
640
+
641
+ const lineAmountIncludeTax: any = format2(evaluate(`${priceIncludeTax} * ${quantity}`));
642
+ const taxAmount: any = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate as any);
643
+ const lineAmountExcludeTax: any = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
644
+ const priceExcludeTax: any = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
645
+
646
+ return {
647
+ ...good,
648
+ lineAmountExcludeTax,
649
+ lineAmountIncludeTax,
650
+ taxAmount,
651
+ priceExcludeTax
652
+ }
653
+
654
+ } else {
655
+ if (!sourceQuantity && sourceQuantity !== 0) return good;
656
+ if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
657
+ if (!taxRate && taxRate !== 0) return good;
658
+ if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
659
+ return good
660
+ } else {
661
+ needRefresh = true;
662
+ }
663
+ const quantity: any = format15(sourceQuantity, calculatingDigits);
664
+ const priceExcludeTax: any = format15(sourcePriceExcludeTax, calculatingDigits);
665
+
666
+ const lineAmountExcludeTax: any = format2(evaluate(`${priceExcludeTax} * ${quantity}`));
667
+ const lineAmountIncludeTax: any = format2(evaluate(`${lineAmountExcludeTax} * (1+(${taxRate}/100))`));
668
+ const priceIncludeTax: any = format15(evaluate(`${lineAmountIncludeTax} / ${quantity}`), calculatingDigits);
669
+ const taxAmount: any = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
670
+
671
+ return {
672
+ ...good,
673
+ lineAmountExcludeTax,
674
+ lineAmountIncludeTax,
675
+ taxAmount,
676
+ priceIncludeTax
677
+ }
678
+ }
679
+
680
+ })
681
+
682
+ if (needRefresh) {
683
+ s.goodsListState.goodsList = newGoodsList;
684
+ }
685
+ }
686
+ } catch (e) {
687
+ console.error('切换税率重新计算出错', e, s.goodsListState)
688
+ }
689
+ })
690
+ }