Skip to content

Commit

Permalink
Modify the quantity of the products
Browse files Browse the repository at this point in the history
  • Loading branch information
Kev1nByte committed Jul 13, 2023
1 parent 59f7681 commit 3c9d950
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion views/js/ventas.js
Expand Up @@ -273,7 +273,7 @@ $(".btnAgregarProducto").click(function(){

}

}
}

}

Expand Down Expand Up @@ -307,9 +307,41 @@ $(".formularioVenta").on("change", "select.nuevaDescripcionProducto", function()

$(nuevaCantidadProducto).attr("stock", respuesta["stock"]);
$(nuevoPrecioProducto).val(respuesta["precio_venta"]);
$(nuevoPrecioProducto).attr("precioReal", respuesta["precio_venta"]);

}

})

})

// MODIFICAR LA CANTIDAD

$(".formularioVenta").on("change", "input.nuevaCantidadProducto", function(){

var precio = $(this).parent().parent().children(".ingresoPrecio").children().children(".nuevoPrecioProducto");

var precioFinal = $(this).val() * precio.attr("precioReal");

precio.val(precioFinal);

if(Number($(this).val()) > Number($(this).attr("stock"))){

// SI LA CANTIDAD ES SUPERIOR AL STOCK REGRESAR VALORES INICIALES

$(this).val(1);

swal({

title: "La cantidad supera el Stock",
text: "¡Sólo hay "+$(this).attr("stock")+" unidades!",
type: "error",
confirmButtonText: "¡Cerrar!"

});

return;

}

})

0 comments on commit 3c9d950

Please sign in to comment.