📦 danniefraim / gmail-to-fortnox

📄 config.example.json · 62 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62{
  "gmail": {
    "credentials_file": "credentials.json",
    "token_file": "token.json",
    "scopes": ["https://www.googleapis.com/auth/gmail.readonly"]
  },
  "fortnox": {
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "redirect_uri": "http://localhost:8000/callback",
    "base_url": "https://api.fortnox.se/3",
    "scopes": ["bookkeeping", "archive", "connectfile"]
  },
  "email_rules": [
    {
      "sender": "no_reply@email.apple.com",
      "subject": "",
      "body_contains": "iCloud+ med 6 TB lagrings­utrymme",
      "data_extraction": {
        "total_amount": {
          "pattern": "(?:betalat|avgift|SEK|kr)[\\s:]*([0-9]+[,.]?[0-9]*)",
          "default": 399.00
        }
      },
      "accounting": {
        "description": "Apple iCloud",
        "series": "F",
        "entries": [
          {"account": "6540", "debit": "total_amount * 0.8", "credit": 0},
          {"account": "2641", "debit": "total_amount * 0.2", "credit": 0},
          {"account": "2820", "debit": 0, "credit": "total_amount"}
        ]
      }
    },
    {
      "sender": "another-example@example.com",
      "subject": "Monthly Subscription",
      "body_contains": ["Your subscription fee", "Payment due"],
      "data_extraction": {
        "base_amount": {
          "pattern": "Amount: \\$([0-9]+\\.?[0-9]*)",
          "html_pattern": "<td[^>]*>\\$([0-9]+\\.?[0-9]*)</td>",
          "default": 100.00
        },
        "tax_percent": {
          "pattern": "Tax: ([0-9]+)%",
          "default": 25
        }
      },
      "accounting": {
        "description": "Example Subscription",
        "series": "F",
        "entries": [
          {"account": "6500", "debit": "base_amount", "credit": 0},
          {"account": "2641", "debit": "base_amount * (tax_percent/100)", "credit": 0},
          {"account": "2820", "debit": 0, "credit": "base_amount * (1 + tax_percent/100)"}
        ]
      }
    }
  ]
}