class Factura { final int? id; final int servicioId; final double monto; final String fechaEmision; final String fechaVencimiento; final String estado; final String? nota; final String? fechaPago; Factura({ this.id, required this.servicioId, required this.monto, required this.fechaEmision, required this.fechaVencimiento, this.estado = 'Pendiente', this.nota, this.fechaPago, }); Factura copyWith({ int? id, int? servicioId, double? monto, String? fechaEmision, String? fechaVencimiento, String? estado, String? nota, String? fechaPago, }) => Factura( id: id ?? this.id, servicioId: servicioId ?? this.servicioId, monto: monto ?? this.monto, fechaEmision: fechaEmision ?? this.fechaEmision, fechaVencimiento: fechaVencimiento ?? this.fechaVencimiento, estado: estado ?? this.estado, nota: nota ?? this.nota, fechaPago: fechaPago ?? this.fechaPago, ); Map toMap() => { 'id': id, 'servicio_id': servicioId, 'monto': monto, 'fecha_emision': fechaEmision, 'fecha_vencimiento': fechaVencimiento, 'estado': estado, 'nota': nota, 'fecha_pago': fechaPago, }; factory Factura.fromMap(Map map) => Factura( id: map['id'] as int?, servicioId: map['servicio_id'] as int, monto: (map['monto'] as num).toDouble(), fechaEmision: map['fecha_emision'] as String, fechaVencimiento: map['fecha_vencimiento'] as String, estado: map['estado'] as String? ?? 'Pendiente', nota: map['nota'] as String?, fechaPago: map['fecha_pago'] as String?, ); }