@moatless/bookkeeping 0.2.1 → 0.3.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 CHANGED
@@ -7,3 +7,4 @@ export * from "./utils";
7
7
  export * from "./services";
8
8
  export * from "./auth";
9
9
  export * from "./progress";
10
+ export * from "./skills";
package/dist/index.js CHANGED
@@ -18,3 +18,5 @@ export * from "./services";
18
18
  export * from "./auth";
19
19
  // Progress bar utilities
20
20
  export * from "./progress";
21
+ // Skills (domain knowledge for AI agents)
22
+ export * from "./skills";
@@ -0,0 +1,7 @@
1
+ export type { Skill } from "./types";
2
+ export { SWEDISH_BOOKKEEPING_SKILL } from "./swedish-bookkeeping";
3
+ export { TRAVEL_EXPENSES_SKILL } from "./travel-expenses";
4
+ import type { Skill } from "./types";
5
+ export declare const SKILLS: Skill[];
6
+ export declare function listSkills(): Skill[];
7
+ export declare function getSkill(name: string): Skill | undefined;
@@ -0,0 +1,14 @@
1
+ export { SWEDISH_BOOKKEEPING_SKILL } from "./swedish-bookkeeping";
2
+ export { TRAVEL_EXPENSES_SKILL } from "./travel-expenses";
3
+ import { SWEDISH_BOOKKEEPING_SKILL } from "./swedish-bookkeeping";
4
+ import { TRAVEL_EXPENSES_SKILL } from "./travel-expenses";
5
+ export const SKILLS = [
6
+ SWEDISH_BOOKKEEPING_SKILL,
7
+ TRAVEL_EXPENSES_SKILL,
8
+ ];
9
+ export function listSkills() {
10
+ return SKILLS;
11
+ }
12
+ export function getSkill(name) {
13
+ return SKILLS.find((skill) => skill.name === name);
14
+ }
@@ -0,0 +1,2 @@
1
+ import type { Skill } from "./types";
2
+ export declare const SWEDISH_BOOKKEEPING_SKILL: Skill;
@@ -0,0 +1,388 @@
1
+ export const SWEDISH_BOOKKEEPING_SKILL = {
2
+ name: "swedish-bookkeeping",
3
+ description: "Swedish bookkeeping and accounting using BAS kontoplan. Use when creating journal entries (verifikationer), handling Swedish VAT (moms), categorizing expenses, or working with Swedish accounting data. Triggers on tasks involving BAS accounts (1xxx-9xxx), moms/VAT codes, reverse charge (omvänd skattskyldighet), supplier invoices, or financial record-keeping for Swedish companies.",
4
+ content: `# Swedish Bookkeeping
5
+
6
+ Create journal entries following Swedish BAS accounting standards with correct VAT handling.
7
+
8
+ ## Quick Reference
9
+
10
+ - **Accounts**: See accounts section below for BAS account codes
11
+ - **VAT/Tax codes**: See VAT codes section below for tax code selection
12
+
13
+ ## Journal Entry Structure
14
+
15
+ Every entry (verifikation) must balance: total debits = total credits.
16
+
17
+ \`\`\`yaml
18
+ series: D # A=Admin, B=Customer invoices, C=Customer payments,
19
+ # D=Supplier invoices, E=Supplier payments, K=Salary
20
+ entryNumber: 1
21
+ entryDate: 2024-01-15
22
+ description: Supplier Name - Invoice description
23
+ status: POSTED
24
+ currency: SEK
25
+ lines:
26
+ - account: "5422" # Expense account
27
+ debit: 1000.00
28
+ memo: SaaS subscription
29
+ - account: "2645" # VAT (if applicable)
30
+ debit: 250.00
31
+ memo: Input VAT reverse charge
32
+ - account: "2614" # Output VAT for reverse charge
33
+ credit: 250.00
34
+ memo: Output VAT reverse charge
35
+ - account: "2820" # Balancing account
36
+ credit: 1000.00
37
+ memo: Credit card payment
38
+ \`\`\`
39
+
40
+ ## Tax Code Selection
41
+
42
+ \`\`\`
43
+ Swedish supplier (VAT on invoice)?
44
+ ├─ YES → SE_VAT_25_PURCHASE_DOMESTIC (or 12%/6%/exempt)
45
+ └─ NO → Is it a service?
46
+ ├─ YES, EU supplier → SE_VAT_25_PURCHASE_EU_SERVICES_RC
47
+ ├─ YES, non-EU (US/UK) → SE_VAT_25_PURCHASE_NON_EU_SERVICES_RC
48
+ └─ NO (goods) → SE_VAT_25_PURCHASE_EU_GOODS_RC or import
49
+ \`\`\`
50
+
51
+ ## Common Expense Accounts
52
+
53
+ | Type | Account | Example Vendors |
54
+ |------|---------|-----------------|
55
+ | SaaS/Software | 5422 | AWS, GitHub, Anthropic, Slack |
56
+ | IT services | 6540 | Consulting, development |
57
+ | Accounting | 6530 | Bokio, Fortnox |
58
+ | Bank fees | 6570 | Bank charges (VAT exempt) |
59
+ | Internet/Telecom | 6230 | ISP, phone plans |
60
+ | Office supplies | 6110 | Stationery, small equipment |
61
+ | Travel | 5800 | Flights, trains |
62
+ | Meals (business) | 5831 | Hotels, business meals |
63
+
64
+ ## Balancing Accounts
65
+
66
+ | Method | Account | Use |
67
+ |--------|---------|-----|
68
+ | Supplier payable | 2440 | When paying later via bank transfer |
69
+ | Credit card | 2820 | Direct credit card charge |
70
+ | Bank account | 1930 | Direct debit/immediate payment |
71
+
72
+ ## Workflow: Creating an Entry
73
+
74
+ 1. **Identify the supplier** - Swedish, EU, or non-EU?
75
+ 2. **Determine expense type** - Select appropriate 5xxx/6xxx account
76
+ 3. **Select tax code** - Based on supplier location and transaction type
77
+ 4. **Choose balancing account** - 2440 (payable), 2820 (credit card), or 1930 (bank)
78
+ 5. **Create balanced entry** - Ensure debits = credits
79
+
80
+ ## Currency Handling
81
+
82
+ Foreign currency amounts must be converted to SEK using the exchange rate on the transaction date. Use Riksbank published rates.
83
+
84
+ ## Series Codes
85
+
86
+ | Series | Swedish | Use |
87
+ |--------|---------|-----|
88
+ | A | Administration | Internal adjustments, corrections |
89
+ | B | Kundfakturor | Customer invoices (sales) |
90
+ | C | Kundbetalningar | Customer payments received |
91
+ | D | Leverantörsfakturor | Supplier invoices (purchases) |
92
+ | E | Leverantörsbetalningar | Supplier payments made |
93
+ | K | Löner | Salary and payroll |
94
+
95
+ ---
96
+
97
+ # Swedish BAS Account Codes
98
+
99
+ The BAS chart of accounts (kontoplan) is the standard accounting framework used by Swedish companies. Account numbers have 4 digits where the first digit indicates the account class.
100
+
101
+ ## Account Classes
102
+
103
+ | Class | Swedish Name | English | Description |
104
+ |-------|-------------|---------|-------------|
105
+ | 1xxx | Tillgångar | Assets | Cash, receivables, inventory, fixed assets |
106
+ | 2xxx | Skulder & Eget kapital | Liabilities & Equity | Payables, loans, VAT, equity |
107
+ | 3xxx | Intäkter | Revenue | Sales, other income |
108
+ | 4xxx | Inköp/Varor | Cost of Goods | Direct costs, materials |
109
+ | 5xxx | Övriga externa kostnader | External Expenses | Rent, services, supplies |
110
+ | 6xxx | Övriga externa kostnader | External Expenses | Marketing, admin, IT |
111
+ | 7xxx | Personalkostnader | Personnel Costs | Salaries, benefits, taxes |
112
+ | 8xxx | Finansiella poster | Financial Items | Interest, currency gains/losses |
113
+ | 9xxx | Bokslutsdispositioner | Year-end Items | Appropriations, tax |
114
+
115
+ ## Account Number Structure
116
+
117
+ - **First digit**: Account class (1-9)
118
+ - **First two digits**: Account group
119
+ - **Ending in 00**: Control account (aggregates entire group)
120
+ - **Ending in 0**: Main account
121
+ - **Ending in 1-9**: Sub-accounts (detailed breakdown)
122
+
123
+ ## Commonly Used Accounts
124
+
125
+ ### Assets (1xxx)
126
+
127
+ | Account | Name | Use |
128
+ |---------|------|-----|
129
+ | 1510 | Kundfordringar | Accounts receivable |
130
+ | 1630 | Skattekonto | Tax account (Skatteverket) |
131
+ | 1930 | Företagskonto | Business bank account |
132
+ | 1940 | Placeringskonto | Savings/investment account |
133
+
134
+ ### Liabilities & Equity (2xxx)
135
+
136
+ | Account | Name | Use |
137
+ |---------|------|-----|
138
+ | 2010 | Eget kapital | Owner's equity |
139
+ | 2091 | Balanserad vinst | Retained earnings |
140
+ | 2099 | Årets resultat | Current year profit/loss |
141
+ | 2440 | Leverantörsskulder | Accounts payable |
142
+ | 2510 | Skatteskulder | Tax liabilities |
143
+ | 2610 | Utgående moms 25% | Output VAT 25% (sales) |
144
+ | 2611 | Utgående moms 12% | Output VAT 12% |
145
+ | 2612 | Utgående moms 6% | Output VAT 6% |
146
+ | 2614 | Utgående moms omvänd skattskyldighet | Output VAT reverse charge |
147
+ | 2640 | Ingående moms | Input VAT (general) |
148
+ | 2641 | Ingående moms 25% | Input VAT 25% (domestic) |
149
+ | 2645 | Ingående moms omvänd skattskyldighet | Input VAT reverse charge |
150
+ | 2650 | Momsredovisningskonto | VAT settlement account |
151
+ | 2820 | Kortfristiga skulder | Short-term liabilities (credit card) |
152
+ | 2898 | Outtagen vinstutdelning | Undistributed dividends |
153
+
154
+ ### Revenue (3xxx)
155
+
156
+ | Account | Name | Use |
157
+ |---------|------|-----|
158
+ | 3000 | Försäljning | Sales (general) |
159
+ | 3001 | Försäljning 25% moms | Sales 25% VAT |
160
+ | 3002 | Försäljning 12% moms | Sales 12% VAT |
161
+ | 3003 | Försäljning 6% moms | Sales 6% VAT |
162
+ | 3041 | Försäljning tjänster EU | Services sold to EU |
163
+ | 3051 | Försäljning varor EU | Goods sold to EU |
164
+ | 3305 | Försäljning utanför EU | Sales outside EU |
165
+ | 3740 | Öres- och kronutjämning | Rounding adjustments |
166
+ | 3960 | Valutakursvinster | Currency gains |
167
+
168
+ ### Cost of Goods (4xxx)
169
+
170
+ | Account | Name | Use |
171
+ |---------|------|-----|
172
+ | 4000 | Inköp varor | Goods purchased |
173
+ | 4010 | Inköp material | Materials purchased |
174
+ | 4531 | Import EU varor | Imports from EU (goods) |
175
+ | 4535 | Import utanför EU varor | Imports from non-EU (goods) |
176
+ | 4545 | Inköp tjänster EU | Services from EU |
177
+ | 4546 | Inköp tjänster utanför EU | Services from non-EU |
178
+
179
+ ### External Expenses (5xxx-6xxx)
180
+
181
+ | Account | Name | Use |
182
+ |---------|------|-----|
183
+ | 5010 | Lokalhyra | Office rent |
184
+ | 5400 | Förbrukningsinventarier | Consumable equipment |
185
+ | 5410 | Förbrukningsmat. | Consumables |
186
+ | 5420 | Programvara | Software |
187
+ | 5422 | Programvara, onlinetjänster | SaaS subscriptions |
188
+ | 5480 | Arbetskläder | Work clothing |
189
+ | 5500 | Reparation maskiner | Repairs machinery |
190
+ | 5800 | Resekostnader | Travel expenses |
191
+ | 5831 | Kost och logi | Meals and accommodation |
192
+ | 5910 | Annonsering | Advertising |
193
+ | 6071 | Representation | Business entertainment |
194
+ | 6110 | Kontorsmaterial | Office supplies |
195
+ | 6212 | Mobiltelefon | Mobile phone |
196
+ | 6230 | Datakommunikation | Internet/data |
197
+ | 6310 | Företagsförsäkringar | Business insurance |
198
+ | 6420 | Ersättning styrelsen | Board compensation |
199
+ | 6530 | Redovisningstjänster | Accounting services |
200
+ | 6540 | IT-tjänster | IT services |
201
+ | 6570 | Bankkostnader | Bank charges |
202
+ | 6970 | Tidningar och tidskrifter | Subscriptions |
203
+
204
+ ### Personnel Costs (7xxx)
205
+
206
+ | Account | Name | Use |
207
+ |---------|------|-----|
208
+ | 7010 | Löner tjänstemän | Salaries (employees) |
209
+ | 7082 | Sjuklön | Sick pay |
210
+ | 7090 | Förändring semesterlöneskuld | Vacation pay accrual |
211
+ | 7210 | Löner styrelse | Board salaries |
212
+ | 7381 | Kostnadsersättning | Expense reimbursement |
213
+ | 7510 | Arbetsgivaravgifter | Employer contributions |
214
+ | 7533 | Särskild löneskatt pensionskostnader | Special payroll tax (pensions) |
215
+ | 7820 | Utbildning | Training/education |
216
+
217
+ ### Financial Items (8xxx)
218
+
219
+ | Account | Name | Use |
220
+ |---------|------|-----|
221
+ | 8310 | Ränteintäkter | Interest income |
222
+ | 8410 | Räntekostnader | Interest expenses |
223
+ | 8423 | Räntekostnader skattekonto | Tax account interest |
224
+ | 8910 | Skatt på årets resultat | Income tax |
225
+
226
+ ## Double-Entry Principles
227
+
228
+ Swedish bookkeeping follows standard double-entry principles:
229
+ - **Debit (debet)**: Increases assets (1xxx), decreases liabilities (2xxx), increases expenses (4xxx-8xxx)
230
+ - **Credit (kredit)**: Decreases assets, increases liabilities/equity, increases revenue (3xxx)
231
+
232
+ Every transaction must balance: total debits = total credits.
233
+
234
+ ---
235
+
236
+ # Swedish VAT (Moms) Tax Codes
237
+
238
+ Swedish VAT (Mervärdesskatt/Moms) uses different rates and reporting rules depending on the type of transaction and geographic origin.
239
+
240
+ ## VAT Rates
241
+
242
+ | Rate | Description | Common Uses |
243
+ |------|-------------|-------------|
244
+ | 25% | Standard rate | Most goods and services |
245
+ | 12% | Reduced rate | Food, hotels, restaurants |
246
+ | 6% | Reduced rate | Books, newspapers, public transport, cultural events |
247
+ | 0% | Zero-rated | Exports, certain financial services |
248
+
249
+ ## Tax Code Patterns
250
+
251
+ ### Domestic Purchases (Swedish Seller)
252
+
253
+ When purchasing from a Swedish company that charges VAT:
254
+
255
+ | Tax Code | Rate | Expense Account | VAT Account | Balancing |
256
+ |----------|------|-----------------|-------------|-----------|
257
+ | \`SE_VAT_25_PURCHASE_DOMESTIC\` | 25% | Expense (5xxx/6xxx) | 2641 | 2440 |
258
+ | \`SE_VAT_12_PURCHASE_DOMESTIC\` | 12% | Expense | 2641 | 2440 |
259
+ | \`SE_VAT_6_PURCHASE_DOMESTIC\` | 6% | Expense | 2641 | 2440 |
260
+ | \`SE_VAT_EXEMPT_PURCHASE\` | 0% | Expense | - | 2440/2820 |
261
+
262
+ **Example**: SEK 1,250 domestic purchase with 25% VAT
263
+ \`\`\`
264
+ Debit 5420 (Software) 1,000.00
265
+ Debit 2641 (Input VAT) 250.00
266
+ Credit 2440 (Supplier payables) 1,250.00
267
+ \`\`\`
268
+
269
+ ### Reverse Charge - EU Services
270
+
271
+ For B2B services from EU countries (not goods), the buyer reports VAT:
272
+
273
+ | Tax Code | Use Case | VAT Handling |
274
+ |----------|----------|--------------|
275
+ | \`SE_VAT_25_PURCHASE_EU_SERVICES_RC\` | SaaS, consulting from EU | Reverse charge 25% |
276
+ | \`SE_VAT_12_PURCHASE_EU_SERVICES_RC\` | Reduced rate EU services | Reverse charge 12% |
277
+
278
+ **Journal pattern** (25% reverse charge):
279
+ \`\`\`
280
+ Debit 5422 (Expense) 1,000.00 # Net amount
281
+ Debit 2645 (Input VAT RC) 250.00 # Deductible VAT
282
+ Credit 2614 (Output VAT RC) 250.00 # VAT liability
283
+ Credit 2440 (Supplier payables) 1,000.00 # Net to pay
284
+ \`\`\`
285
+
286
+ ### Reverse Charge - Non-EU Services
287
+
288
+ For B2B services from countries outside EU (US, UK, etc.):
289
+
290
+ | Tax Code | Use Case | VAT Handling |
291
+ |----------|----------|--------------|
292
+ | \`SE_VAT_25_PURCHASE_NON_EU_SERVICES_RC\` | US SaaS (AWS, GitHub, etc.) | Reverse charge 25% |
293
+ | \`SE_VAT_12_PURCHASE_NON_EU_SERVICES_RC\` | Reduced rate non-EU services | Reverse charge 12% |
294
+
295
+ **Journal pattern** (US SaaS subscription USD 100 = SEK 1,000):
296
+ \`\`\`
297
+ Debit 5422 (SaaS expense) 1,000.00
298
+ Debit 2645 (Input VAT RC) 250.00
299
+ Credit 2614 (Output VAT RC) 250.00
300
+ Credit 2820 (Credit card) 1,000.00
301
+ \`\`\`
302
+
303
+ ### Reverse Charge - EU Goods
304
+
305
+ Physical goods purchased from EU require different handling:
306
+
307
+ | Tax Code | Use Case |
308
+ |----------|----------|
309
+ | \`SE_VAT_25_PURCHASE_EU_GOODS_RC\` | Hardware, equipment from EU |
310
+ | \`SE_VAT_12_PURCHASE_EU_GOODS_RC\` | Reduced rate goods from EU |
311
+
312
+ ### Sales Tax Codes
313
+
314
+ | Tax Code | Use Case |
315
+ |----------|----------|
316
+ | \`SE_VAT_25_SALE_DOMESTIC\` | Domestic sales 25% |
317
+ | \`SE_VAT_12_SALE_DOMESTIC\` | Domestic sales 12% |
318
+ | \`SE_VAT_6_SALE_DOMESTIC\` | Domestic sales 6% |
319
+ | \`SE_VAT_EXEMPT_SALE_EU\` | B2B sales to EU (reverse charge applies to buyer) |
320
+ | \`SE_VAT_EXEMPT_SALE_EXPORT\` | Sales outside EU (export) |
321
+
322
+ ## Determining the Right Tax Code
323
+
324
+ \`\`\`
325
+ Is the supplier Swedish?
326
+ ├─ YES → Use DOMESTIC tax code
327
+ │ └─ Match VAT rate on invoice (25%, 12%, 6%, or exempt)
328
+
329
+ └─ NO → Is it a service or goods?
330
+
331
+ ├─ SERVICE → Is supplier in EU?
332
+ │ ├─ YES → SE_VAT_25_PURCHASE_EU_SERVICES_RC
333
+ │ └─ NO → SE_VAT_25_PURCHASE_NON_EU_SERVICES_RC
334
+
335
+ └─ GOODS → Is supplier in EU?
336
+ ├─ YES → SE_VAT_25_PURCHASE_EU_GOODS_RC
337
+ └─ NO → Import VAT (customs declaration)
338
+ \`\`\`
339
+
340
+ ## Key VAT Accounts
341
+
342
+ | Account | Swedish Name | Use |
343
+ |---------|-------------|-----|
344
+ | 2610 | Utgående moms 25% | Output VAT on sales |
345
+ | 2611 | Utgående moms 12% | Output VAT 12% |
346
+ | 2612 | Utgående moms 6% | Output VAT 6% |
347
+ | 2614 | Utgående moms omvänd skattskyldighet | Output VAT (reverse charge liability) |
348
+ | 2640 | Ingående moms | Input VAT (general) |
349
+ | 2641 | Ingående moms | Input VAT on domestic purchases |
350
+ | 2645 | Ingående moms omvänd skattskyldighet | Input VAT (reverse charge deduction) |
351
+ | 2650 | Momsredovisningskonto | VAT settlement/clearing |
352
+
353
+ ## VAT Reporting Periods
354
+
355
+ | Annual Turnover | Reporting Frequency |
356
+ |-----------------|---------------------|
357
+ | > SEK 40 million | Monthly |
358
+ | SEK 1-40 million | Quarterly (or monthly by choice) |
359
+ | < SEK 1 million | Annually (or quarterly by choice) |
360
+
361
+ ## Common Scenarios
362
+
363
+ ### US SaaS Subscription (GitHub, AWS, Anthropic)
364
+ - Tax code: \`SE_VAT_25_PURCHASE_NON_EU_SERVICES_RC\`
365
+ - Expense account: 5422 (Software/online services)
366
+ - Balancing: 2820 (credit card) or 2440 (payables)
367
+
368
+ ### EU Software/Service (Hetzner, OVH)
369
+ - Tax code: \`SE_VAT_25_PURCHASE_EU_SERVICES_RC\`
370
+ - Expense account: 5422 or appropriate 5xxx/6xxx
371
+ - Balancing: 2440 or 2820
372
+
373
+ ### Swedish Accounting Service (Bokio, Fortnox)
374
+ - Tax code: \`SE_VAT_25_PURCHASE_DOMESTIC\`
375
+ - Expense account: 6530 (Accounting services)
376
+ - Balancing: 2440
377
+
378
+ ### Bank Charges (Swedish Bank)
379
+ - Tax code: \`SE_VAT_EXEMPT_PURCHASE\` (financial services exempt)
380
+ - Expense account: 6570 (Bank charges)
381
+ - No VAT accounts involved
382
+
383
+ ### Domain Registration (EU or US Registrar)
384
+ - EU: \`SE_VAT_25_PURCHASE_EU_SERVICES_RC\`
385
+ - US: \`SE_VAT_25_PURCHASE_NON_EU_SERVICES_RC\`
386
+ - Expense account: 6230 (Data communication)
387
+ `,
388
+ };
@@ -0,0 +1,2 @@
1
+ import type { Skill } from "./types";
2
+ export declare const TRAVEL_EXPENSES_SKILL: Skill;
@@ -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,5 @@
1
+ export interface Skill {
2
+ name: string;
3
+ description: string;
4
+ content: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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
- ### Common Tax Code Patterns
130
+ For detailed VAT/tax code guidance, run \`npx ledgit-cli skills swedish-bookkeeping\`.
108
131
 
109
- | Scenario | Tax Code | Accounts |
110
- |----------|----------|----------|
111
- | Domestic purchase 25% | \`SE_VAT_25_PURCHASE_DOMESTIC\` | Expense + 2641 + 2440 |
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
- Swedish BAS account codes are organized by ranges:
176
-
177
- - **1xxx** - Assets (Tillgångar)
178
- - **2xxx** - Liabilities & Equity (Skulder och eget kapital)
179
- - **3xxx** - Revenue (Intäkter)
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moatless/bookkeeping",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },