7 Revize 49b1ee97c0 ... 73fcfea796

Autor SHA1 Zpráva Datum
  ElPoteito 73fcfea796 13207: GRID: Ordenar Fecha DESC před 7 měsíci
  ElPoteito 5d1bfd03e0 13208: GRID PEDIDOS de mesa: Informar en una columna la MESA před 7 měsíci
  ElPoteito 0ffafebc94 13205: Pedidos de Mesa : Al guardar pedido corregir formato de fecha a iso 8601 před 8 měsíci
  ElPoteito ecf6636c3d 13204: Los pedidos de Mesa no se debe imprimir automaticamente před 8 měsíci
  ElPoteito 3318a01aa8 13202: Ordenar selector de mesas en select Az-Z en pedido před 8 měsíci
  ElPoteito d33bb92aff 13200: Ocultar ID local en vista d epedidos před 8 měsíci
  ElPoteito fe39f9802a 13143: Cargar mesas al abrir pantalla de pedidos de mesa před 8 měsíci

+ 7 - 0
lib/models/pedido_model.dart

@@ -1,3 +1,4 @@
+import 'package:conalep_pos/models/mesa_model.dart';
 import 'package:intl/intl.dart';
 import 'package:intl/intl.dart';
 
 
 import 'basico_model.dart';
 import 'basico_model.dart';
@@ -25,6 +26,7 @@ class Pedido extends Basico {
   double? cantTransferencia;
   double? cantTransferencia;
   List<PedidoProducto> productos = [];
   List<PedidoProducto> productos = [];
   int? idWeb;
   int? idWeb;
+  Mesa? mesa;
 
 
   String? sincronizado;
   String? sincronizado;
 
 
@@ -50,6 +52,7 @@ class Pedido extends Basico {
     this.cantTransferencia,
     this.cantTransferencia,
     this.productos = const [],
     this.productos = const [],
     this.idWeb,
     this.idWeb,
+    this.mesa,
     this.sincronizado,
     this.sincronizado,
   });
   });
 
 
@@ -75,6 +78,7 @@ class Pedido extends Basico {
       'cantEfectivo': cantEfectivo,
       'cantEfectivo': cantEfectivo,
       'cantTarjeta': cantTarjeta,
       'cantTarjeta': cantTarjeta,
       'cantTransferencia': cantTransferencia,
       'cantTransferencia': cantTransferencia,
+      'mesa': mesa,
       'sincronizado': sincronizado,
       'sincronizado': sincronizado,
     }..addAll(super.toJson());
     }..addAll(super.toJson());
   }
   }
@@ -95,6 +99,7 @@ class Pedido extends Basico {
       'cantEfectivo': cantEfectivo,
       'cantEfectivo': cantEfectivo,
       'cantTarjeta': cantTarjeta,
       'cantTarjeta': cantTarjeta,
       'cantTransferencia': cantTransferencia,
       'cantTransferencia': cantTransferencia,
+      'mesa': mesa,
       'productos': productos.map((producto) => producto.toApi()).toList(),
       'productos': productos.map((producto) => producto.toApi()).toList(),
     };
     };
     Map<String, dynamic> basicoMap = super.toJson();
     Map<String, dynamic> basicoMap = super.toJson();
