@accounter/shaam6111-generator 0.1.5-alpha-20251211102658-1b334ef361fc6faf8cd44900059dd236994fe9ab → 0.1.5-alpha-20251211102852-d38bdad76ee8318b9cd2ad1aaf2ae67f2a79230f

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.
Files changed (2) hide show
  1. package/README.md +69 -61
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -32,7 +32,11 @@ pnpm add @accounter/shaam6111-generator
32
32
  Create a structured report and generate a compliant SHAAM 6111 report string:
33
33
 
34
34
  ```typescript
35
- import { generateReport, IndividualOrCompanyEnum, ReportData } from '@accounter/shaam6111-generator'
35
+ import {
36
+ generateReport,
37
+ IndividualOrCompanyEnum,
38
+ ReportData,
39
+ } from '@accounter/shaam6111-generator';
36
40
 
37
41
  // Create report data structure
38
42
  const reportData: ReportData = {
@@ -53,28 +57,28 @@ const reportData: ReportData = {
53
57
  taxAdjustmentEntryCount: 2,
54
58
  balanceSheetEntryCount: 2,
55
59
  currencyType: 1, // Shekels
56
- amountsInThousands: 2 // No
60
+ amountsInThousands: 2, // No
57
61
  },
58
62
  profitAndLoss: [
59
63
  { code: 1001, amount: 500000 }, // Revenue
60
64
  { code: 2001, amount: 300000 }, // Expenses
61
- { code: 6666, amount: 200000 } // Profit
65
+ { code: 6666, amount: 200000 }, // Profit
62
66
  ],
63
67
  taxAdjustment: [
64
68
  { code: 100, amount: 200000 }, // Accounting profit
65
- { code: 400, amount: 200000 } // Taxable income
69
+ { code: 400, amount: 200000 }, // Taxable income
66
70
  ],
67
71
  balanceSheet: [
68
72
  { code: 6000, amount: 300000 }, // Assets
69
- { code: 7800, amount: 300000 } // Liabilities + Equity
73
+ { code: 7800, amount: 300000 }, // Liabilities + Equity
70
74
  ],
71
- individualOrCompany: IndividualOrCompanyEnum.COMPANY
72
- }
75
+ individualOrCompany: IndividualOrCompanyEnum.COMPANY,
76
+ };
73
77
 
74
78
  // Generate the report
75
- const reportString = generateReport(reportData)
79
+ const reportString = generateReport(reportData);
76
80
 
77
- console.log(reportString)
81
+ console.log(reportString);
78
82
  // Output: Properly formatted SHAAM 6111 report string
79
83
  ```
80
84
 
@@ -83,24 +87,24 @@ console.log(reportString)
83
87
  Parse an existing SHAAM 6111 report into structured data:
84
88
 
85
89
  ```typescript
86
- import fs from 'fs'
87
- import { parseReport } from '@accounter/shaam6111-generator'
90
+ import fs from 'fs';
91
+ import { parseReport } from '@accounter/shaam6111-generator';
88
92
 
89
93
  // Read report content
90
- const reportContent = fs.readFileSync('path/to/report.txt', 'utf-8')
94
+ const reportContent = fs.readFileSync('path/to/report.txt', 'utf-8');
91
95
 
92
96
  // Parse the report
93
97
  try {
94
- const reportData = parseReport(reportContent)
95
-
96
- console.log('Tax File Number:', reportData.header.taxFileNumber)
97
- console.log('Tax Year:', reportData.header.taxYear)
98
- console.log('Business Type:', reportData.header.businessType)
99
- console.log('Profit & Loss Entries:', reportData.profitAndLoss.length)
100
- console.log('Tax Adjustment Entries:', reportData.taxAdjustment.length)
101
- console.log('Balance Sheet Entries:', reportData.balanceSheet.length)
98
+ const reportData = parseReport(reportContent);
99
+
100
+ console.log('Tax File Number:', reportData.header.taxFileNumber);
101
+ console.log('Tax Year:', reportData.header.taxYear);
102
+ console.log('Business Type:', reportData.header.businessType);
103
+ console.log('Profit & Loss Entries:', reportData.profitAndLoss.length);
104
+ console.log('Tax Adjustment Entries:', reportData.taxAdjustment.length);
105
+ console.log('Balance Sheet Entries:', reportData.balanceSheet.length);
102
106
  } catch (error) {
103
- console.error('Error parsing report:', error)
107
+ console.error('Error parsing report:', error);
104
108
  }
105
109
  ```
106
110
 
