Initial commit: app Fideliter client (Flutter)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/// Type d'un mouvement de points dans l'historique.
|
||||
class TypeMouvement {
|
||||
static const facture = 'facture';
|
||||
static const recompense = 'recompense';
|
||||
static const ajustement = 'ajustement';
|
||||
}
|
||||
|
||||
/// Une ligne d'historique : gain (facture) ou dépense (récompense).
|
||||
class Mouvement {
|
||||
final String id;
|
||||
final String type;
|
||||
final double? montantEuros;
|
||||
final double points; // signé
|
||||
final String libelle;
|
||||
final DateTime date;
|
||||
|
||||
const Mouvement({
|
||||
required this.id,
|
||||
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(),
|
||||
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