@@ -128,6 +133,8 @@ class Pedido extends Basico {
     cantTransferencia = Basico.parseDouble(json['cantTransferencia']);
     cantTransferencia = Basico.parseDouble(json['cantTransferencia']);
     idWeb = Basico.parseInt(json['idWeb']);
     idWeb = Basico.parseInt(json['idWeb']);
     sincronizado = Basico.parseString(json['sincronizado']);
     sincronizado = Basico.parseString(json['sincronizado']);
+    mesa =
+        json["mesa"] == null ? null : Mesa.fromJson(json["mesa"]);
 
 
     List<PedidoProducto> _productos = [];
     List<PedidoProducto> _productos = [];
     if (json["productos"] != null && (json["productos"] as List).isNotEmpty) {
     if (json["productos"] != null && (json["productos"] as List).isNotEmpty) {

+ 8 - 6
lib/services/repo_service.dart

@@ -549,7 +549,7 @@ class RepoService<T> {
     List<Map<String, dynamic>> result = await dbClient!.query('Pedido',
     List<Map<String, dynamic>> result = await dbClient!.query('Pedido',
         limit: limit,
         limit: limit,
         offset: offset,
         offset: offset,
-        orderBy: 'id DESC',
+        orderBy: 'peticion DESC',
         where: 'idMesa IS NULL');
         where: 'idMesa IS NULL');
     return result.map((map) => Pedido.fromJson(map)).toList();
     return result.map((map) => Pedido.fromJson(map)).toList();
   }
   }
@@ -557,11 +557,13 @@ class RepoService<T> {
   Future<List<Pedido>> obtenerMesaPedidosPaginados(
   Future<List<Pedido>> obtenerMesaPedidosPaginados(
       int limit, int offset) async {
       int limit, int offset) async {
     Database? dbClient = await db;
     Database? dbClient = await db;
-    List<Map<String, dynamic>> result = await dbClient!.query('Pedido',
-        limit: limit,
-        offset: offset,
-        orderBy: 'id DESC',
-        where: 'idMesa IS NOT NULL');
+    List<Map<String, dynamic>> result = await dbClient!.query(
+      'Pedido',
+      limit: limit,
+      offset: offset,
+      orderBy: 'peticion DESC',
+      where: 'idMesa IS NOT NULL',
+    );
     return result.map((map) => Pedido.fromJson(map)).toList();
     return result.map((map) => Pedido.fromJson(map)).toList();
   }
   }
 
 

+ 5 - 0
lib/viewmodels/mesa_view_model.dart

@@ -65,6 +65,11 @@ class MesaViewModel extends ChangeNotifier {
     notifyListeners();
     notifyListeners();
   }
   }
 
 
+  Mesa fetchLocalById({required int? idMesa}) {
+    final mesa = mesas.firstWhere((mesa) => mesa.id == idMesa, orElse: () => Mesa(id: 0, nombre: 'Mesa desconocida'));
+    return mesa;
+  }
+
   Future<void> addMesa(Mesa mesa) async {
   Future<void> addMesa(Mesa mesa) async {
     await RepoService().guardar(mesa);
     await RepoService().guardar(mesa);
     fetchLocalAll();
     fetchLocalAll();

+ 1 - 1
lib/views/pedido/pedido_screen.dart

@@ -609,7 +609,7 @@ class _PedidoScreenState extends State<PedidoScreen> {
   }
   }
 
 
   String _formatDateTime(String? dateTimeString) {
   String _formatDateTime(String? dateTimeString) {
-    if (dateTimeString == null) return "Sin fecha";
+    if (dateTimeString == null || dateTimeString == "") return "Sin fecha";
 
 
     DateTime parsedDate = DateTime.parse(dateTimeString);
     DateTime parsedDate = DateTime.parse(dateTimeString);
 
 

+ 11 - 6
lib/views/pedido_mesa/pedido_mesa_form.dart

@@ -96,7 +96,11 @@ class _PedidoMesaFormState extends State<PedidoMesaForm> {
       }
       }
     });
     });
 
 
