meta { name: 04 Validate draft type: http seq: 4 } post { url: {{baseUrl}}/api/v1/invoices/import-batch/{{batchId}}/drafts/{{draftId}}/validate body: json auth: inherit } body:json { { "clientId": null, "clientName": "Atelier Durand", "clientEmail": "compta@atelier-durand.fr", "numero": "F-2026-0039", "amountTtcCents": 360000, "issueDate": "2026-04-01T09:00:00.000Z", "dueDate": "2026-05-01T09:00:00.000Z", "planId": null } } script:post-response { if (res.getStatus() === 201) { bru.setEnvVar("invoiceId", res.getBody().data.id); } } tests { test("201 Created", function () { expect(res.getStatus()).to.equal(201); }); test("invoice rubisEarned = 1 (bonus import)", function () { expect(res.getBody().data.rubisEarned).to.equal(1); }); } docs { POST /api/v1/invoices/import-batch/:id/drafts/:draftId/validate L'utilisateur a (potentiellement édité puis) validé un draft → on crée l'Invoice avec les champs envoyés. Résolution client identique à POST /invoices (cf. service `resolveClient`) : 1. clientId fourni → utilise tel quel 2. match par nom (case-insensitive) sur les clients existants 3. création à la volée → clientEmail REQUIS sinon 422 `client_email_required` Le draft passe `pending` → `validated` et capture l'`invoiceId`. Erreurs : - 404 not_found (batch ou draft inexistant) - 409 draft_already_processed (déjà validated/skipped) - 422 client_email_required (création de client sans email) }