@moatless/bookkeeping 0.2.1 → 0.4.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/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/services/document-download.d.ts +1 -7
- package/dist/services/document-download.js +3 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/journal.service.js +21 -5
- package/dist/skills/cli-usage.d.ts +2 -0
- package/dist/skills/cli-usage.js +283 -0
- package/dist/skills/index.d.ts +8 -0
- package/dist/skills/index.js +15 -0
- package/dist/skills/swedish-bookkeeping.d.ts +2 -0
- package/dist/skills/swedish-bookkeeping.js +388 -0
- package/dist/skills/travel-expenses.d.ts +2 -0
- package/dist/skills/travel-expenses.js +406 -0
- package/dist/skills/types.d.ts +5 -0
- package/dist/skills/types.js +1 -0
- package/dist/types/document.d.ts +5 -2
- package/dist/types/journal-entry.d.ts +2 -1
- package/dist/utils/git.d.ts +5 -0
- package/dist/utils/git.js +18 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/templates.js +32 -34
- package/dist/yaml/entry-helpers.d.ts +1 -8
- package/package.json +2 -2
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
export const TRAVEL_EXPENSES_SKILL = {
|
|
2
|
+
name: "travel-expenses",
|
|
3
|
+
description: "Swedish business travel expense accounting. Use when handling hotel receipts, flight bookings, taxi fares, traktamente (per diem), mileage claims, or grouping travel receipts into journal entries. Triggers on keywords - travel, hotel, flight, taxi, traktamente, per diem, business trip, resa, hotell, reseräkning, milersättning, accommodation.",
|
|
4
|
+
content: `# Travel Expenses
|
|
5
|
+
|
|
6
|
+
Create journal entries for Swedish business travel, handling both company-paid expenses and employee reimbursements.
|
|
7
|
+
|
|
8
|
+
## Quick Reference
|
|
9
|
+
|
|
10
|
+
- **Accounts**: See accounts section below for 5800/7300 series
|
|
11
|
+
- **VAT treatment**: See VAT rules section below for rates
|
|
12
|
+
- **Non-travel expenses**: Use swedish-bookkeeping skill for SaaS, services, or other purchases during trips
|
|
13
|
+
|
|
14
|
+
## Payment Type Decision
|
|
15
|
+
|
|
16
|
+
\`\`\`
|
|
17
|
+
Who paid?
|
|
18
|
+
├─ Company (corporate card, invoice)
|
|
19
|
+
│ └─ Use 5800 series accounts
|
|
20
|
+
│ 5810 = tickets, 5820 = rental, 5831/5832 = hotel/meals
|
|
21
|
+
│
|
|
22
|
+
└─ Employee (personal card, cash)
|
|
23
|
+
└─ Use 7300 series accounts
|
|
24
|
+
7321/7323 = traktamente, 7381 = expense reimbursement
|
|
25
|
+
\`\`\`
|
|
26
|
+
|
|
27
|
+
## Traktamente (Per Diem)
|
|
28
|
+
|
|
29
|
+
Use the CLI to calculate and create traktamente entries:
|
|
30
|
+
|
|
31
|
+
\`\`\`bash
|
|
32
|
+
# List country rates
|
|
33
|
+
npx ledgit-cli traktamente list
|
|
34
|
+
npx ledgit-cli traktamente list --year 2026
|
|
35
|
+
|
|
36
|
+
# Create traktamente entry
|
|
37
|
+
npx ledgit-cli traktamente create \\
|
|
38
|
+
-d DK \\
|
|
39
|
+
--departure-date 2025-01-15 --departure-time 08:00 \\
|
|
40
|
+
--return-date 2025-01-17 --return-time 18:00 \\
|
|
41
|
+
-s K -n 1 \\
|
|
42
|
+
-o inbox/2025-01-15-traktamente-copenhagen
|
|
43
|
+
\`\`\`
|
|
44
|
+
|
|
45
|
+
**Calculation rules (Skatteverket):**
|
|
46
|
+
- Departure before 12:00 → full day
|
|
47
|
+
- Departure 12:00 or later → half day
|
|
48
|
+
- Return after 19:00 → full day
|
|
49
|
+
- Return 19:00 or earlier → half day
|
|
50
|
+
- Days in between → full days
|
|
51
|
+
|
|
52
|
+
**Output files:** \`documents.yaml\`, \`entry.yaml\`, \`traktamente.pdf\`
|
|
53
|
+
|
|
54
|
+
**Accounts:**
|
|
55
|
+
- 7321 = Tax-free domestic per diem (SE)
|
|
56
|
+
- 7323 = Tax-free international per diem (abroad)
|
|
57
|
+
- 2820 = Debt to employee (credit)
|
|
58
|
+
|
|
59
|
+
## Grouping Trip Receipts
|
|
60
|
+
|
|
61
|
+
Combine related receipts from one trip into a single journal entry:
|
|
62
|
+
|
|
63
|
+
\`\`\`yaml
|
|
64
|
+
series: D
|
|
65
|
+
entryDate: 2025-01-15
|
|
66
|
+
description: Business trip Copenhagen Jan 15-17
|
|
67
|
+
currency: SEK
|
|
68
|
+
lines:
|
|
69
|
+
# Flight (6% VAT)
|
|
70
|
+
- account: "5810"
|
|
71
|
+
debit: 1415.09
|
|
72
|
+
memo: SAS ARN-CPH return
|
|
73
|
+
- account: "2641"
|
|
74
|
+
debit: 84.91
|
|
75
|
+
memo: Moms 6%
|
|
76
|
+
# Hotel (no Swedish VAT - foreign)
|
|
77
|
+
- account: "5832"
|
|
78
|
+
debit: 3200.00
|
|
79
|
+
memo: Hotel Copenhagen 2 nights
|
|
80
|
+
# Taxi (6% VAT)
|
|
81
|
+
- account: "5890"
|
|
82
|
+
debit: 424.53
|
|
83
|
+
memo: Taxi transfers
|
|
84
|
+
- account: "2641"
|
|
85
|
+
debit: 25.47
|
|
86
|
+
memo: Moms 6%
|
|
87
|
+
# Balancing
|
|
88
|
+
- account: "2820"
|
|
89
|
+
credit: 5150.00
|
|
90
|
+
memo: Corporate card
|
|
91
|
+
\`\`\`
|
|
92
|
+
|
|
93
|
+
## Common Expense Accounts
|
|
94
|
+
|
|
95
|
+
| Expense | Account | VAT Rate |
|
|
96
|
+
|---------|---------|----------|
|
|
97
|
+
| Flight (domestic) | 5810 | 6% |
|
|
98
|
+
| Train/Bus | 5810 | 6% |
|
|
99
|
+
| Hotel (Sweden) | 5831 | 12% |
|
|
100
|
+
| Hotel (abroad) | 5832 | Exempt |
|
|
101
|
+
| Rental car | 5820 | 25% |
|
|
102
|
+
| Taxi | 5890 | 6% |
|
|
103
|
+
| Meals (Sweden) | 5831 | 12% |
|
|
104
|
+
| Meals (abroad) | 5832 | Exempt |
|
|
105
|
+
|
|
106
|
+
## Workflow: Trip with Multiple Receipts
|
|
107
|
+
|
|
108
|
+
1. **Collect receipts** - flight, hotel, taxi, meals
|
|
109
|
+
2. **Identify payment method** - corporate card → 5800, employee → 7300
|
|
110
|
+
3. **Calculate VAT per receipt** - Swedish rates: hotel 12%, transport 6%
|
|
111
|
+
4. **Create single entry** - one line per expense type
|
|
112
|
+
5. **Add traktamente if applicable** - separate entry via CLI
|
|
113
|
+
|
|
114
|
+
## Swedish VAT Rates
|
|
115
|
+
|
|
116
|
+
| Type | Rate | Calculation |
|
|
117
|
+
|------|------|-------------|
|
|
118
|
+
| Transport | 6% | Net = Gross / 1.06 |
|
|
119
|
+
| Hotel/Restaurant | 12% | Net = Gross / 1.12 |
|
|
120
|
+
| Rental car | 25% | Net = Gross / 1.25 |
|
|
121
|
+
| International | 0% | Full amount to expense |
|
|
122
|
+
|
|
123
|
+
## Series Codes
|
|
124
|
+
|
|
125
|
+
| Series | Use |
|
|
126
|
+
|--------|-----|
|
|
127
|
+
| D | Company-paid travel (supplier invoice) |
|
|
128
|
+
| E | Payment of travel expenses |
|
|
129
|
+
| K | Employee traktamente/reimbursement |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
# Travel Expense Accounts
|
|
134
|
+
|
|
135
|
+
Swedish BAS accounts for business travel expenses, covering both company-paid and employee reimbursement scenarios.
|
|
136
|
+
|
|
137
|
+
## Company-Paid Travel (5800 Series)
|
|
138
|
+
|
|
139
|
+
Use these accounts when the company pays directly (corporate card, invoice to company).
|
|
140
|
+
|
|
141
|
+
| Account | Swedish Name | Use |
|
|
142
|
+
|---------|-------------|-----|
|
|
143
|
+
| 5800 | Resekostnader | General travel expenses (control account) |
|
|
144
|
+
| 5810 | Biljetter | Flights, trains, buses, ferries |
|
|
145
|
+
| 5820 | Hyrbilskostnader | Rental cars |
|
|
146
|
+
| 5830 | Kost och logi | Meals and lodging (general) |
|
|
147
|
+
| 5831 | Kost och logi Sverige | Swedish hotels, meals, accommodation |
|
|
148
|
+
| 5832 | Kost och logi utlandet | International hotels, meals, accommodation |
|
|
149
|
+
| 5890 | Övriga resekostnader | Taxi, parking, tolls, other travel |
|
|
150
|
+
|
|
151
|
+
### When to Use 5800 Series
|
|
152
|
+
|
|
153
|
+
- Company credit card charges
|
|
154
|
+
- Corporate travel bookings
|
|
155
|
+
- Direct invoices to company
|
|
156
|
+
- Prepaid travel expenses
|
|
157
|
+
|
|
158
|
+
## Employee Reimbursement (7300 Series)
|
|
159
|
+
|
|
160
|
+
Use these accounts when the employee pays first and gets reimbursed.
|
|
161
|
+
|
|
162
|
+
### Traktamente (Per Diem)
|
|
163
|
+
|
|
164
|
+
| Account | Swedish Name | Use |
|
|
165
|
+
|---------|-------------|-----|
|
|
166
|
+
| 7321 | Skattefria traktamenten, Sverige | Tax-free per diem (domestic travel) |
|
|
167
|
+
| 7322 | Skattepliktiga traktamenten, Sverige | Taxable per diem (domestic) |
|
|
168
|
+
| 7323 | Skattefria traktamenten, utlandet | Tax-free per diem (international) |
|
|
169
|
+
| 7324 | Skattepliktiga traktamenten, utlandet | Taxable per diem (international) |
|
|
170
|
+
|
|
171
|
+
### Expense Reimbursement
|
|
172
|
+
|
|
173
|
+
| Account | Swedish Name | Use |
|
|
174
|
+
|---------|-------------|-----|
|
|
175
|
+
| 7381 | Kostnadsersättning | Employee expense reimbursement (receipts) |
|
|
176
|
+
| 7385 | Bilersättningar, skattefria | Tax-free mileage reimbursement |
|
|
177
|
+
| 7386 | Bilersättningar, skattepliktiga | Taxable mileage reimbursement |
|
|
178
|
+
|
|
179
|
+
### When to Use 7300 Series
|
|
180
|
+
|
|
181
|
+
- Employee paid with personal card
|
|
182
|
+
- Expense reports with receipts
|
|
183
|
+
- Per diem (traktamente) claims
|
|
184
|
+
- Mileage reimbursement
|
|
185
|
+
|
|
186
|
+
## Balancing Accounts
|
|
187
|
+
|
|
188
|
+
| Account | Name | Use |
|
|
189
|
+
|---------|------|-----|
|
|
190
|
+
| 2820 | Kortfristiga skulder | Debt to employee (reimbursement pending) |
|
|
191
|
+
| 2440 | Leverantörsskulder | Supplier payables (travel agency invoices) |
|
|
192
|
+
| 1930 | Företagskonto | Direct bank payment |
|
|
193
|
+
|
|
194
|
+
## Decision Tree
|
|
195
|
+
|
|
196
|
+
\`\`\`
|
|
197
|
+
Who paid for the expense?
|
|
198
|
+
│
|
|
199
|
+
├─ Company paid (corporate card, invoice)
|
|
200
|
+
│ └─ Use 5800 series
|
|
201
|
+
│ ├─ Flights/trains → 5810
|
|
202
|
+
│ ├─ Rental car → 5820
|
|
203
|
+
│ ├─ Hotel/meals Sweden → 5831
|
|
204
|
+
│ ├─ Hotel/meals abroad → 5832
|
|
205
|
+
│ └─ Taxi/parking/other → 5890
|
|
206
|
+
│
|
|
207
|
+
└─ Employee paid (personal card, cash)
|
|
208
|
+
└─ Use 7300 series
|
|
209
|
+
├─ Per diem claim → 7321 (SE) or 7323 (abroad)
|
|
210
|
+
├─ Mileage → 7385
|
|
211
|
+
└─ Receipt-based → 7381
|
|
212
|
+
\`\`\`
|
|
213
|
+
|
|
214
|
+
## Journal Entry Examples
|
|
215
|
+
|
|
216
|
+
### Company-Paid Hotel (Sweden, 12% VAT)
|
|
217
|
+
|
|
218
|
+
\`\`\`yaml
|
|
219
|
+
lines:
|
|
220
|
+
- account: "5831"
|
|
221
|
+
debit: 1785.71
|
|
222
|
+
memo: Hotel Stockholm
|
|
223
|
+
- account: "2641"
|
|
224
|
+
debit: 214.29
|
|
225
|
+
memo: Ingående moms 12%
|
|
226
|
+
- account: "2820"
|
|
227
|
+
credit: 2000.00
|
|
228
|
+
memo: Corporate card
|
|
229
|
+
\`\`\`
|
|
230
|
+
|
|
231
|
+
### Employee Traktamente (International)
|
|
232
|
+
|
|
233
|
+
\`\`\`yaml
|
|
234
|
+
lines:
|
|
235
|
+
- account: "7323"
|
|
236
|
+
debit: 1226.00
|
|
237
|
+
memo: Skattefria traktamenten, utlandet
|
|
238
|
+
- account: "2820"
|
|
239
|
+
credit: 1226.00
|
|
240
|
+
memo: Kortfristiga skulder till anställda
|
|
241
|
+
\`\`\`
|
|
242
|
+
|
|
243
|
+
### Grouped Trip Entry (Multiple Expenses)
|
|
244
|
+
|
|
245
|
+
\`\`\`yaml
|
|
246
|
+
description: Business trip Copenhagen Jan 15-17
|
|
247
|
+
lines:
|
|
248
|
+
- account: "5810"
|
|
249
|
+
debit: 1500.00
|
|
250
|
+
memo: SAS flight ARN-CPH
|
|
251
|
+
- account: "5832"
|
|
252
|
+
debit: 3200.00
|
|
253
|
+
memo: Hotel Copenhagen 2 nights
|
|
254
|
+
- account: "5890"
|
|
255
|
+
debit: 450.00
|
|
256
|
+
memo: Taxi airport transfers
|
|
257
|
+
- account: "2820"
|
|
258
|
+
credit: 5150.00
|
|
259
|
+
memo: Corporate card
|
|
260
|
+
\`\`\`
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
# Travel Expense VAT Rules
|
|
265
|
+
|
|
266
|
+
Swedish VAT (moms) treatment for business travel expenses.
|
|
267
|
+
|
|
268
|
+
## Swedish VAT Rates for Travel
|
|
269
|
+
|
|
270
|
+
| Expense Type | VAT Rate | Tax Code |
|
|
271
|
+
|--------------|----------|----------|
|
|
272
|
+
| Hotels/Accommodation | 12% | SE_VAT_12_PURCHASE_DOMESTIC |
|
|
273
|
+
| Restaurants/Meals | 12% | SE_VAT_12_PURCHASE_DOMESTIC |
|
|
274
|
+
| Domestic flights | 6% | SE_VAT_6_PURCHASE_DOMESTIC |
|
|
275
|
+
| Trains/Buses | 6% | SE_VAT_6_PURCHASE_DOMESTIC |
|
|
276
|
+
| Taxi | 6% | SE_VAT_6_PURCHASE_DOMESTIC |
|
|
277
|
+
| Rental car | 25% | SE_VAT_25_PURCHASE_DOMESTIC |
|
|
278
|
+
| Fuel | 25% | SE_VAT_25_PURCHASE_DOMESTIC |
|
|
279
|
+
| Parking | 25% | SE_VAT_25_PURCHASE_DOMESTIC |
|
|
280
|
+
|
|
281
|
+
## International Travel
|
|
282
|
+
|
|
283
|
+
| Scenario | VAT Treatment |
|
|
284
|
+
|----------|---------------|
|
|
285
|
+
| Foreign hotel | No Swedish VAT, use SE_VAT_EXEMPT_PURCHASE |
|
|
286
|
+
| Foreign meals | No Swedish VAT, use SE_VAT_EXEMPT_PURCHASE |
|
|
287
|
+
| International flight | Usually zero-rated or exempt |
|
|
288
|
+
| EU transport | May have local VAT, no Swedish deduction |
|
|
289
|
+
|
|
290
|
+
## VAT Account Mapping
|
|
291
|
+
|
|
292
|
+
| VAT Type | Account | Use |
|
|
293
|
+
|----------|---------|-----|
|
|
294
|
+
| Input VAT 25% | 2641 | Rental car, parking, fuel |
|
|
295
|
+
| Input VAT 12% | 2641 | Hotels, restaurants (reduced rate) |
|
|
296
|
+
| Input VAT 6% | 2641 | Transport (trains, flights, taxi) |
|
|
297
|
+
| No VAT | - | International, exempt, per diem |
|
|
298
|
+
|
|
299
|
+
## Decision Tree
|
|
300
|
+
|
|
301
|
+
\`\`\`
|
|
302
|
+
Is this a Swedish expense?
|
|
303
|
+
│
|
|
304
|
+
├─ YES → Check the VAT rate on receipt
|
|
305
|
+
│ ├─ 25% → SE_VAT_25_PURCHASE_DOMESTIC (rental car, parking)
|
|
306
|
+
│ ├─ 12% → SE_VAT_12_PURCHASE_DOMESTIC (hotel, restaurant)
|
|
307
|
+
│ ├─ 6% → SE_VAT_6_PURCHASE_DOMESTIC (transport)
|
|
308
|
+
│ └─ 0% → SE_VAT_EXEMPT_PURCHASE
|
|
309
|
+
│
|
|
310
|
+
└─ NO → Is VAT shown on receipt?
|
|
311
|
+
├─ YES → Usually not recoverable in Sweden
|
|
312
|
+
│ Use SE_VAT_EXEMPT_PURCHASE, book gross amount
|
|
313
|
+
└─ NO → SE_VAT_EXEMPT_PURCHASE
|
|
314
|
+
\`\`\`
|
|
315
|
+
|
|
316
|
+
## Calculating Net from Gross
|
|
317
|
+
|
|
318
|
+
When you have the total including VAT:
|
|
319
|
+
|
|
320
|
+
| VAT Rate | Calculation |
|
|
321
|
+
|----------|-------------|
|
|
322
|
+
| 25% | Net = Gross / 1.25 |
|
|
323
|
+
| 12% | Net = Gross / 1.12 |
|
|
324
|
+
| 6% | Net = Gross / 1.06 |
|
|
325
|
+
|
|
326
|
+
**Example:** Hotel SEK 2,240 (12% VAT)
|
|
327
|
+
- Net: 2,240 / 1.12 = 2,000.00
|
|
328
|
+
- VAT: 2,240 - 2,000 = 240.00
|
|
329
|
+
|
|
330
|
+
## Journal Entry Examples
|
|
331
|
+
|
|
332
|
+
### Swedish Hotel (12% VAT)
|
|
333
|
+
|
|
334
|
+
Total: SEK 2,240 including 12% VAT
|
|
335
|
+
|
|
336
|
+
\`\`\`yaml
|
|
337
|
+
lines:
|
|
338
|
+
- account: "5831"
|
|
339
|
+
debit: 2000.00
|
|
340
|
+
memo: Hotel Scandic Stockholm
|
|
341
|
+
- account: "2641"
|
|
342
|
+
debit: 240.00
|
|
343
|
+
memo: Ingående moms 12%
|
|
344
|
+
- account: "2820"
|
|
345
|
+
credit: 2240.00
|
|
346
|
+
memo: Corporate card
|
|
347
|
+
\`\`\`
|
|
348
|
+
|
|
349
|
+
### Swedish Taxi (6% VAT)
|
|
350
|
+
|
|
351
|
+
Total: SEK 530 including 6% VAT
|
|
352
|
+
|
|
353
|
+
\`\`\`yaml
|
|
354
|
+
lines:
|
|
355
|
+
- account: "5890"
|
|
356
|
+
debit: 500.00
|
|
357
|
+
memo: Taxi Arlanda-City
|
|
358
|
+
- account: "2641"
|
|
359
|
+
debit: 30.00
|
|
360
|
+
memo: Ingående moms 6%
|
|
361
|
+
- account: "2820"
|
|
362
|
+
credit: 530.00
|
|
363
|
+
memo: Corporate card
|
|
364
|
+
\`\`\`
|
|
365
|
+
|
|
366
|
+
### Foreign Hotel (No Swedish VAT)
|
|
367
|
+
|
|
368
|
+
Total: EUR 180 = SEK 2,016 (converted)
|
|
369
|
+
|
|
370
|
+
\`\`\`yaml
|
|
371
|
+
lines:
|
|
372
|
+
- account: "5832"
|
|
373
|
+
debit: 2016.00
|
|
374
|
+
memo: Hotel Berlin
|
|
375
|
+
- account: "2820"
|
|
376
|
+
credit: 2016.00
|
|
377
|
+
memo: Corporate card
|
|
378
|
+
\`\`\`
|
|
379
|
+
|
|
380
|
+
## Per Diem (Traktamente) - No VAT
|
|
381
|
+
|
|
382
|
+
Per diem allowances have no VAT component. Book the full amount to the traktamente account.
|
|
383
|
+
|
|
384
|
+
\`\`\`yaml
|
|
385
|
+
lines:
|
|
386
|
+
- account: "7323"
|
|
387
|
+
debit: 1226.00
|
|
388
|
+
memo: Traktamente Denmark 1 day
|
|
389
|
+
- account: "2820"
|
|
390
|
+
credit: 1226.00
|
|
391
|
+
\`\`\`
|
|
392
|
+
|
|
393
|
+
## Limitations on VAT Deduction
|
|
394
|
+
|
|
395
|
+
Some travel VAT is not deductible in Sweden:
|
|
396
|
+
|
|
397
|
+
| Item | VAT Deductible? |
|
|
398
|
+
|------|-----------------|
|
|
399
|
+
| Business meals (representation) | 50% deductible |
|
|
400
|
+
| Employee lunch | Not deductible |
|
|
401
|
+
| Personal travel portion | Not deductible |
|
|
402
|
+
| Entertainment | Not deductible |
|
|
403
|
+
|
|
404
|
+
For representation meals, only deduct 50% of the VAT amount.
|
|
405
|
+
`,
|
|
406
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/document.d.ts
CHANGED
|
@@ -25,11 +25,11 @@ export interface TaxDetail {
|
|
|
25
25
|
/**
|
|
26
26
|
* Document kind/type
|
|
27
27
|
*/
|
|
28
|
-
export type DocumentKind = "RECEIPT" | "SUPPLIER_INVOICE" | "CUSTOMER_INVOICE" | "TRAKTAMENTE" | "OTHER";
|
|
28
|
+
export type DocumentKind = "RECEIPT" | "SUPPLIER_INVOICE" | "CUSTOMER_INVOICE" | "TRAKTAMENTE" | "FILE" | "OTHER";
|
|
29
29
|
/**
|
|
30
30
|
* Document status in workflow
|
|
31
31
|
*/
|
|
32
|
-
export type DocumentStatus = "DRAFT" | "REVIEWED" | "READY_TO_EXPORT" | "EXPORTED" | "ERROR" | "DISCARDED" | "POSTED";
|
|
32
|
+
export type DocumentStatus = "DRAFT" | "REVIEWED" | "READY_TO_EXPORT" | "EXPORTED" | "ERROR" | "DISCARDED" | "POSTED" | "PENDING_CONNECTION";
|
|
33
33
|
/**
|
|
34
34
|
* Complete exported document with parsed data
|
|
35
35
|
*
|
|
@@ -60,4 +60,7 @@ export interface Document {
|
|
|
60
60
|
sourceId?: string;
|
|
61
61
|
uploadedAt?: string;
|
|
62
62
|
interpretedAt?: string;
|
|
63
|
+
errorMessage?: string;
|
|
64
|
+
linkedToJournalEntry?: boolean;
|
|
65
|
+
previousSourceIds?: string[];
|
|
63
66
|
}
|
|
@@ -66,7 +66,6 @@ export interface JournalEntry {
|
|
|
66
66
|
lines: JournalLine[];
|
|
67
67
|
postedAt?: string;
|
|
68
68
|
errorMessage?: string;
|
|
69
|
-
postingCheckpoint?: string;
|
|
70
69
|
voucherNumber?: number;
|
|
71
70
|
voucherSeriesCode?: string;
|
|
72
71
|
fortnoxFileId?: string;
|
|
@@ -76,4 +75,6 @@ export interface JournalEntry {
|
|
|
76
75
|
reversingEntryExternalId?: string;
|
|
77
76
|
/** If this entry was reversed/cancelled, the external ID of the reversing entry */
|
|
78
77
|
reversedByEntryExternalId?: string;
|
|
78
|
+
/** The external ID of the fiscal year this entry belongs to (e.g., Fortnox year ID) */
|
|
79
|
+
fiscalYearExternalId?: number;
|
|
79
80
|
}
|
package/dist/utils/git.d.ts
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
* Initialize a new git repository with a .gitignore file
|
|
3
3
|
*/
|
|
4
4
|
export declare function initGitRepo(repoPath: string): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Check if a directory is a git repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function isGitRepo(repoPath: string): Promise<boolean>;
|
|
5
9
|
/**
|
|
6
10
|
* Stage all changes and commit with the given message.
|
|
7
11
|
* Returns true if a commit was made, false if there were no changes to commit.
|
|
12
|
+
* Returns false if the directory is not a git repository.
|
|
8
13
|
*/
|
|
9
14
|
export declare function commitAll(repoPath: string, message: string): Promise<boolean>;
|
package/dist/utils/git.js
CHANGED
|
@@ -26,11 +26,29 @@ export async function initGitRepo(repoPath) {
|
|
|
26
26
|
await git.init();
|
|
27
27
|
await fs.writeFile(path.join(repoPath, ".gitignore"), DEFAULT_GITIGNORE);
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if a directory is a git repository
|
|
31
|
+
*/
|
|
32
|
+
export async function isGitRepo(repoPath) {
|
|
33
|
+
try {
|
|
34
|
+
const git = simpleGit(repoPath);
|
|
35
|
+
await git.revparse(["--git-dir"]);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
29
42
|
/**
|
|
30
43
|
* Stage all changes and commit with the given message.
|
|
31
44
|
* Returns true if a commit was made, false if there were no changes to commit.
|
|
45
|
+
* Returns false if the directory is not a git repository.
|
|
32
46
|
*/
|
|
33
47
|
export async function commitAll(repoPath, message) {
|
|
48
|
+
// Check if it's a git repository first
|
|
49
|
+
if (!(await isGitRepo(repoPath))) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
34
52
|
const git = simpleGit(repoPath);
|
|
35
53
|
await git.add(".");
|
|
36
54
|
const status = await git.status();
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { journalEntryDirName, journalEntryPath, journalEntryDirFromPath, fiscalYearDirName, sanitizeOrgName, } from "./file-namer";
|
|
2
2
|
export { parseYaml, toYaml } from "./yaml";
|
|
3
3
|
export { withRetry, isRateLimitError, type RetryOptions } from "./retry";
|
|
4
|
-
export { initGitRepo, commitAll } from "./git";
|
|
4
|
+
export { initGitRepo, commitAll, isGitRepo } from "./git";
|
|
5
5
|
export { getAgentsTemplate, renderAgentsTemplate, type RenderAgentsTemplateOptions, } from "./templates";
|
|
6
6
|
export { LEDGIT_DIR, getLedgitDir, getTokensDir, getCacheDir, } from "./paths";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { journalEntryDirName, journalEntryPath, journalEntryDirFromPath, fiscalYearDirName, sanitizeOrgName, } from "./file-namer";
|
|
2
2
|
export { parseYaml, toYaml } from "./yaml";
|
|
3
3
|
export { withRetry, isRateLimitError } from "./retry";
|
|
4
|
-
export { initGitRepo, commitAll } from "./git";
|
|
4
|
+
export { initGitRepo, commitAll, isGitRepo } from "./git";
|
|
5
5
|
export { getAgentsTemplate, renderAgentsTemplate, } from "./templates";
|
|
6
6
|
export { LEDGIT_DIR, getLedgitDir, getTokensDir, getCacheDir, } from "./paths";
|
package/dist/utils/templates.js
CHANGED
|
@@ -56,6 +56,10 @@ npx ledgit-cli generate-lines --inbox-dir <path> \\
|
|
|
56
56
|
# List available tax codes
|
|
57
57
|
npx ledgit-cli list-tax-codes
|
|
58
58
|
|
|
59
|
+
# Skills - detailed guidance for specific tasks
|
|
60
|
+
npx ledgit-cli skills # List available skills
|
|
61
|
+
npx ledgit-cli skills <name> # Get detailed instructions for a skill
|
|
62
|
+
|
|
59
63
|
# Update instructions
|
|
60
64
|
npx ledgit-cli update # Update AGENTS.md to latest version
|
|
61
65
|
\`\`\`
|
|
@@ -70,6 +74,25 @@ inbox/ → (create-entry) → journal-entries/ → (git review & commit) → (sy
|
|
|
70
74
|
|
|
71
75
|
When you run \`create-entry\` on main branch, a new git branch is automatically created (e.g., \`book/V-189-2025-10-15-anthropic\`). Review changes with \`git diff\`, commit, and sync to provider.
|
|
72
76
|
|
|
77
|
+
## Skills
|
|
78
|
+
|
|
79
|
+
Skills provide detailed domain knowledge for specific accounting tasks. **Before creating journal entries**, load the relevant skill to get comprehensive guidance on accounts, tax codes, and workflows.
|
|
80
|
+
|
|
81
|
+
\`\`\`bash
|
|
82
|
+
# List available skills
|
|
83
|
+
npx ledgit-cli skills
|
|
84
|
+
|
|
85
|
+
# Load skill instructions (read the full output before proceeding)
|
|
86
|
+
npx ledgit-cli skills swedish-bookkeeping # General bookkeeping, VAT, BAS accounts
|
|
87
|
+
npx ledgit-cli skills travel-expenses # Hotels, flights, traktamente, per diem
|
|
88
|
+
\`\`\`
|
|
89
|
+
|
|
90
|
+
**When to use skills:**
|
|
91
|
+
- \`swedish-bookkeeping\` - Creating journal entries, handling VAT/moms, selecting accounts
|
|
92
|
+
- \`travel-expenses\` - Business travel, hotels, flights, traktamente (per diem), mileage
|
|
93
|
+
|
|
94
|
+
Always load the appropriate skill when working on unfamiliar transaction types.
|
|
95
|
+
|
|
73
96
|
## Bookkeeping New Entries
|
|
74
97
|
|
|
75
98
|
To create a journal entry from an inbox document:
|
|
@@ -104,21 +127,11 @@ This removes the directory and marks the item for deletion from the provider on
|
|
|
104
127
|
|
|
105
128
|
## Tax Codes
|
|
106
129
|
|
|
107
|
-
|
|
130
|
+
For detailed VAT/tax code guidance, run \`npx ledgit-cli skills swedish-bookkeeping\`.
|
|
108
131
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
| Domestic purchase 12% | \`SE_VAT_12_PURCHASE_DOMESTIC\` | Expense + 2641 + 2440 |
|
|
113
|
-
| Non-EU services (US SaaS) | \`SE_VAT_25_PURCHASE_NON_EU_SERVICES_RC\` | 5422 + 2645 + 2614 + 2820 |
|
|
114
|
-
| EU services | \`SE_VAT_25_PURCHASE_EU_SERVICES_RC\` | Expense + 2645 + 2614 + 2440 |
|
|
115
|
-
| Exempt purchase | \`SE_VAT_EXEMPT_PURCHASE\` | Expense + balancing |
|
|
116
|
-
|
|
117
|
-
**Notes:**
|
|
118
|
-
- \`RC\` = Reverse Charge (buyer reports VAT instead of seller)
|
|
119
|
-
- Use \`--list-tax-codes\` to see all available codes with descriptions
|
|
120
|
-
- Account 2641 = Incoming VAT (domestic), 2645 = Incoming VAT (reverse charge)
|
|
121
|
-
- Account 2614 = Outgoing VAT (reverse charge)
|
|
132
|
+
Quick reference:
|
|
133
|
+
- \`npx ledgit-cli list-tax-codes\` - List all available codes
|
|
134
|
+
- \`RC\` suffix = Reverse Charge (buyer reports VAT instead of seller)
|
|
122
135
|
|
|
123
136
|
## Entities
|
|
124
137
|
|
|
@@ -172,26 +185,11 @@ externalId: "12" # Provider reference
|
|
|
172
185
|
|
|
173
186
|
## Account Codes
|
|
174
187
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
- **4xxx** - Cost of goods sold (Inköp)
|
|
181
|
-
- **5xxx-6xxx** - Operating expenses (Kostnader)
|
|
182
|
-
- **7xxx** - Personnel costs (Personalkostnader)
|
|
183
|
-
- **8xxx** - Financial items (Finansiella poster)
|
|
184
|
-
- **9xxx** - Year-end allocations (Bokslutsdispositioner)
|
|
185
|
-
|
|
186
|
-
Common accounts:
|
|
187
|
-
- \`1930\` - Business bank account
|
|
188
|
-
- \`2440\` - Supplier payables
|
|
189
|
-
- \`2610\` - Outgoing VAT 25%
|
|
190
|
-
- \`2640\` - Incoming VAT
|
|
191
|
-
- \`2820\` - Short-term liabilities (credit card, etc.)
|
|
192
|
-
- \`4000\` - Cost of goods sold
|
|
193
|
-
- \`5420\` - Software and IT services
|
|
194
|
-
- \`6570\` - Bank charges
|
|
188
|
+
For detailed BAS account guidance, run \`npx ledgit-cli skills swedish-bookkeeping\`.
|
|
189
|
+
|
|
190
|
+
Account ranges: 1xxx=Assets, 2xxx=Liabilities, 3xxx=Revenue, 4xxx=COGS, 5-6xxx=Expenses, 7xxx=Personnel, 8xxx=Financial.
|
|
191
|
+
|
|
192
|
+
Also check \`accounts.yaml\` in this repository for the company's chart of accounts.
|
|
195
193
|
`;
|
|
196
194
|
/**
|
|
197
195
|
* Get the raw AGENTS.md template with placeholders
|
|
@@ -8,16 +8,10 @@ import type { JournalLineInput } from "../accounting";
|
|
|
8
8
|
* Read and parse entry.yaml file
|
|
9
9
|
*/
|
|
10
10
|
export declare function readEntryYaml(filePath: string): Promise<JournalEntry>;
|
|
11
|
-
interface DocumentMetadata {
|
|
12
|
-
fileName: string;
|
|
13
|
-
mimeType?: string;
|
|
14
|
-
sourceIntegration?: string;
|
|
15
|
-
sourceId?: string;
|
|
16
|
-
}
|
|
17
11
|
/**
|
|
18
12
|
* Read and parse documents.yaml file (list format)
|
|
19
13
|
*/
|
|
20
|
-
export declare function readDocumentsYaml(filePath: string): Promise<
|
|
14
|
+
export declare function readDocumentsYaml(filePath: string): Promise<Document[]>;
|
|
21
15
|
/**
|
|
22
16
|
* @deprecated Use readDocumentsYaml instead
|
|
23
17
|
* Read and parse document.yaml file (legacy single object format)
|
|
@@ -54,4 +48,3 @@ export declare function getAccountName(accountCode: string, accounts: Array<{
|
|
|
54
48
|
code: string;
|
|
55
49
|
name: string;
|
|
56
50
|
}>): string | undefined;
|
|
57
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moatless/bookkeeping",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@moatless/api-client": "^0.1.2",
|
|
26
|
-
"@moatless/bookkeeping-types": "^0.
|
|
26
|
+
"@moatless/bookkeeping-types": "^0.3.0",
|
|
27
27
|
"@moatless/fortnox-client": "^0.1.2",
|
|
28
28
|
"@moatless/bokio-client": "^0.1.2",
|
|
29
29
|
"cli-progress": "^3.12.0",
|