--BDH. FIX Autorizaciones de NC en bdh

--GDIAZ. Validacion ps para Ant
--GDIAZ. Quitar amortización de anticipo por descuento
This commit is contained in:
2024-07-18 19:16:43 -07:00
parent 2cd6d71ee7
commit 862040a16f
2 changed files with 94 additions and 36 deletions

View File

@@ -969,7 +969,7 @@
</td> </td>
</tr> </tr>
<tr align="left" id="TrMotivoDev" runat="server" visible="false"> <tr align="left" id="TrMotivoDev" runat="server" visible="false">
<td><b class="truncate">Motivo devolución:</b>&nbsp;</td> <td><b class="truncate">Motivo de devolución:</b>&nbsp;</td>
<td> <td>
<asp:Label ID="lblMotivoDev" runat="server"></asp:Label></td> <asp:Label ID="lblMotivoDev" runat="server"></asp:Label></td>
</tr> </tr>

View File

@@ -8884,11 +8884,20 @@ Partial Class Ventas
Dim DatarowPS As DataRow = Nothing Dim DatarowPS As DataRow = Nothing
DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("") ' Estado = -1 DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("") ' Estado = -1
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
If DdlTipoComprobante.SelectedValue = "Cot" Then
If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then If DdlTipoComprobante.SelectedValue = "Ant" Then
If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then Dim PSCodigoSAT As String = DatarowPS("SATClavePS").ToString
Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia) If PSCodigoSAT <> "84111506" Then
Exit Sub Alert($"El producto y/o servicio no es valido para generar anticipos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If End If
End If End If
@@ -9755,13 +9764,13 @@ Partial Class Ventas
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero() Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas Dim ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, If(DdlTipoComprobante.SelectedValue = "Egs", "Egs", "Ing"), CveEstatus:=1) Then If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Ing", CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
If TieneDiasVencidos Then If TieneDiasVencidos Then
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='{If(DdlTipoComprobante.SelectedValue = "Egs", "Egs", "Ing")}'", Orderby:="Importe DESC") RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='{"Ing"}'", Orderby:="Importe DESC")
Else Else
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='{If(DdlTipoComprobante.SelectedValue = "Egs", "Egs", "Ing")}'", Orderby:="Importe DESC") RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='{"Ing"}'", Orderby:="Importe DESC")
End If End If
If RowAutorizacion IsNot Nothing Then If RowAutorizacion IsNot Nothing Then
@@ -9809,14 +9818,6 @@ Partial Class Ventas
End If End If
'If TipoAutorizacion = 2 Then
' If DiasVencidosCliente > DiasVencidosAutorizacion Then
' CveAutorizacion = -1
' Alert($"El crédito no esta autorizado. Los días vencidos del cliente son mayores a lo autorizado", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
'End If
'SI NO SE ENCONTRO NINGUA AUTORIZACION 'SI NO SE ENCONTRO NINGUA AUTORIZACION
If TipoAutorizacion = 0 Then If TipoAutorizacion = 0 Then
If TieneDiasVencidos Then If TieneDiasVencidos Then
@@ -9827,21 +9828,57 @@ Partial Class Ventas
End If End If
End If End If
'If TieneDiasVencidos AndAlso DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then End If
' CveAutorizacion = -1
' Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
' Exit Sub
'End If
'If TipoDocumentoAutorizacion = "Egs" Then 'VALIDACION DE AUTORIZACION PARA NC, POR AHORA SOLO BDH
' If TipoAutorizacion = 1 Then If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Egs") Then
' If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then PermiteAutorizacion = False
' CveAutorizacion = -1 'SI NO ES GENERADA CON REMISIONES DE NC, UTILIZAR LA AUTORIZACION
' Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia) If (ListaRemisionesNC Is Nothing OrElse ListaRemisionesNC.Count = 0) Then
' Exit Sub PermiteAutorizacion = True
' End If End If
' End If
'End If If PermiteAutorizacion Then
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Egs", CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Egs'", Orderby:="Importe DESC")
If RowAutorizacion IsNot Nothing Then
ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
End If
End If
ObjVentas.Dispose()
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
Dim BloquearCredito As Boolean = True
CveAutorizacion = -1
If BloquearCredito Then
Alert($"El importe autorizado es insuficiente. Importe autorizado:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
Else
CveAutorizacion = -1
Alert($"No se encontro una autorización de crédito.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If End If
'VALIDAR LINEAS ADICIONALES 'VALIDAR LINEAS ADICIONALES
@@ -16710,6 +16747,13 @@ Partial Class Ventas
HdnTieneAnticipos.Value = "0" HdnTieneAnticipos.Value = "0"
If CveCliente > 0 Then If CveCliente > 0 Then
'QUE NO SE PUEDA REALIZAR AMORTIZACIÓN DE ANTICIPO POR DESCUENTO
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") IsNot Nothing Then
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
End If
End If
HdnIVACalculado.Value = "0" HdnIVACalculado.Value = "0"
'SI ES REFACTURACION NO LIMPIAR EL FOLIO FISCAL 'SI ES REFACTURACION NO LIMPIAR EL FOLIO FISCAL
If NuevaFactura <> 1 Then If NuevaFactura <> 1 Then
@@ -18810,13 +18854,24 @@ Partial Class Ventas
Return False Return False
End If End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
Dim DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") Dim DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DatarowPS IsNot Nothing Then If DatarowPS IsNot Nothing Then
If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then If DdlTipoComprobante.SelectedValue = "Cot" Then
Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia) If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
Return False Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
Return False
End If
End If End If
If DdlTipoComprobante.SelectedValue = "Ant" Then
Dim PSCodigoSAT As String = DatarowPS("SATClavePS").ToString
If PSCodigoSAT <> "84111506" Then
Alert($"El producto y/o servicio '{DatarowPS("CodigoPS").ToString}' no es valido para generar anticipos", TipoMensaje.MsgAdvertencia)
Return False
End If
End If
End If End If
End If End If
@@ -38448,9 +38503,12 @@ Partial Class Ventas
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("2")) DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("2"))
End If End If
Else Else
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") Is Nothing Then If Not (UsuarioActual.Empresa.Funcionalidad(382) = "1") Then
DdlTipoAmortizacionAnticipo.Items.Add(New ListItem("Amortización anticipo en descuento", "1")) If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") Is Nothing Then
DdlTipoAmortizacionAnticipo.Items.Add(New ListItem("Amortización anticipo en descuento", "1"))
End If
End If End If
If DdlTipoAmortizacionAnticipo.Items.FindByValue("2") Is Nothing Then If DdlTipoAmortizacionAnticipo.Items.FindByValue("2") Is Nothing Then
DdlTipoAmortizacionAnticipo.Items.Add(New ListItem("Amortización anticipo con nota de crédito", "2")) DdlTipoAmortizacionAnticipo.Items.Add(New ListItem("Amortización anticipo con nota de crédito", "2"))
End If End If