Cambios de lineas adicionales, saldo por remisiones

This commit is contained in:
2023-01-25 14:54:46 -07:00
parent 739834781e
commit 17ab276f62
3 changed files with 262 additions and 217 deletions

View File

@@ -2280,6 +2280,14 @@ Partial Class Ventas
ViewState("SaldoLineaAdicional") = value
End Set
End Property
Private Property SaldoIngresosLineaAdicional As Decimal
Get
Return (IfNull(ViewState("SaldoIngresosLineaAdicional"), "0", ViewState("SaldoIngresosLineaAdicional"))).ToString().ToDecimal()
End Get
Set(value As Decimal)
ViewState("SaldoIngresosLineaAdicional") = value
End Set
End Property
Private Property CveCategoriaLineaAdicional As Integer
Get
@@ -2298,6 +2306,14 @@ Partial Class Ventas
ViewState("CveMonedaLineaAdicional") = value
End Set
End Property
Private Property HabilitoFacturacionIngresoLineaAdicional As Boolean
Get
Return If(IsNothing(ViewState("HabilitoFacturacionIngresoLineaAdicional")), False, CType(ViewState("HabilitoFacturacionIngresoLineaAdicional"), Boolean))
End Get
Set(value As Boolean)
ViewState("HabilitoFacturacionIngresoLineaAdicional") = value
End Set
End Property
#End Region
@@ -8839,6 +8855,11 @@ Partial Class Ventas
Exit Sub
End If
If DdlLineaAdicional.SelectedValue.ToEntero() > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then
Alert("No se puede seleccionar una linea adicional de crédito si no se genera una remisón.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'SI TIENE ANTICIPOS Y ESTA AMORTIZADO AL 100% EL DOCUMENTO (SALDO = 0) | NO VALIDA PU DEL CONCEPTO
If Not (LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0) Then
If Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "Ant", "DPe") Then
@@ -9057,18 +9078,6 @@ Partial Class Ventas
Alert("El saldo de la linea adicional debe ser mayor a cero", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'VERIFICA QUE LA MONEDA DE LA LINEA ADICIONAL SEA LA MISMA QUE LA VENTA
If Me.CveMonedaLineaAdicional <> DdlMoneda.SelectedValue.ToEntero() Then
Alert("La moneda de la linea adicional de crédito debe ser la misma que la factura.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'VERIFICA QUE EL SALDO DISPONIBLE SEA MENOR AL IMPORTE
If Me.SaldoLineaAdicional <= TxtTotal.Text.ToDecimal() Then
Alert("El saldo de la linea adicional debe ser mayor o igual al de la factura", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
@@ -9406,6 +9415,30 @@ Partial Class Ventas
Exit Sub
End If
If UsuarioActual.Empresa.Funcionalidad(705) = "1" AndAlso DdlLineaAdicional.SelectedValue.ToEntero() > 0 Then
'VERIFICA QUE LA MONEDA DE LA LINEA ADICIONAL SEA LA MISMA QUE LA VENTA
If Me.CveMonedaLineaAdicional <> ObjFactura.CveMoneda Then
Alert("La moneda de la linea adicional de crédito debe ser la misma que la factura.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'VERIFICA QUE EL SALDO DISPONIBLE SEA MENOR AL IMPORTE
If ObjFactura.TipoDocto = "Rem" AndAlso Me.SaldoLineaAdicional <= ObjFactura.Total Then
Alert("El saldo de la linea adicional debe ser mayor o igual al de la remisión", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If ObjFactura.TipoDocto = "Ing" AndAlso (DtRemisionesPS Is Nothing OrElse DtRemisionesPS.Rows.Count = 0) Then
Alert("No se puede generar un ingreso con una linea adicional de credito si este no viene de una remisión", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If ObjFactura.TipoDocto = "Ing" AndAlso Me.SaldoIngresosLineaAdicional <= ObjFactura.Total Then
Alert("El saldo de la linea adicional debe ser mayor o igual al de la factura", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
'If Not CveEmpresaCRM > 0 Then
' If ObjFactura.Cliente.AplicaComercioExterior Then
' If Not ValidaComercioExterior() Then
@@ -18659,28 +18692,40 @@ Partial Class Ventas
End Sub
Private Sub CalculaLineasAdicionales()
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(705) = "1" Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "PA") AndAlso UsuarioActual.Empresa.Funcionalidad(705) = "1" Then
DdlLineaAdicional.DataSource = Nothing
Using ObjVentas As New ClsVentas
'SI ES VENTA EXISTENTE , SI SE VA EDITAR SOLO MOSTRAR LAS CON SALDO, FECHA DE VENCIMIENTO VIGENTE O LA LINEA ACTUAL
If CveVenta > 0 Then
If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, DdlMoneda.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, ConSaldo:=-1, FechaVencimientoConsulta:=MinFecha) Then
If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, -1, UsuarioActual.CveEmpresa, ConSaldo:=-1, FechaVencimientoConsulta:=MinFecha) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
TrLineaAdicional.Visible = True
DdlLineaAdicional.DataSource = ObjVentas.DtResultados.FiltraParametros($"(Saldo > 0 AND FechaVencimiento <= '{Now.ToString("dd/MM/yyyy")}') OR CveLineaAdicional = {Me.CveLineaAdicionalVenta}")
End If
End If
Else
If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, DdlMoneda.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, ConSaldo:=1, FechaVencimientoConsulta:=Now) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
TrLineaAdicional.Visible = True
DdlLineaAdicional.DataSource = ObjVentas.DtResultados
'SI SE ESTA FACTURANDO UNA REMISION DEBE SELECCIONAR LA LINEA ADICIONAL DE ESTA
If Me.CveLineaAdicionalVenta > 0 Then
If ObjVentas.GetLineasAdicionalesSaldo(Me.CveLineaAdicionalVenta, CveCliente, -1, -1, UsuarioActual.CveEmpresa, ConSaldo:=-1, FechaVencimientoConsulta:=MinFecha) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
TrLineaAdicional.Visible = True
DdlLineaAdicional.DataSource = ObjVentas.DtResultados
End If
End If
Else
If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, -1, UsuarioActual.CveEmpresa, ConSaldo:=1, FechaVencimientoConsulta:=Now) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
TrLineaAdicional.Visible = True
DdlLineaAdicional.DataSource = ObjVentas.DtResultados
End If
End If
End If
End If
End Using
DdlLineaAdicional.DataBind()
DdlLineaAdicional.Items.Insert(0, New ListItem("Seleccione", "-1"))
If Me.CveLineaAdicionalVenta > 0 Then
@@ -31616,6 +31661,13 @@ Partial Class Ventas
DdlMoneda.SelectedValue = GlobalDTMonedas.FiltroPrimeroValor("CveMoneda", $"Abreviatura = '{dtSeleccionadas.FiltroPrimeroValor("Abreviatura")}'")
DdlMoneda.Enabled = False
CambiaMoneda()
If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then
Me.CveLineaAdicionalVenta = dtSeleccionadas.FiltroPrimeroValor("CveLineaAdicional", "CveLineaAdicional > 0").ToEntero()
CalculaLineasAdicionales()
End If
DdlUsoCFDI.SelectedValueExist(dtSeleccionadas.FiltroPrimeroValor("CveUsoCFDI"))
DdlMetodoPago33.SelectedValueExist(dtSeleccionadas.FiltroPrimeroValor("CveMetodoPago"))
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
@@ -36097,42 +36149,76 @@ Partial Class Ventas
RBLPago.Enabled = False
Using ObjVentas As New ClsVentas
If ObjVentas.GetLineasAdicionalesSaldo(DdlLineaAdicional.SelectedValue.ToEntero(), CveCliente, -1, DdlMoneda.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, FechaVencimientoConsulta:=MinFecha) Then
If ObjVentas.GetLineasAdicionalesSaldo(DdlLineaAdicional.SelectedValue.ToEntero(), CveCliente, -1, -1, UsuarioActual.CveEmpresa, FechaVencimientoConsulta:=MinFecha) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
Dim RowLinea As DataRow = ObjVentas.DtResultados.Rows(0)
If RowLinea IsNot Nothing Then
TxtFechaPago.Text = RowLinea("FechaVencimiento").ToString().ToDateTime().ToString("dd/MM/yyyy")
If CveVenta <= 0 Then
TxtFechaPago.Text = RowLinea("FechaVencimiento").ToString().ToDateTime().ToString("dd/MM/yyyy")
'AL FACTURAR CON LINEA ADICIONAL TIPO PO, SE SUMARÁN LOS DIAS DE VENCIMIENTO A LA FECHA ACTUAL
If RowLinea("TipoLinea").ToString() = "2" Then
TxtFechaPago.Text = Now.AddDays(RowLinea("DiasVencimiento").ToString().ToEntero()).ToString("dd/MM/yyyy")
TxtFechaPago.Enabled = False
imgCalendario.Visible = False
'AL FACTURAR CON LINEA ADICIONAL TIPO PO, SE SUMARÁN LOS DIAS DE VENCIMIENTO A LA FECHA ACTUAL
If RowLinea("TipoLinea").ToString() = "2" Then
TxtFechaPago.Text = Now.AddDays(RowLinea("DiasVencimiento").ToString().ToEntero()).ToString("dd/MM/yyyy")
TxtFechaPago.Enabled = False
imgCalendario.Visible = False
End If
TxtOrdenCompra.Text = RowLinea("LineaAdicionalComercializador").ToString()
End If
Me.CveCategoriaLineaAdicional = RowLinea("CveCategoria").ToString().ToEntero()
Me.CveMonedaLineaAdicional = RowLinea("CveMoneda").ToString().ToEntero()
Me.SaldoLineaAdicional = RowLinea("Saldo").ToString().ToDecimal()
Me.SaldoIngresosLineaAdicional = RowLinea("SaldoIngresos").ToString().ToDecimal()
If CveVenta <= 0 Then
If DdlTipoComprobante.SelectedValue.Contiene("PA") Then
'SI NO TIENE LA OPCION DE FACTURAR LA PERMITE
If DdlTipoComprobante.Items.FindByValue("Rem") Is Nothing Then
DdlTipoComprobante.Items.Insert(0, New ListItem("Remisión", "Rem"))
HabilitoFacturacionIngresoLineaAdicional = True
End If
DdlTipoComprobante.SelectedValueExist("Rem")
End If
End If
End If
Else
Alert("No se pudieron obtener datos de la linea adicional", TipoMensaje.MsgAdvertencia)
Me.SaldoLineaAdicional = 0
Me.SaldoIngresosLineaAdicional = 0
Me.CveCategoriaLineaAdicional = 0
End If
Else
Alert("No se pudieron obtener datos de la linea adicional", TipoMensaje.MsgAdvertencia)
Me.SaldoLineaAdicional = 0
Me.SaldoIngresosLineaAdicional = 0
Me.CveCategoriaLineaAdicional = 0
End If
End Using
Else
Me.SaldoLineaAdicional = 0
Me.SaldoIngresosLineaAdicional = 0
Me.CveCategoriaLineaAdicional = 0
TxtFechaPago.Text = Now.ToString("dd/MM/yyyy")
If CveVenta <= 0 Then
TxtFechaPago.Text = Now.ToString("dd/MM/yyyy")
TxtOrdenCompra.Text = ""
'SI SE HABILITO LA FACTURACION DESDE LA LINEA ADICIONAL DEBE QUITARLO
If HabilitoFacturacionIngresoLineaAdicional Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
DdlTipoComprobante.SelectedValueExist("PA")
UpParametros.Update()
End If
End If
End If
UpParametros.Update()
UPCondicionesPago.Update()
UPObservaciones.Update()
End Sub
Protected Sub LnkUpdateLineaAdicional_Click(sender As Object, e As EventArgs)
'VALIDAR LINEAS ADICIONALES