فهرست منبع

Agregar soporte para descuento en impreso

ronald 3 ماه پیش
والد
کامیت
03b026739a
1فایلهای تغییر یافته به همراه11 افزوده شده و 1 حذف شده
  1. 11 1
      factura_electronica.php

+ 11 - 1
factura_electronica.php

@@ -124,6 +124,7 @@ if($dataPrint){
             $totalUnitario = $producto->cant * $producto->costo;
             $cantidad = str_pad(number_format($producto->cant, 2), 4, " ", STR_PAD_RIGHT);
             $precio = str_pad(number_format($producto->costo, 2), 7, " ", STR_PAD_LEFT);
+            $descuento = $producto->descuento && $producto->descuento > 0 ? $producto->descuento : null;
             $total = str_pad(number_format($totalUnitario, 2), 7, " ", STR_PAD_LEFT);
 
             // Dividir la descripción en líneas
@@ -137,6 +138,10 @@ if($dataPrint){
             for ($i = 1; $i < count($lineasDescripcion); $i++) {
                 $printer->text("     " . str_pad($lineasDescripcion[$i], $maxDescripcion) . "\n");
             }
+            // Imprimir línea de descuento si existe
+            if ($descuento) {
+                $printer->text(str_pad("        Descuento:", $maxDescripcion, " ") . str_pad("-" . number_format($descuento, 2), 21, " ", STR_PAD_LEFT) . "\n");
+            }   
         }
         
         $printer->text(str_repeat("-", 45) . "\n");
@@ -167,7 +172,7 @@ if($dataPrint){
         
         // CÓDIGO QR
         $printer->text("$qrMessage\n");
-        $printer->qrCode($urlQR, Printer::QR_ECLEVEL_L, 6);
+        $printer->qrCode($urlQR, Printer::QR_ECLEVEL_L, 5);
 
         $printer->text("\n$mensaje\n");
 
@@ -196,4 +201,9 @@ if($dataPrint){
             "message" => "Error al imprimir: " . $e->getMessage()
         ]);
     }
+}else{
+    echo json_encode([
+        "status" => "error",
+        "message" => "No se recibieron datos para imprimir."
+    ]);
 }