initial webapp
This commit is contained in:
1 parent
6c989c338c
commit
d32f2b3a66
18 files changed
+1145
-16
No files matched your search
@@ -53,3 +53,40 @@ State is only persisted once the input reaches EOF, so a crash or `Ctrl-C` befor
|
||||
All Euro values are rounded to cents (2 decimal places) but internal calculations use the statement values with full precision.
|
||||
There are no explicit rules or details about how to round Euro values in Anexo J.
|
||||
This application rounds according to `Portaria n.º 1180/2001, art. 2.º, alínea c) e d)` (Ministerial Order / Government Order) examples, which imply we should round to the 2nd decimal place by rounding up (ceiling) or down (floor) depending on whether the third decimal place is ≥ 5 or < 5, respectively.
|
||||
|
||||
## Web app
|
||||
|
||||
A minimal single-user web frontend is bundled in the `cmd/any2anexoj-web` binary. It reuses the existing `internal/trading212` parser, the `internal.BuildReport` pipeline, and the `internal/prettyprinter` formatter, so the rendered table is byte-for-byte identical to the CLI output.
|
||||
|
||||
### Run
|
||||
|
||||
```bash
|
||||
go run ./cmd/any2anexoj-web
|
||||
```
|
||||
|
||||
The server listens on `:8080` by default. Override the port with the `PORT` environment variable:
|
||||
|
||||
```bash
|
||||
PORT=9000 go run ./cmd/any2anexoj-web
|
||||
```
|
||||
|
||||
Then open <http://localhost:8080> in a browser, pick a Trading212 CSV file, and click **Upload**. The rendered Anexo J table appears below the form along with the row count.
|
||||
|
||||
### API
|
||||
|
||||
The web app exposes two JSON endpoints. Auth is intentionally stubbed (a no-op middleware), and state is kept in process memory only — single user, no persistence.
|
||||
|
||||
| Method | Path | Description |
|
||||
|--------|----------------|---------------------------------------------------------------------------------------------------|
|
||||
| POST | `/api/upload` | `multipart/form-data` with a `csv` file field. Returns `{"table": "<rendered>", "rows": <int>}`. |
|
||||
| GET | `/api/table` | Returns the most recently rendered table (`{"table": "", "rows": 0}` if none uploaded yet). |
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
curl -F csv=@trading212-small.csv http://localhost:8080/api/upload
|
||||
curl http://localhost:8080/api/table
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> The web app is single-user and in-memory. Uploads overwrite the previously stored table, and restarting the server clears all state. Auth is a stub — do not expose this service to the public internet without adding real authentication and per-user state first.
|
||||
Reference in new issue
Block a user