@fin.cx/skr 1.1.0 → 1.2.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/index.d.ts +6 -0
- package/dist_ts/index.js +7 -1
- package/dist_ts/plugins.d.ts +8 -1
- package/dist_ts/plugins.js +10 -2
- package/dist_ts/skr.api.d.ts +70 -0
- package/dist_ts/skr.api.js +348 -1
- package/dist_ts/skr.export.accounts.d.ts +53 -0
- package/dist_ts/skr.export.accounts.js +111 -0
- package/dist_ts/skr.export.balances.d.ts +59 -0
- package/dist_ts/skr.export.balances.js +205 -0
- package/dist_ts/skr.export.d.ts +110 -0
- package/dist_ts/skr.export.js +315 -0
- package/dist_ts/skr.export.ledger.d.ts +95 -0
- package/dist_ts/skr.export.ledger.js +164 -0
- package/dist_ts/skr.export.pdf.d.ts +82 -0
- package/dist_ts/skr.export.pdf.js +548 -0
- package/dist_ts/skr.invoice.adapter.d.ts +98 -0
- package/dist_ts/skr.invoice.adapter.js +476 -0
- package/dist_ts/skr.invoice.booking.d.ts +102 -0
- package/dist_ts/skr.invoice.booking.js +556 -0
- package/dist_ts/skr.invoice.entity.d.ts +287 -0
- package/dist_ts/skr.invoice.entity.js +2 -0
- package/dist_ts/skr.invoice.mapper.d.ts +69 -0
- package/dist_ts/skr.invoice.mapper.js +401 -0
- package/dist_ts/skr.invoice.storage.d.ts +140 -0
- package/dist_ts/skr.invoice.storage.js +529 -0
- package/dist_ts/skr.security.d.ts +65 -0
- package/dist_ts/skr.security.js +319 -0
- package/dist_ts/skr.types.d.ts +1 -0
- package/package.json +17 -12
- package/readme.md +207 -16
- package/ts/index.ts +6 -0
- package/ts/plugins.ts +22 -1
- package/ts/skr.api.ts +485 -0
- package/ts/skr.export.accounts.ts +154 -0
- package/ts/skr.export.balances.ts +270 -0
- package/ts/skr.export.ledger.ts +249 -0
- package/ts/skr.export.pdf.ts +601 -0
- package/ts/skr.export.ts +443 -0
- package/ts/skr.invoice.adapter.ts +581 -0
- package/ts/skr.invoice.booking.ts +738 -0
- package/ts/skr.invoice.entity.ts +351 -0
- package/ts/skr.invoice.mapper.ts +486 -0
- package/ts/skr.invoice.storage.ts +710 -0
- package/ts/skr.security.ts +405 -0
- package/ts/skr.types.ts +1 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { TSKRType } from './skr.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Invoice direction
|
|
4
|
+
*/
|
|
5
|
+
export type TInvoiceDirection = 'inbound' | 'outbound';
|
|
6
|
+
/**
|
|
7
|
+
* Supported e-invoice formats
|
|
8
|
+
*/
|
|
9
|
+
export type TInvoiceFormat = 'xrechnung' | 'zugferd' | 'facturx' | 'peppol' | 'ubl';
|
|
10
|
+
/**
|
|
11
|
+
* Invoice status in the system
|
|
12
|
+
*/
|
|
13
|
+
export type TInvoiceStatus = 'draft' | 'validated' | 'posted' | 'partially_paid' | 'paid' | 'cancelled' | 'error';
|
|
14
|
+
/**
|
|
15
|
+
* Tax scenario classification
|
|
16
|
+
*/
|
|
17
|
+
export type TTaxScenario = 'domestic_taxed' | 'domestic_exempt' | 'reverse_charge' | 'intra_eu_supply' | 'intra_eu_acquisition' | 'export' | 'small_business';
|
|
18
|
+
/**
|
|
19
|
+
* VAT rate categories
|
|
20
|
+
*/
|
|
21
|
+
export interface IVATCategory {
|
|
22
|
+
code: string;
|
|
23
|
+
rate: number;
|
|
24
|
+
exemptionReason?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Party information (supplier/customer)
|
|
28
|
+
*/
|
|
29
|
+
export interface IInvoiceParty {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
address: {
|
|
33
|
+
street?: string;
|
|
34
|
+
city?: string;
|
|
35
|
+
postalCode?: string;
|
|
36
|
+
countryCode: string;
|
|
37
|
+
};
|
|
38
|
+
vatId?: string;
|
|
39
|
+
taxId?: string;
|
|
40
|
+
email?: string;
|
|
41
|
+
phone?: string;
|
|
42
|
+
bankAccount?: {
|
|
43
|
+
iban: string;
|
|
44
|
+
bic?: string;
|
|
45
|
+
accountHolder?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Invoice line item
|
|
50
|
+
*/
|
|
51
|
+
export interface IInvoiceLine {
|
|
52
|
+
lineNumber: number;
|
|
53
|
+
description: string;
|
|
54
|
+
quantity: number;
|
|
55
|
+
unitPrice: number;
|
|
56
|
+
netAmount: number;
|
|
57
|
+
vatCategory: IVATCategory;
|
|
58
|
+
vatAmount: number;
|
|
59
|
+
grossAmount: number;
|
|
60
|
+
accountNumber?: string;
|
|
61
|
+
costCenter?: string;
|
|
62
|
+
productCode?: string;
|
|
63
|
+
allowances?: IAllowanceCharge[];
|
|
64
|
+
charges?: IAllowanceCharge[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Allowance or charge
|
|
68
|
+
*/
|
|
69
|
+
export interface IAllowanceCharge {
|
|
70
|
+
reason: string;
|
|
71
|
+
amount: number;
|
|
72
|
+
percentage?: number;
|
|
73
|
+
vatCategory?: IVATCategory;
|
|
74
|
+
vatAmount?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Payment terms
|
|
78
|
+
*/
|
|
79
|
+
export interface IPaymentTerms {
|
|
80
|
+
dueDate: Date;
|
|
81
|
+
paymentTermsNote?: string;
|
|
82
|
+
skonto?: {
|
|
83
|
+
percentage: number;
|
|
84
|
+
days: number;
|
|
85
|
+
baseAmount: number;
|
|
86
|
+
}[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Validation result
|
|
90
|
+
*/
|
|
91
|
+
export interface IValidationResult {
|
|
92
|
+
isValid: boolean;
|
|
93
|
+
syntax: {
|
|
94
|
+
valid: boolean;
|
|
95
|
+
errors: string[];
|
|
96
|
+
warnings: string[];
|
|
97
|
+
};
|
|
98
|
+
semantic: {
|
|
99
|
+
valid: boolean;
|
|
100
|
+
errors: string[];
|
|
101
|
+
warnings: string[];
|
|
102
|
+
};
|
|
103
|
+
businessRules: {
|
|
104
|
+
valid: boolean;
|
|
105
|
+
errors: string[];
|
|
106
|
+
warnings: string[];
|
|
107
|
+
};
|
|
108
|
+
countrySpecific?: {
|
|
109
|
+
valid: boolean;
|
|
110
|
+
errors: string[];
|
|
111
|
+
warnings: string[];
|
|
112
|
+
};
|
|
113
|
+
validatedAt: Date;
|
|
114
|
+
validatorVersion: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Booking information
|
|
118
|
+
*/
|
|
119
|
+
export interface IBookingInfo {
|
|
120
|
+
journalEntryId: string;
|
|
121
|
+
transactionIds: string[];
|
|
122
|
+
bookedAt: Date;
|
|
123
|
+
bookedBy: string;
|
|
124
|
+
bookingRules: {
|
|
125
|
+
vendorAccount?: string;
|
|
126
|
+
customerAccount?: string;
|
|
127
|
+
expenseAccounts?: string[];
|
|
128
|
+
revenueAccounts?: string[];
|
|
129
|
+
vatAccounts?: string[];
|
|
130
|
+
};
|
|
131
|
+
confidence: number;
|
|
132
|
+
autoBooked: boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Payment information
|
|
136
|
+
*/
|
|
137
|
+
export interface IPaymentInfo {
|
|
138
|
+
paymentId: string;
|
|
139
|
+
paymentDate: Date;
|
|
140
|
+
amount: number;
|
|
141
|
+
currency: string;
|
|
142
|
+
bankTransactionId?: string;
|
|
143
|
+
endToEndId?: string;
|
|
144
|
+
remittanceInfo?: string;
|
|
145
|
+
skontoTaken?: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Main invoice entity
|
|
149
|
+
*/
|
|
150
|
+
export interface IInvoice {
|
|
151
|
+
id: string;
|
|
152
|
+
direction: TInvoiceDirection;
|
|
153
|
+
format: TInvoiceFormat;
|
|
154
|
+
invoiceNumber: string;
|
|
155
|
+
issueDate: Date;
|
|
156
|
+
invoiceTypeCode?: string;
|
|
157
|
+
currencyCode: string;
|
|
158
|
+
taxCurrencyCode?: string;
|
|
159
|
+
taxPointDate?: Date;
|
|
160
|
+
paymentDueDate?: Date;
|
|
161
|
+
buyerReference?: string;
|
|
162
|
+
projectReference?: string;
|
|
163
|
+
contractReference?: string;
|
|
164
|
+
orderReference?: string;
|
|
165
|
+
sellerOrderReference?: string;
|
|
166
|
+
supplier: IInvoiceParty;
|
|
167
|
+
customer: IInvoiceParty;
|
|
168
|
+
payee?: IInvoiceParty;
|
|
169
|
+
lines: IInvoiceLine[];
|
|
170
|
+
allowances?: IAllowanceCharge[];
|
|
171
|
+
charges?: IAllowanceCharge[];
|
|
172
|
+
lineNetAmount: number;
|
|
173
|
+
allowanceTotalAmount?: number;
|
|
174
|
+
chargeTotalAmount?: number;
|
|
175
|
+
taxExclusiveAmount: number;
|
|
176
|
+
taxInclusiveAmount: number;
|
|
177
|
+
prepaidAmount?: number;
|
|
178
|
+
payableAmount: number;
|
|
179
|
+
vatBreakdown: {
|
|
180
|
+
vatCategory: IVATCategory;
|
|
181
|
+
taxableAmount: number;
|
|
182
|
+
taxAmount: number;
|
|
183
|
+
}[];
|
|
184
|
+
totalVATAmount: number;
|
|
185
|
+
paymentTerms?: IPaymentTerms;
|
|
186
|
+
paymentMeans?: {
|
|
187
|
+
code: string;
|
|
188
|
+
account?: IInvoiceParty['bankAccount'];
|
|
189
|
+
};
|
|
190
|
+
payments?: IPaymentInfo[];
|
|
191
|
+
invoiceNote?: string;
|
|
192
|
+
status: TInvoiceStatus;
|
|
193
|
+
taxScenario?: TTaxScenario;
|
|
194
|
+
skrType?: TSKRType;
|
|
195
|
+
contentHash: string;
|
|
196
|
+
xmlContent?: string;
|
|
197
|
+
pdfHash?: string;
|
|
198
|
+
pdfContent?: Buffer;
|
|
199
|
+
validationResult?: IValidationResult;
|
|
200
|
+
bookingInfo?: IBookingInfo;
|
|
201
|
+
createdAt: Date;
|
|
202
|
+
createdBy: string;
|
|
203
|
+
modifiedAt?: Date;
|
|
204
|
+
modifiedBy?: string;
|
|
205
|
+
metadata?: {
|
|
206
|
+
importSource?: string;
|
|
207
|
+
importedAt?: Date;
|
|
208
|
+
parserVersion?: string;
|
|
209
|
+
originalFilename?: string;
|
|
210
|
+
originalFormat?: string;
|
|
211
|
+
[key: string]: any;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Invoice import options
|
|
216
|
+
*/
|
|
217
|
+
export interface IInvoiceImportOptions {
|
|
218
|
+
autoBook?: boolean;
|
|
219
|
+
confidenceThreshold?: number;
|
|
220
|
+
validateOnly?: boolean;
|
|
221
|
+
skipDuplicateCheck?: boolean;
|
|
222
|
+
bookingRules?: {
|
|
223
|
+
vendorDefaults?: Record<string, string>;
|
|
224
|
+
customerDefaults?: Record<string, string>;
|
|
225
|
+
productCategoryMapping?: Record<string, string>;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Invoice export options
|
|
230
|
+
*/
|
|
231
|
+
export interface IInvoiceExportOptions {
|
|
232
|
+
format: TInvoiceFormat;
|
|
233
|
+
embedInPdf?: boolean;
|
|
234
|
+
sign?: boolean;
|
|
235
|
+
validate?: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Invoice search filter
|
|
239
|
+
*/
|
|
240
|
+
export interface IInvoiceFilter {
|
|
241
|
+
direction?: TInvoiceDirection;
|
|
242
|
+
status?: TInvoiceStatus;
|
|
243
|
+
format?: TInvoiceFormat;
|
|
244
|
+
dateFrom?: Date;
|
|
245
|
+
dateTo?: Date;
|
|
246
|
+
supplierId?: string;
|
|
247
|
+
customerId?: string;
|
|
248
|
+
minAmount?: number;
|
|
249
|
+
maxAmount?: number;
|
|
250
|
+
invoiceNumber?: string;
|
|
251
|
+
reference?: string;
|
|
252
|
+
isPaid?: boolean;
|
|
253
|
+
isOverdue?: boolean;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Duplicate check result
|
|
257
|
+
*/
|
|
258
|
+
export interface IDuplicateCheckResult {
|
|
259
|
+
isDuplicate: boolean;
|
|
260
|
+
matchedInvoiceId?: string;
|
|
261
|
+
matchedContentHash?: string;
|
|
262
|
+
matchedFields?: string[];
|
|
263
|
+
confidence: number;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Booking rules configuration
|
|
267
|
+
*/
|
|
268
|
+
export interface IBookingRules {
|
|
269
|
+
skrType: TSKRType;
|
|
270
|
+
vendorControlAccount: string;
|
|
271
|
+
customerControlAccount: string;
|
|
272
|
+
vatAccounts: {
|
|
273
|
+
inputVAT19: string;
|
|
274
|
+
inputVAT7: string;
|
|
275
|
+
outputVAT19: string;
|
|
276
|
+
outputVAT7: string;
|
|
277
|
+
reverseChargeVAT: string;
|
|
278
|
+
};
|
|
279
|
+
defaultExpenseAccount: string;
|
|
280
|
+
defaultRevenueAccount: string;
|
|
281
|
+
productCategoryMapping?: Record<string, string>;
|
|
282
|
+
vendorMapping?: Record<string, string>;
|
|
283
|
+
customerMapping?: Record<string, string>;
|
|
284
|
+
skontoMethod?: 'net' | 'gross';
|
|
285
|
+
skontoExpenseAccount?: string;
|
|
286
|
+
skontoRevenueAccount?: string;
|
|
287
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { TSKRType } from './skr.types.js';
|
|
2
|
+
import type { IInvoice, IInvoiceLine, IBookingRules, TTaxScenario, IVATCategory } from './skr.invoice.entity.js';
|
|
3
|
+
/**
|
|
4
|
+
* Maps invoice data to SKR accounts
|
|
5
|
+
* Handles both SKR03 and SKR04 account mappings
|
|
6
|
+
*/
|
|
7
|
+
export declare class SKRInvoiceMapper {
|
|
8
|
+
private logger;
|
|
9
|
+
private skrType;
|
|
10
|
+
private readonly SKR03_ACCOUNTS;
|
|
11
|
+
private readonly SKR04_ACCOUNTS;
|
|
12
|
+
private readonly CATEGORY_MAPPINGS;
|
|
13
|
+
constructor(skrType: TSKRType);
|
|
14
|
+
/**
|
|
15
|
+
* Get account mappings for current SKR type
|
|
16
|
+
*/
|
|
17
|
+
private getAccounts;
|
|
18
|
+
/**
|
|
19
|
+
* Map invoice to booking rules
|
|
20
|
+
*/
|
|
21
|
+
mapInvoiceToSKR(invoice: IInvoice, customMappings?: Partial<IBookingRules>): IBookingRules;
|
|
22
|
+
/**
|
|
23
|
+
* Map invoice line to SKR account
|
|
24
|
+
*/
|
|
25
|
+
mapInvoiceLineToAccount(line: IInvoiceLine, invoice: IInvoice, bookingRules: IBookingRules): string;
|
|
26
|
+
/**
|
|
27
|
+
* Map revenue account based on VAT rate and scenario
|
|
28
|
+
*/
|
|
29
|
+
private mapRevenueAccount;
|
|
30
|
+
/**
|
|
31
|
+
* Map expense account based on product category and vendor
|
|
32
|
+
*/
|
|
33
|
+
private mapExpenseAccount;
|
|
34
|
+
/**
|
|
35
|
+
* Detect product category from description
|
|
36
|
+
*/
|
|
37
|
+
private detectProductCategory;
|
|
38
|
+
/**
|
|
39
|
+
* Get VAT account for given VAT category and rate
|
|
40
|
+
*/
|
|
41
|
+
getVATAccount(vatCategory: IVATCategory, direction: 'input' | 'output', taxScenario: TTaxScenario): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get control account for party
|
|
44
|
+
*/
|
|
45
|
+
getControlAccount(invoice: IInvoice, bookingRules: IBookingRules): string;
|
|
46
|
+
/**
|
|
47
|
+
* Check if account is a control account
|
|
48
|
+
*/
|
|
49
|
+
private isControlAccount;
|
|
50
|
+
/**
|
|
51
|
+
* Get skonto accounts
|
|
52
|
+
*/
|
|
53
|
+
getSkontoAccounts(invoice: IInvoice): {
|
|
54
|
+
skontoAccount: string;
|
|
55
|
+
vatCorrectionAccount: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Validate account number format
|
|
59
|
+
*/
|
|
60
|
+
validateAccountNumber(accountNumber: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Get account description
|
|
63
|
+
*/
|
|
64
|
+
getAccountDescription(accountNumber: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Calculate booking confidence score
|
|
67
|
+
*/
|
|
68
|
+
calculateConfidence(invoice: IInvoice, bookingRules: IBookingRules): number;
|
|
69
|
+
}
|