@accounter/opcn1214-generator 0.0.0-bootstrap.0 → 0.0.0-stage
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/README.md +2 -336
- package/package.json +3 -74
- package/.bob/cjs/api/generate.d.ts +0 -44
- package/.bob/cjs/api/generate.js +0 -115
- package/.bob/cjs/api/parse.d.ts +0 -28
- package/.bob/cjs/api/parse.js +0 -38
- package/.bob/cjs/api/response.d.ts +0 -24
- package/.bob/cjs/api/response.js +0 -75
- package/.bob/cjs/api/validate.d.ts +0 -16
- package/.bob/cjs/api/validate.js +0 -15
- package/.bob/cjs/codec/boolean.d.ts +0 -7
- package/.bob/cjs/codec/boolean.js +0 -49
- package/.bob/cjs/codec/date.d.ts +0 -6
- package/.bob/cjs/codec/date.js +0 -68
- package/.bob/cjs/codec/enum.d.ts +0 -4
- package/.bob/cjs/codec/enum.js +0 -26
- package/.bob/cjs/codec/numeric.d.ts +0 -56
- package/.bob/cjs/codec/numeric.js +0 -186
- package/.bob/cjs/codec/padding.d.ts +0 -10
- package/.bob/cjs/codec/padding.js +0 -26
- package/.bob/cjs/codec/percent.d.ts +0 -6
- package/.bob/cjs/codec/percent.js +0 -33
- package/.bob/cjs/codec/phone.d.ts +0 -4
- package/.bob/cjs/codec/phone.js +0 -48
- package/.bob/cjs/codec/record.d.ts +0 -18
- package/.bob/cjs/codec/record.js +0 -176
- package/.bob/cjs/codec/registry.d.ts +0 -8
- package/.bob/cjs/codec/registry.js +0 -27
- package/.bob/cjs/codec/sections.d.ts +0 -41
- package/.bob/cjs/codec/sections.js +0 -177
- package/.bob/cjs/codec/text.d.ts +0 -5
- package/.bob/cjs/codec/text.js +0 -29
- package/.bob/cjs/codec/types.d.ts +0 -36
- package/.bob/cjs/codec/types.js +0 -16
- package/.bob/cjs/codec/windows1255.d.ts +0 -9
- package/.bob/cjs/codec/windows1255.js +0 -38
- package/.bob/cjs/errors.d.ts +0 -32
- package/.bob/cjs/errors.js +0 -103
- package/.bob/cjs/file/assemble.d.ts +0 -17
- package/.bob/cjs/file/assemble.js +0 -28
- package/.bob/cjs/file/control.d.ts +0 -13
- package/.bob/cjs/file/control.js +0 -45
- package/.bob/cjs/file/parse.d.ts +0 -18
- package/.bob/cjs/file/parse.js +0 -478
- package/.bob/cjs/file/split.d.ts +0 -17
- package/.bob/cjs/file/split.js +0 -71
- package/.bob/cjs/index.d.ts +0 -16
- package/.bob/cjs/index.js +0 -28
- package/.bob/cjs/layout/2024/layout.generated.d.ts +0 -6919
- package/.bob/cjs/layout/2024/layout.generated.js +0 -7224
- package/.bob/cjs/layout/2025/index.d.ts +0 -6
- package/.bob/cjs/layout/2025/index.js +0 -10
- package/.bob/cjs/layout/capital-gains.d.ts +0 -9
- package/.bob/cjs/layout/capital-gains.js +0 -15
- package/.bob/cjs/layout/countries.d.ts +0 -5
- package/.bob/cjs/layout/countries.js +0 -10
- package/.bob/cjs/layout/freeze.d.ts +0 -5
- package/.bob/cjs/layout/freeze.js +0 -16
- package/.bob/cjs/layout/registry.d.ts +0 -10
- package/.bob/cjs/layout/registry.js +0 -32
- package/.bob/cjs/layout/types.d.ts +0 -82
- package/.bob/cjs/layout/types.js +0 -35
- package/.bob/cjs/model/codes.generated.d.ts +0 -48
- package/.bob/cjs/model/codes.generated.js +0 -628
- package/.bob/cjs/model/index.d.ts +0 -3
- package/.bob/cjs/model/index.js +0 -5
- package/.bob/cjs/model/input.d.ts +0 -543
- package/.bob/cjs/model/input.js +0 -24
- package/.bob/cjs/model/normalized.d.ts +0 -43
- package/.bob/cjs/model/normalized.js +0 -0
- package/.bob/cjs/model/options.d.ts +0 -14
- package/.bob/cjs/model/options.js +0 -0
- package/.bob/cjs/model/schema.d.ts +0 -594
- package/.bob/cjs/model/schema.js +0 -339
- package/.bob/cjs/normalize/canonical.d.ts +0 -13
- package/.bob/cjs/normalize/canonical.js +0 -288
- package/.bob/cjs/normalize/capital-gains/assets.d.ts +0 -37
- package/.bob/cjs/normalize/capital-gains/assets.js +0 -94
- package/.bob/cjs/normalize/capital-gains/index.d.ts +0 -61
- package/.bob/cjs/normalize/capital-gains/index.js +0 -149
- package/.bob/cjs/normalize/capital-gains/no-withholding.d.ts +0 -18
- package/.bob/cjs/normalize/capital-gains/no-withholding.js +0 -36
- package/.bob/cjs/normalize/capital-gains/other.d.ts +0 -54
- package/.bob/cjs/normalize/capital-gains/other.js +0 -122
- package/.bob/cjs/normalize/capital-gains/section6.d.ts +0 -7
- package/.bob/cjs/normalize/capital-gains/section6.js +0 -13
- package/.bob/cjs/normalize/capital-gains/securities.d.ts +0 -26
- package/.bob/cjs/normalize/capital-gains/securities.js +0 -58
- package/.bob/cjs/normalize/denormalize.d.ts +0 -42
- package/.bob/cjs/normalize/denormalize.js +0 -359
- package/.bob/cjs/normalize/derive.d.ts +0 -57
- package/.bob/cjs/normalize/derive.js +0 -111
- package/.bob/cjs/normalize/enums.d.ts +0 -58
- package/.bob/cjs/normalize/enums.js +0 -69
- package/.bob/cjs/normalize/fields.d.ts +0 -28
- package/.bob/cjs/normalize/fields.js +0 -86
- package/.bob/cjs/normalize/foreign.d.ts +0 -22
- package/.bob/cjs/normalize/foreign.js +0 -85
- package/.bob/cjs/normalize/main.d.ts +0 -24
- package/.bob/cjs/normalize/main.js +0 -208
- package/.bob/cjs/normalize/paths.d.ts +0 -74
- package/.bob/cjs/normalize/paths.js +0 -169
- package/.bob/cjs/normalize/phone.d.ts +0 -12
- package/.bob/cjs/normalize/phone.js +0 -35
- package/.bob/cjs/normalize/rd-investments.d.ts +0 -10
- package/.bob/cjs/normalize/rd-investments.js +0 -25
- package/.bob/cjs/normalize/related-companies.d.ts +0 -10
- package/.bob/cjs/normalize/related-companies.js +0 -25
- package/.bob/cjs/normalize/report.d.ts +0 -9
- package/.bob/cjs/normalize/report.js +0 -53
- package/.bob/cjs/normalize/shareholders.d.ts +0 -10
- package/.bob/cjs/normalize/shareholders.js +0 -30
- package/.bob/cjs/normalize/text.d.ts +0 -11
- package/.bob/cjs/normalize/text.js +0 -41
- package/.bob/cjs/normalize/today.d.ts +0 -4
- package/.bob/cjs/normalize/today.js +0 -14
- package/.bob/cjs/pipeline.d.ts +0 -13
- package/.bob/cjs/pipeline.js +0 -37
- package/.bob/cjs/response/codes.d.ts +0 -2
- package/.bob/cjs/response/codes.js +0 -31
- package/.bob/cjs/validate/capital-gains-rules.d.ts +0 -6
- package/.bob/cjs/validate/capital-gains-rules.js +0 -162
- package/.bob/cjs/validate/check-digit.d.ts +0 -10
- package/.bob/cjs/validate/check-digit.js +0 -26
- package/.bob/cjs/validate/engine.d.ts +0 -5
- package/.bob/cjs/validate/engine.js +0 -35
- package/.bob/cjs/validate/field-rules.d.ts +0 -4
- package/.bob/cjs/validate/field-rules.js +0 -331
- package/.bob/cjs/validate/foreign-rules.d.ts +0 -6
- package/.bob/cjs/validate/foreign-rules.js +0 -171
- package/.bob/cjs/validate/issue.d.ts +0 -51
- package/.bob/cjs/validate/issue.js +0 -78
- package/.bob/cjs/validate/main-rules.d.ts +0 -24
- package/.bob/cjs/validate/main-rules.js +0 -425
- package/.bob/cjs/validate/parse-rules.d.ts +0 -31
- package/.bob/cjs/validate/parse-rules.js +0 -114
- package/.bob/cjs/validate/rules.d.ts +0 -746
- package/.bob/cjs/validate/rules.js +0 -680
- package/.bob/cjs/validate/shape.d.ts +0 -19
- package/.bob/cjs/validate/shape.js +0 -231
- package/.bob/cjs/validate/shareholder-rules.d.ts +0 -6
- package/.bob/cjs/validate/shareholder-rules.js +0 -83
- package/.bob/cjs/validate/structure-rules.d.ts +0 -26
- package/.bob/cjs/validate/structure-rules.js +0 -130
- package/.bob/esm/api/generate.d.ts +0 -44
- package/.bob/esm/api/generate.js +0 -111
- package/.bob/esm/api/parse.d.ts +0 -28
- package/.bob/esm/api/parse.js +0 -34
- package/.bob/esm/api/response.d.ts +0 -24
- package/.bob/esm/api/response.js +0 -72
- package/.bob/esm/api/validate.d.ts +0 -16
- package/.bob/esm/api/validate.js +0 -11
- package/.bob/esm/codec/boolean.d.ts +0 -7
- package/.bob/esm/codec/boolean.js +0 -46
- package/.bob/esm/codec/date.d.ts +0 -6
- package/.bob/esm/codec/date.js +0 -64
- package/.bob/esm/codec/enum.d.ts +0 -4
- package/.bob/esm/codec/enum.js +0 -23
- package/.bob/esm/codec/numeric.d.ts +0 -56
- package/.bob/esm/codec/numeric.js +0 -175
- package/.bob/esm/codec/padding.d.ts +0 -10
- package/.bob/esm/codec/padding.js +0 -21
- package/.bob/esm/codec/percent.d.ts +0 -6
- package/.bob/esm/codec/percent.js +0 -30
- package/.bob/esm/codec/phone.d.ts +0 -4
- package/.bob/esm/codec/phone.js +0 -45
- package/.bob/esm/codec/record.d.ts +0 -18
- package/.bob/esm/codec/record.js +0 -172
- package/.bob/esm/codec/registry.d.ts +0 -8
- package/.bob/esm/codec/registry.js +0 -23
- package/.bob/esm/codec/sections.d.ts +0 -41
- package/.bob/esm/codec/sections.js +0 -170
- package/.bob/esm/codec/text.d.ts +0 -5
- package/.bob/esm/codec/text.js +0 -26
- package/.bob/esm/codec/types.d.ts +0 -36
- package/.bob/esm/codec/types.js +0 -12
- package/.bob/esm/codec/windows1255.d.ts +0 -9
- package/.bob/esm/codec/windows1255.js +0 -32
- package/.bob/esm/errors.d.ts +0 -32
- package/.bob/esm/errors.js +0 -94
- package/.bob/esm/file/assemble.d.ts +0 -17
- package/.bob/esm/file/assemble.js +0 -25
- package/.bob/esm/file/control.d.ts +0 -13
- package/.bob/esm/file/control.js +0 -41
- package/.bob/esm/file/parse.d.ts +0 -18
- package/.bob/esm/file/parse.js +0 -474
- package/.bob/esm/file/split.d.ts +0 -17
- package/.bob/esm/file/split.js +0 -68
- package/.bob/esm/index.d.ts +0 -16
- package/.bob/esm/index.js +0 -11
- package/.bob/esm/layout/2024/layout.generated.d.ts +0 -6919
- package/.bob/esm/layout/2024/layout.generated.js +0 -7221
- package/.bob/esm/layout/2025/index.d.ts +0 -6
- package/.bob/esm/layout/2025/index.js +0 -7
- package/.bob/esm/layout/capital-gains.d.ts +0 -9
- package/.bob/esm/layout/capital-gains.js +0 -11
- package/.bob/esm/layout/countries.d.ts +0 -5
- package/.bob/esm/layout/countries.js +0 -7
- package/.bob/esm/layout/freeze.d.ts +0 -5
- package/.bob/esm/layout/freeze.js +0 -13
- package/.bob/esm/layout/registry.d.ts +0 -10
- package/.bob/esm/layout/registry.js +0 -27
- package/.bob/esm/layout/types.d.ts +0 -82
- package/.bob/esm/layout/types.js +0 -32
- package/.bob/esm/model/codes.generated.d.ts +0 -48
- package/.bob/esm/model/codes.generated.js +0 -625
- package/.bob/esm/model/index.d.ts +0 -3
- package/.bob/esm/model/index.js +0 -2
- package/.bob/esm/model/input.d.ts +0 -543
- package/.bob/esm/model/input.js +0 -21
- package/.bob/esm/model/normalized.d.ts +0 -43
- package/.bob/esm/model/normalized.js +0 -0
- package/.bob/esm/model/options.d.ts +0 -14
- package/.bob/esm/model/options.js +0 -0
- package/.bob/esm/model/schema.d.ts +0 -594
- package/.bob/esm/model/schema.js +0 -335
- package/.bob/esm/normalize/canonical.d.ts +0 -13
- package/.bob/esm/normalize/canonical.js +0 -285
- package/.bob/esm/normalize/capital-gains/assets.d.ts +0 -37
- package/.bob/esm/normalize/capital-gains/assets.js +0 -87
- package/.bob/esm/normalize/capital-gains/index.d.ts +0 -61
- package/.bob/esm/normalize/capital-gains/index.js +0 -142
- package/.bob/esm/normalize/capital-gains/no-withholding.d.ts +0 -18
- package/.bob/esm/normalize/capital-gains/no-withholding.js +0 -31
- package/.bob/esm/normalize/capital-gains/other.d.ts +0 -54
- package/.bob/esm/normalize/capital-gains/other.js +0 -112
- package/.bob/esm/normalize/capital-gains/section6.d.ts +0 -7
- package/.bob/esm/normalize/capital-gains/section6.js +0 -9
- package/.bob/esm/normalize/capital-gains/securities.d.ts +0 -26
- package/.bob/esm/normalize/capital-gains/securities.js +0 -52
- package/.bob/esm/normalize/denormalize.d.ts +0 -42
- package/.bob/esm/normalize/denormalize.js +0 -354
- package/.bob/esm/normalize/derive.d.ts +0 -57
- package/.bob/esm/normalize/derive.js +0 -99
- package/.bob/esm/normalize/enums.d.ts +0 -58
- package/.bob/esm/normalize/enums.js +0 -64
- package/.bob/esm/normalize/fields.d.ts +0 -28
- package/.bob/esm/normalize/fields.js +0 -81
- package/.bob/esm/normalize/foreign.d.ts +0 -22
- package/.bob/esm/normalize/foreign.js +0 -81
- package/.bob/esm/normalize/main.d.ts +0 -24
- package/.bob/esm/normalize/main.js +0 -204
- package/.bob/esm/normalize/paths.d.ts +0 -74
- package/.bob/esm/normalize/paths.js +0 -161
- package/.bob/esm/normalize/phone.d.ts +0 -12
- package/.bob/esm/normalize/phone.js +0 -32
- package/.bob/esm/normalize/rd-investments.d.ts +0 -10
- package/.bob/esm/normalize/rd-investments.js +0 -22
- package/.bob/esm/normalize/related-companies.d.ts +0 -10
- package/.bob/esm/normalize/related-companies.js +0 -22
- package/.bob/esm/normalize/report.d.ts +0 -9
- package/.bob/esm/normalize/report.js +0 -50
- package/.bob/esm/normalize/shareholders.d.ts +0 -10
- package/.bob/esm/normalize/shareholders.js +0 -27
- package/.bob/esm/normalize/text.d.ts +0 -11
- package/.bob/esm/normalize/text.js +0 -37
- package/.bob/esm/normalize/today.d.ts +0 -4
- package/.bob/esm/normalize/today.js +0 -11
- package/.bob/esm/pipeline.d.ts +0 -13
- package/.bob/esm/pipeline.js +0 -34
- package/.bob/esm/response/codes.d.ts +0 -2
- package/.bob/esm/response/codes.js +0 -28
- package/.bob/esm/validate/capital-gains-rules.d.ts +0 -6
- package/.bob/esm/validate/capital-gains-rules.js +0 -159
- package/.bob/esm/validate/check-digit.d.ts +0 -10
- package/.bob/esm/validate/check-digit.js +0 -23
- package/.bob/esm/validate/engine.d.ts +0 -5
- package/.bob/esm/validate/engine.js +0 -32
- package/.bob/esm/validate/field-rules.d.ts +0 -4
- package/.bob/esm/validate/field-rules.js +0 -328
- package/.bob/esm/validate/foreign-rules.d.ts +0 -6
- package/.bob/esm/validate/foreign-rules.js +0 -168
- package/.bob/esm/validate/issue.d.ts +0 -51
- package/.bob/esm/validate/issue.js +0 -72
- package/.bob/esm/validate/main-rules.d.ts +0 -24
- package/.bob/esm/validate/main-rules.js +0 -420
- package/.bob/esm/validate/parse-rules.d.ts +0 -31
- package/.bob/esm/validate/parse-rules.js +0 -110
- package/.bob/esm/validate/rules.d.ts +0 -746
- package/.bob/esm/validate/rules.js +0 -676
- package/.bob/esm/validate/shape.d.ts +0 -19
- package/.bob/esm/validate/shape.js +0 -227
- package/.bob/esm/validate/shareholder-rules.d.ts +0 -6
- package/.bob/esm/validate/shareholder-rules.js +0 -80
- package/.bob/esm/validate/structure-rules.d.ts +0 -26
- package/.bob/esm/validate/structure-rules.js +0 -122
- package/.bob/tsconfig.tsbuildinfo +0 -1
- package/.gitattributes +0 -1
- package/CLAUDE.md +0 -39
- package/dist/cjs/index.js +0 -28
- package/dist/esm/index.js +0 -11
- package/documentation/IMPLEMENTATION_PLAN.md +0 -2258
- package/documentation/SPEC.md +0 -1803
- package/documentation/layout/2024/codes.csv +0 -261
- package/documentation/layout/2024/countries.csv +0 -256
- package/documentation/layout/2024/fields.csv +0 -271
- package/documentation/layout/2024/records.csv +0 -18
- package/documentation/layout/README.md +0 -87
- package/documentation/specifications/1214-2024.pdf +0 -0
- package/documentation/tools/extract_layout.py +0 -191
- package/scripts/generate-layout.ts +0 -23
- package/scripts/layout/csv.ts +0 -111
- package/scripts/layout/derived-codes.ts +0 -12
- package/scripts/layout/render.ts +0 -364
- package/scripts/layout/sources.ts +0 -51
- package/scripts/layout/values.ts +0 -42
- package/scripts/render-rules-table.ts +0 -66
- package/src/api/generate.ts +0 -169
- package/src/api/parse.ts +0 -58
- package/src/api/response.ts +0 -110
- package/src/api/validate.ts +0 -26
- package/src/codec/boolean.ts +0 -62
- package/src/codec/date.ts +0 -75
- package/src/codec/enum.ts +0 -28
- package/src/codec/numeric.ts +0 -208
- package/src/codec/padding.ts +0 -33
- package/src/codec/percent.ts +0 -35
- package/src/codec/phone.ts +0 -54
- package/src/codec/record.ts +0 -206
- package/src/codec/registry.ts +0 -27
- package/src/codec/sections.ts +0 -208
- package/src/codec/text.ts +0 -31
- package/src/codec/types.ts +0 -47
- package/src/codec/windows1255.ts +0 -38
- package/src/errors.ts +0 -114
- package/src/file/assemble.ts +0 -42
- package/src/file/control.ts +0 -59
- package/src/file/parse.ts +0 -620
- package/src/file/split.ts +0 -86
- package/src/index.ts +0 -70
- package/src/layout/2024/layout.generated.ts +0 -7238
- package/src/layout/2025/index.ts +0 -9
- package/src/layout/capital-gains.ts +0 -20
- package/src/layout/countries.ts +0 -7
- package/src/layout/freeze.ts +0 -13
- package/src/layout/registry.ts +0 -33
- package/src/layout/types.ts +0 -134
- package/src/model/codes.generated.ts +0 -1190
- package/src/model/index.ts +0 -4
- package/src/model/input.ts +0 -594
- package/src/model/normalized.ts +0 -38
- package/src/model/options.ts +0 -17
- package/src/model/schema.ts +0 -381
- package/src/normalize/canonical.ts +0 -374
- package/src/normalize/capital-gains/assets.ts +0 -112
- package/src/normalize/capital-gains/index.ts +0 -212
- package/src/normalize/capital-gains/no-withholding.ts +0 -46
- package/src/normalize/capital-gains/other.ts +0 -153
- package/src/normalize/capital-gains/section6.ts +0 -14
- package/src/normalize/capital-gains/securities.ts +0 -73
- package/src/normalize/denormalize.ts +0 -426
- package/src/normalize/derive.ts +0 -136
- package/src/normalize/enums.ts +0 -87
- package/src/normalize/fields.ts +0 -110
- package/src/normalize/foreign.ts +0 -114
- package/src/normalize/main.ts +0 -284
- package/src/normalize/paths.ts +0 -184
- package/src/normalize/phone.ts +0 -45
- package/src/normalize/rd-investments.ts +0 -38
- package/src/normalize/related-companies.ts +0 -37
- package/src/normalize/report.ts +0 -59
- package/src/normalize/shareholders.ts +0 -42
- package/src/normalize/text.ts +0 -40
- package/src/normalize/today.ts +0 -15
- package/src/pipeline.ts +0 -42
- package/src/response/codes.ts +0 -30
- package/src/validate/capital-gains-rules.ts +0 -199
- package/src/validate/check-digit.ts +0 -25
- package/src/validate/engine.ts +0 -45
- package/src/validate/field-rules.ts +0 -383
- package/src/validate/foreign-rules.ts +0 -274
- package/src/validate/issue.ts +0 -121
- package/src/validate/main-rules.ts +0 -678
- package/src/validate/parse-rules.ts +0 -169
- package/src/validate/rules.ts +0 -747
- package/src/validate/shape.ts +0 -278
- package/src/validate/shareholder-rules.ts +0 -92
- package/src/validate/structure-rules.ts +0 -136
- package/tests/api/batch.test.ts +0 -227
- package/tests/api/exports.test.ts +0 -355
- package/tests/api/generate.test.ts +0 -409
- package/tests/api/parse.test.ts +0 -789
- package/tests/api/response.test.ts +0 -152
- package/tests/api/validate.test.ts +0 -86
- package/tests/codec/numeric.test.ts +0 -325
- package/tests/codec/record.test.ts +0 -318
- package/tests/codec/registry.test.ts +0 -17
- package/tests/codec/sections.test.ts +0 -333
- package/tests/codec/text.test.ts +0 -454
- package/tests/codec/windows1255.test.ts +0 -46
- package/tests/docs/readme.test.ts +0 -69
- package/tests/edge-cases.test.ts +0 -359
- package/tests/errors.test.ts +0 -138
- package/tests/file/assemble.test.ts +0 -188
- package/tests/file/split.test.ts +0 -61
- package/tests/fixtures/builders.ts +0 -512
- package/tests/fixtures/files.ts +0 -78
- package/tests/fixtures/golden/README.md +0 -37
- package/tests/fixtures/golden/VERIFICATION.md +0 -72
- package/tests/fixtures/golden/batch-50.input.ts +0 -92
- package/tests/fixtures/golden/batch-50.opcn +0 -150
- package/tests/fixtures/golden/capital-gains-max.input.ts +0 -177
- package/tests/fixtures/golden/capital-gains-max.opcn +0 -17
- package/tests/fixtures/golden/cg-27.input.ts +0 -63
- package/tests/fixtures/golden/cg-27.opcn +0 -4
- package/tests/fixtures/golden/cg-50.input.ts +0 -59
- package/tests/fixtures/golden/cg-50.opcn +0 -4
- package/tests/fixtures/golden/cg-51.input.ts +0 -60
- package/tests/fixtures/golden/cg-51.opcn +0 -4
- package/tests/fixtures/golden/cg-54.input.ts +0 -53
- package/tests/fixtures/golden/cg-54.opcn +0 -4
- package/tests/fixtures/golden/cg-60.input.ts +0 -77
- package/tests/fixtures/golden/cg-60.opcn +0 -4
- package/tests/fixtures/golden/cg-63.input.ts +0 -51
- package/tests/fixtures/golden/cg-63.opcn +0 -4
- package/tests/fixtures/golden/cg-64.input.ts +0 -62
- package/tests/fixtures/golden/cg-64.opcn +0 -4
- package/tests/fixtures/golden/cg-65.input.ts +0 -79
- package/tests/fixtures/golden/cg-65.opcn +0 -4
- package/tests/fixtures/golden/cg-66.input.ts +0 -53
- package/tests/fixtures/golden/cg-66.opcn +0 -4
- package/tests/fixtures/golden/cg-77.input.ts +0 -109
- package/tests/fixtures/golden/cg-77.opcn +0 -4
- package/tests/fixtures/golden/foreign.input.ts +0 -202
- package/tests/fixtures/golden/foreign.opcn +0 -27
- package/tests/fixtures/golden/hebrew-edge.input.ts +0 -90
- package/tests/fixtures/golden/hebrew-edge.opcn +0 -8
- package/tests/fixtures/golden/kibbutz.input.ts +0 -31
- package/tests/fixtures/golden/kibbutz.opcn +0 -2
- package/tests/fixtures/golden/main-full.input.ts +0 -780
- package/tests/fixtures/golden/main-full.opcn +0 -101
- package/tests/fixtures/golden/minimal.input.ts +0 -37
- package/tests/fixtures/golden/minimal.opcn +0 -3
- package/tests/fixtures/golden/related-and-rd.input.ts +0 -59
- package/tests/fixtures/golden/related-and-rd.opcn +0 -11
- package/tests/fixtures/random.ts +0 -843
- package/tests/golden/fixtures.test.ts +0 -627
- package/tests/golden/golden.test.ts +0 -95
- package/tests/helpers/coverage.ts +0 -18
- package/tests/helpers/sample-values.ts +0 -114
- package/tests/layout/codegen-sync.test.ts +0 -19
- package/tests/layout/integrity.test.ts +0 -232
- package/tests/layout/registry.test.ts +0 -98
- package/tests/model/code-unions.test.ts +0 -91
- package/tests/model/schema.test.ts +0 -1031
- package/tests/normalize/canonical.test.ts +0 -728
- package/tests/normalize/capital-gains.test.ts +0 -1850
- package/tests/normalize/coverage.test.ts +0 -88
- package/tests/normalize/denormalize.test.ts +0 -318
- package/tests/normalize/enums.test.ts +0 -118
- package/tests/normalize/foreign.test.ts +0 -273
- package/tests/normalize/main.test.ts +0 -839
- package/tests/normalize/paths.test.ts +0 -257
- package/tests/normalize/rd-investments.test.ts +0 -99
- package/tests/normalize/related-companies.test.ts +0 -106
- package/tests/normalize/shareholders.test.ts +0 -117
- package/tests/normalize/text.test.ts +0 -86
- package/tests/pipeline.test.ts +0 -96
- package/tests/roundtrip/determinism.test.ts +0 -207
- package/tests/roundtrip/property.test.ts +0 -126
- package/tests/roundtrip/roundtrip.test.ts +0 -573
- package/tests/rules/cases.ts +0 -873
- package/tests/rules/rules.test.ts +0 -69
- package/tests/rules/spec-sync.test.ts +0 -80
- package/tests/scripts/csv.test.ts +0 -78
- package/tests/scripts/values.test.ts +0 -80
- package/tests/validate/capital-gains-rules.test.ts +0 -307
- package/tests/validate/check-digit.test.ts +0 -42
- package/tests/validate/field-rules.test.ts +0 -867
- package/tests/validate/foreign-rules.test.ts +0 -255
- package/tests/validate/issue.test.ts +0 -96
- package/tests/validate/main-rules.test.ts +0 -761
- package/tests/validate/parse-rules.test.ts +0 -293
- package/tests/validate/shareholder-rules.test.ts +0 -143
- package/tsconfig.json +0 -10
- package/tsconfig.typecheck.json +0 -9
- package/vitest.config.ts +0 -11
|
@@ -1,1850 +0,0 @@
|
|
|
1
|
-
import { renderReport } from '../../src/file/assemble.js';
|
|
2
|
-
import { generate1214, parse1214, validate1214 } from '../../src/index.js';
|
|
3
|
-
import {
|
|
4
|
-
capitalGainsRecordType,
|
|
5
|
-
isCapitalGainsRecordType,
|
|
6
|
-
} from '../../src/layout/capital-gains.js';
|
|
7
|
-
import { getLayout } from '../../src/layout/registry.js';
|
|
8
|
-
import type { Report1214Input } from '../../src/model/input.js';
|
|
9
|
-
import type { ValidateOptions } from '../../src/model/options.js';
|
|
10
|
-
import { placeCapitalGains } from '../../src/normalize/capital-gains/index.js';
|
|
11
|
-
import { normalizeReport } from '../../src/normalize/report.js';
|
|
12
|
-
import { fieldRules } from '../../src/validate/field-rules.js';
|
|
13
|
-
import {
|
|
14
|
-
bettermentTaxAppendix,
|
|
15
|
-
breakdownCountries,
|
|
16
|
-
forcedVirtualCurrencyAppendix,
|
|
17
|
-
foreignAppendixWithBreakdown,
|
|
18
|
-
improvements,
|
|
19
|
-
minimalInput,
|
|
20
|
-
noWithholding1322Appendix,
|
|
21
|
-
noWithholding1326Appendix,
|
|
22
|
-
oilPartnershipAppendix,
|
|
23
|
-
otherTransactionsAppendix,
|
|
24
|
-
rdInvestments,
|
|
25
|
-
rdInvestmentsTotal,
|
|
26
|
-
reitAppendix,
|
|
27
|
-
section6Appendices,
|
|
28
|
-
section6Appendix,
|
|
29
|
-
securitiesAppendix,
|
|
30
|
-
sharesAppendix,
|
|
31
|
-
withholders,
|
|
32
|
-
} from '../fixtures/builders.js';
|
|
33
|
-
import { unmappedHeaderKeys } from '../helpers/coverage.js';
|
|
34
|
-
|
|
35
|
-
const LAYOUT = getLayout(2024);
|
|
36
|
-
const OPTIONS: ValidateOptions = { today: () => '2024-06-30' };
|
|
37
|
-
|
|
38
|
-
function reportOf(input: Report1214Input, options = OPTIONS) {
|
|
39
|
-
return normalizeReport(input, LAYOUT, options);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function capitalGainsRecords(input: Report1214Input, options = OPTIONS) {
|
|
43
|
-
return reportOf(input, options).records.filter(r => isCapitalGainsRecordType(r.recordType));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function mainOf(input: Report1214Input) {
|
|
47
|
-
const main = reportOf(input).records[0];
|
|
48
|
-
if (main?.recordType !== '1000') {
|
|
49
|
-
throw new Error('expected record 1000 first');
|
|
50
|
-
}
|
|
51
|
-
return main;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** The lines of the file of `input`, 9999 last. */
|
|
55
|
-
function linesOf(input: Report1214Input): string[] {
|
|
56
|
-
return renderReport(reportOf(input)).lines;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** The `length` characters of `line` at the 1-based layout `position`. */
|
|
60
|
-
function at(line: string | undefined, position: number, length: number): string | undefined {
|
|
61
|
-
return line?.slice(position - 1, position - 1 + length);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
describe('capital-gains record types (SPEC §3.7)', () => {
|
|
65
|
-
it('maps a symbol to its record type, 3000 + symbol', () => {
|
|
66
|
-
expect(capitalGainsRecordType(63)).toBe('3063');
|
|
67
|
-
expect(capitalGainsRecordType(27)).toBe('3027');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('recognizes the ten capital-gains record types only', () => {
|
|
71
|
-
const types = Object.keys(LAYOUT.records).filter(type =>
|
|
72
|
-
isCapitalGainsRecordType(type as keyof typeof LAYOUT.records),
|
|
73
|
-
);
|
|
74
|
-
expect(types).toEqual([
|
|
75
|
-
'3027',
|
|
76
|
-
'3050',
|
|
77
|
-
'3051',
|
|
78
|
-
'3054',
|
|
79
|
-
'3060',
|
|
80
|
-
'3063',
|
|
81
|
-
'3064',
|
|
82
|
-
'3065',
|
|
83
|
-
'3066',
|
|
84
|
-
'3077',
|
|
85
|
-
]);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('placeCapitalGains (SPEC §3.3, §7.4, §15 A-7)', () => {
|
|
90
|
-
const appendices = [
|
|
91
|
-
{ symbol: 77, name: 'a' },
|
|
92
|
-
{ symbol: 63, name: 'b' },
|
|
93
|
-
{ symbol: 77, name: 'c' },
|
|
94
|
-
{ symbol: 27, name: 'd' },
|
|
95
|
-
{ symbol: 63, name: 'e' },
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
it('groups by record type ascending, input order within a type', () => {
|
|
99
|
-
expect(placeCapitalGains(appendices).map(placed => placed.appendix.name)).toEqual([
|
|
100
|
-
'd',
|
|
101
|
-
'b',
|
|
102
|
-
'e',
|
|
103
|
-
'a',
|
|
104
|
-
'c',
|
|
105
|
-
]);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('keeps the input index of every appendix', () => {
|
|
109
|
-
expect(placeCapitalGains(appendices).map(placed => placed.inputIndex)).toEqual([3, 1, 4, 0, 2]);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('numbers appendices per symbol (30xx@139), 1-based in emission order', () => {
|
|
113
|
-
expect(placeCapitalGains(appendices).map(placed => placed.appendixNumber)).toEqual([
|
|
114
|
-
1, 1, 2, 1, 2,
|
|
115
|
-
]);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('numbers the "מספר בתל"ם" sequence across all appendices, 1-based in emission order', () => {
|
|
119
|
-
expect(placeCapitalGains(appendices).map(placed => placed.sequenceNumber)).toEqual([
|
|
120
|
-
1, 2, 3, 4, 5,
|
|
121
|
-
]);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('places nothing for no appendices', () => {
|
|
125
|
-
expect(placeCapitalGains([])).toEqual([]);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe('normalizeReport: record 3063 (securities under section 6)', () => {
|
|
130
|
-
it('maps the header and the codes, with paths capitalGains[i].<key> and amounts["NNN"]', () => {
|
|
131
|
-
const [record] = capitalGainsRecords(minimalInput({ capitalGains: [section6Appendix()] }));
|
|
132
|
-
expect(record?.recordType).toBe('3063');
|
|
133
|
-
expect(record?.index).toBe(0);
|
|
134
|
-
expect(record?.inputIndex).toBe(0);
|
|
135
|
-
expect(record?.values).toEqual({
|
|
136
|
-
transactionSymbol: 63,
|
|
137
|
-
appendixNumber: 1,
|
|
138
|
-
foreignAsset: true,
|
|
139
|
-
lossesCarriedForward: 12_000,
|
|
140
|
-
});
|
|
141
|
-
expect([...(record?.codes ?? [])]).toEqual([
|
|
142
|
-
['022', 50_000],
|
|
143
|
-
['056', 3000],
|
|
144
|
-
]);
|
|
145
|
-
expect(record?.countries).toEqual([]);
|
|
146
|
-
expect(record?.paths).toEqual({
|
|
147
|
-
transactionSymbol: '',
|
|
148
|
-
appendixNumber: '',
|
|
149
|
-
foreignAsset: 'capitalGains[0].foreignAsset',
|
|
150
|
-
lossesCarriedForward: 'capitalGains[0].lossesCarriedForward',
|
|
151
|
-
'code:022': 'capitalGains[0].amounts["022"]',
|
|
152
|
-
'code:056': 'capitalGains[0].amounts["056"]',
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('sets every non-filler header field of record 3063', () => {
|
|
157
|
-
const report = reportOf(minimalInput({ capitalGains: [section6Appendix()] }));
|
|
158
|
-
expect(unmappedHeaderKeys(LAYOUT.records['3063'], report.records)).toEqual([]);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('writes the symbol at 137 and the appendix number at 139, the section at 1161', () => {
|
|
162
|
-
const lines = linesOf(minimalInput({ capitalGains: [section6Appendix()] }));
|
|
163
|
-
const line = lines.find(text => text.slice(4, 8) === '3063');
|
|
164
|
-
expect(at(line, 137, 2)).toBe('63');
|
|
165
|
-
expect(at(line, 139, 3)).toBe('001');
|
|
166
|
-
expect(at(line, 142, 1)).toBe('1');
|
|
167
|
-
expect(at(line, 143, 10)).toBe('0000012000');
|
|
168
|
-
expect(at(line, 1161, 26)).toBe('0220000050000' + '0560000003000');
|
|
169
|
-
expect(line?.slice(1186)).toMatch(/^0+$/);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('writes foreignAsset false as 2 (no) and an absent one as 0', () => {
|
|
173
|
-
const [no] = linesOf(
|
|
174
|
-
minimalInput({ capitalGains: [section6Appendix({ foreignAsset: false })] }),
|
|
175
|
-
).filter(text => text.slice(4, 8) === '3063');
|
|
176
|
-
expect(at(no, 142, 1)).toBe('2');
|
|
177
|
-
const [absent] = linesOf(minimalInput({ capitalGains: [{ symbol: 63, amounts: {} }] })).filter(
|
|
178
|
-
text => text.slice(4, 8) === '3063',
|
|
179
|
-
);
|
|
180
|
-
expect(at(absent, 142, 1)).toBe('0');
|
|
181
|
-
expect(at(absent, 143, 10)).toBe('0'.repeat(10));
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('numbers two 3063 appendices 1 and 2, in input order, with their input index', () => {
|
|
185
|
-
const records = capitalGainsRecords(minimalInput({ capitalGains: section6Appendices(2) }));
|
|
186
|
-
expect(records.map(r => [r.index, r.inputIndex, r.values.appendixNumber])).toEqual([
|
|
187
|
-
[0, 0, 1],
|
|
188
|
-
[1, 1, 2],
|
|
189
|
-
]);
|
|
190
|
-
expect(records[1]?.codes.get('022')).toBe(2000);
|
|
191
|
-
expect(records[1]?.paths['code:022']).toBe('capitalGains[1].amounts["022"]');
|
|
192
|
-
const lines = linesOf(minimalInput({ capitalGains: section6Appendices(2) }));
|
|
193
|
-
expect(lines.filter(text => text.slice(4, 8) === '3063').map(text => at(text, 139, 3))).toEqual(
|
|
194
|
-
['001', '002'],
|
|
195
|
-
);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it('omits zero codes (none of 3063 is zeroAllowed) and lists them by record index', () => {
|
|
199
|
-
const report = reportOf(
|
|
200
|
-
minimalInput({
|
|
201
|
-
capitalGains: [
|
|
202
|
-
section6Appendix(),
|
|
203
|
-
section6Appendix({ amounts: { '022': 0, '023': 0, '026': 5 } }),
|
|
204
|
-
],
|
|
205
|
-
}),
|
|
206
|
-
);
|
|
207
|
-
const second = report.records.filter(r => r.recordType === '3063')[1];
|
|
208
|
-
expect([...(second?.codes.keys() ?? [])]).toEqual(['026', '056']);
|
|
209
|
-
expect(report.omittedZeroCodes).toEqual([
|
|
210
|
-
{ record: '3063', recordIndex: 1, code: '022' },
|
|
211
|
-
{ record: '3063', recordIndex: 1, code: '023' },
|
|
212
|
-
]);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it('rounds the losses and the codes per options.rounding', () => {
|
|
216
|
-
const [record] = capitalGainsRecords(
|
|
217
|
-
minimalInput({
|
|
218
|
-
capitalGains: [section6Appendix({ lossesCarriedForward: 99.5, amounts: { '022': 0.4 } })],
|
|
219
|
-
}),
|
|
220
|
-
{ ...OPTIONS, rounding: 'halfUp' },
|
|
221
|
-
);
|
|
222
|
-
expect(record?.values.lossesCarriedForward).toBe(100);
|
|
223
|
-
expect(record?.codes.has('022')).toBe(false);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('emits the capital-gains records after 1030, 2000 and 2200', () => {
|
|
227
|
-
const report = reportOf(
|
|
228
|
-
minimalInput({
|
|
229
|
-
rdInvestments: rdInvestments(1),
|
|
230
|
-
amounts: { '165': rdInvestmentsTotal(1) },
|
|
231
|
-
foreignAppendix: foreignAppendixWithBreakdown('420', {
|
|
232
|
-
countries: breakdownCountries(1),
|
|
233
|
-
}),
|
|
234
|
-
capitalGains: section6Appendices(2),
|
|
235
|
-
}),
|
|
236
|
-
);
|
|
237
|
-
expect(report.records.map(r => [r.recordType, r.index])).toEqual([
|
|
238
|
-
['1000', 0],
|
|
239
|
-
['1020', 0],
|
|
240
|
-
['1030', 0],
|
|
241
|
-
['2000', 0],
|
|
242
|
-
['2200', 0],
|
|
243
|
-
['3063', 0],
|
|
244
|
-
['3063', 1],
|
|
245
|
-
]);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('emits no capital-gains record without appendices or for an empty list', () => {
|
|
249
|
-
expect(capitalGainsRecords(minimalInput())).toEqual([]);
|
|
250
|
-
expect(capitalGainsRecords(minimalInput({ capitalGains: [] }))).toEqual([]);
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
describe('1000@833, code 028 and 9999@145 from the appendices (SPEC §7.4)', () => {
|
|
255
|
-
it('833 = yes when any appendix exists', () => {
|
|
256
|
-
const main = mainOf(minimalInput({ capitalGains: [section6Appendix()] }));
|
|
257
|
-
expect(main.values['declarations.hasCapitalGainsAppendix']).toBe(true);
|
|
258
|
-
expect(at(linesOf(minimalInput({ capitalGains: [section6Appendix()] }))[0], 833, 1)).toBe('1');
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it('833 = no without appendices, untransmitted count or override', () => {
|
|
262
|
-
expect(mainOf(minimalInput({ capitalGains: [] })).values).toMatchObject({
|
|
263
|
-
'declarations.hasCapitalGainsAppendix': false,
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('code 028 = appendices + untransmittedCount', () => {
|
|
268
|
-
const main = mainOf(
|
|
269
|
-
minimalInput({
|
|
270
|
-
capitalGains: section6Appendices(2),
|
|
271
|
-
capitalGainsSummary: { untransmittedCount: 3, reasons: { lossOrNoGain: true } },
|
|
272
|
-
}),
|
|
273
|
-
);
|
|
274
|
-
expect(main.codes.get('028')).toBe(5);
|
|
275
|
-
expect(main.paths['code:028']).toBe('');
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('code 028 = the number of appendices without untransmitted ones', () => {
|
|
279
|
-
expect(mainOf(minimalInput({ capitalGains: section6Appendices(2) })).codes.get('028')).toBe(2);
|
|
280
|
-
expect(mainOf(minimalInput()).codes.has('028')).toBe(false);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('9999@145 counts the capital-gains appendices', () => {
|
|
284
|
-
expect(at(linesOf(minimalInput({ capitalGains: section6Appendices(3) })).at(-1), 145, 2)).toBe(
|
|
285
|
-
'03',
|
|
286
|
-
);
|
|
287
|
-
expect(at(linesOf(minimalInput()).at(-1), 145, 2)).toBe('00');
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('raises main.capitalGains.flag when hasCapitalGainsAppendix is false while appendices exist', () => {
|
|
291
|
-
const report = reportOf(
|
|
292
|
-
minimalInput({
|
|
293
|
-
declarations: { hasCapitalGainsAppendix: false },
|
|
294
|
-
capitalGains: [section6Appendix()],
|
|
295
|
-
}),
|
|
296
|
-
);
|
|
297
|
-
expect(report.notices).toEqual([
|
|
298
|
-
expect.objectContaining({
|
|
299
|
-
ruleId: 'main.capitalGains.flag',
|
|
300
|
-
severity: 'error',
|
|
301
|
-
path: 'declarations.hasCapitalGainsAppendix',
|
|
302
|
-
recordType: '1000',
|
|
303
|
-
recordIndex: 0,
|
|
304
|
-
value: false,
|
|
305
|
-
}),
|
|
306
|
-
]);
|
|
307
|
-
// 833 itself is derived: yes.
|
|
308
|
-
expect(report.records[0]?.values['declarations.hasCapitalGainsAppendix']).toBe(true);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('raises no notice for false without appendices, or true with appendices', () => {
|
|
312
|
-
const noticesOf = (overrides: Parameters<typeof minimalInput>[0]) =>
|
|
313
|
-
reportOf(minimalInput(overrides)).notices;
|
|
314
|
-
expect(noticesOf({ declarations: { hasCapitalGainsAppendix: false } })).toEqual([]);
|
|
315
|
-
expect(
|
|
316
|
-
noticesOf({
|
|
317
|
-
declarations: { hasCapitalGainsAppendix: true },
|
|
318
|
-
capitalGains: [section6Appendix()],
|
|
319
|
-
}),
|
|
320
|
-
).toEqual([]);
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
/** The lines of record type `type` in the file of `input`. */
|
|
325
|
-
function linesOfType(input: Report1214Input, type: string): string[] {
|
|
326
|
-
return linesOf(input).filter(text => text.slice(4, 8) === type);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
describe.each([
|
|
330
|
-
['3060', 'securities', securitiesAppendix],
|
|
331
|
-
['3064', 'REIT', reitAppendix],
|
|
332
|
-
] as const)('normalizeReport: record %s (%s, with withholders)', (type, _name, build) => {
|
|
333
|
-
const def = LAYOUT.records[type];
|
|
334
|
-
|
|
335
|
-
it('has the shared securities header, the same keys at the same positions as the other type', () => {
|
|
336
|
-
const other = LAYOUT.records[type === '3060' ? '3064' : '3060'];
|
|
337
|
-
const shape = (fields: typeof def.fields) =>
|
|
338
|
-
fields.filter(f => f.kind !== 'filler').map(f => [f.key, f.position, f.length, f.kind]);
|
|
339
|
-
expect(shape(def.fields)).toEqual(shape(other.fields));
|
|
340
|
-
// No "מספר בתל"ם" sequence field: the header is symbol, appendix number, members only.
|
|
341
|
-
expect(def.fields.filter(f => f.kind !== 'filler').map(f => f.key)).toEqual([
|
|
342
|
-
'transactionSymbol',
|
|
343
|
-
'appendixNumber',
|
|
344
|
-
'foreignAsset',
|
|
345
|
-
'soldToRelatedParty',
|
|
346
|
-
'boughtFromRelatedParty',
|
|
347
|
-
'gainFromInvestmentFund',
|
|
348
|
-
...[0, 1, 2, 3].flatMap(i => [
|
|
349
|
-
`withholders[${i}].name`,
|
|
350
|
-
`withholders[${i}].branch`,
|
|
351
|
-
`withholders[${i}].account`,
|
|
352
|
-
]),
|
|
353
|
-
'lossesCarriedForward',
|
|
354
|
-
]);
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('maps the header, withholders[j] to keys withholders[j].<member>, with input paths', () => {
|
|
358
|
-
const appendix = build({ withholders: withholders(2) });
|
|
359
|
-
const [record] = capitalGainsRecords(minimalInput({ capitalGains: [appendix] }));
|
|
360
|
-
expect(record?.recordType).toBe(type);
|
|
361
|
-
expect(record?.inputIndex).toBe(0);
|
|
362
|
-
expect(record?.values).toEqual({
|
|
363
|
-
transactionSymbol: Number(type.slice(2)),
|
|
364
|
-
appendixNumber: 1,
|
|
365
|
-
foreignAsset: appendix.foreignAsset,
|
|
366
|
-
soldToRelatedParty: appendix.soldToRelatedParty,
|
|
367
|
-
boughtFromRelatedParty: appendix.boughtFromRelatedParty,
|
|
368
|
-
gainFromInvestmentFund: appendix.gainFromInvestmentFund,
|
|
369
|
-
'withholders[0].name': 'בנק הפועלים',
|
|
370
|
-
'withholders[0].branch': '011',
|
|
371
|
-
'withholders[0].account': '000123450',
|
|
372
|
-
'withholders[1].name': 'בנק לאומי',
|
|
373
|
-
'withholders[1].branch': '012',
|
|
374
|
-
'withholders[1].account': '000123451',
|
|
375
|
-
lossesCarriedForward: appendix.lossesCarriedForward,
|
|
376
|
-
});
|
|
377
|
-
expect(record?.paths).toMatchObject({
|
|
378
|
-
transactionSymbol: '',
|
|
379
|
-
appendixNumber: '',
|
|
380
|
-
foreignAsset: 'capitalGains[0].foreignAsset',
|
|
381
|
-
gainFromInvestmentFund: 'capitalGains[0].gainFromInvestmentFund',
|
|
382
|
-
'withholders[1].name': 'capitalGains[0].withholders[1].name',
|
|
383
|
-
'withholders[1].branch': 'capitalGains[0].withholders[1].branch',
|
|
384
|
-
'withholders[1].account': 'capitalGains[0].withholders[1].account',
|
|
385
|
-
lossesCarriedForward: 'capitalGains[0].lossesCarriedForward',
|
|
386
|
-
'code:056': 'capitalGains[0].amounts["056"]',
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
it('sets every non-filler header field with four withholders', () => {
|
|
391
|
-
const report = reportOf(
|
|
392
|
-
minimalInput({ capitalGains: [build({ withholders: withholders(4) })] }),
|
|
393
|
-
);
|
|
394
|
-
expect(unmappedHeaderKeys(def, report.records)).toEqual([]);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('writes the header at its layout positions', () => {
|
|
398
|
-
const [line] = linesOfType(
|
|
399
|
-
minimalInput({
|
|
400
|
-
capitalGains: [
|
|
401
|
-
build({
|
|
402
|
-
foreignAsset: true,
|
|
403
|
-
soldToRelatedParty: false,
|
|
404
|
-
boughtFromRelatedParty: true,
|
|
405
|
-
gainFromInvestmentFund: false,
|
|
406
|
-
withholders: [{}, { name: 'בנק', branch: '12', account: '345' }],
|
|
407
|
-
lossesCarriedForward: 777,
|
|
408
|
-
}),
|
|
409
|
-
],
|
|
410
|
-
}),
|
|
411
|
-
type,
|
|
412
|
-
);
|
|
413
|
-
expect(at(line, 137, 2)).toBe(type.slice(2));
|
|
414
|
-
expect(at(line, 139, 3)).toBe('001');
|
|
415
|
-
expect(at(line, 142, 4)).toBe('1212');
|
|
416
|
-
// Slot 0 is empty; slot 1 at 188 (name, padded on the left), 218 (branch), 221 (account).
|
|
417
|
-
expect(at(line, 146, 42)).toBe(' '.repeat(30) + '0'.repeat(12));
|
|
418
|
-
expect(at(line, 188, 30)).toBe('בנק'.padStart(30, ' '));
|
|
419
|
-
expect(at(line, 218, 3)).toBe('012');
|
|
420
|
-
expect(at(line, 221, 9)).toBe('000000345');
|
|
421
|
-
expect(at(line, 230, 84)).toBe((' '.repeat(30) + '0'.repeat(12)).repeat(2));
|
|
422
|
-
expect(at(line, 314, 10)).toBe('0000000777');
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
it('writes gainFromInvestmentFund as yes/no {1, 2} (SPEC §15 A-8)', () => {
|
|
426
|
-
const flag = (gainFromInvestmentFund: boolean | undefined) =>
|
|
427
|
-
at(
|
|
428
|
-
linesOfType(minimalInput({ capitalGains: [build({ gainFromInvestmentFund })] }), type)[0],
|
|
429
|
-
145,
|
|
430
|
-
1,
|
|
431
|
-
);
|
|
432
|
-
expect(flag(true)).toBe('1');
|
|
433
|
-
expect(flag(false)).toBe('2');
|
|
434
|
-
expect(flag(undefined)).toBe('0');
|
|
435
|
-
expect(def.fields.find(f => f.key === 'gainFromInvestmentFund')?.kind).toBe('yesNo');
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
it('reports a withholder name that does not start with a Hebrew letter at its input path', () => {
|
|
439
|
-
const input = minimalInput({
|
|
440
|
-
capitalGains: [
|
|
441
|
-
build({ withholders: [...withholders(2), { name: 'Bank Hapoalim', branch: '1' }] }),
|
|
442
|
-
],
|
|
443
|
-
});
|
|
444
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
445
|
-
expect.objectContaining({
|
|
446
|
-
ruleId: 'field.hebrewFirstLetter',
|
|
447
|
-
path: 'capitalGains[0].withholders[2].name',
|
|
448
|
-
recordType: type,
|
|
449
|
-
recordIndex: 0,
|
|
450
|
-
}),
|
|
451
|
-
]);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it('accepts four withholders and empty slots without issues', () => {
|
|
455
|
-
expect(
|
|
456
|
-
validate1214(
|
|
457
|
-
minimalInput({ capitalGains: [build({ withholders: withholders(4) })] }),
|
|
458
|
-
OPTIONS,
|
|
459
|
-
),
|
|
460
|
-
).toEqual({ valid: true, errors: [], warnings: [] });
|
|
461
|
-
expect(
|
|
462
|
-
validate1214(
|
|
463
|
-
minimalInput({ capitalGains: [build({ withholders: [{}, {}, ...withholders(1)] })] }),
|
|
464
|
-
OPTIONS,
|
|
465
|
-
),
|
|
466
|
-
).toEqual({ valid: true, errors: [], warnings: [] });
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
it('reports a fifth withholder as input.shape', () => {
|
|
470
|
-
const input = minimalInput({
|
|
471
|
-
capitalGains: [build({ withholders: [...withholders(4), { name: 'בנק' }] })],
|
|
472
|
-
});
|
|
473
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
474
|
-
expect.objectContaining({ ruleId: 'input.shape', path: 'capitalGains[0].withholders' }),
|
|
475
|
-
]);
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
describe('mixed appendices (SPEC §3.3, §15 A-7)', () => {
|
|
480
|
-
// Input order 64, 60, 63, 60: emitted 3060, 3060, 3063, 3064.
|
|
481
|
-
const appendices = [
|
|
482
|
-
reitAppendix(),
|
|
483
|
-
securitiesAppendix({ amounts: { '012': 1 } }),
|
|
484
|
-
section6Appendix(),
|
|
485
|
-
securitiesAppendix({ amounts: { '012': 2 } }),
|
|
486
|
-
];
|
|
487
|
-
const input = minimalInput({ capitalGains: appendices });
|
|
488
|
-
|
|
489
|
-
it('groups the records by type ascending, numbers them per symbol, keeps the input index', () => {
|
|
490
|
-
expect(
|
|
491
|
-
capitalGainsRecords(input).map(r => [
|
|
492
|
-
r.recordType,
|
|
493
|
-
r.index,
|
|
494
|
-
r.inputIndex,
|
|
495
|
-
r.values.appendixNumber,
|
|
496
|
-
]),
|
|
497
|
-
).toEqual([
|
|
498
|
-
['3060', 0, 1, 1],
|
|
499
|
-
['3060', 1, 3, 2],
|
|
500
|
-
['3063', 0, 2, 1],
|
|
501
|
-
['3064', 0, 0, 1],
|
|
502
|
-
]);
|
|
503
|
-
const lines = linesOf(input).filter(text =>
|
|
504
|
-
isCapitalGainsRecordType(text.slice(4, 8) as '3060'),
|
|
505
|
-
);
|
|
506
|
-
expect(lines.map(text => [text.slice(4, 8), at(text, 137, 5)])).toEqual([
|
|
507
|
-
['3060', '60001'],
|
|
508
|
-
['3060', '60002'],
|
|
509
|
-
['3063', '63001'],
|
|
510
|
-
['3064', '64001'],
|
|
511
|
-
]);
|
|
512
|
-
// Code 028 and 9999@145 count all of them.
|
|
513
|
-
expect(mainOf(input).codes.get('028')).toBe(4);
|
|
514
|
-
expect(at(linesOf(input).at(-1), 145, 2)).toBe('04');
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
it('writes no sequence for these types: the header ends with the losses carried forward', () => {
|
|
518
|
-
for (const line of linesOf(input).slice(2, -1)) {
|
|
519
|
-
const type = line.slice(4, 8) as '3060' | '3063' | '3064';
|
|
520
|
-
const def = LAYOUT.records[type];
|
|
521
|
-
const filler = def.fields.find(f => f.kind === 'filler');
|
|
522
|
-
expect(filler).toBeDefined();
|
|
523
|
-
expect(at(line, filler?.position ?? 0, filler?.length ?? 0)).toMatch(/^0+$/);
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
describe('end to end: appendices [64, 60, 63]', () => {
|
|
529
|
-
const appendices = [
|
|
530
|
-
reitAppendix({ withholders: [{ name: 'Leumi' }] }),
|
|
531
|
-
securitiesAppendix(),
|
|
532
|
-
section6Appendix({ foreignAsset: false }),
|
|
533
|
-
];
|
|
534
|
-
const input = minimalInput({ capitalGains: appendices });
|
|
535
|
-
|
|
536
|
-
it('reports an issue of the 3064 appendix at capitalGains[0], its input index', () => {
|
|
537
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
538
|
-
expect.objectContaining({
|
|
539
|
-
ruleId: 'field.hebrewFirstLetter',
|
|
540
|
-
path: 'capitalGains[0].withholders[0].name',
|
|
541
|
-
recordType: '3064',
|
|
542
|
-
recordIndex: 0,
|
|
543
|
-
}),
|
|
544
|
-
]);
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
it('reports an issue of the 3060 appendix at capitalGains[1] and of 3063 at capitalGains[2]', () => {
|
|
548
|
-
const errors = validate1214(
|
|
549
|
-
minimalInput({
|
|
550
|
-
capitalGains: [
|
|
551
|
-
reitAppendix(),
|
|
552
|
-
securitiesAppendix({ lossesCarriedForward: 1.5 }),
|
|
553
|
-
section6Appendix({ lossesCarriedForward: -1 }),
|
|
554
|
-
],
|
|
555
|
-
}),
|
|
556
|
-
OPTIONS,
|
|
557
|
-
).errors;
|
|
558
|
-
expect(errors.map(issue => [issue.ruleId, issue.path, issue.recordType])).toEqual([
|
|
559
|
-
['field.integer', 'capitalGains[1].lossesCarriedForward', '3060'],
|
|
560
|
-
['field.negative', 'capitalGains[2].lossesCarriedForward', '3063'],
|
|
561
|
-
]);
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
it('generates 3060, 3063, 3064 and parses them back in file order', () => {
|
|
565
|
-
const valid = minimalInput({
|
|
566
|
-
capitalGains: [reitAppendix(), securitiesAppendix(), section6Appendix()],
|
|
567
|
-
});
|
|
568
|
-
const { text } = generate1214(valid, OPTIONS);
|
|
569
|
-
const parsed = parse1214(text);
|
|
570
|
-
expect(parsed.issues).toEqual([]);
|
|
571
|
-
expect(parsed.report.capitalGains).toEqual([
|
|
572
|
-
securitiesAppendix(),
|
|
573
|
-
section6Appendix(),
|
|
574
|
-
reitAppendix(),
|
|
575
|
-
]);
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
describe('normalizeReport: record 3065 (no withholding, form 1322)', () => {
|
|
580
|
-
const def = LAYOUT.records['3065'];
|
|
581
|
-
|
|
582
|
-
it('has the securities header with a withholding status and the sequence, one position later', () => {
|
|
583
|
-
const position = (key: string) => def.fields.find(f => f.key === key)?.position;
|
|
584
|
-
expect(def.fields.filter(f => f.kind !== 'filler').map(f => f.key)).toEqual([
|
|
585
|
-
'transactionSymbol',
|
|
586
|
-
'appendixNumber',
|
|
587
|
-
'foreignAsset',
|
|
588
|
-
'soldToRelatedParty',
|
|
589
|
-
'boughtFromRelatedParty',
|
|
590
|
-
'gainFromInvestmentFund',
|
|
591
|
-
'withholdingStatus',
|
|
592
|
-
...[0, 1, 2, 3].flatMap(i => [
|
|
593
|
-
`withholders[${i}].name`,
|
|
594
|
-
`withholders[${i}].branch`,
|
|
595
|
-
`withholders[${i}].account`,
|
|
596
|
-
]),
|
|
597
|
-
'lossesCarriedForward',
|
|
598
|
-
'sequenceNumber',
|
|
599
|
-
]);
|
|
600
|
-
// 3060 has its first withholder at 146; 3065 has the withholding status there.
|
|
601
|
-
expect(LAYOUT.records['3060'].fields.find(f => f.key === 'withholders[0].name')?.position).toBe(
|
|
602
|
-
146,
|
|
603
|
-
);
|
|
604
|
-
expect(position('withholdingStatus')).toBe(146);
|
|
605
|
-
expect(position('withholders[0].name')).toBe(147);
|
|
606
|
-
expect(position('sequenceNumber')).toBe(325);
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
it('maps the header, the withholders and the status code, with input paths', () => {
|
|
610
|
-
const appendix = noWithholding1322Appendix();
|
|
611
|
-
const [record] = capitalGainsRecords(minimalInput({ capitalGains: [appendix] }));
|
|
612
|
-
expect(record?.recordType).toBe('3065');
|
|
613
|
-
expect(record?.inputIndex).toBe(0);
|
|
614
|
-
expect(record?.values).toEqual({
|
|
615
|
-
transactionSymbol: 65,
|
|
616
|
-
appendixNumber: 1,
|
|
617
|
-
sequenceNumber: 1,
|
|
618
|
-
foreignAsset: false,
|
|
619
|
-
soldToRelatedParty: true,
|
|
620
|
-
boughtFromRelatedParty: true,
|
|
621
|
-
gainFromInvestmentFund: false,
|
|
622
|
-
withholdingStatus: 2,
|
|
623
|
-
'withholders[0].name': 'בנק הפועלים',
|
|
624
|
-
'withholders[0].branch': '011',
|
|
625
|
-
'withholders[0].account': '000123450',
|
|
626
|
-
'withholders[1].name': 'בנק לאומי',
|
|
627
|
-
'withholders[1].branch': '012',
|
|
628
|
-
'withholders[1].account': '000123451',
|
|
629
|
-
lossesCarriedForward: 6000,
|
|
630
|
-
});
|
|
631
|
-
expect(record?.paths).toEqual({
|
|
632
|
-
transactionSymbol: '',
|
|
633
|
-
appendixNumber: '',
|
|
634
|
-
sequenceNumber: '',
|
|
635
|
-
foreignAsset: 'capitalGains[0].foreignAsset',
|
|
636
|
-
soldToRelatedParty: 'capitalGains[0].soldToRelatedParty',
|
|
637
|
-
boughtFromRelatedParty: 'capitalGains[0].boughtFromRelatedParty',
|
|
638
|
-
gainFromInvestmentFund: 'capitalGains[0].gainFromInvestmentFund',
|
|
639
|
-
withholdingStatus: 'capitalGains[0].withholdingStatus',
|
|
640
|
-
'withholders[0].name': 'capitalGains[0].withholders[0].name',
|
|
641
|
-
'withholders[0].branch': 'capitalGains[0].withholders[0].branch',
|
|
642
|
-
'withholders[0].account': 'capitalGains[0].withholders[0].account',
|
|
643
|
-
'withholders[1].name': 'capitalGains[0].withholders[1].name',
|
|
644
|
-
'withholders[1].branch': 'capitalGains[0].withholders[1].branch',
|
|
645
|
-
'withholders[1].account': 'capitalGains[0].withholders[1].account',
|
|
646
|
-
lossesCarriedForward: 'capitalGains[0].lossesCarriedForward',
|
|
647
|
-
'code:012': 'capitalGains[0].amounts["012"]',
|
|
648
|
-
'code:056': 'capitalGains[0].amounts["056"]',
|
|
649
|
-
});
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
it('sets every non-filler header field with four withholders', () => {
|
|
653
|
-
const report = reportOf(
|
|
654
|
-
minimalInput({ capitalGains: [noWithholding1322Appendix({ withholders: withholders(4) })] }),
|
|
655
|
-
);
|
|
656
|
-
expect(unmappedHeaderKeys(def, report.records)).toEqual([]);
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
it('writes the header at its layout positions', () => {
|
|
660
|
-
const [line] = linesOfType(
|
|
661
|
-
minimalInput({
|
|
662
|
-
capitalGains: [
|
|
663
|
-
noWithholding1322Appendix({
|
|
664
|
-
foreignAsset: true,
|
|
665
|
-
soldToRelatedParty: false,
|
|
666
|
-
boughtFromRelatedParty: true,
|
|
667
|
-
gainFromInvestmentFund: false,
|
|
668
|
-
withholdingStatus: 'notWithheldSecondHalf',
|
|
669
|
-
withholders: [{}, { name: 'בנק', branch: '12', account: '345' }],
|
|
670
|
-
lossesCarriedForward: 777,
|
|
671
|
-
}),
|
|
672
|
-
],
|
|
673
|
-
}),
|
|
674
|
-
'3065',
|
|
675
|
-
);
|
|
676
|
-
expect(at(line, 137, 5)).toBe('65001');
|
|
677
|
-
expect(at(line, 142, 4)).toBe('1212');
|
|
678
|
-
expect(at(line, 146, 1)).toBe('3');
|
|
679
|
-
// Slot 0 is empty; slot 1 at 189 (name, padded on the left), 219 (branch), 222 (account).
|
|
680
|
-
expect(at(line, 147, 42)).toBe(' '.repeat(30) + '0'.repeat(12));
|
|
681
|
-
expect(at(line, 189, 30)).toBe('בנק'.padStart(30, ' '));
|
|
682
|
-
expect(at(line, 219, 3)).toBe('012');
|
|
683
|
-
expect(at(line, 222, 9)).toBe('000000345');
|
|
684
|
-
expect(at(line, 231, 84)).toBe((' '.repeat(30) + '0'.repeat(12)).repeat(2));
|
|
685
|
-
expect(at(line, 315, 10)).toBe('0000000777');
|
|
686
|
-
expect(at(line, 325, 2)).toBe('01');
|
|
687
|
-
expect(at(line, 327, 834)).toMatch(/^0+$/);
|
|
688
|
-
expect(at(line, 1161, 26)).toBe('0120000025000' + '0560000001250');
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
it('reports a withholder name that does not start with a Hebrew letter at its input path', () => {
|
|
692
|
-
const input = minimalInput({
|
|
693
|
-
capitalGains: [
|
|
694
|
-
section6Appendix(),
|
|
695
|
-
noWithholding1322Appendix({ withholders: [{}, { name: 'Bank Leumi' }] }),
|
|
696
|
-
],
|
|
697
|
-
});
|
|
698
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
699
|
-
expect.objectContaining({
|
|
700
|
-
ruleId: 'field.hebrewFirstLetter',
|
|
701
|
-
path: 'capitalGains[1].withholders[1].name',
|
|
702
|
-
recordType: '3065',
|
|
703
|
-
recordIndex: 0,
|
|
704
|
-
}),
|
|
705
|
-
]);
|
|
706
|
-
});
|
|
707
|
-
|
|
708
|
-
it('reports a fifth withholder as input.shape', () => {
|
|
709
|
-
const input = minimalInput({
|
|
710
|
-
capitalGains: [
|
|
711
|
-
noWithholding1322Appendix({ withholders: [...withholders(4), { name: 'בנק' }] }),
|
|
712
|
-
],
|
|
713
|
-
});
|
|
714
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
715
|
-
expect.objectContaining({ ruleId: 'input.shape', path: 'capitalGains[0].withholders' }),
|
|
716
|
-
]);
|
|
717
|
-
});
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
describe('normalizeReport: record 3066 (no withholding, form 1326)', () => {
|
|
721
|
-
const def = LAYOUT.records['3066'];
|
|
722
|
-
|
|
723
|
-
it('has a short header: foreign asset, withholding status, losses and the sequence', () => {
|
|
724
|
-
expect(
|
|
725
|
-
def.fields.filter(f => f.kind !== 'filler').map(f => [f.key, f.position, f.length]),
|
|
726
|
-
).toEqual([
|
|
727
|
-
['transactionSymbol', 137, 2],
|
|
728
|
-
['appendixNumber', 139, 3],
|
|
729
|
-
['foreignAsset', 142, 1],
|
|
730
|
-
['withholdingStatus', 143, 1],
|
|
731
|
-
['lossesCarriedForward', 144, 10],
|
|
732
|
-
['sequenceNumber', 154, 2],
|
|
733
|
-
]);
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
it('maps the header and the status code, with input paths', () => {
|
|
737
|
-
const [record] = capitalGainsRecords(
|
|
738
|
-
minimalInput({ capitalGains: [noWithholding1326Appendix()] }),
|
|
739
|
-
);
|
|
740
|
-
expect(record?.recordType).toBe('3066');
|
|
741
|
-
expect(record?.values).toEqual({
|
|
742
|
-
transactionSymbol: 66,
|
|
743
|
-
appendixNumber: 1,
|
|
744
|
-
sequenceNumber: 1,
|
|
745
|
-
foreignAsset: true,
|
|
746
|
-
withholdingStatus: 3,
|
|
747
|
-
lossesCarriedForward: 4000,
|
|
748
|
-
});
|
|
749
|
-
expect(record?.paths).toEqual({
|
|
750
|
-
transactionSymbol: '',
|
|
751
|
-
appendixNumber: '',
|
|
752
|
-
sequenceNumber: '',
|
|
753
|
-
foreignAsset: 'capitalGains[0].foreignAsset',
|
|
754
|
-
withholdingStatus: 'capitalGains[0].withholdingStatus',
|
|
755
|
-
lossesCarriedForward: 'capitalGains[0].lossesCarriedForward',
|
|
756
|
-
'code:022': 'capitalGains[0].amounts["022"]',
|
|
757
|
-
'code:056': 'capitalGains[0].amounts["056"]',
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
it('sets every non-filler header field of record 3066', () => {
|
|
762
|
-
const report = reportOf(minimalInput({ capitalGains: [noWithholding1326Appendix()] }));
|
|
763
|
-
expect(unmappedHeaderKeys(def, report.records)).toEqual([]);
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
it('writes the header at its layout positions', () => {
|
|
767
|
-
const [line] = linesOfType(
|
|
768
|
-
minimalInput({
|
|
769
|
-
capitalGains: [
|
|
770
|
-
noWithholding1326Appendix({
|
|
771
|
-
foreignAsset: false,
|
|
772
|
-
withholdingStatus: 'notWithheldFirstHalf',
|
|
773
|
-
lossesCarriedForward: 321,
|
|
774
|
-
}),
|
|
775
|
-
],
|
|
776
|
-
}),
|
|
777
|
-
'3066',
|
|
778
|
-
);
|
|
779
|
-
expect(at(line, 137, 5)).toBe('66001');
|
|
780
|
-
expect(at(line, 142, 1)).toBe('2');
|
|
781
|
-
expect(at(line, 143, 1)).toBe('2');
|
|
782
|
-
expect(at(line, 144, 10)).toBe('0000000321');
|
|
783
|
-
expect(at(line, 154, 2)).toBe('01');
|
|
784
|
-
expect(at(line, 156, 1005)).toMatch(/^0+$/);
|
|
785
|
-
expect(at(line, 1161, 26)).toBe('0220000018000' + '0560000000900');
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
it('has no withholders member: one is input.shape', () => {
|
|
789
|
-
const input = {
|
|
790
|
-
...minimalInput(),
|
|
791
|
-
capitalGains: [{ ...noWithholding1326Appendix(), withholders: withholders(1) }],
|
|
792
|
-
};
|
|
793
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
794
|
-
expect.objectContaining({ ruleId: 'input.shape', path: 'capitalGains[0].withholders' }),
|
|
795
|
-
]);
|
|
796
|
-
});
|
|
797
|
-
});
|
|
798
|
-
|
|
799
|
-
describe.each([
|
|
800
|
-
['3065', 146, noWithholding1322Appendix],
|
|
801
|
-
['3066', 143, noWithholding1326Appendix],
|
|
802
|
-
] as const)('withholdingStatus of record %s (SPEC §7.3, §15 A-18)', (type, position, build) => {
|
|
803
|
-
const status = (
|
|
804
|
-
withholdingStatus: 'notWithheldFirstHalf' | 'notWithheldSecondHalf' | undefined,
|
|
805
|
-
) =>
|
|
806
|
-
at(
|
|
807
|
-
linesOfType(minimalInput({ capitalGains: [build({ withholdingStatus })] }), type)[0],
|
|
808
|
-
position,
|
|
809
|
-
1,
|
|
810
|
-
);
|
|
811
|
-
|
|
812
|
-
it(`writes notWithheldFirstHalf → 2, notWithheldSecondHalf → 3, absent → 0 at ${position}`, () => {
|
|
813
|
-
expect(status('notWithheldFirstHalf')).toBe('2');
|
|
814
|
-
expect(status('notWithheldSecondHalf')).toBe('3');
|
|
815
|
-
expect(status(undefined)).toBe('0');
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
it('reads the status back as its literal, and an absent one as absent', () => {
|
|
819
|
-
for (const withholdingStatus of ['notWithheldFirstHalf', 'notWithheldSecondHalf'] as const) {
|
|
820
|
-
const input = minimalInput({ capitalGains: [build({ withholdingStatus })] });
|
|
821
|
-
const [appendix] = parse1214(generate1214(input, OPTIONS).text).report.capitalGains ?? [];
|
|
822
|
-
expect(appendix).toMatchObject({ withholdingStatus });
|
|
823
|
-
}
|
|
824
|
-
const appendix = { ...build() };
|
|
825
|
-
delete appendix.withholdingStatus;
|
|
826
|
-
const input = minimalInput({ capitalGains: [appendix] });
|
|
827
|
-
const [parsed] = parse1214(generate1214(input, OPTIONS).text).report.capitalGains ?? [];
|
|
828
|
-
expect(parsed).toEqual(appendix);
|
|
829
|
-
expect(parsed).not.toHaveProperty('withholdingStatus');
|
|
830
|
-
});
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
describe('the "מספר בתל"ם" sequence across mixed appendices (SPEC §7.4, §15 A-7)', () => {
|
|
834
|
-
// Input order 63, 65, 60, 66: emitted 3060, 3063, 3065, 3066.
|
|
835
|
-
const input = minimalInput({
|
|
836
|
-
capitalGains: [
|
|
837
|
-
section6Appendix(),
|
|
838
|
-
noWithholding1322Appendix(),
|
|
839
|
-
securitiesAppendix(),
|
|
840
|
-
noWithholding1326Appendix(),
|
|
841
|
-
],
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
it('numbers 3065 and 3066 by their emission position among all appendices', () => {
|
|
845
|
-
expect(
|
|
846
|
-
capitalGainsRecords(input).map(r => [
|
|
847
|
-
r.recordType,
|
|
848
|
-
r.inputIndex,
|
|
849
|
-
r.values.appendixNumber,
|
|
850
|
-
r.values.sequenceNumber,
|
|
851
|
-
]),
|
|
852
|
-
).toEqual([
|
|
853
|
-
['3060', 2, 1, undefined],
|
|
854
|
-
['3063', 0, 1, undefined],
|
|
855
|
-
['3065', 1, 1, 3],
|
|
856
|
-
['3066', 3, 1, 4],
|
|
857
|
-
]);
|
|
858
|
-
});
|
|
859
|
-
|
|
860
|
-
it('writes the sequence at 3065@325 and 3066@154, and keeps the input index in paths', () => {
|
|
861
|
-
const lines = linesOf(input);
|
|
862
|
-
expect(lines.map(line => line.slice(4, 8))).toEqual([
|
|
863
|
-
'1000',
|
|
864
|
-
'1020',
|
|
865
|
-
'3060',
|
|
866
|
-
'3063',
|
|
867
|
-
'3065',
|
|
868
|
-
'3066',
|
|
869
|
-
'9999',
|
|
870
|
-
]);
|
|
871
|
-
expect(at(lines[4], 325, 2)).toBe('03');
|
|
872
|
-
expect(at(lines[5], 154, 2)).toBe('04');
|
|
873
|
-
expect(at(lines.at(-1), 145, 2)).toBe('04');
|
|
874
|
-
const errors = validate1214(
|
|
875
|
-
minimalInput({
|
|
876
|
-
capitalGains: [
|
|
877
|
-
section6Appendix(),
|
|
878
|
-
noWithholding1322Appendix({ lossesCarriedForward: -1 }),
|
|
879
|
-
securitiesAppendix(),
|
|
880
|
-
noWithholding1326Appendix({ lossesCarriedForward: 1.5 }),
|
|
881
|
-
],
|
|
882
|
-
}),
|
|
883
|
-
OPTIONS,
|
|
884
|
-
).errors;
|
|
885
|
-
expect(errors.map(issue => [issue.ruleId, issue.path, issue.recordType])).toEqual([
|
|
886
|
-
['field.negative', 'capitalGains[1].lossesCarriedForward', '3065'],
|
|
887
|
-
['field.integer', 'capitalGains[3].lossesCarriedForward', '3066'],
|
|
888
|
-
]);
|
|
889
|
-
});
|
|
890
|
-
|
|
891
|
-
it('generates the four records and parses them back in file order', () => {
|
|
892
|
-
const { text } = generate1214(input, OPTIONS);
|
|
893
|
-
const parsed = parse1214(text);
|
|
894
|
-
expect(parsed.issues).toEqual([]);
|
|
895
|
-
expect(parsed.report.capitalGains).toEqual([
|
|
896
|
-
securitiesAppendix(),
|
|
897
|
-
section6Appendix(),
|
|
898
|
-
noWithholding1322Appendix(),
|
|
899
|
-
noWithholding1326Appendix(),
|
|
900
|
-
]);
|
|
901
|
-
});
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
/** The [ruleId, path, recordType] of every error of `input`. */
|
|
905
|
-
function errorsOf(input: Report1214Input): Array<[string, string, string | undefined]> {
|
|
906
|
-
return validate1214(input, OPTIONS).errors.map(issue => [
|
|
907
|
-
issue.ruleId,
|
|
908
|
-
issue.path,
|
|
909
|
-
issue.recordType,
|
|
910
|
-
]);
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
/**
|
|
914
|
-
* The [ruleId, path] of the field-rule issues of the report of `input`, normalized without the
|
|
915
|
-
* shape stage: an untyped caller's input that lacks a member the types require (SPEC §9.3).
|
|
916
|
-
*/
|
|
917
|
-
function fieldIssuesOf(input: unknown): Array<[string, string]> {
|
|
918
|
-
return fieldRules(reportOf(input as Report1214Input)).map(issue => [issue.ruleId, issue.path]);
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
describe('normalizeReport: record 3027 (shares)', () => {
|
|
922
|
-
const def = LAYOUT.records['3027'];
|
|
923
|
-
|
|
924
|
-
it('has the asset header with three dates and the sequence at 255', () => {
|
|
925
|
-
expect(
|
|
926
|
-
def.fields.filter(f => f.kind !== 'filler').map(f => [f.key, f.position, f.length, f.kind]),
|
|
927
|
-
).toEqual([
|
|
928
|
-
['transactionSymbol', 137, 2, 'const'],
|
|
929
|
-
['appendixNumber', 139, 3, 'serial'],
|
|
930
|
-
['expropriation', 142, 1, 'yesNo'],
|
|
931
|
-
['assetDetails', 143, 50, 'hebrewText'],
|
|
932
|
-
['assetLocation', 193, 1, 'enum'],
|
|
933
|
-
['relatedParty', 194, 1, 'yesNo'],
|
|
934
|
-
['buyerName', 195, 30, 'text'],
|
|
935
|
-
['dates.code15', 225, 10, 'date'],
|
|
936
|
-
['dates.code20', 235, 10, 'date'],
|
|
937
|
-
['dates.code53', 245, 10, 'date'],
|
|
938
|
-
['sequenceNumber', 255, 2, 'serial'],
|
|
939
|
-
]);
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
it('maps the header, the dates as dates.<code> and the location code, with input paths', () => {
|
|
943
|
-
const [record] = capitalGainsRecords(minimalInput({ capitalGains: [sharesAppendix()] }));
|
|
944
|
-
expect(record?.recordType).toBe('3027');
|
|
945
|
-
expect(record?.inputIndex).toBe(0);
|
|
946
|
-
expect(record?.values).toEqual({
|
|
947
|
-
transactionSymbol: 27,
|
|
948
|
-
appendixNumber: 1,
|
|
949
|
-
sequenceNumber: 1,
|
|
950
|
-
expropriation: false,
|
|
951
|
-
assetDetails: 'מניות חברה פרטית',
|
|
952
|
-
assetLocation: 1,
|
|
953
|
-
relatedParty: true,
|
|
954
|
-
buyerName: 'קונה בע"מ',
|
|
955
|
-
'dates.code15': '2024-03-15',
|
|
956
|
-
'dates.code20': '2015-06-01',
|
|
957
|
-
'dates.code53': '2010-01-31',
|
|
958
|
-
});
|
|
959
|
-
expect([...(record?.codes ?? [])]).toEqual([
|
|
960
|
-
['015', 90_000],
|
|
961
|
-
['018', 23],
|
|
962
|
-
['020', 1234.56],
|
|
963
|
-
['074', 5000],
|
|
964
|
-
]);
|
|
965
|
-
expect(record?.paths).toEqual({
|
|
966
|
-
transactionSymbol: '',
|
|
967
|
-
appendixNumber: '',
|
|
968
|
-
sequenceNumber: '',
|
|
969
|
-
expropriation: 'capitalGains[0].expropriation',
|
|
970
|
-
assetDetails: 'capitalGains[0].assetDetails',
|
|
971
|
-
assetLocation: 'capitalGains[0].assetLocation',
|
|
972
|
-
relatedParty: 'capitalGains[0].relatedParty',
|
|
973
|
-
buyerName: 'capitalGains[0].buyerName',
|
|
974
|
-
'dates.code15': 'capitalGains[0].dates.code15',
|
|
975
|
-
'dates.code20': 'capitalGains[0].dates.code20',
|
|
976
|
-
'dates.code53': 'capitalGains[0].dates.code53',
|
|
977
|
-
'code:015': 'capitalGains[0].amounts["015"]',
|
|
978
|
-
'code:018': 'capitalGains[0].amounts["018"]',
|
|
979
|
-
'code:020': 'capitalGains[0].amounts["020"]',
|
|
980
|
-
'code:074': 'capitalGains[0].amounts["074"]',
|
|
981
|
-
});
|
|
982
|
-
});
|
|
983
|
-
|
|
984
|
-
it('sets every non-filler header field of record 3027', () => {
|
|
985
|
-
const report = reportOf(minimalInput({ capitalGains: [sharesAppendix()] }));
|
|
986
|
-
expect(unmappedHeaderKeys(def, report.records)).toEqual([]);
|
|
987
|
-
});
|
|
988
|
-
|
|
989
|
-
it('writes the header at its layout positions, the dates as DD/MM/YYYY', () => {
|
|
990
|
-
const [line] = linesOfType(minimalInput({ capitalGains: [sharesAppendix()] }), '3027');
|
|
991
|
-
expect(at(line, 137, 5)).toBe('27001');
|
|
992
|
-
expect(at(line, 142, 1)).toBe('2');
|
|
993
|
-
expect(at(line, 143, 50)).toBe('מניות חברה פרטית'.padStart(50, ' '));
|
|
994
|
-
expect(at(line, 193, 1)).toBe('1');
|
|
995
|
-
expect(at(line, 194, 1)).toBe('1');
|
|
996
|
-
expect(at(line, 195, 30)).toBe('קונה בע"מ'.padStart(30, ' '));
|
|
997
|
-
expect(at(line, 225, 10)).toBe('15/03/2024');
|
|
998
|
-
expect(at(line, 235, 10)).toBe('01/06/2015');
|
|
999
|
-
expect(at(line, 245, 10)).toBe('31/01/2010');
|
|
1000
|
-
expect(at(line, 255, 2)).toBe('01');
|
|
1001
|
-
expect(at(line, 257, 904)).toMatch(/^0+$/);
|
|
1002
|
-
});
|
|
1003
|
-
|
|
1004
|
-
it('writes codes 020/053/027 ×100 with agorot (1234.56 → 123456) and the rate 018 ×100', () => {
|
|
1005
|
-
const [line] = linesOfType(
|
|
1006
|
-
minimalInput({
|
|
1007
|
-
capitalGains: [
|
|
1008
|
-
sharesAppendix({
|
|
1009
|
-
amounts: { '015': 7, '018': 23, '020': 1234.56, '027': 0.01, '053': 99 },
|
|
1010
|
-
}),
|
|
1011
|
-
],
|
|
1012
|
-
}),
|
|
1013
|
-
'3027',
|
|
1014
|
-
);
|
|
1015
|
-
expect(at(line, 1161, 3 + 10 + 3 + 4 + 3 * (3 + 12) + 3 + 10)).toBe(
|
|
1016
|
-
'015' +
|
|
1017
|
-
'0000000007' +
|
|
1018
|
-
'018' +
|
|
1019
|
-
'2300' +
|
|
1020
|
-
'020' +
|
|
1021
|
-
'000000123456' +
|
|
1022
|
-
'027' +
|
|
1023
|
-
'000000000001' +
|
|
1024
|
-
'053' +
|
|
1025
|
-
'000000009900' +
|
|
1026
|
-
'074' +
|
|
1027
|
-
'0000005000',
|
|
1028
|
-
);
|
|
1029
|
-
const [rate50] = linesOfType(
|
|
1030
|
-
minimalInput({ capitalGains: [sharesAppendix({ amounts: { '015': 1, '018': 50 } })] }),
|
|
1031
|
-
'3027',
|
|
1032
|
-
);
|
|
1033
|
-
expect(at(rate50, 1174, 7)).toBe('0185000');
|
|
1034
|
-
});
|
|
1035
|
-
|
|
1036
|
-
it('reports code 018 outside {23, 50} as field.enum and a third decimal as field.decimals', () => {
|
|
1037
|
-
expect(
|
|
1038
|
-
errorsOf(
|
|
1039
|
-
minimalInput({
|
|
1040
|
-
capitalGains: [
|
|
1041
|
-
section6Appendix(),
|
|
1042
|
-
sharesAppendix({ amounts: { '018': 30, '053': 1.234 } }),
|
|
1043
|
-
],
|
|
1044
|
-
}),
|
|
1045
|
-
),
|
|
1046
|
-
).toEqual([
|
|
1047
|
-
['field.enum', 'capitalGains[1].amounts["018"]', '3027'],
|
|
1048
|
-
['field.decimals', 'capitalGains[1].amounts["053"]', '3027'],
|
|
1049
|
-
]);
|
|
1050
|
-
});
|
|
1051
|
-
|
|
1052
|
-
it('writes assetLocation abroad → 1, israel → 2, absent → 0', () => {
|
|
1053
|
-
const location = (assetLocation: 'abroad' | 'israel' | undefined) =>
|
|
1054
|
-
at(
|
|
1055
|
-
linesOfType(minimalInput({ capitalGains: [sharesAppendix({ assetLocation })] }), '3027')[0],
|
|
1056
|
-
193,
|
|
1057
|
-
1,
|
|
1058
|
-
);
|
|
1059
|
-
expect(location('abroad')).toBe('1');
|
|
1060
|
-
expect(location('israel')).toBe('2');
|
|
1061
|
-
expect(location(undefined)).toBe('0');
|
|
1062
|
-
});
|
|
1063
|
-
|
|
1064
|
-
it('accepts an appendix without dates or other members: the date fields are blank', () => {
|
|
1065
|
-
const input = minimalInput({ capitalGains: [{ symbol: 27, amounts: { '015': 1 } }] });
|
|
1066
|
-
expect(validate1214(input, OPTIONS)).toEqual({ valid: true, errors: [], warnings: [] });
|
|
1067
|
-
const [line] = linesOfType(input, '3027');
|
|
1068
|
-
expect(at(line, 142, 1)).toBe('0');
|
|
1069
|
-
expect(at(line, 225, 30)).toBe(' '.repeat(30));
|
|
1070
|
-
expect(at(line, 255, 2)).toBe('01');
|
|
1071
|
-
const partial = minimalInput({
|
|
1072
|
-
capitalGains: [
|
|
1073
|
-
sharesAppendix({ dates: { code15: undefined, code20: undefined, code53: '2020-02-29' } }),
|
|
1074
|
-
],
|
|
1075
|
-
});
|
|
1076
|
-
const [partialLine] = linesOfType(partial, '3027');
|
|
1077
|
-
expect(at(partialLine, 225, 30)).toBe(' '.repeat(20) + '29/02/2020');
|
|
1078
|
-
});
|
|
1079
|
-
|
|
1080
|
-
it('reports a date that is not a real calendar date at capitalGains[i].dates.<code>', () => {
|
|
1081
|
-
expect(
|
|
1082
|
-
errorsOf(
|
|
1083
|
-
minimalInput({ capitalGains: [sharesAppendix({ dates: { code20: '2023-02-29' } })] }),
|
|
1084
|
-
),
|
|
1085
|
-
).toEqual([['field.date', 'capitalGains[0].dates.code20', '3027']]);
|
|
1086
|
-
});
|
|
1087
|
-
|
|
1088
|
-
it('takes a buyer name that does not start with a Hebrew letter (kind text)', () => {
|
|
1089
|
-
expect(
|
|
1090
|
-
errorsOf(minimalInput({ capitalGains: [sharesAppendix({ buyerName: 'Buyer Ltd' })] })),
|
|
1091
|
-
).toEqual([]);
|
|
1092
|
-
});
|
|
1093
|
-
});
|
|
1094
|
-
|
|
1095
|
-
describe.each([
|
|
1096
|
-
['3050', 'betterment tax', bettermentTaxAppendix, 193, 203],
|
|
1097
|
-
['3054', 'oil partnership', oilPartnershipAppendix, 192, 202],
|
|
1098
|
-
] as const)(
|
|
1099
|
-
'normalizeReport: record %s (%s)',
|
|
1100
|
-
(type, _name, build, purchaseDatePosition, code15Position) => {
|
|
1101
|
-
const def = LAYOUT.records[type];
|
|
1102
|
-
const symbol = Number(type.slice(2));
|
|
1103
|
-
|
|
1104
|
-
it('requires the purchase date and the code-15 date and has no sequence field', () => {
|
|
1105
|
-
const keys = def.fields.filter(f => f.kind !== 'filler').map(f => f.key);
|
|
1106
|
-
expect(keys).not.toContain('sequenceNumber');
|
|
1107
|
-
expect(
|
|
1108
|
-
def.fields
|
|
1109
|
-
.filter(f => f.key === 'purchaseDate' || f.key === 'dates.code15')
|
|
1110
|
-
.map(f => [f.key, f.position, f.required, f.kind]),
|
|
1111
|
-
).toEqual([
|
|
1112
|
-
['purchaseDate', purchaseDatePosition, 'yes', 'date'],
|
|
1113
|
-
['dates.code15', code15Position, 'yes', 'date'],
|
|
1114
|
-
]);
|
|
1115
|
-
});
|
|
1116
|
-
|
|
1117
|
-
it('maps the header with input paths', () => {
|
|
1118
|
-
const appendix = build();
|
|
1119
|
-
const [record] = capitalGainsRecords(minimalInput({ capitalGains: [appendix] }));
|
|
1120
|
-
expect(record?.recordType).toBe(type);
|
|
1121
|
-
expect(record?.values).toEqual({
|
|
1122
|
-
transactionSymbol: symbol,
|
|
1123
|
-
appendixNumber: 1,
|
|
1124
|
-
...('expropriation' in appendix ? { expropriation: appendix.expropriation } : {}),
|
|
1125
|
-
assetDetails: appendix.assetDetails,
|
|
1126
|
-
purchaseDate: appendix.purchaseDate,
|
|
1127
|
-
'dates.code15': appendix.dates.code15,
|
|
1128
|
-
});
|
|
1129
|
-
expect(record?.paths).toMatchObject({
|
|
1130
|
-
transactionSymbol: '',
|
|
1131
|
-
appendixNumber: '',
|
|
1132
|
-
assetDetails: 'capitalGains[0].assetDetails',
|
|
1133
|
-
purchaseDate: 'capitalGains[0].purchaseDate',
|
|
1134
|
-
'dates.code15': 'capitalGains[0].dates.code15',
|
|
1135
|
-
'code:015': 'capitalGains[0].amounts["015"]',
|
|
1136
|
-
});
|
|
1137
|
-
});
|
|
1138
|
-
|
|
1139
|
-
it(`sets every non-filler header field of record ${type}`, () => {
|
|
1140
|
-
const report = reportOf(minimalInput({ capitalGains: [build()] }));
|
|
1141
|
-
expect(unmappedHeaderKeys(def, report.records)).toEqual([]);
|
|
1142
|
-
});
|
|
1143
|
-
|
|
1144
|
-
it('writes the header at its layout positions', () => {
|
|
1145
|
-
const appendix = build({ purchaseDate: '2001-02-03', dates: { code15: '2024-11-30' } });
|
|
1146
|
-
const [line] = linesOfType(minimalInput({ capitalGains: [appendix] }), type);
|
|
1147
|
-
expect(at(line, 137, 5)).toBe(`${symbol}001`);
|
|
1148
|
-
expect(at(line, purchaseDatePosition, 10)).toBe('03/02/2001');
|
|
1149
|
-
expect(at(line, code15Position, 10)).toBe('30/11/2024');
|
|
1150
|
-
expect(at(line, purchaseDatePosition - 50, 50)).toBe(
|
|
1151
|
-
(appendix.assetDetails ?? '').padStart(50, ' '),
|
|
1152
|
-
);
|
|
1153
|
-
expect(at(line, code15Position + 10, 1160 - code15Position - 9)).toMatch(/^0+$/);
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
it('reports an absent purchase date or code-15 date: input.shape for typed input', () => {
|
|
1157
|
-
const appendix: Record<string, unknown> = { ...build() };
|
|
1158
|
-
delete appendix['purchaseDate'];
|
|
1159
|
-
const input = { ...minimalInput(), capitalGains: [appendix, { ...build(), dates: {} }] };
|
|
1160
|
-
expect(validate1214(input, OPTIONS).errors.map(issue => [issue.ruleId, issue.path])).toEqual([
|
|
1161
|
-
['input.shape', 'capitalGains[0].purchaseDate'],
|
|
1162
|
-
['input.shape', 'capitalGains[1].dates.code15'],
|
|
1163
|
-
]);
|
|
1164
|
-
});
|
|
1165
|
-
|
|
1166
|
-
it('reports them as field.required at capitalGains[i].purchaseDate / .dates.code15', () => {
|
|
1167
|
-
const withoutPurchaseDate: Record<string, unknown> = { ...build() };
|
|
1168
|
-
delete withoutPurchaseDate['purchaseDate'];
|
|
1169
|
-
const withoutDates: Record<string, unknown> = { ...build() };
|
|
1170
|
-
delete withoutDates['dates'];
|
|
1171
|
-
expect(
|
|
1172
|
-
fieldIssuesOf({
|
|
1173
|
-
...minimalInput(),
|
|
1174
|
-
capitalGains: [section6Appendix(), withoutDates, withoutPurchaseDate],
|
|
1175
|
-
}),
|
|
1176
|
-
).toEqual([
|
|
1177
|
-
['field.required', 'capitalGains[1].dates.code15'],
|
|
1178
|
-
['field.required', 'capitalGains[2].purchaseDate'],
|
|
1179
|
-
]);
|
|
1180
|
-
});
|
|
1181
|
-
},
|
|
1182
|
-
);
|
|
1183
|
-
|
|
1184
|
-
describe('record 3050 codes', () => {
|
|
1185
|
-
it('accepts code 014 = 10 or 20 and reports any other value as field.enum', () => {
|
|
1186
|
-
expect(
|
|
1187
|
-
errorsOf(minimalInput({ capitalGains: [bettermentTaxAppendix({ amounts: { '014': 20 } })] })),
|
|
1188
|
-
).toEqual([]);
|
|
1189
|
-
expect(
|
|
1190
|
-
errorsOf(minimalInput({ capitalGains: [bettermentTaxAppendix({ amounts: { '014': 15 } })] })),
|
|
1191
|
-
).toEqual([['field.enum', 'capitalGains[0].amounts["014"]', '3050']]);
|
|
1192
|
-
});
|
|
1193
|
-
|
|
1194
|
-
it('writes 014, then 015, 016 and the rate 018 ×100 in ascending code order', () => {
|
|
1195
|
-
const [line] = linesOfType(minimalInput({ capitalGains: [bettermentTaxAppendix()] }), '3050');
|
|
1196
|
-
expect(at(line, 1161, 5 + 13 + 13 + 7)).toBe(
|
|
1197
|
-
'01410' + '0150001200000' + '0160000700000' + '0185000',
|
|
1198
|
-
);
|
|
1199
|
-
});
|
|
1200
|
-
|
|
1201
|
-
it('reports code 018 outside {23, 50} as field.enum (D-6)', () => {
|
|
1202
|
-
expect(
|
|
1203
|
-
errorsOf(minimalInput({ capitalGains: [bettermentTaxAppendix({ amounts: { '018': 25 } })] })),
|
|
1204
|
-
).toEqual([['field.enum', 'capitalGains[0].amounts["018"]', '3050']]);
|
|
1205
|
-
});
|
|
1206
|
-
|
|
1207
|
-
it('omits code 016 = 0 (not zeroAllowed in 3050)', () => {
|
|
1208
|
-
const report = reportOf(
|
|
1209
|
-
minimalInput({ capitalGains: [bettermentTaxAppendix({ amounts: { '016': 0 } })] }),
|
|
1210
|
-
);
|
|
1211
|
-
expect(report.omittedZeroCodes).toEqual([{ record: '3050', recordIndex: 0, code: '016' }]);
|
|
1212
|
-
});
|
|
1213
|
-
});
|
|
1214
|
-
|
|
1215
|
-
describe('record 3054 codes', () => {
|
|
1216
|
-
it('writes code 016 = 0 (zeroAllowed, SPEC §4.5)', () => {
|
|
1217
|
-
const input = minimalInput({
|
|
1218
|
-
capitalGains: [oilPartnershipAppendix({ amounts: { '015': 0, '016': 0 } })],
|
|
1219
|
-
});
|
|
1220
|
-
const report = reportOf(input);
|
|
1221
|
-
expect(report.omittedZeroCodes).toEqual([{ record: '3054', recordIndex: 0, code: '015' }]);
|
|
1222
|
-
const [line] = linesOfType(input, '3054');
|
|
1223
|
-
expect(at(line, 1161, 14)).toBe('0160000000000' + '0');
|
|
1224
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([]);
|
|
1225
|
-
});
|
|
1226
|
-
});
|
|
1227
|
-
|
|
1228
|
-
describe('normalizeReport: record 3051 (forced virtual-currency transaction)', () => {
|
|
1229
|
-
const def = LAYOUT.records['3051'];
|
|
1230
|
-
|
|
1231
|
-
it('has the asset header, the sequence at 234 and two wallet addresses at 236 and 386', () => {
|
|
1232
|
-
expect(
|
|
1233
|
-
def.fields
|
|
1234
|
-
.filter(f => f.kind !== 'filler')
|
|
1235
|
-
.map(f => [f.key, f.position, f.length, f.kind, f.required]),
|
|
1236
|
-
).toEqual([
|
|
1237
|
-
['transactionSymbol', 137, 2, 'const', 'yes'],
|
|
1238
|
-
['appendixNumber', 139, 3, 'serial', 'yes'],
|
|
1239
|
-
['assetDetails', 142, 50, 'hebrewText', 'no'],
|
|
1240
|
-
['assetLocation', 192, 1, 'enum', 'no'],
|
|
1241
|
-
['relatedParty', 193, 1, 'yesNo', 'no'],
|
|
1242
|
-
['buyerName', 194, 30, 'hebrewText', 'no'],
|
|
1243
|
-
['dates.code15', 224, 10, 'date', 'yes'],
|
|
1244
|
-
['sequenceNumber', 234, 2, 'serial', 'yes'],
|
|
1245
|
-
['walletAddresses[0]', 236, 150, 'text', 'no'],
|
|
1246
|
-
['walletAddresses[1]', 386, 150, 'text', 'no'],
|
|
1247
|
-
]);
|
|
1248
|
-
});
|
|
1249
|
-
|
|
1250
|
-
it('maps the header, walletAddresses[i] to keys walletAddresses[i], with input paths', () => {
|
|
1251
|
-
const [record] = capitalGainsRecords(
|
|
1252
|
-
minimalInput({ capitalGains: [forcedVirtualCurrencyAppendix()] }),
|
|
1253
|
-
);
|
|
1254
|
-
expect(record?.recordType).toBe('3051');
|
|
1255
|
-
expect(record?.values).toEqual({
|
|
1256
|
-
transactionSymbol: 51,
|
|
1257
|
-
appendixNumber: 1,
|
|
1258
|
-
sequenceNumber: 1,
|
|
1259
|
-
assetDetails: 'ביטקוין',
|
|
1260
|
-
assetLocation: 2,
|
|
1261
|
-
relatedParty: false,
|
|
1262
|
-
buyerName: 'בורסת מטבעות',
|
|
1263
|
-
'dates.code15': '2024-12-31',
|
|
1264
|
-
'walletAddresses[0]': 'bc1qwalletaddressone',
|
|
1265
|
-
'walletAddresses[1]': 'bc1qwalletaddresstwo',
|
|
1266
|
-
});
|
|
1267
|
-
expect([...(record?.codes ?? [])]).toEqual([
|
|
1268
|
-
['015', 80_000],
|
|
1269
|
-
['016', 30_000],
|
|
1270
|
-
['071', 1],
|
|
1271
|
-
]);
|
|
1272
|
-
expect(record?.paths).toEqual({
|
|
1273
|
-
transactionSymbol: '',
|
|
1274
|
-
appendixNumber: '',
|
|
1275
|
-
sequenceNumber: '',
|
|
1276
|
-
assetDetails: 'capitalGains[0].assetDetails',
|
|
1277
|
-
assetLocation: 'capitalGains[0].assetLocation',
|
|
1278
|
-
relatedParty: 'capitalGains[0].relatedParty',
|
|
1279
|
-
buyerName: 'capitalGains[0].buyerName',
|
|
1280
|
-
'dates.code15': 'capitalGains[0].dates.code15',
|
|
1281
|
-
'walletAddresses[0]': 'capitalGains[0].walletAddresses[0]',
|
|
1282
|
-
'walletAddresses[1]': 'capitalGains[0].walletAddresses[1]',
|
|
1283
|
-
'code:015': 'capitalGains[0].amounts["015"]',
|
|
1284
|
-
'code:016': 'capitalGains[0].amounts["016"]',
|
|
1285
|
-
'code:071': 'capitalGains[0].amounts["071"]',
|
|
1286
|
-
});
|
|
1287
|
-
});
|
|
1288
|
-
|
|
1289
|
-
it('sets every non-filler header field of record 3051', () => {
|
|
1290
|
-
const report = reportOf(minimalInput({ capitalGains: [forcedVirtualCurrencyAppendix()] }));
|
|
1291
|
-
expect(unmappedHeaderKeys(def, report.records)).toEqual([]);
|
|
1292
|
-
});
|
|
1293
|
-
|
|
1294
|
-
it('writes the header at its layout positions, the wallet addresses padded to 150', () => {
|
|
1295
|
-
const [line] = linesOfType(
|
|
1296
|
-
minimalInput({ capitalGains: [forcedVirtualCurrencyAppendix()] }),
|
|
1297
|
-
'3051',
|
|
1298
|
-
);
|
|
1299
|
-
expect(at(line, 137, 5)).toBe('51001');
|
|
1300
|
-
expect(at(line, 142, 50)).toBe('ביטקוין'.padStart(50, ' '));
|
|
1301
|
-
expect(at(line, 192, 2)).toBe('22');
|
|
1302
|
-
expect(at(line, 194, 30)).toBe('בורסת מטבעות'.padStart(30, ' '));
|
|
1303
|
-
expect(at(line, 224, 10)).toBe('31/12/2024');
|
|
1304
|
-
expect(at(line, 234, 2)).toBe('01');
|
|
1305
|
-
expect(at(line, 236, 150)).toBe('bc1qwalletaddressone'.padStart(150, ' '));
|
|
1306
|
-
expect(at(line, 386, 150)).toBe('bc1qwalletaddresstwo'.padStart(150, ' '));
|
|
1307
|
-
expect(at(line, 536, 625)).toMatch(/^0+$/);
|
|
1308
|
-
expect(at(line, 1161, 13 + 13 + 4)).toBe('0150000080000' + '0160000030000' + '0711');
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
it('writes one wallet address in the first slot and leaves the second blank', () => {
|
|
1312
|
-
const [line] = linesOfType(
|
|
1313
|
-
minimalInput({
|
|
1314
|
-
capitalGains: [forcedVirtualCurrencyAppendix({ walletAddresses: ['0xabc'] })],
|
|
1315
|
-
}),
|
|
1316
|
-
'3051',
|
|
1317
|
-
);
|
|
1318
|
-
expect(at(line, 236, 150)).toBe('0xabc'.padStart(150, ' '));
|
|
1319
|
-
expect(at(line, 386, 150)).toBe(' '.repeat(150));
|
|
1320
|
-
});
|
|
1321
|
-
|
|
1322
|
-
it('requires codes 071 and 016 (field.required; 0 counts as absent) and 071 = 1', () => {
|
|
1323
|
-
expect(
|
|
1324
|
-
errorsOf(
|
|
1325
|
-
minimalInput({
|
|
1326
|
-
capitalGains: [
|
|
1327
|
-
sharesAppendix(),
|
|
1328
|
-
forcedVirtualCurrencyAppendix({ amounts: { '071': undefined, '016': 0 } }),
|
|
1329
|
-
],
|
|
1330
|
-
}),
|
|
1331
|
-
),
|
|
1332
|
-
).toEqual([
|
|
1333
|
-
['field.required', 'capitalGains[1].amounts["016"]', '3051'],
|
|
1334
|
-
['field.required', 'capitalGains[1].amounts["071"]', '3051'],
|
|
1335
|
-
]);
|
|
1336
|
-
expect(
|
|
1337
|
-
errorsOf(
|
|
1338
|
-
minimalInput({ capitalGains: [forcedVirtualCurrencyAppendix({ amounts: { '071': 2 } })] }),
|
|
1339
|
-
),
|
|
1340
|
-
).toEqual([['field.enum', 'capitalGains[0].amounts["071"]', '3051']]);
|
|
1341
|
-
});
|
|
1342
|
-
|
|
1343
|
-
it('reports an absent code-15 date: input.shape for typed input, field.required in the model', () => {
|
|
1344
|
-
const input = {
|
|
1345
|
-
...minimalInput(),
|
|
1346
|
-
capitalGains: [{ ...forcedVirtualCurrencyAppendix(), dates: {} }],
|
|
1347
|
-
};
|
|
1348
|
-
expect(validate1214(input, OPTIONS).errors.map(issue => [issue.ruleId, issue.path])).toEqual([
|
|
1349
|
-
['input.shape', 'capitalGains[0].dates.code15'],
|
|
1350
|
-
]);
|
|
1351
|
-
expect(fieldIssuesOf(input)).toEqual([['field.required', 'capitalGains[0].dates.code15']]);
|
|
1352
|
-
});
|
|
1353
|
-
|
|
1354
|
-
it('reports a wallet address over 150 characters at its slot and a third one as input.shape', () => {
|
|
1355
|
-
expect(
|
|
1356
|
-
errorsOf(
|
|
1357
|
-
minimalInput({
|
|
1358
|
-
capitalGains: [
|
|
1359
|
-
forcedVirtualCurrencyAppendix({ walletAddresses: ['a', 'b'.repeat(151)] }),
|
|
1360
|
-
],
|
|
1361
|
-
}),
|
|
1362
|
-
),
|
|
1363
|
-
).toEqual([['field.length', 'capitalGains[0].walletAddresses[1]', '3051']]);
|
|
1364
|
-
expect(
|
|
1365
|
-
errorsOf(
|
|
1366
|
-
minimalInput({
|
|
1367
|
-
capitalGains: [forcedVirtualCurrencyAppendix({ walletAddresses: ['a'.repeat(150)] })],
|
|
1368
|
-
}),
|
|
1369
|
-
),
|
|
1370
|
-
).toEqual([]);
|
|
1371
|
-
const input = {
|
|
1372
|
-
...minimalInput(),
|
|
1373
|
-
capitalGains: [{ ...forcedVirtualCurrencyAppendix(), walletAddresses: ['a', 'b', 'c'] }],
|
|
1374
|
-
};
|
|
1375
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
1376
|
-
expect.objectContaining({ ruleId: 'input.shape', path: 'capitalGains[0].walletAddresses' }),
|
|
1377
|
-
]);
|
|
1378
|
-
});
|
|
1379
|
-
|
|
1380
|
-
it('reports a buyer name that does not start with a Hebrew letter (kind hebrewText)', () => {
|
|
1381
|
-
expect(
|
|
1382
|
-
errorsOf(
|
|
1383
|
-
minimalInput({ capitalGains: [forcedVirtualCurrencyAppendix({ buyerName: 'Exchange' })] }),
|
|
1384
|
-
),
|
|
1385
|
-
).toEqual([['field.hebrewFirstLetter', 'capitalGains[0].buyerName', '3051']]);
|
|
1386
|
-
});
|
|
1387
|
-
});
|
|
1388
|
-
|
|
1389
|
-
describe('the "מספר בתל"ם" sequence with asset appendices (SPEC §7.4, §15 A-7)', () => {
|
|
1390
|
-
// Input order 51, 63, 27, 65, 50, 54, 27: emitted 3027, 3027, 3050, 3051, 3054, 3063, 3065.
|
|
1391
|
-
const appendices = [
|
|
1392
|
-
forcedVirtualCurrencyAppendix(),
|
|
1393
|
-
section6Appendix(),
|
|
1394
|
-
sharesAppendix(),
|
|
1395
|
-
noWithholding1322Appendix(),
|
|
1396
|
-
bettermentTaxAppendix(),
|
|
1397
|
-
oilPartnershipAppendix(),
|
|
1398
|
-
sharesAppendix({ assetLocation: 'israel' }),
|
|
1399
|
-
];
|
|
1400
|
-
const input = minimalInput({ capitalGains: appendices });
|
|
1401
|
-
|
|
1402
|
-
it('numbers 3027, 3051 and 3065 by their emission position among all appendices', () => {
|
|
1403
|
-
expect(
|
|
1404
|
-
capitalGainsRecords(input).map(r => [
|
|
1405
|
-
r.recordType,
|
|
1406
|
-
r.inputIndex,
|
|
1407
|
-
r.values.appendixNumber,
|
|
1408
|
-
r.values.sequenceNumber,
|
|
1409
|
-
]),
|
|
1410
|
-
).toEqual([
|
|
1411
|
-
['3027', 2, 1, 1],
|
|
1412
|
-
['3027', 6, 2, 2],
|
|
1413
|
-
['3050', 4, 1, undefined],
|
|
1414
|
-
['3051', 0, 1, 4],
|
|
1415
|
-
['3054', 5, 1, undefined],
|
|
1416
|
-
['3063', 1, 1, undefined],
|
|
1417
|
-
['3065', 3, 1, 7],
|
|
1418
|
-
]);
|
|
1419
|
-
});
|
|
1420
|
-
|
|
1421
|
-
it('writes the sequences at 3027@255, 3051@234 and 3065@325', () => {
|
|
1422
|
-
const lines = linesOf(input);
|
|
1423
|
-
expect(lines.map(line => line.slice(4, 8))).toEqual([
|
|
1424
|
-
'1000',
|
|
1425
|
-
'1020',
|
|
1426
|
-
'3027',
|
|
1427
|
-
'3027',
|
|
1428
|
-
'3050',
|
|
1429
|
-
'3051',
|
|
1430
|
-
'3054',
|
|
1431
|
-
'3063',
|
|
1432
|
-
'3065',
|
|
1433
|
-
'9999',
|
|
1434
|
-
]);
|
|
1435
|
-
expect([at(lines[2], 255, 2), at(lines[3], 255, 2)]).toEqual(['01', '02']);
|
|
1436
|
-
expect(at(lines[5], 234, 2)).toBe('04');
|
|
1437
|
-
expect(at(lines[8], 325, 2)).toBe('07');
|
|
1438
|
-
expect(at(lines.at(-1), 145, 2)).toBe('07');
|
|
1439
|
-
});
|
|
1440
|
-
|
|
1441
|
-
it('generates the seven records and parses them back in file order', () => {
|
|
1442
|
-
expect(validate1214(input, OPTIONS)).toEqual({ valid: true, errors: [], warnings: [] });
|
|
1443
|
-
const parsed = parse1214(generate1214(input, OPTIONS).text);
|
|
1444
|
-
expect(parsed.issues).toEqual([]);
|
|
1445
|
-
expect(parsed.report.capitalGains).toEqual([
|
|
1446
|
-
appendices[2],
|
|
1447
|
-
appendices[6],
|
|
1448
|
-
appendices[4],
|
|
1449
|
-
appendices[0],
|
|
1450
|
-
appendices[5],
|
|
1451
|
-
appendices[1],
|
|
1452
|
-
appendices[3],
|
|
1453
|
-
]);
|
|
1454
|
-
});
|
|
1455
|
-
});
|
|
1456
|
-
|
|
1457
|
-
describe('normalizeReport: record 3077 (other transactions)', () => {
|
|
1458
|
-
const def = LAYOUT.records['3077'];
|
|
1459
|
-
|
|
1460
|
-
it('has the asset header, five improvement slots, a replacement asset, the sequence and two wallets', () => {
|
|
1461
|
-
expect(
|
|
1462
|
-
def.fields
|
|
1463
|
-
.filter(f => f.kind !== 'filler')
|
|
1464
|
-
.map(f => [f.key, f.position, f.length, f.kind, f.required]),
|
|
1465
|
-
).toEqual([
|
|
1466
|
-
['transactionSymbol', 137, 2, 'const', 'yes'],
|
|
1467
|
-
['appendixNumber', 139, 3, 'serial', 'yes'],
|
|
1468
|
-
['expropriation', 142, 1, 'yesNo', 'no'],
|
|
1469
|
-
['assetDetails', 143, 50, 'text', 'no'],
|
|
1470
|
-
['assetLocation', 193, 1, 'enum', 'no'],
|
|
1471
|
-
['relatedParty', 194, 1, 'yesNo', 'no'],
|
|
1472
|
-
['buyerName', 195, 30, 'text', 'no'],
|
|
1473
|
-
['dates.code15', 225, 10, 'date', 'yes'],
|
|
1474
|
-
['dates.code20', 235, 10, 'date', 'yes'],
|
|
1475
|
-
['improvementCount', 245, 2, 'count', 'no'],
|
|
1476
|
-
...[0, 1, 2, 3, 4].flatMap(slot => [
|
|
1477
|
-
[`improvements[${slot}].expense`, 247 + 34 * slot, 12, 'amountX100', 'no'],
|
|
1478
|
-
[`improvements[${slot}].accumulatedDepreciation`, 259 + 34 * slot, 12, 'amountX100', 'no'],
|
|
1479
|
-
[`improvements[${slot}].date`, 271 + 34 * slot, 10, 'date', 'yes'],
|
|
1480
|
-
]),
|
|
1481
|
-
['replacementAsset.details', 417, 50, 'text', 'no'],
|
|
1482
|
-
['replacementAsset.purchaseDate', 467, 10, 'date', 'no'],
|
|
1483
|
-
['replacementAsset.price', 477, 10, 'amount', 'no'],
|
|
1484
|
-
['sequenceNumber', 487, 2, 'serial', 'yes'],
|
|
1485
|
-
['walletAddresses[0]', 489, 150, 'text', 'no'],
|
|
1486
|
-
['walletAddresses[1]', 639, 150, 'text', 'no'],
|
|
1487
|
-
]);
|
|
1488
|
-
expect(def.codes.filter(code => code.derived).map(code => code.code)).toEqual([
|
|
1489
|
-
'501',
|
|
1490
|
-
'502',
|
|
1491
|
-
'503',
|
|
1492
|
-
'504',
|
|
1493
|
-
'505',
|
|
1494
|
-
]);
|
|
1495
|
-
});
|
|
1496
|
-
|
|
1497
|
-
it('maps improvements[i] to keys improvements[i].*, code50Amount to code 50(i+1), 245 to the count', () => {
|
|
1498
|
-
const [section6, other] = capitalGainsRecords(
|
|
1499
|
-
minimalInput({ capitalGains: [section6Appendix(), otherTransactionsAppendix()] }),
|
|
1500
|
-
);
|
|
1501
|
-
expect(section6?.recordType).toBe('3063');
|
|
1502
|
-
expect(other?.recordType).toBe('3077');
|
|
1503
|
-
expect(other?.values).toEqual({
|
|
1504
|
-
transactionSymbol: 77,
|
|
1505
|
-
appendixNumber: 1,
|
|
1506
|
-
sequenceNumber: 2,
|
|
1507
|
-
expropriation: false,
|
|
1508
|
-
assetDetails: 'מבנה תעשייה',
|
|
1509
|
-
assetLocation: 2,
|
|
1510
|
-
relatedParty: true,
|
|
1511
|
-
buyerName: 'רוכש נכסים בע"מ',
|
|
1512
|
-
'dates.code15': '2024-07-01',
|
|
1513
|
-
'dates.code20': '2009-02-01',
|
|
1514
|
-
improvementCount: 2,
|
|
1515
|
-
'improvements[0].expense': 10_000.25,
|
|
1516
|
-
'improvements[0].accumulatedDepreciation': 1000,
|
|
1517
|
-
'improvements[0].date': '2010-01-15',
|
|
1518
|
-
'improvements[1].expense': 20_000.25,
|
|
1519
|
-
'improvements[1].accumulatedDepreciation': 2000,
|
|
1520
|
-
'improvements[1].date': '2011-02-15',
|
|
1521
|
-
'replacementAsset.details': 'מבנה חלופי',
|
|
1522
|
-
'replacementAsset.purchaseDate': '2024-09-01',
|
|
1523
|
-
'replacementAsset.price': 2_000_000,
|
|
1524
|
-
'walletAddresses[0]': 'bc1qotherwalletone',
|
|
1525
|
-
});
|
|
1526
|
-
expect([...(other?.codes ?? [])]).toEqual([
|
|
1527
|
-
['015', 3_000_000],
|
|
1528
|
-
['020', 1_500_000.5],
|
|
1529
|
-
['071', 1],
|
|
1530
|
-
['501', 9000.5],
|
|
1531
|
-
['502', 18_000.5],
|
|
1532
|
-
]);
|
|
1533
|
-
expect(other?.paths).toEqual({
|
|
1534
|
-
transactionSymbol: '',
|
|
1535
|
-
appendixNumber: '',
|
|
1536
|
-
sequenceNumber: '',
|
|
1537
|
-
improvementCount: '',
|
|
1538
|
-
expropriation: 'capitalGains[1].expropriation',
|
|
1539
|
-
assetDetails: 'capitalGains[1].assetDetails',
|
|
1540
|
-
assetLocation: 'capitalGains[1].assetLocation',
|
|
1541
|
-
relatedParty: 'capitalGains[1].relatedParty',
|
|
1542
|
-
buyerName: 'capitalGains[1].buyerName',
|
|
1543
|
-
'dates.code15': 'capitalGains[1].dates.code15',
|
|
1544
|
-
'dates.code20': 'capitalGains[1].dates.code20',
|
|
1545
|
-
'improvements[0].expense': 'capitalGains[1].improvements[0].expense',
|
|
1546
|
-
'improvements[0].accumulatedDepreciation':
|
|
1547
|
-
'capitalGains[1].improvements[0].accumulatedDepreciation',
|
|
1548
|
-
'improvements[0].date': 'capitalGains[1].improvements[0].date',
|
|
1549
|
-
'improvements[1].expense': 'capitalGains[1].improvements[1].expense',
|
|
1550
|
-
'improvements[1].accumulatedDepreciation':
|
|
1551
|
-
'capitalGains[1].improvements[1].accumulatedDepreciation',
|
|
1552
|
-
'improvements[1].date': 'capitalGains[1].improvements[1].date',
|
|
1553
|
-
'replacementAsset.details': 'capitalGains[1].replacementAsset.details',
|
|
1554
|
-
'replacementAsset.purchaseDate': 'capitalGains[1].replacementAsset.purchaseDate',
|
|
1555
|
-
'replacementAsset.price': 'capitalGains[1].replacementAsset.price',
|
|
1556
|
-
'walletAddresses[0]': 'capitalGains[1].walletAddresses[0]',
|
|
1557
|
-
'code:015': 'capitalGains[1].amounts["015"]',
|
|
1558
|
-
'code:020': 'capitalGains[1].amounts["020"]',
|
|
1559
|
-
'code:071': 'capitalGains[1].amounts["071"]',
|
|
1560
|
-
'code:501': 'capitalGains[1].improvements[0].code50Amount',
|
|
1561
|
-
'code:502': 'capitalGains[1].improvements[1].code50Amount',
|
|
1562
|
-
});
|
|
1563
|
-
});
|
|
1564
|
-
|
|
1565
|
-
it('sets every non-filler header field of record 3077 with five improvements and two wallets', () => {
|
|
1566
|
-
const report = reportOf(
|
|
1567
|
-
minimalInput({
|
|
1568
|
-
capitalGains: [
|
|
1569
|
-
otherTransactionsAppendix({
|
|
1570
|
-
improvements: improvements(5),
|
|
1571
|
-
walletAddresses: ['0x1', '0x2'],
|
|
1572
|
-
}),
|
|
1573
|
-
],
|
|
1574
|
-
}),
|
|
1575
|
-
);
|
|
1576
|
-
expect(unmappedHeaderKeys(def, report.records)).toEqual([]);
|
|
1577
|
-
});
|
|
1578
|
-
|
|
1579
|
-
it('writes the header at its layout positions: ×100 improvement amounts, dates DD/MM/YYYY', () => {
|
|
1580
|
-
const [line] = linesOfType(
|
|
1581
|
-
minimalInput({
|
|
1582
|
-
capitalGains: [
|
|
1583
|
-
otherTransactionsAppendix({
|
|
1584
|
-
improvements: improvements(5),
|
|
1585
|
-
walletAddresses: ['0x1', '0x2'],
|
|
1586
|
-
}),
|
|
1587
|
-
],
|
|
1588
|
-
}),
|
|
1589
|
-
'3077',
|
|
1590
|
-
);
|
|
1591
|
-
expect(at(line, 137, 5)).toBe('77001');
|
|
1592
|
-
expect(at(line, 142, 1)).toBe('2');
|
|
1593
|
-
expect(at(line, 143, 50)).toBe('מבנה תעשייה'.padStart(50, ' '));
|
|
1594
|
-
expect(at(line, 193, 2)).toBe('21');
|
|
1595
|
-
expect(at(line, 195, 30)).toBe('רוכש נכסים בע"מ'.padStart(30, ' '));
|
|
1596
|
-
expect(at(line, 225, 10)).toBe('01/07/2024');
|
|
1597
|
-
expect(at(line, 235, 10)).toBe('01/02/2009');
|
|
1598
|
-
expect(at(line, 245, 2)).toBe('05');
|
|
1599
|
-
expect(at(line, 247, 12)).toBe('000001000025');
|
|
1600
|
-
expect(at(line, 259, 12)).toBe('000000100000');
|
|
1601
|
-
expect(at(line, 271, 10)).toBe('15/01/2010');
|
|
1602
|
-
expect(at(line, 383, 12)).toBe('000005000025');
|
|
1603
|
-
expect(at(line, 395, 12)).toBe('000000500000');
|
|
1604
|
-
expect(at(line, 407, 10)).toBe('15/05/2014');
|
|
1605
|
-
expect(at(line, 417, 50)).toBe('מבנה חלופי'.padStart(50, ' '));
|
|
1606
|
-
expect(at(line, 467, 10)).toBe('01/09/2024');
|
|
1607
|
-
expect(at(line, 477, 10)).toBe('0002000000');
|
|
1608
|
-
expect(at(line, 487, 2)).toBe('01');
|
|
1609
|
-
expect(at(line, 489, 150)).toBe('0x1'.padStart(150, ' '));
|
|
1610
|
-
expect(at(line, 639, 150)).toBe('0x2'.padStart(150, ' '));
|
|
1611
|
-
expect(at(line, 789, 372)).toMatch(/^0+$/);
|
|
1612
|
-
});
|
|
1613
|
-
|
|
1614
|
-
it('writes codes 501–505 ×100 after the input codes, in ascending code order', () => {
|
|
1615
|
-
const [line] = linesOfType(
|
|
1616
|
-
minimalInput({
|
|
1617
|
-
capitalGains: [
|
|
1618
|
-
otherTransactionsAppendix({ improvements: improvements(5), amounts: { '092': 1 } }),
|
|
1619
|
-
],
|
|
1620
|
-
}),
|
|
1621
|
-
'3077',
|
|
1622
|
-
);
|
|
1623
|
-
expect(at(line, 1161, 13 + 15 + 4 + 4 + 5 * 15)).toBe(
|
|
1624
|
-
'0150003000000' +
|
|
1625
|
-
'020000150000050' +
|
|
1626
|
-
'0711' +
|
|
1627
|
-
'0921' +
|
|
1628
|
-
'501000000900050' +
|
|
1629
|
-
'502000001800050' +
|
|
1630
|
-
'503000002700050' +
|
|
1631
|
-
'504000003600050' +
|
|
1632
|
-
'505000004500050',
|
|
1633
|
-
);
|
|
1634
|
-
});
|
|
1635
|
-
|
|
1636
|
-
it('writes 245 = 00 and blank slots without improvements, and reads none back', () => {
|
|
1637
|
-
const appendix = otherTransactionsAppendix({ improvements: undefined });
|
|
1638
|
-
const input = minimalInput({ capitalGains: [appendix] });
|
|
1639
|
-
const [record] = capitalGainsRecords(input);
|
|
1640
|
-
expect(record?.values).not.toHaveProperty('improvementCount');
|
|
1641
|
-
const [line] = linesOfType(input, '3077');
|
|
1642
|
-
expect(at(line, 245, 2)).toBe('00');
|
|
1643
|
-
expect(at(line, 247, 24)).toMatch(/^0+$/);
|
|
1644
|
-
expect(at(line, 271, 10)).toBe(' '.repeat(10));
|
|
1645
|
-
const parsed = parse1214(generate1214(input, OPTIONS).text);
|
|
1646
|
-
expect(parsed.issues).toEqual([]);
|
|
1647
|
-
expect(parsed.report.capitalGains?.[0]).not.toHaveProperty('improvements');
|
|
1648
|
-
});
|
|
1649
|
-
|
|
1650
|
-
it('raises no field.required for the empty slots 2–5 of a 3077 with one improvement', () => {
|
|
1651
|
-
const input = minimalInput({
|
|
1652
|
-
capitalGains: [otherTransactionsAppendix({ improvements: improvements(1) })],
|
|
1653
|
-
});
|
|
1654
|
-
expect(validate1214(input, OPTIONS)).toEqual({ valid: true, errors: [], warnings: [] });
|
|
1655
|
-
});
|
|
1656
|
-
|
|
1657
|
-
it('raises cg.improvements.max as a notice for a sixth improvement and writes the first five', () => {
|
|
1658
|
-
const input = minimalInput({
|
|
1659
|
-
capitalGains: [
|
|
1660
|
-
section6Appendix(),
|
|
1661
|
-
otherTransactionsAppendix({ improvements: improvements(6) }),
|
|
1662
|
-
],
|
|
1663
|
-
});
|
|
1664
|
-
const report = reportOf(input);
|
|
1665
|
-
expect(report.notices).toEqual([
|
|
1666
|
-
expect.objectContaining({
|
|
1667
|
-
ruleId: 'cg.improvements.max',
|
|
1668
|
-
severity: 'error',
|
|
1669
|
-
path: 'capitalGains[1].improvements[5]',
|
|
1670
|
-
recordType: '3077',
|
|
1671
|
-
recordIndex: 0,
|
|
1672
|
-
}),
|
|
1673
|
-
]);
|
|
1674
|
-
const record = report.records.find(r => r.recordType === '3077');
|
|
1675
|
-
expect(record?.values['improvements[4].date']).toBe('2014-05-15');
|
|
1676
|
-
expect(
|
|
1677
|
-
Object.keys(record?.values ?? {}).filter(key => key.startsWith('improvements[5]')),
|
|
1678
|
-
).toEqual([]);
|
|
1679
|
-
expect([...(record?.codes.keys() ?? [])].filter(code => code.startsWith('50'))).toEqual([
|
|
1680
|
-
'501',
|
|
1681
|
-
'502',
|
|
1682
|
-
'503',
|
|
1683
|
-
'504',
|
|
1684
|
-
'505',
|
|
1685
|
-
]);
|
|
1686
|
-
expect(errorsOf(input)).toEqual([
|
|
1687
|
-
['cg.improvements.max', 'capitalGains[1].improvements[5]', '3077'],
|
|
1688
|
-
]);
|
|
1689
|
-
});
|
|
1690
|
-
|
|
1691
|
-
it('accepts only 1 in code 092 (SPEC §15 A-11, A-31: shopcn rejected 2)', () => {
|
|
1692
|
-
expect(
|
|
1693
|
-
errorsOf(
|
|
1694
|
-
minimalInput({ capitalGains: [otherTransactionsAppendix({ amounts: { '092': 1 } })] }),
|
|
1695
|
-
),
|
|
1696
|
-
).toEqual([]);
|
|
1697
|
-
for (const value of [2, 9]) {
|
|
1698
|
-
expect(
|
|
1699
|
-
errorsOf(
|
|
1700
|
-
minimalInput({
|
|
1701
|
-
capitalGains: [otherTransactionsAppendix({ amounts: { '092': value } })],
|
|
1702
|
-
}),
|
|
1703
|
-
),
|
|
1704
|
-
).toEqual([['field.enum', 'capitalGains[0].amounts["092"]', '3077']]);
|
|
1705
|
-
}
|
|
1706
|
-
});
|
|
1707
|
-
|
|
1708
|
-
it('requires dates.code15 and dates.code20: input.shape for typed input, field.required in the model', () => {
|
|
1709
|
-
const input = {
|
|
1710
|
-
...minimalInput(),
|
|
1711
|
-
capitalGains: [{ ...otherTransactionsAppendix(), dates: {} }],
|
|
1712
|
-
};
|
|
1713
|
-
expect(validate1214(input, OPTIONS).errors.map(issue => [issue.ruleId, issue.path])).toEqual([
|
|
1714
|
-
['input.shape', 'capitalGains[0].dates.code15'],
|
|
1715
|
-
['input.shape', 'capitalGains[0].dates.code20'],
|
|
1716
|
-
]);
|
|
1717
|
-
expect(fieldIssuesOf(input)).toEqual([
|
|
1718
|
-
['field.required', 'capitalGains[0].dates.code15'],
|
|
1719
|
-
['field.required', 'capitalGains[0].dates.code20'],
|
|
1720
|
-
]);
|
|
1721
|
-
});
|
|
1722
|
-
|
|
1723
|
-
it('reports an improvement without a date: input.shape for typed input, field.required in the model', () => {
|
|
1724
|
-
const { date: _date, ...undated } = improvements(2)[1]!;
|
|
1725
|
-
const input = {
|
|
1726
|
-
...minimalInput(),
|
|
1727
|
-
capitalGains: [
|
|
1728
|
-
{ ...otherTransactionsAppendix(), improvements: [improvements(1)[0], undated] },
|
|
1729
|
-
],
|
|
1730
|
-
};
|
|
1731
|
-
expect(validate1214(input, OPTIONS).errors.map(issue => [issue.ruleId, issue.path])).toEqual([
|
|
1732
|
-
['input.shape', 'capitalGains[0].improvements[1].date'],
|
|
1733
|
-
]);
|
|
1734
|
-
expect(fieldIssuesOf(input)).toEqual([
|
|
1735
|
-
['field.required', 'capitalGains[0].improvements[1].date'],
|
|
1736
|
-
]);
|
|
1737
|
-
});
|
|
1738
|
-
|
|
1739
|
-
it('reports a problem of an improvement or of its code-50 amount at the improvement', () => {
|
|
1740
|
-
expect(
|
|
1741
|
-
errorsOf(
|
|
1742
|
-
minimalInput({
|
|
1743
|
-
capitalGains: [
|
|
1744
|
-
otherTransactionsAppendix({
|
|
1745
|
-
improvements: [
|
|
1746
|
-
improvements(1)[0]!,
|
|
1747
|
-
{ expense: 1.234, date: '2020-02-30', code50Amount: -1 },
|
|
1748
|
-
],
|
|
1749
|
-
}),
|
|
1750
|
-
],
|
|
1751
|
-
}),
|
|
1752
|
-
),
|
|
1753
|
-
).toEqual([
|
|
1754
|
-
['field.decimals', 'capitalGains[0].improvements[1].expense', '3077'],
|
|
1755
|
-
['field.date', 'capitalGains[0].improvements[1].date', '3077'],
|
|
1756
|
-
['field.negative', 'capitalGains[0].improvements[1].code50Amount', '3077'],
|
|
1757
|
-
]);
|
|
1758
|
-
});
|
|
1759
|
-
|
|
1760
|
-
it('reports a derived code 501–505 in amounts as input.derivedCode naming the improvement', () => {
|
|
1761
|
-
const input = {
|
|
1762
|
-
...minimalInput(),
|
|
1763
|
-
capitalGains: [
|
|
1764
|
-
section6Appendix(),
|
|
1765
|
-
{ ...otherTransactionsAppendix(), amounts: { '015': 1, '501': 5, '505': 6 } },
|
|
1766
|
-
],
|
|
1767
|
-
};
|
|
1768
|
-
const { errors } = validate1214(input, OPTIONS);
|
|
1769
|
-
expect(errors.map(issue => [issue.ruleId, issue.path, issue.recordType])).toEqual([
|
|
1770
|
-
['input.derivedCode', 'capitalGains[1].amounts["501"]', '3077'],
|
|
1771
|
-
['input.derivedCode', 'capitalGains[1].amounts["505"]', '3077'],
|
|
1772
|
-
]);
|
|
1773
|
-
expect(errors[0]?.message).toContain('capitalGains[1].improvements[0].code50Amount');
|
|
1774
|
-
expect(errors[1]?.message).toContain('capitalGains[1].improvements[4].code50Amount');
|
|
1775
|
-
});
|
|
1776
|
-
|
|
1777
|
-
it('reports a wallet address over 150 characters at its slot and a third one as input.shape', () => {
|
|
1778
|
-
expect(
|
|
1779
|
-
errorsOf(
|
|
1780
|
-
minimalInput({
|
|
1781
|
-
capitalGains: [otherTransactionsAppendix({ walletAddresses: ['a', 'b'.repeat(151)] })],
|
|
1782
|
-
}),
|
|
1783
|
-
),
|
|
1784
|
-
).toEqual([['field.length', 'capitalGains[0].walletAddresses[1]', '3077']]);
|
|
1785
|
-
const input = {
|
|
1786
|
-
...minimalInput(),
|
|
1787
|
-
capitalGains: [{ ...otherTransactionsAppendix(), walletAddresses: ['a', 'b', 'c'] }],
|
|
1788
|
-
};
|
|
1789
|
-
expect(validate1214(input, OPTIONS).errors).toEqual([
|
|
1790
|
-
expect.objectContaining({ ruleId: 'input.shape', path: 'capitalGains[0].walletAddresses' }),
|
|
1791
|
-
]);
|
|
1792
|
-
});
|
|
1793
|
-
|
|
1794
|
-
it('generates a 3077 with every member and parses it back', () => {
|
|
1795
|
-
const appendix = otherTransactionsAppendix({
|
|
1796
|
-
improvements: improvements(5),
|
|
1797
|
-
walletAddresses: ['0x1', '0x2'],
|
|
1798
|
-
amounts: { '092': 1 },
|
|
1799
|
-
});
|
|
1800
|
-
const input = minimalInput({ capitalGains: [appendix] });
|
|
1801
|
-
expect(validate1214(input, OPTIONS)).toEqual({ valid: true, errors: [], warnings: [] });
|
|
1802
|
-
const parsed = parse1214(generate1214(input, OPTIONS).text);
|
|
1803
|
-
expect(parsed.issues).toEqual([]);
|
|
1804
|
-
expect(parsed.report.capitalGains).toEqual([appendix]);
|
|
1805
|
-
});
|
|
1806
|
-
});
|
|
1807
|
-
|
|
1808
|
-
describe('the "מספר בתל"ם" sequence with a 3077 appendix (SPEC §7.4, §15 A-7)', () => {
|
|
1809
|
-
// Input order 77, 27, 66, 77: emitted 3027, 3066, 3077, 3077.
|
|
1810
|
-
const appendices = [
|
|
1811
|
-
otherTransactionsAppendix(),
|
|
1812
|
-
sharesAppendix(),
|
|
1813
|
-
noWithholding1326Appendix(),
|
|
1814
|
-
otherTransactionsAppendix({ assetLocation: 'abroad', improvements: improvements(1) }),
|
|
1815
|
-
];
|
|
1816
|
-
const input = minimalInput({ capitalGains: appendices });
|
|
1817
|
-
|
|
1818
|
-
it('numbers the 3077 appendices per symbol and writes their sequence at 487', () => {
|
|
1819
|
-
expect(
|
|
1820
|
-
capitalGainsRecords(input).map(r => [
|
|
1821
|
-
r.recordType,
|
|
1822
|
-
r.inputIndex,
|
|
1823
|
-
r.values.appendixNumber,
|
|
1824
|
-
r.values.sequenceNumber,
|
|
1825
|
-
]),
|
|
1826
|
-
).toEqual([
|
|
1827
|
-
['3027', 1, 1, 1],
|
|
1828
|
-
['3066', 2, 1, 2],
|
|
1829
|
-
['3077', 0, 1, 3],
|
|
1830
|
-
['3077', 3, 2, 4],
|
|
1831
|
-
]);
|
|
1832
|
-
const lines = linesOfType(input, '3077');
|
|
1833
|
-
expect(lines.map(line => [at(line, 137, 5), at(line, 487, 2)])).toEqual([
|
|
1834
|
-
['77001', '03'],
|
|
1835
|
-
['77002', '04'],
|
|
1836
|
-
]);
|
|
1837
|
-
});
|
|
1838
|
-
|
|
1839
|
-
it('generates the four records and parses them back in file order', () => {
|
|
1840
|
-
expect(validate1214(input, OPTIONS)).toEqual({ valid: true, errors: [], warnings: [] });
|
|
1841
|
-
const parsed = parse1214(generate1214(input, OPTIONS).text);
|
|
1842
|
-
expect(parsed.issues).toEqual([]);
|
|
1843
|
-
expect(parsed.report.capitalGains).toEqual([
|
|
1844
|
-
appendices[1],
|
|
1845
|
-
appendices[2],
|
|
1846
|
-
appendices[0],
|
|
1847
|
-
appendices[3],
|
|
1848
|
-
]);
|
|
1849
|
-
});
|
|
1850
|
-
});
|