@accounter/shaam-uniform-format-generator 0.1.0 → 0.1.1
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 +366 -13
- package/dist/README.md +476 -0
- package/dist/cjs/api/generate-report-legacy.js +6 -0
- package/dist/cjs/api/generate-report.js +328 -0
- package/dist/cjs/constants.js +11 -0
- package/dist/cjs/generator/format/encoder.js +86 -0
- package/dist/cjs/generator/records/a000-sum.js +66 -0
- package/dist/cjs/generator/records/a000.js +349 -0
- package/dist/cjs/generator/records/a100.js +107 -0
- package/dist/cjs/generator/records/b100.js +305 -0
- package/dist/cjs/generator/records/b110.js +255 -0
- package/dist/cjs/generator/records/c100.js +338 -0
- package/dist/cjs/generator/records/d110.js +272 -0
- package/dist/cjs/generator/records/d120.js +278 -0
- package/{cjs → dist/cjs}/generator/records/index.js +1 -0
- package/dist/cjs/generator/records/m100.js +177 -0
- package/dist/cjs/generator/records/z900.js +93 -0
- package/{cjs → dist/cjs}/index.js +3 -0
- package/dist/cjs/records/a100.js +78 -0
- package/dist/cjs/records/index.js +20 -0
- package/dist/cjs/records/z900.js +82 -0
- package/dist/cjs/types/enums.js +457 -0
- package/{cjs → dist/cjs}/types/index.js +6 -1
- package/dist/cjs/utils/file-helpers.js +198 -0
- package/dist/cjs/utils/index.js +8 -0
- package/dist/cjs/utils/key-generator.js +71 -0
- package/dist/esm/api/generate-report-legacy.js +2 -0
- package/dist/esm/api/generate-report.js +325 -0
- package/dist/esm/constants.js +8 -0
- package/dist/esm/generator/format/encoder.js +77 -0
- package/dist/esm/generator/records/a000-sum.js +61 -0
- package/dist/esm/generator/records/a000.js +344 -0
- package/dist/esm/generator/records/a100.js +102 -0
- package/dist/esm/generator/records/b100.js +300 -0
- package/dist/esm/generator/records/b110.js +250 -0
- package/dist/esm/generator/records/c100.js +333 -0
- package/dist/esm/generator/records/d110.js +267 -0
- package/dist/esm/generator/records/d120.js +273 -0
- package/{esm → dist/esm}/generator/records/index.js +1 -0
- package/dist/esm/generator/records/m100.js +172 -0
- package/dist/esm/generator/records/z900.js +88 -0
- package/{esm → dist/esm}/index.js +3 -0
- package/dist/esm/records/a100.js +73 -0
- package/dist/esm/records/index.js +11 -0
- package/dist/esm/records/z900.js +77 -0
- package/dist/esm/types/enums.js +454 -0
- package/{esm → dist/esm}/types/index.js +5 -1
- package/dist/esm/utils/file-helpers.js +188 -0
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/key-generator.js +65 -0
- package/dist/package.json +54 -0
- package/dist/typings/api/generate-report-legacy.d.cts +1 -0
- package/dist/typings/api/generate-report-legacy.d.ts +1 -0
- package/dist/typings/constants.d.cts +8 -0
- package/dist/typings/constants.d.ts +8 -0
- package/dist/typings/generator/format/encoder.d.cts +57 -0
- package/dist/typings/generator/format/encoder.d.ts +57 -0
- package/dist/typings/generator/records/a000-sum.d.cts +40 -0
- package/dist/typings/generator/records/a000-sum.d.ts +40 -0
- package/dist/typings/generator/records/a000.d.cts +238 -0
- package/dist/typings/generator/records/a000.d.ts +238 -0
- package/dist/typings/generator/records/a100.d.cts +59 -0
- package/dist/typings/generator/records/a100.d.ts +59 -0
- package/dist/typings/generator/records/b100.d.cts +101 -0
- package/dist/typings/generator/records/b100.d.ts +101 -0
- package/dist/typings/generator/records/b110.d.cts +89 -0
- package/dist/typings/generator/records/b110.d.ts +89 -0
- package/dist/typings/generator/records/c100.d.cts +133 -0
- package/dist/typings/generator/records/c100.d.ts +133 -0
- package/dist/typings/generator/records/d110.d.cts +98 -0
- package/dist/typings/generator/records/d110.d.ts +98 -0
- package/dist/typings/generator/records/d120.d.cts +95 -0
- package/dist/typings/generator/records/d120.d.ts +95 -0
- package/{typings → dist/typings}/generator/records/index.d.cts +1 -0
- package/{typings → dist/typings}/generator/records/index.d.ts +1 -0
- package/dist/typings/generator/records/m100.d.cts +69 -0
- package/dist/typings/generator/records/m100.d.ts +69 -0
- package/dist/typings/generator/records/z900.d.cts +61 -0
- package/dist/typings/generator/records/z900.d.ts +61 -0
- package/{typings → dist/typings}/index.d.cts +3 -0
- package/{typings → dist/typings}/index.d.ts +3 -0
- package/dist/typings/records/a100.d.cts +35 -0
- package/dist/typings/records/a100.d.ts +35 -0
- package/dist/typings/records/index.d.cts +2 -0
- package/dist/typings/records/index.d.ts +2 -0
- package/dist/typings/records/z900.d.cts +38 -0
- package/dist/typings/records/z900.d.ts +38 -0
- package/dist/typings/types/enums.d.cts +162 -0
- package/dist/typings/types/enums.d.ts +162 -0
- package/{typings → dist/typings}/types/index.d.cts +17 -14
- package/{typings → dist/typings}/types/index.d.ts +17 -14
- package/dist/typings/utils/file-helpers.d.cts +131 -0
- package/dist/typings/utils/file-helpers.d.ts +131 -0
- package/dist/typings/utils/index.d.cts +5 -0
- package/dist/typings/utils/index.d.ts +5 -0
- package/dist/typings/utils/key-generator.d.cts +41 -0
- package/dist/typings/utils/key-generator.d.ts +41 -0
- package/documentation/IncomeTax_IncomeTaxSoftwareHousesInfo_horaot1.31_2_05.pdf +0 -0
- package/documentation/_4D6963726F736F667420576F7264202D20F8E5E0E9ED20F8E7E5F720F8E5E0E9ED20F9F7E5F32E646F63_.pdf +0 -0
- package/documentation/a000-sum.csv +3 -0
- package/documentation/a000.csv +37 -0
- package/documentation/a100.csv +7 -0
- package/documentation/b100.csv +29 -0
- package/documentation/b110.csv +26 -0
- package/documentation/c100.csv +37 -0
- package/documentation/d110.csv +27 -0
- package/documentation/d120.csv +26 -0
- package/documentation/m100.csv +17 -0
- package/documentation/z900.csv +8 -0
- package/package.json +50 -29
- package/prompt_plan.md +259 -0
- package/spec.md +206 -0
- package/src/api/generate-report.ts +366 -0
- package/src/api/parse-files.ts +33 -0
- package/src/constants.ts +9 -0
- package/src/format/index.ts +6 -0
- package/src/format/newline.ts +8 -0
- package/src/format/padding.ts +39 -0
- package/src/generator/format/decoder.ts +15 -0
- package/src/generator/format/encoder.ts +95 -0
- package/src/generator/format/index.ts +6 -0
- package/src/generator/index.ts +6 -0
- package/src/generator/records/a000-sum.ts +78 -0
- package/src/generator/records/a000.ts +373 -0
- package/src/generator/records/a100.ts +118 -0
- package/src/generator/records/b100.ts +317 -0
- package/src/generator/records/b110.ts +267 -0
- package/src/generator/records/c100.ts +347 -0
- package/src/generator/records/d110.ts +286 -0
- package/src/generator/records/d120.ts +293 -0
- package/src/generator/records/index.ts +14 -0
- package/src/generator/records/m100.ts +185 -0
- package/src/generator/records/z900.ts +104 -0
- package/src/index.ts +18 -0
- package/src/parser/data-parser.ts +14 -0
- package/src/parser/index.ts +6 -0
- package/src/parser/ini-parser.ts +14 -0
- package/src/types/enums.ts +531 -0
- package/src/types/index.ts +110 -0
- package/src/utils/file-helpers.ts +221 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/key-generator.ts +75 -0
- package/src/validation/errors.ts +35 -0
- package/src/validation/index.ts +6 -0
- package/src/validation/validate-input.ts +67 -0
- package/tests/debug-output.test.ts +81 -0
- package/tests/format/crlf-join.test.ts +124 -0
- package/tests/format/encoder.test.ts +80 -0
- package/tests/format/newline.test.ts +19 -0
- package/tests/format/padding.test.ts +74 -0
- package/tests/index.test.ts +29 -0
- package/tests/ini-text.test.ts +122 -0
- package/tests/integration/comprehensive.integration.test.ts +350 -0
- package/tests/integration/roundtrip.integration.test.ts +377 -0
- package/tests/records/a000-sum.test.ts +278 -0
- package/tests/records/a000.test.ts +318 -0
- package/tests/records/a100.test.ts +239 -0
- package/tests/records/b100.test.ts +419 -0
- package/tests/records/b110.test.ts +445 -0
- package/tests/records/c100.test.ts +333 -0
- package/tests/records/d110.test.ts +93 -0
- package/tests/records/d120.test.ts +275 -0
- package/tests/records/m100.test.ts +437 -0
- package/tests/records/z900.test.ts +254 -0
- package/tests/types/enums.test.ts +290 -0
- package/tests/utils/file-helpers.test.ts +276 -0
- package/tests/utils/key-generator.test.ts +121 -0
- package/tests/validation/document-type-validation.test.ts +521 -0
- package/tests/validation/validate-input.test.ts +219 -0
- package/todo.md +203 -0
- package/tsconfig.json +10 -0
- package/vitest.config.ts +11 -0
- package/cjs/api/generate-report.js +0 -53
- package/cjs/generator/format/encoder.js +0 -46
- package/cjs/generator/records/a000.js +0 -8
- package/cjs/generator/records/a100.js +0 -8
- package/cjs/generator/records/b100.js +0 -8
- package/cjs/generator/records/b110.js +0 -8
- package/cjs/generator/records/c100.js +0 -8
- package/cjs/generator/records/d110.js +0 -8
- package/cjs/generator/records/d120.js +0 -8
- package/cjs/generator/records/m100.js +0 -8
- package/cjs/generator/records/z900.js +0 -8
- package/esm/api/generate-report.js +0 -50
- package/esm/generator/format/encoder.js +0 -42
- package/esm/generator/records/a000.js +0 -5
- package/esm/generator/records/a100.js +0 -5
- package/esm/generator/records/b100.js +0 -5
- package/esm/generator/records/b110.js +0 -5
- package/esm/generator/records/c100.js +0 -5
- package/esm/generator/records/d110.js +0 -5
- package/esm/generator/records/d120.js +0 -5
- package/esm/generator/records/m100.js +0 -5
- package/esm/generator/records/z900.js +0 -5
- package/typings/generator/format/encoder.d.cts +0 -33
- package/typings/generator/format/encoder.d.ts +0 -33
- package/typings/generator/records/a000.d.cts +0 -4
- package/typings/generator/records/a000.d.ts +0 -4
- package/typings/generator/records/a100.d.cts +0 -4
- package/typings/generator/records/a100.d.ts +0 -4
- package/typings/generator/records/b100.d.cts +0 -4
- package/typings/generator/records/b100.d.ts +0 -4
- package/typings/generator/records/b110.d.cts +0 -4
- package/typings/generator/records/b110.d.ts +0 -4
- package/typings/generator/records/c100.d.cts +0 -4
- package/typings/generator/records/c100.d.ts +0 -4
- package/typings/generator/records/d110.d.cts +0 -4
- package/typings/generator/records/d110.d.ts +0 -4
- package/typings/generator/records/d120.d.cts +0 -4
- package/typings/generator/records/d120.d.ts +0 -4
- package/typings/generator/records/m100.d.cts +0 -4
- package/typings/generator/records/m100.d.ts +0 -4
- package/typings/generator/records/z900.d.cts +0 -4
- package/typings/generator/records/z900.d.ts +0 -4
- /package/{cjs → dist/cjs}/api/parse-files.js +0 -0
- /package/{cjs → dist/cjs}/format/index.js +0 -0
- /package/{cjs → dist/cjs}/format/newline.js +0 -0
- /package/{cjs → dist/cjs}/format/padding.js +0 -0
- /package/{cjs → dist/cjs}/generator/format/decoder.js +0 -0
- /package/{cjs → dist/cjs}/generator/format/index.js +0 -0
- /package/{cjs → dist/cjs}/generator/index.js +0 -0
- /package/{cjs → dist/cjs}/package.json +0 -0
- /package/{cjs → dist/cjs}/parser/data-parser.js +0 -0
- /package/{cjs → dist/cjs}/parser/index.js +0 -0
- /package/{cjs → dist/cjs}/parser/ini-parser.js +0 -0
- /package/{cjs → dist/cjs}/validation/errors.js +0 -0
- /package/{cjs → dist/cjs}/validation/index.js +0 -0
- /package/{cjs → dist/cjs}/validation/validate-input.js +0 -0
- /package/{esm → dist/esm}/api/parse-files.js +0 -0
- /package/{esm → dist/esm}/format/index.js +0 -0
- /package/{esm → dist/esm}/format/newline.js +0 -0
- /package/{esm → dist/esm}/format/padding.js +0 -0
- /package/{esm → dist/esm}/generator/format/decoder.js +0 -0
- /package/{esm → dist/esm}/generator/format/index.js +0 -0
- /package/{esm → dist/esm}/generator/index.js +0 -0
- /package/{esm → dist/esm}/parser/data-parser.js +0 -0
- /package/{esm → dist/esm}/parser/index.js +0 -0
- /package/{esm → dist/esm}/parser/ini-parser.js +0 -0
- /package/{esm → dist/esm}/validation/errors.js +0 -0
- /package/{esm → dist/esm}/validation/index.js +0 -0
- /package/{esm → dist/esm}/validation/validate-input.js +0 -0
- /package/{typings → dist/typings}/api/generate-report.d.cts +0 -0
- /package/{typings → dist/typings}/api/generate-report.d.ts +0 -0
- /package/{typings → dist/typings}/api/parse-files.d.cts +0 -0
- /package/{typings → dist/typings}/api/parse-files.d.ts +0 -0
- /package/{typings → dist/typings}/format/index.d.cts +0 -0
- /package/{typings → dist/typings}/format/index.d.ts +0 -0
- /package/{typings → dist/typings}/format/newline.d.cts +0 -0
- /package/{typings → dist/typings}/format/newline.d.ts +0 -0
- /package/{typings → dist/typings}/format/padding.d.cts +0 -0
- /package/{typings → dist/typings}/format/padding.d.ts +0 -0
- /package/{typings → dist/typings}/generator/format/decoder.d.cts +0 -0
- /package/{typings → dist/typings}/generator/format/decoder.d.ts +0 -0
- /package/{typings → dist/typings}/generator/format/index.d.cts +0 -0
- /package/{typings → dist/typings}/generator/format/index.d.ts +0 -0
- /package/{typings → dist/typings}/generator/index.d.cts +0 -0
- /package/{typings → dist/typings}/generator/index.d.ts +0 -0
- /package/{typings → dist/typings}/parser/data-parser.d.cts +0 -0
- /package/{typings → dist/typings}/parser/data-parser.d.ts +0 -0
- /package/{typings → dist/typings}/parser/index.d.cts +0 -0
- /package/{typings → dist/typings}/parser/index.d.ts +0 -0
- /package/{typings → dist/typings}/parser/ini-parser.d.cts +0 -0
- /package/{typings → dist/typings}/parser/ini-parser.d.ts +0 -0
- /package/{typings → dist/typings}/validation/errors.d.cts +0 -0
- /package/{typings → dist/typings}/validation/errors.d.ts +0 -0
- /package/{typings → dist/typings}/validation/index.d.cts +0 -0
- /package/{typings → dist/typings}/validation/index.d.ts +0 -0
- /package/{typings → dist/typings}/validation/validate-input.d.cts +0 -0
- /package/{typings → dist/typings}/validation/validate-input.d.ts +0 -0
package/dist/README.md
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
# @accounter/shaam-uniform-format-generator
|
|
2
|
+
|
|
3
|
+
A fully typed TypeScript library for generating, parsing, and validating SHAAM uniform format tax
|
|
4
|
+
reports (`INI.TXT` and `BKMVDATA.TXT` files).
|
|
5
|
+
|
|
6
|
+
## 🧩 Overview
|
|
7
|
+
|
|
8
|
+
This package provides a comprehensive solution for working with SHAAM (Israeli tax authority)
|
|
9
|
+
uniform format files. It allows you to:
|
|
10
|
+
|
|
11
|
+
1. **Generate** `INI.TXT` and `BKMVDATA.TXT` files from a high-level JSON object
|
|
12
|
+
2. **Parse** those files back into structured, validated JSON
|
|
13
|
+
3. **Validate** data against SHAAM 1.31 specifications
|
|
14
|
+
4. **Format** output with spec-compliant field widths, padding, and CRLF line endings
|
|
15
|
+
|
|
16
|
+
## 🚀 Features
|
|
17
|
+
|
|
18
|
+
- **Type Safety**: Full TypeScript support with strict typing
|
|
19
|
+
- **Validation**: Built-in Zod schemas for data validation
|
|
20
|
+
- **Format Compliance**: Generates files that meet SHAAM 1.31 specifications
|
|
21
|
+
- **Developer Experience**: Excellent autocompletion and helpful error messages
|
|
22
|
+
- **File System Agnostic**: Returns content in memory without writing to disk
|
|
23
|
+
- **Comprehensive Testing**: Full test coverage with Vitest
|
|
24
|
+
|
|
25
|
+
## 📁 Supported Record Types
|
|
26
|
+
|
|
27
|
+
### `INI.TXT`
|
|
28
|
+
|
|
29
|
+
- `A000` — Header
|
|
30
|
+
- `A000Sum` — Count summary records for each record type
|
|
31
|
+
|
|
32
|
+
### `BKMVDATA.TXT`
|
|
33
|
+
|
|
34
|
+
- `A100` — Business opening record
|
|
35
|
+
- `C100` — Document header
|
|
36
|
+
- `D110` — Document line
|
|
37
|
+
- `D120` — Payment/receipt
|
|
38
|
+
- `B100` — Journal entry line
|
|
39
|
+
- `B110` — Account
|
|
40
|
+
- `M100` — Inventory item
|
|
41
|
+
- `Z900` — Closing record
|
|
42
|
+
|
|
43
|
+
## 🛠️ Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install @accounter/shaam-uniform-format-generator
|
|
47
|
+
# or
|
|
48
|
+
yarn add @accounter/shaam-uniform-format-generator
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 📖 API Documentation
|
|
52
|
+
|
|
53
|
+
### Main Functions
|
|
54
|
+
|
|
55
|
+
#### `generateUniformFormatReport(input, options?)`
|
|
56
|
+
|
|
57
|
+
Generates SHAAM uniform format report files from a high-level JSON input object.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import {
|
|
61
|
+
generateUniformFormatReport,
|
|
62
|
+
type ReportInput
|
|
63
|
+
} from '@accounter/shaam-uniform-format-generator'
|
|
64
|
+
|
|
65
|
+
const reportInput: ReportInput = {
|
|
66
|
+
business: {
|
|
67
|
+
businessId: '12345',
|
|
68
|
+
name: 'Example Business Ltd',
|
|
69
|
+
taxId: '123456789',
|
|
70
|
+
reportingPeriod: {
|
|
71
|
+
startDate: '2023-01-01',
|
|
72
|
+
endDate: '2023-12-31'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
documents: [
|
|
76
|
+
{
|
|
77
|
+
id: 'INV001',
|
|
78
|
+
type: '320', // Invoice
|
|
79
|
+
date: '2023-06-15',
|
|
80
|
+
amount: 1000.0,
|
|
81
|
+
description: 'Service invoice'
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
journalEntries: [
|
|
85
|
+
{
|
|
86
|
+
id: 'JE001',
|
|
87
|
+
date: '2023-06-15',
|
|
88
|
+
amount: 1000.0,
|
|
89
|
+
accountId: '1100',
|
|
90
|
+
description: 'Revenue entry'
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
accounts: [
|
|
94
|
+
{
|
|
95
|
+
id: '1100',
|
|
96
|
+
name: 'Revenue Account',
|
|
97
|
+
type: '4', // Revenue
|
|
98
|
+
balance: 1000.0
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
inventory: [
|
|
102
|
+
{
|
|
103
|
+
id: 'ITEM001',
|
|
104
|
+
name: 'Service Item',
|
|
105
|
+
quantity: 1,
|
|
106
|
+
unitPrice: 1000.0
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const result = generateUniformFormatReport(reportInput, {
|
|
112
|
+
validationMode: 'fail-fast', // or 'collect-all'
|
|
113
|
+
fileNameBase: 'my-report'
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
console.log(result.iniText) // INI.TXT content
|
|
117
|
+
console.log(result.dataText) // BKMVDATA.TXT content
|
|
118
|
+
console.log(result.summary) // Generation summary
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### `parseUniformFormatFiles(iniContent, dataContent)`
|
|
122
|
+
|
|
123
|
+
Parses SHAAM uniform format files back into structured JSON.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import { parseUniformFormatFiles } from '@accounter/shaam-uniform-format-generator'
|
|
127
|
+
|
|
128
|
+
const parsedData = parseUniformFormatFiles(iniFileContent, dataFileContent)
|
|
129
|
+
console.log(parsedData.business) // Parsed business metadata
|
|
130
|
+
console.log(parsedData.documents) // Parsed documents
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Types and Interfaces
|
|
134
|
+
|
|
135
|
+
#### `ReportInput`
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
interface ReportInput {
|
|
139
|
+
business: BusinessMetadata
|
|
140
|
+
documents: Document[]
|
|
141
|
+
journalEntries: JournalEntry[]
|
|
142
|
+
accounts: Account[]
|
|
143
|
+
inventory: InventoryItem[]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### `BusinessMetadata`
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
interface BusinessMetadata {
|
|
151
|
+
businessId: string
|
|
152
|
+
name: string
|
|
153
|
+
taxId: string
|
|
154
|
+
reportingPeriod: {
|
|
155
|
+
startDate: string // YYYY-MM-DD format
|
|
156
|
+
endDate: string // YYYY-MM-DD format
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### `Document`
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
interface Document {
|
|
165
|
+
id: string
|
|
166
|
+
type: DocumentType // e.g., "320" for invoice, "330" for credit note
|
|
167
|
+
date: string // YYYY-MM-DD format
|
|
168
|
+
amount: number
|
|
169
|
+
description?: string
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### `JournalEntry`
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
interface JournalEntry {
|
|
177
|
+
id: string
|
|
178
|
+
date: string // YYYY-MM-DD format
|
|
179
|
+
amount: number
|
|
180
|
+
accountId: string
|
|
181
|
+
description?: string
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### `Account`
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
interface Account {
|
|
189
|
+
id: string
|
|
190
|
+
name: string
|
|
191
|
+
type: string // Account type code
|
|
192
|
+
balance: number
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### `InventoryItem`
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
interface InventoryItem {
|
|
200
|
+
id: string
|
|
201
|
+
name: string
|
|
202
|
+
quantity: number
|
|
203
|
+
unitPrice: number
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### `ReportOutput`
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
interface ReportOutput {
|
|
211
|
+
iniText: string // INI.TXT file content
|
|
212
|
+
dataText: string // BKMVDATA.TXT file content
|
|
213
|
+
iniFile: File // Virtual File object for INI.TXT
|
|
214
|
+
dataFile: File // Virtual File object for BKMVDATA.TXT
|
|
215
|
+
summary: {
|
|
216
|
+
totalRecords: number
|
|
217
|
+
perType: Record<string, number>
|
|
218
|
+
errors?: ValidationError[]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Options
|
|
224
|
+
|
|
225
|
+
#### `GenerationOptions`
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
interface GenerationOptions {
|
|
229
|
+
validationMode?: 'fail-fast' | 'collect-all' // Default: 'fail-fast'
|
|
230
|
+
fileNameBase?: string // Default: 'report'
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
- **`validationMode`**:
|
|
235
|
+
- `'fail-fast'`: Stop validation on first error and throw immediately
|
|
236
|
+
- `'collect-all'`: Collect all validation errors before throwing
|
|
237
|
+
- **`fileNameBase`**: Base name for generated files (without extension)
|
|
238
|
+
|
|
239
|
+
### Enums and Constants
|
|
240
|
+
|
|
241
|
+
The package exports comprehensive enums for SHAAM code tables:
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import {
|
|
245
|
+
CountryCodeEnum,
|
|
246
|
+
CurrencyCodeEnum,
|
|
247
|
+
DocumentTypeEnum,
|
|
248
|
+
PaymentMethodEnum
|
|
249
|
+
} from '@accounter/shaam-uniform-format-generator'
|
|
250
|
+
|
|
251
|
+
// Document types
|
|
252
|
+
const invoiceType = DocumentTypeEnum.enum['320'] // Invoice
|
|
253
|
+
const creditNoteType = DocumentTypeEnum.enum['330'] // Credit note
|
|
254
|
+
|
|
255
|
+
// Currency codes
|
|
256
|
+
const ils = CurrencyCodeEnum.enum.ILS // Israeli Shekel
|
|
257
|
+
const usd = CurrencyCodeEnum.enum.USD // US Dollar
|
|
258
|
+
|
|
259
|
+
// Payment methods
|
|
260
|
+
const cash = PaymentMethodEnum.enum['1'] // Cash
|
|
261
|
+
const check = PaymentMethodEnum.enum['2'] // Check
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## 🎯 Complete Example
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import {
|
|
268
|
+
generateUniformFormatReport,
|
|
269
|
+
parseUniformFormatFiles,
|
|
270
|
+
type ReportInput
|
|
271
|
+
} from '@accounter/shaam-uniform-format-generator'
|
|
272
|
+
|
|
273
|
+
// 1. Prepare your data
|
|
274
|
+
const reportData: ReportInput = {
|
|
275
|
+
business: {
|
|
276
|
+
businessId: 'COMP001',
|
|
277
|
+
name: 'Acme Corp Ltd',
|
|
278
|
+
taxId: '123456789',
|
|
279
|
+
reportingPeriod: {
|
|
280
|
+
startDate: '2023-01-01',
|
|
281
|
+
endDate: '2023-12-31'
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
documents: [
|
|
285
|
+
{
|
|
286
|
+
id: 'INV-2023-001',
|
|
287
|
+
type: '320', // Invoice
|
|
288
|
+
date: '2023-03-15',
|
|
289
|
+
amount: 2340.0,
|
|
290
|
+
description: 'Consulting services'
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
id: 'CN-2023-001',
|
|
294
|
+
type: '330', // Credit note
|
|
295
|
+
date: '2023-04-10',
|
|
296
|
+
amount: -340.0,
|
|
297
|
+
description: 'Service adjustment'
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
journalEntries: [
|
|
301
|
+
{
|
|
302
|
+
id: 'JE-2023-001',
|
|
303
|
+
date: '2023-03-15',
|
|
304
|
+
amount: 2340.0,
|
|
305
|
+
accountId: '4000',
|
|
306
|
+
description: 'Consulting revenue'
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
id: 'JE-2023-002',
|
|
310
|
+
date: '2023-04-10',
|
|
311
|
+
amount: -340.0,
|
|
312
|
+
accountId: '4000',
|
|
313
|
+
description: 'Revenue adjustment'
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
accounts: [
|
|
317
|
+
{
|
|
318
|
+
id: '4000',
|
|
319
|
+
name: 'Consulting Revenue',
|
|
320
|
+
type: '4', // Revenue account
|
|
321
|
+
balance: 2000.0
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
id: '1200',
|
|
325
|
+
name: 'Accounts Receivable',
|
|
326
|
+
type: '1', // Asset account
|
|
327
|
+
balance: 1500.0
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
inventory: [
|
|
331
|
+
{
|
|
332
|
+
id: 'SERV-001',
|
|
333
|
+
name: 'Consulting Hour',
|
|
334
|
+
quantity: 20,
|
|
335
|
+
unitPrice: 117.0
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// 2. Generate the files
|
|
341
|
+
try {
|
|
342
|
+
const result = generateUniformFormatReport(reportData, {
|
|
343
|
+
validationMode: 'fail-fast',
|
|
344
|
+
fileNameBase: 'quarterly-report-2023-q1'
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
// 3. Access the generated content
|
|
348
|
+
console.log('Generated INI.TXT:')
|
|
349
|
+
console.log(result.iniText)
|
|
350
|
+
|
|
351
|
+
console.log('\nGenerated BKMVDATA.TXT:')
|
|
352
|
+
console.log(result.dataText)
|
|
353
|
+
|
|
354
|
+
console.log('\nSummary:')
|
|
355
|
+
console.log(`Total records: ${result.summary.totalRecords}`)
|
|
356
|
+
console.log('Records per type:', result.summary.perType)
|
|
357
|
+
|
|
358
|
+
// 4. Save files (example using Node.js fs)
|
|
359
|
+
// import { writeFileSync } from 'fs'
|
|
360
|
+
// writeFileSync('report.INI.TXT', result.iniText, 'utf8')
|
|
361
|
+
// writeFileSync('report.BKMVDATA.TXT', result.dataText, 'utf8')
|
|
362
|
+
|
|
363
|
+
// 5. Parse files back (round-trip test)
|
|
364
|
+
const parsedData = parseUniformFormatFiles(result.iniText, result.dataText)
|
|
365
|
+
console.log('\nParsed business data:', parsedData.business)
|
|
366
|
+
} catch (error) {
|
|
367
|
+
console.error('Generation failed:', error.message)
|
|
368
|
+
if (error.errors) {
|
|
369
|
+
console.error('Validation errors:', error.errors)
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## 🔧 Advanced Usage
|
|
375
|
+
|
|
376
|
+
### Custom Validation
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
import { ReportInputSchema } from '@accounter/shaam-uniform-format-generator'
|
|
380
|
+
|
|
381
|
+
// Validate data before generation
|
|
382
|
+
const validationResult = ReportInputSchema.safeParse(yourData)
|
|
383
|
+
if (!validationResult.success) {
|
|
384
|
+
console.error('Validation errors:', validationResult.error.issues)
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Working with Individual Records
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
import { encodeC100, parseC100, type C100Input } from '@accounter/shaam-uniform-format-generator'
|
|
392
|
+
|
|
393
|
+
// Encode a single document record
|
|
394
|
+
const documentRecord: C100Input = {
|
|
395
|
+
code: 'C100',
|
|
396
|
+
recordNumber: '1',
|
|
397
|
+
vatId: '123456789',
|
|
398
|
+
documentType: '320',
|
|
399
|
+
documentId: 'INV001',
|
|
400
|
+
documentIssueDate: '20230315'
|
|
401
|
+
// ... other fields
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const encodedLine = encodeC100(documentRecord)
|
|
405
|
+
console.log(encodedLine) // Fixed-width formatted line
|
|
406
|
+
|
|
407
|
+
// Parse it back
|
|
408
|
+
const parsedRecord = parseC100(encodedLine)
|
|
409
|
+
console.log(parsedRecord) // Structured object
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## 🏗️ Development
|
|
413
|
+
|
|
414
|
+
This project uses:
|
|
415
|
+
|
|
416
|
+
- **TypeScript** in strict mode for type safety
|
|
417
|
+
- **Zod** for runtime validation
|
|
418
|
+
- **Vitest** for testing
|
|
419
|
+
- **Bob the Bundler** for building
|
|
420
|
+
|
|
421
|
+
### Commands
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
# Development
|
|
425
|
+
yarn dev
|
|
426
|
+
|
|
427
|
+
# Testing
|
|
428
|
+
yarn test
|
|
429
|
+
yarn test:watch
|
|
430
|
+
|
|
431
|
+
# Building
|
|
432
|
+
yarn build
|
|
433
|
+
|
|
434
|
+
# Linting
|
|
435
|
+
yarn lint
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
## 📋 Requirements
|
|
439
|
+
|
|
440
|
+
- Node.js ^20.0.0 || >= 22
|
|
441
|
+
- TypeScript support
|
|
442
|
+
|
|
443
|
+
## � Error Handling
|
|
444
|
+
|
|
445
|
+
The library provides detailed error information:
|
|
446
|
+
|
|
447
|
+
```typescript
|
|
448
|
+
import { ShaamFormatError } from '@accounter/shaam-uniform-format-generator'
|
|
449
|
+
|
|
450
|
+
try {
|
|
451
|
+
const result = generateUniformFormatReport(invalidData)
|
|
452
|
+
} catch (error) {
|
|
453
|
+
if (error instanceof ShaamFormatError) {
|
|
454
|
+
console.error('SHAAM format error:', error.message)
|
|
455
|
+
console.error('Validation errors:', error.errors)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## �📄 License
|
|
461
|
+
|
|
462
|
+
MIT
|
|
463
|
+
|
|
464
|
+
## 🤝 Contributing
|
|
465
|
+
|
|
466
|
+
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our
|
|
467
|
+
repository.
|
|
468
|
+
|
|
469
|
+
## 📚 Documentation
|
|
470
|
+
|
|
471
|
+
For detailed documentation about SHAAM format specifications, see the `documentation/` folder.
|
|
472
|
+
|
|
473
|
+
## 🔗 Related
|
|
474
|
+
|
|
475
|
+
- [SHAAM Specification 1.31](documentation/) - Official specification documents
|
|
476
|
+
- [Israeli Tax Authority](https://www.gov.il/he/departments/taxes) - Official tax authority website
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateUniformFormatReport = void 0;
|
|
4
|
+
// Placeholder for generateReport implementation
|
|
5
|
+
var generate_report_js_1 = require("./generate-report.js");
|
|
6
|
+
Object.defineProperty(exports, "generateUniformFormatReport", { enumerable: true, get: function () { return generate_report_js_1.generateUniformFormatReport; } });
|