-- aplicar promociones a toda la una cotización/remisión. al editar la partida, verificar si tiene promoción de nuevo.

This commit is contained in:
2025-01-03 18:24:38 -07:00
parent 6eb9a67eb1
commit d3d554c18b
3 changed files with 55 additions and 9 deletions

View File

@@ -1631,7 +1631,7 @@ Public Class ClsVentas
Return Retorno Return Retorno
End Function End Function
Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, IEPS As Decimal, PorcentajeIEPS As Decimal, IVA As Decimal, PorcentajeIVA As Decimal, Descuento As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, IEPS As Decimal, PorcentajeIEPS As Decimal, IVA As Decimal, PorcentajeIVA As Decimal, Descuento As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1, Optional CvePromocionDetalle As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_VentasDetalleRemisionUpdate") DataAdapter("PA_VentasDetalleRemisionUpdate")
@@ -1647,6 +1647,7 @@ Public Class ClsVentas
.Add("@Descuento", SqlDbType.Decimal).Value = Descuento .Add("@Descuento", SqlDbType.Decimal).Value = Descuento
.Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones
.Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico
.Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle
End With End With
Try Try

View File

@@ -407,6 +407,10 @@
<li> <li>
<asp:HyperLink ID="HLFAgregarOS" Target="_blank" runat="server" Visible="false"> <i class="fa fa-plus"></i> Agregar Orden de Servicio</asp:HyperLink> <asp:HyperLink ID="HLFAgregarOS" Target="_blank" runat="server" Visible="false"> <i class="fa fa-plus"></i> Agregar Orden de Servicio</asp:HyperLink>
</li> </li>
<li id="LiCalcularPromociones" runat="server" visible="false">
<asp:LinkButton ID="LnkCalcularPromociones" runat="server" CausesValidation="False" Text="<i class='fa fa-tag'></i> Aplicar promociones" OnClick="LnkCalcularPromociones_Click"
data-toggle="confirmation" data-popout="true" data-original-title="¿Aplicar Promociones?" data-btn-ok-label="si" />
</li>
</ContentTemplate> </ContentTemplate>
<Triggers> <Triggers>
<asp:AsyncPostBackTrigger ControlID="LnkImprimir" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="LnkImprimir" EventName="Click" />
@@ -8343,7 +8347,7 @@
<div id="DivCorreoCuentaCliente" runat="server" visible="false" class="row" style="padding-left: 16px;"> <div id="DivCorreoCuentaCliente" runat="server" visible="false" class="row" style="padding-left: 16px;">
<div class="form-group form-md-line-input input-iconright col-xs-6"> <div class="form-group form-md-line-input input-iconright col-xs-6">
<asp:TextBox ID="TxtCorreoCliente" CssClass="form-control" runat="server" MaxLength="300" CausesValidation="true"></asp:TextBox> <asp:TextBox ID="TxtCorreoCliente" CssClass="form-control" runat="server" MaxLength="300" CausesValidation="true"></asp:TextBox>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" CssClass="help-block errorimput" ValidationExpression="(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*" ControlToValidate="TxtCorreoCliente" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Email''</b> no es válido, por favor ingrése uno correcto." ValidationGroup="GrpGuardarCliente"></asp:RegularExpressionValidator>--%> <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" CssClass="help-block errorimput" ValidationExpression="(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*" ControlToValidate="TxtCorreoCliente" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Email''</b> no es válido, por favor ingrése uno correcto." ValidationGroup="GrpGuardarCliente"></asp:RegularExpressionValidator>--%>
<label for="<%= TxtCorreoCliente.ClientID.ToString()%>">Email: </label> <label for="<%= TxtCorreoCliente.ClientID.ToString()%>">Email: </label>
<i></i> <i></i>
</div> </div>

View File

@@ -23821,6 +23821,11 @@ Partial Class Ventas
End If End If
End If End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = True
End If
TxtAtencionA.Enabled = True TxtAtencionA.Enabled = True
UpCliente.Update() UpCliente.Update()
@@ -23828,6 +23833,7 @@ Partial Class Ventas
UpPS.Update() UpPS.Update()
UpCliente.Update() UpCliente.Update()
UPObservaciones.Update() UPObservaciones.Update()
UpnTools.Update()
End Sub End Sub
Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click
@@ -23954,7 +23960,7 @@ Partial Class Ventas
For Each Row As DataRow In TmpDT.Rows For Each Row As DataRow In TmpDT.Rows
Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero() Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero()
If CveVentaDetalle > 0 Then If CveVentaDetalle > 0 Then
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Descuento").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario) Then If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Descuento").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario, CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero()) Then
OcurrioError = True OcurrioError = True
Exit For Exit For
End If End If
@@ -23962,7 +23968,7 @@ Partial Class Ventas
If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("CveUM").ToString().ToEntero(), If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("CveUM").ToString().ToEntero(),
Row("PU").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), Row("PU").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6),
Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(), Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(),
CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString()}").ToEntero(), -1), CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(),
ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDecimal, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDecimal, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal()) Then ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDecimal, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDecimal, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal()) Then
OcurrioError = True OcurrioError = True
Exit For Exit For
@@ -24897,7 +24903,7 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then EjecutaRecalculaPrecios = True If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then EjecutaRecalculaPrecios = True
If UsuarioActual.CveEmpresa = 189 Then EjecutaRecalculaPrecios = False If UsuarioActual.CveEmpresa = 189 Then EjecutaRecalculaPrecios = False
If EjecutaRecalculaPrecios Then RecalculaPrecios() If EjecutaRecalculaPrecios Then RecalculaPrecios(False)
End Sub End Sub
Private Function ValidaPagosContado(Optional MostrarAlertas As Boolean = True, Optional TipoDoctoViejo As String = "") As Boolean Private Function ValidaPagosContado(Optional MostrarAlertas As Boolean = True, Optional TipoDoctoViejo As String = "") As Boolean
@@ -31899,6 +31905,9 @@ Partial Class Ventas
BtnCrearApartirDe.Visible = False BtnCrearApartirDe.Visible = False
BtnGenerarRemision.Visible = False BtnGenerarRemision.Visible = False
BtnPermisoEditarCotizacion.Visible = False BtnPermisoEditarCotizacion.Visible = False
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = False
End If
BtnEditarCotizacion.Visible = False BtnEditarCotizacion.Visible = False
BtnGenerarOS.Visible = False BtnGenerarOS.Visible = False
@@ -32967,12 +32976,16 @@ Partial Class Ventas
End If End If
End If End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = True
End If
UpPS.Update() UpPS.Update()
UPPDescuento.Update() UPPDescuento.Update()
UPObservaciones.Update() UPObservaciones.Update()
UPCondicionesPago.Update() UPCondicionesPago.Update()
UpCliente.Update() UpCliente.Update()
UpnTools.Update()
End Sub End Sub
Private Sub BtnEditarCotizacion_Click(sender As Object, e As EventArgs) Handles BtnEditarCotizacion.Click Private Sub BtnEditarCotizacion_Click(sender As Object, e As EventArgs) Handles BtnEditarCotizacion.Click
@@ -33107,7 +33120,7 @@ Partial Class Ventas
Row("PU").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal() * (1 + Row("PorcentajeIVA").ToString().ToDecimal())), 6), Row("PU").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal() * (1 + Row("PorcentajeIVA").ToString().ToDecimal())), 6),
Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(),
PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDecimal, TiempoEntrega:=Row("TiempoEntrega").ToString(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDecimal, TiempoEntrega:=Row("TiempoEntrega").ToString(),
PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero()) Then
MensajeError = "Ocurrió un error al guardar las partidas de la cotización" MensajeError = "Ocurrió un error al guardar las partidas de la cotización"
OcurrioError = True OcurrioError = True
Exit For Exit For
@@ -34591,6 +34604,9 @@ Partial Class Ventas
'CUANDO ES CREAR APARTIR DE SE LIMPIAN FUNCIONALIDADES DE DOCUMENTOS YA REGISTRADOS 'CUANDO ES CREAR APARTIR DE SE LIMPIAN FUNCIONALIDADES DE DOCUMENTOS YA REGISTRADOS
BtnGenerarRemision.Visible = False BtnGenerarRemision.Visible = False
BtnEditarRemision.Visible = False BtnEditarRemision.Visible = False
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = False
End If
BtnPermisoEditarRemision.Visible = False BtnPermisoEditarRemision.Visible = False
BtnPermisoEditarCotizacion.Visible = False BtnPermisoEditarCotizacion.Visible = False
BtnEditarCotizacion.Visible = False BtnEditarCotizacion.Visible = False
@@ -39807,7 +39823,7 @@ Partial Class Ventas
RegistraScript("MuestraAnticipos();", "AE") RegistraScript("MuestraAnticipos();", "AE")
End Sub End Sub
Private Sub RecalculaPrecios() Private Sub RecalculaPrecios(ByRef RecalculoPromociones As Boolean, Optional ForzarRecalculo As Boolean = False)
Dim PuedeRecalcular As Boolean = False Dim PuedeRecalcular As Boolean = False
If CveVenta <= 0 OrElse EsCreaApartirDe OrElse (ModalidadEdicion AndAlso Not DdlTipoComprobante.SelectedValue = "Cot") Then If CveVenta <= 0 OrElse EsCreaApartirDe OrElse (ModalidadEdicion AndAlso Not DdlTipoComprobante.SelectedValue = "Cot") Then
@@ -39819,6 +39835,10 @@ Partial Class Ventas
PuedeRecalcular = False PuedeRecalcular = False
End If End If
If ForzarRecalculo Then
PuedeRecalcular = True
End If
If TmpDT IsNot Nothing AndAlso PuedeRecalcular Then If TmpDT IsNot Nothing AndAlso PuedeRecalcular Then
For Each Row As DataRow In TmpDT.Rows For Each Row As DataRow In TmpDT.Rows
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal() Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
@@ -39846,6 +39866,13 @@ Partial Class Ventas
Row("Total") = (Cantidad * PU) Row("Total") = (Cantidad * PU)
Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales) Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
Row("TotalConImpuestos") = (Row("Total").ToString().ToDecimal() - Row("Descuento").ToString().ToDecimal() + Row("ImporteIVA").ToString().ToDecimal()).RoundSQL(2) Row("TotalConImpuestos") = (Row("Total").ToString().ToDecimal() - Row("Descuento").ToString().ToDecimal() + Row("ImporteIVA").ToString().ToDecimal()).RoundSQL(2)
Row("CvePromocionDetalle") = ObjDescuento.CvePromocionDetalle
If ObjDescuento.CvePromocionDetalle > 0 Then
RecalculoPromociones = True
End If
End If End If
Next Next
@@ -39917,7 +39944,9 @@ Partial Class Ventas
BtnsFacturar.Visible = False BtnsFacturar.Visible = False
BtnEditarRemision.Visible = False BtnEditarRemision.Visible = False
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = False
End If
LimpiaDocumentoDEV() LimpiaDocumentoDEV()
CambiaTipoDocto() CambiaTipoDocto()
@@ -40288,5 +40317,17 @@ Partial Class Ventas
Protected Sub BtnRegresarBusqueda_Click(sender As Object, e As EventArgs) Protected Sub BtnRegresarBusqueda_Click(sender As Object, e As EventArgs)
LimpiarAgregarCliente() LimpiarAgregarCliente()
End Sub End Sub
Protected Sub LnkCalcularPromociones_Click(sender As Object, e As EventArgs)
Dim Recalculo As Boolean = False
RecalculaPrecios(Recalculo, ForzarRecalculo:=True)
If Recalculo Then
Alert("Se han recalculado los precios y promociones en base a las condiciones actuales")
Else
Alert("No se han encontrado cambios para los precios y promociones")
End If
End Sub
End Class End Class