@mostajs/wagon-engine 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  **Auteur** : Dr Hamid MADANI <drmdh@msn.com>
4
4
  Format : Keep a Changelog ; versions : SemVer.
5
5
 
6
+ ## [0.4.1] — 2026-10-28
7
+
8
+ ### Corrigé
9
+ - **Le prix de l'inscription suit les moyens de paiement actifs** : la monnaie de chaque banque prépayée (Chargily :
10
+ DZD), puis l'euro si Stripe est actif. Une école payant en dinars voyait « 19,00 €/mois » sur « Créer un compte »
11
+ et « 8 000 DZD » sur les tarifs (Speaking, 28/10). Demande `@mostajs/wagon-ui` ≥ 0.10.1. Essai T-ENG-11.
12
+
6
13
  ## [0.4.0] — 2026-10-27
7
14
 
8
15
  ### Ajouté
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/wagon-engine",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Le wagon d'un SaaS, une fois pour toutes : comptes, connexion, paliers, quotas, paiement (Stripe, Chargily, SATIM), espace client, administration, pages légales, fr/en/ar. Une greffe n'apporte que wagon.config.mjs, charge/, legal/ et son .env ; la suite de conformité publiée juge la greffe.",
5
5
  "keywords": [
6
6
  "mostajs",
@@ -52,7 +52,7 @@
52
52
  "@mostajs/orm": "^2.12.1",
53
53
  "@mostajs/payment": "^2.6.0",
54
54
  "@mostajs/subscriptions-plan": "^0.9.0",
55
- "@mostajs/wagon-ui": "^0.10.0",
55
+ "@mostajs/wagon-ui": "^0.10.1",
56
56
  "better-sqlite3": "^12.11.1",
57
57
  "stripe": "^17.7.0"
58
58
  },
package/src/wagon.mjs CHANGED
@@ -602,14 +602,23 @@ export async function creerWagon({ config, charge, sgbd, baseUrl, stripe = null,
602
602
  if (chemin === '/inscription') {
603
603
  const tous = await paliersEnBase();
604
604
  const palierDe = (slug) => tous.find((p) => p.slug === slug && p.active !== false) ?? tous.find((p) => p.slug === (config.planGratuit ?? 'gratuit'));
605
+ // 0.4.1 — le prix montré est celui des moyens ACTIFS : la monnaie de chaque banque prépayée, puis l'euro de Stripe
606
+ // (une école payant en dinars voyait l'euro de Stripe ici, et les dinars sur /tarifs).
607
+ const prixDe = (p) => {
608
+ if (!p) return null;
609
+ const pp = typeof p.prepaid === 'string' ? JSON.parse(p.prepaid || 'null') : p.prepaid;
610
+ const l = [...new Set(Object.values(banques))].filter((dv) => Number(pp?.[dv]?.month) > 0).map((dv) => ({ centimes: Number(pp[dv].month), devise: dv }));
611
+ if (stripe && Number(p.price) > 0) l.push({ centimes: Number(p.price), devise: 'EUR' });
612
+ return l.length ? l : null;
613
+ };
605
614
  const suite = suiteSure(url.searchParams.get('suite'));
606
615
  const action = avecSuite('/inscription', suite);
607
- if (methode === 'GET') return envoyer(200, page({ titre: t('inscription.titre'), contenu: ui.inscription({ lang, palier: palierDe(url.searchParams.get('plan')), methode: methodeConnexion, minMotDePasse: motsDePasse.policy.minLength, action }) }));
616
+ if (methode === 'GET') return envoyer(200, page({ titre: t('inscription.titre'), contenu: ui.inscription({ lang, palier: palierDe(url.searchParams.get('plan')), prix: prixDe(palierDe(url.searchParams.get('plan'))), methode: methodeConnexion, minMotDePasse: motsDePasse.policy.minLength, action }) }));
608
617
  if (!freinInscription.take(`ip:${ipClient(req)}`).ok) return envoyer(429, page({ titre: t('inscription.titre'), contenu: `<p class="msg">${esc((TEXTES_COMPTE[lang] ?? TEXTES_COMPTE.fr).trop)}</p>` }), { 'retry-after': '60' });
609
618
  const f = await formulaire();
610
619
  const palier = palierDe(f.plan);
611
620
  const courriel = String(f.courriel ?? '').trim().toLowerCase();
612
- const refus = (m) => envoyer(200, page({ titre: t('inscription.titre'), contenu: ui.inscription({ lang, palier, erreur: m, methode: methodeConnexion, minMotDePasse: motsDePasse.policy.minLength, action }) }));
621
+ const refus = (m) => envoyer(200, page({ titre: t('inscription.titre'), contenu: ui.inscription({ lang, palier, prix: prixDe(palier), erreur: m, methode: methodeConnexion, minMotDePasse: motsDePasse.policy.minLength, action }) }));
613
622
  if (!COURRIEL.test(courriel) || !String(f.nom ?? '').trim()) return refus(t('inscription.courrielAide'));
614
623
  if (await d.findOne(S.User, { email: courriel })) return refus(t('inscription.deja'));
615
624
  if (methodeConnexion === 'motdepasse') {