-    listaMesas = mvm.mesas
+    final mesas = mvm.mesas;
+    if (mesas.isNotEmpty) {
+      mesas.sort((a, b) => a.nombre!.compareTo(b.nombre!));
+    }
+    listaMesas = mesas
         .map(
         .map(
           (mesa) => DropdownMenuItem<int>(
           (mesa) => DropdownMenuItem<int>(
             value: mesa.id,
             value: mesa.id,
@@ -107,6 +111,7 @@ class _PedidoMesaFormState extends State<PedidoMesaForm> {
           ),
           ),
         )
         )
         .toList();
         .toList();
+    
 
 
     Provider.of<DescuentoViewModel>(context, listen: false).cargarDescuentos();
     Provider.of<DescuentoViewModel>(context, listen: false).cargarDescuentos();
 
 
@@ -572,7 +577,7 @@ class _PedidoMesaFormState extends State<PedidoMesaForm> {
 
 
   void prepararPedidoActual(String nombreCliente, String comentarios) async {
   void prepararPedidoActual(String nombreCliente, String comentarios) async {
     DateTime now = DateTime.now();
     DateTime now = DateTime.now();
-    String formattedDate = DateFormat('dd-MM-yyyy kk:mm:ss').format(now);
+    String formattedDate = DateTime.now().toUtc().toIso8601String();
 
 
     Pedido nuevoPedido = Pedido(
     Pedido nuevoPedido = Pedido(
       peticion: formattedDate,
       peticion: formattedDate,
@@ -635,7 +640,7 @@ class _PedidoMesaFormState extends State<PedidoMesaForm> {
 
 
   void guardarPedidoActual() async {
   void guardarPedidoActual() async {
     DateTime now = DateTime.now();
     DateTime now = DateTime.now();
-    String formattedDate = DateFormat('dd-MM-yyyy kk:mm:ss').format(now);
+    String formattedDate = DateTime.now().toUtc().toIso8601String();
 
 
     Pedido nuevoPedido = Pedido(
     Pedido nuevoPedido = Pedido(
         peticion: formattedDate,
         peticion: formattedDate,
@@ -692,9 +697,9 @@ class _PedidoMesaFormState extends State<PedidoMesaForm> {
           await Provider.of<PedidoViewModel>(context, listen: false)
           await Provider.of<PedidoViewModel>(context, listen: false)
               .fetchPedidoConProductos(nuevoPedido.id!);
               .fetchPedidoConProductos(nuevoPedido.id!);
 
 
-      if (pedidoCompleto != null) {
+      /* if (pedidoCompleto != null) {
         imprimirTicketsJuntos(context, pedidoCompleto);
         imprimirTicketsJuntos(context, pedidoCompleto);
-      }
+      } */
       Navigator.of(context).pop();
       Navigator.of(context).pop();
     } else {
     } else {
       print("Error al guardar el pedido");
       print("Error al guardar el pedido");
@@ -706,7 +711,7 @@ class _PedidoMesaFormState extends State<PedidoMesaForm> {
       Navigator.of(context).pop();
       Navigator.of(context).pop();
     } else {
     } else {
       DateTime now = DateTime.now();
       DateTime now = DateTime.now();
-      String formattedDate = DateFormat('dd-MM-yyyy kk:mm:ss').format(now);
+      String formattedDate = DateTime.now().toUtc().toIso8601String();
 
 
       Pedido nuevoPedido = Pedido(
       Pedido nuevoPedido = Pedido(
           peticion: formattedDate,
           peticion: formattedDate,

+ 21 - 14
lib/views/pedido_mesa/pedido_mesa_screen.dart

@@ -1,5 +1,6 @@
 import 'package:conalep_pos/models/models.dart';
 import 'package:conalep_pos/models/models.dart';
 import 'package:conalep_pos/themes/themes.dart';
 import 'package:conalep_pos/themes/themes.dart';
+import 'package:conalep_pos/viewmodels/mesa_view_model.dart';
 import 'package:conalep_pos/viewmodels/viewmodels.dart';
 import 'package:conalep_pos/viewmodels/viewmodels.dart';
 import 'package:conalep_pos/views/pedido_mesa/pedido_mesa_detalle.dart';
 import 'package:conalep_pos/views/pedido_mesa/pedido_mesa_detalle.dart';
 import 'package:conalep_pos/views/pedido_mesa/pedido_mesa_form.dart';
 import 'package:conalep_pos/views/pedido_mesa/pedido_mesa_form.dart';
@@ -27,6 +28,7 @@ class _PedidoMesaScreenState extends State<PedidoMesaScreen> {
     WidgetsBinding.instance.addPostFrameCallback((_) {
     WidgetsBinding.instance.addPostFrameCallback((_) {
       Provider.of<PedidoViewModel>(context, listen: false)
       Provider.of<PedidoViewModel>(context, listen: false)
           .fetchLocalMesaPedidosForScreen();
           .fetchLocalMesaPedidosForScreen();
+      Provider.of<MesaViewModel>(context, listen: false).fetchLocalAll();
     });
     });
   }
   }
 
 
@@ -80,8 +82,7 @@ class _PedidoMesaScreenState extends State<PedidoMesaScreen> {
         Navigator.push(
         Navigator.push(
           context,
           context,
           MaterialPageRoute(
           MaterialPageRoute(
-            builder: (context) =>
-                PedidoMesaForm(pedido: pedidoCompleto),
+            builder: (context) => PedidoMesaForm(pedido: pedidoCompleto),
           ),
           ),
         );
         );
       } else {
       } else {
@@ -187,17 +188,25 @@ class _PedidoMesaScreenState extends State<PedidoMesaScreen> {
           )
           )
         ])),
         ])),
         DataCell(
         DataCell(
-          Text(item.id.toString()),
+          Text(item.peticion ?? "Sin fecha"),
           onTap: () => go(item),
           onTap: () => go(item),
         ),
         ),
         DataCell(
         DataCell(
-          Text(item.folio.toString()),
+          Text(Provider.of<MesaViewModel>(context, listen: false).fetchLocalById(idMesa: item.idMesa).nombre.toString()),
           onTap: () => go(item),
           onTap: () => go(item),
         ),
         ),
+        /* DataCell(
+          Text(item.id.toString()),
+          onTap: () => go(item),
+        ), */
         DataCell(
         DataCell(
-          Text(item.idLocal.toString()),
+          Text(item.folio.toString()),
           onTap: () => go(item),
           onTap: () => go(item),
         ),
         ),
+        /* DataCell(
+          Text(item.idLocal.toString()),
+          onTap: () => go(item),
+        ), */
         DataCell(
         DataCell(
           Text(item.nombreCliente ?? "Sin nombre"),
           Text(item.nombreCliente ?? "Sin nombre"),
           onTap: () => go(item),
           onTap: () => go(item),
@@ -210,10 +219,6 @@ class _PedidoMesaScreenState extends State<PedidoMesaScreen> {
           Text(item.estatus ?? "Sin Estatus"),
           Text(item.estatus ?? "Sin Estatus"),
           onTap: () => go(item),
           onTap: () => go(item),
         ),
         ),
-        DataCell(
-          Text(item.peticion ?? "Sin fecha"),
-          onTap: () => go(item),
-        ),
       ]));
       ]));
     }
     }
 
 
@@ -323,11 +328,15 @@ class _PedidoMesaScreenState extends State<PedidoMesaScreen> {
                                   columns: [
                                   columns: [
                                     DataColumn(label: Text(" ", style: estilo)),
                                     DataColumn(label: Text(" ", style: estilo)),
                                     DataColumn(
                                     DataColumn(
-                                        label: Text("ID", style: estilo)),
+                                        label: Text("FECHA", style: estilo)),
                                     DataColumn(
                                     DataColumn(
-                                        label: Text("FOLIO", style: estilo)),
+                                        label: Text("MESA", style: estilo)),
+                                    /* DataColumn(
+                                        label: Text("ID", style: estilo)), */
                                     DataColumn(
                                     DataColumn(
-                                        label: Text("IDLOCAL", style: estilo)),
+                                        label: Text("FOLIO", style: estilo)),
+                                    /* DataColumn(
+                                        label: Text("IDLOCAL", style: estilo)), */
                                     DataColumn(
                                     DataColumn(
                                         label: Text("NOMBRE", style: estilo)),
                                         label: Text("NOMBRE", style: estilo)),
                                     DataColumn(
                                     DataColumn(
@@ -335,8 +344,6 @@ class _PedidoMesaScreenState extends State<PedidoMesaScreen> {
                                             Text("COMENTARIOS", style: estilo)),
                                             Text("COMENTARIOS", style: estilo)),
                                     DataColumn(
                                     DataColumn(
                                         label: Text("ESTATUS", style: estilo)),
                                         label: Text("ESTATUS", style: estilo)),
-                                    DataColumn(
-                                        label: Text("FECHA", style: estilo)),
                                   ],
                                   ],
                                   rows: registros,
                                   rows: registros,
                                 ),
                                 ),