1d3ee69c6d
App Flutter de programme de fidélité : login staff, clients (nom/prénom), scan QR, factures (€→points), récompenses, réglages. Backend Supabase (schéma SQL + RLS anti-triche dans supabase/). Icône incluse. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
1.1 KiB
Dart
32 lines
1.1 KiB
Dart
import 'package:intl/intl.dart';
|
|
|
|
final NumberFormat _euro = NumberFormat.currency(locale: 'fr_FR', symbol: '€');
|
|
final DateFormat _dateHeure = DateFormat('d MMM y • HH:mm', 'fr_FR');
|
|
|
|
String euro(double v) => _euro.format(v);
|
|
|
|
/// Formate un nombre de points de façon lisible :
|
|
/// entier sans décimale (« 12 pts »), sinon jusqu'à 2 décimales sans zéros
|
|
/// inutiles (« 0,48 pt », « 2,5 pts »). Gère le singulier/pluriel.
|
|
String points(double v) {
|
|
final arrondi = (v * 100).round() / 100;
|
|
var s = arrondi == arrondi.roundToDouble()
|
|
? arrondi.toInt().toString()
|
|
: arrondi
|
|
.toStringAsFixed(2)
|
|
.replaceAll(RegExp(r'0+$'), '')
|
|
.replaceAll(RegExp(r'\.$'), '');
|
|
s = s.replaceAll('.', ',');
|
|
final abs = arrondi.abs();
|
|
final pluriel = abs >= 2 ? 'pts' : 'pt';
|
|
return '$s $pluriel';
|
|
}
|
|
|
|
/// Comme [points] mais sans le suffixe « pt/pts » (pour les gros affichages).
|
|
String pointsNombre(double v) {
|
|
final complet = points(v);
|
|
return complet.replaceAll(RegExp(r'\s?pts?$'), '');
|
|
}
|
|
|
|
String dateHeure(DateTime d) => _dateHeure.format(d);
|