Initial commit: unionflow-mobile-apps
Application Flutter complète (sans build artifacts). Signed-off-by: lions dev Team
This commit is contained in:
52
lib/features/epargne/data/models/compte_epargne_model.dart
Normal file
52
lib/features/epargne/data/models/compte_epargne_model.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
/// Modèle d'un compte épargne (aligné API CompteEpargneResponse).
|
||||
class CompteEpargneModel {
|
||||
final String? id;
|
||||
final String? membreId;
|
||||
final String? organisationId;
|
||||
final String? numeroCompte;
|
||||
final String? typeCompte;
|
||||
final double soldeActuel;
|
||||
final double soldeBloque;
|
||||
final String? statut;
|
||||
final DateTime? dateOuverture;
|
||||
final DateTime? dateDerniereTransaction;
|
||||
final String? description;
|
||||
|
||||
const CompteEpargneModel({
|
||||
this.id,
|
||||
this.membreId,
|
||||
this.organisationId,
|
||||
this.numeroCompte,
|
||||
this.typeCompte,
|
||||
this.soldeActuel = 0,
|
||||
this.soldeBloque = 0,
|
||||
this.statut,
|
||||
this.dateOuverture,
|
||||
this.dateDerniereTransaction,
|
||||
this.description,
|
||||
});
|
||||
|
||||
factory CompteEpargneModel.fromJson(Map<String, dynamic> json) {
|
||||
return CompteEpargneModel(
|
||||
id: json['id']?.toString(),
|
||||
membreId: json['membreId']?.toString(),
|
||||
organisationId: json['organisationId']?.toString(),
|
||||
numeroCompte: json['numeroCompte'] as String?,
|
||||
typeCompte: json['typeCompte'] as String?,
|
||||
soldeActuel: _toDouble(json['soldeActuel']),
|
||||
soldeBloque: _toDouble(json['soldeBloque']),
|
||||
statut: json['statut'] as String?,
|
||||
dateOuverture: json['dateOuverture'] != null ? DateTime.tryParse(json['dateOuverture'].toString()) : null,
|
||||
dateDerniereTransaction: json['dateDerniereTransaction'] != null ? DateTime.tryParse(json['dateDerniereTransaction'].toString()) : null,
|
||||
description: json['description'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
static double _toDouble(dynamic v) {
|
||||
if (v == null) return 0;
|
||||
if (v is num) return v.toDouble();
|
||||
return double.tryParse(v.toString()) ?? 0;
|
||||
}
|
||||
|
||||
double get soldeDisponible => soldeActuel - soldeBloque;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/// Modèle d'une transaction épargne (aligné API TransactionEpargneResponse).
|
||||
class TransactionEpargneModel {
|
||||
final String? id;
|
||||
final String? compteId;
|
||||
final String? type; // DEPOT, RETRAIT, TRANSFERT_ENTRANT, TRANSFERT_SORTANT
|
||||
final double montant;
|
||||
final double soldeAvant;
|
||||
final double soldeApres;
|
||||
final String? motif;
|
||||
final DateTime? dateTransaction;
|
||||
final String? statutExecution; // REUSSIE, etc.
|
||||
final String? origineFonds;
|
||||
|
||||
const TransactionEpargneModel({
|
||||
this.id,
|
||||
this.compteId,
|
||||
this.type,
|
||||
this.montant = 0,
|
||||
this.soldeAvant = 0,
|
||||
this.soldeApres = 0,
|
||||
this.motif,
|
||||
this.dateTransaction,
|
||||
this.statutExecution,
|
||||
this.origineFonds,
|
||||
});
|
||||
|
||||
factory TransactionEpargneModel.fromJson(Map<String, dynamic> json) {
|
||||
return TransactionEpargneModel(
|
||||
id: json['id']?.toString(),
|
||||
compteId: json['compteId']?.toString(),
|
||||
type: json['type']?.toString(),
|
||||
montant: _toDouble(json['montant']),
|
||||
soldeAvant: _toDouble(json['soldeAvant']),
|
||||
soldeApres: _toDouble(json['soldeApres']),
|
||||
motif: json['motif'] as String?,
|
||||
dateTransaction: json['dateTransaction'] != null
|
||||
? DateTime.tryParse(json['dateTransaction'].toString())
|
||||
: null,
|
||||
statutExecution: json['statutExecution']?.toString(),
|
||||
origineFonds: json['origineFonds'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
static double _toDouble(dynamic v) {
|
||||
if (v == null) return 0;
|
||||
if (v is num) return v.toDouble();
|
||||
return double.tryParse(v.toString()) ?? 0;
|
||||
}
|
||||
|
||||
bool get isCredit =>
|
||||
type == 'DEPOT' || type == 'TRANSFERT_ENTRANT';
|
||||
bool get isDebit =>
|
||||
type == 'RETRAIT' || type == 'TRANSFERT_SORTANT';
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/// Modèle de requête pour une transaction épargne (aligné API backend).
|
||||
/// LCB-FT : origineFonds et pieceJustificativeId obligatoires au-dessus du seuil.
|
||||
class TransactionEpargneRequest {
|
||||
final String compteId;
|
||||
final String typeTransaction; // DEPOT, RETRAIT, TRANSFERT_ENTRANT, etc.
|
||||
final double montant;
|
||||
final String? compteDestinationId;
|
||||
final String? motif;
|
||||
final String? origineFonds;
|
||||
final String? pieceJustificativeId;
|
||||
|
||||
const TransactionEpargneRequest({
|
||||
required this.compteId,
|
||||
required this.typeTransaction,
|
||||
required this.montant,
|
||||
this.compteDestinationId,
|
||||
this.motif,
|
||||
this.origineFonds,
|
||||
this.pieceJustificativeId,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'compteId': compteId,
|
||||
'typeTransaction': typeTransaction,
|
||||
'montant': montant,
|
||||
if (compteDestinationId != null) 'compteDestinationId': compteDestinationId,
|
||||
if (motif != null && motif!.isNotEmpty) 'motif': motif,
|
||||
if (origineFonds != null && origineFonds!.isNotEmpty) 'origineFonds': origineFonds,
|
||||
if (pieceJustificativeId != null && pieceJustificativeId!.isNotEmpty)
|
||||
'pieceJustificativeId': pieceJustificativeId,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user