diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb
index a37c2505c..6f00aa0c8 100644
--- a/App_Code/Modelos.vb
+++ b/App_Code/Modelos.vb
@@ -742,7 +742,7 @@ Namespace Modelos
Return Not ErrorPrePolizas
End Function
- Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Transac As SqlClient.SqlTransaction = Nothing, Optional Modulo As String = "Modelos/GuardarVentaM") As MMensajeFactura
+ Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Transac As SqlClient.SqlTransaction = Nothing, Optional Modulo As String = "Modelos/GuardarVentaM", Optional MostrarURL As Boolean = False) As MMensajeFactura
Dim Retorno As New MMensajeFactura()
If Me.Version = "3.3" AndAlso Not Me.TipoDocto.Contiene("Ped", "PeC") Then
@@ -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
@@ -1117,8 +1117,12 @@ Namespace Modelos
End If
'MENSAJE PRINCIPAL
- MensajeAlert.AppendFormat(String.Format(" La {0}: {1} se generó correctamente.
", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio))
+ If MostrarURL Then
+ MensajeAlert.AppendFormat(" La {0}: {1} se generó correctamente.
", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio, Me.CveVenta)
+ Else
+ MensajeAlert.AppendFormat(String.Format(" La {0}: {1} se generó correctamente.
", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio))
+ End If
' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA
If SeTimbro Then
@@ -1158,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
@@ -1194,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)))
@@ -1901,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()
@@ -3505,6 +3509,39 @@ Namespace Modelos
Pago.Referencia = Concepto
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta)
+
+ If Not ErrorPrepoliza AndAlso ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.EsNCAmortizacion AndAlso ObjFactura.TipoDocto.Contiene("Egs") AndAlso ObjFactura.DtAnticiposAplicados IsNot Nothing Then
+
+ For Each row2 As DataRow In ObjFactura.DtAnticiposAplicados.Rows
+ If row2("CveConceptoContable").ToString().ToEntero() = 3 Then
+ CveIEAnticipo = row2("CveIE").ToString().ToEntero()
+
+ importeMovimiento = row2("Importe").ToString().ToDecimal() '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal)
+
+ Dim ImporteAnticipo As Decimal = importeMovimiento
+ Dim CveMonedaAnticipo As Integer = row2("CveMoneda").ToString().ToEntero()
+
+ If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
+
+ If ObjFactura.CveTipoAmortizacionAnticipo = 2 Then
+ Dim DescuentosAnticipos As Decimal = row2("Descuentos").ToString().ToDecimal
+ ImporteAnticipo = ImporteAnticipo / (row2("TotalAnticipo").ToString().ToDecimal - DescuentosAnticipos) * row2("SubTotalAnticipo").ToString().ToDecimal
+ ImporteAnticipo = ImporteAnticipo.RoundSQL(2)
+ End If
+
+ Dim Importe11MX As Decimal = ImporteAnticipo
+ CveSubProyectoContabilizar = CveSubProyectoVenta
+
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe11MX, Importe11MX, 11, Referencia, Concepto, CveVenta:=row2("CveVenta").ToString().ToEntero(), CveVentaAmortizacion:=ObjFactura.CveVenta, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ End If
+ End If
+ Next
+
+ End If
Next
If ObjConta.ValidacionesPrePoliza(ObjFactura.CvePrePoliza, UsuarioActual, Opcion:=5) Then
@@ -3517,6 +3554,9 @@ Namespace Modelos
' Dim DtTest = ObjConta.DtResultados
'End If
End If
+
+ importeMovimiento = 0
+ importeMX = 0
End If
If ErrorPrepoliza Then
@@ -3667,30 +3707,31 @@ Namespace Modelos
' cuando es amortización de nota de crédito, y es la nc
' cuando es amortización por descuento, y es el ingreso
' cuando es amortización en cero
- If (ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.TipoDocto.Contiene("Egs") OrElse
- ObjFactura.CveTipoAmortizacionAnticipo = 1 AndAlso ObjFactura.TipoDocto.Contiene("Ing") OrElse
- ObjFactura.CveTipoAmortizacionAnticipo = 3) Then
- For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows
- If row2("CveConceptoContable").ToString().ToEntero = 11 Then
- CveIEAnticipo = -1
- importeMovimiento = row2("Importe").ToString().ToDecimal()
- If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
+ If (ObjFactura.CveTipoAmortizacionAnticipo = 1 AndAlso ObjFactura.TipoDocto.Contiene("Ing") OrElse ObjFactura.CveTipoAmortizacionAnticipo = 3) Then
+ If DtAnticipos IsNot Nothing Then
+ For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows
+ If row2("CveConceptoContable").ToString().ToEntero = 11 Then
+ CveIEAnticipo = -1
+ importeMovimiento = row2("Importe").ToString().ToDecimal()
+ If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
- CveSubProyectoContabilizar = CveSubProyectoVenta
+ CveSubProyectoContabilizar = CveSubProyectoVenta
- If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, ConceptoContable, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta,
- CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo,
- ImporteME:=If(tipoCambio = 1, 0, importeMovimiento),
- CveSubProyecto:=CveSubProyectoContabilizar) Then
- ErrorPrepoliza = True
- Exit For
- Else
- ObjFactura.SeGuardoPrePoliza = True
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, ConceptoContable, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta,
+ CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo,
+ ImporteME:=If(tipoCambio = 1, 0, importeMovimiento),
+ CveSubProyecto:=CveSubProyectoContabilizar) Then
+ ErrorPrepoliza = True
+ Exit For
+ Else
+ ObjFactura.SeGuardoPrePoliza = True
+ End If
End If
End If
- End If
- Next
+ Next
+ End If
+
End If
End If
@@ -3851,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()
@@ -3874,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
@@ -4166,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())
@@ -6697,7 +6800,7 @@ Namespace Modelos
If Not ObjVentas.UpdateEstatusOCRelacionada(ObjFactura.CveVenta, CveEstatusCancelacion, ObjFactura.CveEmpresa) Then
ErrorCancelar = True
MensajeError = "Ocurrió un error al cancelar la orden de servicio"
- else
+ Else
End If
End If
End If
@@ -7601,6 +7704,7 @@ Namespace Modelos
Public Property DtDocumentosRelacionados As Data.DataTable
Public Property DtNCVinculadas As Data.DataTable
Public Property DtAnticipos As Data.DataTable
+ Public Property DtAnticiposAplicados As Data.DataTable
Public Property DtPromociones As Data.DataTable
Public Property DtImpuestosLocales As Data.DataTable
Public Property DtPagos As Data.DataTable
diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx
index 71e5d047e..bebe8fb29 100644
--- a/Compras/Compras.aspx
+++ b/Compras/Compras.aspx
@@ -2137,7 +2137,7 @@
-
@@ -2194,6 +2206,9 @@
+
+ Vinculación
+
@@ -2207,11 +2222,17 @@
+
+ Horómetro / Odómetro
+
+
+ Mantenimiento
+
@@ -2221,6 +2242,9 @@
+
+ Dividir
+
diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb
index db74efea7..073f60a19 100644
--- a/General/SaldosIniciales.aspx.vb
+++ b/General/SaldosIniciales.aspx.vb
@@ -1800,7 +1800,7 @@ Partial Class General_SaldosIniciales
Dim dtsubp As DataTable = GlobalDTSubProyectos(UsuarioActual.CveEmpresa)
If UsuarioActual.CveEmpresa = 189 Then
- For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
+ For Each Row As DataRow In dt.Rows
Dim SubTotal = Row("SubTotal").ToString().ToDecimal.RoundSQL
Dim IVA = Row("IVA").ToString().ToDecimal.RoundSQL
Dim Total = Row("Total").ToString().ToDecimal.RoundSQL
@@ -1810,8 +1810,16 @@ Partial Class General_SaldosIniciales
If Total - SubTotal - IVA <> 0 Then
Row("PU") = (Total - IVA) / Cantidad
Row("SubTotal") = Row("PU").ToString.ToDecimal * Cantidad
+
+ PU = Row("PU").ToString.ToDecimal
+ SubTotal = Row("SubTotal").ToString().ToDecimal.RoundSQL
+ End If
+
+ If ((Cantidad * PU) - SubTotal) <> 0 Then
+ Row("PU") = SubTotal / Cantidad
End If
Next
+ dt.AcceptChanges()
End If
Dim CountRow As Integer = 1
diff --git a/Inventarios/KardexAlmacenHorizontal.aspx b/Inventarios/KardexAlmacenHorizontal.aspx
index 770f57010..a791a8f1d 100644
--- a/Inventarios/KardexAlmacenHorizontal.aspx
+++ b/Inventarios/KardexAlmacenHorizontal.aspx
@@ -195,6 +195,7 @@
+
<%----%>
@@ -228,11 +229,11 @@
-
-
+
+
-
+
diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb
index fef677302..560009b05 100644
--- a/Inventarios/RecepcionAlmacen.aspx.vb
+++ b/Inventarios/RecepcionAlmacen.aspx.vb
@@ -1038,11 +1038,14 @@ Partial Class Inventarios_RecepcionAlmacen
' HplCargaExcel.Enabled = True
+
+
Dim CargaSoloUsados As Boolean = False
If ObjInventario.RecepcionAlmacenGet(pCveCompra, BuscaEntregaDirecta, -1, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
Dim DtRecepcion As DataTable = ObjInventario.DtResultados.Copy()
DtInv = DtRecepcion
+
Dim NumUsados As Integer = ObjInventario.DtResultados.COUNT("EsUsado", "EsUsado = True").ToEntero()
Dim NumProductos As Integer = ObjInventario.DtResultados.COUNT("EsUsado", "EsUsado = False").ToEntero()
Dim CveSubProyecto As Integer
@@ -1093,6 +1096,14 @@ Partial Class Inventarios_RecepcionAlmacen
End If
End If
+
+ If Not UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ If ObjCompras.GetCompraDetalle(pCveCompra, UsuarioActual.CveEmpresa) Then
+ TotalCompraOC = ObjCompras.DtResultados.SUM("Total", "CveTipoPS = 2")
+ End If
+ End If
+
+
CveSubProyecto = DtRecepcion.Rows(0)("CveSubProyecto").ToString.ToEntero
CveAlmacenDevolucionProveedor = DtRecepcion.Rows(0)("CveAlmacenDevolucionProveedor").ToString.ToEntero
diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb
index d5c09fa02..1e5be9f9f 100644
--- a/Sistemas/UsuarioDetalle.aspx.vb
+++ b/Sistemas/UsuarioDetalle.aspx.vb
@@ -410,8 +410,9 @@ Partial Class Sistemas_UsuarioDetalle
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
- If Not IsPostBack Then
-
+ If Not IsPostBack Then
+
+
ViewState("Orden") = ""
ViewState("CveEmpresa") = "-1"
'ViewState("CveSucursal") = ""
@@ -1404,8 +1405,13 @@ Partial Class Sistemas_UsuarioDetalle
' Application("GlobalDTUsuarioResponsable") = ObjUsuarios.DtResultados.FiltraParametros("ProveedoresResponsables > 0")
'End If
End Sub
- Private Sub EnviaCorreo()
-
+ Private Sub EnviaCorreo()
+
+ Dim UrlsitioUrlActual As String = ObtenerUrlCompleta()
+
+ Dim Solicitud As HttpRequest = HttpContext.Current.Request
+
+
Try
Dim Para As String = TxtCorreo.Text.Trim
Dim Asunto As String = "ALTA DE CUENTA"
@@ -1438,7 +1444,7 @@ Partial Class Sistemas_UsuarioDetalle
SBBody.Append("")
SBBody.Append("
")
SBBody.Append("Nota Favor de NO responder este correo. ")
SBBody.Append("
")
- SBBody.AppendFormat("
ADSistemas
", UrlSitio)
+ SBBody.AppendFormat("
ADSistemas
", UrlsitioUrlActual)
SBBody.Append("")
SBBody.Append("")
'Termino Cuerpo del correo
@@ -1458,6 +1464,27 @@ Partial Class Sistemas_UsuarioDetalle
OnError("Ocurrió error al mandar MAIL", ex)
End Try
End Sub
+
+
+ Public Function ObtenerUrlCompleta() As String
+
+ Dim Solicitud As HttpRequest = HttpContext.Current.Request
+ Dim url As String = Solicitud.Url.Scheme & "://" & Solicitud.Url.Host
+
+ If (Solicitud.Url.Port <> 80 AndAlso Solicitud.Url.Port <> 443) Then
+ url &= ":" & Solicitud.Url.Port
+ End If
+
+
+ url &= Solicitud.ApplicationPath
+
+ If Not url.EndsWith("/") Then
+ url &= "/"
+ End If
+
+ Return url
+ End Function
+
#End Region
diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx
index bd66a876e..6e34641e4 100644
--- a/Ventas/PVCobranza.aspx
+++ b/Ventas/PVCobranza.aspx
@@ -411,6 +411,10 @@
@@ -1101,21 +1275,124 @@
//function impresionDirecta(urlPDF) {
// printJS({ printable: urlPDF, type: 'pdf', showModal: true });
//}
+
+ function chkAnt(t, txt, importe, AmorContrato = 0) {
+ let totalAnt = 0;
+
+ let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
+
+ //si es con.nc,es.el.total
+ let Total = ToDouble($get("C_LtlSaldo").value);
+
+ let SaldoCompra = parseFloat(parseFloat($get("C_LtlSaldo").value).toFixed(2));
+
+ if (t.checked) {
+
+ if (SaldoCompra > 0) {
+
+ if (AmorContrato > 0) {
+ txt.value = AmorContrato.toFixed(2);
+ } else {
+ txt.value = importe.toFixed(2);
+ }
+
+ totalAnt = FnSumaValoresAnt();
+
+ if (totalAnt > SaldoCompra) {
+ txt.value = FormatoNumero(importe - (totalAnt - SaldoCompra), 2);
+ //$get('HdnVentaSaldo').value = 0.00;
+ alert("El Importe no debe de exceder a el saldo");
+ }
+
+ } else {
+ t.checked = false;
+ }
+
+ } else {
+ //$get('HdnVentaSaldo').value = parseFloat(SaldoCompra) + parseFloat(txt.value);
+ txt.value = "";
+ }
+
+ $("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
+ }
+
+
+ function FnCambiaAnt(chk, txt, saldo) {
+
+ let Total = ToDouble($get("C_LtlSaldo").value);// ToDouble($get('TxtSubTotal').value);
+
+ let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
+ let importeTxt = parseFloat(txt.value.replace(/,/g, ''));
+
+ if (TipoAnticipo == '4') {
+ Total = ToDouble($get("C_LtlSaldo").value);
+ }
+
+ if (isNaN(importeTxt)) {
+ importeTxt = 0;
+ } else {
+ if (importeTxt <= 0) {
+ importeTxt = 0;
+ chk.checked = false;
+ return;
+ }
+ }
+
+ saldo = (importeTxt > saldo) ? saldo : importeTxt;
+
+
+ var SaldoCompra = (Total - FnSumaValoresAnt() + ToDouble(txt.value)).toFixed(2); // le agrego lo del valor actual para validarlo //parseFloat(parseFloat($get('HdnVentaSaldo').value).toFixed(2));
+ if (SaldoCompra < 0) txt.value = SaldoCompra - txt.value;
+ //minimo entre saldocompra y el saldoanticipo
+ if (SaldoCompra < saldo) saldo = SaldoCompra;
+
+ if (ToDouble(txt.value) > 0) {
+ chk.checked = true;
+ } else {
+ chk.checked = false;
+ }
+
+ if (ToDouble(txt.value) > saldo) {
+ txt.value = saldo;
+ alert("El Importe no debe de exceder a el saldo");
+ }
+
+ $("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
+
+ // $get('HdnVentaSaldo').value = Total - FnSumaValoresAnt();
+ }
+
+ function FnSumaValoresAnt() {
+ let totalPoints = 0;
+ let t = '';
+
+ $('input[name*=TxtAnticipo]').each(function () {
+ totalPoints += ToDouble($(this).val());
+ });
+
+ return Math.round(totalPoints * 100) / 100;
+ }
function impresionBase64(pdfBase64) {
printJS({ printable: pdfBase64, type: 'pdf', showModal: true, base64: true });
}
- function CalculaTotalPagoContado() {
- debugger;
- var totalEfectivo = ToDouble($get("TxtImporteEfectivo").value);
- var totalCredito = ToDouble($get("TxtImporteCredito").value);
- var totalDebito = ToDouble($get("TxtImporteDebito").value);
- var totalCheque = ToDouble($get("TxtImporteCheque").value);
- var totalTransferencia = ToDouble($get("TxtImporteTransferencia").value);
- var TotalOtrosContado = 0;
- var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado;
- var totalVenta = ToDouble($get('HdnTotal').value);// - ToDouble($get('HdnTotal').value);
+ function CalculaTotalPagoContado() {
+ let totalEfectivo = ToDouble($get("TxtImporteEfectivo").value);
+ let totalCredito = ToDouble($get("TxtImporteCredito").value);
+ let totalDebito = ToDouble($get("TxtImporteDebito").value);
+ let totalCheque = ToDouble($get("TxtImporteCheque").value);
+ let totalTransferencia = ToDouble($get("TxtImporteTransferencia").value);
+ let TotalOtrosContado = 0;
+
+ let total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado;
+
+ if (<%= If(UsuarioActual.Empresa.CveEmpresa = 189, 1, 0)%> == 1) {
+ let totalAnticipos = ToDouble($get("TxtNCDev").value);
+ total = total + totalAnticipos;
+ }
+
+ let totalVenta = ToDouble($get('HdnTotal').value);// - ToDouble($get('HdnTotal').value);
if (total > totalVenta) {
lblCambio.innerHTML = "Cambio:";
@@ -1131,14 +1408,13 @@
}
function CalculaDiferencia() {
- ;
- var total = 0
+ let total = 0;
total = ToDouble($('#C_TxtEfectivoEnCaja').val()) - ToDouble($('#C_LblEfectivoEsperado').text());
$('#C_LblDiferenciaCaja').text(FormatoNumero(total));
}
function CalculaDiferenciaBloqueo() {
- var total = 0;
+ let total = 0;
total = ToDouble($('#C_TxtEfectivoCajaBloqueo').val()) - ToDouble($('#C_LblEfectivoBloqueo').text());
$('#C_LblDiferenciaCajaBloqueo').val(FormatoNumero(total));
}
diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb
index a9a2cd176..58a0c8a6d 100644
--- a/Ventas/PVCobranza.aspx.vb
+++ b/Ventas/PVCobranza.aspx.vb
@@ -4,9 +4,40 @@ Option Strict On
Imports System.Data
Imports System.IO
Imports Extensiones
+Imports Modelos.Factura
Partial Class Ventas_PVCobranza
- Inherits ClsPaginas
+ Inherits ClsPaginas
+
+ Private Property CveCliente As Integer
+ Get
+ If ViewState("CveCliente") Is Nothing Then
+ ViewState("CveCliente") = -1
+ End If
+ Return ViewState("CveCliente").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveCliente") = value
+ End Set
+ End Property
+
+ Private Property TmpDTAnticiposNCIxCCliente As DataTable
+ Get
+ Return If(IsNothing(ViewState("TmpDTAnticiposNCIxCCliente")), Nothing, CType(ViewState("TmpDTAnticiposNCIxCCliente"), DataTable))
+ End Get
+ Set(value As DataTable)
+ ViewState("TmpDTAnticiposNCIxCCliente") = value
+ End Set
+ End Property
+
+ Private Property ListaAnticiposAplicados As List(Of Modelos.MAnticipoRelacionado)
+ Get
+ Return If(IsNothing(ViewState("ListaAnticiposAplicados")), Nothing, CType(ViewState("ListaAnticiposAplicados"), List(Of Modelos.MAnticipoRelacionado)))
+ End Get
+ Set(value As List(Of Modelos.MAnticipoRelacionado))
+ ViewState("ListaAnticiposAplicados") = value
+ End Set
+ End Property
Private Property CveCorte As Integer
Get
@@ -270,16 +301,6 @@ Partial Class Ventas_PVCobranza
ObjMovtos.Dispose()
GvDatos.DataBind()
- TxtImporteEfectivo.Text = ""
- TxtImporteCredito.Text = ""
- TxtImporteDebito.Text = ""
- TxtImporteCheque.Text = ""
- TxtImporteTransferencia.Text = ""
- TxtImporteOtrosContado.Text = ""
- TxtCambio.Text = ""
- TxtClaveAutorizacion.Text = ""
- TxtAutorizo.Text = ""
-
UpL.Update()
End Sub
@@ -296,6 +317,7 @@ Partial Class Ventas_PVCobranza
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
+ LimpiarDatos()
If ChkMostrarSoloPagados.Checked Then
DVCobraza.Visible = False
@@ -343,6 +365,8 @@ Partial Class Ventas_PVCobranza
Private Sub GvDatos_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvDatos.RowCommand
If e.CommandName = "Cobrar" Then
+ LimpiarDatos()
+
Dim ImgBtn As LinkButton = DirectCast(e.CommandSource, LinkButton)
Dim GvRow As GridViewRow = DirectCast(ImgBtn.BindingContainer, GridViewRow)
Dim TieneError As Boolean = False
@@ -380,6 +404,12 @@ Partial Class Ventas_PVCobranza
LtlNombre.Text = GvRow.DataKey("AtencionA")
LtlFolio.Text = GvRow.DataKey("SerieFolio")
LtlSaldo.Text = GvRow.DataKey("Saldo").ToDecimal.FormatoNumero
+
+ If UsuarioActual.CveEmpresa = 189 AndAlso GvRow.DataKey("TipoDocto") = "Rem" Then
+ DivAnticipo.Visible = True
+ ImgAntiPend.Visible = True
+ End If
+
Catch ex As Exception
TieneError = True
End Try
@@ -404,7 +434,7 @@ Partial Class Ventas_PVCobranza
'registrar pago
'validaciones
- Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal
+ Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal + TxtNCDev.Text.ToDecimal()
If Pagado = 0 Then
Alert("Favor de especificar importe", TipoMensaje.ToastAdventencia)
Exit Sub
@@ -436,7 +466,8 @@ Partial Class Ventas_PVCobranza
End If
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero
-
+ Dim CveVentaRemision As Integer = -1
+
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
@@ -463,6 +494,7 @@ Partial Class Ventas_PVCobranza
VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal
VentaActual.UsuarioActual = UsuarioActual
VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero
+
If tCveCorte <= 0 AndAlso DbRowVenta("CveCorte").ToString.ToEntero > 0 Then tCveCorte = DbRowVenta("CveCorte").ToString.ToEntero
Dim CvePrePoliza As Integer
@@ -479,10 +511,14 @@ Partial Class Ventas_PVCobranza
Dim ObjClientes As New ClsClientes(ObjVentas2.IniciaTransacSQL())
Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing
+ Dim respNC As Modelos.Factura.MMensajeFactura = Nothing
Try
'FACTURAR LA REMISION PARA HACER EL PAGO
If UsuarioActual.CveEmpresa.Contiene(189, 197) AndAlso VentaActual.TipoDocto = "Rem" Then
+
+ CveVentaRemision = HdnCveVenta.Value.ToEntero
+
respFactura = GenerarFactura(VentaActual, ObjVentas2, ObjClientes)
If respFactura Is Nothing Then
@@ -493,6 +529,36 @@ 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
+
+ 'GENERAR NC PARA AMORTIZACION
+ If MsgError = "" AndAlso UsuarioActual.CveEmpresa.Contiene(189) AndAlso HdnTipoAmortizacion.Value = "2" Then
+ respNC = GenerarNC(VentaActual, ObjVentas2)
+
+ If respNC IsNot Nothing Then
+ If respNC.TieneError Then
+ CveVenta = -1
+
+ If respNC.Mensajes.Count > 0 Then
+ MsgError = respNC.Mensajes(0)
+ Else
+ MsgError = "Ocurrió un error al generar la nota de crédito"
+ End If
+ Else
+ PagoAplicado += respNC.Factura.Total
+ SaldoPendiente = SaldoPendiente - PagoAplicado
+ End If
+ Else
+ MsgError = "Ocurrió un error al generar la nota de crédito"
End If
End If
@@ -546,14 +612,22 @@ Partial Class Ventas_PVCobranza
MsgError = "Tiene saldo pendiente por aplicar"
End If
- If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, tCveCorte) Then
- MsgError = "Error al aplicar el corte"
+ If UsuarioActual.CveRol <> 1 Then
+ If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, tCveCorte) Then
+ MsgError = "Error al aplicar el corte"
+ End If
End If
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaTicketImpreso(CveVenta, 0) Then
MsgError = "No se pudo desmarcar la impresión"
End If
+ If CveVentaRemision > 0 Then
+ If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaTicketImpreso(CveVentaRemision, 0) Then
+ MsgError = "No se pudo desmarcar la impresión"
+ End If
+ End If
+
Else
MsgError = "Error al registrar prepólizas"
End If
@@ -567,17 +641,24 @@ Partial Class Ventas_PVCobranza
ObjVentas2.Commit()
Dim msBuild As New StringBuilder()
'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO
- If respFactura IsNot Nothing Then
- If Not respFactura.Factura.TimbrarFactura() Then
- msBuild.Append("La factura no se pudo timbrar ")
- End If
- End If
+ 'If respFactura IsNot Nothing Then
+ ' If Not respFactura.Factura.TimbrarFactura() Then
+ ' msBuild.Append("La factura no se pudo timbrar ")
+ ' End If
+ 'End If
If respFactura IsNot Nothing Then
msBuild.Append($"Pago Registrado correctamente.")
For Each m In respFactura.Mensajes
msBuild.AppendFormat(" {0}", m)
Next
+
+ If respNC IsNot Nothing Then
+ For Each m In respNC.Mensajes
+ msBuild.AppendFormat(" {0}", m)
+ Next
+ End If
+
Else
msBuild.Append($"Pago Registrado correctamente.
Imprimir ticket")
End If
@@ -599,8 +680,8 @@ Partial Class Ventas_PVCobranza
ImpresionDirectaPDF(CveVenta)
End If
- PnlContado.Visible = False
- HdnCveVenta.Value = ""
+ LimpiarDatos()
+
CargaDatos()
Catch ex As Exception
GuardaLog(ex.ToString())
@@ -612,6 +693,38 @@ Partial Class Ventas_PVCobranza
End Sub
+ Private Sub LimpiarDatos()
+ PnlContado.Visible = False
+ TxtImporteEfectivo.Text = ""
+ TxtImporteCredito.Text = ""
+ TxtImporteDebito.Text = ""
+ TxtImporteCheque.Text = ""
+ TxtImporteTransferencia.Text = ""
+ TxtImporteOtrosContado.Text = ""
+ TxtCambio.Text = ""
+ TxtClaveAutorizacion.Text = ""
+ TxtAutorizo.Text = ""
+ TxtNCDev.Text = ""
+ LtlTipoAnticipo.Text = ""
+ HdnTipoAmortizacion.Value = ""
+ CveCliente = -1
+
+ If TmpDTAnticiposNCIxCCliente IsNot Nothing Then
+ TmpDTAnticiposNCIxCCliente.Clear()
+ TmpDTAnticiposNCIxCCliente = Nothing
+ End If
+
+ If ListaAnticiposAplicados IsNot Nothing Then
+ ListaAnticiposAplicados.Clear()
+ ListaAnticiposAplicados = Nothing
+ End If
+
+ ImgAntiPend.Visible = False
+ DivAnticipo.Visible = False
+
+ UpL.Update()
+ End Sub
+
Private Function GenerarFactura(ByRef VentaRemision As Venta, ByRef ObjVentas As ClsVentas, ByRef ObjClientes As ClsClientes) As Modelos.Factura.MMensajeFactura
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
@@ -685,15 +798,51 @@ Partial Class Ventas_PVCobranza
ObjFactura.CalculaTotales()
+
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
- Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta")
+ Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)
Retorno.Factura = ObjFactura
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
+
For Each msg In Retorno.Mensajes
SbAlert.AppendFormat("{0} ", msg)
Next
@@ -756,6 +905,97 @@ Partial Class Ventas_PVCobranza
Return Retorno
End Function
+ Private Function GenerarNC(ByRef Venta As Venta, ByRef ObjVentas As ClsVentas) As Modelos.Factura.MMensajeFactura
+ Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
+ Dim ObjNC = Modelos.Factura.CrearVentaNueva(UsuarioActual, Venta.CveSubProyecto, Venta.CveCliente, Venta.CveMoneda, "Egs")
+
+ Dim Total As Decimal = TxtNCDev.Text.ToDecimal()
+ Dim subTotal As Decimal = (Total / (1D + Venta.PorcentajeIVA))
+ 'Dim IVA = (subTotal * Factura.PorcentajeIVA).RoundSQL(2)
+ Dim PU As Decimal = subTotal
+ Dim Cantidad As Decimal = 1D
+ Dim Descuento As Decimal = 0
+ Dim Obs = ""
+
+ ObjNC.AgregarPS(DdlNCPSAnt.SelectedValue.ToEntero(), Cantidad, PU, Descuento, Obs, CveSubProyecto:=Venta.CveSubProyecto, PorcentajeIVA:=Venta.PorcentajeIVA)
+ ObjNC.CalculaTotales()
+
+ Dim DtVentasNC = New DataTable
+ DtVentasNC.Columns.Add("CveVenta", GetType(Integer))
+ DtVentasNC.Columns.Add("Importe", GetType(Decimal))
+ DtVentasNC.Columns.Add("FolioFiscal", GetType(String))
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TC", .DataType = GetType(Decimal), .DefaultValue = 1})
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TCCambioValuacion", .DataType = GetType(Decimal), .DefaultValue = 1})
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "CveEstatusFactura", .DataType = GetType(Integer), .DefaultValue = -1})
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "Folio", .DataType = GetType(String), .DefaultValue = ""})
+
+ DtVentasNC.Rows.Add(Venta.CveVenta, Total, "")
+
+ ObjNC.DtVentasNC = DtVentasNC
+
+ Dim DtVentasRelacionadas As New DataTable()
+ DtVentasRelacionadas.Columns.Add("CveVenta", GetType(Integer))
+ DtVentasRelacionadas.Rows.Add(Venta.CveVenta)
+
+ ObjNC.DtVentasRelacionadas = DtVentasRelacionadas
+
+ 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
+
+ ObjNC.EsNCAmortizacion = True
+ ObjNC.CveTipoAmortizacionAnticipo = 2
+ ObjNC.DtAnticiposAplicados = DtAnticipos
+
+ ObjNC.PreparaTimbre()
+
+ Dim SbAlert As New StringBuilder()
+
+ Try
+ Retorno = ObjNC.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)
+ Retorno.Factura = ObjNC
+
+ If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
+
+ For Each msg In Retorno.Mensajes
+ SbAlert.AppendFormat("{0} ", msg)
+ Next
+
+ SbAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta)))
+ Else
+ SbAlert.Append("Ocurrió un error al generar la nota de crédito")
+ End If
+ Catch ex As Exception
+ SbAlert.Append("Ocurrió un error al generar el documento")
+ GuardaLog(ex.ToString())
+ End Try
+ Return Retorno
+ End Function
+
Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas, tCveCorte As Integer, Optional Obs As String = "", Optional CveAutorizacion As String = "", Optional CveSubProyecto As Integer = -1) As String
Dim Retorno As String = ""
Dim CveIEPago As Integer = 0
@@ -1078,8 +1318,7 @@ Partial Class Ventas_PVCobranza
Dim ObjVentas As New ClsVentas
If ObjVentas.UpdateAsignaVentaCobranza(HdnCveVenta.Value.ToEntero, -1, -1, -1, "", Now) Then
- PnlContado.Visible = False
- HdnCveVenta.Value = ""
+ LimpiarDatos()
CargaDatos()
End If
ObjVentas.Dispose()
@@ -1132,9 +1371,7 @@ Partial Class Ventas_PVCobranza
End If
End Sub
-
-
- Sub CargaDdlPagos()
+ Private Sub CargaDdlPagos()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing' AND Estatus = 1")
DdlTipoTransaccion.DataBind()
@@ -1223,4 +1460,361 @@ Partial Class Ventas_PVCobranza
RegistraScript("$('#DVModalCobrosEnTranscurso').modal('show');")
End Sub
+
+ Protected Sub ImgAntiPend_Click(sender As Object, e As EventArgs)
+
+ 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")
+
+ DdlTipoRelacionAnticipo.SelectedValueExist("-1")
+
+ divAmortizacionTipoRelacion.Visible = False
+
+ DdlTipoAmortizacionAnticipo_SelectedIndexChanged(DdlTipoAmortizacionAnticipo, EventArgs.Empty)
+ End If
+
+ If CveCliente <= 0 Then
+ Dim DbRowVenta As DataRow = Nothing
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
+ DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
+ End If
+ ObjVentas.Dispose()
+
+ If DbRowVenta IsNot Nothing Then
+ CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
+ End If
+ End If
+
+ If CveCliente > 0 Then
+ CargaAnticipos(CveCliente)
+ End If
+
+ UpAnticipos.Update()
+
+ RegistraScript("$('#DivAnticipos').modal();", "AE")
+ End Sub
+
+ Private Sub CargaAnticipos(CveCliente As Integer)
+ 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
+
+ Dim ObjMovtos As New ClsMovimientos()
+ If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then
+ Me.TmpDTAnticiposNCIxCCliente = ObjMovtos.DtResultados.Copy()
+ End If
+
+ 'AGREGAR LOS ANTICIPOS, DEV, IxC QUE ESTEN EN PUBLICO GENERAL
+ If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing AndAlso UsuarioActual.CveEmpresa.Contiene(189, 190, 192, 195, 197) Then
+ Dim CveClientePublicoGeneral = UsuarioActual.Empresa.Funcionalidad(714).ToEntero()
+ If CveClientePublicoGeneral > 0 Then
+ If CveCliente <> CveClientePublicoGeneral Then
+ If ObjMovtos.GetAnticiposNCIxCCliente(CveClientePublicoGeneral) Then
+ For Each DrGeneral As DataRow In ObjMovtos.DtResultados.Rows
+ Me.TmpDTAnticiposNCIxCCliente.Rows.Add(DrGeneral.ItemArray)
+ Next
+ End If
+ End If
+ End If
+ End If
+ ObjMovtos.Dispose()
+
+ If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing Then
+ Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 AND Tipo IN('NC','IxC','Ant') ")
+
+ If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then
+ GVAnticipos.DataSource = DtMovtos.FiltraParametros("Tipo IN('NC','IxC')")
+ Else
+ GVAnticipos.DataSource = DtMovtos.FiltraParametros("Tipo IN('Ant')")
+ End If
+ Else
+ GVAnticipos.DataSource = Nothing
+ End If
+
+ divAmortizacionTipo.Visible = True
+
+ If UsuarioActual.Empresa.Funcionalidad(343) = "1" Then
+ DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
+ End If
+
+ GVAnticipos.Columns(4).Visible = False
+ GVAnticipos.Columns(8).Visible = False
+
+ If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
+ GVAnticipos.Columns(6).Visible = True
+ End If
+
+ GVAnticipos.DataBind()
+ End If
+ UpAnticipos.Update()
+ End Sub
+
+ Protected Sub TxtFechaAnticipoCliente_TextChanged(sender As Object, e As EventArgs)
+ Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
+
+ If CveCliente <= 0 Then
+ Dim DbRowVenta As DataRow = Nothing
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
+ DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
+ End If
+ ObjVentas.Dispose()
+
+ If DbRowVenta IsNot Nothing Then
+ CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
+ End If
+ End If
+
+ If CveCliente > 0 Then
+ CargaAnticipos(CveCliente)
+ End If
+
+ End Sub
+ Protected Sub LnkRecargaAnticipos_Click(sender As Object, e As EventArgs)
+ Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
+
+ If CveCliente <= 0 Then
+ Dim DbRowVenta As DataRow = Nothing
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
+ DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
+ End If
+ ObjVentas.Dispose()
+
+ If DbRowVenta IsNot Nothing Then
+ CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
+ End If
+ End If
+
+ If CveCliente > 0 Then
+ CargaAnticipos(CveCliente)
+ End If
+ End Sub
+
+ Protected Sub LnkSolicitarActivarAnticipo_Click(sender As Object, e As EventArgs)
+ Dim CveCliente As Integer = -1
+ 'falta sacar a los usuarios a notificar.
+ Dim gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow)
+ Dim Folio As String = gvr.DataKey("Folio")
+ Dim dtt As DataTable = Nothing
+
+ Dim ObjProceso As New ClsSisProcesos
+ If ObjProceso.GetUsuariosconProceso(379, UsuarioActual.CveEmpresa) Then 'proceso para autorizar
+ dtt = ObjProceso.DtResultados.Copy()
+ End If
+ ObjProceso.Dispose()
+
+ If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
+ For Each dr As DataRow In dtt.Rows
+ ClsSisNotificaciones.EnviarAlerta("Solicitud de Anticipo", $"Solicitud de activación de anticipo Folio: {Folio} Ir Activar", dr("CveUsuario").ToString, Tipo:=TipoNotificacion.ToastInformacionB)
+ Next
+ End If
+
+ UpAnticipos.Update()
+ End Sub
+
+ Protected Sub GVAnticipos_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAnticipos.RowCreated
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.ClientIDMode = ClientIDMode.Static
+ e.Row.ID = String.Format("TrH{0}", e.Row.RowIndex)
+ ElseIf e.Row.RowType = DataControlRowType.DataRow Then
+ e.Row.ClientIDMode = ClientIDMode.Static
+ e.Row.ID = String.Format("Tr{0}", e.Row.RowIndex)
+ e.Row.FCCheckBox("Chk").ID = "Chk" & e.Row.RowIndex
+ e.Row.FCTextBox("TxtAnticipo").ID = "TxtAnticipo" & e.Row.RowIndex
+ e.Row.FCTextBox("TxtTC").ID = "TxtTC" & e.Row.RowIndex
+ DirectCast(e.Row.FindControl("CVAmortAnti"), CompareValidator).ID = "CVAmortAnti" & e.Row.RowIndex
+ DirectCast(e.Row.FindControl("VCOAmortAnti"), AjaxControlToolkit.ValidatorCalloutExtender).ID = "VCOAmortAnti" & e.Row.RowIndex
+ DirectCast(e.Row.FindControl("CVAmortAnti"), CompareValidator).ControlToValidate = "TxtAnticipo" & e.Row.RowIndex
+ DirectCast(e.Row.FindControl("VCOAmortAnti"), AjaxControlToolkit.ValidatorCalloutExtender).TargetControlID = "CVAmortAnti" & e.Row.RowIndex
+
+ 'SI NO TIENE PERMISO, NO PERMITIR APLICAR ANTICIPOS PUNTUALES
+ If GVAnticipos.DataSource IsNot Nothing Then
+ If CBool(e.Row.DBCampo("AnticipoPuntual")) AndAlso Not UsuarioActual.TienePermisoProceso(377) Then
+ e.Row.FCCheckBox("Chk").Enabled = False
+ End If
+ End If
+
+ End If
+ End Sub
+
+ Protected Sub GVAnticipos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAnticipos.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+ 'Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal
+
+ If e.Row.RowIndex = 0 Then
+ e.Row.Cells(1).Width = Unit.Pixel(60)
+ e.Row.Cells(2).Width = Unit.Pixel(100)
+ e.Row.Cells(3).Width = Unit.Pixel(80)
+ e.Row.Cells(4).Width = Unit.Pixel(80)
+ End If
+
+ e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right
+
+ If e.Row.DataKey("Saldo").ToDouble < 0 Then e.Row.Cells(3).ForeColor = Drawing.Color.Red
+ If e.Row.DataKey("Saldo").ToDouble = 0 Then e.Row.FCLiteral("LtlAnticipos").Text = ""
+
+ Dim saldo As Decimal = 0
+ Dim tipoCambio As Decimal = 0
+ Dim total As Decimal = LtlSaldo.Text.ToDecimal() '- Pagado
+
+ saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
+
+ If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("4") Then
+ saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
+ Else
+ saldo = e.Row.DataKey("SaldoConImpuestos").ToString().ToDecimal
+ End If
+
+ e.Row.FCLiteral("LtlAnticipos").Text = saldo.FormatoNumero
+
+ saldo = saldo.RoundSQL()
+
+ Dim maxsaldo As Decimal = 0
+ If total > saldo Then
+ maxsaldo = saldo
+ Else
+ maxsaldo = total
+ End If
+
+ Dim AmortizacionSujeridaContrato As Decimal = 0
+
+ e.Row.FCLiteral("MonedaVenta").Text = saldo.FormatoNumero(2)
+ e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2});", e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).ClientID, saldo, AmortizacionSujeridaContrato))
+ e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).Attributes.Add("onKeyUp", String.Format("FnCambiaAnt({0},this,{1});", e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ClientID, saldo))
+ e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).Attributes.Add("onKeyUp", String.Format("CambioTipoMoneda({0},{1},{2},{3},{4});", e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ClientID, e.Row.DataKey("Saldo"), e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).ClientID, e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).ClientID, e.Row.DataKey("CveMoneda")))
+
+ If e.Row.DataKey("CveIE").ToString().ToEntero() > 0 Then
+ e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DataKey("CveIE"), e.Row.DataKey("Folio"))
+ Else
+ e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DataKey("CveVenta"), e.Row.DataKey("Folio"))
+ End If
+
+ If e.Row.DataKey("ISTotal") = "1" Then
+ e.Row.Cells(0).Visible = False
+ e.Row.Cells(1).ColumnSpan = 3
+ e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Right
+ e.Row.FCLiteral("LtlFactura").Text = String.Format("Total {0} ", e.Row.DataKey("Tipo"))
+ e.Row.BackColor = Drawing.Color.LightGray
+ e.Row.Cells(2).Visible = False
+ e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).Visible = False
+ e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).Visible = False
+ e.Row.FCLabel("LblTotalAnticipos").Visible = True
+ e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(185) = "1" Then
+ If e.Row.DBCampo("Tipo").ToString().Contiene("Ant", "IxC") AndAlso Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then
+ e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Enabled = False
+ e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ToolTip = "Anticipo Bloqueado"
+ e.Row.FCLinkButton("LnkSolicitarActivarAnticipo").Visible = True
+ End If
+ End If
+
+ If e.Row.DBCampo("CveMoneda").ToString().ToEntero() = 1 Then
+ e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).Visible = False
+ End If
+
+ End If
+ End Sub
+
+ Protected Sub BtnAceptarAnticipos_Click(sender As Object, e As System.EventArgs) Handles BtnAceptarAnticipos.Click
+
+ If DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero() <= 0 Then
+ Alert("Debe seleccionar un tipo de amortización", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim Amortizacion As Decimal = 0
+
+ If ListaAnticiposAplicados Is Nothing Then
+ ListaAnticiposAplicados = New List(Of Modelos.MAnticipoRelacionado)
+ Else
+ ListaAnticiposAplicados.Clear()
+ End If
+
+
+ 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
+ If gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal > 0 Then
+ Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal()
+
+ If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
+ ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal")})
+ End If
+ End If
+ End If
+ Next
+
+ If Amortizacion > 0 Then
+ TxtNCDev.Text = Amortizacion.ToString()
+ LtlTipoAnticipo.Text = DdlTipoAmortizacionAnticipo.SelectedItem.Text
+ HdnTipoAmortizacion.Value = DdlTipoAmortizacionAnticipo.SelectedValue
+ Else
+ TxtNCDev.Text = ""
+ LtlTipoAnticipo.Text = ""
+ HdnTipoAmortizacion.Value = ""
+ End If
+
+ RegistraScript("$('#DivAnticipos').modal('hide');CalculaTotalPagoContado()", "AE")
+ UpL.Update()
+ End Sub
+
+ Protected Sub DdlTipoAmortizacionAnticipo_SelectedIndexChanged(sender As Object, e As EventArgs)
+ divAmortizacionTipoRelacion.Visible = DdlTipoAmortizacionAnticipo.SelectedValue = "2"
+
+ If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
+ CargaDdlNCPS()
+ DivConceptoNC.Visible = True
+ Else
+ DivConceptoNC.Visible = False
+ End If
+
+ If CveCliente <= 0 Then
+ Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero
+ Dim DbRowVenta As DataRow = Nothing
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
+ DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
+ End If
+ ObjVentas.Dispose()
+
+ If DbRowVenta IsNot Nothing Then
+ CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
+ End If
+
+ End If
+
+ If CveCliente > 0 Then
+ CargaAnticipos(CveCliente)
+ End If
+
+ UpAnticipos.Update()
+ End Sub
+
+ Public Sub CargaDdlNCPS()
+ Dim CveSATNC As String = "84111506"
+ Dim dtt As New DataTable
+ dtt = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CodigoSATPS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC
+
+ If dtt IsNot Nothing Then
+
+ DdlNCPSAnt.DataSource = dtt
+ DdlNCPSAnt.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ DdlNCPSAnt.DataBind()
+ dtt.Dispose()
+ End If
+
+ End Sub
End Class