diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 5a0c04c99..d078f30e8 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -296,7 +296,7 @@ Partial Class Ventas_ClientesAbonar 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 End If @@ -864,15 +864,12 @@ Partial Class Ventas_ClientesAbonar 'inserto los movimientos de la conta para abonar al saldo If CvePrePoliza > 0 Then - Dim PorcentajePago As Decimal = 100 Dim CvePlantillaPoliza As Integer = 11 Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" Dim idCuentaContabilizacion As Long = 1 Dim CveCuentaContabilizacion As Long = 1 Dim dtConceptos As DataTable = Nothing - Dim tipoCambioVenta As Decimal Dim tipoCambioPago As Decimal - Dim tipoCambioVentaValuacion As Decimal = 1 Dim TipoCambioGeneral As Decimal = 1 Dim CveSubProyectoContabilizar As Integer = -1 Dim CveSubProyectoMaximo As Integer = -1 @@ -886,6 +883,7 @@ Partial Class Ventas_ClientesAbonar Dim ImportePrestamo As Decimal = 0 Dim TCPrestamo As Decimal = 0 + If TxtPrestamoImporte.Text.ToDecimal <> 0 Then 'amortización del préstamo ImportePrestamo = TxtPrestamoImporte.Text.ToDecimal Dim tCveProv As Integer = DtPrestamos.FiltroPrimeroValor("CveProveedor", "CveIE=" & DdlPrestamo.SelectedValue) @@ -912,14 +910,14 @@ Partial Class Ventas_ClientesAbonar 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 + 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 '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 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 EsAnticipoEspecial = True Pago.AplicaTraslado = False @@ -1109,7 +1087,7 @@ Partial Class Ventas_ClientesAbonar End If '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 - 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 If MsgError = "" AndAlso gvr.FCDropDownList("DdlAnti2").SelectedValue.ToEntero > 0 Then @@ -1130,12 +1108,13 @@ Partial Class Ventas_ClientesAbonar End If '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 - 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 If ImportePrestamo <> 0 Then If TCPrestamo > 0 Then FluctuacionAnticipo += ((TCPrestamo - tipoCambioPago) * ImportePrestamo).RoundSQL + ImportePrestamo = 0 End If End If Pago.ImporteFluctuacionAdicional = FluctuacionAnticipo @@ -1216,8 +1195,6 @@ Partial Class Ventas_ClientesAbonar End If - - End If If MsgError = "" AndAlso UsuarioActual.Empresa.Funcionalidad(220) <> "" Then @@ -1386,13 +1363,12 @@ Partial Class Ventas_ClientesAbonar StrMsg.AppendFormat("Nota de crédito generada correctamente.

Folio: {1}
", RespuestaNotaCredito.Respuesta.CveVenta, RespuestaNotaCredito.Respuesta.SerieFolio) End If Next - Alert($"{StrMsg.ToString}

{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx""")) Else If ObjConta IsNot Nothing Then ObjConta.RollBack() ObjIE.RollBack() - ' Alert(MsgError, TipoMensaje.MsgAdvertencia) + Alert(MsgError, TipoMensaje.MsgAdvertencia) End If ObjIE.Dispose() @@ -1409,7 +1385,7 @@ Partial Class Ventas_ClientesAbonar 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 = "" If CveMonedaPago = 2 Then @@ -2756,7 +2732,10 @@ Partial Class Ventas_ClientesAbonar End Sub Protected Sub ChkLiquidacion_CheckedChanged(sender As Object, e As EventArgs) + ActivaDesactivaLiquidacion() + End Sub + Private Sub ActivaDesactivaLiquidacion() If ChkLiquidacion.Checked Then TimTiempo.Enabled = True 'para que no me saque @@ -2811,7 +2790,6 @@ Partial Class Ventas_ClientesAbonar End If UPVentas.Update() - End Sub #End Region @@ -2833,31 +2811,36 @@ Partial Class Ventas_ClientesAbonar Dim CountRegistros As Integer = 0 Dim TotalSeleccion As Decimal = 0D - Dim SBNoEncotradosEnLista As New StringBuilder - Dim SBPagoMAyorASaldo As New StringBuilder + Dim SBNoEncontradosEnLista As New StringBuilder + Dim SBPagoMayorASaldo As New StringBuilder If TxtModalLayoutExcel.getfiles().Archivos.Count > 0 Then Dim file As Archivo = TxtModalLayoutExcel.getfiles().Archivos(0) Dim Directorio As String = Server.MapPath("~") & file.path 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 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) Exit Sub End If - If Not DT.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) + If Not DTExcel.Columns(1).ColumnName.ToUpper = "IMPORTE PAGO" Then + Alert("El nombre de la segunda columna debe ser 'Importe Pago'.Favor de corregirlo." & DTExcel.Columns(1).ColumnName, TipoMensaje.MsgAdvertencia) Exit Sub 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 ImportePago As Decimal = Drow("Importe Pago").ToString.ToDecimal.RoundSQL(2) @@ -2878,7 +2861,7 @@ Partial Class Ventas_ClientesAbonar If Diferencia < 0 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")}
") + SBPagoMayorASaldo.AppendLine($"Factura: {SerieFolioBusqueda} Importe de pago {ImportePago.ToString("###,###,###.00")} es mayor al saldo {SaldoGV.ToString("###,###,###.00")}
") ProcesoOK = False Exit For Else @@ -2889,6 +2872,26 @@ Partial Class Ventas_ClientesAbonar GvRow.FCCheckBox("Chk").Checked = True 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 CountRegistros = CountRegistros + 1 @@ -2897,7 +2900,7 @@ Partial Class Ventas_ClientesAbonar Next If Not SerieFolioEncontrado Then - SBNoEncotradosEnLista.AppendLine($"{SerieFolioBusqueda}
") + SBNoEncontradosEnLista.AppendLine($"{SerieFolioBusqueda}
") End If End If Next @@ -2908,7 +2911,7 @@ Partial Class Ventas_ClientesAbonar If ProcesoOK Then - Alert($"Facturas seleccionadas: {CountRegistros}
{SBNoEncotradosEnLista.ToString}") + Alert($"Facturas seleccionadas: {CountRegistros}
{SBNoEncontradosEnLista.ToString}") RegistraScript("$('#ModalSeleccionLayout').modal('hide');") TxtImporte.Text = TotalSeleccion.ToString("###,###,###.00") @@ -2925,13 +2928,26 @@ Partial Class Ventas_ClientesAbonar 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) 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