|
@@ -38,6 +38,9 @@ class VentaTicket {
|
|
double totalTransferencia = pedidosNoCancelados.fold(
|
|
double totalTransferencia = pedidosNoCancelados.fold(
|
|
0.0, (sum, p) => sum + (p.cantTransferencia ?? 0.0));
|
|
0.0, (sum, p) => sum + (p.cantTransferencia ?? 0.0));
|
|
|
|
|
|
|
|
+ double totalSinCambio = totalEfectivo + totalTarjeta + totalTransferencia;
|
|
|
|
+ double cambio = totalSinCambio - totalNoCancelados;
|
|
|
|
+
|
|
final spelling = SpellingNumber(lang: 'es');
|
|
final spelling = SpellingNumber(lang: 'es');
|
|
String totalEnLetras = toTitleCase(spelling.convert(totalNoCancelados));
|
|
String totalEnLetras = toTitleCase(spelling.convert(totalNoCancelados));
|
|
|
|
|
|
@@ -48,14 +51,12 @@ class VentaTicket {
|
|
String formattedTotalTarjeta = numberFormat.format(totalTarjeta);
|
|
String formattedTotalTarjeta = numberFormat.format(totalTarjeta);
|
|
String formattedTotalTransferencia =
|
|
String formattedTotalTransferencia =
|
|
numberFormat.format(totalTransferencia);
|
|
numberFormat.format(totalTransferencia);
|
|
|
|
+ String formattedCambio = numberFormat.format(cambio);
|
|
|
|
|
|
int centavos =
|
|
int centavos =
|
|
((totalNoCancelados - totalNoCancelados.floor()) * 100).round();
|
|
((totalNoCancelados - totalNoCancelados.floor()) * 100).round();
|
|
String centavosEnLetras = centavos.toString().padLeft(2, '0') + "/100 M.N.";
|
|
String centavosEnLetras = centavos.toString().padLeft(2, '0') + "/100 M.N.";
|
|
|
|
|
|
- print("Total en letras: $totalEnLetras $centavosEnLetras");
|
|
|
|
- print("Total formateado: $formattedTotalNoCancelados");
|
|
|
|
-
|
|
|
|
pdf.addPage(pw.Page(
|
|
pdf.addPage(pw.Page(
|
|
pageFormat: PdfPageFormat.roll57,
|
|
pageFormat: PdfPageFormat.roll57,
|
|
build: (pw.Context context) {
|
|
build: (pw.Context context) {
|
|
@@ -94,19 +95,25 @@ class VentaTicket {
|
|
child: pw.Column(
|
|
child: pw.Column(
|
|
crossAxisAlignment: pw.CrossAxisAlignment.start,
|
|
crossAxisAlignment: pw.CrossAxisAlignment.start,
|
|
children: [
|
|
children: [
|
|
- pw.Text("- Total en Efectivo: \$${formattedTotalEfectivo}",
|
|
|
|
- style: pw.TextStyle(
|
|
|
|
- fontWeight: pw.FontWeight.bold, fontSize: 11)),
|
|
|
|
- pw.Text("- Total en Tarjeta: \$${formattedTotalTarjeta}",
|
|
|
|
- style: pw.TextStyle(
|
|
|
|
- fontWeight: pw.FontWeight.bold, fontSize: 11)),
|
|
|
|
- pw.Text(
|
|
|
|
- "- Total en Transferencia: \$${formattedTotalTransferencia}",
|
|
|
|
- style: pw.TextStyle(
|
|
|
|
- fontWeight: pw.FontWeight.bold, fontSize: 11)),
|
|
|
|
- pw.Text("- Total General: \$${formattedTotalNoCancelados}",
|
|
|
|
|
|
+ if (totalTarjeta > 0)
|
|
|
|
+ pw.Text("Tarjeta: \$${formattedTotalTarjeta}",
|
|
|
|
+ style: pw.TextStyle(
|
|
|
|
+ fontWeight: pw.FontWeight.bold, fontSize: 9.5)),
|
|
|
|
+ if (totalTransferencia > 0)
|
|
|
|
+ pw.Text("Transf: \$${formattedTotalTransferencia}",
|
|
|
|
+ style: pw.TextStyle(
|
|
|
|
+ fontWeight: pw.FontWeight.bold, fontSize: 9.5)),
|
|
|
|
+ if (totalEfectivo > 0)
|
|
|
|
+ pw.Text("Efectivo: \$${formattedTotalEfectivo}",
|
|
|
|
+ style: pw.TextStyle(
|
|
|
|
+ fontWeight: pw.FontWeight.bold, fontSize: 9.5)),
|
|
|
|
+ if (cambio > 0)
|
|
|
|
+ pw.Text("Cambio: \$${formattedCambio}",
|
|
|
|
+ style: pw.TextStyle(
|
|
|
|
+ fontWeight: pw.FontWeight.bold, fontSize: 9.5)),
|
|
|
|
+ pw.Text("Total: \$${formattedTotalNoCancelados}",
|
|
style: pw.TextStyle(
|
|
style: pw.TextStyle(
|
|
- fontWeight: pw.FontWeight.bold, fontSize: 11)),
|
|
|
|
|
|
+ fontWeight: pw.FontWeight.bold, fontSize: 9.5)),
|
|
pw.Text("Son: $totalEnLetras Pesos $centavosEnLetras",
|
|
pw.Text("Son: $totalEnLetras Pesos $centavosEnLetras",
|
|
style: pw.TextStyle(fontSize: 10))
|
|
style: pw.TextStyle(fontSize: 10))
|
|
],
|
|
],
|
|
@@ -126,7 +133,7 @@ class VentaTicket {
|
|
child: pw.Row(
|
|
child: pw.Row(
|
|
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
|
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
children: [
|
|
- pw.Text("Folio: ${pedido.folio} (Cancelado)",
|
|
|
|
|
|
+ pw.Text("Folio: ${pedido.folio}",
|
|
style: pw.TextStyle(fontSize: 10)),
|
|
style: pw.TextStyle(fontSize: 10)),
|
|
pw.Text("\$${pedido.totalPedido?.toStringAsFixed(2)}",
|
|
pw.Text("\$${pedido.totalPedido?.toStringAsFixed(2)}",
|
|
style: pw.TextStyle(fontSize: 10)),
|
|
style: pw.TextStyle(fontSize: 10)),
|