leancpms-cli 0.1.2__tar.gz → 0.1.5__tar.gz
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.
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/PKG-INFO +22 -13
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/README.md +21 -12
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/cli/main.py +72 -66
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/manifest/schema.py +37 -1
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/pyproject.toml +1 -1
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/.gitignore +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/LICENSE +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/__init__.py +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/cli/__init__.py +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/cli/client.py +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/cli/login.py +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/manifest/__init__.py +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/cpms/manifest/documents.py +0 -0
- {leancpms_cli-0.1.2 → leancpms_cli-0.1.5}/hatch_build.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: leancpms-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: The cpms command alone: a client of a LeanCPMS instance's JSON API
|
|
5
5
|
License-Expression: AGPL-3.0-or-later
|
|
6
6
|
License-File: LICENSE
|
|
@@ -13,7 +13,7 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
# `cpms`, the LeanCPMS command line
|
|
14
14
|
|
|
15
15
|
`cpms` manages an organization in a LeanCPMS instance from your own
|
|
16
|
-
machine: live state, sessions, the monthly
|
|
16
|
+
machine: live state, sessions, the monthly settlements, and the declared
|
|
17
17
|
state (organization, price list, sites) as YAML documents you can keep in
|
|
18
18
|
a git repository. It talks to the instance's JSON API over HTTPS with an
|
|
19
19
|
API key, and the same commands work for people and for AI agents.
|
|
@@ -23,25 +23,25 @@ depends on httpx, pydantic and PyYAML only.
|
|
|
23
23
|
|
|
24
24
|
## Install
|
|
25
25
|
|
|
26
|
-
With [uv](https://docs.astral.sh/uv/), from PyPI
|
|
26
|
+
With [uv](https://docs.astral.sh/uv/), from PyPI:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
uv tool install leancpms-cli
|
|
30
30
|
cpms --help
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
from the repository:
|
|
33
|
+
That needs no access to the repository. With access, also from a GitHub
|
|
34
|
+
release (a tag `cli-v<version>`) or straight from the repository:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
gh release download cli-v0.1.
|
|
38
|
-
uv tool install ./leancpms_cli-0.1.
|
|
37
|
+
gh release download cli-v0.1.4 --repo forsslund/leancpms --pattern '*.whl'
|
|
38
|
+
uv tool install ./leancpms_cli-0.1.4-py3-none-any.whl
|
|
39
39
|
# or
|
|
40
40
|
uv tool install "git+https://github.com/forsslund/leancpms#subdirectory=cli"
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
- The repository is private for now, so
|
|
44
|
-
GitHub; over SSH the URL is
|
|
43
|
+
- The repository is private for now, so these two need read access to it
|
|
44
|
+
on GitHub; over SSH the URL is
|
|
45
45
|
`git+ssh://git@github.com/forsslund/leancpms#subdirectory=cli`.
|
|
46
46
|
- It needs Python 3.14. uv downloads it if your machine lacks it.
|
|
47
47
|
- To get a newer version, run `uv tool upgrade leancpms-cli`. To pin a
|
|
@@ -78,6 +78,8 @@ cpms logout # revokes the key on the server and removes the profile
|
|
|
78
78
|
The key stops working when you are removed as a member, and so does
|
|
79
79
|
every key you issued with it. Approve a code only if you just ran
|
|
80
80
|
`cpms login` yourself: whoever started it gets the key.
|
|
81
|
+
[`docs/users-and-access.md`](../docs/users-and-access.md) explains members, roles and keys in full, with
|
|
82
|
+
several computers, a lost computer, and common tasks.
|
|
81
83
|
|
|
82
84
|
### Machine keys, for CI and agents
|
|
83
85
|
|
|
@@ -113,7 +115,7 @@ A networked command that has neither exits 2 and says what to set.
|
|
|
113
115
|
```bash
|
|
114
116
|
cpms # live state: sites, fuse groups, outlets, current per phase
|
|
115
117
|
cpms sessions --since 2026-10-01
|
|
116
|
-
cpms report
|
|
118
|
+
cpms report settlements --month 2026-10 # the month's settlements per site, with bookkeeping proposals
|
|
117
119
|
cpms manifest export kvartersel > all.yaml
|
|
118
120
|
cpms manifest export kvartersel --site odalvagen > sites/odalvagen.yaml
|
|
119
121
|
cpms manifest validate sites/odalvagen.yaml # offline: the schema
|
|
@@ -144,6 +146,12 @@ document that changed on the server since your plan; plan again. Removing
|
|
|
144
146
|
anything needs `--prune`. `validate` needs no key, so CI can run it on
|
|
145
147
|
every pull request; `plan` needs one.
|
|
146
148
|
|
|
149
|
+
An outlet's `public_id` is the id in its QR code (`/c/<public_id>`). Leave
|
|
150
|
+
it out and the server makes one up on first apply and keeps it. Once the
|
|
151
|
+
codes are printed, write the ids into the site file
|
|
152
|
+
(`- {connector: 1, key: s1-1, public_id: h7k2m9pq}`): a declared id applies,
|
|
153
|
+
also on a new server, and `plan` warns before an outlet's id changes.
|
|
154
|
+
|
|
147
155
|
## In your editor: the JSON Schema
|
|
148
156
|
|
|
149
157
|
The documents have a JSON Schema, so an editor can complete field names
|
|
@@ -173,8 +181,9 @@ line, so add it again after an export.
|
|
|
173
181
|
The schema checks types, required and unknown fields, allowed values,
|
|
174
182
|
key spelling, and that amounts are quoted (`"4.70"`, not `4.70`). It does
|
|
175
183
|
not check anything that spans several fields: a budget above the fuse,
|
|
176
|
-
duplicate keys or
|
|
177
|
-
time zone. `validate` and `plan` check those.
|
|
184
|
+
duplicate keys, ocpp ids or public ids, a plan naming a missing tariff, or
|
|
185
|
+
an unknown time zone. `validate` and `plan` check those. Only `plan`
|
|
186
|
+
knows whether another outlet on the server already has a public id.
|
|
178
187
|
|
|
179
188
|
## For agents
|
|
180
189
|
|
|
@@ -194,7 +203,7 @@ Raise `version` in both `cli/pyproject.toml` and the root `pyproject.toml`
|
|
|
194
203
|
(a test keeps them equal), then tag and push:
|
|
195
204
|
|
|
196
205
|
```bash
|
|
197
|
-
git tag cli-v0.1.
|
|
206
|
+
git tag cli-v0.1.4 && git push origin cli-v0.1.4
|
|
198
207
|
```
|
|
199
208
|
|
|
200
209
|
`.github/workflows/release-cli.yml` builds the wheel and sdist, smoke-tests
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# `cpms`, the LeanCPMS command line
|
|
2
2
|
|
|
3
3
|
`cpms` manages an organization in a LeanCPMS instance from your own
|
|
4
|
-
machine: live state, sessions, the monthly
|
|
4
|
+
machine: live state, sessions, the monthly settlements, and the declared
|
|
5
5
|
state (organization, price list, sites) as YAML documents you can keep in
|
|
6
6
|
a git repository. It talks to the instance's JSON API over HTTPS with an
|
|
7
7
|
API key, and the same commands work for people and for AI agents.
|
|
@@ -11,25 +11,25 @@ depends on httpx, pydantic and PyYAML only.
|
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
14
|
-
With [uv](https://docs.astral.sh/uv/), from PyPI
|
|
14
|
+
With [uv](https://docs.astral.sh/uv/), from PyPI:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
uv tool install leancpms-cli
|
|
18
18
|
cpms --help
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
from the repository:
|
|
21
|
+
That needs no access to the repository. With access, also from a GitHub
|
|
22
|
+
release (a tag `cli-v<version>`) or straight from the repository:
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
gh release download cli-v0.1.
|
|
26
|
-
uv tool install ./leancpms_cli-0.1.
|
|
25
|
+
gh release download cli-v0.1.4 --repo forsslund/leancpms --pattern '*.whl'
|
|
26
|
+
uv tool install ./leancpms_cli-0.1.4-py3-none-any.whl
|
|
27
27
|
# or
|
|
28
28
|
uv tool install "git+https://github.com/forsslund/leancpms#subdirectory=cli"
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
- The repository is private for now, so
|
|
32
|
-
GitHub; over SSH the URL is
|
|
31
|
+
- The repository is private for now, so these two need read access to it
|
|
32
|
+
on GitHub; over SSH the URL is
|
|
33
33
|
`git+ssh://git@github.com/forsslund/leancpms#subdirectory=cli`.
|
|
34
34
|
- It needs Python 3.14. uv downloads it if your machine lacks it.
|
|
35
35
|
- To get a newer version, run `uv tool upgrade leancpms-cli`. To pin a
|
|
@@ -66,6 +66,8 @@ cpms logout # revokes the key on the server and removes the profile
|
|
|
66
66
|
The key stops working when you are removed as a member, and so does
|
|
67
67
|
every key you issued with it. Approve a code only if you just ran
|
|
68
68
|
`cpms login` yourself: whoever started it gets the key.
|
|
69
|
+
[`docs/users-and-access.md`](../docs/users-and-access.md) explains members, roles and keys in full, with
|
|
70
|
+
several computers, a lost computer, and common tasks.
|
|
69
71
|
|
|
70
72
|
### Machine keys, for CI and agents
|
|
71
73
|
|
|
@@ -101,7 +103,7 @@ A networked command that has neither exits 2 and says what to set.
|
|
|
101
103
|
```bash
|
|
102
104
|
cpms # live state: sites, fuse groups, outlets, current per phase
|
|
103
105
|
cpms sessions --since 2026-10-01
|
|
104
|
-
cpms report
|
|
106
|
+
cpms report settlements --month 2026-10 # the month's settlements per site, with bookkeeping proposals
|
|
105
107
|
cpms manifest export kvartersel > all.yaml
|
|
106
108
|
cpms manifest export kvartersel --site odalvagen > sites/odalvagen.yaml
|
|
107
109
|
cpms manifest validate sites/odalvagen.yaml # offline: the schema
|
|
@@ -132,6 +134,12 @@ document that changed on the server since your plan; plan again. Removing
|
|
|
132
134
|
anything needs `--prune`. `validate` needs no key, so CI can run it on
|
|
133
135
|
every pull request; `plan` needs one.
|
|
134
136
|
|
|
137
|
+
An outlet's `public_id` is the id in its QR code (`/c/<public_id>`). Leave
|
|
138
|
+
it out and the server makes one up on first apply and keeps it. Once the
|
|
139
|
+
codes are printed, write the ids into the site file
|
|
140
|
+
(`- {connector: 1, key: s1-1, public_id: h7k2m9pq}`): a declared id applies,
|
|
141
|
+
also on a new server, and `plan` warns before an outlet's id changes.
|
|
142
|
+
|
|
135
143
|
## In your editor: the JSON Schema
|
|
136
144
|
|
|
137
145
|
The documents have a JSON Schema, so an editor can complete field names
|
|
@@ -161,8 +169,9 @@ line, so add it again after an export.
|
|
|
161
169
|
The schema checks types, required and unknown fields, allowed values,
|
|
162
170
|
key spelling, and that amounts are quoted (`"4.70"`, not `4.70`). It does
|
|
163
171
|
not check anything that spans several fields: a budget above the fuse,
|
|
164
|
-
duplicate keys or
|
|
165
|
-
time zone. `validate` and `plan` check those.
|
|
172
|
+
duplicate keys, ocpp ids or public ids, a plan naming a missing tariff, or
|
|
173
|
+
an unknown time zone. `validate` and `plan` check those. Only `plan`
|
|
174
|
+
knows whether another outlet on the server already has a public id.
|
|
166
175
|
|
|
167
176
|
## For agents
|
|
168
177
|
|
|
@@ -182,7 +191,7 @@ Raise `version` in both `cli/pyproject.toml` and the root `pyproject.toml`
|
|
|
182
191
|
(a test keeps them equal), then tag and push:
|
|
183
192
|
|
|
184
193
|
```bash
|
|
185
|
-
git tag cli-v0.1.
|
|
194
|
+
git tag cli-v0.1.4 && git push origin cli-v0.1.4
|
|
186
195
|
```
|
|
187
196
|
|
|
188
197
|
`.github/workflows/release-cli.yml` builds the wheel and sdist, smoke-tests
|
|
@@ -12,10 +12,8 @@ import csv
|
|
|
12
12
|
import json
|
|
13
13
|
import os
|
|
14
14
|
import sys
|
|
15
|
-
from datetime import datetime
|
|
16
15
|
from pathlib import Path
|
|
17
16
|
from typing import Any, Callable
|
|
18
|
-
from zoneinfo import ZoneInfo
|
|
19
17
|
|
|
20
18
|
from cpms.manifest.documents import ManifestError, diff, json_schema, parse_yaml, to_data, to_yaml
|
|
21
19
|
|
|
@@ -241,72 +239,79 @@ def cmd_events(api: Api, a: argparse.Namespace) -> int:
|
|
|
241
239
|
# --- reports -------------------------------------------------------------------------------
|
|
242
240
|
|
|
243
241
|
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
def _kwh(wh: int | None) -> str:
|
|
243
|
+
return "" if wh is None else f"{wh / 1000:.3f}"
|
|
246
244
|
|
|
247
245
|
|
|
248
|
-
def
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
table(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
246
|
+
def _bookkeeping(s: dict[str, Any]) -> None:
|
|
247
|
+
"""A settlement's bookkeeping proposals: account, what it is, project, debit, credit."""
|
|
248
|
+
for v in s["bookkeeping"]:
|
|
249
|
+
when = v["date"] or "on the date of the invoice"
|
|
250
|
+
_print(f"bookkeeping proposal {when}" + (f", {v['kind']}" if v["kind"] in ("accrual", "reversal") else ""))
|
|
251
|
+
if not v["entries"]:
|
|
252
|
+
_print("nothing to book")
|
|
253
|
+
continue
|
|
254
|
+
blank = {"0.00": ""}
|
|
255
|
+
table([[e["account"], e["role"], e["project"], blank.get(e["debit"], e["debit"]),
|
|
256
|
+
blank.get(e["credit"], e["credit"])] for e in v["entries"]] + [["sum", "", "", v["debit"], v["credit"]]],
|
|
257
|
+
["ACCOUNT", "WHAT", "PROJECT", "DEBIT", "CREDIT"], right=3)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _settlement(s: dict[str, Any]) -> None:
|
|
261
|
+
"""One settlement as the portal's sheet says it: its rows per site, then its bookkeeping proposal."""
|
|
262
|
+
issued = f"issued {s['issued']}" if s["issued"] else "not final"
|
|
263
|
+
if s["kind"] == "billing":
|
|
264
|
+
what = f"roaming invoice basis, {s['partner']}" if s["source"] == "roaming" else f"billing, {s['source']}"
|
|
265
|
+
_print(f"{s['number']} {what}: {s['documents']} {'sessions' if s['source'] == 'roaming' else 'receipts'} ({issued})")
|
|
266
|
+
rows = [[x["project"], x["name"], _kwh(x["wh"]), x["amount_excl_vat"]] for x in s["sites"]]
|
|
267
|
+
rows.append(["sum excl. VAT", "", _kwh(s["wh"]), s["amount_excl_vat"]])
|
|
268
|
+
for v in s["vat"]:
|
|
269
|
+
rate = f" {float(v['rate']) * 100:g} %" if v["rate"] is not None else ""
|
|
270
|
+
rows.append([f"VAT{rate}", "", "", v["amount"]])
|
|
271
|
+
rows.append(["to invoice, incl. VAT" if s["source"] == "roaming" else "sum incl. VAT", "", "", s["amount_incl_vat"]])
|
|
272
|
+
table(rows, ["PROJECT", "SITE", "KWH", "EXCL VAT"], right=2)
|
|
273
|
+
elif s["kind"] == "payment":
|
|
274
|
+
_print(f"{s['number']} payment, {s['provider']} ({issued})")
|
|
275
|
+
table([[u["source"] or "sum", u["unpaid_before_incl_vat"], u["charged_incl_vat"], u["paid_in_incl_vat"],
|
|
276
|
+
u["unpaid_after_incl_vat"], u["difference"]] for u in [*s["unpaid"], s["unpaid_total"]]],
|
|
277
|
+
["INCL VAT", "UNPAID BEFORE", "CHARGED", "PAID IN", "UNPAID AFTER", "DIFFERENCE"], right=1)
|
|
278
|
+
table([[f["project"], f["name"], f["amount_excl_vat"]] for f in s["fees"]] + [["sum", "", s["fees_excl_vat"]]],
|
|
279
|
+
["PROJECT", "SITE", "FEE EXCL VAT"], right=2)
|
|
280
|
+
_print(f"reached the balance: {s['reached_balance']}")
|
|
281
|
+
if s["unclassified"]:
|
|
282
|
+
_print("not in this settlement (booked by hand):")
|
|
283
|
+
table([[u["what"], u["count"], u["amount"]] for u in s["unclassified"]], ["BALANCE TRANSACTION", "COUNT", "AMOUNT"],
|
|
284
|
+
right=1)
|
|
285
|
+
if not s["reconciles"]:
|
|
286
|
+
_print(f"DOES NOT RECONCILE: {', '.join(s['problems'])}")
|
|
287
|
+
else:
|
|
288
|
+
_print(f"{s['number']} accrual basis: sessions ended in the month, billed after it ({issued})")
|
|
289
|
+
sources = s["sources"]
|
|
290
|
+
table([[x["project"], x["name"], _kwh(x["wh"]), *(x["by_source_excl_vat"].get(src, "") for src in sources),
|
|
291
|
+
x["amount_excl_vat"]] for x in s["sites"]]
|
|
292
|
+
+ [["sum", "", _kwh(s["wh"]), *(s["by_source_excl_vat"][src] for src in sources), s["amount_excl_vat"]]],
|
|
293
|
+
["PROJECT", "SITE", "KWH", *(src.upper() for src in sources), "EXCL VAT"], right=2)
|
|
294
|
+
_bookkeeping(s)
|
|
280
295
|
|
|
281
296
|
|
|
282
|
-
def
|
|
283
|
-
body = api.get("/reports/
|
|
297
|
+
def cmd_settlements(api: Api, a: argparse.Namespace) -> int:
|
|
298
|
+
body = api.get("/reports/settlements", month=a.month, organization=a.org)
|
|
284
299
|
if a.json:
|
|
285
300
|
_dump(body)
|
|
286
301
|
return 0
|
|
287
|
-
p
|
|
288
|
-
_print(f"
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
_print()
|
|
299
|
-
_print("No receipt: sessions that ended in the month without one (cancelled, unpaid, or pending capture); "
|
|
300
|
-
"no money")
|
|
301
|
-
if none["sessions"]:
|
|
302
|
-
_statement_part(none, False)
|
|
303
|
-
else:
|
|
304
|
-
_print("none")
|
|
305
|
-
if body["active_sessions"]:
|
|
302
|
+
p = body["period"]
|
|
303
|
+
_print(f"Settlements {p['month']} {body['organization']} ({body['organization_name']}); amounts in {body['currency']}")
|
|
304
|
+
if body["not_final"] == "month_not_ended":
|
|
305
|
+
_print("NOT FINAL: the month has not ended")
|
|
306
|
+
elif body["not_final"]:
|
|
307
|
+
_print(f"NOT FINAL: {', '.join(body['providers_not_read'])} has not been read to the end since the month ended")
|
|
308
|
+
if body["roaming_without_cdr"]:
|
|
309
|
+
_print(f"left out: {body['roaming_without_cdr']} roaming sessions that ended in the month without a CDR yet")
|
|
310
|
+
if body["receipts_without_session"]:
|
|
311
|
+
_print(f"{body['receipts_without_session']} receipts have no session; placed by the site name on the receipt")
|
|
312
|
+
for s in body["settlements"]:
|
|
306
313
|
_print()
|
|
307
|
-
|
|
308
|
-
for w in body["warnings"]:
|
|
309
|
-
_err(f"warning: {w}")
|
|
314
|
+
_settlement(s)
|
|
310
315
|
return 0
|
|
311
316
|
|
|
312
317
|
|
|
@@ -820,13 +825,14 @@ def parser() -> argparse.ArgumentParser:
|
|
|
820
825
|
s.add_argument("--event")
|
|
821
826
|
s.add_argument("--limit", type=int, default=100)
|
|
822
827
|
|
|
823
|
-
r = sub.add_parser("report", parents=[common], help="reports: the monthly
|
|
828
|
+
r = sub.add_parser("report", parents=[common], help="reports: the monthly settlements")
|
|
824
829
|
rsub = r.add_subparsers(dest="report_command", parser_class=_Parser, required=True)
|
|
825
|
-
s = rsub.add_parser("
|
|
826
|
-
"
|
|
827
|
-
description="The monthly
|
|
828
|
-
|
|
829
|
-
s.
|
|
830
|
+
s = rsub.add_parser("settlements", parents=[common],
|
|
831
|
+
help="a month's settlements: drop-in, roaming invoice basis, payment provider, accrual basis",
|
|
832
|
+
description="The monthly settlements (PRD §6.1): per site, each with its bookkeeping proposal. "
|
|
833
|
+
"The same figures as the portal's sheets, which are the ones to print.")
|
|
834
|
+
s.set_defaults(fn=cmd_settlements)
|
|
835
|
+
s.add_argument("--month", help="YYYY-MM in the organization's time zone (default: the last month that has ended)")
|
|
830
836
|
s.add_argument("--org", help="operator: which organization (an organization key knows its own)")
|
|
831
837
|
|
|
832
838
|
m = sub.add_parser("manifest", parents=[common], help="declared state: export, plan, apply, history, diff, validate, schema")
|
|
@@ -70,6 +70,12 @@ def _not_reserved(value: str) -> str:
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
OrganizationKey = Annotated[Key, AfterValidator(_not_reserved)]
|
|
73
|
+
|
|
74
|
+
# An outlet's public id, the last part of its QR code's URL (/c/<public_id>). The server generates
|
|
75
|
+
# one from this alphabet (no 0, 1, i, l or o, which read alike) unless the site document declares it.
|
|
76
|
+
PUBLIC_ID_ALPHABET = "23456789abcdefghjkmnpqrstuvwxyz"
|
|
77
|
+
PUBLIC_ID_LENGTH = 8
|
|
78
|
+
PublicId = Annotated[str, StringConstraints(pattern=rf"^[{PUBLIC_ID_ALPHABET}]{{{PUBLIC_ID_LENGTH}}}$")]
|
|
73
79
|
Rate = Annotated[Decimal, BeforeValidator(_no_float), Field(ge=0, le=1), _DECIMAL_TEXT]
|
|
74
80
|
|
|
75
81
|
|
|
@@ -116,6 +122,27 @@ DriverOrigin = Annotated[
|
|
|
116
122
|
]
|
|
117
123
|
|
|
118
124
|
|
|
125
|
+
# A ledger account in the organization's bookkeeping, as its chart of accounts writes it.
|
|
126
|
+
Account = Annotated[str, StringConstraints(pattern=r"^[0-9A-Za-z][0-9A-Za-z.-]{0,15}$")]
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class BookkeepingAccounts(Strict):
|
|
130
|
+
"""The accounts the monthly settlements' bookkeeping proposals name (architecture §8).
|
|
131
|
+
|
|
132
|
+
The defaults are suggestions from the Swedish BAS chart, for the organization's accountant to
|
|
133
|
+
confirm. Revenue has one account per source; the project on each row is the site's key.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
receivables: Account = "1510"
|
|
137
|
+
accrued_revenue: Account = "1790"
|
|
138
|
+
provider_balance: Account = "1940" # the balance at the payment provider, treated as a bank account
|
|
139
|
+
output_vat: Account = "2611"
|
|
140
|
+
bank_charges: Account = "6570" # the payment provider's fees
|
|
141
|
+
revenue_dropin: Account = "3001"
|
|
142
|
+
revenue_subscription: Account = "3002"
|
|
143
|
+
revenue_roaming: Account = "3003"
|
|
144
|
+
|
|
145
|
+
|
|
119
146
|
class Organization(Strict):
|
|
120
147
|
key: OrganizationKey
|
|
121
148
|
name: str
|
|
@@ -134,6 +161,8 @@ class Organization(Strict):
|
|
|
134
161
|
# The organization's own driver front ends, on domains of its own: they may call the driver API's
|
|
135
162
|
# start and session endpoints from a browser, and payment may return to them (architecture §3.1).
|
|
136
163
|
driver_origins: list[DriverOrigin] = []
|
|
164
|
+
# The accounts in the monthly settlements' bookkeeping proposals; left out, the suggested ones.
|
|
165
|
+
bookkeeping_accounts: BookkeepingAccounts = BookkeepingAccounts()
|
|
137
166
|
|
|
138
167
|
@model_validator(mode="after")
|
|
139
168
|
def _unique_hosts(self): # type: ignore[no-untyped-def]
|
|
@@ -321,6 +350,11 @@ class Outlet(Strict):
|
|
|
321
350
|
plug: Literal["type2_socket", "type2_cable"] | None = None
|
|
322
351
|
phases: Literal[1, 3] | None = None
|
|
323
352
|
evse_id: Annotated[str, StringConstraints(max_length=48)] | None = None # overrides the derived eMI3 id
|
|
353
|
+
# The id in the printed QR code, a physical fact once printed. Left out, the server generates one
|
|
354
|
+
# on first apply and keeps it; declared, it applies, also over one generated before.
|
|
355
|
+
public_id: PublicId | None = Field(default=None, description=(
|
|
356
|
+
f"the id in the outlet's printed QR code (/c/<public_id>): {PUBLIC_ID_LENGTH} characters from "
|
|
357
|
+
f"{PUBLIC_ID_ALPHABET}; left out, the server generates one on first apply and keeps it"))
|
|
324
358
|
|
|
325
359
|
|
|
326
360
|
class ChargePoint(Strict):
|
|
@@ -392,7 +426,9 @@ class Site(Strict):
|
|
|
392
426
|
cps = [cp for fg in self.fuse_groups for cp in fg.charge_points]
|
|
393
427
|
_unique(cps, "key", "charge point")
|
|
394
428
|
_unique(cps, "ocpp_id", "ocpp_id")
|
|
395
|
-
|
|
429
|
+
outlets = [o for cp in cps for o in cp.outlets]
|
|
430
|
+
_unique(outlets, "key", "outlet")
|
|
431
|
+
_unique([o for o in outlets if o.public_id], "public_id", "public_id")
|
|
396
432
|
return self
|
|
397
433
|
|
|
398
434
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|