carga layout liquidación E158

This commit is contained in:
2023-01-29 13:39:28 -07:00
parent 563ea013f3
commit e389f5246d

View File

@@ -296,7 +296,7 @@ Partial Class Ventas_ClientesAbonar
RVTxtFechaDocumento.MaximumValue = Now.ToString("dd/MM/yyyy") RVTxtFechaDocumento.MaximumValue = Now.ToString("dd/MM/yyyy")
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then If UsuarioActual.CveEmpresa.Contiene(13, 83, 158) Then
LnkAccionesModalSeleccionLayout.Visible = True LnkAccionesModalSeleccionLayout.Visible = True
End If End If
@@ -864,15 +864,12 @@ Partial Class Ventas_ClientesAbonar
'inserto los movimientos de la conta para abonar al saldo 'inserto los movimientos de la conta para abonar al saldo
If CvePrePoliza > 0 Then If CvePrePoliza > 0 Then
Dim PorcentajePago As Decimal = 100
Dim CvePlantillaPoliza As Integer = 11 Dim CvePlantillaPoliza As Integer = 11
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>" Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
Dim idCuentaContabilizacion As Long = 1 Dim idCuentaContabilizacion As Long = 1
Dim CveCuentaContabilizacion As Long = 1 Dim CveCuentaContabilizacion As Long = 1
Dim dtConceptos As DataTable = Nothing Dim dtConceptos As DataTable = Nothing
Dim tipoCambioVenta As Decimal
Dim tipoCambioPago As Decimal Dim tipoCambioPago As Decimal
Dim tipoCambioVentaValuacion As Decimal = 1
Dim TipoCambioGeneral As Decimal = 1 Dim TipoCambioGeneral As Decimal = 1
Dim CveSubProyectoContabilizar As Integer = -1 Dim CveSubProyectoContabilizar As Integer = -1
Dim CveSubProyectoMaximo As Integer = -1 Dim CveSubProyectoMaximo As Integer = -1
@@ -886,6 +883,7 @@ Partial Class Ventas_ClientesAbonar
Dim ImportePrestamo As Decimal = 0 Dim ImportePrestamo As Decimal = 0
Dim TCPrestamo As Decimal = 0 Dim TCPrestamo As Decimal = 0
If TxtPrestamoImporte.Text.ToDecimal <> 0 Then 'amortización del préstamo If TxtPrestamoImporte.Text.ToDecimal <> 0 Then 'amortización del préstamo
ImportePrestamo = TxtPrestamoImporte.Text.ToDecimal ImportePrestamo = TxtPrestamoImporte.Text.ToDecimal
Dim tCveProv As Integer = DtPrestamos.FiltroPrimeroValor("CveProveedor", "CveIE=" & DdlPrestamo.SelectedValue) Dim tCveProv As Integer = DtPrestamos.FiltroPrimeroValor("CveProveedor", "CveIE=" & DdlPrestamo.SelectedValue)
@@ -912,14 +910,14 @@ Partial Class Ventas_ClientesAbonar
End If End If
End If End If
If TxtPrestamoIntereses.Text.ToDecimal <> 0 AndAlso MsgError = "" Then End If
tipoCambioPago = If(TxtTCDolares.Visible, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal)
Dim ImporteIntereses As Decimal = (TxtPrestamoIntereses.Text.ToDecimal * tipoCambioPago).RoundSQL
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteIntereses, ImporteIntereses, 51, TxtFolio.Text, TxtObservaciones.Text, 0, CveIE:=DdlPrestamo.SelectedValue.ToEntero, CveSubProyecto:=11881, TipoCambio:=tipoCambioPago, CveClasificacion:=21927) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
If TxtPrestamoIntereses.Text.ToDecimal <> 0 AndAlso MsgError = "" Then
tipoCambioPago = If(TxtTCDolares.Visible, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal)
Dim ImporteIntereses As Decimal = (TxtPrestamoIntereses.Text.ToDecimal * tipoCambioPago).RoundSQL
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteIntereses, ImporteIntereses, 51, TxtFolio.Text, TxtObservaciones.Text, 0, CveIE:=DdlPrestamo.SelectedValue.ToEntero, CveSubProyecto:=11881, TipoCambio:=tipoCambioPago, CveClasificacion:=21927) Then
MsgError = "No se pudo insertar la póliza"
End If
End If End If
'inserto las ventas que voy a pagar 'inserto las ventas que voy a pagar
@@ -977,26 +975,6 @@ Partial Class Ventas_ClientesAbonar
If gvr.FCTextBox("TxtComision").Text.ToDecimal <> 0 Then Pago.OtroGastoIngreso = gvr.FCTextBox("TxtComision").Text.ToDecimal If gvr.FCTextBox("TxtComision").Text.ToDecimal <> 0 Then Pago.OtroGastoIngreso = gvr.FCTextBox("TxtComision").Text.ToDecimal
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos
tipoCambioPago = 1
tipoCambioVenta = 1
PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
tipoCambioPago = TxtTC.Text.ToDecimal
tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
tipoCambioVentaValuacion = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
PorcentajePago = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal) / gvr.DataKey("Original").ToDecimal
ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
tipoCambioPago = If(CveMonedaFiltro = -1, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal)
tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
tipoCambioVentaValuacion = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
tipoCambioPago = TxtTCDolares.Text.ToDecimal
tipoCambioVenta = 1
PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
End If
If gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then If gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then
EsAnticipoEspecial = True EsAnticipoEspecial = True
Pago.AplicaTraslado = False Pago.AplicaTraslado = False
@@ -1109,7 +1087,7 @@ Partial Class Ventas_ClientesAbonar
End If End If
'se calcula la fluctuación de la aplicación del anticipo, para sumarla en el concepto de fluctuación más abajo 'se calcula la fluctuación de la aplicación del anticipo, para sumarla en el concepto de fluctuación más abajo
FluctuacionAnticipo = ((TCP - tipoCambioPago) * gvr.FCTextBox("TxtAmort").Text.ToDecimal).RoundSQL FluctuacionAnticipo = ((TCP - tipoCambioPago) * gvr.FCTextBox("TxtAmort").Text.ToDecimal).RoundSQL
MsgError = RegistraAmortizacionAnticipo(ObjMov, CvePrePoliza, gvr.FCDropDownList("DdlAnti").SelectedValue.ToEntero, gvr.FCTextBox("TxtAmort").Text.ToDecimal, TCP, tipoCambioVentaValuacion, gvr.DataKey("CveVenta").ToEntero, gvr.DataKey("SerieFolio").ToString, FolioPago) MsgError = RegistraAmortizacionAnticipo(ObjMov, CvePrePoliza, gvr.FCDropDownList("DdlAnti").SelectedValue.ToEntero, gvr.FCTextBox("TxtAmort").Text.ToDecimal, TCP, gvr.DataKey("CveVenta").ToEntero, gvr.DataKey("SerieFolio").ToString, FolioPago)
End If End If
If MsgError = "" AndAlso gvr.FCDropDownList("DdlAnti2").SelectedValue.ToEntero > 0 Then If MsgError = "" AndAlso gvr.FCDropDownList("DdlAnti2").SelectedValue.ToEntero > 0 Then
@@ -1130,12 +1108,13 @@ Partial Class Ventas_ClientesAbonar
End If End If
'se calcula la fluctuación de la aplicación del anticipo, para sumarla en el concepto de fluctuación más abajo 'se calcula la fluctuación de la aplicación del anticipo, para sumarla en el concepto de fluctuación más abajo
FluctuacionAnticipo += ((TCP - tipoCambioPago) * gvr.FCTextBox("TxtAmort2").Text.ToDecimal).RoundSQL FluctuacionAnticipo += ((TCP - tipoCambioPago) * gvr.FCTextBox("TxtAmort2").Text.ToDecimal).RoundSQL
MsgError = RegistraAmortizacionAnticipo(ObjMov, CvePrePoliza, gvr.FCDropDownList("DdlAnti2").SelectedValue.ToEntero, gvr.FCTextBox("TxtAmort2").Text.ToDecimal, TCP, tipoCambioVentaValuacion, gvr.DataKey("CveVenta").ToEntero, gvr.DataKey("SerieFolio").ToString, FolioPago) MsgError = RegistraAmortizacionAnticipo(ObjMov, CvePrePoliza, gvr.FCDropDownList("DdlAnti2").SelectedValue.ToEntero, gvr.FCTextBox("TxtAmort2").Text.ToDecimal, TCP, gvr.DataKey("CveVenta").ToEntero, gvr.DataKey("SerieFolio").ToString, FolioPago)
End If End If
If ImportePrestamo <> 0 Then If ImportePrestamo <> 0 Then
If TCPrestamo > 0 Then If TCPrestamo > 0 Then
FluctuacionAnticipo += ((TCPrestamo - tipoCambioPago) * ImportePrestamo).RoundSQL FluctuacionAnticipo += ((TCPrestamo - tipoCambioPago) * ImportePrestamo).RoundSQL
ImportePrestamo = 0
End If End If
End If End If
Pago.ImporteFluctuacionAdicional = FluctuacionAnticipo Pago.ImporteFluctuacionAdicional = FluctuacionAnticipo
@@ -1216,8 +1195,6 @@ Partial Class Ventas_ClientesAbonar
End If End If
End If End If
If MsgError = "" AndAlso UsuarioActual.Empresa.Funcionalidad(220) <> "" Then If MsgError = "" AndAlso UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
@@ -1386,13 +1363,12 @@ Partial Class Ventas_ClientesAbonar
StrMsg.AppendFormat("Nota de crédito generada correctamente.<br/><br/> Folio: <a href='/Ventas/Ventas.aspx?CveVenta={0}' target='_blank' class='Texto'>{1}</a><br/>", RespuestaNotaCredito.Respuesta.CveVenta, RespuestaNotaCredito.Respuesta.SerieFolio) StrMsg.AppendFormat("Nota de crédito generada correctamente.<br/><br/> Folio: <a href='/Ventas/Ventas.aspx?CveVenta={0}' target='_blank' class='Texto'>{1}</a><br/>", RespuestaNotaCredito.Respuesta.CveVenta, RespuestaNotaCredito.Respuesta.SerieFolio)
End If End If
Next Next
Alert($"{StrMsg.ToString}<br/><br/>{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx""")) Alert($"{StrMsg.ToString}<br/><br/>{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
Else Else
If ObjConta IsNot Nothing Then ObjConta.RollBack() If ObjConta IsNot Nothing Then ObjConta.RollBack()
ObjIE.RollBack() ObjIE.RollBack()
' Alert(MsgError, TipoMensaje.MsgAdvertencia) Alert(MsgError, TipoMensaje.MsgAdvertencia)
End If End If
ObjIE.Dispose() ObjIE.Dispose()
@@ -1409,7 +1385,7 @@ Partial Class Ventas_ClientesAbonar
End Sub End Sub
Private Function RegistraAmortizacionAnticipo(ByRef ObjMov As ClsContabilidad, CvePrePoliza As Integer, CveIE As Integer, Importe As Decimal, tipoCambioPago As Decimal, tipoCambioVenta As Decimal, CveVenta As Integer, ReferenciaVenta As String, ReferenciaPago As String) As String Private Function RegistraAmortizacionAnticipo(ByRef ObjMov As ClsContabilidad, CvePrePoliza As Integer, CveIE As Integer, Importe As Decimal, tipoCambioPago As Decimal, CveVenta As Integer, ReferenciaVenta As String, ReferenciaPago As String) As String
Dim MsgError As String = "" Dim MsgError As String = ""
If CveMonedaPago = 2 Then If CveMonedaPago = 2 Then
@@ -2756,7 +2732,10 @@ Partial Class Ventas_ClientesAbonar
End Sub End Sub
Protected Sub ChkLiquidacion_CheckedChanged(sender As Object, e As EventArgs) Protected Sub ChkLiquidacion_CheckedChanged(sender As Object, e As EventArgs)
ActivaDesactivaLiquidacion()
End Sub
Private Sub ActivaDesactivaLiquidacion()
If ChkLiquidacion.Checked Then If ChkLiquidacion.Checked Then
TimTiempo.Enabled = True 'para que no me saque TimTiempo.Enabled = True 'para que no me saque
@@ -2811,7 +2790,6 @@ Partial Class Ventas_ClientesAbonar
End If End If
UPVentas.Update() UPVentas.Update()
End Sub End Sub
#End Region #End Region
@@ -2833,31 +2811,36 @@ Partial Class Ventas_ClientesAbonar
Dim CountRegistros As Integer = 0 Dim CountRegistros As Integer = 0
Dim TotalSeleccion As Decimal = 0D Dim TotalSeleccion As Decimal = 0D
Dim SBNoEncotradosEnLista As New StringBuilder Dim SBNoEncontradosEnLista As New StringBuilder
Dim SBPagoMAyorASaldo As New StringBuilder Dim SBPagoMayorASaldo As New StringBuilder
If TxtModalLayoutExcel.getfiles().Archivos.Count > 0 Then If TxtModalLayoutExcel.getfiles().Archivos.Count > 0 Then
Dim file As Archivo = TxtModalLayoutExcel.getfiles().Archivos(0) Dim file As Archivo = TxtModalLayoutExcel.getfiles().Archivos(0)
Dim Directorio As String = Server.MapPath("~") & file.path Dim Directorio As String = Server.MapPath("~") & file.path
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV") Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
Dim DT As New DataTable Dim DTExcel As New DataTable
Dim ErrorArchivo = False Dim ErrorArchivo = False
Dim ErrorExcel = False Dim ErrorExcel = False
DT = ReadExcelFile(Directorio + file.filename, True) DTExcel = ReadExcelFile(Directorio + file.filename, True)
If Not DT.Columns(0).ColumnName.ToUpper = "FOLIO" Then If Not DTExcel.Columns(0).ColumnName.ToUpper = "FOLIO" Then
Alert("El nombre de la primera columna debe ser 'Folio'. Favor de corregirlo", TipoMensaje.MsgAdvertencia) Alert("El nombre de la primera columna debe ser 'Folio'. Favor de corregirlo", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
If Not DT.Columns(1).ColumnName.ToUpper = "IMPORTE PAGO" Then If Not DTExcel.Columns(1).ColumnName.ToUpper = "IMPORTE PAGO" Then
Alert("El nombre de la segunda columna debe ser 'Importe Pago'.Favor de corregirlo." & DT.Columns(1).ColumnName, TipoMensaje.MsgAdvertencia) Alert("El nombre de la segunda columna debe ser 'Importe Pago'.Favor de corregirlo." & DTExcel.Columns(1).ColumnName, TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
For Each Drow As DataRow In DT.Rows If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
ChkLiquidacion.Checked = True
ActivaDesactivaLiquidacion()
End If
For Each Drow As DataRow In DTExcel.Rows
Dim SerieFolioBusqueda As String = Drow("Folio").ToString.Trim.ToUpper Dim SerieFolioBusqueda As String = Drow("Folio").ToString.Trim.ToUpper
Dim ImportePago As Decimal = Drow("Importe Pago").ToString.ToDecimal.RoundSQL(2) Dim ImportePago As Decimal = Drow("Importe Pago").ToString.ToDecimal.RoundSQL(2)
@@ -2878,7 +2861,7 @@ Partial Class Ventas_ClientesAbonar
If Diferencia < 0 Then If Diferencia < 0 Then
If Math.Abs(Diferencia) > 0.01 Then If Math.Abs(Diferencia) > 0.01 Then
SBPagoMAyorASaldo.AppendLine($"Factura: {SerieFolioBusqueda} Importe de pago {ImportePago.ToString("###,###,###.00")} es mayor al saldo {SaldoGV.ToString("###,###,###.00")} <br/>") SBPagoMayorASaldo.AppendLine($"Factura: {SerieFolioBusqueda} Importe de pago {ImportePago.ToString("###,###,###.00")} es mayor al saldo {SaldoGV.ToString("###,###,###.00")} <br/>")
ProcesoOK = False ProcesoOK = False
Exit For Exit For
Else Else
@@ -2889,6 +2872,26 @@ Partial Class Ventas_ClientesAbonar
GvRow.FCCheckBox("Chk").Checked = True GvRow.FCCheckBox("Chk").Checked = True
GvRow.FCTextBox("TxtAbonar").Text = ImportePago.ToString("###,###,###.00") GvRow.FCTextBox("TxtAbonar").Text = ImportePago.ToString("###,###,###.00")
If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
GvRow.FCDropDownList("DdlTG").SelectedTextExist(Drow("Tipo").ToString)
GvRow.FCTextBox("TxtLiqCol1").Text = Drow("Comisión").ToString
GvRow.FCTextBox("TxtLiqCol2").Text = Drow("Gastos").ToString
GvRow.FCTextBox("TxtLiqCol3").Text = Drow("Inspeccion").ToString
GvRow.FCTextBox("TxtLiqCol4").Text = Drow("Seguro").ToString
GvRow.FCTextBox("TxtLiqCol5").Text = Drow("AduanaMex").ToString
GvRow.FCTextBox("TxtLiqCol6").Text = Drow("Diversos").ToString
GvRow.FCTextBox("TxtLiqCol7").Text = Drow("AduanaUSA").ToString
GvRow.FCTextBox("TxtLiqCol8").Text = Drow("MaterialEmpaque").ToString
GvRow.FCTextBox("TxtLiqCol9").Text = Drow("Semilla").ToString
GvRow.FCDropDownList("DdlAnti").SelectedTextLikeIfExist(Drow("FolioAnticipo1").ToString)
GvRow.FCTextBox("TxtAmort").Text = Drow("ImporteAnticipo1").ToString
GvRow.FCDropDownList("DdlAnti2").SelectedTextLikeIfExist(Drow("FolioAnticipo2").ToString)
GvRow.FCTextBox("TxtAmort2").Text = Drow("ImporteAnticipo2").ToString
End If
TotalSeleccion = TotalSeleccion + ImportePago TotalSeleccion = TotalSeleccion + ImportePago
CountRegistros = CountRegistros + 1 CountRegistros = CountRegistros + 1
@@ -2897,7 +2900,7 @@ Partial Class Ventas_ClientesAbonar
Next Next
If Not SerieFolioEncontrado Then If Not SerieFolioEncontrado Then
SBNoEncotradosEnLista.AppendLine($"{SerieFolioBusqueda}<br>") SBNoEncontradosEnLista.AppendLine($"{SerieFolioBusqueda}<br>")
End If End If
End If End If
Next Next
@@ -2908,7 +2911,7 @@ Partial Class Ventas_ClientesAbonar
If ProcesoOK Then If ProcesoOK Then
Alert($"Facturas seleccionadas: {CountRegistros} <br/>{SBNoEncotradosEnLista.ToString}") Alert($"Facturas seleccionadas: {CountRegistros} <br/>{SBNoEncontradosEnLista.ToString}")
RegistraScript("$('#ModalSeleccionLayout').modal('hide');") RegistraScript("$('#ModalSeleccionLayout').modal('hide');")
TxtImporte.Text = TotalSeleccion.ToString("###,###,###.00") TxtImporte.Text = TotalSeleccion.ToString("###,###,###.00")
@@ -2925,13 +2928,26 @@ Partial Class Ventas_ClientesAbonar
End Sub End Sub
Public Sub SelectedTextLikeIfExist(ByRef Rbl As RadioButtonList, Value As String)
Try
For Each item As ListItem In Rbl.Items
If item.Value.Contains(Value) Then
item.Selected = True
End If
Next
Catch ex As Exception
End Try
End Sub
Protected Sub LnkDescargaFormato_Click(sender As Object, e As EventArgs) Protected Sub LnkDescargaFormato_Click(sender As Object, e As EventArgs)
Dim Directorio As String = "" Dim Directorio As String = ""
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\LayoutSeleccion.xlsx" Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\LayoutPagoCliente.xlsx"
If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\LayoutPagoClienteLiquidacion.xlsx"
End If
If Not (Directorio = "") Then If Not (Directorio = "") Then