/// 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,
      };
}
