@fin.cx/compatibility 5.0.1 → 5.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/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/buchungsliste/index.d.ts +80 -0
- package/dist_ts/buchungsliste/index.js +385 -0
- package/dist_ts/buchungsliste/plugins.d.ts +2 -0
- package/dist_ts/buchungsliste/plugins.js +3 -0
- package/dist_ts/encoding/index.d.ts +8 -0
- package/dist_ts/encoding/index.js +16 -1
- package/dist_ts/error.d.ts +21 -4
- package/dist_ts/error.js +3 -2
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/package.json +12 -7
- package/readme.md +51 -2
- package/ts/00_commitinfo_data.ts +2 -2
- package/ts/buchungsliste/index.ts +499 -0
- package/ts/buchungsliste/plugins.ts +3 -0
- package/ts/encoding/index.ts +17 -0
- package/ts/error.ts +30 -4
- package/ts/index.ts +1 -0
package/ts/encoding/index.ts
CHANGED
|
@@ -57,3 +57,20 @@ export const encodeWindows1252 = (textArg: string): IWindows1252Result => {
|
|
|
57
57
|
}
|
|
58
58
|
return { bytes: Uint8Array.from(bytes), replaced };
|
|
59
59
|
};
|
|
60
|
+
|
|
61
|
+
const CODE_POINT_OF_HIGH_BYTE = new Map<number, number>(HIGH_BYTES.map(([codePointArg, byteArg]) => [byteArg, codePointArg]));
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Decodes Windows-1252 as the WHATWG Encoding Standard does: the 27 characters
|
|
65
|
+
* of 0x80–0x9F by the table above, every other byte as the code point of its
|
|
66
|
+
* own number (the five bytes the standard leaves to C1 controls included).
|
|
67
|
+
* It does not rest on the platform's decoder: Node 25.2.1 reads 0x96 as
|
|
68
|
+
* U+0096, not as the dash.
|
|
69
|
+
*/
|
|
70
|
+
export const decodeWindows1252 = (bytesArg: Uint8Array): string => {
|
|
71
|
+
let text = '';
|
|
72
|
+
for (const byte of bytesArg) {
|
|
73
|
+
text += String.fromCharCode(CODE_POINT_OF_HIGH_BYTE.get(byte) ?? byte);
|
|
74
|
+
}
|
|
75
|
+
return text;
|
|
76
|
+
};
|
package/ts/error.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Why an exchange file could not be written:
|
|
2
|
+
* Why an exchange file could not be written or read:
|
|
3
3
|
* - `invalid_bookings`: a draft the account policy refuses, the message names it; a general reversal among the
|
|
4
4
|
* bookings handed over to a correction Buchungsstapel (a correction file passed as the state handed over); or a row
|
|
5
5
|
* or booking a Buchungsstapel does not hold (no day, an amount that is not positive) or whose Belegdatum lies
|
|
@@ -10,16 +10,42 @@
|
|
|
10
10
|
* - `invalid_documents`: a document of a document-image archive DATEV does not take (its GUID, its format), or none;
|
|
11
11
|
* - `nothing_to_correct`: a correction Buchungsstapel whose current bookings are the ones handed over;
|
|
12
12
|
* - `handed_over_cost_centres_unknown`: a correction of a period whose bookings handed over include one whose cost
|
|
13
|
-
* centres its record does not state (stored before 4.1) and no rows sent were given; the message names it
|
|
13
|
+
* centres its record does not state (stored before 4.1) and no rows sent were given; the message names it;
|
|
14
|
+
* - `invalid_buchungsliste`: a Buchungsliste that cannot be read or booked as it is: no header line, a required
|
|
15
|
+
* column missing, a field that is not of its format, a field this version does not map, or a row that gives no
|
|
16
|
+
* valid entry; `details` names the line, the row and the field where it can.
|
|
14
17
|
*/
|
|
15
|
-
export type TCompatibilityErrorCode =
|
|
18
|
+
export type TCompatibilityErrorCode =
|
|
19
|
+
| 'invalid_bookings'
|
|
20
|
+
| 'invalid_header'
|
|
21
|
+
| 'export_failed'
|
|
22
|
+
| 'invalid_documents'
|
|
23
|
+
| 'nothing_to_correct'
|
|
24
|
+
| 'handed_over_cost_centres_unknown'
|
|
25
|
+
| 'invalid_buchungsliste';
|
|
26
|
+
|
|
27
|
+
/** Where a refusal of a file read stands, as far as it is known; empty for a file written. */
|
|
28
|
+
export interface ICompatibilityErrorDetails {
|
|
29
|
+
/** the data row, from 1 */
|
|
30
|
+
row?: number;
|
|
31
|
+
/** the line of the file, from 1 */
|
|
32
|
+
line?: number;
|
|
33
|
+
/** the field, by the name of its column as the file states it */
|
|
34
|
+
field?: string;
|
|
35
|
+
/** the field's value as the file states it */
|
|
36
|
+
value?: string;
|
|
37
|
+
/** what the check of the entry found (`@fin.cx/skr` `validateJournalDraft`) */
|
|
38
|
+
errors?: string[];
|
|
39
|
+
}
|
|
16
40
|
|
|
17
41
|
export class CompatibilityError extends Error {
|
|
18
42
|
public readonly code: TCompatibilityErrorCode;
|
|
43
|
+
public readonly details: ICompatibilityErrorDetails;
|
|
19
44
|
|
|
20
|
-
constructor(codeArg: TCompatibilityErrorCode, messageArg: string) {
|
|
45
|
+
constructor(codeArg: TCompatibilityErrorCode, messageArg: string, detailsArg: ICompatibilityErrorDetails = {}) {
|
|
21
46
|
super(messageArg);
|
|
22
47
|
this.name = 'CompatibilityError';
|
|
23
48
|
this.code = codeArg;
|
|
49
|
+
this.details = detailsArg;
|
|
24
50
|
}
|
|
25
51
|
}
|
package/ts/index.ts
CHANGED