@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,87 @@
|
|
|
1
|
+
import { ASSET_LOCATION_CODES, enumCode } from '../enums.js';
|
|
2
|
+
/** Header keys of record 3027 that are members of the appendix (137, 139 and 255 are derived). */
|
|
3
|
+
export const SHARES_INPUT_KEYS = [
|
|
4
|
+
'expropriation',
|
|
5
|
+
'assetDetails',
|
|
6
|
+
'assetLocation',
|
|
7
|
+
'relatedParty',
|
|
8
|
+
'buyerName',
|
|
9
|
+
'dates.code15',
|
|
10
|
+
'dates.code20',
|
|
11
|
+
'dates.code53',
|
|
12
|
+
];
|
|
13
|
+
/** Header keys of record 3050 that are members of the appendix (137 and 139 are derived). */
|
|
14
|
+
export const BETTERMENT_TAX_INPUT_KEYS = [
|
|
15
|
+
'expropriation',
|
|
16
|
+
'assetDetails',
|
|
17
|
+
'purchaseDate',
|
|
18
|
+
'dates.code15',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Header keys of record 3051 that are scalar members of the appendix, besides `walletAddresses`
|
|
22
|
+
* (137, 139 and 234 are derived).
|
|
23
|
+
*/
|
|
24
|
+
export const FORCED_VIRTUAL_CURRENCY_INPUT_KEYS = [
|
|
25
|
+
'assetDetails',
|
|
26
|
+
'assetLocation',
|
|
27
|
+
'relatedParty',
|
|
28
|
+
'buyerName',
|
|
29
|
+
'dates.code15',
|
|
30
|
+
];
|
|
31
|
+
/** Header keys of record 3054 that are members of the appendix (137 and 139 are derived). */
|
|
32
|
+
export const OIL_PARTNERSHIP_INPUT_KEYS = ['assetDetails', 'purchaseDate', 'dates.code15'];
|
|
33
|
+
/** The number of wallet-address slots of a record (3051@236 and @386). */
|
|
34
|
+
const WALLET_ADDRESS_SLOTS = 2;
|
|
35
|
+
/** The FieldDef key of the `slot`-th (0-based) wallet address: `walletAddresses[1]`. */
|
|
36
|
+
export function walletAddressKey(slot) {
|
|
37
|
+
return `walletAddresses[${slot}]`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The value at the dotted `key` (`dates.code15`) of `appendix`; undefined when a member on the way
|
|
41
|
+
* is absent (an untyped caller may leave out a required `dates`) or the value is not a primitive.
|
|
42
|
+
*/
|
|
43
|
+
function memberAt(appendix, key) {
|
|
44
|
+
let node = appendix;
|
|
45
|
+
for (const segment of key.split('.')) {
|
|
46
|
+
if (typeof node !== 'object' || node === null) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
node = node[segment];
|
|
50
|
+
}
|
|
51
|
+
return typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean'
|
|
52
|
+
? node
|
|
53
|
+
: undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The header input values of the asset members `keys` of `appendix`, by FieldDef key: each value
|
|
57
|
+
* as given (dates as ISO strings, the date kind writes them DD/MM/YYYY), the asset location as its
|
|
58
|
+
* code (abroad → 1, israel → 2; any other value kept for field.enum).
|
|
59
|
+
*/
|
|
60
|
+
export function assetHeader(appendix, keys) {
|
|
61
|
+
const values = {};
|
|
62
|
+
for (const key of keys) {
|
|
63
|
+
const value = memberAt(appendix, key);
|
|
64
|
+
values[key] = key === 'assetLocation' ? enumCode(ASSET_LOCATION_CODES, value) : value;
|
|
65
|
+
}
|
|
66
|
+
return values;
|
|
67
|
+
}
|
|
68
|
+
/** The header input values of the wallet addresses, slot by slot (`walletAddresses[0]` …). */
|
|
69
|
+
export function walletAddressesHeader(addresses) {
|
|
70
|
+
const values = {};
|
|
71
|
+
for (const [slot, address] of (addresses ?? []).entries()) {
|
|
72
|
+
values[walletAddressKey(slot)] = address;
|
|
73
|
+
}
|
|
74
|
+
return values;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The wallet addresses as the parser reads them back from the two slots, where `read` gives the
|
|
78
|
+
* value of a slot (absent: undefined): every slot up to the last one with a value, an empty slot
|
|
79
|
+
* before it as `''` (so the slots keep their input indices), undefined when no slot has one.
|
|
80
|
+
*/
|
|
81
|
+
export function readWalletAddresses(read) {
|
|
82
|
+
const slots = Array.from({ length: WALLET_ADDRESS_SLOTS }, (_, slot) => read(slot));
|
|
83
|
+
const used = slots.findLastIndex(value => value !== undefined);
|
|
84
|
+
return used === -1
|
|
85
|
+
? undefined
|
|
86
|
+
: slots.slice(0, used + 1).map(value => (value === undefined ? '' : String(value)));
|
|
87
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizer of the capital-gains appendices, records 30xx (SPEC §3.3, §3.7, §7.4, §15 A-7): their
|
|
3
|
+
* order in the file, appendix numbers and the "מספר בתל"ם" sequence, shared by every appendix type.
|
|
4
|
+
*/
|
|
5
|
+
import { type CapitalGainsRecordType } from '../../layout/capital-gains.js';
|
|
6
|
+
import type { YearLayout } from '../../layout/types.js';
|
|
7
|
+
import type { CapitalGainsAppendix } from '../../model/input.js';
|
|
8
|
+
import type { NormalizedRecord } from '../../model/normalized.js';
|
|
9
|
+
import type { ValidateOptions } from '../../model/options.js';
|
|
10
|
+
import type { Issue } from '../../validate/issue.js';
|
|
11
|
+
/** The transaction symbols the input model has an appendix type for. */
|
|
12
|
+
export type CapitalGainsInputSymbol = CapitalGainsAppendix['symbol'];
|
|
13
|
+
/**
|
|
14
|
+
* Header keys of each appendix type that are scalar members of the appendix (dotted for a member
|
|
15
|
+
* of a nested object: `dates.code15`), besides `symbol`, `amounts`, `withholders`,
|
|
16
|
+
* `walletAddresses` and `improvements` (the transaction symbol, appendix number, improvement count
|
|
17
|
+
* and sequence are derived).
|
|
18
|
+
*/
|
|
19
|
+
export declare const CAPITAL_GAINS_INPUT_KEYS: Readonly<Record<CapitalGainsInputSymbol, readonly string[]>>;
|
|
20
|
+
/** True when appendices of `symbol` have `withholders` (records 3060, 3064, 3065). */
|
|
21
|
+
export declare function hasWithholders(symbol: CapitalGainsInputSymbol): boolean;
|
|
22
|
+
/** True when appendices of `symbol` have `walletAddresses` (records 3051 and 3077). */
|
|
23
|
+
export declare function hasWalletAddresses(symbol: CapitalGainsInputSymbol): boolean;
|
|
24
|
+
/** Where an appendix goes in the file (SPEC §3.3, §7.4). */
|
|
25
|
+
export interface CapitalGainsPlacement<T> {
|
|
26
|
+
appendix: T;
|
|
27
|
+
/** 0-based index of the appendix in the input list. */
|
|
28
|
+
inputIndex: number;
|
|
29
|
+
/** 30xx@139: 1-based among appendices of the same symbol, in emission order (SPEC §15 A-7). */
|
|
30
|
+
appendixNumber: number;
|
|
31
|
+
/** "מספר בתל"ם": 1-based among all capital-gains appendices, in emission order (SPEC §7.4). */
|
|
32
|
+
sequenceNumber: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The appendices in emission order: grouped by symbol (= record type) ascending, input order within
|
|
36
|
+
* a symbol (SPEC §3.3, §15 A-7), each with its input index, appendix number and sequence number.
|
|
37
|
+
*/
|
|
38
|
+
export declare function placeCapitalGains<T extends {
|
|
39
|
+
symbol: number;
|
|
40
|
+
}>(appendices: readonly T[]): Array<CapitalGainsPlacement<T>>;
|
|
41
|
+
export interface NormalizedCapitalGains {
|
|
42
|
+
/** In emission order (SPEC §3.3). */
|
|
43
|
+
records: NormalizedRecord[];
|
|
44
|
+
/** Codes whose input value 0 was omitted (every 30xx code but 3054 016, SPEC §4.5). */
|
|
45
|
+
omittedZeroCodes: Array<{
|
|
46
|
+
record: CapitalGainsRecordType;
|
|
47
|
+
recordIndex: number;
|
|
48
|
+
code: string;
|
|
49
|
+
}>;
|
|
50
|
+
/** Raised while normalizing: improvements after the fifth (cg.improvements.max). */
|
|
51
|
+
notices: Issue[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The 30xx records of `appendices` in emission order (placeCapitalGains): each indexed among the
|
|
55
|
+
* records of its type, with its input index, the derived symbol (30xx@137), appendix number
|
|
56
|
+
* (30xx@139) and, where the record type has the field, "מספר בתל"ם" sequence, its header values
|
|
57
|
+
* and its code-amount section (derived codes from their sources, amounts rounded per
|
|
58
|
+
* `options.rounding`, SPEC §4.4, then zero codes omitted unless zeroAllowed). Paths per pathFor
|
|
59
|
+
* (records 30xx).
|
|
60
|
+
*/
|
|
61
|
+
export declare function normalizeCapitalGains(appendices: readonly CapitalGainsAppendix[], layout: YearLayout, options: ValidateOptions): NormalizedCapitalGains;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizer of the capital-gains appendices, records 30xx (SPEC §3.3, §3.7, §7.4, §15 A-7): their
|
|
3
|
+
* order in the file, appendix numbers and the "מספר בתל"ם" sequence, shared by every appendix type.
|
|
4
|
+
*/
|
|
5
|
+
import { capitalGainsRecordType } from '../../layout/capital-gains.js';
|
|
6
|
+
import { codeSection, headerValues } from '../fields.js';
|
|
7
|
+
import { assetHeader, BETTERMENT_TAX_INPUT_KEYS, FORCED_VIRTUAL_CURRENCY_INPUT_KEYS, OIL_PARTNERSHIP_INPUT_KEYS, SHARES_INPUT_KEYS, walletAddressesHeader, } from './assets.js';
|
|
8
|
+
import { NO_WITHHOLDING_1322_INPUT_KEYS, NO_WITHHOLDING_1326_INPUT_KEYS, noWithholding1322Header, noWithholding1326Header, } from './no-withholding.js';
|
|
9
|
+
import { improvementCodes, improvementsHeader, improvementsMaxNotice, OTHER_TRANSACTIONS_INPUT_KEYS, } from './other.js';
|
|
10
|
+
import { SECTION6_INPUT_KEYS, section6Header } from './section6.js';
|
|
11
|
+
import { SECURITIES_INPUT_KEYS, securitiesHeader } from './securities.js';
|
|
12
|
+
/**
|
|
13
|
+
* Header keys of each appendix type that are scalar members of the appendix (dotted for a member
|
|
14
|
+
* of a nested object: `dates.code15`), besides `symbol`, `amounts`, `withholders`,
|
|
15
|
+
* `walletAddresses` and `improvements` (the transaction symbol, appendix number, improvement count
|
|
16
|
+
* and sequence are derived).
|
|
17
|
+
*/
|
|
18
|
+
export const CAPITAL_GAINS_INPUT_KEYS = {
|
|
19
|
+
27: SHARES_INPUT_KEYS,
|
|
20
|
+
50: BETTERMENT_TAX_INPUT_KEYS,
|
|
21
|
+
51: FORCED_VIRTUAL_CURRENCY_INPUT_KEYS,
|
|
22
|
+
54: OIL_PARTNERSHIP_INPUT_KEYS,
|
|
23
|
+
60: SECURITIES_INPUT_KEYS,
|
|
24
|
+
63: SECTION6_INPUT_KEYS,
|
|
25
|
+
64: SECURITIES_INPUT_KEYS,
|
|
26
|
+
65: NO_WITHHOLDING_1322_INPUT_KEYS,
|
|
27
|
+
66: NO_WITHHOLDING_1326_INPUT_KEYS,
|
|
28
|
+
77: OTHER_TRANSACTIONS_INPUT_KEYS,
|
|
29
|
+
};
|
|
30
|
+
/** The symbols whose appendix has `withholders`, header keys `withholders[i].*` (SPEC §7.3). */
|
|
31
|
+
const WITHHOLDING_SYMBOLS = new Set([60, 64, 65]);
|
|
32
|
+
/** True when appendices of `symbol` have `withholders` (records 3060, 3064, 3065). */
|
|
33
|
+
export function hasWithholders(symbol) {
|
|
34
|
+
return WITHHOLDING_SYMBOLS.has(symbol);
|
|
35
|
+
}
|
|
36
|
+
/** The symbols whose appendix has `walletAddresses`, header keys `walletAddresses[i]` (SPEC §7.3). */
|
|
37
|
+
const WALLET_SYMBOLS = new Set([51, 77]);
|
|
38
|
+
/** True when appendices of `symbol` have `walletAddresses` (records 3051 and 3077). */
|
|
39
|
+
export function hasWalletAddresses(symbol) {
|
|
40
|
+
return WALLET_SYMBOLS.has(symbol);
|
|
41
|
+
}
|
|
42
|
+
/** Header keys of the derived transaction symbol (30xx@137) and appendix number (30xx@139). */
|
|
43
|
+
const TRANSACTION_SYMBOL_KEY = 'transactionSymbol';
|
|
44
|
+
const APPENDIX_NUMBER_KEY = 'appendixNumber';
|
|
45
|
+
/** Header key of the derived "מספר בתל"ם" sequence, in the record types that have one (SPEC §7.4). */
|
|
46
|
+
const SEQUENCE_NUMBER_KEY = 'sequenceNumber';
|
|
47
|
+
/**
|
|
48
|
+
* The appendices in emission order: grouped by symbol (= record type) ascending, input order within
|
|
49
|
+
* a symbol (SPEC §3.3, §15 A-7), each with its input index, appendix number and sequence number.
|
|
50
|
+
*/
|
|
51
|
+
export function placeCapitalGains(appendices) {
|
|
52
|
+
const perSymbol = new Map();
|
|
53
|
+
return appendices
|
|
54
|
+
.map((appendix, inputIndex) => ({ appendix, inputIndex }))
|
|
55
|
+
.sort((a, b) => a.appendix.symbol - b.appendix.symbol || a.inputIndex - b.inputIndex)
|
|
56
|
+
.map(({ appendix, inputIndex }, emissionIndex) => {
|
|
57
|
+
const appendixNumber = (perSymbol.get(appendix.symbol) ?? 0) + 1;
|
|
58
|
+
perSymbol.set(appendix.symbol, appendixNumber);
|
|
59
|
+
return { appendix, inputIndex, appendixNumber, sequenceNumber: emissionIndex + 1 };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** The header input values of an appendix of any type, by FieldDef.key (derived ones aside). */
|
|
63
|
+
function headerInput(appendix) {
|
|
64
|
+
switch (appendix.symbol) {
|
|
65
|
+
case 27:
|
|
66
|
+
return assetHeader(appendix, SHARES_INPUT_KEYS);
|
|
67
|
+
case 50:
|
|
68
|
+
return assetHeader(appendix, BETTERMENT_TAX_INPUT_KEYS);
|
|
69
|
+
case 51:
|
|
70
|
+
return {
|
|
71
|
+
...assetHeader(appendix, FORCED_VIRTUAL_CURRENCY_INPUT_KEYS),
|
|
72
|
+
...walletAddressesHeader(appendix.walletAddresses),
|
|
73
|
+
};
|
|
74
|
+
case 54:
|
|
75
|
+
return assetHeader(appendix, OIL_PARTNERSHIP_INPUT_KEYS);
|
|
76
|
+
case 60:
|
|
77
|
+
case 64:
|
|
78
|
+
return securitiesHeader(appendix);
|
|
79
|
+
case 63:
|
|
80
|
+
return section6Header(appendix);
|
|
81
|
+
case 65:
|
|
82
|
+
return noWithholding1322Header(appendix);
|
|
83
|
+
case 66:
|
|
84
|
+
return noWithholding1326Header(appendix);
|
|
85
|
+
case 77:
|
|
86
|
+
return {
|
|
87
|
+
...assetHeader(appendix, OTHER_TRANSACTIONS_INPUT_KEYS),
|
|
88
|
+
...improvementsHeader(appendix.improvements),
|
|
89
|
+
...walletAddressesHeader(appendix.walletAddresses),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** The derived codes of an appendix (SPEC §7.4): 3077 codes 501–505, none for the other types. */
|
|
94
|
+
function derivedCodes(appendix) {
|
|
95
|
+
return appendix.symbol === 77 ? improvementCodes(appendix.improvements) : {};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The 30xx records of `appendices` in emission order (placeCapitalGains): each indexed among the
|
|
99
|
+
* records of its type, with its input index, the derived symbol (30xx@137), appendix number
|
|
100
|
+
* (30xx@139) and, where the record type has the field, "מספר בתל"ם" sequence, its header values
|
|
101
|
+
* and its code-amount section (derived codes from their sources, amounts rounded per
|
|
102
|
+
* `options.rounding`, SPEC §4.4, then zero codes omitted unless zeroAllowed). Paths per pathFor
|
|
103
|
+
* (records 30xx).
|
|
104
|
+
*/
|
|
105
|
+
export function normalizeCapitalGains(appendices, layout, options) {
|
|
106
|
+
const omittedZeroCodes = [];
|
|
107
|
+
const notices = [];
|
|
108
|
+
const records = placeCapitalGains(appendices).map(({ appendix, inputIndex, appendixNumber, sequenceNumber }) => {
|
|
109
|
+
const recordType = capitalGainsRecordType(appendix.symbol);
|
|
110
|
+
const def = layout.records[recordType];
|
|
111
|
+
const index = appendixNumber - 1;
|
|
112
|
+
const hasSequence = def.fields.some(field => field.key === SEQUENCE_NUMBER_KEY);
|
|
113
|
+
const { values, paths } = headerValues(def, inputIndex, {
|
|
114
|
+
[TRANSACTION_SYMBOL_KEY]: appendix.symbol,
|
|
115
|
+
[APPENDIX_NUMBER_KEY]: appendixNumber,
|
|
116
|
+
...(hasSequence ? { [SEQUENCE_NUMBER_KEY]: sequenceNumber } : {}),
|
|
117
|
+
...headerInput(appendix),
|
|
118
|
+
}, options.rounding);
|
|
119
|
+
if (appendix.symbol === 77) {
|
|
120
|
+
notices.push(...improvementsMaxNotice(appendix.improvements, inputIndex, index));
|
|
121
|
+
}
|
|
122
|
+
// Derived codes come from their sources only, never from `amounts` (SPEC §7.4).
|
|
123
|
+
const amounts = {
|
|
124
|
+
...appendix.amounts,
|
|
125
|
+
...derivedCodes(appendix),
|
|
126
|
+
};
|
|
127
|
+
const section = codeSection(def, inputIndex, amounts, options.rounding);
|
|
128
|
+
for (const code of section.omittedZeroCodes) {
|
|
129
|
+
omittedZeroCodes.push({ record: recordType, recordIndex: index, code });
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
recordType,
|
|
133
|
+
index,
|
|
134
|
+
inputIndex,
|
|
135
|
+
values,
|
|
136
|
+
codes: section.codes,
|
|
137
|
+
countries: [],
|
|
138
|
+
paths: { ...paths, ...section.paths },
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
return { records, omittedZeroCodes, notices };
|
|
142
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records 3065 (form 1322, p.50–52) and 3066 (form 1326, p.53–54): capital gains from securities
|
|
3
|
+
* without tax withholding (SPEC §7.2). 3065 is the securities header (securities.ts) with a
|
|
4
|
+
* withholding status; 3066 is a short variant. Their "מספר בתל"ם" sequence is derived (index.ts).
|
|
5
|
+
*/
|
|
6
|
+
import type { Primitive } from '../../codec/types.js';
|
|
7
|
+
import type { NoWithholding1322Appendix, NoWithholding1326Appendix } from '../../model/input.js';
|
|
8
|
+
/** Header keys of record 3065 that are scalar members of the appendix (besides `withholders`). */
|
|
9
|
+
export declare const NO_WITHHOLDING_1322_INPUT_KEYS: readonly ["foreignAsset", "soldToRelatedParty", "boughtFromRelatedParty", "gainFromInvestmentFund", "lossesCarriedForward", "withholdingStatus"];
|
|
10
|
+
/** Header keys of record 3066 that are members of the appendix (137, 139 and 154 are derived). */
|
|
11
|
+
export declare const NO_WITHHOLDING_1326_INPUT_KEYS: readonly ["foreignAsset", "withholdingStatus", "lossesCarriedForward"];
|
|
12
|
+
/**
|
|
13
|
+
* The header input values of the 3065 record of `appendix`, by FieldDef key (derived ones aside):
|
|
14
|
+
* the securities header (withholders included) and the withholding status code.
|
|
15
|
+
*/
|
|
16
|
+
export declare function noWithholding1322Header(appendix: NoWithholding1322Appendix): Record<string, Primitive>;
|
|
17
|
+
/** The header input values of the 3066 record of `appendix`, by FieldDef key (derived ones aside). */
|
|
18
|
+
export declare function noWithholding1326Header(appendix: NoWithholding1326Appendix): Record<string, Primitive>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { enumCode, WITHHOLDING_STATUS_CODES } from '../enums.js';
|
|
2
|
+
import { SECURITIES_INPUT_KEYS, securitiesHeader } from './securities.js';
|
|
3
|
+
/** Header keys of record 3065 that are scalar members of the appendix (besides `withholders`). */
|
|
4
|
+
export const NO_WITHHOLDING_1322_INPUT_KEYS = [
|
|
5
|
+
...SECURITIES_INPUT_KEYS,
|
|
6
|
+
'withholdingStatus',
|
|
7
|
+
];
|
|
8
|
+
/** Header keys of record 3066 that are members of the appendix (137, 139 and 154 are derived). */
|
|
9
|
+
export const NO_WITHHOLDING_1326_INPUT_KEYS = [
|
|
10
|
+
'foreignAsset',
|
|
11
|
+
'withholdingStatus',
|
|
12
|
+
'lossesCarriedForward',
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* The header input values of the 3065 record of `appendix`, by FieldDef key (derived ones aside):
|
|
16
|
+
* the securities header (withholders included) and the withholding status code.
|
|
17
|
+
*/
|
|
18
|
+
export function noWithholding1322Header(appendix) {
|
|
19
|
+
return {
|
|
20
|
+
...securitiesHeader(appendix),
|
|
21
|
+
withholdingStatus: enumCode(WITHHOLDING_STATUS_CODES, appendix.withholdingStatus),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The header input values of the 3066 record of `appendix`, by FieldDef key (derived ones aside). */
|
|
25
|
+
export function noWithholding1326Header(appendix) {
|
|
26
|
+
return {
|
|
27
|
+
foreignAsset: appendix.foreignAsset,
|
|
28
|
+
withholdingStatus: enumCode(WITHHOLDING_STATUS_CODES, appendix.withholdingStatus),
|
|
29
|
+
lossesCarriedForward: appendix.lossesCarriedForward,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The header of record 3077 (other transactions, p.55–59) besides the asset members it shares with
|
|
3
|
+
* the asset appendices (assets.ts): up to five improvements written slot by slot, with their count
|
|
4
|
+
* at 245 and their code-50 amounts as the derived codes 501–505, and the replacement asset (SPEC
|
|
5
|
+
* §7.2, §7.3, §7.4). Values go through the layout keys (`improvements[1].date`), never offsets.
|
|
6
|
+
*/
|
|
7
|
+
import type { Primitive } from '../../codec/types.js';
|
|
8
|
+
import type { OtherTransactionsAppendix } from '../../model/input.js';
|
|
9
|
+
import { type Issue } from '../../validate/issue.js';
|
|
10
|
+
/**
|
|
11
|
+
* Header keys of record 3077 that are scalar members of the appendix, besides `improvements` and
|
|
12
|
+
* `walletAddresses` (137, 139, 245 and 487 are derived).
|
|
13
|
+
*/
|
|
14
|
+
export declare const OTHER_TRANSACTIONS_INPUT_KEYS: readonly ["expropriation", "assetDetails", "assetLocation", "relatedParty", "buyerName", "dates.code15", "dates.code20", "replacementAsset.details", "replacementAsset.purchaseDate", "replacementAsset.price"];
|
|
15
|
+
/** An improvement of a 3077 appendix (SPEC §7.2). */
|
|
16
|
+
type Improvement = NonNullable<OtherTransactionsAppendix['improvements']>[number];
|
|
17
|
+
/** The members of an improvement slot that are header fields, in field order. */
|
|
18
|
+
export declare const IMPROVEMENT_HEADER_MEMBERS: readonly ["expense", "accumulatedDepreciation", "date"];
|
|
19
|
+
/** A member of an improvement: a header field of its slot or its code-50 amount. */
|
|
20
|
+
export type ImprovementMember = (typeof IMPROVEMENT_HEADER_MEMBERS)[number] | 'code50Amount';
|
|
21
|
+
/** The number of improvement slots of record 3077 (247–416; codes 501–505). */
|
|
22
|
+
export declare const IMPROVEMENT_SLOTS = 5;
|
|
23
|
+
/** Header key of the derived improvement count, 3077@245 (SPEC §7.4). */
|
|
24
|
+
export declare const IMPROVEMENT_COUNT_KEY = "improvementCount";
|
|
25
|
+
/** The FieldDef key of `member` of the `slot`-th (0-based) improvement: `improvements[1].date`. */
|
|
26
|
+
export declare function improvementKey(slot: number, member: (typeof IMPROVEMENT_HEADER_MEMBERS)[number]): string;
|
|
27
|
+
/** The code holding the code-50 amount of the `slot`-th (0-based) improvement: 501 … 505. */
|
|
28
|
+
export declare function improvementCode(slot: number): string;
|
|
29
|
+
/** The 0-based improvement slot whose code-50 amount `code` (501 … 505) holds, else undefined. */
|
|
30
|
+
export declare function improvementSlotOfCode(code: string): number | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The header input values of the improvements of a 3077 appendix, by FieldDef key: every member of
|
|
33
|
+
* every improvement that has a slot (the first five), and the count (3077@245, SPEC §7.4) when
|
|
34
|
+
* there is any improvement.
|
|
35
|
+
*/
|
|
36
|
+
export declare function improvementsHeader(improvements: readonly Improvement[] | undefined): Record<string, Primitive>;
|
|
37
|
+
/**
|
|
38
|
+
* The derived codes 501–505 of the improvements (SPEC §7.4): the code-50 amount of each slot, every
|
|
39
|
+
* code present (undefined when its slot has none), so that they replace any caller value.
|
|
40
|
+
*/
|
|
41
|
+
export declare function improvementCodes(improvements: readonly Improvement[] | undefined): Record<string, number | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* cg.improvements.max: only five improvements have a slot (3077@247–416), so a sixth one has no
|
|
44
|
+
* field to be reported on; it raises a notice at the first improvement that is not written. The
|
|
45
|
+
* first five are still written.
|
|
46
|
+
*/
|
|
47
|
+
export declare function improvementsMaxNotice(improvements: readonly Improvement[] | undefined, inputIndex: number, recordIndex: number): Issue[];
|
|
48
|
+
/**
|
|
49
|
+
* The improvements as the parser reads them back from the five slots, where `read` gives the value
|
|
50
|
+
* of a member of a slot (absent: undefined): every slot up to the last one with a value, an empty
|
|
51
|
+
* slot before it as `{}` (so the slots keep their input indices), undefined when no slot has one.
|
|
52
|
+
*/
|
|
53
|
+
export declare function readImprovements(read: (slot: number, member: ImprovementMember) => Primitive): Array<Partial<Record<ImprovementMember, Primitive>>> | undefined;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { makeIssue } from '../../validate/issue.js';
|
|
2
|
+
/**
|
|
3
|
+
* Header keys of record 3077 that are scalar members of the appendix, besides `improvements` and
|
|
4
|
+
* `walletAddresses` (137, 139, 245 and 487 are derived).
|
|
5
|
+
*/
|
|
6
|
+
export const OTHER_TRANSACTIONS_INPUT_KEYS = [
|
|
7
|
+
'expropriation',
|
|
8
|
+
'assetDetails',
|
|
9
|
+
'assetLocation',
|
|
10
|
+
'relatedParty',
|
|
11
|
+
'buyerName',
|
|
12
|
+
'dates.code15',
|
|
13
|
+
'dates.code20',
|
|
14
|
+
'replacementAsset.details',
|
|
15
|
+
'replacementAsset.purchaseDate',
|
|
16
|
+
'replacementAsset.price',
|
|
17
|
+
];
|
|
18
|
+
/** The members of an improvement slot that are header fields, in field order. */
|
|
19
|
+
export const IMPROVEMENT_HEADER_MEMBERS = [
|
|
20
|
+
'expense',
|
|
21
|
+
'accumulatedDepreciation',
|
|
22
|
+
'date',
|
|
23
|
+
];
|
|
24
|
+
/** The number of improvement slots of record 3077 (247–416; codes 501–505). */
|
|
25
|
+
export const IMPROVEMENT_SLOTS = 5;
|
|
26
|
+
/** Header key of the derived improvement count, 3077@245 (SPEC §7.4). */
|
|
27
|
+
export const IMPROVEMENT_COUNT_KEY = 'improvementCount';
|
|
28
|
+
/** The FieldDef key of `member` of the `slot`-th (0-based) improvement: `improvements[1].date`. */
|
|
29
|
+
export function improvementKey(slot, member) {
|
|
30
|
+
return `improvements[${slot}].${member}`;
|
|
31
|
+
}
|
|
32
|
+
/** The code holding the code-50 amount of the `slot`-th (0-based) improvement: 501 … 505. */
|
|
33
|
+
export function improvementCode(slot) {
|
|
34
|
+
return `50${slot + 1}`;
|
|
35
|
+
}
|
|
36
|
+
/** Codes 501–505: the digit after `50` is the 1-based improvement slot. */
|
|
37
|
+
const IMPROVEMENT_CODE = /^50([1-5])$/;
|
|
38
|
+
/** The 0-based improvement slot whose code-50 amount `code` (501 … 505) holds, else undefined. */
|
|
39
|
+
export function improvementSlotOfCode(code) {
|
|
40
|
+
const match = IMPROVEMENT_CODE.exec(code);
|
|
41
|
+
return match ? Number(match[1]) - 1 : undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The header input values of the improvements of a 3077 appendix, by FieldDef key: every member of
|
|
45
|
+
* every improvement that has a slot (the first five), and the count (3077@245, SPEC §7.4) when
|
|
46
|
+
* there is any improvement.
|
|
47
|
+
*/
|
|
48
|
+
export function improvementsHeader(improvements) {
|
|
49
|
+
const values = {};
|
|
50
|
+
const given = improvements ?? [];
|
|
51
|
+
if (given.length > 0) {
|
|
52
|
+
values[IMPROVEMENT_COUNT_KEY] = given.length;
|
|
53
|
+
}
|
|
54
|
+
for (const [slot, improvement] of given.slice(0, IMPROVEMENT_SLOTS).entries()) {
|
|
55
|
+
for (const member of IMPROVEMENT_HEADER_MEMBERS) {
|
|
56
|
+
values[improvementKey(slot, member)] = improvement[member];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return values;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The derived codes 501–505 of the improvements (SPEC §7.4): the code-50 amount of each slot, every
|
|
63
|
+
* code present (undefined when its slot has none), so that they replace any caller value.
|
|
64
|
+
*/
|
|
65
|
+
export function improvementCodes(improvements) {
|
|
66
|
+
return Object.fromEntries(Array.from({ length: IMPROVEMENT_SLOTS }, (_, slot) => [
|
|
67
|
+
improvementCode(slot),
|
|
68
|
+
improvements?.[slot]?.code50Amount,
|
|
69
|
+
]));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* cg.improvements.max: only five improvements have a slot (3077@247–416), so a sixth one has no
|
|
73
|
+
* field to be reported on; it raises a notice at the first improvement that is not written. The
|
|
74
|
+
* first five are still written.
|
|
75
|
+
*/
|
|
76
|
+
export function improvementsMaxNotice(improvements, inputIndex, recordIndex) {
|
|
77
|
+
const count = improvements?.length ?? 0;
|
|
78
|
+
if (count <= IMPROVEMENT_SLOTS) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return [
|
|
82
|
+
makeIssue('cg.improvements.max', {
|
|
83
|
+
message: `capitalGains[${inputIndex}] has ${count} improvements; record 3077 holds at most ${IMPROVEMENT_SLOTS} (report the excess via 962 with reason 965).`,
|
|
84
|
+
path: `capitalGains[${inputIndex}].improvements[${IMPROVEMENT_SLOTS}]`,
|
|
85
|
+
recordType: '3077',
|
|
86
|
+
recordIndex,
|
|
87
|
+
value: count,
|
|
88
|
+
expected: `at most ${IMPROVEMENT_SLOTS}`,
|
|
89
|
+
specRef: { page: 55 },
|
|
90
|
+
}),
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The improvements as the parser reads them back from the five slots, where `read` gives the value
|
|
95
|
+
* of a member of a slot (absent: undefined): every slot up to the last one with a value, an empty
|
|
96
|
+
* slot before it as `{}` (so the slots keep their input indices), undefined when no slot has one.
|
|
97
|
+
*/
|
|
98
|
+
export function readImprovements(read) {
|
|
99
|
+
const members = [...IMPROVEMENT_HEADER_MEMBERS, 'code50Amount'];
|
|
100
|
+
const slots = Array.from({ length: IMPROVEMENT_SLOTS }, (_, slot) => {
|
|
101
|
+
const improvement = {};
|
|
102
|
+
for (const member of members) {
|
|
103
|
+
const value = read(slot, member);
|
|
104
|
+
if (value !== undefined) {
|
|
105
|
+
improvement[member] = value;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return improvement;
|
|
109
|
+
});
|
|
110
|
+
const used = slots.findLastIndex(improvement => Object.keys(improvement).length > 0);
|
|
111
|
+
return used === -1 ? undefined : slots.slice(0, used + 1);
|
|
112
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Record 3063: capital gains from securities under section 6 (SPEC §7.2, p.46–47). */
|
|
2
|
+
import type { Primitive } from '../../codec/types.js';
|
|
3
|
+
import type { Section6SecuritiesAppendix } from '../../model/input.js';
|
|
4
|
+
/** Header keys of record 3063 that are members of the appendix (137 and 139 are derived). */
|
|
5
|
+
export declare const SECTION6_INPUT_KEYS: readonly ["foreignAsset", "lossesCarriedForward"];
|
|
6
|
+
/** The header input values of the 3063 record of `appendix`, by FieldDef.key (derived ones aside). */
|
|
7
|
+
export declare function section6Header(appendix: Section6SecuritiesAppendix): Record<string, Primitive>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Header keys of record 3063 that are members of the appendix (137 and 139 are derived). */
|
|
2
|
+
export const SECTION6_INPUT_KEYS = ['foreignAsset', 'lossesCarriedForward'];
|
|
3
|
+
/** The header input values of the 3063 record of `appendix`, by FieldDef.key (derived ones aside). */
|
|
4
|
+
export function section6Header(appendix) {
|
|
5
|
+
return {
|
|
6
|
+
foreignAsset: appendix.foreignAsset,
|
|
7
|
+
lossesCarriedForward: appendix.lossesCarriedForward,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The securities header shared by records 3060 (securities, p.43–45) and 3064 (REIT, p.48–49), and
|
|
3
|
+
* reused by 3065: four yes/no flags, up to four withholding agents and the losses carried forward
|
|
4
|
+
* (SPEC §7.2, §7.3). Values go through the layout keys (`withholders[1].branch`), never offsets, so
|
|
5
|
+
* a type whose fields sit at other positions shares it unchanged.
|
|
6
|
+
*/
|
|
7
|
+
import type { Primitive } from '../../codec/types.js';
|
|
8
|
+
import type { SecuritiesAppendix, Withholder } from '../../model/input.js';
|
|
9
|
+
/** The header members shared by the securities types besides `withholders` (their FieldDef keys). */
|
|
10
|
+
export declare const SECURITIES_INPUT_KEYS: readonly ["foreignAsset", "soldToRelatedParty", "boughtFromRelatedParty", "gainFromInvestmentFund", "lossesCarriedForward"];
|
|
11
|
+
/** The header of a securities appendix: the members SecuritiesAppendix shares with the others. */
|
|
12
|
+
export type SecuritiesHeader = Omit<SecuritiesAppendix, 'symbol' | 'amounts'>;
|
|
13
|
+
/** The FieldDef key of `member` of the `slot`-th (0-based) withholder: `withholders[1].branch`. */
|
|
14
|
+
export declare function withholderKey(slot: number, member: keyof Withholder): string;
|
|
15
|
+
/**
|
|
16
|
+
* The header input values of a securities record of `appendix`, by FieldDef key (the derived
|
|
17
|
+
* symbol and appendix number aside): the shared members and every member of every given
|
|
18
|
+
* withholder (`withholders[i].name` …).
|
|
19
|
+
*/
|
|
20
|
+
export declare function securitiesHeader(appendix: SecuritiesHeader): Record<string, Primitive>;
|
|
21
|
+
/**
|
|
22
|
+
* The withholders as the parser reads them back from the four slots, where `read` gives the value
|
|
23
|
+
* of a member of a slot (absent: undefined): every slot up to the last one with a value, an empty
|
|
24
|
+
* slot before it as `{}` (so the slots keep their input indices), undefined when no slot has one.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readWithholders(read: (slot: number, member: keyof Withholder) => Primitive): Withholder[] | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** The header members shared by the securities types besides `withholders` (their FieldDef keys). */
|
|
2
|
+
export const SECURITIES_INPUT_KEYS = [
|
|
3
|
+
'foreignAsset',
|
|
4
|
+
'soldToRelatedParty',
|
|
5
|
+
'boughtFromRelatedParty',
|
|
6
|
+
'gainFromInvestmentFund',
|
|
7
|
+
'lossesCarriedForward',
|
|
8
|
+
];
|
|
9
|
+
/** The members of a withholder slot, in field order. */
|
|
10
|
+
const WITHHOLDER_MEMBERS = ['name', 'branch', 'account'];
|
|
11
|
+
/** The number of withholder slots of a securities record (146–313; the schema allows 4). */
|
|
12
|
+
const WITHHOLDER_SLOTS = 4;
|
|
13
|
+
/** The FieldDef key of `member` of the `slot`-th (0-based) withholder: `withholders[1].branch`. */
|
|
14
|
+
export function withholderKey(slot, member) {
|
|
15
|
+
return `withholders[${slot}].${member}`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The header input values of a securities record of `appendix`, by FieldDef key (the derived
|
|
19
|
+
* symbol and appendix number aside): the shared members and every member of every given
|
|
20
|
+
* withholder (`withholders[i].name` …).
|
|
21
|
+
*/
|
|
22
|
+
export function securitiesHeader(appendix) {
|
|
23
|
+
const values = {};
|
|
24
|
+
for (const key of SECURITIES_INPUT_KEYS) {
|
|
25
|
+
values[key] = appendix[key];
|
|
26
|
+
}
|
|
27
|
+
for (const [slot, withholder] of (appendix.withholders ?? []).entries()) {
|
|
28
|
+
for (const member of WITHHOLDER_MEMBERS) {
|
|
29
|
+
values[withholderKey(slot, member)] = withholder[member];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return values;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The withholders as the parser reads them back from the four slots, where `read` gives the value
|
|
36
|
+
* of a member of a slot (absent: undefined): every slot up to the last one with a value, an empty
|
|
37
|
+
* slot before it as `{}` (so the slots keep their input indices), undefined when no slot has one.
|
|
38
|
+
*/
|
|
39
|
+
export function readWithholders(read) {
|
|
40
|
+
const slots = Array.from({ length: WITHHOLDER_SLOTS }, (_, slot) => {
|
|
41
|
+
const withholder = {};
|
|
42
|
+
for (const member of WITHHOLDER_MEMBERS) {
|
|
43
|
+
const value = read(slot, member);
|
|
44
|
+
if (value !== undefined) {
|
|
45
|
+
withholder[member] = String(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return withholder;
|
|
49
|
+
});
|
|
50
|
+
const used = slots.findLastIndex(withholder => Object.keys(withholder).length > 0);
|
|
51
|
+
return used === -1 ? undefined : slots.slice(0, used + 1);
|
|
52
|
+
}
|