App Flutter 2.11 para vendedores de ruta de Telcotronics. Incluye ruta del día con mapa custom, catálogo, pedidos CRUD, firma digital, scanner QR/barcode, selector de clientes escalable, notificaciones in-app y soporte multiplataforma (Android + Linux desktop). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58 lines
1.5 KiB
Dart
58 lines
1.5 KiB
Dart
import 'cliente.dart';
|
|
import 'item_pedido.dart';
|
|
|
|
enum EstadoPedido { pendiente, confirmado, entregado, cancelado }
|
|
|
|
extension EstadoPedidoExt on EstadoPedido {
|
|
String get label {
|
|
switch (this) {
|
|
case EstadoPedido.pendiente: return 'Pendiente';
|
|
case EstadoPedido.confirmado: return 'Confirmado';
|
|
case EstadoPedido.entregado: return 'Entregado';
|
|
case EstadoPedido.cancelado: return 'Cancelado';
|
|
}
|
|
}
|
|
|
|
static EstadoPedido fromString(String s) {
|
|
switch (s) {
|
|
case 'confirmado': return EstadoPedido.confirmado;
|
|
case 'entregado': return EstadoPedido.entregado;
|
|
case 'cancelado': return EstadoPedido.cancelado;
|
|
default: return EstadoPedido.pendiente;
|
|
}
|
|
}
|
|
}
|
|
|
|
class Pedido {
|
|
final String id;
|
|
final Cliente cliente;
|
|
final List<ItemPedido> items;
|
|
EstadoPedido estado;
|
|
final DateTime fecha;
|
|
String notas;
|
|
String? firmaBase64;
|
|
|
|
Pedido({
|
|
required this.id,
|
|
required this.cliente,
|
|
required this.items,
|
|
required this.estado,
|
|
required this.fecha,
|
|
this.notas = '',
|
|
this.firmaBase64,
|
|
});
|
|
|
|
double get subtotal => items.fold(0, (s, i) => s + i.subtotal);
|
|
double get total => subtotal;
|
|
int get totalItems => items.fold(0, (s, i) => s + i.cantidad);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
'id': id,
|
|
'cliente_id': cliente.id,
|
|
'estado': estado.label.toLowerCase(),
|
|
'fecha': fecha.toIso8601String(),
|
|
'notas': notas,
|
|
'firma_base64': firmaBase64,
|
|
};
|
|
}
|