This commit is contained in:
seb
2026-07-31 05:46:33 +02:00
parent a57e81fe30
commit b99c3a9ec7
4 changed files with 14 additions and 26 deletions

View File

@@ -27,23 +27,11 @@ SQL lives in `src/sql/<table>.js`. Schema DDL: `src/schema.js` / `import 'libdas
| Method | Signature | Returns |
| --- | --- | --- |
| `create` | `({ iso639, name, taxrate, reducedtaxrate })` | result |
| `update` | `(id, { iso639, name, taxrate, reducedtaxrate })` | result |
| `create` | `({ iso639, name, taxrate, reducedtaxrate })` | `{ id, root_category_id, language_id, taxrate_id, reducedtaxrate_id, taxfreerate_id }` |
| `update` | `(id, { iso639, name, taxrate, reducedtaxrate })` | `{ id, root_category_id, language_id, taxrate_id, reducedtaxrate_id, taxfreerate_id }` |
| `delete` | `(companyId)` | `void` |
| `list` | `()` | `result[]` |
| `list` | `()` | `{ id, root_category_id, language_id, taxrate_id, reducedtaxrate_id, taxfreerate_id }[]` |
### result (`create` / `update` / `list` items)
```ts
{
id: number // company id
root_category_id: number
language_id: number // language.id for iso639
taxrate: number // tax.id
reducedtaxrate: number // tax.id
taxfreerate: number // tax.id (rate 0; unchanged on update)
}
```
### `create` (transaction)
@@ -51,7 +39,7 @@ For `POST /api/company`:
1. Fails if `name` is taken (`Company name not available`)
2. Ensures language by `iso639` (get or create)
3. Ensures tax rows for `taxrate`, `reducedtaxrate`, and `0` → `taxfreerate`
3. Ensures tax rows for `taxrate`, `reducedtaxrate`, and `0` → `taxfreerate_id`
4. Creates root category (`parent_id = null`)
5. Inserts company with all FKs set
@@ -62,7 +50,7 @@ For `PATCH /api/company/:id`:
1. Fails if company missing / name taken by another company
2. Ensures lang + tax rates
3. Updates `name`, `default_language_id`, `taxrate`, `reducedtaxrate`
(`taxfreerate` / root category unchanged)
(`taxfreerate_id` / root category unchanged)
---