feat(articles): expose and filter code centrale (artcentrale)
The code centrale is LaFoir'Fouille's 11-digit product identifier
(prefix 1000x). Only products referenced by the central purchasing
office have one: ~355 800 of 427 700 articles.
The column was already synced from SQL Server and returned by the
detail route via `a.*`, but was absent from the list route and could
not be filtered on.
- list route: select artcentrale, add `artcentrale` (partial match)
and `has_artcentrale=1|0` query params
- filter matches on prefix AND length 11, so malformed values with a
valid prefix ('10000', '10000192289P') are excluded
- COALESCE in the predicate: without it, NOT (NULL LIKE '1000%') is
NULL and the 61 442 NULL rows would vanish from has_artcentrale=0
- normalise '' to null in both routes so they agree
- sync: use safeStr so empty values are stored as NULL, not ''
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
62249e6c13
commit
f00b9c4b14
3 files changed
+30
-5
No files matched your search
+10
-1
@@ -32,9 +32,17 @@ GET /api/articles
|
||||
| `ean` | string | EAN / GTIN | — |
|
||||
| `codefou` | string | Code fournisseur (partiel) | — |
|
||||
| `actif` | `1`/`0`| `1` = actif, `0` = suspendu | — |
|
||||
| `artcentrale` | string | Code centrale (partiel) | — |
|
||||
| `has_artcentrale` | `1`/`0` | `1` = référencé centrale, `0` = non référencé | — |
|
||||
| `page` | int | Numéro de page | 1 |
|
||||
| `limit` | int | Lignes par page (max 500) | 50 |
|
||||
|
||||
> **Code centrale** (`artcentrale`) : identifiant LaFoir'Fouille sur 11 chiffres, préfixe `1000x`
|
||||
> (ex. `10000137005`). Seuls les produits référencés par la centrale en possèdent un —
|
||||
> environ 355 800 articles sur 427 700. Pour les autres, le champ vaut `null`.
|
||||
> `has_artcentrale=1` ne retient que les codes conformes : quelques valeurs parasites
|
||||
> (`10000`, `10000192289P`) ont le bon préfixe mais pas la bonne longueur, et sont exclues.
|
||||
|
||||
**Réponse** :
|
||||
```json
|
||||
{
|
||||
@@ -54,6 +62,7 @@ GET /api/articles
|
||||
"suspendu": null,
|
||||
"suividatecreation": "2020-01-15T00:00:00.000Z",
|
||||
"suividatemodif": "2024-06-01T00:00:00.000Z",
|
||||
"artcentrale": "10000137005",
|
||||
"prix_vente_mini": 15.00,
|
||||
"prix_vente_maxi": 25.00,
|
||||
"eco_ttc": 0.10,
|
||||
@@ -85,7 +94,7 @@ GET /api/articles/:id
|
||||
**Réponse** :
|
||||
```json
|
||||
{
|
||||
"article": { "no_id": 12345, "codein": "...", "libelle1": "...", "pa": 10.50, "..." : "..." },
|
||||
"article": { "no_id": 12345, "codein": "...", "libelle1": "...", "artcentrale": "10000137005", "pa": 10.50, "..." : "..." },
|
||||
"gtins": [
|
||||
{ "gtin": "3760000000001", "preferentiel": 1 }
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user