meta {
  name: 02 List with stats
  type: http
  seq: 2
}

get {
  url: {{baseUrl}}/api/v1/clients?withStats=1
  body: none
  auth: inherit
}

params:query {
  withStats: 1
}

tests {
  test("200 OK", function () {
    expect(res.getStatus()).to.equal(200);
  });
  test("clients are enriched", function () {
    const list = res.getBody().data;
    if (list.length > 0) {
      expect(list[0]).to.have.property("invoiceCount");
      expect(list[0]).to.have.property("lateInvoiceCount");
      expect(list[0]).to.have.property("paidLifetimeCents");
    }
  });
}

docs {
  GET /api/v1/clients?withStats=1

  Liste enrichie pour la page /clients. Chaque client expose :
  - `invoiceCount` (total)
  - `activeInvoiceCount` / `lateInvoiceCount`
  - `paidInvoiceCount` / `paidLifetimeCents`
  - `pendingLifetimeCents`
  - `lastActivityAt`

  Tri : retards d'abord (actionnable), puis activité récente.
}
