@accounter/opcn1214-generator 0.0.0-bootstrap.0

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 (477) hide show
  1. package/.bob/cjs/api/generate.d.ts +44 -0
  2. package/.bob/cjs/api/generate.js +115 -0
  3. package/.bob/cjs/api/parse.d.ts +28 -0
  4. package/.bob/cjs/api/parse.js +38 -0
  5. package/.bob/cjs/api/response.d.ts +24 -0
  6. package/.bob/cjs/api/response.js +75 -0
  7. package/.bob/cjs/api/validate.d.ts +16 -0
  8. package/.bob/cjs/api/validate.js +15 -0
  9. package/.bob/cjs/codec/boolean.d.ts +7 -0
  10. package/.bob/cjs/codec/boolean.js +49 -0
  11. package/.bob/cjs/codec/date.d.ts +6 -0
  12. package/.bob/cjs/codec/date.js +68 -0
  13. package/.bob/cjs/codec/enum.d.ts +4 -0
  14. package/.bob/cjs/codec/enum.js +26 -0
  15. package/.bob/cjs/codec/numeric.d.ts +56 -0
  16. package/.bob/cjs/codec/numeric.js +186 -0
  17. package/.bob/cjs/codec/padding.d.ts +10 -0
  18. package/.bob/cjs/codec/padding.js +26 -0
  19. package/.bob/cjs/codec/percent.d.ts +6 -0
  20. package/.bob/cjs/codec/percent.js +33 -0
  21. package/.bob/cjs/codec/phone.d.ts +4 -0
  22. package/.bob/cjs/codec/phone.js +48 -0
  23. package/.bob/cjs/codec/record.d.ts +18 -0
  24. package/.bob/cjs/codec/record.js +176 -0
  25. package/.bob/cjs/codec/registry.d.ts +8 -0
  26. package/.bob/cjs/codec/registry.js +27 -0
  27. package/.bob/cjs/codec/sections.d.ts +41 -0
  28. package/.bob/cjs/codec/sections.js +177 -0
  29. package/.bob/cjs/codec/text.d.ts +5 -0
  30. package/.bob/cjs/codec/text.js +29 -0
  31. package/.bob/cjs/codec/types.d.ts +36 -0
  32. package/.bob/cjs/codec/types.js +16 -0
  33. package/.bob/cjs/codec/windows1255.d.ts +9 -0
  34. package/.bob/cjs/codec/windows1255.js +38 -0
  35. package/.bob/cjs/errors.d.ts +32 -0
  36. package/.bob/cjs/errors.js +103 -0
  37. package/.bob/cjs/file/assemble.d.ts +17 -0
  38. package/.bob/cjs/file/assemble.js +28 -0
  39. package/.bob/cjs/file/control.d.ts +13 -0
  40. package/.bob/cjs/file/control.js +45 -0
  41. package/.bob/cjs/file/parse.d.ts +18 -0
  42. package/.bob/cjs/file/parse.js +478 -0
  43. package/.bob/cjs/file/split.d.ts +17 -0
  44. package/.bob/cjs/file/split.js +71 -0
  45. package/.bob/cjs/index.d.ts +16 -0
  46. package/.bob/cjs/index.js +28 -0
  47. package/.bob/cjs/layout/2024/layout.generated.d.ts +6919 -0
  48. package/.bob/cjs/layout/2024/layout.generated.js +7224 -0
  49. package/.bob/cjs/layout/2025/index.d.ts +6 -0
  50. package/.bob/cjs/layout/2025/index.js +10 -0
  51. package/.bob/cjs/layout/capital-gains.d.ts +9 -0
  52. package/.bob/cjs/layout/capital-gains.js +15 -0
  53. package/.bob/cjs/layout/countries.d.ts +5 -0
  54. package/.bob/cjs/layout/countries.js +10 -0
  55. package/.bob/cjs/layout/freeze.d.ts +5 -0
  56. package/.bob/cjs/layout/freeze.js +16 -0
  57. package/.bob/cjs/layout/registry.d.ts +10 -0
  58. package/.bob/cjs/layout/registry.js +32 -0
  59. package/.bob/cjs/layout/types.d.ts +82 -0
  60. package/.bob/cjs/layout/types.js +35 -0
  61. package/.bob/cjs/model/codes.generated.d.ts +48 -0
  62. package/.bob/cjs/model/codes.generated.js +628 -0
  63. package/.bob/cjs/model/index.d.ts +3 -0
  64. package/.bob/cjs/model/index.js +5 -0
  65. package/.bob/cjs/model/input.d.ts +543 -0
  66. package/.bob/cjs/model/input.js +24 -0
  67. package/.bob/cjs/model/normalized.d.ts +43 -0
  68. package/.bob/cjs/model/normalized.js +0 -0
  69. package/.bob/cjs/model/options.d.ts +14 -0
  70. package/.bob/cjs/model/options.js +0 -0
  71. package/.bob/cjs/model/schema.d.ts +594 -0
  72. package/.bob/cjs/model/schema.js +339 -0
  73. package/.bob/cjs/normalize/canonical.d.ts +13 -0
  74. package/.bob/cjs/normalize/canonical.js +288 -0
  75. package/.bob/cjs/normalize/capital-gains/assets.d.ts +37 -0
  76. package/.bob/cjs/normalize/capital-gains/assets.js +94 -0
  77. package/.bob/cjs/normalize/capital-gains/index.d.ts +61 -0
  78. package/.bob/cjs/normalize/capital-gains/index.js +149 -0
  79. package/.bob/cjs/normalize/capital-gains/no-withholding.d.ts +18 -0
  80. package/.bob/cjs/normalize/capital-gains/no-withholding.js +36 -0
  81. package/.bob/cjs/normalize/capital-gains/other.d.ts +54 -0
  82. package/.bob/cjs/normalize/capital-gains/other.js +122 -0
  83. package/.bob/cjs/normalize/capital-gains/section6.d.ts +7 -0
  84. package/.bob/cjs/normalize/capital-gains/section6.js +13 -0
  85. package/.bob/cjs/normalize/capital-gains/securities.d.ts +26 -0
  86. package/.bob/cjs/normalize/capital-gains/securities.js +58 -0
  87. package/.bob/cjs/normalize/denormalize.d.ts +42 -0
  88. package/.bob/cjs/normalize/denormalize.js +359 -0
  89. package/.bob/cjs/normalize/derive.d.ts +57 -0
  90. package/.bob/cjs/normalize/derive.js +111 -0
  91. package/.bob/cjs/normalize/enums.d.ts +58 -0
  92. package/.bob/cjs/normalize/enums.js +69 -0
  93. package/.bob/cjs/normalize/fields.d.ts +28 -0
  94. package/.bob/cjs/normalize/fields.js +86 -0
  95. package/.bob/cjs/normalize/foreign.d.ts +22 -0
  96. package/.bob/cjs/normalize/foreign.js +85 -0
  97. package/.bob/cjs/normalize/main.d.ts +24 -0
  98. package/.bob/cjs/normalize/main.js +208 -0
  99. package/.bob/cjs/normalize/paths.d.ts +74 -0
  100. package/.bob/cjs/normalize/paths.js +169 -0
  101. package/.bob/cjs/normalize/phone.d.ts +12 -0
  102. package/.bob/cjs/normalize/phone.js +35 -0
  103. package/.bob/cjs/normalize/rd-investments.d.ts +10 -0
  104. package/.bob/cjs/normalize/rd-investments.js +25 -0
  105. package/.bob/cjs/normalize/related-companies.d.ts +10 -0
  106. package/.bob/cjs/normalize/related-companies.js +25 -0
  107. package/.bob/cjs/normalize/report.d.ts +9 -0
  108. package/.bob/cjs/normalize/report.js +53 -0
  109. package/.bob/cjs/normalize/shareholders.d.ts +10 -0
  110. package/.bob/cjs/normalize/shareholders.js +30 -0
  111. package/.bob/cjs/normalize/text.d.ts +11 -0
  112. package/.bob/cjs/normalize/text.js +41 -0
  113. package/.bob/cjs/normalize/today.d.ts +4 -0
  114. package/.bob/cjs/normalize/today.js +14 -0
  115. package/.bob/cjs/pipeline.d.ts +13 -0
  116. package/.bob/cjs/pipeline.js +37 -0
  117. package/.bob/cjs/response/codes.d.ts +2 -0
  118. package/.bob/cjs/response/codes.js +31 -0
  119. package/.bob/cjs/validate/capital-gains-rules.d.ts +6 -0
  120. package/.bob/cjs/validate/capital-gains-rules.js +162 -0
  121. package/.bob/cjs/validate/check-digit.d.ts +10 -0
  122. package/.bob/cjs/validate/check-digit.js +26 -0
  123. package/.bob/cjs/validate/engine.d.ts +5 -0
  124. package/.bob/cjs/validate/engine.js +35 -0
  125. package/.bob/cjs/validate/field-rules.d.ts +4 -0
  126. package/.bob/cjs/validate/field-rules.js +331 -0
  127. package/.bob/cjs/validate/foreign-rules.d.ts +6 -0
  128. package/.bob/cjs/validate/foreign-rules.js +171 -0
  129. package/.bob/cjs/validate/issue.d.ts +51 -0
  130. package/.bob/cjs/validate/issue.js +78 -0
  131. package/.bob/cjs/validate/main-rules.d.ts +24 -0
  132. package/.bob/cjs/validate/main-rules.js +425 -0
  133. package/.bob/cjs/validate/parse-rules.d.ts +31 -0
  134. package/.bob/cjs/validate/parse-rules.js +114 -0
  135. package/.bob/cjs/validate/rules.d.ts +746 -0
  136. package/.bob/cjs/validate/rules.js +680 -0
  137. package/.bob/cjs/validate/shape.d.ts +19 -0
  138. package/.bob/cjs/validate/shape.js +231 -0
  139. package/.bob/cjs/validate/shareholder-rules.d.ts +6 -0
  140. package/.bob/cjs/validate/shareholder-rules.js +83 -0
  141. package/.bob/cjs/validate/structure-rules.d.ts +26 -0
  142. package/.bob/cjs/validate/structure-rules.js +130 -0
  143. package/.bob/esm/api/generate.d.ts +44 -0
  144. package/.bob/esm/api/generate.js +111 -0
  145. package/.bob/esm/api/parse.d.ts +28 -0
  146. package/.bob/esm/api/parse.js +34 -0
  147. package/.bob/esm/api/response.d.ts +24 -0
  148. package/.bob/esm/api/response.js +72 -0
  149. package/.bob/esm/api/validate.d.ts +16 -0
  150. package/.bob/esm/api/validate.js +11 -0
  151. package/.bob/esm/codec/boolean.d.ts +7 -0
  152. package/.bob/esm/codec/boolean.js +46 -0
  153. package/.bob/esm/codec/date.d.ts +6 -0
  154. package/.bob/esm/codec/date.js +64 -0
  155. package/.bob/esm/codec/enum.d.ts +4 -0
  156. package/.bob/esm/codec/enum.js +23 -0
  157. package/.bob/esm/codec/numeric.d.ts +56 -0
  158. package/.bob/esm/codec/numeric.js +175 -0
  159. package/.bob/esm/codec/padding.d.ts +10 -0
  160. package/.bob/esm/codec/padding.js +21 -0
  161. package/.bob/esm/codec/percent.d.ts +6 -0
  162. package/.bob/esm/codec/percent.js +30 -0
  163. package/.bob/esm/codec/phone.d.ts +4 -0
  164. package/.bob/esm/codec/phone.js +45 -0
  165. package/.bob/esm/codec/record.d.ts +18 -0
  166. package/.bob/esm/codec/record.js +172 -0
  167. package/.bob/esm/codec/registry.d.ts +8 -0
  168. package/.bob/esm/codec/registry.js +23 -0
  169. package/.bob/esm/codec/sections.d.ts +41 -0
  170. package/.bob/esm/codec/sections.js +170 -0
  171. package/.bob/esm/codec/text.d.ts +5 -0
  172. package/.bob/esm/codec/text.js +26 -0
  173. package/.bob/esm/codec/types.d.ts +36 -0
  174. package/.bob/esm/codec/types.js +12 -0
  175. package/.bob/esm/codec/windows1255.d.ts +9 -0
  176. package/.bob/esm/codec/windows1255.js +32 -0
  177. package/.bob/esm/errors.d.ts +32 -0
  178. package/.bob/esm/errors.js +94 -0
  179. package/.bob/esm/file/assemble.d.ts +17 -0
  180. package/.bob/esm/file/assemble.js +25 -0
  181. package/.bob/esm/file/control.d.ts +13 -0
  182. package/.bob/esm/file/control.js +41 -0
  183. package/.bob/esm/file/parse.d.ts +18 -0
  184. package/.bob/esm/file/parse.js +474 -0
  185. package/.bob/esm/file/split.d.ts +17 -0
  186. package/.bob/esm/file/split.js +68 -0
  187. package/.bob/esm/index.d.ts +16 -0
  188. package/.bob/esm/index.js +11 -0
  189. package/.bob/esm/layout/2024/layout.generated.d.ts +6919 -0
  190. package/.bob/esm/layout/2024/layout.generated.js +7221 -0
  191. package/.bob/esm/layout/2025/index.d.ts +6 -0
  192. package/.bob/esm/layout/2025/index.js +7 -0
  193. package/.bob/esm/layout/capital-gains.d.ts +9 -0
  194. package/.bob/esm/layout/capital-gains.js +11 -0
  195. package/.bob/esm/layout/countries.d.ts +5 -0
  196. package/.bob/esm/layout/countries.js +7 -0
  197. package/.bob/esm/layout/freeze.d.ts +5 -0
  198. package/.bob/esm/layout/freeze.js +13 -0
  199. package/.bob/esm/layout/registry.d.ts +10 -0
  200. package/.bob/esm/layout/registry.js +27 -0
  201. package/.bob/esm/layout/types.d.ts +82 -0
  202. package/.bob/esm/layout/types.js +32 -0
  203. package/.bob/esm/model/codes.generated.d.ts +48 -0
  204. package/.bob/esm/model/codes.generated.js +625 -0
  205. package/.bob/esm/model/index.d.ts +3 -0
  206. package/.bob/esm/model/index.js +2 -0
  207. package/.bob/esm/model/input.d.ts +543 -0
  208. package/.bob/esm/model/input.js +21 -0
  209. package/.bob/esm/model/normalized.d.ts +43 -0
  210. package/.bob/esm/model/normalized.js +0 -0
  211. package/.bob/esm/model/options.d.ts +14 -0
  212. package/.bob/esm/model/options.js +0 -0
  213. package/.bob/esm/model/schema.d.ts +594 -0
  214. package/.bob/esm/model/schema.js +335 -0
  215. package/.bob/esm/normalize/canonical.d.ts +13 -0
  216. package/.bob/esm/normalize/canonical.js +285 -0
  217. package/.bob/esm/normalize/capital-gains/assets.d.ts +37 -0
  218. package/.bob/esm/normalize/capital-gains/assets.js +87 -0
  219. package/.bob/esm/normalize/capital-gains/index.d.ts +61 -0
  220. package/.bob/esm/normalize/capital-gains/index.js +142 -0
  221. package/.bob/esm/normalize/capital-gains/no-withholding.d.ts +18 -0
  222. package/.bob/esm/normalize/capital-gains/no-withholding.js +31 -0
  223. package/.bob/esm/normalize/capital-gains/other.d.ts +54 -0
  224. package/.bob/esm/normalize/capital-gains/other.js +112 -0
  225. package/.bob/esm/normalize/capital-gains/section6.d.ts +7 -0
  226. package/.bob/esm/normalize/capital-gains/section6.js +9 -0
  227. package/.bob/esm/normalize/capital-gains/securities.d.ts +26 -0
  228. package/.bob/esm/normalize/capital-gains/securities.js +52 -0
  229. package/.bob/esm/normalize/denormalize.d.ts +42 -0
  230. package/.bob/esm/normalize/denormalize.js +354 -0
  231. package/.bob/esm/normalize/derive.d.ts +57 -0
  232. package/.bob/esm/normalize/derive.js +99 -0
  233. package/.bob/esm/normalize/enums.d.ts +58 -0
  234. package/.bob/esm/normalize/enums.js +64 -0
  235. package/.bob/esm/normalize/fields.d.ts +28 -0
  236. package/.bob/esm/normalize/fields.js +81 -0
  237. package/.bob/esm/normalize/foreign.d.ts +22 -0
  238. package/.bob/esm/normalize/foreign.js +81 -0
  239. package/.bob/esm/normalize/main.d.ts +24 -0
  240. package/.bob/esm/normalize/main.js +204 -0
  241. package/.bob/esm/normalize/paths.d.ts +74 -0
  242. package/.bob/esm/normalize/paths.js +161 -0
  243. package/.bob/esm/normalize/phone.d.ts +12 -0
  244. package/.bob/esm/normalize/phone.js +32 -0
  245. package/.bob/esm/normalize/rd-investments.d.ts +10 -0
  246. package/.bob/esm/normalize/rd-investments.js +22 -0
  247. package/.bob/esm/normalize/related-companies.d.ts +10 -0
  248. package/.bob/esm/normalize/related-companies.js +22 -0
  249. package/.bob/esm/normalize/report.d.ts +9 -0
  250. package/.bob/esm/normalize/report.js +50 -0
  251. package/.bob/esm/normalize/shareholders.d.ts +10 -0
  252. package/.bob/esm/normalize/shareholders.js +27 -0
  253. package/.bob/esm/normalize/text.d.ts +11 -0
  254. package/.bob/esm/normalize/text.js +37 -0
  255. package/.bob/esm/normalize/today.d.ts +4 -0
  256. package/.bob/esm/normalize/today.js +11 -0
  257. package/.bob/esm/pipeline.d.ts +13 -0
  258. package/.bob/esm/pipeline.js +34 -0
  259. package/.bob/esm/response/codes.d.ts +2 -0
  260. package/.bob/esm/response/codes.js +28 -0
  261. package/.bob/esm/validate/capital-gains-rules.d.ts +6 -0
  262. package/.bob/esm/validate/capital-gains-rules.js +159 -0
  263. package/.bob/esm/validate/check-digit.d.ts +10 -0
  264. package/.bob/esm/validate/check-digit.js +23 -0
  265. package/.bob/esm/validate/engine.d.ts +5 -0
  266. package/.bob/esm/validate/engine.js +32 -0
  267. package/.bob/esm/validate/field-rules.d.ts +4 -0
  268. package/.bob/esm/validate/field-rules.js +328 -0
  269. package/.bob/esm/validate/foreign-rules.d.ts +6 -0
  270. package/.bob/esm/validate/foreign-rules.js +168 -0
  271. package/.bob/esm/validate/issue.d.ts +51 -0
  272. package/.bob/esm/validate/issue.js +72 -0
  273. package/.bob/esm/validate/main-rules.d.ts +24 -0
  274. package/.bob/esm/validate/main-rules.js +420 -0
  275. package/.bob/esm/validate/parse-rules.d.ts +31 -0
  276. package/.bob/esm/validate/parse-rules.js +110 -0
  277. package/.bob/esm/validate/rules.d.ts +746 -0
  278. package/.bob/esm/validate/rules.js +676 -0
  279. package/.bob/esm/validate/shape.d.ts +19 -0
  280. package/.bob/esm/validate/shape.js +227 -0
  281. package/.bob/esm/validate/shareholder-rules.d.ts +6 -0
  282. package/.bob/esm/validate/shareholder-rules.js +80 -0
  283. package/.bob/esm/validate/structure-rules.d.ts +26 -0
  284. package/.bob/esm/validate/structure-rules.js +122 -0
  285. package/.bob/tsconfig.tsbuildinfo +1 -0
  286. package/.gitattributes +1 -0
  287. package/CLAUDE.md +39 -0
  288. package/README.md +337 -0
  289. package/dist/cjs/index.js +28 -0
  290. package/dist/esm/index.js +11 -0
  291. package/documentation/IMPLEMENTATION_PLAN.md +2258 -0
  292. package/documentation/SPEC.md +1803 -0
  293. package/documentation/layout/2024/codes.csv +261 -0
  294. package/documentation/layout/2024/countries.csv +256 -0
  295. package/documentation/layout/2024/fields.csv +271 -0
  296. package/documentation/layout/2024/records.csv +18 -0
  297. package/documentation/layout/README.md +87 -0
  298. package/documentation/specifications/1214-2024.pdf +0 -0
  299. package/documentation/tools/extract_layout.py +191 -0
  300. package/package.json +77 -0
  301. package/scripts/generate-layout.ts +23 -0
  302. package/scripts/layout/csv.ts +111 -0
  303. package/scripts/layout/derived-codes.ts +12 -0
  304. package/scripts/layout/render.ts +364 -0
  305. package/scripts/layout/sources.ts +51 -0
  306. package/scripts/layout/values.ts +42 -0
  307. package/scripts/render-rules-table.ts +66 -0
  308. package/src/api/generate.ts +169 -0
  309. package/src/api/parse.ts +58 -0
  310. package/src/api/response.ts +110 -0
  311. package/src/api/validate.ts +26 -0
  312. package/src/codec/boolean.ts +62 -0
  313. package/src/codec/date.ts +75 -0
  314. package/src/codec/enum.ts +28 -0
  315. package/src/codec/numeric.ts +208 -0
  316. package/src/codec/padding.ts +33 -0
  317. package/src/codec/percent.ts +35 -0
  318. package/src/codec/phone.ts +54 -0
  319. package/src/codec/record.ts +206 -0
  320. package/src/codec/registry.ts +27 -0
  321. package/src/codec/sections.ts +208 -0
  322. package/src/codec/text.ts +31 -0
  323. package/src/codec/types.ts +47 -0
  324. package/src/codec/windows1255.ts +38 -0
  325. package/src/errors.ts +114 -0
  326. package/src/file/assemble.ts +42 -0
  327. package/src/file/control.ts +59 -0
  328. package/src/file/parse.ts +620 -0
  329. package/src/file/split.ts +86 -0
  330. package/src/index.ts +70 -0
  331. package/src/layout/2024/layout.generated.ts +7238 -0
  332. package/src/layout/2025/index.ts +9 -0
  333. package/src/layout/capital-gains.ts +20 -0
  334. package/src/layout/countries.ts +7 -0
  335. package/src/layout/freeze.ts +13 -0
  336. package/src/layout/registry.ts +33 -0
  337. package/src/layout/types.ts +134 -0
  338. package/src/model/codes.generated.ts +1190 -0
  339. package/src/model/index.ts +4 -0
  340. package/src/model/input.ts +594 -0
  341. package/src/model/normalized.ts +38 -0
  342. package/src/model/options.ts +17 -0
  343. package/src/model/schema.ts +381 -0
  344. package/src/normalize/canonical.ts +374 -0
  345. package/src/normalize/capital-gains/assets.ts +112 -0
  346. package/src/normalize/capital-gains/index.ts +212 -0
  347. package/src/normalize/capital-gains/no-withholding.ts +46 -0
  348. package/src/normalize/capital-gains/other.ts +153 -0
  349. package/src/normalize/capital-gains/section6.ts +14 -0
  350. package/src/normalize/capital-gains/securities.ts +73 -0
  351. package/src/normalize/denormalize.ts +426 -0
  352. package/src/normalize/derive.ts +136 -0
  353. package/src/normalize/enums.ts +87 -0
  354. package/src/normalize/fields.ts +110 -0
  355. package/src/normalize/foreign.ts +114 -0
  356. package/src/normalize/main.ts +284 -0
  357. package/src/normalize/paths.ts +184 -0
  358. package/src/normalize/phone.ts +45 -0
  359. package/src/normalize/rd-investments.ts +38 -0
  360. package/src/normalize/related-companies.ts +37 -0
  361. package/src/normalize/report.ts +59 -0
  362. package/src/normalize/shareholders.ts +42 -0
  363. package/src/normalize/text.ts +40 -0
  364. package/src/normalize/today.ts +15 -0
  365. package/src/pipeline.ts +42 -0
  366. package/src/response/codes.ts +30 -0
  367. package/src/validate/capital-gains-rules.ts +199 -0
  368. package/src/validate/check-digit.ts +25 -0
  369. package/src/validate/engine.ts +45 -0
  370. package/src/validate/field-rules.ts +383 -0
  371. package/src/validate/foreign-rules.ts +274 -0
  372. package/src/validate/issue.ts +121 -0
  373. package/src/validate/main-rules.ts +678 -0
  374. package/src/validate/parse-rules.ts +169 -0
  375. package/src/validate/rules.ts +747 -0
  376. package/src/validate/shape.ts +278 -0
  377. package/src/validate/shareholder-rules.ts +92 -0
  378. package/src/validate/structure-rules.ts +136 -0
  379. package/tests/api/batch.test.ts +227 -0
  380. package/tests/api/exports.test.ts +355 -0
  381. package/tests/api/generate.test.ts +409 -0
  382. package/tests/api/parse.test.ts +789 -0
  383. package/tests/api/response.test.ts +152 -0
  384. package/tests/api/validate.test.ts +86 -0
  385. package/tests/codec/numeric.test.ts +325 -0
  386. package/tests/codec/record.test.ts +318 -0
  387. package/tests/codec/registry.test.ts +17 -0
  388. package/tests/codec/sections.test.ts +333 -0
  389. package/tests/codec/text.test.ts +454 -0
  390. package/tests/codec/windows1255.test.ts +46 -0
  391. package/tests/docs/readme.test.ts +69 -0
  392. package/tests/edge-cases.test.ts +359 -0
  393. package/tests/errors.test.ts +138 -0
  394. package/tests/file/assemble.test.ts +188 -0
  395. package/tests/file/split.test.ts +61 -0
  396. package/tests/fixtures/builders.ts +512 -0
  397. package/tests/fixtures/files.ts +78 -0
  398. package/tests/fixtures/golden/README.md +37 -0
  399. package/tests/fixtures/golden/VERIFICATION.md +72 -0
  400. package/tests/fixtures/golden/batch-50.input.ts +92 -0
  401. package/tests/fixtures/golden/batch-50.opcn +150 -0
  402. package/tests/fixtures/golden/capital-gains-max.input.ts +177 -0
  403. package/tests/fixtures/golden/capital-gains-max.opcn +17 -0
  404. package/tests/fixtures/golden/cg-27.input.ts +63 -0
  405. package/tests/fixtures/golden/cg-27.opcn +4 -0
  406. package/tests/fixtures/golden/cg-50.input.ts +59 -0
  407. package/tests/fixtures/golden/cg-50.opcn +4 -0
  408. package/tests/fixtures/golden/cg-51.input.ts +60 -0
  409. package/tests/fixtures/golden/cg-51.opcn +4 -0
  410. package/tests/fixtures/golden/cg-54.input.ts +53 -0
  411. package/tests/fixtures/golden/cg-54.opcn +4 -0
  412. package/tests/fixtures/golden/cg-60.input.ts +77 -0
  413. package/tests/fixtures/golden/cg-60.opcn +4 -0
  414. package/tests/fixtures/golden/cg-63.input.ts +51 -0
  415. package/tests/fixtures/golden/cg-63.opcn +4 -0
  416. package/tests/fixtures/golden/cg-64.input.ts +62 -0
  417. package/tests/fixtures/golden/cg-64.opcn +4 -0
  418. package/tests/fixtures/golden/cg-65.input.ts +79 -0
  419. package/tests/fixtures/golden/cg-65.opcn +4 -0
  420. package/tests/fixtures/golden/cg-66.input.ts +53 -0
  421. package/tests/fixtures/golden/cg-66.opcn +4 -0
  422. package/tests/fixtures/golden/cg-77.input.ts +109 -0
  423. package/tests/fixtures/golden/cg-77.opcn +4 -0
  424. package/tests/fixtures/golden/foreign.input.ts +202 -0
  425. package/tests/fixtures/golden/foreign.opcn +27 -0
  426. package/tests/fixtures/golden/hebrew-edge.input.ts +90 -0
  427. package/tests/fixtures/golden/hebrew-edge.opcn +8 -0
  428. package/tests/fixtures/golden/kibbutz.input.ts +31 -0
  429. package/tests/fixtures/golden/kibbutz.opcn +2 -0
  430. package/tests/fixtures/golden/main-full.input.ts +780 -0
  431. package/tests/fixtures/golden/main-full.opcn +101 -0
  432. package/tests/fixtures/golden/minimal.input.ts +37 -0
  433. package/tests/fixtures/golden/minimal.opcn +3 -0
  434. package/tests/fixtures/golden/related-and-rd.input.ts +59 -0
  435. package/tests/fixtures/golden/related-and-rd.opcn +11 -0
  436. package/tests/fixtures/random.ts +843 -0
  437. package/tests/golden/fixtures.test.ts +627 -0
  438. package/tests/golden/golden.test.ts +95 -0
  439. package/tests/helpers/coverage.ts +18 -0
  440. package/tests/helpers/sample-values.ts +114 -0
  441. package/tests/layout/codegen-sync.test.ts +19 -0
  442. package/tests/layout/integrity.test.ts +232 -0
  443. package/tests/layout/registry.test.ts +98 -0
  444. package/tests/model/code-unions.test.ts +91 -0
  445. package/tests/model/schema.test.ts +1031 -0
  446. package/tests/normalize/canonical.test.ts +728 -0
  447. package/tests/normalize/capital-gains.test.ts +1850 -0
  448. package/tests/normalize/coverage.test.ts +88 -0
  449. package/tests/normalize/denormalize.test.ts +318 -0
  450. package/tests/normalize/enums.test.ts +118 -0
  451. package/tests/normalize/foreign.test.ts +273 -0
  452. package/tests/normalize/main.test.ts +839 -0
  453. package/tests/normalize/paths.test.ts +257 -0
  454. package/tests/normalize/rd-investments.test.ts +99 -0
  455. package/tests/normalize/related-companies.test.ts +106 -0
  456. package/tests/normalize/shareholders.test.ts +117 -0
  457. package/tests/normalize/text.test.ts +86 -0
  458. package/tests/pipeline.test.ts +96 -0
  459. package/tests/roundtrip/determinism.test.ts +207 -0
  460. package/tests/roundtrip/property.test.ts +126 -0
  461. package/tests/roundtrip/roundtrip.test.ts +573 -0
  462. package/tests/rules/cases.ts +873 -0
  463. package/tests/rules/rules.test.ts +69 -0
  464. package/tests/rules/spec-sync.test.ts +80 -0
  465. package/tests/scripts/csv.test.ts +78 -0
  466. package/tests/scripts/values.test.ts +80 -0
  467. package/tests/validate/capital-gains-rules.test.ts +307 -0
  468. package/tests/validate/check-digit.test.ts +42 -0
  469. package/tests/validate/field-rules.test.ts +867 -0
  470. package/tests/validate/foreign-rules.test.ts +255 -0
  471. package/tests/validate/issue.test.ts +96 -0
  472. package/tests/validate/main-rules.test.ts +761 -0
  473. package/tests/validate/parse-rules.test.ts +293 -0
  474. package/tests/validate/shareholder-rules.test.ts +143 -0
  475. package/tsconfig.json +10 -0
  476. package/tsconfig.typecheck.json +9 -0
  477. package/vitest.config.ts +11 -0
