From 46b567c4455a9bb3eb183a244753810b46ed7714 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 22 Oct 2024 13:08:43 -0700 Subject: [PATCH] --GDiaz. pago con devolucion en cobranza --- App_Code/Modelos.vb | 348 ++++++++++++++++++++++---------------- Ventas/PVCobranza.aspx.vb | 52 +++++- 2 files changed, 252 insertions(+), 148 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 701782670..6f00aa0c8 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -843,51 +843,51 @@ Namespace Modelos End If 'SI ES REFACTURACION - Dim ObjNC As List(Of Object) = Nothing - If ErrorList.Count = 0 Then - If NuevaFactura = 1 AndAlso FacturaDevolucion IsNot Nothing Then + 'Dim ObjNC As List(Of Object) = Nothing + 'If ErrorList.Count = 0 Then + ' If NuevaFactura = 1 AndAlso FacturaDevolucion IsNot Nothing Then - ObjNC = GeneraNC(ObjVentas, ObjConta, ObjInventario, ObjContr, FacturaDevolucion, ObjBancos, ObjEventos) + ' ObjNC = GeneraNC(ObjVentas, ObjConta, ObjInventario, ObjContr, FacturaDevolucion, ObjBancos, ObjEventos) - If ObjNC Is Nothing Then - ErrorList.Add("No se pudo Cancelar la Factura") - End If + ' If ObjNC Is Nothing Then + ' ErrorList.Add("No se pudo Cancelar la Factura") + ' End If - 'Esquema viejo, evitamos que aparezca por surtir - If ErrorList.Count = 0 Then - If Not ObjInventario.ActualizarEsDevolucionVenta(CveVenta, 2) Then - ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") - End If - End If + ' 'Esquema viejo, evitamos que aparezca por surtir + ' If ErrorList.Count = 0 Then + ' If Not ObjInventario.ActualizarEsDevolucionVenta(CveVenta, 2) Then + ' ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") + ' End If + ' End If - End If - End If + ' End If + 'End If 'SI ES amortizacion 3.3 - Dim Obj2 As New List(Of Object) + 'Dim Obj2 As New List(Of Object) - If ErrorList.Count = 0 Then - ' cambiar la condicion para saber si hay seleccionado - If TieneAnticipo AndAlso Me.CveTipoAmortizacionAnticipo = 2 Then + 'If ErrorList.Count = 0 Then + ' ' cambiar la condicion para saber si hay seleccionado + ' If TieneAnticipo AndAlso Me.CveTipoAmortizacionAnticipo = 2 Then - If TieneAnticipo Then - Try - 'DESCOMENTAR - If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, FacturaDevolucion, ObjBancos, Nothing, Nothing) Then - Obj2.Add(FacturaDevolucion) - End If - Catch ex As Exception - ErrorList.Add("No se pudo generarse la nota de crédito de amortización") - End Try + ' If TieneAnticipo Then + ' Try + ' 'DESCOMENTAR + ' If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, FacturaDevolucion, ObjBancos, Nothing, Nothing) Then + ' Obj2.Add(FacturaDevolucion) + ' End If + ' Catch ex As Exception + ' ErrorList.Add("No se pudo generarse la nota de crédito de amortización") + ' End Try - End If + ' End If - If Obj2 Is Nothing AndAlso Obj2.Count = 0 Then - ErrorList.Add("No se pudo generarse la nota de crédito de amortización") - End If - End If - End If + ' If Obj2 Is Nothing AndAlso Obj2.Count = 0 Then + ' ErrorList.Add("No se pudo generarse la nota de crédito de amortización") + ' End If + ' End If + 'End If 'MARCA PARA NO SURTIR VENTA DE COTNRATO DE CONSIGNACION DE VENTA | [IPP] : PARCHE If ErrorList.Count = 0 Then @@ -1059,15 +1059,15 @@ Namespace Modelos SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, Me, CvePACEspecial:=CvePAC) 'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION - If Not IsNothing(Obj2) AndAlso Obj2.Count > 0 Then - Dim ofa As Modelos.Factura = CType(Obj2(0), Modelos.Factura) - 'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC - If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then - ofa.Timbre.CFDIRelacionados.UUID.Clear() - ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID) - End If - ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) - End If + 'If Not IsNothing(Obj2) AndAlso Obj2.Count > 0 Then + ' Dim ofa As Modelos.Factura = CType(Obj2(0), Modelos.Factura) + ' 'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC + ' If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then + ' ofa.Timbre.CFDIRelacionados.UUID.Clear() + ' ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID) + ' End If + ' ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) + 'End If If SeTimbro AndAlso Me.TipoDocto.Contiene("Ing") Then EstatusSMS = EnviarSMSTimbrado(ObjEventos) @@ -1080,12 +1080,12 @@ Namespace Modelos End If 'NOTA DE CREDITO DE REFACTURACION - If RefacturacionGeneroNC Then - If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 Then - Dim ofa As Modelos.Factura = CType(ObjNC(0), Modelos.Factura) - SeTimbroNC = ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) - End If - End If + 'If RefacturacionGeneroNC Then + ' If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 Then + ' Dim ofa As Modelos.Factura = CType(ObjNC(0), Modelos.Factura) + ' SeTimbroNC = ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) + ' End If + 'End If End If End If End If @@ -1162,9 +1162,9 @@ Namespace Modelos End If 'ERROR DE NO TIMBRADO NC - If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then - MensajeAlert.AppendFormat("
La NC #{0} no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio) - End If + 'If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then + ' MensajeAlert.AppendFormat("
La NC #{0} no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio) + 'End If 'NOTIFICACION DE SMS Select Case EstatusSMS @@ -1198,9 +1198,9 @@ Namespace Modelos MensajeAlert.AppendFormat("

