@accounter/shaam-uniform-format-generator 0.2.3-alpha-20251211104015-b8754b56e4fb5cb5ab09ff1ee8b5ea7f8fa59f2f → 0.2.3-alpha-20251211105553-850821f760a4152f9e24e7fca4d23874a887bbe3
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 +185 -185
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,8 +62,8 @@ Generates SHAAM uniform format report files from a high-level JSON input object.
|
|
|
62
62
|
```typescript
|
|
63
63
|
import {
|
|
64
64
|
generateUniformFormatReport,
|
|
65
|
-
type ReportInput
|
|
66
|
-
} from '@accounter/shaam-uniform-format-generator'
|
|
65
|
+
type ReportInput
|
|
66
|
+
} from '@accounter/shaam-uniform-format-generator'
|
|
67
67
|
|
|
68
68
|
const reportInput: ReportInput = {
|
|
69
69
|
business: {
|
|
@@ -72,8 +72,8 @@ const reportInput: ReportInput = {
|
|
|
72
72
|
taxId: '123456789',
|
|
73
73
|
reportingPeriod: {
|
|
74
74
|
startDate: '2023-01-01',
|
|
75
|
-
endDate: '2023-12-31'
|
|
76
|
-
}
|
|
75
|
+
endDate: '2023-12-31'
|
|
76
|
+
}
|
|
77
77
|
},
|
|
78
78
|
documents: [
|
|
79
79
|
{
|
|
@@ -81,8 +81,8 @@ const reportInput: ReportInput = {
|
|
|
81
81
|
type: '320', // Invoice
|
|
82
82
|
date: '2023-06-15',
|
|
83
83
|
amount: 1000.0,
|
|
84
|
-
description: 'Service invoice'
|
|
85
|
-
}
|
|
84
|
+
description: 'Service invoice'
|
|
85
|
+
}
|
|
86
86
|
],
|
|
87
87
|
journalEntries: [
|
|
88
88
|
{
|
|
@@ -90,35 +90,35 @@ const reportInput: ReportInput = {
|
|
|
90
90
|
date: '2023-06-15',
|
|
91
91
|
amount: 1000.0,
|
|
92
92
|
accountId: '1100',
|
|
93
|
-
description: 'Revenue entry'
|
|
94
|
-
}
|
|
93
|
+
description: 'Revenue entry'
|
|
94
|
+
}
|
|
95
95
|
],
|
|
96
96
|
accounts: [
|
|
97
97
|
{
|
|
98
98
|
id: '1100',
|
|
99
99
|
name: 'Revenue Account',
|
|
100
100
|
type: '4', // Revenue
|
|
101
|
-
balance: 1000.0
|
|
102
|
-
}
|
|
101
|
+
balance: 1000.0
|
|
102
|
+
}
|
|
103
103
|
],
|
|
104
104
|
inventory: [
|
|
105
105
|
{
|
|
106
106
|
id: 'ITEM001',
|
|
107
107
|
name: 'Service Item',
|
|
108
108
|
quantity: 1,
|
|
109
|
-
unitPrice: 1000.0
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
}
|
|
109
|
+
unitPrice: 1000.0
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
113
|
|
|
114
114
|
const result = generateUniformFormatReport(reportInput, {
|
|
115
115
|
validationMode: 'fail-fast', // or 'collect-all'
|
|
116
|
-
fileNameBase: 'my-report'
|
|
117
|
-
})
|
|
116
|
+
fileNameBase: 'my-report'
|
|
117
|
+
})
|
|
118
118
|
|
|
119
|
-
console.log(result.iniText)
|
|
120
|
-
console.log(result.dataText)
|
|
121
|
-
console.log(result.summary)
|
|
119
|
+
console.log(result.iniText) // INI.TXT content
|
|
120
|
+
console.log(result.dataText) // BKMVDATA.TXT content
|
|
121
|
+
console.log(result.summary) // Generation summary
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
#### `parseUniformFormatFiles(iniContent, dataContent, options?)`
|
|
@@ -126,19 +126,19 @@ console.log(result.summary); // Generation summary
|
|
|
126
126
|
Parses SHAAM uniform format files back into structured JSON with comprehensive validation.
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
|
-
import { parseUniformFormatFiles } from '@accounter/shaam-uniform-format-generator'
|
|
129
|
+
import { parseUniformFormatFiles } from '@accounter/shaam-uniform-format-generator'
|
|
130
130
|
|
|
131
131
|
const parseResult = parseUniformFormatFiles(iniFileContent, dataFileContent, {
|
|
132
132
|
validationMode: 'lenient', // 'strict' | 'lenient' | 'none'
|
|
133
133
|
skipUnknownRecords: true,
|
|
134
|
-
allowPartialData: true
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
console.log(parseResult.data.business)
|
|
138
|
-
console.log(parseResult.data.documents)
|
|
139
|
-
console.log(parseResult.summary.totalRecords)
|
|
140
|
-
console.log(parseResult.summary.errors)
|
|
141
|
-
console.log(parseResult.summary.crossValidationPassed)
|
|
134
|
+
allowPartialData: true
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
console.log(parseResult.data.business) // Parsed business metadata
|
|
138
|
+
console.log(parseResult.data.documents) // Parsed documents
|
|
139
|
+
console.log(parseResult.summary.totalRecords) // Parse summary
|
|
140
|
+
console.log(parseResult.summary.errors) // Validation errors
|
|
141
|
+
console.log(parseResult.summary.crossValidationPassed) // Cross-validation result
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
### Types and Interfaces
|
|
@@ -147,11 +147,11 @@ console.log(parseResult.summary.crossValidationPassed); // Cross-validation resu
|
|
|
147
147
|
|
|
148
148
|
```typescript
|
|
149
149
|
interface ReportInput {
|
|
150
|
-
business: BusinessMetadata
|
|
151
|
-
documents: Document[]
|
|
152
|
-
journalEntries: JournalEntry[]
|
|
153
|
-
accounts: Account[]
|
|
154
|
-
inventory: InventoryItem[]
|
|
150
|
+
business: BusinessMetadata
|
|
151
|
+
documents: Document[]
|
|
152
|
+
journalEntries: JournalEntry[]
|
|
153
|
+
accounts: Account[]
|
|
154
|
+
inventory: InventoryItem[]
|
|
155
155
|
}
|
|
156
156
|
```
|
|
157
157
|
|
|
@@ -159,13 +159,13 @@ interface ReportInput {
|
|
|
159
159
|
|
|
160
160
|
```typescript
|
|
161
161
|
interface BusinessMetadata {
|
|
162
|
-
businessId: string
|
|
163
|
-
name: string
|
|
164
|
-
taxId: string
|
|
162
|
+
businessId: string
|
|
163
|
+
name: string
|
|
164
|
+
taxId: string
|
|
165
165
|
reportingPeriod: {
|
|
166
|
-
startDate: string
|
|
167
|
-
endDate: string
|
|
168
|
-
}
|
|
166
|
+
startDate: string // YYYY-MM-DD format
|
|
167
|
+
endDate: string // YYYY-MM-DD format
|
|
168
|
+
}
|
|
169
169
|
}
|
|
170
170
|
```
|
|
171
171
|
|
|
@@ -173,11 +173,11 @@ interface BusinessMetadata {
|
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
175
|
interface Document {
|
|
176
|
-
id: string
|
|
177
|
-
type: DocumentType
|
|
178
|
-
date: string
|
|
179
|
-
amount: number
|
|
180
|
-
description?: string
|
|
176
|
+
id: string
|
|
177
|
+
type: DocumentType // e.g., "320" for invoice, "330" for credit note
|
|
178
|
+
date: string // YYYY-MM-DD format
|
|
179
|
+
amount: number
|
|
180
|
+
description?: string
|
|
181
181
|
}
|
|
182
182
|
```
|
|
183
183
|
|
|
@@ -185,32 +185,32 @@ interface Document {
|
|
|
185
185
|
|
|
186
186
|
```typescript
|
|
187
187
|
interface JournalEntry {
|
|
188
|
-
id: string
|
|
189
|
-
date: string
|
|
190
|
-
amount: number
|
|
191
|
-
accountId: string
|
|
192
|
-
description?: string
|
|
193
|
-
transactionNumber?: number
|
|
194
|
-
transactionLineNumber?: number
|
|
195
|
-
batchNumber?: number
|
|
196
|
-
transactionType?: string
|
|
197
|
-
referenceDocument?: string
|
|
198
|
-
referenceDocumentType?: DocumentType
|
|
199
|
-
referenceDocument2?: string
|
|
200
|
-
referenceDocumentType2?: DocumentType
|
|
201
|
-
valueDate?: string
|
|
202
|
-
counterAccountKey?: string
|
|
203
|
-
debitCreditIndicator?: '1' | '2'
|
|
204
|
-
currencyCode?: CurrencyCode
|
|
205
|
-
transactionAmount?: number
|
|
206
|
-
foreignCurrencyAmount?: number
|
|
207
|
-
quantityField?: number
|
|
208
|
-
matchingField1?: string
|
|
209
|
-
matchingField2?: string
|
|
210
|
-
branchId?: string
|
|
211
|
-
entryDate?: string
|
|
212
|
-
operatorUsername?: string
|
|
213
|
-
reserved?: string
|
|
188
|
+
id: string
|
|
189
|
+
date: string // YYYY-MM-DD format
|
|
190
|
+
amount: number
|
|
191
|
+
accountId: string
|
|
192
|
+
description?: string
|
|
193
|
+
transactionNumber?: number
|
|
194
|
+
transactionLineNumber?: number
|
|
195
|
+
batchNumber?: number
|
|
196
|
+
transactionType?: string
|
|
197
|
+
referenceDocument?: string
|
|
198
|
+
referenceDocumentType?: DocumentType
|
|
199
|
+
referenceDocument2?: string
|
|
200
|
+
referenceDocumentType2?: DocumentType
|
|
201
|
+
valueDate?: string
|
|
202
|
+
counterAccountKey?: string
|
|
203
|
+
debitCreditIndicator?: '1' | '2' // 1=Debit, 2=Credit
|
|
204
|
+
currencyCode?: CurrencyCode
|
|
205
|
+
transactionAmount?: number // Preserve original B100 transaction amount
|
|
206
|
+
foreignCurrencyAmount?: number
|
|
207
|
+
quantityField?: number
|
|
208
|
+
matchingField1?: string
|
|
209
|
+
matchingField2?: string
|
|
210
|
+
branchId?: string
|
|
211
|
+
entryDate?: string
|
|
212
|
+
operatorUsername?: string
|
|
213
|
+
reserved?: string
|
|
214
214
|
}
|
|
215
215
|
```
|
|
216
216
|
|
|
@@ -218,29 +218,29 @@ interface JournalEntry {
|
|
|
218
218
|
|
|
219
219
|
```typescript
|
|
220
220
|
interface Account {
|
|
221
|
-
id: string
|
|
222
|
-
name?: string
|
|
221
|
+
id: string
|
|
222
|
+
name?: string // Optional for round-trip compatibility
|
|
223
223
|
sortCode: {
|
|
224
|
-
key: string
|
|
225
|
-
name?: string
|
|
226
|
-
}
|
|
224
|
+
key: string // Required - Account sort code key
|
|
225
|
+
name?: string // Optional - Sort code description
|
|
226
|
+
}
|
|
227
227
|
address?: {
|
|
228
|
-
street?: string
|
|
229
|
-
houseNumber?: string
|
|
230
|
-
city?: string
|
|
231
|
-
zip?: string
|
|
232
|
-
country?: string
|
|
233
|
-
}
|
|
234
|
-
countryCode?: string
|
|
235
|
-
parentAccountKey?: string
|
|
236
|
-
vatId?: string
|
|
237
|
-
accountOpeningBalance: number
|
|
238
|
-
totalDebits?: number
|
|
239
|
-
totalCredits?: number
|
|
240
|
-
accountingClassificationCode?: string
|
|
241
|
-
branchId?: string
|
|
242
|
-
openingBalanceForeignCurrency?: number
|
|
243
|
-
foreignCurrencyCode?: string
|
|
228
|
+
street?: string
|
|
229
|
+
houseNumber?: string
|
|
230
|
+
city?: string
|
|
231
|
+
zip?: string
|
|
232
|
+
country?: string
|
|
233
|
+
}
|
|
234
|
+
countryCode?: string // ISO country code
|
|
235
|
+
parentAccountKey?: string // Parent account identifier
|
|
236
|
+
vatId?: string // Supplier/Customer VAT ID
|
|
237
|
+
accountOpeningBalance: number // Required - Opening balance amount
|
|
238
|
+
totalDebits?: number // Total debit transactions
|
|
239
|
+
totalCredits?: number // Total credit transactions
|
|
240
|
+
accountingClassificationCode?: string // Classification code (max 4 digits)
|
|
241
|
+
branchId?: string // Branch identifier
|
|
242
|
+
openingBalanceForeignCurrency?: number // Opening balance in foreign currency
|
|
243
|
+
foreignCurrencyCode?: string // Foreign currency code (e.g., "USD", "EUR")
|
|
244
244
|
}
|
|
245
245
|
```
|
|
246
246
|
|
|
@@ -248,10 +248,10 @@ interface Account {
|
|
|
248
248
|
|
|
249
249
|
```typescript
|
|
250
250
|
interface InventoryItem {
|
|
251
|
-
id: string
|
|
252
|
-
name: string
|
|
253
|
-
quantity: number
|
|
254
|
-
unitPrice: number
|
|
251
|
+
id: string
|
|
252
|
+
name: string
|
|
253
|
+
quantity: number
|
|
254
|
+
unitPrice: number
|
|
255
255
|
}
|
|
256
256
|
```
|
|
257
257
|
|
|
@@ -259,11 +259,11 @@ interface InventoryItem {
|
|
|
259
259
|
|
|
260
260
|
```typescript
|
|
261
261
|
interface ValidationError {
|
|
262
|
-
recordType: string
|
|
263
|
-
recordIndex: number
|
|
264
|
-
field: string
|
|
265
|
-
message: string
|
|
266
|
-
severity?: 'error' | 'warning'
|
|
262
|
+
recordType: string
|
|
263
|
+
recordIndex: number
|
|
264
|
+
field: string
|
|
265
|
+
message: string
|
|
266
|
+
severity?: 'error' | 'warning' // Only in parse results
|
|
267
267
|
}
|
|
268
268
|
```
|
|
269
269
|
|
|
@@ -289,13 +289,13 @@ interface ReportOutput {
|
|
|
289
289
|
|
|
290
290
|
```typescript
|
|
291
291
|
interface ParseResult {
|
|
292
|
-
data: ReportInput
|
|
292
|
+
data: ReportInput // Parsed structured data
|
|
293
293
|
summary: {
|
|
294
|
-
totalRecords: number
|
|
295
|
-
perType: Record<string, number
|
|
296
|
-
errors: ValidationError[]
|
|
297
|
-
crossValidationPassed: boolean
|
|
298
|
-
}
|
|
294
|
+
totalRecords: number
|
|
295
|
+
perType: Record<string, number>
|
|
296
|
+
errors: ValidationError[]
|
|
297
|
+
crossValidationPassed: boolean
|
|
298
|
+
}
|
|
299
299
|
}
|
|
300
300
|
```
|
|
301
301
|
|
|
@@ -305,8 +305,8 @@ interface ParseResult {
|
|
|
305
305
|
|
|
306
306
|
```typescript
|
|
307
307
|
interface GenerationOptions {
|
|
308
|
-
validationMode?: 'fail-fast' | 'collect-all'
|
|
309
|
-
fileNameBase?: string
|
|
308
|
+
validationMode?: 'fail-fast' | 'collect-all' // Default: 'fail-fast'
|
|
309
|
+
fileNameBase?: string // Default: 'report'
|
|
310
310
|
}
|
|
311
311
|
```
|
|
312
312
|
|
|
@@ -326,29 +326,29 @@ import {
|
|
|
326
326
|
DebitCreditIndicatorEnum,
|
|
327
327
|
DocumentTypeEnum,
|
|
328
328
|
PaymentMethodEnum,
|
|
329
|
-
RecordTypeEnum
|
|
329
|
+
RecordTypeEnum
|
|
330
330
|
// ... and many more
|
|
331
|
-
} from '@accounter/shaam-uniform-format-generator'
|
|
331
|
+
} from '@accounter/shaam-uniform-format-generator'
|
|
332
332
|
|
|
333
333
|
// Document types
|
|
334
|
-
const invoiceType = DocumentTypeEnum.enum['320']
|
|
335
|
-
const creditNoteType = DocumentTypeEnum.enum['330']
|
|
334
|
+
const invoiceType = DocumentTypeEnum.enum['320'] // Invoice
|
|
335
|
+
const creditNoteType = DocumentTypeEnum.enum['330'] // Credit Tax Invoice
|
|
336
336
|
|
|
337
337
|
// Currency codes
|
|
338
|
-
const ils = CurrencyCodeEnum.enum.ILS
|
|
339
|
-
const usd = CurrencyCodeEnum.enum.USD
|
|
338
|
+
const ils = CurrencyCodeEnum.enum.ILS // Israeli Shekel
|
|
339
|
+
const usd = CurrencyCodeEnum.enum.USD // US Dollar
|
|
340
340
|
|
|
341
341
|
// Payment methods
|
|
342
|
-
const cash = PaymentMethodEnum.enum['1']
|
|
343
|
-
const check = PaymentMethodEnum.enum['2']
|
|
342
|
+
const cash = PaymentMethodEnum.enum['1'] // Cash
|
|
343
|
+
const check = PaymentMethodEnum.enum['2'] // Check
|
|
344
344
|
|
|
345
345
|
// Debit/Credit indicators
|
|
346
|
-
const debit = DebitCreditIndicatorEnum.enum['1']
|
|
347
|
-
const credit = DebitCreditIndicatorEnum.enum['2']
|
|
346
|
+
const debit = DebitCreditIndicatorEnum.enum['1'] // Debit
|
|
347
|
+
const credit = DebitCreditIndicatorEnum.enum['2'] // Credit
|
|
348
348
|
|
|
349
349
|
// Record types
|
|
350
|
-
const b110 = RecordTypeEnum.enum.B110
|
|
351
|
-
const c100 = RecordTypeEnum.enum.C100
|
|
350
|
+
const b110 = RecordTypeEnum.enum.B110 // Account record
|
|
351
|
+
const c100 = RecordTypeEnum.enum.C100 // Document header record
|
|
352
352
|
```
|
|
353
353
|
|
|
354
354
|
## 🎯 Complete Example
|
|
@@ -357,8 +357,8 @@ const c100 = RecordTypeEnum.enum.C100; // Document header record
|
|
|
357
357
|
import {
|
|
358
358
|
generateUniformFormatReport,
|
|
359
359
|
parseUniformFormatFiles,
|
|
360
|
-
type ReportInput
|
|
361
|
-
} from '@accounter/shaam-uniform-format-generator'
|
|
360
|
+
type ReportInput
|
|
361
|
+
} from '@accounter/shaam-uniform-format-generator'
|
|
362
362
|
|
|
363
363
|
// 1. Prepare your data
|
|
364
364
|
const reportData: ReportInput = {
|
|
@@ -368,8 +368,8 @@ const reportData: ReportInput = {
|
|
|
368
368
|
taxId: '123456789',
|
|
369
369
|
reportingPeriod: {
|
|
370
370
|
startDate: '2023-01-01',
|
|
371
|
-
endDate: '2023-12-31'
|
|
372
|
-
}
|
|
371
|
+
endDate: '2023-12-31'
|
|
372
|
+
}
|
|
373
373
|
},
|
|
374
374
|
documents: [
|
|
375
375
|
{
|
|
@@ -377,15 +377,15 @@ const reportData: ReportInput = {
|
|
|
377
377
|
type: '320', // Invoice
|
|
378
378
|
date: '2023-03-15',
|
|
379
379
|
amount: 2340.0,
|
|
380
|
-
description: 'Consulting services'
|
|
380
|
+
description: 'Consulting services'
|
|
381
381
|
},
|
|
382
382
|
{
|
|
383
383
|
id: 'CN-2023-001',
|
|
384
384
|
type: '330', // Credit note
|
|
385
385
|
date: '2023-04-10',
|
|
386
386
|
amount: -340.0,
|
|
387
|
-
description: 'Service adjustment'
|
|
388
|
-
}
|
|
387
|
+
description: 'Service adjustment'
|
|
388
|
+
}
|
|
389
389
|
],
|
|
390
390
|
journalEntries: [
|
|
391
391
|
{
|
|
@@ -396,7 +396,7 @@ const reportData: ReportInput = {
|
|
|
396
396
|
description: 'Consulting revenue',
|
|
397
397
|
batchNumber: 'BATCH-Q1-2023',
|
|
398
398
|
transactionType: 'SALE',
|
|
399
|
-
referenceDocument: 'INV-2023-001'
|
|
399
|
+
referenceDocument: 'INV-2023-001'
|
|
400
400
|
},
|
|
401
401
|
{
|
|
402
402
|
id: 'JE-2023-002',
|
|
@@ -405,8 +405,8 @@ const reportData: ReportInput = {
|
|
|
405
405
|
accountId: '4000',
|
|
406
406
|
description: 'Revenue adjustment',
|
|
407
407
|
currencyCode: 'USD',
|
|
408
|
-
foreignCurrencyAmount: -290.0
|
|
409
|
-
}
|
|
408
|
+
foreignCurrencyAmount: -290.0
|
|
409
|
+
}
|
|
410
410
|
],
|
|
411
411
|
accounts: [
|
|
412
412
|
{
|
|
@@ -414,54 +414,54 @@ const reportData: ReportInput = {
|
|
|
414
414
|
name: 'Consulting Revenue',
|
|
415
415
|
sortCode: {
|
|
416
416
|
key: 'Revenue',
|
|
417
|
-
name: 'Revenue Accounts'
|
|
417
|
+
name: 'Revenue Accounts'
|
|
418
418
|
},
|
|
419
419
|
accountOpeningBalance: 0.0,
|
|
420
420
|
totalDebits: 500.0,
|
|
421
421
|
totalCredits: 2500.0,
|
|
422
|
-
accountingClassificationCode: '0001'
|
|
422
|
+
accountingClassificationCode: '0001'
|
|
423
423
|
},
|
|
424
424
|
{
|
|
425
425
|
id: '1200',
|
|
426
426
|
name: 'Accounts Receivable',
|
|
427
427
|
sortCode: {
|
|
428
428
|
key: 'Asset',
|
|
429
|
-
name: 'Asset Accounts'
|
|
429
|
+
name: 'Asset Accounts'
|
|
430
430
|
},
|
|
431
431
|
accountOpeningBalance: 1500.0,
|
|
432
432
|
countryCode: 'IL',
|
|
433
433
|
branchId: 'MAIN',
|
|
434
434
|
foreignCurrencyCode: 'USD',
|
|
435
|
-
openingBalanceForeignCurrency: 1250.0
|
|
436
|
-
}
|
|
435
|
+
openingBalanceForeignCurrency: 1250.0
|
|
436
|
+
}
|
|
437
437
|
],
|
|
438
438
|
inventory: [
|
|
439
439
|
{
|
|
440
440
|
id: 'SERV-001',
|
|
441
441
|
name: 'Consulting Hour',
|
|
442
442
|
quantity: 20,
|
|
443
|
-
unitPrice: 117.0
|
|
444
|
-
}
|
|
445
|
-
]
|
|
446
|
-
}
|
|
443
|
+
unitPrice: 117.0
|
|
444
|
+
}
|
|
445
|
+
]
|
|
446
|
+
}
|
|
447
447
|
|
|
448
448
|
// 2. Generate the files
|
|
449
449
|
try {
|
|
450
450
|
const result = generateUniformFormatReport(reportData, {
|
|
451
451
|
validationMode: 'fail-fast',
|
|
452
|
-
fileNameBase: 'quarterly-report-2023-q1'
|
|
453
|
-
})
|
|
452
|
+
fileNameBase: 'quarterly-report-2023-q1'
|
|
453
|
+
})
|
|
454
454
|
|
|
455
455
|
// 3. Access the generated content
|
|
456
|
-
console.log('Generated INI.TXT:')
|
|
457
|
-
console.log(result.iniText)
|
|
456
|
+
console.log('Generated INI.TXT:')
|
|
457
|
+
console.log(result.iniText)
|
|
458
458
|
|
|
459
|
-
console.log('\nGenerated BKMVDATA.TXT:')
|
|
460
|
-
console.log(result.dataText)
|
|
459
|
+
console.log('\nGenerated BKMVDATA.TXT:')
|
|
460
|
+
console.log(result.dataText)
|
|
461
461
|
|
|
462
|
-
console.log('\nSummary:')
|
|
463
|
-
console.log(`Total records: ${result.summary.totalRecords}`)
|
|
464
|
-
console.log('Records per type:', result.summary.perType)
|
|
462
|
+
console.log('\nSummary:')
|
|
463
|
+
console.log(`Total records: ${result.summary.totalRecords}`)
|
|
464
|
+
console.log('Records per type:', result.summary.perType)
|
|
465
465
|
|
|
466
466
|
// 4. Save files (example using Node.js fs)
|
|
467
467
|
// import { writeFileSync } from 'fs'
|
|
@@ -469,12 +469,12 @@ try {
|
|
|
469
469
|
// writeFileSync('report.BKMVDATA.TXT', result.dataText, 'utf8')
|
|
470
470
|
|
|
471
471
|
// 5. Parse files back (round-trip test)
|
|
472
|
-
const parsedData = parseUniformFormatFiles(result.iniText, result.dataText)
|
|
473
|
-
console.log('\nParsed business data:', parsedData.business)
|
|
472
|
+
const parsedData = parseUniformFormatFiles(result.iniText, result.dataText)
|
|
473
|
+
console.log('\nParsed business data:', parsedData.business)
|
|
474
474
|
} catch (error) {
|
|
475
|
-
console.error('Generation failed:', error.message)
|
|
475
|
+
console.error('Generation failed:', error.message)
|
|
476
476
|
if (error.errors) {
|
|
477
|
-
console.error('Validation errors:', error.errors)
|
|
477
|
+
console.error('Validation errors:', error.errors)
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
```
|
|
@@ -484,49 +484,49 @@ try {
|
|
|
484
484
|
### Custom Validation
|
|
485
485
|
|
|
486
486
|
```typescript
|
|
487
|
-
import { ReportInputSchema } from '@accounter/shaam-uniform-format-generator'
|
|
487
|
+
import { ReportInputSchema } from '@accounter/shaam-uniform-format-generator'
|
|
488
488
|
|
|
489
489
|
// Validate data before generation
|
|
490
|
-
const validationResult = ReportInputSchema.safeParse(yourData)
|
|
490
|
+
const validationResult = ReportInputSchema.safeParse(yourData)
|
|
491
491
|
if (!validationResult.success) {
|
|
492
|
-
console.error('Validation errors:', validationResult.error.issues)
|
|
492
|
+
console.error('Validation errors:', validationResult.error.issues)
|
|
493
493
|
}
|
|
494
494
|
```
|
|
495
495
|
|
|
496
496
|
### Parse with Different Validation Modes
|
|
497
497
|
|
|
498
498
|
```typescript
|
|
499
|
-
import { parseUniformFormatFiles } from '@accounter/shaam-uniform-format-generator'
|
|
499
|
+
import { parseUniformFormatFiles } from '@accounter/shaam-uniform-format-generator'
|
|
500
500
|
|
|
501
501
|
// Strict validation - throws on any error
|
|
502
502
|
try {
|
|
503
503
|
const strictResult = parseUniformFormatFiles(iniContent, dataContent, {
|
|
504
504
|
validationMode: 'strict',
|
|
505
|
-
allowPartialData: false
|
|
506
|
-
})
|
|
507
|
-
console.log('Strict parsing succeeded:', strictResult.data)
|
|
505
|
+
allowPartialData: false
|
|
506
|
+
})
|
|
507
|
+
console.log('Strict parsing succeeded:', strictResult.data)
|
|
508
508
|
} catch (error) {
|
|
509
|
-
console.error('Strict parsing failed:', error.message)
|
|
509
|
+
console.error('Strict parsing failed:', error.message)
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
// Lenient validation - reports issues but continues
|
|
513
513
|
const lenientResult = parseUniformFormatFiles(iniContent, dataContent, {
|
|
514
|
-
validationMode: 'lenient'
|
|
515
|
-
})
|
|
516
|
-
console.log('Parsed data:', lenientResult.data)
|
|
517
|
-
console.log('Validation issues:', lenientResult.summary.errors)
|
|
514
|
+
validationMode: 'lenient'
|
|
515
|
+
})
|
|
516
|
+
console.log('Parsed data:', lenientResult.data)
|
|
517
|
+
console.log('Validation issues:', lenientResult.summary.errors)
|
|
518
518
|
|
|
519
519
|
// No validation - fastest parsing
|
|
520
520
|
const fastResult = parseUniformFormatFiles(iniContent, dataContent, {
|
|
521
|
-
validationMode: 'none'
|
|
522
|
-
})
|
|
523
|
-
console.log('Fast parsing result:', fastResult.data)
|
|
521
|
+
validationMode: 'none'
|
|
522
|
+
})
|
|
523
|
+
console.log('Fast parsing result:', fastResult.data)
|
|
524
524
|
```
|
|
525
525
|
|
|
526
526
|
### Working with Individual Records
|
|
527
527
|
|
|
528
528
|
```typescript
|
|
529
|
-
import { encodeC100, parseC100, type C100 } from '@accounter/shaam-uniform-format-generator'
|
|
529
|
+
import { encodeC100, parseC100, type C100 } from '@accounter/shaam-uniform-format-generator'
|
|
530
530
|
|
|
531
531
|
// Encode a single document record
|
|
532
532
|
const documentRecord: C100 = {
|
|
@@ -565,15 +565,15 @@ const documentRecord: C100 = {
|
|
|
565
565
|
cancelledAttribute3: '',
|
|
566
566
|
actionExecutor: '',
|
|
567
567
|
lineConnectingField: '',
|
|
568
|
-
reserved: ''
|
|
569
|
-
}
|
|
568
|
+
reserved: ''
|
|
569
|
+
}
|
|
570
570
|
|
|
571
|
-
const encodedLine = encodeC100(documentRecord)
|
|
572
|
-
console.log(encodedLine)
|
|
571
|
+
const encodedLine = encodeC100(documentRecord)
|
|
572
|
+
console.log(encodedLine) // Fixed-width formatted line
|
|
573
573
|
|
|
574
574
|
// Parse it back
|
|
575
|
-
const parsedRecord = parseC100(encodedLine)
|
|
576
|
-
console.log(parsedRecord)
|
|
575
|
+
const parsedRecord = parseC100(encodedLine)
|
|
576
|
+
console.log(parsedRecord) // Structured object
|
|
577
577
|
```
|
|
578
578
|
|
|
579
579
|
## 🏗️ Development
|
|
@@ -613,34 +613,34 @@ yarn lint
|
|
|
613
613
|
The library provides detailed error information:
|
|
614
614
|
|
|
615
615
|
```typescript
|
|
616
|
-
import { ShaamFormatError } from '@accounter/shaam-uniform-format-generator'
|
|
616
|
+
import { ShaamFormatError } from '@accounter/shaam-uniform-format-generator'
|
|
617
617
|
|
|
618
618
|
try {
|
|
619
|
-
const result = generateUniformFormatReport(invalidData)
|
|
619
|
+
const result = generateUniformFormatReport(invalidData)
|
|
620
620
|
} catch (error) {
|
|
621
621
|
if (error instanceof ShaamFormatError) {
|
|
622
|
-
console.error('SHAAM format error:', error.message)
|
|
623
|
-
console.error('Validation errors:', error.errors)
|
|
622
|
+
console.error('SHAAM format error:', error.message)
|
|
623
|
+
console.error('Validation errors:', error.errors)
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
|
|
627
627
|
// Parse errors include context and severity
|
|
628
628
|
try {
|
|
629
629
|
const parseResult = parseUniformFormatFiles(iniContent, dataContent, {
|
|
630
|
-
validationMode: 'strict'
|
|
631
|
-
})
|
|
630
|
+
validationMode: 'strict'
|
|
631
|
+
})
|
|
632
632
|
} catch (error) {
|
|
633
|
-
console.error('Parse failed:', error.message)
|
|
633
|
+
console.error('Parse failed:', error.message)
|
|
634
634
|
}
|
|
635
635
|
|
|
636
636
|
// Access detailed validation information
|
|
637
637
|
const parseResult = parseUniformFormatFiles(iniContent, dataContent, {
|
|
638
|
-
validationMode: 'lenient'
|
|
639
|
-
})
|
|
638
|
+
validationMode: 'lenient'
|
|
639
|
+
})
|
|
640
640
|
|
|
641
641
|
for (const error of parseResult.summary.errors) {
|
|
642
|
-
console.log(`${error.severity}: ${error.message}`)
|
|
643
|
-
console.log(`Record: ${error.recordType}[${error.recordIndex}], Field: ${error.field}`)
|
|
642
|
+
console.log(`${error.severity}: ${error.message}`)
|
|
643
|
+
console.log(`Record: ${error.recordType}[${error.recordIndex}], Field: ${error.field}`)
|
|
644
644
|
}
|
|
645
645
|
```
|
|
646
646
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accounter/shaam-uniform-format-generator",
|
|
3
|
-
"version": "0.2.3-alpha-
|
|
3
|
+
"version": "0.2.3-alpha-20251211105553-850821f760a4152f9e24e7fca4d23874a887bbe3",
|
|
4
4
|
"description": "Fully typed application that generates, parses, and validates SHAAM uniform format tax reports (INI.TXT and BKMVDATA.TXT).",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"iconv-lite": "0.7.0",
|