OscarGil03 před 7 měsíci
rodič
revize
0fbeeee6d9

+ 21 - 7
lib/models/pedido_model.dart

@@ -1,5 +1,8 @@
+import 'package:intl/intl.dart';
+
 import 'basico_model.dart';
 import 'basico_model.dart';
 import 'pedido_producto_model.dart';
 import 'pedido_producto_model.dart';
+import '../services/services.dart';
 
 
 class Pedido extends Basico {
 class Pedido extends Basico {
   int? folio;
   int? folio;
@@ -74,24 +77,35 @@ class Pedido extends Basico {
     }..addAll(super.toJson());
     }..addAll(super.toJson());
   }
   }
 
 
-  @override
   Map<String, dynamic> toApi() {
   Map<String, dynamic> toApi() {
-    return {
-      'idLocal': id,
+    idLocal = id;
+
+    DateTime? fechaPeticion = peticion != null
+        ? DateFormat('dd-MM-yyyy kk:mm:ss').parse(peticion!)
+        : null;
+    String? fechaPeticionIso = fechaPeticion?.toIso8601String();
+
+    Map<String, dynamic> apiMap = {
+      'idLocal': idLocal,
       'folio': folio,
       'folio': folio,
       'estatus': estatus,
       'estatus': estatus,
       'comentarios': comentarios,
       'comentarios': comentarios,
-      'creado': peticion,
       'nombreCliente': nombreCliente,
       'nombreCliente': nombreCliente,
+      'creado': fechaPeticionIso,
+      'tipoPago': tipoPago,
       'totalPedido': totalPedido,
       'totalPedido': totalPedido,
       'descuento': descuento,
       'descuento': descuento,
-      'idCliente': idCliente,
-      'tipoPago': tipoPago,
       'cantEfectivo': cantEfectivo,
       'cantEfectivo': cantEfectivo,
       'cantTarjeta': cantTarjeta,
       'cantTarjeta': cantTarjeta,
       'cantTransferencia': cantTransferencia,
       'cantTransferencia': cantTransferencia,
       'productos': productos.map((producto) => producto.toApi()).toList(),
       'productos': productos.map((producto) => producto.toApi()).toList(),
-    }..addAll(super.toJson());
+    };
+    Map<String, dynamic> basicoMap = super.toJson();
+    basicoMap.remove('id');
+    basicoMap.remove('eliminado');
+    apiMap.addAll(basicoMap);
+
+    return apiMap;
   }
   }
 
 
   Pedido.fromJson(Map<String, dynamic> json) {
   Pedido.fromJson(Map<String, dynamic> json) {

+ 2 - 1
lib/models/pedido_producto_model.dart

@@ -44,7 +44,8 @@ class PedidoProducto extends Basico {
 
 
   Map<String, dynamic> toApi() {
   Map<String, dynamic> toApi() {
     return {
     return {
-      'idProducto': idProducto,
+      'idLocal': idProducto,
+      'nombre': producto?.nombre ?? '',
       'costoUnitario': costoUnitario,
       'costoUnitario': costoUnitario,
       'descuento': descuento,
       'descuento': descuento,
       'cantidad': cantidad,
       'cantidad': cantidad,

+ 2 - 2
lib/services/base_service.dart

@@ -8,8 +8,8 @@ class BaseService {
   int limit = 20;
   int limit = 20;
   int total = 0;
   int total = 0;
 
 
-  String base_url = /*'https://pos.papas.edesarrollos.info'*/ '';
-  String baseUrl = /*'pos.papas.edesarrollos.info'*/ '';
+  String base_url = 'https://pos.conalep.turquessacoffee.com';
+  String baseUrl = 'pos.conalep.turquessacoffee.com';
   Future<Map<String, String>> getDefaultHeaders({withAuth = true}) async {
   Future<Map<String, String>> getDefaultHeaders({withAuth = true}) async {
     Map<String, String> defaultHeaders = {'Content-Type': 'application/json'};
     Map<String, String> defaultHeaders = {'Content-Type': 'application/json'};
 
 

+ 60 - 15
lib/services/repo_service.dart

@@ -6,7 +6,7 @@ import 'package:sqflite/sqflite.dart';
 import '../models/models.dart';
 import '../models/models.dart';
 
 
 class RepoService<T> {
 class RepoService<T> {
-  static int dbVersion = 10;
+  static int dbVersion = 11;
   static String dbName = 'conalepPos7.db';
   static String dbName = 'conalepPos7.db';
   static const String id = Basico.identificadorWeb;
   static const String id = Basico.identificadorWeb;
   static const String idLocal = Basico.identificadorLocal;
   static const String idLocal = Basico.identificadorLocal;
@@ -217,20 +217,35 @@ class RepoService<T> {
         ''');
         ''');
           break;
           break;
 
 
-        // case 9:
-        //   await db.execute('''
-        //   ALTER TABLE Pedido ADD COLUMN idWeb INTEGER;
-        // ''');
-        //   await db.execute('''
-        //   ALTER TABLE Pedido ADD COLUMN sincronizado TEXT;
-        // ''');
-        //   await db.execute('''
-        //   ALTER TABLE PedidoProducto ADD COLUMN idWeb INTEGER;
-        // ''');
-        //   await db.execute('''
-        //   ALTER TABLE PedidoProducto ADD COLUMN sincronizado TEXT;
-        // ''');
-        //   break;
+        case 9:
+          await db.execute('''
+          ALTER TABLE Pedido ADD COLUMN idWeb INTEGER;
+        ''');
+          await db.execute('''
+          ALTER TABLE Pedido ADD COLUMN sincronizado TEXT;
+        ''');
+          await db.execute('''
+          ALTER TABLE PedidoProducto ADD COLUMN idWeb INTEGER;
+        ''');
+          await db.execute('''
+          ALTER TABLE PedidoProducto ADD COLUMN sincronizado TEXT;
+        ''');
+          break;
+
+        case 10:
+          await db.execute('''
+          ALTER TABLE Pedido ADD COLUMN idWeb INTEGER;
+        ''');
+          await db.execute('''
+          ALTER TABLE Pedido ADD COLUMN sincronizado TEXT;
+        ''');
+          await db.execute('''
+          ALTER TABLE PedidoProducto ADD COLUMN idWeb INTEGER;
+        ''');
+          await db.execute('''
+          ALTER TABLE PedidoProducto ADD COLUMN sincronizado TEXT;
+        ''');
+          break;
       }
       }
       oldVersion++;
       oldVersion++;
     }
     }
@@ -516,4 +531,34 @@ class RepoService<T> {
     return await dbClient!
     return await dbClient!
         .delete('Descuento', where: 'id = ?', whereArgs: [id]);
         .delete('Descuento', where: 'id = ?', whereArgs: [id]);
   }
   }
+
+  Future<Variable?> obtenerPorNombre(String nombre) async {
+    var dbClient = await db;
+    List<Map<String, dynamic>> maps = await dbClient!.query(
+      'Variable',
+      where: 'nombre = ?',
+      whereArgs: [nombre],
+    );
+
+    if (maps.isNotEmpty) {
+      return Variable.fromJson(Map<String, dynamic>.from(maps.first));
+    }
+
+    return null;
+  }
+
+  Future<List<Pedido>> obtenerPedidosOrdenadosPorFecha() async {
+    var dbClient = await db;
+
+    String orderBy =
+        "datetime(substr(peticion, 7, 4) || '-' || substr(peticion, 4, 2) || '-' || substr(peticion, 1, 2) || ' ' || substr(peticion, 12)) ASC";
+
+    List<Map<String, dynamic>> result = await dbClient!.query(
+      'Pedido',
+      where: 'sincronizado IS NULL',
+      orderBy: orderBy,
+    );
+
+    return result.map((map) => Pedido.fromJson(map)).toList();
+  }
 }
 }

+ 69 - 15
lib/viewmodels/pedido_view_model.dart

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:intl/intl.dart';
 import 'package:intl/intl.dart';
 import 'package:sqflite/sqflite.dart';
 import 'package:sqflite/sqflite.dart';
 
 
+import '../data/api_response.dart';
 import '../models/models.dart';
 import '../models/models.dart';
 import '../services/services.dart';
 import '../services/services.dart';
 
 
@@ -221,32 +222,85 @@ class PedidoViewModel extends ChangeNotifier {
     fetchLocalPedidosForScreen();
     fetchLocalPedidosForScreen();
   }
   }
 
 
-  Future<void> sincronizarPedidos() async {
-    List<Pedido> todosLosPedidos = await fetchAllLocalPedidos();
+  Future<bool> sincronizarPedidos() async {
+    List<Pedido> pedidosNoSincronizados =
+        await fetchAllLocalPedidosOrdenadosPorFecha();
 
 
-    Pedido? pedidoNoSincronizado;
+    if (pedidosNoSincronizados.isNotEmpty) {
+      Pedido pedidoNoSincronizado = pedidosNoSincronizados.first;
 
 
-    for (var pedido in todosLosPedidos) {
-      if (pedido.sincronizado == null || pedido.sincronizado!.isEmpty) {
-        pedidoNoSincronizado = pedido;
-        break;
-      }
-    }
-
-    if (pedidoNoSincronizado != null) {
       if (pedidoNoSincronizado.productos.isEmpty) {
       if (pedidoNoSincronizado.productos.isEmpty) {
         pedidoNoSincronizado =
         pedidoNoSincronizado =
             await fetchPedidoConProductos(pedidoNoSincronizado.id) ??
             await fetchPedidoConProductos(pedidoNoSincronizado.id) ??
                 pedidoNoSincronizado;
                 pedidoNoSincronizado;
       }
       }
 
 
-      Map<String, dynamic> pedidoJson = pedidoNoSincronizado.toApi();
+      Map<String, dynamic> pedidoJson =
+          await prepararPedidoParaApi(pedidoNoSincronizado);
+
+      print('JSON enviado: $pedidoJson');
+
+      var response = ApiResponse(await BaseService()
+          .post('/pos/pedido/sincronizar', body: pedidoJson));
+
+      if (response.isOk && response.detalle != null) {
+        int idWeb = response.detalle!['id'];
+        String sincronizado = response.detalle!['sincronizado'];
+
+        await actualizarPedidoSincronizado(
+            pedidoNoSincronizado.id!, idWeb, sincronizado);
 
 
-      // Imprimir en consola
-      print('Sincronizando Pedido: ${pedidoJson['folio']}');
-      print(pedidoJson);
+        await fetchLocalPedidosForScreen();
+        return true;
+      } else {
+        print('Error en la sincronización del pedido: ${response.mensaje}');
+        return true;
+      }
     } else {
     } else {
       print('No se encontraron pedidos no sincronizados.');
       print('No se encontraron pedidos no sincronizados.');
+      return false;
     }
     }
   }
   }
+
+  Future<void> actualizarPedidoSincronizado(
+      int idPedido, int idWeb, String sincronizado) async {
+    var db = await RepoService().db;
+
+    await db!.update(
+      'Pedido',
+      {
+        'idWeb': idWeb,
+        'sincronizado': sincronizado,
+      },
+      where: 'id = ?',
+      whereArgs: [idPedido],
+    );
+  }
+
+  Future<List<Pedido>> fetchAllLocalPedidosOrdenadosPorFecha() async {
+    setIsLoading(true);
+    RepoService<Pedido> repoPedido = RepoService<Pedido>();
+
+    List<Pedido> allPedidos =
+        await repoPedido.obtenerPedidosOrdenadosPorFecha();
+
+    setIsLoading(false);
+    return allPedidos;
+  }
+}
+
+Future<Map<String, dynamic>> prepararPedidoParaApi(Pedido pedido) async {
+  String? claveSucursal = await obtenerClaveSucursal();
+
+  Map<String, dynamic> apiMap = pedido.toApi();
+
+  apiMap['claveSucursal'] = claveSucursal;
+
+  return apiMap;
+}
+
+Future<String?> obtenerClaveSucursal() async {
+  RepoService<Variable> repoVariable = RepoService<Variable>();
+  Variable? sucursalVariable = await repoVariable.obtenerPorNombre('Sucursal');
+  return sucursalVariable?.clave;
 }
 }

+ 3 - 3
lib/viewmodels/variable_view_model.dart

@@ -119,12 +119,12 @@ class VariableViewModel extends ChangeNotifier {
     return false;
     return false;
   }
   }
 
 
-  Future<Variable?> getVariableByClave(String clave) async {
+  Future<Variable?> getVariableByClave(String nombre) async {
     var db = await RepoService().db;
     var db = await RepoService().db;
     var result = await db!.query(
     var result = await db!.query(
       'Variable',
       'Variable',
-      where: 'clave = ?',
-      whereArgs: [clave],
+      where: 'nombre = ?',
+      whereArgs: [nombre],
     );
     );
 
 
     if (result.isNotEmpty) {
     if (result.isNotEmpty) {

+ 35 - 32
lib/views/pedido/pedido_form.dart

@@ -1309,41 +1309,44 @@ class _PedidoFormState extends State<PedidoForm> {
     List<CategoriaProducto> categoriasFiltradas =
     List<CategoriaProducto> categoriasFiltradas =
         categorias.where((categoria) => categoria.esToping == 0).toList();
         categorias.where((categoria) => categoria.esToping == 0).toList();
 
 
-    return Container(
-      height: 50,
-      child: Scrollbar(
-        thumbVisibility: true,
-        trackVisibility: true,
-        interactive: true,
-        controller: _categoryScrollController,
-        child: ListView.builder(
-          controller: _categoryScrollController,
-          scrollDirection: Axis.horizontal,
-          itemCount: categoriasFiltradas.length,
-          itemBuilder: (context, index) {
-            final categoria = categoriasFiltradas[index];
-            bool isSelected = categoriaSeleccionada?.id == categoria.id;
-            return Padding(
-              padding: const EdgeInsets.symmetric(horizontal: 4.0),
-              child: ElevatedButton(
-                onPressed: () {
-                  cargarProductosPorCategoria(categoria.id);
-                  setState(() {
-                    categoriaSeleccionada = categoria;
-                  });
+    return Column(
+      children: [
+        Container(
+          height: 50,
+          child: Stack(
+            children: [
+              ListView.builder(
+                controller: _categoryScrollController,
+                scrollDirection: Axis.horizontal,
+                itemCount: categoriasFiltradas.length,
+                itemBuilder: (context, index) {
+                  final categoria = categoriasFiltradas[index];
+                  bool isSelected = categoriaSeleccionada?.id == categoria.id;
+                  return Padding(
+                    padding: const EdgeInsets.symmetric(horizontal: 4.0),
+                    child: ElevatedButton(
+                      onPressed: () {
+                        cargarProductosPorCategoria(categoria.id);
+                        setState(() {
+                          categoriaSeleccionada = categoria;
+                        });
+                      },
+                      style: ElevatedButton.styleFrom(
+                        backgroundColor:
+                            isSelected ? AppTheme.tertiary : Colors.grey,
+                        foregroundColor: isSelected
+                            ? AppTheme.quaternary
+                            : AppTheme.secondary,
+                      ),
+                      child: Text(categoria.nombre!),
+                    ),
+                  );
                 },
                 },
-                style: ElevatedButton.styleFrom(
-                  primary: isSelected ? AppTheme.tertiary : Colors.grey,
-                  foregroundColor:
-                      isSelected ? AppTheme.quaternary : AppTheme.secondary,
-                  onPrimary: AppTheme.secondary,
-                ),
-                child: Text(categoria.nombre!),
               ),
               ),
-            );
-          },
+            ],
+          ),
         ),
         ),
-      ),
+      ],
     );
     );
   }
   }
 
 

+ 5 - 3
lib/views/pedido/pedido_screen.dart

@@ -10,6 +10,7 @@ import '../../models/models.dart';
 import '../../viewmodels/viewmodels.dart';
 import '../../viewmodels/viewmodels.dart';
 import '../../widgets/widgets_components.dart' as clase;
 import '../../widgets/widgets_components.dart' as clase;
 import 'pedido_form.dart';
 import 'pedido_form.dart';
+import 'pedido_sync.dart';
 
 
 class PedidoScreen extends StatefulWidget {
 class PedidoScreen extends StatefulWidget {
   const PedidoScreen({Key? key}) : super(key: key);
   const PedidoScreen({Key? key}) : super(key: key);
@@ -425,9 +426,10 @@ class _PedidoScreenState extends State<PedidoScreen> {
             left: 16,
             left: 16,
             child: FloatingActionButton.extended(
             child: FloatingActionButton.extended(
               heroTag: 'sincronizacion',
               heroTag: 'sincronizacion',
-              onPressed: () async {
-                await Provider.of<PedidoViewModel>(context, listen: false)
-                    .sincronizarPedidos();
+              onPressed: () {
+                alerta(context, etiqueta: "Sincronización Empezada");
+                PedidoSync().startSync(
+                    Provider.of<PedidoViewModel>(context, listen: false));
               },
               },
               icon: Icon(Icons.sync, size: 30, color: AppTheme.quaternary),
               icon: Icon(Icons.sync, size: 30, color: AppTheme.quaternary),
               label: Text(
               label: Text(

+ 38 - 0
lib/views/pedido/pedido_sync.dart

@@ -0,0 +1,38 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import '../../viewmodels/viewmodels.dart';
+
+class PedidoSync {
+  static final PedidoSync _instance = PedidoSync._internal();
+  Timer? _syncTimer;
+
+  factory PedidoSync() {
+    return _instance;
+  }
+
+  PedidoSync._internal();
+
+  void startSync(PedidoViewModel pedidoViewModel) {
+    if (_syncTimer != null && _syncTimer!.isActive) return;
+
+    _syncTimer = Timer.periodic(Duration(seconds: 5), (timer) async {
+      bool hasMoreToSync = await pedidoViewModel.sincronizarPedidos();
+      if (!hasMoreToSync) {
+        timer.cancel();
+        _syncTimer = null;
+        debugPrint(
+            'Sincronización completa, no hay más pedidos por sincronizar.');
+      }
+    });
+  }
+
+  void stopSync() {
+    _syncTimer?.cancel();
+    _syncTimer = null;
+  }
+
+  bool isSyncing() {
+    return _syncTimer != null && _syncTimer!.isActive;
+  }
+}

+ 32 - 44
lib/views/pedido/pedido_ticket.dart

@@ -206,34 +206,27 @@ Future<pw.Page> generarPaginaSegundoTicket(
 
 
   final sucursalVariable =
   final sucursalVariable =
       await Provider.of<VariableViewModel>(context, listen: false)
       await Provider.of<VariableViewModel>(context, listen: false)
-          .getVariableByClave('sucursal');
+          .getVariableByClave('Sucursal');
   final sucursalDescripcion = sucursalVariable?.descripcion ?? '';
   final sucursalDescripcion = sucursalVariable?.descripcion ?? '';
 
 
   List<pw.Widget> content = [
   List<pw.Widget> content = [
-    pw.SizedBox(height: 20),
-    pw.Text('.', style: pw.TextStyle(fontSize: 1)),
     pw.Row(
     pw.Row(
       mainAxisAlignment: pw.MainAxisAlignment.spaceAround,
       mainAxisAlignment: pw.MainAxisAlignment.spaceAround,
       children: [
       children: [
         pw.Text('${pedido.folio}/ ',
         pw.Text('${pedido.folio}/ ',
-            style: pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
+            style: pw.TextStyle(fontSize: 7, fontWeight: pw.FontWeight.bold)),
         if (sucursalDescripcion.isNotEmpty)
         if (sucursalDescripcion.isNotEmpty)
           pw.Text('$sucursalDescripcion/ ',
           pw.Text('$sucursalDescripcion/ ',
-              style:
-                  pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
+              style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
+        pw.Text('${pedido.peticion}',
+            style: pw.TextStyle(fontSize: 7, fontWeight: pw.FontWeight.bold)),
       ],
       ],
     ),
     ),
-    pw.SizedBox(height: 5),
-    pw.Row(children: [
-      pw.Text('${pedido.peticion}',
-          style: pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
-    ]),
-    if (pedido.nombreCliente != null && pedido.nombreCliente!.isNotEmpty)
-      pw.SizedBox(height: 5),
+    pw.SizedBox(height: 2),
     if (pedido.nombreCliente != null && pedido.nombreCliente!.isNotEmpty)
     if (pedido.nombreCliente != null && pedido.nombreCliente!.isNotEmpty)
       pw.Text('Cliente: ${pedido.nombreCliente}',
       pw.Text('Cliente: ${pedido.nombreCliente}',
-          style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
-    pw.SizedBox(height: 10),
+          style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
+    pw.SizedBox(height: 2),
   ];
   ];
 
 
   // Mostrar los productos con la cantidad, el precio total y el precio de los toppings
   // Mostrar los productos con la cantidad, el precio total y el precio de los toppings
@@ -255,14 +248,14 @@ Future<pw.Page> generarPaginaSegundoTicket(
                 flex: 3,
                 flex: 3,
                 child: pw.Text(
                 child: pw.Text(
                     '-${topping.topping?.nombre ?? "Topping no especificado"}',
                     '-${topping.topping?.nombre ?? "Topping no especificado"}',
-                    style: const pw.TextStyle(fontSize: 9)),
+                    style: const pw.TextStyle(fontSize: 6)),
               ),
               ),
               if (toppingPrice > 0)
               if (toppingPrice > 0)
                 pw.Expanded(
                 pw.Expanded(
                   flex: 1,
                   flex: 1,
                   child: pw.Text(
                   child: pw.Text(
                     '\$${numberFormat.format(toppingTotal)}',
                     '\$${numberFormat.format(toppingTotal)}',
-                    style: const pw.TextStyle(fontSize: 9),
+                    style: const pw.TextStyle(fontSize: 6),
                     textAlign: pw.TextAlign.right,
                     textAlign: pw.TextAlign.right,
                   ),
                   ),
                 ),
                 ),
@@ -277,22 +270,23 @@ Future<pw.Page> generarPaginaSegundoTicket(
               pw.Expanded(
               pw.Expanded(
                 flex: 1,
                 flex: 1,
                 child: pw.Text('${producto.cantidad}',
                 child: pw.Text('${producto.cantidad}',
-                    style: const pw.TextStyle(fontSize: 12)),
+                    style: const pw.TextStyle(fontSize: 7)),
               ),
               ),
               pw.Expanded(
               pw.Expanded(
-                flex: 3,
+                flex: 5,
                 child: pw.Text(
                 child: pw.Text(
                     producto.producto?.nombre ?? "Producto no especificado",
                     producto.producto?.nombre ?? "Producto no especificado",
-                    style: const pw.TextStyle(fontSize: 11)),
+                    style: const pw.TextStyle(fontSize: 7)),
               ),
               ),
               pw.Expanded(
               pw.Expanded(
-                flex: 2,
-                child: pw.Text(
-                  '\$${numberFormat.format(productTotal)}',
-                  style: const pw.TextStyle(fontSize: 12),
-                  textAlign: pw.TextAlign.right,
-                ),
-              ),
+                  flex: 2,
+                  child: pw.Align(
+                    alignment: pw.Alignment.centerRight,
+                    child: pw.Text(
+                      '\$${numberFormat.format(productTotal)}',
+                      style: const pw.TextStyle(fontSize: 7),
+                    ),
+                  )),
             ],
             ],
           ),
           ),
           ...toppingsList,
           ...toppingsList,
@@ -313,22 +307,18 @@ Future<pw.Page> generarPaginaSegundoTicket(
         mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
         mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
         children: [
         children: [
           pw.Text('Subtotal:',
           pw.Text('Subtotal:',
-              style:
-                  pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
+              style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
           pw.Text('\$${numberFormat.format(subtotal)}',
           pw.Text('\$${numberFormat.format(subtotal)}',
-              style:
-                  pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
+              style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
         ],
         ],
       ),
       ),
       pw.Row(
       pw.Row(
         mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
         mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
         children: [
         children: [
           pw.Text('Descuento:',
           pw.Text('Descuento:',
-              style:
-                  pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
+              style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
           pw.Text('-\$${numberFormat.format(precioDescuento)}',
           pw.Text('-\$${numberFormat.format(precioDescuento)}',
-              style:
-                  pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
+              style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
         ],
         ],
       ),
       ),
     ]);
     ]);
@@ -339,32 +329,30 @@ Future<pw.Page> generarPaginaSegundoTicket(
       mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
       mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
       children: [
       children: [
         pw.Text('Total:',
         pw.Text('Total:',
-            style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
+            style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
         pw.Text(
         pw.Text(
             '\$${numberFormat.format(descuento > 0 ? totalConDescuento : subtotal)}',
             '\$${numberFormat.format(descuento > 0 ? totalConDescuento : subtotal)}',
-            style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)),
+            style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)),
       ],
       ],
     ),
     ),
   );
   );
 
 
   if (pedido.comentarios != null && pedido.comentarios!.isNotEmpty) {
   if (pedido.comentarios != null && pedido.comentarios!.isNotEmpty) {
-    content.add(pw.SizedBox(height: 10));
+    content.add(pw.SizedBox(height: 1));
     content.add(pw.Text('Comentarios:',
     content.add(pw.Text('Comentarios:',
-        style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 12)));
+        style: pw.TextStyle(fontWeight: pw.FontWeight.bold, fontSize: 7)));
     content.add(pw.Padding(
     content.add(pw.Padding(
       padding: const pw.EdgeInsets.only(right: 15),
       padding: const pw.EdgeInsets.only(right: 15),
       child:
       child:
-          pw.Text(pedido.comentarios!, style: const pw.TextStyle(fontSize: 12)),
+          pw.Text(pedido.comentarios!, style: const pw.TextStyle(fontSize: 7)),
     ));
     ));
-    content.add(pw.Text('.', style: pw.TextStyle(fontSize: 1)));
-    content.add(pw.Text('.', style: pw.TextStyle(fontSize: 1)));
   }
   }
 
 
-  content.add(pw.SizedBox(height: 20));
-  content.add(pw.Text('.', style: pw.TextStyle(fontSize: 1)));
+  content.add(pw.SizedBox(height: 1));
 
 
   return pw.Page(
   return pw.Page(
     pageFormat: PdfPageFormat.roll57,
     pageFormat: PdfPageFormat.roll57,
+    margin: pw.EdgeInsets.all(5),
     build: (pw.Context context) {
     build: (pw.Context context) {
       return pw.Column(
       return pw.Column(
           crossAxisAlignment: pw.CrossAxisAlignment.center, children: content);
           crossAxisAlignment: pw.CrossAxisAlignment.center, children: content);

+ 1 - 1
lib/widgets/app_drawer.dart

@@ -202,7 +202,7 @@ class AppDrawer extends StatelessWidget {
               child: Align(
               child: Align(
                 alignment: Alignment.bottomCenter,
                 alignment: Alignment.bottomCenter,
                 child: Text(
                 child: Text(
-                  'v1.24.08.27',
+                  'v1.24.09.03',
                   style: TextStyle(fontWeight: FontWeight.w300),
                   style: TextStyle(fontWeight: FontWeight.w300),
                 ),
                 ),
               ))
               ))

+ 6 - 1
lib/widgets/widgets_components.dart

@@ -328,10 +328,15 @@ alerta(BuildContext context, {String? etiqueta = "Capturar búsqueda"}) {
             Row(children: [
             Row(children: [
               Expanded(
               Expanded(
                   child: TextButton(
                   child: TextButton(
+                style: ButtonStyle(
+                    backgroundColor: MaterialStatePropertyAll(Colors.black)),
                 onPressed: () async {
                 onPressed: () async {
                   Navigator.pop(context);
                   Navigator.pop(context);
                 },
                 },
-                child: const Text('Continuar'),
+                child: const Text(
+                  'Continuar',
+                  style: TextStyle(color: Colors.white),
+                ),
               ))
               ))
             ])
             ])
           ],
           ],