|
@@ -18,6 +18,7 @@ class PedidoForm extends StatefulWidget {
|
|
|
|
|
|
class _PedidoFormState extends State<PedidoForm> {
|
|
|
final _busqueda = TextEditingController(text: '');
|
|
|
+ final TextEditingController _descuentoController = TextEditingController();
|
|
|
CategoriaProductoViewModel cvm = CategoriaProductoViewModel();
|
|
|
ProductoViewModel pvm = ProductoViewModel();
|
|
|
PedidoViewModel pedvm = PedidoViewModel();
|
|
@@ -32,6 +33,18 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
ScrollController _gridViewController = ScrollController();
|
|
|
final _searchController = TextEditingController();
|
|
|
final NumberFormat _numberFormat = NumberFormat.decimalPattern('es_MX');
|
|
|
+ int? selectedDescuento = 0;
|
|
|
+ double subtotal = 0;
|
|
|
+ double precioDescuento = 0;
|
|
|
+ double totalPedido = 0;
|
|
|
+
|
|
|
+ bool efectivoSeleccionado = false;
|
|
|
+ bool tarjetaSeleccionada = false;
|
|
|
+ bool transferenciaSeleccionada = false;
|
|
|
+ TextEditingController efectivoController = TextEditingController();
|
|
|
+ TextEditingController tarjetaController = TextEditingController();
|
|
|
+ TextEditingController transferenciaController = TextEditingController();
|
|
|
+ double cambio = 0.0;
|
|
|
|
|
|
double calcularTotalPedido() {
|
|
|
double total = 0;
|
|
@@ -53,6 +66,17 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
return total;
|
|
|
}
|
|
|
|
|
|
+ double aplicarDescuento(double total, int? descuento) {
|
|
|
+ if (descuento != null && descuento > 0) {
|
|
|
+ double totalPedido = total * (1 - descuento / 100);
|
|
|
+ // print(
|
|
|
+ // 'Total con descuento: $totalPedido (Descuento aplicado: $descuento%)');
|
|
|
+ return totalPedido;
|
|
|
+ }
|
|
|
+ // print('Sin descuento, total: $total');
|
|
|
+ return total;
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
@@ -62,6 +86,8 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
cargarProductosPorCategoria(categoriaSeleccionada!.id);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ Provider.of<DescuentoViewModel>(context, listen: false).cargarDescuentos();
|
|
|
}
|
|
|
|
|
|
_onSearchChanged(String value) {
|
|
@@ -73,6 +99,24 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ void _recalcularTotal() {
|
|
|
+ subtotal = calcularTotalPedido();
|
|
|
+ // print('Subtotal: $subtotal');
|
|
|
+ // print('Descuento seleccionado: $selectedDescuento%');
|
|
|
+
|
|
|
+ precioDescuento = subtotal * (selectedDescuento! / 100);
|
|
|
+ totalPedido = subtotal - precioDescuento;
|
|
|
+
|
|
|
+ setState(() {
|
|
|
+ pedidoActual = pedidoActual ?? Pedido();
|
|
|
+ pedidoActual!.totalPedido = totalPedido;
|
|
|
+ pedidoActual!.descuento = selectedDescuento;
|
|
|
+ });
|
|
|
+
|
|
|
+ // print('Precio descuento: $precioDescuento');
|
|
|
+ // print('Total con descuento aplicado: $totalPedido');
|
|
|
+ }
|
|
|
+
|
|
|
void _finalizeOrder() async {
|
|
|
if (carrito.isEmpty) {
|
|
|
showDialog(
|
|
@@ -102,12 +146,8 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
},
|
|
|
);
|
|
|
return;
|
|
|
- } else {
|
|
|
- int? pedidoId = pedidoActual?.id;
|
|
|
- if (pedidoId != null) {
|
|
|
- Navigator.of(context).pop();
|
|
|
- }
|
|
|
}
|
|
|
+
|
|
|
await _promptForCustomerName();
|
|
|
}
|
|
|
|
|
@@ -115,6 +155,38 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
TextEditingController nombreController = TextEditingController();
|
|
|
TextEditingController comentarioController = TextEditingController();
|
|
|
String errorMessage = '';
|
|
|
+ double faltante = totalPedido;
|
|
|
+ bool totalCompletado = false;
|
|
|
+
|
|
|
+ void _calcularCambio(StateSetter setState) {
|
|
|
+ double totalPagado = (double.tryParse(efectivoController.text) ?? 0) +
|
|
|
+ (double.tryParse(tarjetaController.text) ?? 0) +
|
|
|
+ (double.tryParse(transferenciaController.text) ?? 0);
|
|
|
+
|
|
|
+ setState(() {
|
|
|
+ cambio = totalPagado - totalPedido;
|
|
|
+ if (cambio < 0) {
|
|
|
+ faltante = totalPedido - totalPagado;
|
|
|
+ cambio = 0;
|
|
|
+ totalCompletado = false;
|
|
|
+ } else {
|
|
|
+ faltante = 0;
|
|
|
+ totalCompletado = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void _validarCantidad(
|
|
|
+ StateSetter setState, TextEditingController controller) {
|
|
|
+ double cantidad = double.tryParse(controller.text) ?? 0;
|
|
|
+ if (cantidad > totalPedido) {
|
|
|
+ setState(() {
|
|
|
+ controller.text = totalPedido.toStringAsFixed(2);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ _calcularCambio(setState);
|
|
|
+ }
|
|
|
+
|
|
|
bool? shouldSave = await showDialog<bool>(
|
|
|
context: context,
|
|
|
builder: (BuildContext context) {
|
|
@@ -135,12 +207,11 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
hintText: "Nombre del Cliente",
|
|
|
errorText: errorMessage.isEmpty ? null : errorMessage,
|
|
|
onChanged: (value) {
|
|
|
- if (value.trim().isEmpty) {
|
|
|
- setState(() => errorMessage =
|
|
|
- "El nombre del cliente es obligatorio.");
|
|
|
- } else {
|
|
|
- setState(() => errorMessage = '');
|
|
|
- }
|
|
|
+ setState(() {
|
|
|
+ errorMessage = value.trim().isEmpty
|
|
|
+ ? "El nombre del cliente es obligatorio."
|
|
|
+ : '';
|
|
|
+ });
|
|
|
},
|
|
|
),
|
|
|
const SizedBox(height: 10),
|
|
@@ -150,6 +221,177 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
hintText: 'Comentarios',
|
|
|
maxLines: 3,
|
|
|
),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ Align(
|
|
|
+ alignment: Alignment.center,
|
|
|
+ child: Text(
|
|
|
+ 'Métodos de pago',
|
|
|
+ style:
|
|
|
+ TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ // Efectivo
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Checkbox(
|
|
|
+ activeColor: AppTheme.primary,
|
|
|
+ value: efectivoSeleccionado,
|
|
|
+ onChanged:
|
|
|
+ (totalCompletado && !efectivoSeleccionado)
|
|
|
+ ? null
|
|
|
+ : (bool? value) {
|
|
|
+ setState(() {
|
|
|
+ efectivoSeleccionado = value ?? false;
|
|
|
+ if (!efectivoSeleccionado) {
|
|
|
+ efectivoController.clear();
|
|
|
+ _calcularCambio(setState);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ const Text(
|
|
|
+ "Efectivo",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ if (efectivoSeleccionado)
|
|
|
+ SizedBox(
|
|
|
+ width: 150,
|
|
|
+ child: AppTextField(
|
|
|
+ controller: efectivoController,
|
|
|
+ etiqueta: 'Cantidad',
|
|
|
+ hintText: '0.00',
|
|
|
+ keyboardType: TextInputType.number,
|
|
|
+ onChanged: (value) => _calcularCambio(setState),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ // Tarjeta
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Checkbox(
|
|
|
+ activeColor: AppTheme.primary,
|
|
|
+ value: tarjetaSeleccionada,
|
|
|
+ onChanged: (totalCompletado && !tarjetaSeleccionada)
|
|
|
+ ? null
|
|
|
+ : (bool? value) {
|
|
|
+ setState(() {
|
|
|
+ tarjetaSeleccionada = value ?? false;
|
|
|
+ if (!tarjetaSeleccionada) {
|
|
|
+ tarjetaController.clear();
|
|
|
+ _calcularCambio(setState);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ const Text(
|
|
|
+ "Tarjeta",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ if (tarjetaSeleccionada)
|
|
|
+ SizedBox(
|
|
|
+ width: 150,
|
|
|
+ child: AppTextField(
|
|
|
+ controller: tarjetaController,
|
|
|
+ etiqueta: 'Cantidad',
|
|
|
+ hintText: '0.00',
|
|
|
+ keyboardType: TextInputType.number,
|
|
|
+ onChanged: (value) {
|
|
|
+ _validarCantidad(setState, tarjetaController);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ // Transferencia
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Checkbox(
|
|
|
+ activeColor: AppTheme.primary,
|
|
|
+ value: transferenciaSeleccionada,
|
|
|
+ onChanged:
|
|
|
+ (totalCompletado && !transferenciaSeleccionada)
|
|
|
+ ? null
|
|
|
+ : (bool? value) {
|
|
|
+ setState(() {
|
|
|
+ transferenciaSeleccionada =
|
|
|
+ value ?? false;
|
|
|
+ if (!transferenciaSeleccionada) {
|
|
|
+ transferenciaController.clear();
|
|
|
+ _calcularCambio(setState);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ const Text(
|
|
|
+ "Transferencia",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ if (transferenciaSeleccionada)
|
|
|
+ SizedBox(
|
|
|
+ width: 150,
|
|
|
+ child: AppTextField(
|
|
|
+ controller: transferenciaController,
|
|
|
+ etiqueta: 'Cantidad',
|
|
|
+ hintText: '0.00',
|
|
|
+ keyboardType: TextInputType.number,
|
|
|
+ onChanged: (value) {
|
|
|
+ _validarCantidad(
|
|
|
+ setState, transferenciaController);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ // Mostrar el total del pedido y la cantidad faltante
|
|
|
+ Align(
|
|
|
+ alignment: Alignment.centerRight,
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ 'Total del pedido: \$${totalPedido.toStringAsFixed(2)}',
|
|
|
+ style: const TextStyle(
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 18),
|
|
|
+ ),
|
|
|
+ if (faltante > 0)
|
|
|
+ Text(
|
|
|
+ 'Faltante: \$${faltante.toStringAsFixed(2)}',
|
|
|
+ style: const TextStyle(
|
|
|
+ color: Colors.red,
|
|
|
+ fontSize: 18,
|
|
|
+ fontWeight: FontWeight.bold),
|
|
|
+ )
|
|
|
+ else if (cambio > 0)
|
|
|
+ Text('Cambio: \$${cambio.toStringAsFixed(2)}',
|
|
|
+ style: const TextStyle(
|
|
|
+ color: Colors.green,
|
|
|
+ fontSize: 18,
|
|
|
+ fontWeight: FontWeight.bold)),
|
|
|
+ ]),
|
|
|
+ ),
|
|
|
],
|
|
|
),
|
|
|
actions: <Widget>[
|
|
@@ -165,8 +407,7 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
style: ButtonStyle(
|
|
|
padding: MaterialStatePropertyAll(
|
|
|
EdgeInsets.fromLTRB(30, 20, 30, 20)),
|
|
|
- backgroundColor:
|
|
|
- MaterialStatePropertyAll(AppTheme.primary),
|
|
|
+ backgroundColor: MaterialStatePropertyAll(Colors.red),
|
|
|
foregroundColor:
|
|
|
MaterialStatePropertyAll(AppTheme.secondary)),
|
|
|
),
|
|
@@ -208,14 +449,21 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
DateTime now = DateTime.now();
|
|
|
String formattedDate = DateFormat('dd-MM-yyyy kk:mm:ss').format(now);
|
|
|
|
|
|
- double totalPedido = calcularTotalPedido();
|
|
|
-
|
|
|
Pedido nuevoPedido = Pedido(
|
|
|
peticion: formattedDate,
|
|
|
nombreCliente: nombreCliente,
|
|
|
comentarios: comentarios,
|
|
|
estatus: "NUEVO",
|
|
|
totalPedido: totalPedido,
|
|
|
+ descuento: pedidoActual?.descuento,
|
|
|
+ tipoPago: _obtenerTipoPago(),
|
|
|
+ cantEfectivo:
|
|
|
+ efectivoSeleccionado ? double.tryParse(efectivoController.text) : 0,
|
|
|
+ cantTarjeta:
|
|
|
+ tarjetaSeleccionada ? double.tryParse(tarjetaController.text) : 0,
|
|
|
+ cantTransferencia: transferenciaSeleccionada
|
|
|
+ ? double.tryParse(transferenciaController.text)
|
|
|
+ : 0,
|
|
|
);
|
|
|
|
|
|
List<PedidoProducto> listaPedidoProducto = carrito.map((item) {
|
|
@@ -244,14 +492,15 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
bool result = await Provider.of<PedidoViewModel>(context, listen: false)
|
|
|
.guardarPedidoLocal(pedido: nuevoPedido);
|
|
|
|
|
|
+ if (!mounted) return;
|
|
|
+
|
|
|
if (result) {
|
|
|
- // Recuperar el pedido completo con detalles antes de imprimir
|
|
|
Pedido? pedidoCompleto =
|
|
|
await Provider.of<PedidoViewModel>(context, listen: false)
|
|
|
.fetchPedidoConProductos(nuevoPedido.id!);
|
|
|
|
|
|
if (pedidoCompleto != null) {
|
|
|
- imprimirTicketsJuntos(pedidoCompleto);
|
|
|
+ imprimirTicketsJuntos(context, pedidoCompleto);
|
|
|
}
|
|
|
Navigator.of(context).pop();
|
|
|
} else {
|
|
@@ -259,6 +508,14 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ String _obtenerTipoPago() {
|
|
|
+ List<String> tiposPago = [];
|
|
|
+ if (efectivoSeleccionado) tiposPago.add('Efectivo');
|
|
|
+ if (tarjetaSeleccionada) tiposPago.add('Tarjeta');
|
|
|
+ if (transferenciaSeleccionada) tiposPago.add('Transferencia');
|
|
|
+ return tiposPago.join(',');
|
|
|
+ }
|
|
|
+
|
|
|
void _limpiarBusqueda() async {
|
|
|
setState(() {
|
|
|
_busqueda.text = '';
|
|
@@ -329,6 +586,7 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
));
|
|
|
});
|
|
|
}
|
|
|
+ _recalcularTotal();
|
|
|
}
|
|
|
|
|
|
Future<Map<int, List<Producto>>> obtenerToppingsSeleccionables(
|
|
@@ -386,6 +644,106 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Widget _buildDiscountSection() {
|
|
|
+ return Padding(
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ const Text(
|
|
|
+ 'Descuento',
|
|
|
+ style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
|
|
+ ),
|
|
|
+ const Spacer(),
|
|
|
+ ConstrainedBox(
|
|
|
+ constraints: const BoxConstraints(
|
|
|
+ maxWidth: 150,
|
|
|
+ ),
|
|
|
+ child: Consumer<DescuentoViewModel>(
|
|
|
+ builder: (context, viewModel, child) {
|
|
|
+ return AppDropdownModel<int>(
|
|
|
+ hint: 'Seleccionar',
|
|
|
+ items: viewModel.descuentos
|
|
|
+ .map(
|
|
|
+ (descuento) => DropdownMenuItem<int>(
|
|
|
+ value: descuento.porcentaje,
|
|
|
+ child: Text(
|
|
|
+ '${descuento.porcentaje}%',
|
|
|
+ style: const TextStyle(color: Colors.black),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ .toList(),
|
|
|
+ selectedValue: selectedDescuento,
|
|
|
+ onChanged: (value) {
|
|
|
+ setState(() {
|
|
|
+ selectedDescuento = value;
|
|
|
+ _recalcularTotal();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildTotalSection() {
|
|
|
+ String formattedsubtotal = _numberFormat.format(subtotal);
|
|
|
+ String formattedPrecioDescuento = _numberFormat.format(precioDescuento);
|
|
|
+ String formattedtotalPedido = _numberFormat.format(totalPedido);
|
|
|
+
|
|
|
+ return Padding(
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ if (precioDescuento > 0)
|
|
|
+ Column(
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ const Text('Subtotal',
|
|
|
+ style: TextStyle(
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
+ Text("\$$formattedsubtotal",
|
|
|
+ style: const TextStyle(
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ const Text('Descuento',
|
|
|
+ style: TextStyle(
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
+ Text("-\$$formattedPrecioDescuento",
|
|
|
+ style: const TextStyle(
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ const Text('Total',
|
|
|
+ style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
+ Text("\$$formattedtotalPedido",
|
|
|
+ style: const TextStyle(
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Scaffold(
|
|
@@ -406,24 +764,6 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget _buildTotalSection() {
|
|
|
- double total = calcularTotalPedido();
|
|
|
- String formattedTotal = _numberFormat.format(total);
|
|
|
- return Padding(
|
|
|
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- const Text('Total',
|
|
|
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
- Text("\$$formattedTotal",
|
|
|
- style:
|
|
|
- const TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
Widget _buildCartSection() {
|
|
|
return Card(
|
|
|
margin: const EdgeInsets.all(8.0),
|
|
@@ -563,6 +903,7 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
}
|
|
|
}
|
|
|
setState(() {});
|
|
|
+ _recalcularTotal();
|
|
|
},
|
|
|
);
|
|
|
},
|
|
@@ -578,6 +919,7 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
},
|
|
|
),
|
|
|
),
|
|
|
+ _buildDiscountSection(),
|
|
|
const Divider(thickness: 5),
|
|
|
_buildTotalSection(),
|
|
|
const SizedBox(height: 25),
|
|
@@ -603,12 +945,14 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
setState(() {
|
|
|
carrito.removeAt(index);
|
|
|
});
|
|
|
+ _recalcularTotal();
|
|
|
}
|
|
|
|
|
|
void incrementarProducto(ItemCarrito item) {
|
|
|
setState(() {
|
|
|
item.cantidad++;
|
|
|
});
|
|
|
+ _recalcularTotal();
|
|
|
}
|
|
|
|
|
|
void quitarProductoDelCarrito(ItemCarrito item) {
|
|
@@ -619,12 +963,12 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
|
carrito.remove(item);
|
|
|
}
|
|
|
});
|
|
|
+ _recalcularTotal();
|
|
|
}
|
|
|
|
|
|
Widget _buildProductsSection() {
|
|
|
return Column(
|
|
|
children: [
|
|
|
- // _buildSearchBar(),
|
|
|
const SizedBox(height: 10),
|
|
|
_buildCategoryButtons(),
|
|
|
const SizedBox(height: 15),
|