|
@@ -25,6 +25,8 @@ class _VentaScreenState extends State<VentaScreen> {
|
|
|
double totalEfectivoDelDia = 0.0;
|
|
|
double totalTarjetaDelDia = 0.0;
|
|
|
double totalTransferenciaDelDia = 0.0;
|
|
|
+ double cambio = 0.0;
|
|
|
+ double totalSinCambio = 0.0;
|
|
|
|
|
|
String formatCurrency(double amount) {
|
|
|
final format = NumberFormat("#,##0.00", "es_MX");
|
|
@@ -200,33 +202,46 @@ class _VentaScreenState extends State<VentaScreen> {
|
|
|
fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
),
|
|
|
),
|
|
|
- if (totalEfectivoDelDia > 0)
|
|
|
- Padding(
|
|
|
- padding: const EdgeInsets.all(16.0),
|
|
|
- child: Text(
|
|
|
- "Total en Efectivo: \$${formatCurrency(totalEfectivoDelDia)}",
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- ),
|
|
|
- if (totalTarjetaDelDia > 0)
|
|
|
- Padding(
|
|
|
- padding: const EdgeInsets.all(16.0),
|
|
|
- child: Text(
|
|
|
- "Total en Tarjeta: \$${formatCurrency(totalTarjetaDelDia)}",
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- ),
|
|
|
- if (totalTransferenciaDelDia > 0)
|
|
|
- Padding(
|
|
|
- padding: const EdgeInsets.all(16.0),
|
|
|
- child: Text(
|
|
|
- "Total en Transferencia: \$${formatCurrency(totalTransferenciaDelDia)}",
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ if (totalTarjetaDelDia > 0)
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.all(16.0),
|
|
|
+ child: Text(
|
|
|
+ "Total en Tarjeta: \$${formatCurrency(totalTarjetaDelDia)}",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ if (totalTransferenciaDelDia > 0)
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.all(16.0),
|
|
|
+ child: Text(
|
|
|
+ "Total en Transferencia: \$${formatCurrency(totalTransferenciaDelDia)}",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ if (totalEfectivoDelDia > 0)
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.all(16.0),
|
|
|
+ child: Text(
|
|
|
+ "Total en Efectivo: \$${formatCurrency(totalEfectivoDelDia)}",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ if (cambio > 0)
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.all(16.0),
|
|
|
+ child: Text(
|
|
|
+ "Cambio Entregado: \$${formatCurrency(cambio)}",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
if (totalCancelados > 0)
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
@@ -249,11 +264,14 @@ class _VentaScreenState extends State<VentaScreen> {
|
|
|
}
|
|
|
|
|
|
void cargarPedidos(DateTime fecha) async {
|
|
|
- final inicioDelDia = DateTime.utc(fecha.year, fecha.month, fecha.day);
|
|
|
- final finDelDia =
|
|
|
- DateTime.utc(fecha.year, fecha.month, fecha.day, 23, 59, 59);
|
|
|
+ // Convertir el inicio y fin del día local a UTC
|
|
|
+ final inicioDelDia = DateTime(fecha.year, fecha.month, fecha.day)
|
|
|
+ .toUtc(); // Convierte la fecha local de inicio del día a UTC
|
|
|
|
|
|
- print('Buscando pedidos desde: $inicioDelDia hasta: $finDelDia');
|
|
|
+ final finDelDia = DateTime(fecha.year, fecha.month, fecha.day, 23, 59, 59)
|
|
|
+ .toUtc(); // Convierte la fecha local de fin del día a UTC
|
|
|
+
|
|
|
+ print('Buscando pedidos desde: $inicioDelDia hasta: $finDelDia (en UTC)');
|
|
|
|
|
|
// Realizar la búsqueda en UTC
|
|
|
final pedidos = await Provider.of<PedidoViewModel>(context, listen: false)
|
|
@@ -273,12 +291,18 @@ class _VentaScreenState extends State<VentaScreen> {
|
|
|
totalEfectivoDelDia = 0.0;
|
|
|
totalTarjetaDelDia = 0.0;
|
|
|
totalTransferenciaDelDia = 0.0;
|
|
|
+ cambio = 0.0;
|
|
|
+ totalSinCambio = 0.0;
|
|
|
|
|
|
for (var pedido in pedidosNoCancelados) {
|
|
|
totalDelDia += pedido.totalPedido ?? 0.0;
|
|
|
totalEfectivoDelDia += pedido.cantEfectivo ?? 0.0;
|
|
|
totalTarjetaDelDia += pedido.cantTarjeta ?? 0.0;
|
|
|
totalTransferenciaDelDia += pedido.cantTransferencia ?? 0.0;
|
|
|
+ totalSinCambio =
|
|
|
+ totalEfectivoDelDia + totalTarjetaDelDia + totalTransferenciaDelDia;
|
|
|
+
|
|
|
+ cambio = totalSinCambio - totalDelDia;
|
|
|
}
|
|
|
|
|
|
totalCancelados = pedidosCancelados.fold(
|