@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.
- package/.bob/cjs/api/generate.d.ts +44 -0
- package/.bob/cjs/api/generate.js +115 -0
- package/.bob/cjs/api/parse.d.ts +28 -0
- package/.bob/cjs/api/parse.js +38 -0
- package/.bob/cjs/api/response.d.ts +24 -0
- package/.bob/cjs/api/response.js +75 -0
- package/.bob/cjs/api/validate.d.ts +16 -0
- package/.bob/cjs/api/validate.js +15 -0
- package/.bob/cjs/codec/boolean.d.ts +7 -0
- package/.bob/cjs/codec/boolean.js +49 -0
- package/.bob/cjs/codec/date.d.ts +6 -0
- package/.bob/cjs/codec/date.js +68 -0
- package/.bob/cjs/codec/enum.d.ts +4 -0
- package/.bob/cjs/codec/enum.js +26 -0
- package/.bob/cjs/codec/numeric.d.ts +56 -0
- package/.bob/cjs/codec/numeric.js +186 -0
- package/.bob/cjs/codec/padding.d.ts +10 -0
- package/.bob/cjs/codec/padding.js +26 -0
- package/.bob/cjs/codec/percent.d.ts +6 -0
- package/.bob/cjs/codec/percent.js +33 -0
- package/.bob/cjs/codec/phone.d.ts +4 -0
- package/.bob/cjs/codec/phone.js +48 -0
- package/.bob/cjs/codec/record.d.ts +18 -0
- package/.bob/cjs/codec/record.js +176 -0
- package/.bob/cjs/codec/registry.d.ts +8 -0
- package/.bob/cjs/codec/registry.js +27 -0
- package/.bob/cjs/codec/sections.d.ts +41 -0
- package/.bob/cjs/codec/sections.js +177 -0
- package/.bob/cjs/codec/text.d.ts +5 -0
- package/.bob/cjs/codec/text.js +29 -0
- package/.bob/cjs/codec/types.d.ts +36 -0
- package/.bob/cjs/codec/types.js +16 -0
- package/.bob/cjs/codec/windows1255.d.ts +9 -0
- package/.bob/cjs/codec/windows1255.js +38 -0
- package/.bob/cjs/errors.d.ts +32 -0
- package/.bob/cjs/errors.js +103 -0
- package/.bob/cjs/file/assemble.d.ts +17 -0
- package/.bob/cjs/file/assemble.js +28 -0
- package/.bob/cjs/file/control.d.ts +13 -0
- package/.bob/cjs/file/control.js +45 -0
- package/.bob/cjs/file/parse.d.ts +18 -0
- package/.bob/cjs/file/parse.js +478 -0
- package/.bob/cjs/file/split.d.ts +17 -0
- package/.bob/cjs/file/split.js +71 -0
- package/.bob/cjs/index.d.ts +16 -0
- package/.bob/cjs/index.js +28 -0
- package/.bob/cjs/layout/2024/layout.generated.d.ts +6919 -0
- package/.bob/cjs/layout/2024/layout.generated.js +7224 -0
- package/.bob/cjs/layout/2025/index.d.ts +6 -0
- package/.bob/cjs/layout/2025/index.js +10 -0
- package/.bob/cjs/layout/capital-gains.d.ts +9 -0
- package/.bob/cjs/layout/capital-gains.js +15 -0
- package/.bob/cjs/layout/countries.d.ts +5 -0
- package/.bob/cjs/layout/countries.js +10 -0
- package/.bob/cjs/layout/freeze.d.ts +5 -0
- package/.bob/cjs/layout/freeze.js +16 -0
- package/.bob/cjs/layout/registry.d.ts +10 -0
- package/.bob/cjs/layout/registry.js +32 -0
- package/.bob/cjs/layout/types.d.ts +82 -0
- package/.bob/cjs/layout/types.js +35 -0
- package/.bob/cjs/model/codes.generated.d.ts +48 -0
- package/.bob/cjs/model/codes.generated.js +628 -0
- package/.bob/cjs/model/index.d.ts +3 -0
- package/.bob/cjs/model/index.js +5 -0
- package/.bob/cjs/model/input.d.ts +543 -0
- package/.bob/cjs/model/input.js +24 -0
- package/.bob/cjs/model/normalized.d.ts +43 -0
- package/.bob/cjs/model/normalized.js +0 -0
- package/.bob/cjs/model/options.d.ts +14 -0
- package/.bob/cjs/model/options.js +0 -0
- package/.bob/cjs/model/schema.d.ts +594 -0
- package/.bob/cjs/model/schema.js +339 -0
- package/.bob/cjs/normalize/canonical.d.ts +13 -0
- package/.bob/cjs/normalize/canonical.js +288 -0
- package/.bob/cjs/normalize/capital-gains/assets.d.ts +37 -0
- package/.bob/cjs/normalize/capital-gains/assets.js +94 -0
- package/.bob/cjs/normalize/capital-gains/index.d.ts +61 -0
- package/.bob/cjs/normalize/capital-gains/index.js +149 -0
- package/.bob/cjs/normalize/capital-gains/no-withholding.d.ts +18 -0
- package/.bob/cjs/normalize/capital-gains/no-withholding.js +36 -0
- package/.bob/cjs/normalize/capital-gains/other.d.ts +54 -0
- package/.bob/cjs/normalize/capital-gains/other.js +122 -0
- package/.bob/cjs/normalize/capital-gains/section6.d.ts +7 -0
- package/.bob/cjs/normalize/capital-gains/section6.js +13 -0
- package/.bob/cjs/normalize/capital-gains/securities.d.ts +26 -0
- package/.bob/cjs/normalize/capital-gains/securities.js +58 -0
- package/.bob/cjs/normalize/denormalize.d.ts +42 -0
- package/.bob/cjs/normalize/denormalize.js +359 -0
- package/.bob/cjs/normalize/derive.d.ts +57 -0
- package/.bob/cjs/normalize/derive.js +111 -0
- package/.bob/cjs/normalize/enums.d.ts +58 -0
- package/.bob/cjs/normalize/enums.js +69 -0
- package/.bob/cjs/normalize/fields.d.ts +28 -0
- package/.bob/cjs/normalize/fields.js +86 -0
- package/.bob/cjs/normalize/foreign.d.ts +22 -0
- package/.bob/cjs/normalize/foreign.js +85 -0
- package/.bob/cjs/normalize/main.d.ts +24 -0
- package/.bob/cjs/normalize/main.js +208 -0
- package/.bob/cjs/normalize/paths.d.ts +74 -0
- package/.bob/cjs/normalize/paths.js +169 -0
- package/.bob/cjs/normalize/phone.d.ts +12 -0
- package/.bob/cjs/normalize/phone.js +35 -0
- package/.bob/cjs/normalize/rd-investments.d.ts +10 -0
- package/.bob/cjs/normalize/rd-investments.js +25 -0
- package/.bob/cjs/normalize/related-companies.d.ts +10 -0
- package/.bob/cjs/normalize/related-companies.js +25 -0
- package/.bob/cjs/normalize/report.d.ts +9 -0
- package/.bob/cjs/normalize/report.js +53 -0
- package/.bob/cjs/normalize/shareholders.d.ts +10 -0
- package/.bob/cjs/normalize/shareholders.js +30 -0
- package/.bob/cjs/normalize/text.d.ts +11 -0
- package/.bob/cjs/normalize/text.js +41 -0
- package/.bob/cjs/normalize/today.d.ts +4 -0
- package/.bob/cjs/normalize/today.js +14 -0
- package/.bob/cjs/pipeline.d.ts +13 -0
- package/.bob/cjs/pipeline.js +37 -0
- package/.bob/cjs/response/codes.d.ts +2 -0
- package/.bob/cjs/response/codes.js +31 -0
- package/.bob/cjs/validate/capital-gains-rules.d.ts +6 -0
- package/.bob/cjs/validate/capital-gains-rules.js +162 -0
- package/.bob/cjs/validate/check-digit.d.ts +10 -0
- package/.bob/cjs/validate/check-digit.js +26 -0
- package/.bob/cjs/validate/engine.d.ts +5 -0
- package/.bob/cjs/validate/engine.js +35 -0
- package/.bob/cjs/validate/field-rules.d.ts +4 -0
- package/.bob/cjs/validate/field-rules.js +331 -0
- package/.bob/cjs/validate/foreign-rules.d.ts +6 -0
- package/.bob/cjs/validate/foreign-rules.js +171 -0
- package/.bob/cjs/validate/issue.d.ts +51 -0
- package/.bob/cjs/validate/issue.js +78 -0
- package/.bob/cjs/validate/main-rules.d.ts +24 -0
- package/.bob/cjs/validate/main-rules.js +425 -0
- package/.bob/cjs/validate/parse-rules.d.ts +31 -0
- package/.bob/cjs/validate/parse-rules.js +114 -0
- package/.bob/cjs/validate/rules.d.ts +746 -0
- package/.bob/cjs/validate/rules.js +680 -0
- package/.bob/cjs/validate/shape.d.ts +19 -0
- package/.bob/cjs/validate/shape.js +231 -0
- package/.bob/cjs/validate/shareholder-rules.d.ts +6 -0
- package/.bob/cjs/validate/shareholder-rules.js +83 -0
- package/.bob/cjs/validate/structure-rules.d.ts +26 -0
- package/.bob/cjs/validate/structure-rules.js +130 -0
- package/.bob/esm/api/generate.d.ts +44 -0
- package/.bob/esm/api/generate.js +111 -0
- package/.bob/esm/api/parse.d.ts +28 -0
- package/.bob/esm/api/parse.js +34 -0
- package/.bob/esm/api/response.d.ts +24 -0
- package/.bob/esm/api/response.js +72 -0
- package/.bob/esm/api/validate.d.ts +16 -0
- package/.bob/esm/api/validate.js +11 -0
- package/.bob/esm/codec/boolean.d.ts +7 -0
- package/.bob/esm/codec/boolean.js +46 -0
- package/.bob/esm/codec/date.d.ts +6 -0
- package/.bob/esm/codec/date.js +64 -0
- package/.bob/esm/codec/enum.d.ts +4 -0
- package/.bob/esm/codec/enum.js +23 -0
- package/.bob/esm/codec/numeric.d.ts +56 -0
- package/.bob/esm/codec/numeric.js +175 -0
- package/.bob/esm/codec/padding.d.ts +10 -0
- package/.bob/esm/codec/padding.js +21 -0
- package/.bob/esm/codec/percent.d.ts +6 -0
- package/.bob/esm/codec/percent.js +30 -0
- package/.bob/esm/codec/phone.d.ts +4 -0
- package/.bob/esm/codec/phone.js +45 -0
- package/.bob/esm/codec/record.d.ts +18 -0
- package/.bob/esm/codec/record.js +172 -0
- package/.bob/esm/codec/registry.d.ts +8 -0
- package/.bob/esm/codec/registry.js +23 -0
- package/.bob/esm/codec/sections.d.ts +41 -0
- package/.bob/esm/codec/sections.js +170 -0
- package/.bob/esm/codec/text.d.ts +5 -0
- package/.bob/esm/codec/text.js +26 -0
- package/.bob/esm/codec/types.d.ts +36 -0
- package/.bob/esm/codec/types.js +12 -0
- package/.bob/esm/codec/windows1255.d.ts +9 -0
- package/.bob/esm/codec/windows1255.js +32 -0
- package/.bob/esm/errors.d.ts +32 -0
- package/.bob/esm/errors.js +94 -0
- package/.bob/esm/file/assemble.d.ts +17 -0
- package/.bob/esm/file/assemble.js +25 -0
- package/.bob/esm/file/control.d.ts +13 -0
- package/.bob/esm/file/control.js +41 -0
- package/.bob/esm/file/parse.d.ts +18 -0
- package/.bob/esm/file/parse.js +474 -0
- package/.bob/esm/file/split.d.ts +17 -0
- package/.bob/esm/file/split.js +68 -0
- package/.bob/esm/index.d.ts +16 -0
- package/.bob/esm/index.js +11 -0
- package/.bob/esm/layout/2024/layout.generated.d.ts +6919 -0
- package/.bob/esm/layout/2024/layout.generated.js +7221 -0
- package/.bob/esm/layout/2025/index.d.ts +6 -0
- package/.bob/esm/layout/2025/index.js +7 -0
- package/.bob/esm/layout/capital-gains.d.ts +9 -0
- package/.bob/esm/layout/capital-gains.js +11 -0
- package/.bob/esm/layout/countries.d.ts +5 -0
- package/.bob/esm/layout/countries.js +7 -0
- package/.bob/esm/layout/freeze.d.ts +5 -0
- package/.bob/esm/layout/freeze.js +13 -0
- package/.bob/esm/layout/registry.d.ts +10 -0
- package/.bob/esm/layout/registry.js +27 -0
- package/.bob/esm/layout/types.d.ts +82 -0
- package/.bob/esm/layout/types.js +32 -0
- package/.bob/esm/model/codes.generated.d.ts +48 -0
- package/.bob/esm/model/codes.generated.js +625 -0
- package/.bob/esm/model/index.d.ts +3 -0
- package/.bob/esm/model/index.js +2 -0
- package/.bob/esm/model/input.d.ts +543 -0
- package/.bob/esm/model/input.js +21 -0
- package/.bob/esm/model/normalized.d.ts +43 -0
- package/.bob/esm/model/normalized.js +0 -0
- package/.bob/esm/model/options.d.ts +14 -0
- package/.bob/esm/model/options.js +0 -0
- package/.bob/esm/model/schema.d.ts +594 -0
- package/.bob/esm/model/schema.js +335 -0
- package/.bob/esm/normalize/canonical.d.ts +13 -0
- package/.bob/esm/normalize/canonical.js +285 -0
- package/.bob/esm/normalize/capital-gains/assets.d.ts +37 -0
- package/.bob/esm/normalize/capital-gains/assets.js +87 -0
- package/.bob/esm/normalize/capital-gains/index.d.ts +61 -0
- package/.bob/esm/normalize/capital-gains/index.js +142 -0
- package/.bob/esm/normalize/capital-gains/no-withholding.d.ts +18 -0
- package/.bob/esm/normalize/capital-gains/no-withholding.js +31 -0
- package/.bob/esm/normalize/capital-gains/other.d.ts +54 -0
- package/.bob/esm/normalize/capital-gains/other.js +112 -0
- package/.bob/esm/normalize/capital-gains/section6.d.ts +7 -0
- package/.bob/esm/normalize/capital-gains/section6.js +9 -0
- package/.bob/esm/normalize/capital-gains/securities.d.ts +26 -0
- package/.bob/esm/normalize/capital-gains/securities.js +52 -0
- package/.bob/esm/normalize/denormalize.d.ts +42 -0
- package/.bob/esm/normalize/denormalize.js +354 -0
- package/.bob/esm/normalize/derive.d.ts +57 -0
- package/.bob/esm/normalize/derive.js +99 -0
- package/.bob/esm/normalize/enums.d.ts +58 -0
- package/.bob/esm/normalize/enums.js +64 -0
- package/.bob/esm/normalize/fields.d.ts +28 -0
- package/.bob/esm/normalize/fields.js +81 -0
- package/.bob/esm/normalize/foreign.d.ts +22 -0
- package/.bob/esm/normalize/foreign.js +81 -0
- package/.bob/esm/normalize/main.d.ts +24 -0
- package/.bob/esm/normalize/main.js +204 -0
- package/.bob/esm/normalize/paths.d.ts +74 -0
- package/.bob/esm/normalize/paths.js +161 -0
- package/.bob/esm/normalize/phone.d.ts +12 -0
- package/.bob/esm/normalize/phone.js +32 -0
- package/.bob/esm/normalize/rd-investments.d.ts +10 -0
- package/.bob/esm/normalize/rd-investments.js +22 -0
- package/.bob/esm/normalize/related-companies.d.ts +10 -0
- package/.bob/esm/normalize/related-companies.js +22 -0
- package/.bob/esm/normalize/report.d.ts +9 -0
- package/.bob/esm/normalize/report.js +50 -0
- package/.bob/esm/normalize/shareholders.d.ts +10 -0
- package/.bob/esm/normalize/shareholders.js +27 -0
- package/.bob/esm/normalize/text.d.ts +11 -0
- package/.bob/esm/normalize/text.js +37 -0
- package/.bob/esm/normalize/today.d.ts +4 -0
- package/.bob/esm/normalize/today.js +11 -0
- package/.bob/esm/pipeline.d.ts +13 -0
- package/.bob/esm/pipeline.js +34 -0
- package/.bob/esm/response/codes.d.ts +2 -0
- package/.bob/esm/response/codes.js +28 -0
- package/.bob/esm/validate/capital-gains-rules.d.ts +6 -0
- package/.bob/esm/validate/capital-gains-rules.js +159 -0
- package/.bob/esm/validate/check-digit.d.ts +10 -0
- package/.bob/esm/validate/check-digit.js +23 -0
- package/.bob/esm/validate/engine.d.ts +5 -0
- package/.bob/esm/validate/engine.js +32 -0
- package/.bob/esm/validate/field-rules.d.ts +4 -0
- package/.bob/esm/validate/field-rules.js +328 -0
- package/.bob/esm/validate/foreign-rules.d.ts +6 -0
- package/.bob/esm/validate/foreign-rules.js +168 -0
- package/.bob/esm/validate/issue.d.ts +51 -0
- package/.bob/esm/validate/issue.js +72 -0
- package/.bob/esm/validate/main-rules.d.ts +24 -0
- package/.bob/esm/validate/main-rules.js +420 -0
- package/.bob/esm/validate/parse-rules.d.ts +31 -0
- package/.bob/esm/validate/parse-rules.js +110 -0
- package/.bob/esm/validate/rules.d.ts +746 -0
- package/.bob/esm/validate/rules.js +676 -0
- package/.bob/esm/validate/shape.d.ts +19 -0
- package/.bob/esm/validate/shape.js +227 -0
- package/.bob/esm/validate/shareholder-rules.d.ts +6 -0
- package/.bob/esm/validate/shareholder-rules.js +80 -0
- package/.bob/esm/validate/structure-rules.d.ts +26 -0
- package/.bob/esm/validate/structure-rules.js +122 -0
- package/.bob/tsconfig.tsbuildinfo +1 -0
- package/.gitattributes +1 -0
- package/CLAUDE.md +39 -0
- package/README.md +337 -0
- package/dist/cjs/index.js +28 -0
- package/dist/esm/index.js +11 -0
- package/documentation/IMPLEMENTATION_PLAN.md +2258 -0
- package/documentation/SPEC.md +1803 -0
- package/documentation/layout/2024/codes.csv +261 -0
- package/documentation/layout/2024/countries.csv +256 -0
- package/documentation/layout/2024/fields.csv +271 -0
- package/documentation/layout/2024/records.csv +18 -0
- package/documentation/layout/README.md +87 -0
- package/documentation/specifications/1214-2024.pdf +0 -0
- package/documentation/tools/extract_layout.py +191 -0
- package/package.json +77 -0
- package/scripts/generate-layout.ts +23 -0
- package/scripts/layout/csv.ts +111 -0
- package/scripts/layout/derived-codes.ts +12 -0
- package/scripts/layout/render.ts +364 -0
- package/scripts/layout/sources.ts +51 -0
- package/scripts/layout/values.ts +42 -0
- package/scripts/render-rules-table.ts +66 -0
- package/src/api/generate.ts +169 -0
- package/src/api/parse.ts +58 -0
- package/src/api/response.ts +110 -0
- package/src/api/validate.ts +26 -0
- package/src/codec/boolean.ts +62 -0
- package/src/codec/date.ts +75 -0
- package/src/codec/enum.ts +28 -0
- package/src/codec/numeric.ts +208 -0
- package/src/codec/padding.ts +33 -0
- package/src/codec/percent.ts +35 -0
- package/src/codec/phone.ts +54 -0
- package/src/codec/record.ts +206 -0
- package/src/codec/registry.ts +27 -0
- package/src/codec/sections.ts +208 -0
- package/src/codec/text.ts +31 -0
- package/src/codec/types.ts +47 -0
- package/src/codec/windows1255.ts +38 -0
- package/src/errors.ts +114 -0
- package/src/file/assemble.ts +42 -0
- package/src/file/control.ts +59 -0
- package/src/file/parse.ts +620 -0
- package/src/file/split.ts +86 -0
- package/src/index.ts +70 -0
- package/src/layout/2024/layout.generated.ts +7238 -0
- package/src/layout/2025/index.ts +9 -0
- package/src/layout/capital-gains.ts +20 -0
- package/src/layout/countries.ts +7 -0
- package/src/layout/freeze.ts +13 -0
- package/src/layout/registry.ts +33 -0
- package/src/layout/types.ts +134 -0
- package/src/model/codes.generated.ts +1190 -0
- package/src/model/index.ts +4 -0
- package/src/model/input.ts +594 -0
- package/src/model/normalized.ts +38 -0
- package/src/model/options.ts +17 -0
- package/src/model/schema.ts +381 -0
- package/src/normalize/canonical.ts +374 -0
- package/src/normalize/capital-gains/assets.ts +112 -0
- package/src/normalize/capital-gains/index.ts +212 -0
- package/src/normalize/capital-gains/no-withholding.ts +46 -0
- package/src/normalize/capital-gains/other.ts +153 -0
- package/src/normalize/capital-gains/section6.ts +14 -0
- package/src/normalize/capital-gains/securities.ts +73 -0
- package/src/normalize/denormalize.ts +426 -0
- package/src/normalize/derive.ts +136 -0
- package/src/normalize/enums.ts +87 -0
- package/src/normalize/fields.ts +110 -0
- package/src/normalize/foreign.ts +114 -0
- package/src/normalize/main.ts +284 -0
- package/src/normalize/paths.ts +184 -0
- package/src/normalize/phone.ts +45 -0
- package/src/normalize/rd-investments.ts +38 -0
- package/src/normalize/related-companies.ts +37 -0
- package/src/normalize/report.ts +59 -0
- package/src/normalize/shareholders.ts +42 -0
- package/src/normalize/text.ts +40 -0
- package/src/normalize/today.ts +15 -0
- package/src/pipeline.ts +42 -0
- package/src/response/codes.ts +30 -0
- package/src/validate/capital-gains-rules.ts +199 -0
- package/src/validate/check-digit.ts +25 -0
- package/src/validate/engine.ts +45 -0
- package/src/validate/field-rules.ts +383 -0
- package/src/validate/foreign-rules.ts +274 -0
- package/src/validate/issue.ts +121 -0
- package/src/validate/main-rules.ts +678 -0
- package/src/validate/parse-rules.ts +169 -0
- package/src/validate/rules.ts +747 -0
- package/src/validate/shape.ts +278 -0
- package/src/validate/shareholder-rules.ts +92 -0
- package/src/validate/structure-rules.ts +136 -0
- package/tests/api/batch.test.ts +227 -0
- package/tests/api/exports.test.ts +355 -0
- package/tests/api/generate.test.ts +409 -0
- package/tests/api/parse.test.ts +789 -0
- package/tests/api/response.test.ts +152 -0
- package/tests/api/validate.test.ts +86 -0
- package/tests/codec/numeric.test.ts +325 -0
- package/tests/codec/record.test.ts +318 -0
- package/tests/codec/registry.test.ts +17 -0
- package/tests/codec/sections.test.ts +333 -0
- package/tests/codec/text.test.ts +454 -0
- package/tests/codec/windows1255.test.ts +46 -0
- package/tests/docs/readme.test.ts +69 -0
- package/tests/edge-cases.test.ts +359 -0
- package/tests/errors.test.ts +138 -0
- package/tests/file/assemble.test.ts +188 -0
- package/tests/file/split.test.ts +61 -0
- package/tests/fixtures/builders.ts +512 -0
- package/tests/fixtures/files.ts +78 -0
- package/tests/fixtures/golden/README.md +37 -0
- package/tests/fixtures/golden/VERIFICATION.md +72 -0
- package/tests/fixtures/golden/batch-50.input.ts +92 -0
- package/tests/fixtures/golden/batch-50.opcn +150 -0
- package/tests/fixtures/golden/capital-gains-max.input.ts +177 -0
- package/tests/fixtures/golden/capital-gains-max.opcn +17 -0
- package/tests/fixtures/golden/cg-27.input.ts +63 -0
- package/tests/fixtures/golden/cg-27.opcn +4 -0
- package/tests/fixtures/golden/cg-50.input.ts +59 -0
- package/tests/fixtures/golden/cg-50.opcn +4 -0
- package/tests/fixtures/golden/cg-51.input.ts +60 -0
- package/tests/fixtures/golden/cg-51.opcn +4 -0
- package/tests/fixtures/golden/cg-54.input.ts +53 -0
- package/tests/fixtures/golden/cg-54.opcn +4 -0
- package/tests/fixtures/golden/cg-60.input.ts +77 -0
- package/tests/fixtures/golden/cg-60.opcn +4 -0
- package/tests/fixtures/golden/cg-63.input.ts +51 -0
- package/tests/fixtures/golden/cg-63.opcn +4 -0
- package/tests/fixtures/golden/cg-64.input.ts +62 -0
- package/tests/fixtures/golden/cg-64.opcn +4 -0
- package/tests/fixtures/golden/cg-65.input.ts +79 -0
- package/tests/fixtures/golden/cg-65.opcn +4 -0
- package/tests/fixtures/golden/cg-66.input.ts +53 -0
- package/tests/fixtures/golden/cg-66.opcn +4 -0
- package/tests/fixtures/golden/cg-77.input.ts +109 -0
- package/tests/fixtures/golden/cg-77.opcn +4 -0
- package/tests/fixtures/golden/foreign.input.ts +202 -0
- package/tests/fixtures/golden/foreign.opcn +27 -0
- package/tests/fixtures/golden/hebrew-edge.input.ts +90 -0
- package/tests/fixtures/golden/hebrew-edge.opcn +8 -0
- package/tests/fixtures/golden/kibbutz.input.ts +31 -0
- package/tests/fixtures/golden/kibbutz.opcn +2 -0
- package/tests/fixtures/golden/main-full.input.ts +780 -0
- package/tests/fixtures/golden/main-full.opcn +101 -0
- package/tests/fixtures/golden/minimal.input.ts +37 -0
- package/tests/fixtures/golden/minimal.opcn +3 -0
- package/tests/fixtures/golden/related-and-rd.input.ts +59 -0
- package/tests/fixtures/golden/related-and-rd.opcn +11 -0
- package/tests/fixtures/random.ts +843 -0
- package/tests/golden/fixtures.test.ts +627 -0
- package/tests/golden/golden.test.ts +95 -0
- package/tests/helpers/coverage.ts +18 -0
- package/tests/helpers/sample-values.ts +114 -0
- package/tests/layout/codegen-sync.test.ts +19 -0
- package/tests/layout/integrity.test.ts +232 -0
- package/tests/layout/registry.test.ts +98 -0
- package/tests/model/code-unions.test.ts +91 -0
- package/tests/model/schema.test.ts +1031 -0
- package/tests/normalize/canonical.test.ts +728 -0
- package/tests/normalize/capital-gains.test.ts +1850 -0
- package/tests/normalize/coverage.test.ts +88 -0
- package/tests/normalize/denormalize.test.ts +318 -0
- package/tests/normalize/enums.test.ts +118 -0
- package/tests/normalize/foreign.test.ts +273 -0
- package/tests/normalize/main.test.ts +839 -0
- package/tests/normalize/paths.test.ts +257 -0
- package/tests/normalize/rd-investments.test.ts +99 -0
- package/tests/normalize/related-companies.test.ts +106 -0
- package/tests/normalize/shareholders.test.ts +117 -0
- package/tests/normalize/text.test.ts +86 -0
- package/tests/pipeline.test.ts +96 -0
- package/tests/roundtrip/determinism.test.ts +207 -0
- package/tests/roundtrip/property.test.ts +126 -0
- package/tests/roundtrip/roundtrip.test.ts +573 -0
- package/tests/rules/cases.ts +873 -0
- package/tests/rules/rules.test.ts +69 -0
- package/tests/rules/spec-sync.test.ts +80 -0
- package/tests/scripts/csv.test.ts +78 -0
- package/tests/scripts/values.test.ts +80 -0
- package/tests/validate/capital-gains-rules.test.ts +307 -0
- package/tests/validate/check-digit.test.ts +42 -0
- package/tests/validate/field-rules.test.ts +867 -0
- package/tests/validate/foreign-rules.test.ts +255 -0
- package/tests/validate/issue.test.ts +96 -0
- package/tests/validate/main-rules.test.ts +761 -0
- package/tests/validate/parse-rules.test.ts +293 -0
- package/tests/validate/shareholder-rules.test.ts +143 -0
- package/tsconfig.json +10 -0
- package/tsconfig.typecheck.json +9 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2 of SPEC §9.2: code-map keys that are unknown or derived (input.unknownCode,
|
|
3
|
+
* input.derivedCode), then the strict zod schema, whose issues become input.shape issues.
|
|
4
|
+
*/
|
|
5
|
+
import type { z } from 'zod';
|
|
6
|
+
import { Opcn1214InternalError } from '../errors.js';
|
|
7
|
+
import { capitalGainsRecordType } from '../layout/capital-gains.js';
|
|
8
|
+
import { getLayout } from '../layout/registry.js';
|
|
9
|
+
import type { CodeDef, RecordDef, YearLayout } from '../layout/types.js';
|
|
10
|
+
import type { SupportedTaxYear } from '../model/input.js';
|
|
11
|
+
import { schemaFor } from '../model/schema.js';
|
|
12
|
+
import {
|
|
13
|
+
CAPITAL_GAINS_INPUT_KEYS,
|
|
14
|
+
type CapitalGainsInputSymbol,
|
|
15
|
+
} from '../normalize/capital-gains/index.js';
|
|
16
|
+
import { IMPROVEMENT_SLOTS, improvementCode } from '../normalize/capital-gains/other.js';
|
|
17
|
+
import { DERIVED_MAIN_CODE_SOURCES } from '../normalize/derive.js';
|
|
18
|
+
import { makeIssue, type Issue } from './issue.js';
|
|
19
|
+
|
|
20
|
+
type ZodIssue = z.ZodError['issues'][number];
|
|
21
|
+
|
|
22
|
+
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
23
|
+
|
|
24
|
+
/** A zod path in the SPEC §9.1 grammar: `a.b`, `a[0]`, `amounts["018"]`; '' for the root. */
|
|
25
|
+
function formatPath(path: readonly PropertyKey[]): string {
|
|
26
|
+
let text = '';
|
|
27
|
+
for (const segment of path) {
|
|
28
|
+
if (typeof segment === 'number') {
|
|
29
|
+
text += `[${segment}]`;
|
|
30
|
+
} else {
|
|
31
|
+
const key = String(segment);
|
|
32
|
+
if (IDENTIFIER.test(key)) {
|
|
33
|
+
text += text === '' ? key : `.${key}`;
|
|
34
|
+
} else {
|
|
35
|
+
text += `[${JSON.stringify(key)}]`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return text;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Only defined primitive offending values are carried, never whole objects or arrays. */
|
|
43
|
+
function primitive(value: unknown): { value?: unknown } {
|
|
44
|
+
return value === undefined || (typeof value === 'object' && value !== null) ? {} : { value };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function hasInput(issue: ZodIssue): issue is ZodIssue & { input: unknown } {
|
|
48
|
+
return 'input' in issue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function convert(issue: ZodIssue): Issue[] {
|
|
52
|
+
if (issue.code === 'unrecognized_keys') {
|
|
53
|
+
// One zod issue at the parent lists every unknown key: one input.shape issue per key.
|
|
54
|
+
const parent: unknown = hasInput(issue) ? issue.input : undefined;
|
|
55
|
+
return issue.keys.map(key =>
|
|
56
|
+
makeIssue('input.shape', {
|
|
57
|
+
message: `Unknown property ${JSON.stringify(key)}.`,
|
|
58
|
+
path: formatPath([...issue.path, key]),
|
|
59
|
+
...(typeof parent === 'object' && parent !== null
|
|
60
|
+
? primitive((parent as Record<string, unknown>)[key])
|
|
61
|
+
: {}),
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return [
|
|
66
|
+
makeIssue('input.shape', {
|
|
67
|
+
message: issue.message,
|
|
68
|
+
path: formatPath(issue.path),
|
|
69
|
+
...(hasInput(issue) ? primitive(issue.input) : {}),
|
|
70
|
+
...(issue.code === 'invalid_type' ? { expected: issue.expected } : {}),
|
|
71
|
+
}),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The input.shape issues of a failed parse (SPEC §9.2), paths in the SPEC §9.1 grammar. Offending
|
|
77
|
+
* values are carried when the parse ran with `reportInput: true`.
|
|
78
|
+
*/
|
|
79
|
+
export function zodIssuesToIssues(error: z.ZodError): Issue[] {
|
|
80
|
+
return error.issues.flatMap(convert);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A code map of the input (`amounts`, …) and the record whose codes it holds. */
|
|
84
|
+
interface CodeMap {
|
|
85
|
+
/** Input path of the map, e.g. `amounts`. */
|
|
86
|
+
path: string;
|
|
87
|
+
taxYear: number;
|
|
88
|
+
record: RecordDef;
|
|
89
|
+
/** 0-based index of the record among records of its type, when the map has one record. */
|
|
90
|
+
recordIndex?: number;
|
|
91
|
+
/** The keys the map accepts (default: the codes of `record`) and what they are, for messages. */
|
|
92
|
+
codes?: { defs: readonly CodeDef[]; description: string };
|
|
93
|
+
/** The input properties each derived code of the record comes from (SPEC §7.4). */
|
|
94
|
+
derivedSources: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
98
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Checks the keys of the code map `value` against the codes of `map.record` (SPEC §9.2): a key that
|
|
103
|
+
* is not a code of the record is input.unknownCode, a derived code is input.derivedCode naming the
|
|
104
|
+
* input property that controls it. Returns those issues and the map without the reported keys, so
|
|
105
|
+
* zod does not report them again; a value that is not a plain object is returned unchanged for zod.
|
|
106
|
+
*/
|
|
107
|
+
function scanCodeMap(value: unknown, map: CodeMap): { issues: Issue[]; value: unknown } {
|
|
108
|
+
if (!isPlainObject(value)) {
|
|
109
|
+
return { issues: [], value };
|
|
110
|
+
}
|
|
111
|
+
const accepted = map.codes ?? {
|
|
112
|
+
defs: map.record.codes,
|
|
113
|
+
description: `a code of record ${map.record.type}`,
|
|
114
|
+
};
|
|
115
|
+
const codes = new Map(accepted.defs.map(def => [def.code, def]));
|
|
116
|
+
const issues: Issue[] = [];
|
|
117
|
+
const kept: Record<string, unknown> = {};
|
|
118
|
+
for (const [key, amount] of Object.entries(value)) {
|
|
119
|
+
const def = codes.get(key);
|
|
120
|
+
if (def && !def.derived) {
|
|
121
|
+
kept[key] = amount;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const details = {
|
|
125
|
+
path: `${map.path}[${JSON.stringify(key)}]`,
|
|
126
|
+
recordType: map.record.type,
|
|
127
|
+
...(map.recordIndex === undefined ? {} : { recordIndex: map.recordIndex }),
|
|
128
|
+
code: key,
|
|
129
|
+
...primitive(amount),
|
|
130
|
+
};
|
|
131
|
+
if (def) {
|
|
132
|
+
const sources = map.derivedSources[key];
|
|
133
|
+
if (!sources) {
|
|
134
|
+
throw new Opcn1214InternalError(`Derived code ${key} has no input source`);
|
|
135
|
+
}
|
|
136
|
+
issues.push(
|
|
137
|
+
makeIssue('input.derivedCode', {
|
|
138
|
+
...details,
|
|
139
|
+
message: `Code ${key} is derived from ${sources.join(' and ')} (SPEC §7.4); remove it from ${map.path}.`,
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
} else {
|
|
143
|
+
issues.push(
|
|
144
|
+
makeIssue('input.unknownCode', {
|
|
145
|
+
...details,
|
|
146
|
+
message: `${JSON.stringify(key)} is not ${accepted.description} for tax year ${map.taxYear}.`,
|
|
147
|
+
}),
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { issues, value: kept };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The foreign appendix and the capital-gains appendices but 3077 have no derived codes (§7.4). */
|
|
155
|
+
const NO_DERIVED_CODES: Readonly<Partial<Record<string, readonly string[]>>> = {};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The input properties the derived codes of the appendix at `index` of `capitalGains` come from
|
|
159
|
+
* (SPEC §7.4): 3077 codes 501–505 from the code-50 amounts of improvements 1–5.
|
|
160
|
+
*/
|
|
161
|
+
function capitalGainsDerivedSources(
|
|
162
|
+
symbol: CapitalGainsInputSymbol,
|
|
163
|
+
index: number,
|
|
164
|
+
): Readonly<Partial<Record<string, readonly string[]>>> {
|
|
165
|
+
if (symbol !== 77) {
|
|
166
|
+
return NO_DERIVED_CODES;
|
|
167
|
+
}
|
|
168
|
+
return Object.fromEntries(
|
|
169
|
+
Array.from({ length: IMPROVEMENT_SLOTS }, (_, slot) => [
|
|
170
|
+
improvementCode(slot),
|
|
171
|
+
[`capitalGains[${index}].improvements[${slot}].code50Amount`],
|
|
172
|
+
]),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** True for a `symbol` the input model has an appendix type for (every capital-gains symbol). */
|
|
177
|
+
function isInputSymbol(symbol: unknown): symbol is CapitalGainsInputSymbol {
|
|
178
|
+
return typeof symbol === 'number' && Object.hasOwn(CAPITAL_GAINS_INPUT_KEYS, symbol);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The `amounts` of every capital-gains appendix of `appendices` scanned against the codes of its
|
|
183
|
+
* record type (30xx = 3000 + symbol): their issues, located by the appendix's index among those of
|
|
184
|
+
* its symbol, and a copy of `appendices` with the reported keys removed. Appendices that are not
|
|
185
|
+
* plain objects or have no modelled symbol are left to zod.
|
|
186
|
+
*/
|
|
187
|
+
function scanCapitalGains(
|
|
188
|
+
appendices: readonly unknown[],
|
|
189
|
+
layout: YearLayout,
|
|
190
|
+
): { issues: Issue[]; value: unknown[] } {
|
|
191
|
+
const perSymbol = new Map<CapitalGainsInputSymbol, number>();
|
|
192
|
+
const issues: Issue[] = [];
|
|
193
|
+
const value = appendices.map((appendix, index) => {
|
|
194
|
+
if (!isPlainObject(appendix) || !isInputSymbol(appendix.symbol)) {
|
|
195
|
+
return appendix;
|
|
196
|
+
}
|
|
197
|
+
const recordIndex = perSymbol.get(appendix.symbol) ?? 0;
|
|
198
|
+
perSymbol.set(appendix.symbol, recordIndex + 1);
|
|
199
|
+
const amounts = scanCodeMap(appendix.amounts, {
|
|
200
|
+
path: `capitalGains[${index}].amounts`,
|
|
201
|
+
taxYear: layout.taxYear,
|
|
202
|
+
record: layout.records[capitalGainsRecordType(appendix.symbol)],
|
|
203
|
+
recordIndex,
|
|
204
|
+
derivedSources: capitalGainsDerivedSources(appendix.symbol, index),
|
|
205
|
+
});
|
|
206
|
+
issues.push(...amounts.issues);
|
|
207
|
+
return { ...appendix, amounts: amounts.value };
|
|
208
|
+
});
|
|
209
|
+
return { issues, value };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The code maps of `input` scanned (scanCodeMap): their issues, and a shallow copy of `input` with
|
|
214
|
+
* the reported keys removed. Record 1000 `amounts` and, when `foreignAppendix` is an object, its
|
|
215
|
+
* `amounts` (record 2000) and `countryBreakdown` (records 2200, keyed by the per-country codes of
|
|
216
|
+
* record 2000), and the `amounts` of every capital-gains appendix (scanCapitalGains). Anything that
|
|
217
|
+
* is not a plain object (or an array, for `capitalGains`) is left to zod.
|
|
218
|
+
*/
|
|
219
|
+
function scanCodeMaps(input: unknown, layout: YearLayout): { issues: Issue[]; input: unknown } {
|
|
220
|
+
if (!isPlainObject(input)) {
|
|
221
|
+
return { issues: [], input };
|
|
222
|
+
}
|
|
223
|
+
const amounts = scanCodeMap(input.amounts, {
|
|
224
|
+
path: 'amounts',
|
|
225
|
+
taxYear: layout.taxYear,
|
|
226
|
+
record: layout.records['1000'],
|
|
227
|
+
recordIndex: 0,
|
|
228
|
+
derivedSources: DERIVED_MAIN_CODE_SOURCES,
|
|
229
|
+
});
|
|
230
|
+
const scanned: Record<string, unknown> = { ...input, amounts: amounts.value };
|
|
231
|
+
const issues = [...amounts.issues];
|
|
232
|
+
const appendix = input.foreignAppendix;
|
|
233
|
+
if (isPlainObject(appendix)) {
|
|
234
|
+
const foreign = scanCodeMap(appendix.amounts, {
|
|
235
|
+
path: 'foreignAppendix.amounts',
|
|
236
|
+
taxYear: layout.taxYear,
|
|
237
|
+
record: layout.records['2000'],
|
|
238
|
+
recordIndex: 0,
|
|
239
|
+
derivedSources: NO_DERIVED_CODES,
|
|
240
|
+
});
|
|
241
|
+
issues.push(...foreign.issues);
|
|
242
|
+
const scannedAppendix: Record<string, unknown> = { ...appendix, amounts: foreign.value };
|
|
243
|
+
if (isPlainObject(appendix.countryBreakdown)) {
|
|
244
|
+
// Keyed by the per-country codes of record 2000; none of them is derived.
|
|
245
|
+
const breakdowns = scanCodeMap(appendix.countryBreakdown, {
|
|
246
|
+
path: 'foreignAppendix.countryBreakdown',
|
|
247
|
+
taxYear: layout.taxYear,
|
|
248
|
+
record: layout.records['2200'],
|
|
249
|
+
codes: {
|
|
250
|
+
defs: layout.records['2000'].codes.filter(def => def.perCountryBreakdown),
|
|
251
|
+
description: 'a per-country breakdown code of record 2000',
|
|
252
|
+
},
|
|
253
|
+
derivedSources: NO_DERIVED_CODES,
|
|
254
|
+
});
|
|
255
|
+
issues.push(...breakdowns.issues);
|
|
256
|
+
scannedAppendix.countryBreakdown = breakdowns.value;
|
|
257
|
+
}
|
|
258
|
+
scanned.foreignAppendix = scannedAppendix;
|
|
259
|
+
}
|
|
260
|
+
if (Array.isArray(input.capitalGains)) {
|
|
261
|
+
const appendices = scanCapitalGains(input.capitalGains, layout);
|
|
262
|
+
issues.push(...appendices.issues);
|
|
263
|
+
scanned.capitalGains = appendices.value;
|
|
264
|
+
}
|
|
265
|
+
return { issues, input: scanned };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The shape stage (SPEC §9.2 stage 2) of `input` of a supported `taxYear`: the
|
|
270
|
+
* input.unknownCode / input.derivedCode issues of its code maps, then the input.shape issues of the
|
|
271
|
+
* year's strict schema run on the input without the reported code keys. Offending values are
|
|
272
|
+
* carried. `input` is not changed.
|
|
273
|
+
*/
|
|
274
|
+
export function checkShape(input: unknown, taxYear: SupportedTaxYear): Issue[] {
|
|
275
|
+
const scanned = scanCodeMaps(input, getLayout(taxYear));
|
|
276
|
+
const shape = schemaFor(taxYear).safeParse(scanned.input, { reportInput: true });
|
|
277
|
+
return shape.success ? scanned.issues : [...scanned.issues, ...zodIssuesToIssues(shape.error)];
|
|
278
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shareholder rules (SPEC §9.2 stage 4, §10.4): pure checks over the normalized 1020 records, so
|
|
3
|
+
* they run on validated input and on parsed files alike.
|
|
4
|
+
*/
|
|
5
|
+
import { Opcn1214InternalError } from '../errors.js';
|
|
6
|
+
import type { FieldDef } from '../layout/types.js';
|
|
7
|
+
import type { NormalizedRecord, NormalizedReport } from '../model/normalized.js';
|
|
8
|
+
import { pathFor } from '../normalize/paths.js';
|
|
9
|
+
import { makeIssue, type Issue } from './issue.js';
|
|
10
|
+
|
|
11
|
+
type ReportRule = (report: NormalizedReport) => Issue[];
|
|
12
|
+
|
|
13
|
+
const DIVIDEND_RIGHTS = 'dividendRightsPercent';
|
|
14
|
+
const ID_NUMBER = 'idNumber';
|
|
15
|
+
/** 100.00 percent, in hundredths. */
|
|
16
|
+
const FULL_RIGHTS_HUNDREDTHS = 10_000;
|
|
17
|
+
/** Special shareholder IDs that many shareholders may share (p.22). */
|
|
18
|
+
const SHARED_IDS: ReadonlySet<string> = new Set(['999999964', '999999998']);
|
|
19
|
+
|
|
20
|
+
function shareholderRecords(report: NormalizedReport): NormalizedRecord[] {
|
|
21
|
+
return report.records.filter(record => record.recordType === '1020');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function shareholderField(report: NormalizedReport, key: string): FieldDef {
|
|
25
|
+
const field = report.layout.records['1020'].fields.find(def => def.key === key);
|
|
26
|
+
if (!field) {
|
|
27
|
+
throw new Opcn1214InternalError(`Record 1020 has no field "${key}"`);
|
|
28
|
+
}
|
|
29
|
+
return field;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* shareholders.dividendRights.total: when at least one shareholder states dividend rights, they
|
|
34
|
+
* must total exactly 100 (p.23; SPEC §15 A-15). Summed in hundredths, so 33.33 + 33.33 + 33.34 is
|
|
35
|
+
* exactly 100 despite floating point.
|
|
36
|
+
*/
|
|
37
|
+
function dividendRightsTotal(report: NormalizedReport): Issue[] {
|
|
38
|
+
const stated = shareholderRecords(report)
|
|
39
|
+
.map(record => record.values[DIVIDEND_RIGHTS])
|
|
40
|
+
.filter(value => typeof value === 'number');
|
|
41
|
+
if (stated.length === 0) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const hundredths = stated.reduce((sum, value) => sum + Math.round(value * 100), 0);
|
|
45
|
+
if (hundredths === FULL_RIGHTS_HUNDREDTHS) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const total = hundredths / 100;
|
|
49
|
+
return [
|
|
50
|
+
makeIssue('shareholders.dividendRights.total', {
|
|
51
|
+
message: `The shareholders' dividend rights total ${total}%; they must total 100%.`,
|
|
52
|
+
path: 'shareholders',
|
|
53
|
+
recordType: '1020',
|
|
54
|
+
value: total,
|
|
55
|
+
expected: '100',
|
|
56
|
+
specRef: { page: shareholderField(report, DIVIDEND_RIGHTS).specPage },
|
|
57
|
+
}),
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* shareholders.duplicateId: an idNumber that an earlier shareholder already has, except the shared
|
|
63
|
+
* special IDs. One issue per repeat, at the repeating shareholder.
|
|
64
|
+
*/
|
|
65
|
+
function duplicateId(report: NormalizedReport): Issue[] {
|
|
66
|
+
const field = shareholderField(report, ID_NUMBER);
|
|
67
|
+
const seen = new Set<string>();
|
|
68
|
+
const issues: Issue[] = [];
|
|
69
|
+
for (const record of shareholderRecords(report)) {
|
|
70
|
+
const id = record.values[ID_NUMBER];
|
|
71
|
+
if (typeof id !== 'string' || SHARED_IDS.has(id)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (seen.has(id)) {
|
|
75
|
+
issues.push(
|
|
76
|
+
makeIssue('shareholders.duplicateId', {
|
|
77
|
+
message: `Shareholder ID ${id} appears more than once.`,
|
|
78
|
+
path: pathFor('1020', record.index, ID_NUMBER),
|
|
79
|
+
recordType: '1020',
|
|
80
|
+
recordIndex: record.index,
|
|
81
|
+
field: { position: field.position, length: field.length, nameHe: field.nameHe },
|
|
82
|
+
value: id,
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
seen.add(id);
|
|
87
|
+
}
|
|
88
|
+
return issues;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The shareholder rules of SPEC §10.4. */
|
|
92
|
+
export const SHAREHOLDER_RULES: readonly ReportRule[] = [dividendRightsTotal, duplicateId];
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Structure rules (SPEC §9.2 stage 5, §10.1). */
|
|
2
|
+
import { isCapitalGainsRecordType } from '../layout/capital-gains.js';
|
|
3
|
+
import type { NormalizedReport } from '../model/normalized.js';
|
|
4
|
+
import { makeIssue, type Issue } from './issue.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* struct.mainCodePairs.max: record 1000 holds more code-amount pairs than its section allows (61,
|
|
8
|
+
* p.13), counted after derivations.
|
|
9
|
+
*/
|
|
10
|
+
export function mainCodePairsMax(report: NormalizedReport): Issue[] {
|
|
11
|
+
const max = report.layout.limits.mainCodePairs;
|
|
12
|
+
return report.records
|
|
13
|
+
.filter(record => record.recordType === '1000' && record.codes.size > max)
|
|
14
|
+
.map(record =>
|
|
15
|
+
makeIssue('struct.mainCodePairs.max', {
|
|
16
|
+
message: `Record 1000 has ${record.codes.size} code-amount pairs (derived codes included); at most ${max} are allowed.`,
|
|
17
|
+
path: 'amounts',
|
|
18
|
+
recordType: '1000',
|
|
19
|
+
recordIndex: record.index,
|
|
20
|
+
value: record.codes.size,
|
|
21
|
+
expected: `at most ${max}`,
|
|
22
|
+
specRef: { page: 13 },
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* struct.relatedCompanies.max: more related companies (1010 records) than the layout allows (3,
|
|
29
|
+
* p.2).
|
|
30
|
+
*/
|
|
31
|
+
export function relatedCompaniesMax(report: NormalizedReport): Issue[] {
|
|
32
|
+
const max = report.layout.records['1010'].maxOccurs;
|
|
33
|
+
const count = report.records.filter(record => record.recordType === '1010').length;
|
|
34
|
+
if (count <= max) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
makeIssue('struct.relatedCompanies.max', {
|
|
39
|
+
message: `The report has ${count} related companies; at most ${max} are allowed.`,
|
|
40
|
+
path: 'relatedCompanies',
|
|
41
|
+
recordType: '1010',
|
|
42
|
+
value: count,
|
|
43
|
+
expected: `at most ${max}`,
|
|
44
|
+
specRef: { page: 2 },
|
|
45
|
+
}),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** struct.rdInvestments.max: more R&D investments (1030 records) than the layout allows (5, p.2). */
|
|
50
|
+
export function rdInvestmentsMax(report: NormalizedReport): Issue[] {
|
|
51
|
+
const max = report.layout.records['1030'].maxOccurs;
|
|
52
|
+
const count = report.records.filter(record => record.recordType === '1030').length;
|
|
53
|
+
if (count <= max) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
return [
|
|
57
|
+
makeIssue('struct.rdInvestments.max', {
|
|
58
|
+
message: `The report has ${count} R&D investments; at most ${max} are allowed.`,
|
|
59
|
+
path: 'rdInvestments',
|
|
60
|
+
recordType: '1030',
|
|
61
|
+
value: count,
|
|
62
|
+
expected: `at most ${max}`,
|
|
63
|
+
specRef: { page: 2 },
|
|
64
|
+
}),
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Most shareholders (1020 records) in a report (p.2, p.21). */
|
|
69
|
+
const MAX_SHAREHOLDERS = 99;
|
|
70
|
+
|
|
71
|
+
function shareholderCount(report: NormalizedReport): number {
|
|
72
|
+
return report.records.filter(record => record.recordType === '1020').length;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* struct.shareholders.min: no shareholders while the company is not a kibbutz (p.1, p.21); a
|
|
77
|
+
* kibbutz may report none.
|
|
78
|
+
*/
|
|
79
|
+
export function shareholdersMin(report: NormalizedReport): Issue[] {
|
|
80
|
+
const isKibbutz = report.records.some(
|
|
81
|
+
record => record.recordType === '1000' && record.values['declarations.isKibbutz'] === true,
|
|
82
|
+
);
|
|
83
|
+
if (isKibbutz || shareholderCount(report) > 0) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
return [
|
|
87
|
+
makeIssue('struct.shareholders.min', {
|
|
88
|
+
message:
|
|
89
|
+
'The report has no shareholders; only a kibbutz (declarations.isKibbutz) may have none.',
|
|
90
|
+
path: 'shareholders',
|
|
91
|
+
recordType: '1020',
|
|
92
|
+
value: 0,
|
|
93
|
+
expected: 'at least 1',
|
|
94
|
+
specRef: { page: 21 },
|
|
95
|
+
}),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** struct.shareholders.max: more than 99 shareholders (p.2, p.21). */
|
|
100
|
+
export function shareholdersMax(report: NormalizedReport): Issue[] {
|
|
101
|
+
const count = shareholderCount(report);
|
|
102
|
+
if (count <= MAX_SHAREHOLDERS) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
return [
|
|
106
|
+
makeIssue('struct.shareholders.max', {
|
|
107
|
+
message: `The report has ${count} shareholders; at most ${MAX_SHAREHOLDERS} are allowed.`,
|
|
108
|
+
path: 'shareholders',
|
|
109
|
+
recordType: '1020',
|
|
110
|
+
value: count,
|
|
111
|
+
expected: `at most ${MAX_SHAREHOLDERS}`,
|
|
112
|
+
specRef: { page: 21 },
|
|
113
|
+
}),
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* struct.capitalGains.max: more capital-gains appendices (30xx records, all types together) than a
|
|
119
|
+
* report may transmit (14, p.1, p.32); the excess belongs on 1000@962 with reasons 964–967.
|
|
120
|
+
*/
|
|
121
|
+
export function capitalGainsMax(report: NormalizedReport): Issue[] {
|
|
122
|
+
const max = report.layout.limits.capitalGainsAppendices;
|
|
123
|
+
const count = report.records.filter(record => isCapitalGainsRecordType(record.recordType)).length;
|
|
124
|
+
if (count <= max) {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
return [
|
|
128
|
+
makeIssue('struct.capitalGains.max', {
|
|
129
|
+
message: `The report has ${count} capital-gains appendices; at most ${max} are allowed (report the rest as untransmitted, 1000@962).`,
|
|
130
|
+
path: 'capitalGains',
|
|
131
|
+
value: count,
|
|
132
|
+
expected: `at most ${max}`,
|
|
133
|
+
specRef: { page: 32 },
|
|
134
|
+
}),
|
|
135
|
+
];
|
|
136
|
+
}
|