@accounter/shaam-uniform-format-generator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -0
- package/cjs/api/generate-report.js +53 -0
- package/cjs/api/parse-files.js +32 -0
- package/cjs/format/index.js +8 -0
- package/cjs/format/newline.js +10 -0
- package/cjs/format/padding.js +39 -0
- package/cjs/generator/format/decoder.js +17 -0
- package/cjs/generator/format/encoder.js +46 -0
- package/cjs/generator/format/index.js +8 -0
- package/cjs/generator/index.js +8 -0
- package/cjs/generator/records/a000.js +8 -0
- package/cjs/generator/records/a100.js +8 -0
- package/cjs/generator/records/b100.js +8 -0
- package/cjs/generator/records/b110.js +8 -0
- package/cjs/generator/records/c100.js +8 -0
- package/cjs/generator/records/d110.js +8 -0
- package/cjs/generator/records/d120.js +8 -0
- package/cjs/generator/records/index.js +15 -0
- package/cjs/generator/records/m100.js +8 -0
- package/cjs/generator/records/z900.js +8 -0
- package/cjs/index.js +19 -0
- package/cjs/package.json +1 -0
- package/cjs/parser/data-parser.js +16 -0
- package/cjs/parser/index.js +8 -0
- package/cjs/parser/ini-parser.js +16 -0
- package/cjs/types/index.js +74 -0
- package/cjs/validation/errors.js +30 -0
- package/cjs/validation/index.js +8 -0
- package/cjs/validation/validate-input.js +56 -0
- package/esm/api/generate-report.js +50 -0
- package/esm/api/parse-files.js +29 -0
- package/esm/format/index.js +5 -0
- package/esm/format/newline.js +7 -0
- package/esm/format/padding.js +35 -0
- package/esm/generator/format/decoder.js +14 -0
- package/esm/generator/format/encoder.js +42 -0
- package/esm/generator/format/index.js +5 -0
- package/esm/generator/index.js +5 -0
- package/esm/generator/records/a000.js +5 -0
- package/esm/generator/records/a100.js +5 -0
- package/esm/generator/records/b100.js +5 -0
- package/esm/generator/records/b110.js +5 -0
- package/esm/generator/records/c100.js +5 -0
- package/esm/generator/records/d110.js +5 -0
- package/esm/generator/records/d120.js +5 -0
- package/esm/generator/records/index.js +12 -0
- package/esm/generator/records/m100.js +5 -0
- package/esm/generator/records/z900.js +5 -0
- package/esm/index.js +13 -0
- package/esm/parser/data-parser.js +13 -0
- package/esm/parser/index.js +5 -0
- package/esm/parser/ini-parser.js +13 -0
- package/esm/types/index.js +71 -0
- package/esm/validation/errors.js +25 -0
- package/esm/validation/index.js +5 -0
- package/esm/validation/validate-input.js +53 -0
- package/package.json +54 -0
- package/typings/api/generate-report.d.cts +13 -0
- package/typings/api/generate-report.d.ts +13 -0
- package/typings/api/parse-files.d.cts +13 -0
- package/typings/api/parse-files.d.ts +13 -0
- package/typings/format/index.d.cts +5 -0
- package/typings/format/index.d.ts +5 -0
- package/typings/format/newline.d.cts +7 -0
- package/typings/format/newline.d.ts +7 -0
- package/typings/format/padding.d.cts +21 -0
- package/typings/format/padding.d.ts +21 -0
- package/typings/generator/format/decoder.d.cts +12 -0
- package/typings/generator/format/decoder.d.ts +12 -0
- package/typings/generator/format/encoder.d.cts +33 -0
- package/typings/generator/format/encoder.d.ts +33 -0
- package/typings/generator/format/index.d.cts +5 -0
- package/typings/generator/format/index.d.ts +5 -0
- package/typings/generator/index.d.cts +5 -0
- package/typings/generator/index.d.ts +5 -0
- package/typings/generator/records/a000.d.cts +4 -0
- package/typings/generator/records/a000.d.ts +4 -0
- package/typings/generator/records/a100.d.cts +4 -0
- package/typings/generator/records/a100.d.ts +4 -0
- package/typings/generator/records/b100.d.cts +4 -0
- package/typings/generator/records/b100.d.ts +4 -0
- package/typings/generator/records/b110.d.cts +4 -0
- package/typings/generator/records/b110.d.ts +4 -0
- package/typings/generator/records/c100.d.cts +4 -0
- package/typings/generator/records/c100.d.ts +4 -0
- package/typings/generator/records/d110.d.cts +4 -0
- package/typings/generator/records/d110.d.ts +4 -0
- package/typings/generator/records/d120.d.cts +4 -0
- package/typings/generator/records/d120.d.ts +4 -0
- package/typings/generator/records/index.d.cts +12 -0
- package/typings/generator/records/index.d.ts +12 -0
- package/typings/generator/records/m100.d.cts +4 -0
- package/typings/generator/records/m100.d.ts +4 -0
- package/typings/generator/records/z900.d.cts +4 -0
- package/typings/generator/records/z900.d.ts +4 -0
- package/typings/index.d.cts +12 -0
- package/typings/index.d.ts +12 -0
- package/typings/parser/data-parser.d.cts +10 -0
- package/typings/parser/data-parser.d.ts +10 -0
- package/typings/parser/index.d.cts +5 -0
- package/typings/parser/index.d.ts +5 -0
- package/typings/parser/ini-parser.d.cts +10 -0
- package/typings/parser/ini-parser.d.ts +10 -0
- package/typings/types/index.d.cts +371 -0
- package/typings/types/index.d.ts +371 -0
- package/typings/validation/errors.d.cts +15 -0
- package/typings/validation/errors.d.ts +15 -0
- package/typings/validation/index.d.cts +5 -0
- package/typings/validation/index.d.ts +5 -0
- package/typings/validation/validate-input.d.cts +12 -0
- package/typings/validation/validate-input.d.ts +12 -0
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
- `B100`, `B110`, `C100`, `D110`, `D120`, `M100` — Count summary records
|
|
31
|
+
|
|
32
|
+
### `BKMVDATA.TXT`
|
|
33
|
+
|
|
34
|
+
- `A100` — Opening
|
|
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
|
|
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
|
+
## 📖 Usage
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { generateUniformFormatReport } from '@accounter/shaam-uniform-format-generator'
|
|
55
|
+
|
|
56
|
+
const reportInput = {
|
|
57
|
+
business: {
|
|
58
|
+
// Business metadata
|
|
59
|
+
},
|
|
60
|
+
documents: [
|
|
61
|
+
// Document records
|
|
62
|
+
],
|
|
63
|
+
journalEntries: [
|
|
64
|
+
// Journal entry records
|
|
65
|
+
],
|
|
66
|
+
accounts: [
|
|
67
|
+
// Account records
|
|
68
|
+
],
|
|
69
|
+
inventory: [
|
|
70
|
+
// Inventory records
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const result = generateUniformFormatReport(reportInput)
|
|
75
|
+
|
|
76
|
+
console.log(result.iniText) // INI.TXT content
|
|
77
|
+
console.log(result.dataText) // BKMVDATA.TXT content
|
|
78
|
+
console.log(result.summary) // Generation summary
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 🏗️ Development
|
|
82
|
+
|
|
83
|
+
This project uses:
|
|
84
|
+
|
|
85
|
+
- **TypeScript** in strict mode for type safety
|
|
86
|
+
- **Zod** for runtime validation
|
|
87
|
+
- **Vitest** for testing
|
|
88
|
+
- **Bob the Bundler** for building
|
|
89
|
+
|
|
90
|
+
### Commands
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Development
|
|
94
|
+
yarn dev
|
|
95
|
+
|
|
96
|
+
# Testing
|
|
97
|
+
yarn test
|
|
98
|
+
yarn test:watch
|
|
99
|
+
|
|
100
|
+
# Building
|
|
101
|
+
yarn build
|
|
102
|
+
|
|
103
|
+
# Linting
|
|
104
|
+
yarn lint
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 📋 Requirements
|
|
108
|
+
|
|
109
|
+
- Node.js ^20.0.0 || >= 22
|
|
110
|
+
- TypeScript support
|
|
111
|
+
|
|
112
|
+
## 📄 License
|
|
113
|
+
|
|
114
|
+
MIT
|
|
115
|
+
|
|
116
|
+
## 🤝 Contributing
|
|
117
|
+
|
|
118
|
+
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our
|
|
119
|
+
repository.
|
|
120
|
+
|
|
121
|
+
## 📚 Documentation
|
|
122
|
+
|
|
123
|
+
For detailed documentation about SHAAM format specifications, see the `documentation/` folder.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Main API for generating SHAAM uniform format reports
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateUniformFormatReport = generateUniformFormatReport;
|
|
7
|
+
const errors_js_1 = require("../validation/errors.js");
|
|
8
|
+
const validate_input_js_1 = require("../validation/validate-input.js");
|
|
9
|
+
/**
|
|
10
|
+
* Generates SHAAM uniform format report files (INI.TXT and BKMVDATA.TXT)
|
|
11
|
+
* from a high-level JSON input object.
|
|
12
|
+
*
|
|
13
|
+
* @param input - The report input data
|
|
14
|
+
* @param options - Generation options
|
|
15
|
+
* @returns Report output with generated file content
|
|
16
|
+
*/
|
|
17
|
+
function generateUniformFormatReport(input, options = {}) {
|
|
18
|
+
// Validate input data first
|
|
19
|
+
const validationMode = options.validationMode || 'fail-fast';
|
|
20
|
+
const validationErrors = (0, validate_input_js_1.validateInput)(input, validationMode);
|
|
21
|
+
if (validationErrors.length > 0) {
|
|
22
|
+
if (validationMode === 'fail-fast') {
|
|
23
|
+
// This should have already thrown, but just in case
|
|
24
|
+
throw new errors_js_1.ShaamFormatError('Validation failed', validationErrors);
|
|
25
|
+
}
|
|
26
|
+
// For collect-all mode, we still throw if there are errors
|
|
27
|
+
// The user can catch and inspect the errors if needed
|
|
28
|
+
throw new errors_js_1.ShaamFormatError('Input validation failed', validationErrors);
|
|
29
|
+
}
|
|
30
|
+
// TODO: Implement the actual generation logic
|
|
31
|
+
const iniText = 'A000placeholder\r\n'; // Placeholder
|
|
32
|
+
const dataText = 'A100placeholder\r\n'; // Placeholder
|
|
33
|
+
// Create virtual File objects
|
|
34
|
+
const iniFile = new File([iniText], `${options.fileNameBase || 'report'}.INI.TXT`, {
|
|
35
|
+
type: 'text/plain',
|
|
36
|
+
});
|
|
37
|
+
const dataFile = new File([dataText], `${options.fileNameBase || 'report'}.BKMVDATA.TXT`, {
|
|
38
|
+
type: 'text/plain',
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
iniText,
|
|
42
|
+
dataText,
|
|
43
|
+
iniFile,
|
|
44
|
+
dataFile,
|
|
45
|
+
summary: {
|
|
46
|
+
totalRecords: 2, // Placeholder
|
|
47
|
+
perType: {
|
|
48
|
+
A000: 1,
|
|
49
|
+
A100: 1,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* API for parsing SHAAM uniform format files
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseUniformFormatFiles = parseUniformFormatFiles;
|
|
7
|
+
/**
|
|
8
|
+
* Parses SHAAM uniform format files (INI.TXT and BKMVDATA.TXT)
|
|
9
|
+
* back into structured JSON objects.
|
|
10
|
+
*
|
|
11
|
+
* @param iniContent - Content of the INI.TXT file
|
|
12
|
+
* @param dataContent - Content of the BKMVDATA.TXT file
|
|
13
|
+
* @returns Parsed report input data
|
|
14
|
+
*/
|
|
15
|
+
function parseUniformFormatFiles(_iniContent, _dataContent) {
|
|
16
|
+
// TODO: Implement the actual parsing logic
|
|
17
|
+
return {
|
|
18
|
+
business: {
|
|
19
|
+
businessId: 'placeholder',
|
|
20
|
+
name: 'Placeholder Business',
|
|
21
|
+
taxId: '000000000',
|
|
22
|
+
reportingPeriod: {
|
|
23
|
+
startDate: '2024-01-01',
|
|
24
|
+
endDate: '2024-12-31',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
documents: [],
|
|
28
|
+
journalEntries: [],
|
|
29
|
+
accounts: [],
|
|
30
|
+
inventory: [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Format utilities for SHAAM uniform format files
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./padding.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./newline.js"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Line ending constants for SHAAM format files
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CRLF = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* CRLF line ending as required by SHAAM format specification
|
|
9
|
+
*/
|
|
10
|
+
exports.CRLF = '\r\n';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* String padding utilities for fixed-width formatting
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.padLeft = padLeft;
|
|
7
|
+
exports.padRight = padRight;
|
|
8
|
+
/**
|
|
9
|
+
* Pads a string on the left (right-aligns the content)
|
|
10
|
+
*
|
|
11
|
+
* @param value - The string to pad
|
|
12
|
+
* @param width - Target width
|
|
13
|
+
* @param fill - Character to use for padding (default: space)
|
|
14
|
+
* @returns Left-padded string
|
|
15
|
+
*/
|
|
16
|
+
function padLeft(value, width, fill = ' ') {
|
|
17
|
+
if (value.length >= width) {
|
|
18
|
+
return value.substring(0, width);
|
|
19
|
+
}
|
|
20
|
+
const padLength = width - value.length;
|
|
21
|
+
const padding = fill.repeat(padLength);
|
|
22
|
+
return padding + value;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Pads a string on the right (left-aligns the content)
|
|
26
|
+
*
|
|
27
|
+
* @param value - The string to pad
|
|
28
|
+
* @param width - Target width
|
|
29
|
+
* @param fill - Character to use for padding (default: space)
|
|
30
|
+
* @returns Right-padded string
|
|
31
|
+
*/
|
|
32
|
+
function padRight(value, width, fill = ' ') {
|
|
33
|
+
if (value.length >= width) {
|
|
34
|
+
return value.substring(0, width);
|
|
35
|
+
}
|
|
36
|
+
const padLength = width - value.length;
|
|
37
|
+
const padding = fill.repeat(padLength);
|
|
38
|
+
return value + padding;
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Fixed-width decoding utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.decodeFixedWidth = decodeFixedWidth;
|
|
7
|
+
/**
|
|
8
|
+
* Decodes a fixed-width string value
|
|
9
|
+
*
|
|
10
|
+
* @param line - The line to decode from
|
|
11
|
+
* @param start - Start position (0-based)
|
|
12
|
+
* @param length - Field length
|
|
13
|
+
* @returns Decoded and trimmed value
|
|
14
|
+
*/
|
|
15
|
+
function decodeFixedWidth(line, start, length) {
|
|
16
|
+
return line.substring(start, start + length).trim();
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Fixed-wiexport function formatField(
|
|
4
|
+
value: string,
|
|
5
|
+
width: number,
|
|
6
|
+
align: 'left' | 'right',
|
|
7
|
+
padChar = ' '
|
|
8
|
+
): string {
|
|
9
|
+
if (align === 'left') {
|
|
10
|
+
return padRight(value, width, padChar);
|
|
11
|
+
}
|
|
12
|
+
return padLeft(value, width, padChar);
|
|
13
|
+
} utilities
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.formatField = formatField;
|
|
17
|
+
exports.encodeFixedWidth = encodeFixedWidth;
|
|
18
|
+
const padding_js_1 = require("../../format/padding.js");
|
|
19
|
+
/**
|
|
20
|
+
* Formats a field value with specified width and alignment
|
|
21
|
+
*
|
|
22
|
+
* @param value - The value to format
|
|
23
|
+
* @param width - Target field width
|
|
24
|
+
* @param align - Alignment ('left' or 'right')
|
|
25
|
+
* @param padChar - Character to use for padding (default: space)
|
|
26
|
+
* @returns Formatted fixed-width string
|
|
27
|
+
*/
|
|
28
|
+
function formatField(value, width, align, padChar = ' ') {
|
|
29
|
+
if (align === 'left') {
|
|
30
|
+
return (0, padding_js_1.padRight)(value, width, padChar);
|
|
31
|
+
}
|
|
32
|
+
return (0, padding_js_1.padLeft)(value, width, padChar);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Encodes a value to fixed-width format with padding
|
|
36
|
+
*
|
|
37
|
+
* @param value - The value to encode
|
|
38
|
+
* @param width - Target width
|
|
39
|
+
* @param padChar - Padding character (default: space)
|
|
40
|
+
* @param align - Alignment ('left' or 'right')
|
|
41
|
+
* @returns Fixed-width encoded string
|
|
42
|
+
*/
|
|
43
|
+
function encodeFixedWidth(value, width, padChar = ' ', align = 'left') {
|
|
44
|
+
const str = String(value);
|
|
45
|
+
return formatField(str, width, align, padChar);
|
|
46
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Format encoding and decoding utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./encoder.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./decoder.js"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File generation utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./records/index.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./format/index.js"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Record type definitions and generators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./a000.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./a100.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./b100.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./b110.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./c100.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./d110.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./d120.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./m100.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./z900.js"), exports);
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @accounter/shaam-uniform-format-generator
|
|
4
|
+
*
|
|
5
|
+
* A fully typed TypeScript library for generating, parsing, and validating
|
|
6
|
+
* SHAAM uniform format tax reports (INI.TXT and BKMVDATA.TXT files).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.parseUniformFormatFiles = exports.generateUniformFormatReport = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
tslib_1.__exportStar(require("./types/index.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./generator/index.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./parser/index.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./validation/index.js"), exports);
|
|
15
|
+
// Main API
|
|
16
|
+
var generate_report_js_1 = require("./api/generate-report.js");
|
|
17
|
+
Object.defineProperty(exports, "generateUniformFormatReport", { enumerable: true, get: function () { return generate_report_js_1.generateUniformFormatReport; } });
|
|
18
|
+
var parse_files_js_1 = require("./api/parse-files.js");
|
|
19
|
+
Object.defineProperty(exports, "parseUniformFormatFiles", { enumerable: true, get: function () { return parse_files_js_1.parseUniformFormatFiles; } });
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* BKMVDATA.TXT file parsing utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseDataFile = parseDataFile;
|
|
7
|
+
/**
|
|
8
|
+
* Parses BKMVDATA.TXT file content
|
|
9
|
+
*
|
|
10
|
+
* @param content - Raw BKMVDATA.TXT file content
|
|
11
|
+
* @returns Parsed data structure
|
|
12
|
+
*/
|
|
13
|
+
function parseDataFile(_content) {
|
|
14
|
+
// TODO: Implement data file parsing logic
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File parsing utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./ini-parser.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./data-parser.js"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* INI.TXT file parsing utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseIniFile = parseIniFile;
|
|
7
|
+
/**
|
|
8
|
+
* Parses INI.TXT file content
|
|
9
|
+
*
|
|
10
|
+
* @param content - Raw INI.TXT file content
|
|
11
|
+
* @returns Parsed data structure
|
|
12
|
+
*/
|
|
13
|
+
function parseIniFile(_content) {
|
|
14
|
+
// TODO: Implement INI file parsing logic
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for SHAAM uniform format generator
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReportOutputSchema = exports.ReportInputSchema = exports.InventoryItemSchema = exports.AccountSchema = exports.JournalEntrySchema = exports.DocumentSchema = exports.BusinessMetadataSchema = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
// Business metadata schema
|
|
9
|
+
exports.BusinessMetadataSchema = zod_1.z.object({
|
|
10
|
+
businessId: zod_1.z.string().min(1, 'Business ID is required'),
|
|
11
|
+
name: zod_1.z.string().min(1, 'Business name is required'),
|
|
12
|
+
taxId: zod_1.z.string().min(1, 'Tax ID is required'),
|
|
13
|
+
reportingPeriod: zod_1.z.object({
|
|
14
|
+
startDate: zod_1.z.string().min(1, 'Start date is required'),
|
|
15
|
+
endDate: zod_1.z.string().min(1, 'End date is required'),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
// Document schema
|
|
19
|
+
exports.DocumentSchema = zod_1.z.object({
|
|
20
|
+
id: zod_1.z.string().min(1, 'Document ID is required'),
|
|
21
|
+
type: zod_1.z.string().min(1, 'Document type is required'),
|
|
22
|
+
date: zod_1.z.string().min(1, 'Document date is required'),
|
|
23
|
+
amount: zod_1.z.number(),
|
|
24
|
+
description: zod_1.z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
// Journal entry schema
|
|
27
|
+
exports.JournalEntrySchema = zod_1.z.object({
|
|
28
|
+
id: zod_1.z.string().min(1, 'Journal entry ID is required'),
|
|
29
|
+
date: zod_1.z.string().min(1, 'Journal entry date is required'),
|
|
30
|
+
amount: zod_1.z.number(),
|
|
31
|
+
accountId: zod_1.z.string().min(1, 'Account ID is required'),
|
|
32
|
+
description: zod_1.z.string().optional(),
|
|
33
|
+
});
|
|
34
|
+
// Account schema
|
|
35
|
+
exports.AccountSchema = zod_1.z.object({
|
|
36
|
+
id: zod_1.z.string().min(1, 'Account ID is required'),
|
|
37
|
+
name: zod_1.z.string().min(1, 'Account name is required'),
|
|
38
|
+
type: zod_1.z.string().min(1, 'Account type is required'),
|
|
39
|
+
balance: zod_1.z.number(),
|
|
40
|
+
});
|
|
41
|
+
// Inventory item schema
|
|
42
|
+
exports.InventoryItemSchema = zod_1.z.object({
|
|
43
|
+
id: zod_1.z.string().min(1, 'Inventory item ID is required'),
|
|
44
|
+
name: zod_1.z.string().min(1, 'Inventory item name is required'),
|
|
45
|
+
quantity: zod_1.z.number(),
|
|
46
|
+
unitPrice: zod_1.z.number(),
|
|
47
|
+
});
|
|
48
|
+
// Main input schema
|
|
49
|
+
exports.ReportInputSchema = zod_1.z.object({
|
|
50
|
+
business: exports.BusinessMetadataSchema,
|
|
51
|
+
documents: zod_1.z.array(exports.DocumentSchema),
|
|
52
|
+
journalEntries: zod_1.z.array(exports.JournalEntrySchema),
|
|
53
|
+
accounts: zod_1.z.array(exports.AccountSchema),
|
|
54
|
+
inventory: zod_1.z.array(exports.InventoryItemSchema),
|
|
55
|
+
});
|
|
56
|
+
// Output schema
|
|
57
|
+
exports.ReportOutputSchema = zod_1.z.object({
|
|
58
|
+
iniText: zod_1.z.string(),
|
|
59
|
+
dataText: zod_1.z.string(),
|
|
60
|
+
iniFile: zod_1.z.instanceof(File),
|
|
61
|
+
dataFile: zod_1.z.instanceof(File),
|
|
62
|
+
summary: zod_1.z.object({
|
|
63
|
+
totalRecords: zod_1.z.number(),
|
|
64
|
+
perType: zod_1.z.record(zod_1.z.string(), zod_1.z.number()),
|
|
65
|
+
errors: zod_1.z
|
|
66
|
+
.array(zod_1.z.object({
|
|
67
|
+
recordType: zod_1.z.string(),
|
|
68
|
+
recordIndex: zod_1.z.number(),
|
|
69
|
+
field: zod_1.z.string(),
|
|
70
|
+
message: zod_1.z.string(),
|
|
71
|
+
}))
|
|
72
|
+
.optional(),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Error handling utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ShaamFormatError = void 0;
|
|
7
|
+
exports.createValidationError = createValidationError;
|
|
8
|
+
/**
|
|
9
|
+
* Custom error class for SHAAM format generation errors
|
|
10
|
+
*/
|
|
11
|
+
class ShaamFormatError extends Error {
|
|
12
|
+
errors;
|
|
13
|
+
constructor(message, errors = []) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.errors = errors;
|
|
16
|
+
this.name = 'ShaamFormatError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ShaamFormatError = ShaamFormatError;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a validation error object
|
|
22
|
+
*/
|
|
23
|
+
function createValidationError(recordType, recordIndex, field, message) {
|
|
24
|
+
return {
|
|
25
|
+
recordType,
|
|
26
|
+
recordIndex,
|
|
27
|
+
field,
|
|
28
|
+
message,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Validation utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./validate-input.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./errors.js"), exports);
|