Movimiento de Almacén
", Me.Inv_CveMovimiento) End If - If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then - MensajeAlert.AppendFormat("

Se generó una Nota de crédito Folio: {0} amortizando el anticipo
", FacturaDevolucion.Folio) - End If + 'If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then + ' MensajeAlert.AppendFormat("

Se generó una Nota de crédito Folio: {0} amortizando el anticipo
", FacturaDevolucion.Folio) + 'End If If SeTimbro AndAlso CveFacturacionAcarreo > 0 Then MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))) @@ -1905,110 +1905,110 @@ Namespace Modelos End Function #Region " GUARDAR - VENTA, PREPOLIZAS, INV, NC , ESTIMACIONES, AC, NOTA DE CRÉDITO " - Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean - Dim ProcesoCorrecto As Boolean = True + 'Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean + ' Dim ProcesoCorrecto As Boolean = True - 'Generamos el nuevo folio - Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL()) + ' 'Generamos el nuevo folio + ' Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL()) - If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then - Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", Me.CveSubProyecto)) - If DT.Rows.Count > 0 Then - factura.Folio = DT.Rows(0)("FActual").ToString.ToEntero - Else - ProcesoCorrecto = False - End If - DT.Dispose() - End If + ' If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then + ' Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", Me.CveSubProyecto)) + ' If DT.Rows.Count > 0 Then + ' factura.Folio = DT.Rows(0)("FActual").ToString.ToEntero + ' Else + ' ProcesoCorrecto = False + ' End If + ' DT.Dispose() + ' End If - '** genero los datos de la NC - Dim tmpcon As DataTable = DtDetalle.Clone - tmpcon.Clear() + ' '** genero los datos de la NC + ' Dim tmpcon As DataTable = DtDetalle.Clone + ' tmpcon.Clear() - Dim drpss As DataRow = ClsPaginas.GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506").FiltroPrimero("SATClavePS = '84111506'") + ' Dim drpss As DataRow = ClsPaginas.GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506").FiltroPrimero("SATClavePS = '84111506'") - If drpss IsNot Nothing Then - Dim ii As Integer = 1 - Dim CveVentaP As Integer = 0 - For Each gvrt As DataRow In DtAnticipos.Rows - Dim CveSub As Integer = DtDetalle.FiltroPrimeroValor("CveSubProyecto").ToEntero - Dim dr As DataRow = tmpcon.NewRow - Dim Cantidad As Decimal = 1 - Dim PU As Decimal = gvrt("Importe").ToString().ToDecimal() - Dim TotalCalculableImpuestos As Decimal = (Cantidad * (PU)) - dr("CvePS") = drpss("CvePS") - dr("PS") = drpss("PS") - dr("OBS") = drpss("PS") - dr("PU") = PU - dr("Cantidad") = Cantidad - dr("CveUM") = drpss("CveUnidadMedida") - dr("SATClaveProdServ") = "84111506" - dr("SATClaveUM") = "ACT" - dr("Consec") = ii + ' If drpss IsNot Nothing Then + ' Dim ii As Integer = 1 + ' Dim CveVentaP As Integer = 0 + ' For Each gvrt As DataRow In DtAnticipos.Rows + ' Dim CveSub As Integer = DtDetalle.FiltroPrimeroValor("CveSubProyecto").ToEntero + ' Dim dr As DataRow = tmpcon.NewRow + ' Dim Cantidad As Decimal = 1 + ' Dim PU As Decimal = gvrt("Importe").ToString().ToDecimal() + ' Dim TotalCalculableImpuestos As Decimal = (Cantidad * (PU)) + ' dr("CvePS") = drpss("CvePS") + ' dr("PS") = drpss("PS") + ' dr("OBS") = drpss("PS") + ' dr("PU") = PU + ' dr("Cantidad") = Cantidad + ' dr("CveUM") = drpss("CveUnidadMedida") + ' dr("SATClaveProdServ") = "84111506" + ' dr("SATClaveUM") = "ACT" + ' dr("Consec") = ii - If drpss("IVA").ToString = "-1" Then - dr("PorcentajeIVA") = SubProyectoPorcentajeIVA - Else - dr("PorcentajeIVA") = drpss("IVA") - End If + ' If drpss("IVA").ToString = "-1" Then + ' dr("PorcentajeIVA") = SubProyectoPorcentajeIVA + ' Else + ' dr("PorcentajeIVA") = drpss("IVA") + ' End If - dr("IVA") = dr("PorcentajeIVA") - dr("ImporteIVA") = Math.Round(dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2) + ' dr("IVA") = dr("PorcentajeIVA") + ' dr("ImporteIVA") = Math.Round(dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2) - dr("ImporteRetIVA") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) - dr("ImporteRetISR") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) - dr("PorcentajeRetIVA") = Me.Cliente.RetIVA - dr("PorcentajeRetISR") = Me.Cliente.RetISR - dr("PorcentajeIEPS") = 0 ' DrPS("IEPSPorcentaje") - dr("ImporteIEPS") = 0 'Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - dr("IEPS") = dr("ImporteIEPS") - dr("Descuento") = Math.Round(0, 2) - dr("TipoDescuento") = TipoDescuento - dr("Total") = (Cantidad * PU) - dr("CveClasificacion") = drpss("CveClasificacion") - dr("CveSubProyecto") = CveSub - dr("TotalImporte") = Math.Round(Cantidad * PU, 2) - CveVentaP = gvrt("CveVenta").ToString().ToEntero() - tmpcon.Rows.Add(dr) - ii += 1 + ' dr("ImporteRetIVA") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) + ' dr("ImporteRetISR") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) + ' dr("PorcentajeRetIVA") = Me.Cliente.RetIVA + ' dr("PorcentajeRetISR") = Me.Cliente.RetISR + ' dr("PorcentajeIEPS") = 0 ' DrPS("IEPSPorcentaje") + ' dr("ImporteIEPS") = 0 'Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + ' dr("IEPS") = dr("ImporteIEPS") + ' dr("Descuento") = Math.Round(0, 2) + ' dr("TipoDescuento") = TipoDescuento + ' dr("Total") = (Cantidad * PU) + ' dr("CveClasificacion") = drpss("CveClasificacion") + ' dr("CveSubProyecto") = CveSub + ' dr("TotalImporte") = Math.Round(Cantidad * PU, 2) + ' CveVentaP = gvrt("CveVenta").ToString().ToEntero() + ' tmpcon.Rows.Add(dr) + ' ii += 1 - Next + ' Next - '**** impuestos locales + ' '**** impuestos locales - factura.DtDetalle = tmpcon - Dim TotalSubTotal As Decimal = tmpcon.SUM("TotalImporte") - Dim TotalDescuentos As Decimal = tmpcon.SUM("Descuento") + ' factura.DtDetalle = tmpcon + ' Dim TotalSubTotal As Decimal = tmpcon.SUM("TotalImporte") + ' Dim TotalDescuentos As FunctionDecimal = tmpcon.SUM("Descuento") - Dim TotalIVA As Decimal = tmpcon.SUM("ImporteIVA") - Dim TotalIEPS As Decimal = tmpcon.SUM("ImporteIEPS") - Dim TotalRetIVA As Decimal = tmpcon.SUM("ImporteRetIVA") - Dim TotalRetISR As Decimal = tmpcon.SUM("ImporteRetISR") - Dim Total As Decimal = 0 - Dim TotalImpuestosLocales As Decimal = 0 - Total = (TotalSubTotal - TotalDescuentos + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales) + ' Dim TotalIVA As Decimal = tmpcon.SUM("ImporteIVA") + ' Dim TotalIEPS As Decimal = tmpcon.SUM("ImporteIEPS") + ' Dim TotalRetIVA As Decimal = tmpcon.SUM("ImporteRetIVA") + ' Dim TotalRetISR As Decimal = tmpcon.SUM("ImporteRetISR") + ' Dim Total As Decimal = 0 + ' Dim TotalImpuestosLocales As Decimal = 0 + ' Total = (TotalSubTotal - TotalDescuentos + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales) - factura.SubTotal = TotalSubTotal - factura.Descuento = 0 - factura.IVA = TotalIVA - factura.IEPS = TotalIEPS - factura.RetIVA = TotalRetIVA - factura.RetISR = TotalRetISR - factura.Total = Total - factura.CveVentaPadre = CveVentaP + ' factura.SubTotal = TotalSubTotal + ' factura.Descuento = 0 + ' factura.IVA = TotalIVA + ' factura.IEPS = TotalIEPS + ' factura.RetIVA = TotalRetIVA + ' factura.RetISR = TotalRetISR + ' factura.Total = Total + ' factura.CveVentaPadre = CveVentaP - 'Registramos la venta - GuardarVenta(factura, ObjVentas, ObjConta, ObjInventario, ObjContr, tmpcon, -1, ObjBancos) + ' 'Registramos la venta + ' GuardarVenta(factura, ObjVentas, ObjConta, ObjInventario, ObjContr, tmpcon, -1, ObjBancos) - ''Timbramos - Else - ErrorList.Add("No se encontró un producto para generar la nota de crédito") - End If + ' ''Timbramos + ' Else + ' ErrorList.Add("No se encontró un producto para generar la nota de crédito") + ' End If - Return ProcesoCorrecto - End Function + ' Return ProcesoCorrecto + 'End Private Sub EnviarNotificacionAvance(NumeroContrato As String, DescripcionContrato As String, ContratoTipo As String, Cliente As String, CorreoVendedor As String, Optional MontoMaximo As Double = 0) Dim ObjMail As New ClsSisMail() @@ -3892,8 +3892,8 @@ Namespace Modelos End If End If Else - If ObjFactura.DtAnticipos IsNot Nothing Then - For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows + If ObjFactura.DtAnticiposAplicados IsNot Nothing Then + For Each row2 As DataRow In ObjFactura.DtAnticiposAplicados.Rows If row2("CveConceptoContable").ToString().ToEntero = 12 Then importeMovimiento = row2("Importe").ToString().ToDecimal() @@ -3915,6 +3915,32 @@ Namespace Modelos End If + 'SI ES PAGO CON DEVOLUCION + If ObjFactura.CveTipoAmortizacionAnticipo = 4 Then + If row2("CveConceptoContable").ToString().ToEntero = 277 Then + + importeMovimiento = row2("Importe").ToString().ToDecimal() + importeMX = importeMovimiento * tipoCambio + sumaAmorticaciones += importeMovimiento + + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, 150, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=-1, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveClasificacion:=ObjFactura.DtDetalle.MAX("CveClasificacion").ToEntero(), CveSubProyecto:=ObjFactura.CveSubProyecto, Contabilizable:=Contabilizable) Then + ErrorPrepoliza = True + End If + + If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento * -1, importeMX * -1, 277, Referencia, Concepto, CveVenta:=row2("CveVenta").ToString().ToEntero(), CveVentaAmortizacion:=-1, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento * -1, importeMX * -1, 278, Referencia, Concepto, CveVenta:=row2("CveVenta").ToString().ToEntero(), CveVentaAmortizacion:=-1, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + Else + ErrorPrepoliza = True + End If + End If + + End If + End If + + Next End If If sumaAmorticaciones <> 0 Then @@ -4207,6 +4233,42 @@ Namespace Modelos End If + 'APLICA PAGO SI SELECCIONA IxC + If Not ErrorPrepoliza AndAlso ValorMultiplicador = 1 AndAlso ObjFactura.CveTipoAmortizacionAnticipo = 4 Then + + Dim VentaActual As New ClsPaginas.Venta(ObjFactura, UsuarioActual) + + For Each row2 As DataRow In DtAnticiposAplicados.Rows + + If row2("CveConceptoContable").ToString().ToEntero() = 66 Then + + importeMovimiento = row2("Importe").ToString().ToDecimal + + If importeMovimiento <> 0 Then + + Dim Pago As New ClsPaginas.VentaPago + Pago.Fecha = Now + Pago.FechaDocumentoRelacionado = row2("Fecha").ToString().ToDateTime() + Pago.ImportePagoVenta = importeMovimiento + Pago.ImportePago = importeMovimiento + Pago.CveIE = row2("CveIE").ToString().ToEntero() + Pago.CveMonedaPago = row2("CveMoneda").ToString().ToEntero() + Pago.TCPago = row2("TipoCambioPago").ToString().ToDecimal() + Pago.AplicaTraslado = False + Pago.Referencia = row2("Folio").ToString() + Pago.CveVentaAmortizacion = -1 + Pago.TipoPago = "I" + Pago.CveClientePago = ObjFactura.CveCliente + + ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(VentaActual, Pago, ObjFactura.CvePrePoliza, ObjConta, AplicarConceptoAplicacion:=True) + + End If + + End If + Next + End If + + If ObjFactura.RemisionesLista.Count = 0 AndAlso (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) Then For Each Row As DataRow In DtRemisionesRelacionadas.Rows ObjFactura.RemisionesLista.Add(Row("CveVenta").ToString().ToEntero()) diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index 7748dc5ff..58a0c8a6d 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -529,6 +529,14 @@ Partial Class Ventas_PVCobranza 'REALIZAR EL PAGO EN LA FACTURA If respFactura IsNot Nothing AndAlso Not respFactura.TieneError Then CveVenta = respFactura.CveVenta + + If HdnTipoAmortizacion.Value = "4" Then + If respFactura.Factura.DtAnticiposAplicados IsNot Nothing Then + PagoAplicado += respFactura.Factura.DtAnticiposAplicados.SUM("Importe") + SaldoPendiente = SaldoPendiente - PagoAplicado + End If + End If + End If End If @@ -793,6 +801,40 @@ Partial Class Ventas_PVCobranza ObjFactura.PreparaTimbre() + If HdnTipoAmortizacion.Value = "4" Then + Dim DtAnticipos As New DataTable() + DtAnticipos.Columns.Add("CveVenta", GetType(Integer)) + DtAnticipos.Columns.Add("Importe", GetType(Decimal)) + DtAnticipos.Columns.Add("CveConceptoContable", GetType(Integer)) + DtAnticipos.Columns.Add("CveIE", GetType(Integer)) + DtAnticipos.Columns.Add("FolioFiscal", GetType(String)) + DtAnticipos.Columns.Add("Descuentos", GetType(Decimal)) + DtAnticipos.Columns.Add("TotalAnticipo", GetType(Decimal)) + DtAnticipos.Columns.Add("SubTotalAnticipo", GetType(Decimal)) + DtAnticipos.Columns.Add("CveMoneda", GetType(Decimal)) + + For Each GvRow As GridViewRow In GVAnticipos.Rows + If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then + Dim CveVenta = GvRow.DataKey("CveVenta").ToEntero() + Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal() + Dim CveConceptoContable = GvRow.DataKey("CveConceptoContable").ToEntero() + Dim CveIE = GvRow.DataKey("CveIE").ToEntero() + + Dim FolioFiscal = GvRow.DataKey("FolioFiscal") + Dim Descuentos As Decimal = GvRow.DataKey("Descuentos").ToDecimal() + Dim TotalAnticipo As Decimal = GvRow.DataKey("TotalAnticipo").ToDecimal() + Dim SubTotalAnticipo As Decimal = GvRow.DataKey("SubTotalAnticipo").ToDecimal() + Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero() + + DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda) + End If + Next + + ObjFactura.EsNCAmortizacion = True + ObjFactura.CveTipoAmortizacionAnticipo = 4 + ObjFactura.DtAnticiposAplicados = DtAnticipos + End If + Dim SbAlert As New StringBuilder() Try @@ -1424,10 +1466,10 @@ Partial Class Ventas_PVCobranza Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero() If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then - 'If DdlTipoAmortizacionAnticipo.Items.FindByValue("4") Is Nothing Then - ' DdlTipoAmortizacionAnticipo.Items.Insert(1, New ListItem("Pago con devolución", "4")) - 'End If - 'DdlTipoAmortizacionAnticipo.SelectedValueExist("4") + If DdlTipoAmortizacionAnticipo.Items.FindByValue("4") Is Nothing Then + DdlTipoAmortizacionAnticipo.Items.Insert(1, New ListItem("Pago con devolución", "4")) + End If + DdlTipoAmortizacionAnticipo.SelectedValueExist("4") DdlTipoRelacionAnticipo.SelectedValueExist("-1") @@ -1701,7 +1743,7 @@ Partial Class Ventas_PVCobranza ListaAnticiposAplicados.Clear() End If - 'cuando es PAGO CON DEVOLUCION + Dim SbObs As New StringBuilder For Each gvr As GridViewRow In GVAnticipos.Rows If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then