@@ -0,0 +1,839 @@
1
+ import { renderReport } from '../../src/file/assemble.js';
2
+ import { getLayout } from '../../src/layout/registry.js';
3
+ import type { PhonePrefix, Report1214Input } from '../../src/model/input.js';
4
+ import type { NormalizedRecord } from '../../src/model/normalized.js';
5
+ import { normalizeReport } from '../../src/normalize/report.js';
6
+ import { todayInJerusalem } from '../../src/normalize/today.js';
7
+ import { fullDeclarationsInput, fullMainInput, minimalInput } from '../fixtures/builders.js';
8
+
9
+ const LAYOUT = getLayout(2024);
10
+ const TODAY = '2024-06-30';
11
+ const OPTIONS = { today: () => TODAY };
12
+
13
+ function mainRecord(input = minimalInput(), options = OPTIONS): NormalizedRecord {
14
+ const record = normalizeReport(input, LAYOUT, options).records[0];
15
+ if (record?.recordType !== '1000') {
16
+ throw new Error('expected record 1000 first');
17
+ }
18
+ return record;
19
+ }
20
+
21
+ /** The record 1000 line of `input`. */
22
+ function mainLine(input: Report1214Input): string {
23
+ const line = renderReport(normalizeReport(input, LAYOUT, OPTIONS)).lines[0];
24
+ if (line === undefined) {
25
+ throw new Error('expected a record 1000 line');
26
+ }
27
+ return line;
28
+ }
29
+
30
+ /** The `length` characters of `line` at the 1-based layout `position`. */
31
+ function at(line: string, position: number, length: number): string {
32
+ return line.slice(position - 1, position - 1 + length);
33
+ }
34
+
35
+ describe('normalizeReport: record 1000 (skeleton)', () => {
36
+ it('produces one 1000 and one 1020 record, in that order, with no notices', () => {
37
+ const report = normalizeReport(minimalInput(), LAYOUT, OPTIONS);
38
+ expect(report.taxYear).toBe(2024);
39
+ expect(report.layout).toBe(LAYOUT);
40
+ expect(report.records.map(r => [r.recordType, r.index])).toEqual([
41
+ ['1000', 0],
42
+ ['1020', 0],
43
+ ]);
44
+ expect(report.notices).toEqual([]);
45
+ expect(report.omittedZeroCodes).toEqual([]);
46
+ });
47
+
48
+ it('defaults the layout to the one of input.taxYear', () => {
49
+ expect(normalizeReport(minimalInput(), undefined, OPTIONS).layout).toBe(LAYOUT);
50
+ });
51
+
52
+ it('maps every 1000 key of the minimal input to its value and path', () => {
53
+ const record = mainRecord();
54
+ expect(record.values).toEqual({
55
+ taxYear: 2024,
56
+ 'meta.softwareName': 'ACCOUNTER',
57
+ 'meta.saveDate': TODAY,
58
+ 'company.fileNumber': '514000009',
59
+ 'company.registeredName': 'חברה לדוגמה בע"מ',
60
+ 'company.mailingAddress': 'רחוב הרצל 1, תל אביב',
61
+ 'company.businessAddress': 'רחוב הרצל 1, תל אביב',
62
+ 'company.phone.prefix': '03',
63
+ 'company.phone.number': '1234567',
64
+ hasForeignAppendix: false,
65
+ 'declarations.hasCapitalGainsAppendix': false,
66
+ 'declarations.hasTaxPlanningAction': false,
67
+ 'declarations.hadRelatedPartyTransactions': false,
68
+ 'declarations.controlsBodyOfPersons': false,
69
+ 'declarations.holdsRightsInBodyOfPersons': false,
70
+ 'declarations.appliesAccountingStandards': false,
71
+ 'declarations.directorsReceivedOpinion': false,
72
+ 'declarations.tookReportablePosition': false,
73
+ });
74
+ expect(record.paths).toEqual({
75
+ taxYear: 'taxYear',
76
+ 'meta.softwareName': 'meta.softwareName',
77
+ 'meta.saveDate': 'meta.saveDate',
78
+ 'company.fileNumber': 'company.fileNumber',
79
+ 'company.registeredName': 'company.registeredName',
80
+ 'company.mailingAddress': 'company.mailingAddress',
81
+ 'company.businessAddress': 'company.businessAddress',
82
+ 'company.phone.prefix': 'company.phone.prefix',
83
+ 'company.phone.number': 'company.phone.number',
84
+ hasForeignAppendix: '',
85
+ 'declarations.hasCapitalGainsAppendix': 'declarations.hasCapitalGainsAppendix',
86
+ 'declarations.hasTaxPlanningAction': 'declarations.hasTaxPlanningAction',
87
+ 'declarations.hadRelatedPartyTransactions': 'declarations.hadRelatedPartyTransactions',
88
+ 'declarations.controlsBodyOfPersons': 'declarations.controlsBodyOfPersons',
89
+ 'declarations.holdsRightsInBodyOfPersons': 'declarations.holdsRightsInBodyOfPersons',
90
+ 'declarations.appliesAccountingStandards': 'declarations.appliesAccountingStandards',
91
+ 'declarations.directorsReceivedOpinion': 'declarations.directorsReceivedOpinion',
92
+ 'declarations.tookReportablePosition': 'declarations.tookReportablePosition',
93
+ 'code:018': 'amounts["018"]',
94
+ 'code:072': 'amounts["072"]',
95
+ 'code:081': 'amounts["081"]',
96
+ 'code:094': 'amounts["094"]',
97
+ 'code:263': 'amounts["263"]',
98
+ 'code:273': '',
99
+ });
100
+ expect(record.codes).toEqual(
101
+ new Map([
102
+ ['018', 4],
103
+ ['072', 0],
104
+ ['081', 1000],
105
+ ['094', 0],
106
+ ['263', 1],
107
+ ['273', 9],
108
+ ]),
109
+ );
110
+ expect(record.countries).toEqual([]);
111
+ });
112
+
113
+ it('maps the optional company members, including the fax', () => {
114
+ const record = mainRecord(
115
+ minimalInput({
116
+ company: {
117
+ withholdingFileNumber: '914000005',
118
+ vatFileNumber: '514000009',
119
+ occupationDescription: 'ייעוץ',
120
+ booksAddress: 'רחוב יפו 2, ירושלים',
121
+ email: 'office@example.com',
122
+ fax: { prefix: '052', number: '7654321' },
123
+ },
124
+ }),
125
+ );
126
+ expect(record.values).toMatchObject({
127
+ 'company.withholdingFileNumber': '914000005',
128
+ 'company.vatFileNumber': '514000009',
129
+ 'company.occupationDescription': 'ייעוץ',
130
+ 'company.booksAddress': 'רחוב יפו 2, ירושלים',
131
+ 'company.email': 'office@example.com',
132
+ 'company.fax.prefix': '052',
133
+ 'company.fax.number': '7654321',
134
+ });
135
+ expect(record.paths['company.fax.number']).toBe('company.fax.number');
136
+ expect(record.paths['company.withholdingFileNumber']).toBe('company.withholdingFileNumber');
137
+ });
138
+
139
+ it('every key it sets is a field of record 1000 and has a path', () => {
140
+ const record = mainRecord(
141
+ minimalInput({ company: { email: 'a@b.co', fax: { prefix: '02', number: '1111111' } } }),
142
+ );
143
+ const keys = new Set(LAYOUT.records['1000'].fields.map(field => field.key));
144
+ for (const key of Object.keys(record.values)) {
145
+ expect(keys).toContain(key);
146
+ expect(record.paths).toHaveProperty([key]);
147
+ }
148
+ for (const code of record.codes.keys()) {
149
+ expect(record.paths).toHaveProperty([`code:${code}`]);
150
+ }
151
+ });
152
+
153
+ describe('meta defaults (SPEC §7.4)', () => {
154
+ it("defaults softwareName to 'ACCOUNTER' and saveDate to options.today()", () => {
155
+ const record = mainRecord(minimalInput(), { today: () => '2025-01-02' });
156
+ expect(record.values['meta.softwareName']).toBe('ACCOUNTER');
157
+ expect(record.values['meta.saveDate']).toBe('2025-01-02');
158
+ });
159
+
160
+ it('takes meta values from the input when given', () => {
161
+ const record = mainRecord(
162
+ minimalInput({ meta: { softwareName: ' My Soft ', saveDate: '2024-05-01' } }),
163
+ );
164
+ expect(record.values['meta.softwareName']).toBe('My Soft');
165
+ expect(record.values['meta.saveDate']).toBe('2024-05-01');
166
+ });
167
+
168
+ it('defaults saveDate to today in Asia/Jerusalem when options.today is absent', () => {
169
+ vi.useFakeTimers();
170
+ try {
171
+ vi.setSystemTime(new Date('2024-03-15T22:30:00Z'));
172
+ const report = normalizeReport(minimalInput());
173
+ expect(report.records[0]?.values['meta.saveDate']).toBe('2024-03-16');
174
+ } finally {
175
+ vi.useRealTimers();
176
+ }
177
+ });
178
+ });
179
+
180
+ describe('todayInJerusalem', () => {
181
+ it.each([
182
+ // Winter (UTC+2)
183
+ ['2024-03-15T21:59:59Z', '2024-03-15'],
184
+ ['2024-03-15T22:00:00Z', '2024-03-16'],
185
+ // Summer (UTC+3)
186
+ ['2024-07-01T20:59:59Z', '2024-07-01'],
187
+ ['2024-07-01T21:00:00Z', '2024-07-02'],
188
+ // Around midnight UTC
189
+ ['2024-12-31T23:59:59Z', '2025-01-01'],
190
+ ['2025-01-01T00:00:00Z', '2025-01-01'],
191
+ ['2024-06-30T23:59:59Z', '2024-07-01'],
192
+ ])('%s → %s', (instant, expected) => {
193
+ expect(todayInJerusalem(new Date(instant))).toBe(expected);
194
+ });
195
+
196
+ it('defaults to the current time', () => {
197
+ vi.useFakeTimers();
198
+ try {
199
+ vi.setSystemTime(new Date('2024-07-01T21:00:00Z'));
200
+ expect(todayInJerusalem()).toBe('2024-07-02');
201
+ } finally {
202
+ vi.useRealTimers();
203
+ }
204
+ });
205
+ });
206
+
207
+ describe('text normalization (SPEC §4.3)', () => {
208
+ it('passes text fields through normalizeText', () => {
209
+ const record = mainRecord(
210
+ minimalInput({
211
+ company: {
212
+ registeredName: ' חברה\u00A0 לדוגמה\u200F בע\u201Dמ ',
213
+ mailingAddress: 'רחוב\tהרצל 1 \u2013 תל אביב',
214
+ },
215
+ }),
216
+ );
217
+ expect(record.values['company.registeredName']).toBe('חברה לדוגמה בע"מ');
218
+ expect(record.values['company.mailingAddress']).toBe('רחוב הרצל 1 - תל אביב');
219
+ });
220
+
221
+ it('treats text that is empty after normalization as absent (SPEC §4.1)', () => {
222
+ const record = mainRecord(minimalInput({ company: { email: ' \u200E ', booksAddress: '' } }));
223
+ expect(record.values).not.toHaveProperty(['company.email']);
224
+ expect(record.values).not.toHaveProperty(['company.booksAddress']);
225
+ expect(record.paths).not.toHaveProperty(['company.email']);
226
+ });
227
+ });
228
+
229
+ describe('digit strings', () => {
230
+ it('keeps a digit string that is not all digits as-is (rules report it)', () => {
231
+ const record = mainRecord(minimalInput({ company: { fileNumber: '12a' } }));
232
+ expect(record.values['company.fileNumber']).toBe('12a');
233
+ });
234
+
235
+ it('keeps phone numbers as digit strings with their leading zeros', () => {
236
+ const record = mainRecord(minimalInput({ company: { phone: { number: '0123456' } } }));
237
+ expect(record.values['company.phone.number']).toBe('0123456');
238
+ });
239
+ });
240
+
241
+ describe('derived values (SPEC §7.4)', () => {
242
+ it('832 and 833 are "no" while no appendix exists', () => {
243
+ const record = mainRecord();
244
+ expect(record.values.hasForeignAppendix).toBe(false);
245
+ expect(record.values['declarations.hasCapitalGainsAppendix']).toBe(false);
246
+ });
247
+
248
+ it('832 is "yes" when a foreign appendix exists', () => {
249
+ const record = mainRecord(
250
+ minimalInput({ foreignAppendix: { taxRefundDeclaration: false, amounts: {} } }),
251
+ );
252
+ expect(record.values.hasForeignAppendix).toBe(true);
253
+ });
254
+
255
+ it.each([
256
+ [true, false, 1],
257
+ [false, true, 2],
258
+ [true, true, 3],
259
+ [false, false, 9],
260
+ ])(
261
+ 'code 273: directorsReceivedOpinion %s, tookReportablePosition %s → %i',
262
+ (directorsReceivedOpinion, tookReportablePosition, expected) => {
263
+ const record = mainRecord(
264
+ minimalInput({ declarations: { directorsReceivedOpinion, tookReportablePosition } }),
265
+ );
266
+ expect(record.codes.get('273')).toBe(expected);
267
+ expect(record.values['declarations.directorsReceivedOpinion']).toBe(
268
+ directorsReceivedOpinion,
269
+ );
270
+ expect(record.values['declarations.tookReportablePosition']).toBe(tookReportablePosition);
271
+ expect(record.paths['code:273']).toBe('');
272
+ },
273
+ );
274
+
275
+ it('code 008 = 1 when appliesAccountingStandards', () => {
276
+ const record = mainRecord(
277
+ minimalInput({ declarations: { appliesAccountingStandards: true } }),
278
+ );
279
+ expect(record.codes.get('008')).toBe(1);
280
+ expect(record.paths['code:008']).toBe('');
281
+ expect(record.values['declarations.appliesAccountingStandards']).toBe(true);
282
+ });
283
+
284
+ it('code 008 is omitted when not appliesAccountingStandards', () => {
285
+ expect(mainRecord().codes.has('008')).toBe(false);
286
+ });
287
+ });
288
+
289
+ describe('amounts (SPEC §4.5)', () => {
290
+ it('omits a zero for a code that is not zeroAllowed and lists it in omittedZeroCodes', () => {
291
+ const report = normalizeReport(
292
+ minimalInput({ amounts: { '010': 0, '070': 0, '020': 5 } }),
293
+ LAYOUT,
294
+ OPTIONS,
295
+ );
296
+ const record = report.records[0];
297
+ expect(record?.codes.has('010')).toBe(false);
298
+ expect(record?.codes.has('070')).toBe(false);
299
+ expect(record?.paths).not.toHaveProperty(['code:010']);
300
+ expect(record?.codes.get('020')).toBe(5);
301
+ expect(record?.paths['code:020']).toBe('amounts["020"]');
302
+ expect(report.omittedZeroCodes).toEqual([
303
+ { record: '1000', recordIndex: 0, code: '010' },
304
+ { record: '1000', recordIndex: 0, code: '070' },
305
+ ]);
306
+ });
307
+
308
+ it('keeps a zero for a zeroAllowed code', () => {
309
+ const record = mainRecord(minimalInput({ amounts: { '072': 0, '121': 0 } }));
310
+ expect(record.codes.get('072')).toBe(0);
311
+ expect(record.codes.get('121')).toBe(0);
312
+ expect(record.paths['code:072']).toBe('amounts["072"]');
313
+ expect(record.paths['code:121']).toBe('amounts["121"]');
314
+ });
315
+
316
+ it('skips codes whose value is undefined', () => {
317
+ const record = mainRecord(minimalInput({ amounts: { '010': undefined } }));
318
+ expect(record.codes.has('010')).toBe(false);
319
+ });
320
+
321
+ it('keeps codes in ascending code order', () => {
322
+ const record = mainRecord(minimalInput({ amounts: { '299': 7, '010': 3 } }));
323
+ const codes = [...record.codes.keys()];
324
+ expect(codes).toEqual([...codes].sort());
325
+ });
326
+ });
327
+ });
328
+
329
+ describe('normalizeReport: record 1000 declarations and preparer', () => {
330
+ it('maps the preparer (1000@563–831) to its keys, encoded values and paths', () => {
331
+ const input = fullDeclarationsInput();
332
+ const record = mainRecord(input);
333
+ const line = mainLine(input);
334
+ const expected: Array<[string, unknown, number, string]> = [
335
+ ['preparer.officeName', 'משרד רואי חשבון', 563, 'משרד רואי חשבון'.padStart(50)],
336
+ ['preparer.contactName', 'דנה כהן', 613, 'דנה כהן'.padStart(50)],
337
+ ['preparer.name', 'יוסי לוי', 663, 'יוסי לוי'.padStart(50)],
338
+ ['preparer.profession', 'רואה חשבון', 713, 'רואה חשבון'.padStart(50)],
339
+ ['preparer.licensedDealerNumber', '012345674', 763, '012345674'],
340
+ ['preparer.address', 'רחוב יפו 10, ירושלים', 772, 'רחוב יפו 10, ירושלים'.padStart(50)],
341
+ // 822 is a numeric prefix field: zero-padded (SPEC §15 A-19).
342
+ ['preparer.phone.prefix', '02', 822, '002'],
343
+ ['preparer.phone.number', '6543210', 825, '6543210'],
344
+ ];
345
+ for (const [key, value, position, encoded] of expected) {
346
+ expect(record.values[key]).toBe(value);
347
+ expect(record.paths[key]).toBe(key);
348
+ expect(at(line, position, encoded.length)).toBe(encoded);
349
+ }
350
+ });
351
+
352
+ it('normalizes preparer text and drops an invalid preparer phone prefix with a notice', () => {
353
+ const report = normalizeReport(
354
+ fullDeclarationsInput({
355
+ preparer: { name: ' יוסי\u00A0 לוי ', phone: { prefix: '01' as PhonePrefix } },
356
+ }),
357
+ LAYOUT,
358
+ OPTIONS,
359
+ );
360
+ const record = report.records[0];
361
+ expect(record?.values['preparer.name']).toBe('יוסי לוי');
362
+ expect(record?.values).not.toHaveProperty(['preparer.phone.prefix']);
363
+ expect(record?.values['preparer.phone.number']).toBe('6543210');
364
+ expect(report.notices).toEqual([
365
+ expect.objectContaining({
366
+ ruleId: 'field.phonePrefix',
367
+ severity: 'warning',
368
+ path: 'preparer.phone.prefix',
369
+ value: '01',
370
+ }),
371
+ ]);
372
+ });
373
+
374
+ it('leaves every preparer field absent without a preparer', () => {
375
+ const record = mainRecord();
376
+ expect(Object.keys(record.values).filter(key => key.startsWith('preparer.'))).toEqual([]);
377
+ const line = mainLine(minimalInput());
378
+ expect(at(line, 763, 9)).toBe('000000000');
379
+ expect(at(line, 822, 3)).toBe('000');
380
+ });
381
+
382
+ it.each([
383
+ ['obliged', 1],
384
+ ['notObliged', 2],
385
+ ['notRelevant', 3],
386
+ ] as const)('form6111Obligation %s → 834 = %i', (form6111Obligation, code) => {
387
+ const input = minimalInput({ declarations: { form6111Obligation } });
388
+ const record = mainRecord(input);
389
+ expect(record.values['declarations.form6111Obligation']).toBe(code);
390
+ expect(record.paths['declarations.form6111Obligation']).toBe('declarations.form6111Obligation');
391
+ expect(at(mainLine(input), 834, 1)).toBe(String(code));
392
+ });
393
+
394
+ it.each([
395
+ ['consolidatedUnderSection23', 1],
396
+ ['consolidatesWithParent', 2],
397
+ ['notRelevant', 3],
398
+ ] as const)('consolidatedReport %s → 875 = %i', (consolidatedReport, code) => {
399
+ const input = minimalInput({ declarations: { consolidatedReport } });
400
+ const record = mainRecord(input);
401
+ expect(record.values['declarations.consolidatedReport']).toBe(code);
402
+ expect(record.paths['declarations.consolidatedReport']).toBe('declarations.consolidatedReport');
403
+ expect(at(mainLine(input), 875, 1)).toBe(String(code));
404
+ });
405
+
406
+ it('writes 0 for an absent enum declaration', () => {
407
+ const line = mainLine(minimalInput());
408
+ expect(at(line, 834, 1)).toBe('0');
409
+ expect(at(line, 875, 1)).toBe('0');
410
+ });
411
+
412
+ it('keeps an enum value that is not one of its literals as-is, for the field rules', () => {
413
+ const record = mainRecord(
414
+ minimalInput({ declarations: { form6111Obligation: 'sometimes' as 'obliged' } }),
415
+ );
416
+ expect(record.values['declarations.form6111Obligation']).toBe('sometimes');
417
+ });
418
+
419
+ it('familyCompany → 836 = 1 and 837 = representativeFileNumber', () => {
420
+ const input = minimalInput({
421
+ declarations: { familyCompany: { representativeFileNumber: '300000007' } },
422
+ });
423
+ const record = mainRecord(input);
424
+ const line = mainLine(input);
425
+ expect(record.values['declarations.familyCompany.isFamilyCompany']).toBe(true);
426
+ expect(record.paths['declarations.familyCompany.isFamilyCompany']).toBe(
427
+ 'declarations.familyCompany',
428
+ );
429
+ expect(record.values['declarations.familyCompany.representativeFileNumber']).toBe('300000007');
430
+ expect(record.paths['declarations.familyCompany.representativeFileNumber']).toBe(
431
+ 'declarations.familyCompany.representativeFileNumber',
432
+ );
433
+ expect(at(line, 836, 1)).toBe('1');
434
+ expect(at(line, 837, 9)).toBe('300000007');
435
+ });
436
+
437
+ it('beneficiaryEnterprise → 851 = 1 and 852 = the notice date', () => {
438
+ const input = minimalInput({
439
+ declarations: { beneficiaryEnterprise: { noticeDate: '2023-05-14' } },
440
+ });
441
+ const record = mainRecord(input);
442
+ const line = mainLine(input);
443
+ expect(record.values['declarations.beneficiaryEnterprise.marked']).toBe(true);
444
+ expect(record.paths['declarations.beneficiaryEnterprise.marked']).toBe(
445
+ 'declarations.beneficiaryEnterprise',
446
+ );
447
+ expect(record.values['declarations.beneficiaryEnterprise.noticeDate']).toBe('2023-05-14');
448
+ expect(record.paths['declarations.beneficiaryEnterprise.noticeDate']).toBe(
449
+ 'declarations.beneficiaryEnterprise.noticeDate',
450
+ );
451
+ expect(at(line, 851, 1)).toBe('1');
452
+ expect(at(line, 852, 10)).toBe('14/05/2023');
453
+ });
454
+
455
+ it('specialYear → 863 = 1 and 864 = the balance sheet date', () => {
456
+ const input = minimalInput({
457
+ declarations: { specialYear: { balanceSheetDate: '2024-09-30' } },
458
+ });
459
+ const record = mainRecord(input);
460
+ const line = mainLine(input);
461
+ expect(record.values['declarations.specialYear.marked']).toBe(true);
462
+ expect(record.paths['declarations.specialYear.marked']).toBe('declarations.specialYear');
463
+ expect(record.values['declarations.specialYear.balanceSheetDate']).toBe('2024-09-30');
464
+ expect(record.paths['declarations.specialYear.balanceSheetDate']).toBe(
465
+ 'declarations.specialYear.balanceSheetDate',
466
+ );
467
+ expect(at(line, 863, 1)).toBe('1');
468
+ expect(at(line, 864, 10)).toBe('30/09/2024');
469
+ });
470
+
471
+ it('leaves the presence flags unmarked without their objects', () => {
472
+ const record = mainRecord();
473
+ const line = mainLine(minimalInput());
474
+ for (const key of [
475
+ 'declarations.familyCompany.isFamilyCompany',
476
+ 'declarations.familyCompany.representativeFileNumber',
477
+ 'declarations.beneficiaryEnterprise.marked',
478
+ 'declarations.beneficiaryEnterprise.noticeDate',
479
+ 'declarations.specialYear.marked',
480
+ 'declarations.specialYear.balanceSheetDate',
481
+ ]) {
482
+ expect(record.values).not.toHaveProperty([key]);
483
+ }
484
+ expect(at(line, 836, 10)).toBe('0000000000');
485
+ expect(at(line, 851, 1)).toBe('0');
486
+ expect(at(line, 852, 10)).toBe(' '.repeat(10));
487
+ expect(at(line, 863, 1)).toBe('0');
488
+ expect(at(line, 864, 10)).toBe(' '.repeat(10));
489
+ });
490
+
491
+ it('reportablePositions [12, 7] → 1034 = 012, 1037 = 007, 1040–1046 = 000', () => {
492
+ const input = minimalInput({
493
+ declarations: { tookReportablePosition: true, reportablePositions: [12, 7] },
494
+ });
495
+ const record = mainRecord(input);
496
+ const line = mainLine(input);
497
+ expect(record.values['declarations.reportablePositions[0]']).toBe(12);
498
+ expect(record.values['declarations.reportablePositions[1]']).toBe(7);
499
+ expect(record.values).not.toHaveProperty(['declarations.reportablePositions[2]']);
500
+ expect(record.paths['declarations.reportablePositions[0]']).toBe(
501
+ 'declarations.reportablePositions[0]',
502
+ );
503
+ expect(record.paths['declarations.reportablePositions[1]']).toBe(
504
+ 'declarations.reportablePositions[1]',
505
+ );
506
+ expect(at(line, 1034, 3)).toBe('012');
507
+ expect(at(line, 1037, 3)).toBe('007');
508
+ expect(at(line, 1040, 3)).toBe('000');
509
+ expect(at(line, 1043, 3)).toBe('000');
510
+ expect(at(line, 1046, 3)).toBe('000');
511
+ });
512
+
513
+ it('writes only the first five reportable positions and raises a notice for the sixth', () => {
514
+ const input = minimalInput({
515
+ declarations: { tookReportablePosition: true, reportablePositions: [1, 2, 3, 4, 5, 6] },
516
+ });
517
+ expect(normalizeReport(input, LAYOUT, OPTIONS).notices).toEqual([
518
+ expect.objectContaining({
519
+ ruleId: 'main.reportablePositions.max',
520
+ severity: 'error',
521
+ path: 'declarations.reportablePositions[5]',
522
+ value: 6,
523
+ }),
524
+ ]);
525
+ const record = mainRecord(input);
526
+ expect(
527
+ Object.keys(record.values).filter(key => key.startsWith('declarations.reportablePositions')),
528
+ ).toHaveLength(5);
529
+ expect(at(mainLine(input), 1034, 15)).toBe('001002003004005');
530
+ });
531
+
532
+ it.each([
533
+ ['requestsAdvancePayments', 883],
534
+ ['hasBuildingIncome', 884],
535
+ ['partOfMultinationalGroup', 1033],
536
+ ] as const)('%s is yes/no at %i: 1, 2, and 0 when absent', (member, position) => {
537
+ const key = `declarations.${member}`;
538
+ for (const [value, encoded] of [
539
+ [true, '1'],
540
+ [false, '2'],
541
+ [undefined, '0'],
542
+ ] as const) {
543
+ const input = minimalInput({ declarations: { [member]: value } });
544
+ const record = mainRecord(input);
545
+ expect(record.values[key]).toBe(value);
546
+ expect(record.paths[key]).toBe(value === undefined ? undefined : key);
547
+ expect(at(mainLine(input), position, 1)).toBe(encoded);
548
+ }
549
+ });
550
+
551
+ it.each([
552
+ ['financialStatementsAttached', 835],
553
+ ['isHouseCompany', 846],
554
+ ['form1343Attached', 847],
555
+ ['form1344Attached', 848],
556
+ ['claimsCapitalInvestmentLawBenefits', 849],
557
+ ['preferredEnterprise', 850],
558
+ ['dividendDistributed', 862],
559
+ ['foreignInvestors', 874],
560
+ ['partnerInPartnership', 876],
561
+ ['isKibbutz', 877],
562
+ ['isTrustBeneficiary', 886],
563
+ ['nonDeductibleSalaryExpenses', 1031],
564
+ ['fewMembersCompany62A', 1032],
565
+ ['noBankAccount', 1064],
566
+ ] as const)('%s is a flag at %i: 1 when marked, 0 otherwise', (member, position) => {
567
+ const key = `declarations.${member}`;
568
+ const marked = minimalInput({ declarations: { [member]: true } });
569
+ expect(mainRecord(marked).values[key]).toBe(true);
570
+ expect(mainRecord(marked).paths[key]).toBe(key);
571
+ expect(at(mainLine(marked), position, 1)).toBe('1');
572
+ expect(at(mainLine(minimalInput({ declarations: { [member]: false } })), position, 1)).toBe(
573
+ '0',
574
+ );
575
+ expect(at(mainLine(minimalInput()), position, 1)).toBe('0');
576
+ });
577
+
578
+ describe('833 has capital-gains appendix (SPEC §7.4)', () => {
579
+ it('hasCapitalGainsAppendix true forces 833 = yes', () => {
580
+ const input = minimalInput({ declarations: { hasCapitalGainsAppendix: true } });
581
+ const record = mainRecord(input);
582
+ expect(record.values['declarations.hasCapitalGainsAppendix']).toBe(true);
583
+ expect(record.paths['declarations.hasCapitalGainsAppendix']).toBe(
584
+ 'declarations.hasCapitalGainsAppendix',
585
+ );
586
+ expect(at(mainLine(input), 833, 1)).toBe('1');
587
+ });
588
+
589
+ it.each([false, undefined])('hasCapitalGainsAppendix %s leaves 833 derived (no)', value => {
590
+ const input = minimalInput({ declarations: { hasCapitalGainsAppendix: value } });
591
+ expect(mainRecord(input).values['declarations.hasCapitalGainsAppendix']).toBe(false);
592
+ expect(at(mainLine(input), 833, 1)).toBe('2');
593
+ });
594
+ });
595
+
596
+ it('raises no notices for the full declarations input', () => {
597
+ expect(normalizeReport(fullDeclarationsInput(), LAYOUT, OPTIONS).notices).toEqual([]);
598
+ });
599
+ });
600
+
601
+ describe('normalizeReport: record 1000 other income, attachments, capital-gains summary, qualifying company', () => {
602
+ it('maps every member to its key, encoded value and path', () => {
603
+ const input = fullMainInput();
604
+ const record = mainRecord(input);
605
+ const line = mainLine(input);
606
+ const expected: Array<[string, unknown, number, string]> = [
607
+ ['otherTaxableIncome.source', 'דמי שכירות', 887, 'דמי שכירות'.padStart(50)],
608
+ ['otherTaxableIncome.amount', 25_000, 937, '000000025000'],
609
+ // percentX100: × 100 with alphanumeric padding (SPEC §15 A-2).
610
+ ['otherTaxableIncome.ratePercent', 10.23, 949, ' 1023'],
611
+ ['attachments.donationReceiptsCount', 2, 954, '002'],
612
+ ['attachments.withholdingCertificatesCount', 3, 957, '003'],
613
+ ['capitalGainsSummary.totalAppendicesCount', 4, 960, '04'],
614
+ ['capitalGainsSummary.untransmittedCount', 3, 962, '03'],
615
+ ['capitalGainsSummary.reasons.lossOrNoGain', true, 964, '1'],
616
+ ['capitalGainsSummary.reasons.overFiveImprovementBalances', true, 965, '1'],
617
+ ['capitalGainsSummary.reasons.over14Appendices', true, 966, '1'],
618
+ ['capitalGainsSummary.reasons.other', true, 967, '1'],
619
+ ['capitalGainsSummary.reasons.otherText', 'העסקה בוטלה', 968, 'העסקה בוטלה'.padStart(50)],
620
+ ['qualifyingCompany.purchased', true, 1065, '1'],
621
+ ['qualifyingCompany.israeliPurchaseAmount', 1_000_000, 1066, '000001000000'],
622
+ ['qualifyingCompany.foreignPurchaseAmount', 2_500_000, 1078, '000002500000'],
623
+ ['qualifyingCompany.amortizationClaimed', true, 1090, '1'],
624
+ // amountX: digits with alphanumeric padding (SPEC §15 A-21).
625
+ ['qualifyingCompany.amortizationAmount', 150_000, 1091, '150000'.padStart(12)],
626
+ ];
627
+ for (const [key, value, position, encoded] of expected) {
628
+ expect(record.values[key]).toBe(value);
629
+ expect(record.paths[key]).toBe(key);
630
+ expect(at(line, position, encoded.length)).toBe(encoded);
631
+ }
632
+ });
633
+
634
+ it('otherTaxableIncome.ratePercent 10.23 → 949 = " 1023", 100 → "10000"', () => {
635
+ expect(at(mainLine(minimalInput({ otherTaxableIncome: { ratePercent: 10.23 } })), 949, 5)).toBe(
636
+ ' 1023',
637
+ );
638
+ expect(at(mainLine(minimalInput({ otherTaxableIncome: { ratePercent: 100 } })), 949, 5)).toBe(
639
+ '10000',
640
+ );
641
+ });
642
+
643
+ it('normalizes the text members', () => {
644
+ const record = mainRecord(
645
+ minimalInput({
646
+ otherTaxableIncome: { source: ' דמי\u00A0 שכירות ' },
647
+ capitalGainsSummary: { reasons: { other: true, otherText: ' ' } },
648
+ }),
649
+ );
650
+ expect(record.values['otherTaxableIncome.source']).toBe('דמי שכירות');
651
+ expect(record.values).not.toHaveProperty(['capitalGainsSummary.reasons.otherText']);
652
+ });
653
+
654
+ it('qualifyingCompany.amortizationAmount 0 is kept and written as "0" (SPEC §15 A-21)', () => {
655
+ const input = minimalInput({
656
+ qualifyingCompany: { amortizationClaimed: true, amortizationAmount: 0 },
657
+ });
658
+ const record = mainRecord(input);
659
+ expect(record.values['qualifyingCompany.amortizationAmount']).toBe(0);
660
+ expect(record.paths['qualifyingCompany.amortizationAmount']).toBe(
661
+ 'qualifyingCompany.amortizationAmount',
662
+ );
663
+ expect(at(mainLine(input), 1091, 12)).toBe('0'.padStart(12));
664
+ });
665
+
666
+ it.each([
667
+ ['purchased', 1065],
668
+ ['amortizationClaimed', 1090],
669
+ ] as const)(
670
+ 'qualifyingCompany.%s is yes/no at %i: 1, 2, and 0 when absent',
671
+ (member, position) => {
672
+ const key = `qualifyingCompany.${member}`;
673
+ for (const [value, encoded] of [
674
+ [true, '1'],
675
+ [false, '2'],
676
+ [undefined, '0'],
677
+ ] as const) {
678
+ const input = minimalInput({ qualifyingCompany: { [member]: value } });
679
+ const record = mainRecord(input);
680
+ expect(record.values[key]).toBe(value);
681
+ expect(record.paths[key]).toBe(value === undefined ? undefined : key);
682
+ expect(at(mainLine(input), position, 1)).toBe(encoded);
683
+ }
684
+ },
685
+ );
686
+
687
+ it('writes the absent value for every member when the groups are absent', () => {
688
+ const record = mainRecord();
689
+ for (const prefix of [
690
+ 'otherTaxableIncome.',
691
+ 'attachments.',
692
+ 'capitalGainsSummary.',
693
+ 'qualifyingCompany.',
694
+ ]) {
695
+ expect(Object.keys(record.values).filter(key => key.startsWith(prefix))).toEqual([]);
696
+ }
697
+ const line = mainLine(minimalInput());
698
+ expect(at(line, 887, 50)).toBe(' '.repeat(50));
699
+ expect(at(line, 937, 12)).toBe('0'.repeat(12));
700
+ expect(at(line, 949, 5)).toBe(' '.repeat(5));
701
+ expect(at(line, 954, 10)).toBe('0'.repeat(10));
702
+ expect(at(line, 964, 4)).toBe('0000');
703
+ expect(at(line, 968, 50)).toBe(' '.repeat(50));
704
+ expect(at(line, 1065, 1)).toBe('0');
705
+ expect(at(line, 1066, 24)).toBe('0'.repeat(24));
706
+ expect(at(line, 1090, 1)).toBe('0');
707
+ expect(at(line, 1091, 12)).toBe(' '.repeat(12));
708
+ });
709
+
710
+ it('writes 0 for false capital-gains reasons', () => {
711
+ const input = minimalInput({
712
+ capitalGainsSummary: {
713
+ reasons: {
714
+ lossOrNoGain: false,
715
+ overFiveImprovementBalances: false,
716
+ over14Appendices: false,
717
+ other: false,
718
+ },
719
+ },
720
+ });
721
+ expect(at(mainLine(input), 964, 4)).toBe('0000');
722
+ });
723
+
724
+ describe('833 has capital-gains appendix (SPEC §7.4)', () => {
725
+ it.each([true, false, undefined])(
726
+ 'untransmittedCount > 0 makes 833 = yes (hasCapitalGainsAppendix %s)',
727
+ hasCapitalGainsAppendix => {
728
+ const input = minimalInput({
729
+ declarations: { hasCapitalGainsAppendix },
730
+ capitalGainsSummary: { untransmittedCount: 3 },
731
+ });
732
+ const record = mainRecord(input);
733
+ expect(record.values['declarations.hasCapitalGainsAppendix']).toBe(true);
734
+ expect(at(mainLine(input), 833, 1)).toBe('1');
735
+ },
736
+ );
737
+
738
+ it('untransmittedCount 0 leaves 833 = no', () => {
739
+ const input = minimalInput({ capitalGainsSummary: { untransmittedCount: 0 } });
740
+ expect(mainRecord(input).values['declarations.hasCapitalGainsAppendix']).toBe(false);
741
+ expect(at(mainLine(input), 833, 1)).toBe('2');
742
+ });
743
+ });
744
+
745
+ it('raises no notices for the full main input', () => {
746
+ expect(normalizeReport(fullMainInput(), LAYOUT, OPTIONS).notices).toEqual([]);
747
+ });
748
+ });
749
+
750
+ describe('normalizeReport: record 1000 derived codes (SPEC §7.4)', () => {
751
+ const BANK_ACCOUNT = { bank: '12', branch: '345', account: '678' };
752
+
753
+ it('bankAccount → 277 = account, 278 = bank then branch, 280 = 1', () => {
754
+ const input = minimalInput({ bankAccount: BANK_ACCOUNT });
755
+ const record = mainRecord(input);
756
+ expect(record.codes.get('277')).toBe(678);
757
+ expect(record.codes.get('278')).toBe(12_345);
758
+ expect(record.codes.get('280')).toBe(1);
759
+ expect(record.paths['code:277']).toBe('');
760
+ expect(record.paths['code:278']).toBe('');
761
+ expect(record.paths['code:280']).toBe('');
762
+ // 1000@2185: the code-amount section, in ascending code order after 273 = 9.
763
+ expect(mainLine(input).slice(2184)).toContain('2739' + '277000000000678' + '27812345' + '2801');
764
+ expect(normalizeReport(input, LAYOUT, OPTIONS).notices).toEqual([]);
765
+ });
766
+
767
+ it('keeps the leading zeros of the bank in 278 (bank 2 digits, branch 3 digits)', () => {
768
+ const input = minimalInput({
769
+ bankAccount: { bank: '01', branch: '002', account: '000000003' },
770
+ });
771
+ expect(mainRecord(input).codes.get('278')).toBe(1002);
772
+ expect(mainRecord(input).codes.get('277')).toBe(3);
773
+ expect(mainLine(input).slice(2184)).toContain('27801002');
774
+ });
775
+
776
+ it('writes no bank codes without bankAccount', () => {
777
+ const record = mainRecord();
778
+ expect(['277', '278', '280'].filter(code => record.codes.has(code))).toEqual([]);
779
+ });
780
+
781
+ it.each([
782
+ ['bank', { bank: '1' }, 'bankAccount.bank'],
783
+ ['bank', { bank: '123' }, 'bankAccount.bank'],
784
+ ['branch', { branch: '34' }, 'bankAccount.branch'],
785
+ ['branch', { branch: '3a5' }, 'bankAccount.branch'],
786
+ ['account', { account: '' }, 'bankAccount.account'],
787
+ ['account', { account: '1234567890' }, 'bankAccount.account'],
788
+ ])(
789
+ 'a malformed %s (%o) raises main.bankAccount.format at %s and writes no bank codes',
790
+ (_, overrides, path) => {
791
+ const input = minimalInput({ bankAccount: { ...BANK_ACCOUNT, ...overrides } });
792
+ const report = normalizeReport(input, LAYOUT, OPTIONS);
793
+ expect(report.notices).toEqual([
794
+ expect.objectContaining({
795
+ ruleId: 'main.bankAccount.format',
796
+ severity: 'error',
797
+ path,
798
+ recordType: '1000',
799
+ recordIndex: 0,
800
+ }),
801
+ ]);
802
+ const record = report.records[0];
803
+ expect(['277', '278', '280'].filter(code => record?.codes.has(code))).toEqual([]);
804
+ },
805
+ );
806
+
807
+ it.each([
808
+ ['obliged', 8],
809
+ ['notObliged', 9],
810
+ ] as const)('form6111Obligation %s → 297 = %i', (form6111Obligation, expected) => {
811
+ const input = minimalInput({ declarations: { form6111Obligation } });
812
+ const record = mainRecord(input);
813
+ expect(record.codes.get('297')).toBe(expected);
814
+ expect(record.paths['code:297']).toBe('');
815
+ expect(mainLine(input).slice(2184)).toContain(`297${expected}`);
816
+ });
817
+
818
+ it.each(['notRelevant', undefined] as const)(
819
+ 'form6111Obligation %s → no 297',
820
+ form6111Obligation => {
821
+ expect(
822
+ mainRecord(minimalInput({ declarations: { form6111Obligation } })).codes.has('297'),
823
+ ).toBe(false);
824
+ },
825
+ );
826
+
827
+ it('capitalGainsSummary.untransmittedCount 3 → 028 = 3', () => {
828
+ const input = minimalInput({ capitalGainsSummary: { untransmittedCount: 3 } });
829
+ const record = mainRecord(input);
830
+ expect(record.codes.get('028')).toBe(3);
831
+ expect(record.paths['code:028']).toBe('');
832
+ expect(mainLine(input).slice(2184)).toContain('02803');
833
+ });
834
+
835
+ it.each([0, undefined])('untransmittedCount %s → no 028', untransmittedCount => {
836
+ const input = minimalInput({ capitalGainsSummary: { untransmittedCount } });
837
+ expect(mainRecord(input).codes.has('028')).toBe(false);
838
+ });
839
+ });