diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb
index cadf04a74..de78bfc95 100644
--- a/App_Code/ClsProductosServicios.vb
+++ b/App_Code/ClsProductosServicios.vb
@@ -875,6 +875,33 @@ Public Class ClsProductosServicios
Return Retorno
End Function
+ Public Function GetUltimoPrecioCompra(CveEmpresa As Integer, CvePS As Integer) As Double
+
+ Dim Retorno As Double = -1
+
+ DataAdapter("PA_Inv_UltimoPrecioCompraGet")
+
+ With SqlAdapter.SelectCommand.Parameters
+
+
+ .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
+ .Add("@CvePS", SqlDbType.Int).Value = CvePS
+ .Add("@PU", SqlDbType.Money).Direction = ParameterDirection.Output
+ End With
+
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = CDbl(SqlAdapter.SelectCommand.Parameters("@PU").Value)
+
+ Catch Ex1 As SqlException
+ Me.OnError("Ocurrió un error al obtener el precio unitario.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ Catch ex As Exception
+ OnError("Ocurrió un error al obtener el precio unitario", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
+ End Try
+
+ Return Retorno
+ End Function
+
#Region "P R O D U C T O S - E Q U I V A L E N C I A S "
Public Function GetPSEquivalencias(CvePS As Integer, CveEmpresa As Integer) As Boolean
diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx
index 592764f8e..874cd27a8 100644
--- a/Ventas/Ventas.aspx
+++ b/Ventas/Ventas.aspx
@@ -612,13 +612,13 @@
Paciente:
-
+
|
Episodio:
|
-
+
|
@@ -1183,7 +1183,7 @@
<%----%>
<%--0--%>
@@ -1404,6 +1404,8 @@
<%--19--%>
+
@@ -4319,6 +4321,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | SubTotal |
+
+
+ |
+ Total |
+
+
+ |
+
+
+ | % Descuento |
+
+
+
+
+ (%)
+ |
+ IVA |
+
+
+ |
+
+
+ |
+
+
+
+ |
+
+ |
+
+
+
+
+ |
+
+ |
+
+
+ |
+ |
+ Total Final |
+
+
+ |
+
+
+
+
+
+
+
+
+
-
+
<%--Medico Procedimiento--%>
@@ -8462,7 +8540,7 @@
Médico:
@@ -8517,9 +8595,9 @@
-
+
-
+
@@ -8544,14 +8622,14 @@
-
+
-
-
+
+
@@ -8560,22 +8638,22 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
@@ -9657,6 +9735,46 @@
$("#LblSubTotal1").text($("#TxtSubTotal").val());
}
+
+ function CalculaDescPS() {
+ if ($get("TxtPorPS").value != "") {
+ var PorcentajeDescuento = parseFloat($get("TxtPorPS").value);
+ if (PorcentajeDescuento < 0 || PorcentajeDescuento > 99) {
+ alert("No se puede aplicar ese porcentaje de descuento");
+ return;
+ }
+
+ var subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", ""));
+ var Monto = parseFloat($get("LblTotalDescPS").innerText.replace(",", "").replace(",", ""));
+
+ var Total = Monto - ((Monto * PorcentajeDescuento) / 100);
+
+ $get("LblTotalFinalDescPS").innerText = formato_numero(Total, 2, '.', ',');
+
+ var TotalRedondeado = parseFloat($get("LblTotalFinalDescPS").innerText.replace(",", "").replace(",", ""));
+
+ var descuento = - ((TotalRedondeado - (subTotal * 1.16)) / 1.16);
+
+ $get("LblIVADescPS").innerText = formato_numero(((subTotal - descuento) * 0.16), 2, '.', ',');
+
+ $get("LblDescPS").innerText = formato_numero(descuento, 2, '.', ',');
+ $get("HdnDescPS").value = descuento;
+
+ var totalCompra = parseFloat($get("HdnTotalCompra").value);
+ if (totalCompra > 0) {
+ var utilidad = ((TotalRedondeado - totalCompra) / TotalRedondeado) * 100;
+ $get("LblUtilidadPorcentaje").innerText = formato_numero(utilidad, 2, '.', ',');
+ }
+ }
+ else {
+ $get("LblTotalFinalDescPS").innerText = "0.00";
+ $get("LblDescPS").innerText = "0.00";
+ $get("LblIVADescPS").innerText = "0.00";
+ $get("LblUtilidadPorcentaje").innerText = "0.00";
+ $get("HdnDescPS").innerText = "0.00";
+ }
+ }
+
function formato_numero(numero, decimales, separador_decimal, separador_miles) { // v2007-08-06
numero = parseFloat(numero);
if (isNaN(numero)) {
@@ -10501,17 +10619,17 @@
}
- function fncRegargaMedicos(CveNuevoMedico) {
+ function fncRegargaMedicos(CveNuevoMedico) {
- $("#HdnCveMedicoNuevo").val(CveNuevoMedico)
- $('#BtnRecargaMedicos').click();
- }
+ $("#HdnCveMedicoNuevo").val(CveNuevoMedico)
+ $('#BtnRecargaMedicos').click();
+ }
- function fncRegargaProcedimientos(CveProcedimientoNuevo) {
+ function fncRegargaProcedimientos(CveProcedimientoNuevo) {
- $("#HdnCveProcedimientoNuevo").val(CveProcedimientoNuevo)
- $('#BtnRecargaProcedimientos').click();
- }
+ $("#HdnCveProcedimientoNuevo").val(CveProcedimientoNuevo)
+ $('#BtnRecargaProcedimientos').click();
+ }
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index df7f915bc..84fcc0b2b 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -2567,6 +2567,7 @@ Partial Class Ventas
TabAlmacen.Enabled = UsuarioActual.Empresa.UsaInventarios
TxtPorDescP.Attributes.Add("onKeyUp", "CalculaDescuento();")
TxtDescP.Attributes.Add("onKeyUp", "CalculaDescuento();")
+ TxtPorPS.Attributes.Add("onKeyUp", "CalculaDescPS();")
CreaDTmpC()
CreaDTmpF()
@@ -8245,6 +8246,10 @@ Partial Class Ventas
e.Row.FCLinkButton("imgE").Visible = True
End If
+ If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso UsuarioActual.TienePermisoProceso(374) Then
+ e.Row.FCLinkButton("LnkDescuentos").Visible = True
+ End If
+
'If GvInv.Rows.Count > 0 AndAlso ModalidadEdicion AndAlso DdlTipoComprobante.SelectedValue = "Rem" AndAlso e.Row.DataKey("CveVentaDetalle").ToString().ToEntero() > 0 Then
' e.Row.FCLinkButton("imgE").Enabled = False
' e.Row.FCLinkButton("imgE").ToolTip = "No se puede editar debido a que ya hay un movimiento de almacen."
@@ -23888,7 +23893,6 @@ Partial Class Ventas
Dim RowNum As Integer = Convert.ToInt32(e.CommandArgument)
Dim GvRow As GridViewRow = GvPS.Rows(RowNum)
-
If (GvRow.RowState = DataControlRowState.Edit OrElse GvRow.RowState = 5) Then
TxtCantidad.Text = GvRow.FCTextBox("TxtCantidad").Text
DdlClasificacion.SelectedValue = GvRow.FCDropDownList("DdlClasificacion").SelectedValue
@@ -23914,6 +23918,32 @@ Partial Class Ventas
RegistraScript("Recalcula();")
LbAgregar_Click(Nothing, Nothing)
+ ElseIf e.CommandName = "Descuento" Then
+ LblSubtotalDescPS.Text = ""
+ LblTotalDescPS.Text = ""
+ LblTituloDesc.Text = "Descuento"
+ HdnConsecPS.Value = "-1"
+ HdnTotalCompra.Value = ""
+ TxtPorPS.Text = ""
+ LblIVADescPS.Text = ""
+
+ Dim GvRow As GridViewRow = GvPS.Rows(e.CommandArgument.ToString().ToEntero())
+ LblTituloDesc.Text = $"Descuento: {GvRow.DataKey("PS")}"
+ HdnConsecPS.Value = GvRow.DataKey("Consec")
+ LblSubtotalDescPS.Text = (GvRow.DataKey("Total").ToDecimal()).FormatoNumero()
+ LblTotalDescPS.Text = (GvRow.DataKey("Total").ToDecimal() + GvRow.DataKey("ImporteIVA").ToDecimal()).FormatoNumero()
+ LblIVADescPS.Text = GvRow.DataKey("ImporteIVA").FormatoNumero()
+
+ Using ObjPS As New ClsProductosServicios
+ Dim PrecioCompra = ObjPS.GetUltimoPrecioCompra(UsuarioActual.CveEmpresa, GvRow.DataKey("CvePS").ToEntero())
+ If PrecioCompra > 0 Then
+ HdnTotalCompra.Value = (PrecioCompra * GvRow.DataKey("Cantidad").ToDouble() * 1.16).ToString()
+ End If
+ End Using
+
+ UpDescPS.Update()
+
+ RegistraScript("$('#ModalDescPS').modal({backdrop: 'static', keyboard: false});")
Else
DdlPS_SelectedIndexChanged(Nothing, Nothing)
End If
@@ -36794,6 +36824,20 @@ Partial Class Ventas
Protected Sub TxtFechaAnticipoCliente_TextChanged(sender As Object, e As EventArgs)
CargaAnticipos(CveCliente)
End Sub
+ Protected Sub BtnPorPS_Click(sender As Object, e As EventArgs)
+ If HdnDescPS.Value.ToEntero() > 0 Then
+ Dim RowUpdate As DataRow = TmpDT.Select($"Consec = {HdnConsecPS.Value}").FirstOrDefault()
+ If RowUpdate IsNot Nothing Then
+ RowUpdate("Descuento") = HdnDescPS.Value.ToDecimal()
+ RowUpdate("ImporteIVA") = LblIVADescPS.Text.ToDecimal()
+ CalculaTotalesVenta()
+ RegistraScript("$('#ModalDescPS').modal('hide');")
+ End If
+ Else
+ Alert("No se pudo aplicar el descuento", TipoMensaje.MsgAdvertencia)
+ End If
+
+ End Sub
End Class