@@ -109,35 +113,35 @@ try {
109
113
  Validate a report against SHAAM 6111 specifications:
110
114
 
111
115
  ```typescript
112
- import fs from 'fs'
116
+ import fs from 'fs';
113
117
  // Option 2: Validate report data (if you already have parsed data)
114
- import { ReportData, validateData, validateReport } from '@accounter/shaam6111-generator'
118
+ import { ReportData, validateData, validateReport } from '@accounter/shaam6111-generator';
115
119
 
116
120
  // Option 1: Validate a report string
117
- const reportContent = fs.readFileSync('path/to/report.txt', 'utf-8')
118
- const validationResult = validateReport(reportContent)
121
+ const reportContent = fs.readFileSync('path/to/report.txt', 'utf-8');
122
+ const validationResult = validateReport(reportContent);
119
123
 
120
124
  if (validationResult.isValid) {
121
- console.log('Report is valid!')
125
+ console.log('Report is valid!');
122
126
  } else {
123
- console.error('Report validation failed:')
127
+ console.error('Report validation failed:');
124
128
  validationResult.errors.forEach(error => {
125
- console.error(`- ${error.path}: ${error.message}`)
126
- })
129
+ console.error(`- ${error.path}: ${error.message}`);
130
+ });
127
131
  }
128
132
 
129
133
  const reportData: ReportData = {
130
134
  /* ... */
131
- }
132
- const dataValidationResult = validateData(reportData)
135
+ };
136
+ const dataValidationResult = validateData(reportData);
133
137
 
134
138
  if (dataValidationResult.isValid) {
135
- console.log('Report data is valid!')
139
+ console.log('Report data is valid!');
136
140
  } else {
137
- console.error('Report data validation failed:')
141
+ console.error('Report data validation failed:');
138
142
  dataValidationResult.errors.forEach(error => {
139
- console.error(`- ${error.path}: ${error.message}`)
140
- })
143
+ console.error(`- ${error.path}: ${error.message}`);
144
+ });
141
145
  }
142
146
  ```
143
147
 
@@ -146,39 +150,43 @@ if (dataValidationResult.isValid) {
146
150
  Save a report to a file or read a report from a file with proper Windows-1255 encoding:
147
151
 
148
152
  ```typescript
149
- import fs from 'fs'
150
- import { convertReportToFile, readReportFromFile, ReportData } from '@accounter/shaam6111-generator'
153
+ import fs from 'fs';
154
+ import {
155
+ convertReportToFile,
156
+ readReportFromFile,
157
+ ReportData,
158
+ } from '@accounter/shaam6111-generator';
151
159
 
152
160
  // Browser environment: Create a File object from report data
153
161
  const reportData: ReportData = {
154
162
  /* ... */
155
- }
156
- const reportFile = convertReportToFile(reportData, 'SHAAM6111.dat')
163
+ };
164
+ const reportFile = convertReportToFile(reportData, 'SHAAM6111.dat');
157
165
 
158
166
  // Handle the File object (e.g., in a browser environment)
159
167
  // For example, trigger a download:
160
- const url = URL.createObjectURL(reportFile)
161
- const a = document.createElement('a')
162
- a.href = url
163
- a.download = reportFile.name
164
- document.body.appendChild(a)
165
- a.click()
166
- document.body.removeChild(a)
167
- URL.revokeObjectURL(url)
168
+ const url = URL.createObjectURL(reportFile);
169
+ const a = document.createElement('a');
170
+ a.href = url;
171
+ a.download = reportFile.name;
172
+ document.body.appendChild(a);
173
+ a.click();
174
+ document.body.removeChild(a);
175
+ URL.revokeObjectURL(url);
168
176
 
169
177
  // Reading a report file (in browser)
170
- const fileInput = document.getElementById('fileInput') as HTMLInputElement
178
+ const fileInput = document.getElementById('fileInput') as HTMLInputElement;
171
179
  fileInput.addEventListener('change', async event => {
172
- const file = fileInput.files?.[0]
180
+ const file = fileInput.files?.[0];
173
181
  if (file) {
174
182
  try {
175
- const reportData = await readReportFromFile(file, true)
176
- console.log('Parsed report data:', reportData)
183
+ const reportData = await readReportFromFile(file, true);
184
+ console.log('Parsed report data:', reportData);
177
185
  } catch (error) {
178
- console.error('Error reading report file:', error)
186
+ console.error('Error reading report file:', error);
179
187
  }
180
188
  }
181
- })
189
+ });
182
190
  ```
183
191
 
184
192
  ### Handling Hebrew Text (Windows-1255 Encoding)
@@ -186,21 +194,21 @@ fileInput.addEventListener('change', async event => {
186
194
  Working with Hebrew text and Windows-1255 encoding:
187
195
 
188
196
  ```typescript
189
- import fs from 'fs'
190
- import { fromWindows1255, toWindows1255 } from '@accounter/shaam6111-generator'
197
+ import fs from 'fs';
198
+ import { fromWindows1255, toWindows1255 } from '@accounter/shaam6111-generator';
191
199
 
192
200
  // Convert Hebrew text to Windows-1255 encoding
193
- const hebrewText = 'חברת תוכנה בע"מ'
194
- const encoded = toWindows1255(hebrewText)
201
+ const hebrewText = 'חברת תוכנה בע"מ';
202
+ const encoded = toWindows1255(hebrewText);
195
203
 
196
204
  // Save encoded text to a file
197
- fs.writeFileSync('hebrew.dat', encoded)
205
+ fs.writeFileSync('hebrew.dat', encoded);
198
206
 
199
207
  // Read encoded text from a file
200
- const readBuffer = fs.readFileSync('hebrew.dat')
201
- const decoded = fromWindows1255(readBuffer)
208
+ const readBuffer = fs.readFileSync('hebrew.dat');
209
+ const decoded = fromWindows1255(readBuffer);
202
210
 
203
- console.log(decoded) // 'חברת תוכנה בע"מ'
211
+ console.log(decoded); // 'חברת תוכנה בע"מ'
204
212
  ```
205
213
 
206
214
  ## API Reference
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@accounter/shaam6111-generator",
3
- "version": "0.1.5-alpha-20251211102658-1b334ef361fc6faf8cd44900059dd236994fe9ab",
3
+ "version": "0.1.5-alpha-20251211102852-d38bdad76ee8318b9cd2ad1aaf2ae67f2a79230f",
4
4
  "description": "Fully typed application that generates, parses, and validates SHAAM 6111 tax reports.",
5
5
  "dependencies": {
6
6
  "iconv-lite": "0.7.0",