Initial commit — app fidélité magasin (tablette)
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>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/// Type d'un mouvement de points dans l'historique d'un client.
|
||||
class TypeMouvement {
|
||||
static const facture = 'facture'; // gain de points suite à un achat
|
||||
static const recompense = 'recompense'; // dépense de points sur une récompense
|
||||
static const ajustement = 'ajustement'; // correction manuelle (+/-)
|
||||
}
|
||||
|
||||
/// Une ligne d'historique : gain (facture) ou dépense (récompense) de points
|
||||
/// pour un client donné.
|
||||
class Mouvement {
|
||||
final String id;
|
||||
final String clientId;
|
||||
|
||||
/// Voir [TypeMouvement].
|
||||
final String type;
|
||||
|
||||
/// Montant de la facture en euros (uniquement pour [TypeMouvement.facture]).
|
||||
final double? montantEuros;
|
||||
|
||||
/// Points crédités (positif) ou débités (négatif).
|
||||
final double points;
|
||||
|
||||
/// Libellé lisible, ex : « Facture 25,00 € » ou « Café offert ».
|
||||
final String libelle;
|
||||
|
||||
/// Date du mouvement.
|
||||
final DateTime date;
|
||||
|
||||
const Mouvement({
|
||||
required this.id,
|
||||
required this.clientId,
|
||||
required this.type,
|
||||
this.montantEuros,
|
||||
required this.points,
|
||||
required this.libelle,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
bool get estGain => points >= 0;
|
||||
|
||||
factory Mouvement.fromMap(Map<String, dynamic> map) {
|
||||
return Mouvement(
|
||||
id: map['id'].toString(),
|
||||
clientId: map['client_id'].toString(),
|
||||
type: (map['type'] as String?) ?? TypeMouvement.ajustement,
|
||||
montantEuros: (map['montant_euros'] as num?)?.toDouble(),
|
||||
points: (map['points'] as num?)?.toDouble() ?? 0,
|
||||
libelle: (map['libelle'] as String?) ?? '',
|
||||
date: DateTime.tryParse(map['created_at']?.toString() ?? '')?.toLocal() ??
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user