This commit is contained in:
2024-10-22 16:10:18 -07:00
8 changed files with 1276 additions and 231 deletions

View File

@@ -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("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio))
If MostrarURL Then
MensajeAlert.AppendFormat("<br/>La {0}: <a class=""Texto"" target=""_blank"" href=""/Ventas/Ventas.aspx?CveVenta={2}""><b></b>{1}</a> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio, Me.CveVenta)
Else
MensajeAlert.AppendFormat(String.Format("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", 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("<br/>La NC <b>#{0}</b> no se pudo timbrar.</b> 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("<br/>La NC <b>#{0}</b> no se pudo timbrar.</b> 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("<br/><br/><b><a target='_blank' class='Texto' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">Movimiento de Almacén</a></b><br/>", Me.Inv_CveMovimiento)
End If
If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then
MensajeAlert.AppendFormat("<br/><br/><b> Se generó una Nota de crédito Folio: {0} amortizando el anticipo </b><br/>", FacturaDevolucion.Folio)
End If
'If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then
' MensajeAlert.AppendFormat("<br/><br/><b> Se generó una Nota de crédito Folio: {0} amortizando el anticipo </b><br/>", FacturaDevolucion.Folio)
'End If
If SeTimbro AndAlso CveFacturacionAcarreo > 0 Then
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul><br/>", 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

View File

@@ -2137,7 +2137,7 @@
<asp:UpdatePanel ID="UpTitulosAFInsumos" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table border="0" rules="none" class="table table-striped table-hover table-advance Widthall">
<%-- <table border="0" rules="none" class="table table-striped table-hover table-advance Widthall">
<tr class="Titulos TextTab">
<td style="width: 20px">#</td>
<td style="width: 60px">Cantidad</td>
@@ -2149,7 +2149,7 @@
<td style="width: 90px">Mantenimiento</td>
<td style="width: 90px">Dividir</td>
</tr>
</table>
</table>--%>
</ContentTemplate>
</asp:UpdatePanel>
@@ -2159,27 +2159,36 @@
<asp:HiddenField ID="HdnTxtAFMedida" runat="server" />
<asp:Button ID="BtnAFMedida" runat="server" Style="display: none;" OnClick="BtnAFMedida_Click" />
<asp:GridView ID="GvAFInsumos" ClientIDMode="AutoID" runat="server" DataKeyNames="Consec,CveClasificacion" ShowHeader="false" AutoGenerateColumns="False" EmptyDataText="No se encontraron Registros" CssClass="table table-striped table-hover table-advance Widthall gridconheader" RowStyle-VerticalAlign="Middle" RowStyle-HorizontalAlign="Center" GridLines="none">
<asp:GridView ID="GvAFInsumos" ClientIDMode="AutoID" runat="server" DataKeyNames="Consec,CveClasificacion" ShowHeader="true" AutoGenerateColumns="False" EmptyDataText="No se encontraron Registros" CssClass="table table-striped table-hover table-advance Widthall gridconheader" RowStyle-VerticalAlign="Middle" RowStyle-HorizontalAlign="Center" GridLines="none">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
#
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LtlConsecutivo" runat="server" Text='<%# Eval("Consec", "{0:N0}") %>' Font-Size="6pt"></asp:Label></label>
<asp:Label ID="LtlConsecutivo" runat="server" Text='<%# Eval("Consec", "{0:N0}") %>' Font-Size="6pt"></asp:Label></label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Cantidad
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlCantidad" runat="server" Text='<%# Eval("Cantidad", "{0:#,##0.00##}") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Unidad
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlUnidadMedida" runat="server" Text='<%# Eval("UM") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Left">
<HeaderTemplate>
Producto
</HeaderTemplate>
<ItemTemplate>
<div class="truncate" style="width: 200px;">
<asp:HyperLink Style="display: initial;" ID="HplPS" NavigateUrl='<%# If(CInt(Eval("CvePS").ToString) > 0, String.Format("/Ventas/ProductosServicios.aspx?CvePS={0}&Ret=Comp&Popup=1&TB_iframe=true&height=500&width=950&Ret=Comp", Eval("CvePS")), "")%>' CssClass='<%# If(CInt(Eval("CvePS").ToString) > 0, "Texto thickbox", "") %>' runat="server" Text='<%# Eval("PS") %>'></asp:HyperLink>
@@ -2187,6 +2196,9 @@
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Left">
<HeaderTemplate>
Observación
</HeaderTemplate>
<ItemTemplate>
<div class="truncate" style="width: 200px;">
<asp:Literal ID="LtlObservacion" runat="server" Text='<%# Eval("Obs") %>'></asp:Literal>
@@ -2194,6 +2206,9 @@
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Vinculación
</HeaderTemplate>
<ItemTemplate>
<asp:Label runat="server" Visible="false" ID="LbCveAF" Text='<%# Eval("CodAF")%>'></asp:Label>
<asp:TextBox ID="LblCodigo" Text='<%# Eval("CodAF")%>' runat="server" Width="80px" Visible="true"></asp:TextBox>
@@ -2207,11 +2222,17 @@
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="100px">
<HeaderTemplate>
Horómetro /<br> Odómetro
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TxtAFMedida" runat="server" Width="60px" Text='<%# Eval("AFMedida")%>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Left">
<HeaderTemplate>
Mantenimiento
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="DdlTipoMantemiento" runat="server" CssClass="form-control select2me" Width="100px" AutoPostBack="true" OnSelectedIndexChanged="DdlTipoMantemiento_SelectedIndexChanged">
<asp:ListItem Selected="True" Text="-" Value="-1"></asp:ListItem>
@@ -2221,6 +2242,9 @@
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="80px">
<HeaderTemplate>
Dividir
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox runat="server" ID="TxtDividir" Width="30px"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="SoloNumeros2" runat="server" TargetControlID="TxtDividir" FilterType="Custom, Numbers" ValidChars="." />

View File

@@ -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

View File

@@ -195,6 +195,7 @@
<asp:ListItem Text="No" Value="0" Selected="True"></asp:ListItem>
<asp:ListItem Text="Si (Origen)" Value="1"></asp:ListItem>
<asp:ListItem Text="Si (Destino)" Value="2"></asp:ListItem>
<asp:ListItem Text="Separado(Destino)" Value="3" />
</asp:DropDownList>
<%--<asp:CheckBox ID="ChkIncluyeTransitorios" runat="server" Checked="false" />--%>
</div>
@@ -228,11 +229,11 @@
</div>
<asp:Label runat="server" ID="LblProyectado" Text="Incluir Proyectados" class="col-md-1 truncate" />
<div class="col-md-2">
<asp:DropDownList ID="DdlProyeccionFiltro" runat="server" CssClass="select2me" Width="100%" >
<asp:ListItem Text="Todos (Entradas/Salidas)" Value="3" />
<asp:DropDownList ID="DdlProyeccionFiltro" runat="server" CssClass="select2me" Width="100%" >
<asp:ListItem Text="Todos (Entradas/Salidas)" Value="3" />
<asp:ListItem Text="Entradas" Value="1" />
<asp:ListItem Text="Salidas" Value="2" />
<asp:ListItem Text="No" Value="0" Selected="True" />
<asp:ListItem Text="No" Value="0" Selected="True" />
</asp:DropDownList>
</div>
</asp:Panel>

View File

@@ -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

View File

@@ -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("</div>")
SBBody.Append("<div>")
SBBody.Append("<div class='col1'> Acceso </div>")
SBBody.AppendFormat("<div class='col2'><a href='{0}login.aspx'>sig.adssistemas.mx</a></div>", UrlSitio)
SBBody.AppendFormat("<div class='col2'><a href='{0}login.aspx'>{1}</a></div>", UrlsitioUrlActual, Solicitud.Url.Host)
SBBody.Append("</div>")
SBBody.Append("</div>")
SBBody.Append("</div>")
@@ -1447,7 +1453,7 @@ Partial Class Sistemas_UsuarioDetalle
SBBody.Append("<div Class='nota'>")
SBBody.Append("Nota Favor de NO responder este correo. ")
SBBody.Append("</div><br/><br/>")
SBBody.AppendFormat("<div class='logo'><img src='{0}Imagenes/LogoSinFondo.png' style='width:30px;'/>ADSistemas </div>", UrlSitio)
SBBody.AppendFormat("<div class='logo'><img src='{0}Imagenes/LogoSinFondo.png' style='width:30px;'/>ADSistemas </div>", UrlsitioUrlActual)
SBBody.Append("</div>")
SBBody.Append("</div>")
'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

View File

@@ -411,6 +411,10 @@
<div class="col-md-1" style="text-align: right;">
<asp:LinkButton ID="LnkLiberar" runat="server" CssClass="btn btn-xs btn-success" Text="Liberar" OnClick="LnkLiberar_Click" />
</div>
<div class="col-md-1" style="text-align: right;">
<asp:LinkButton ID="ImgAntiPend" Visible="false" OnClick="ImgAntiPend_Click" runat="server" Text=" <i class='fa fa-money'></i> " AlternateText="Aplicación de anticipos" Style="cursor: pointer;" />
</div>
</div>
</div>
@@ -524,6 +528,24 @@
</div>
</div>
<div class="chequesie1" id="DivAnticipo" runat="server" visible="false">
<div class="row">
<div class="col-md-2">
<label>Anticipos.:</label>
</div>
<div class="col-md-4 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtNCDev" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" Enabled="false" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FTEAnticipo" runat="server" TargetControlID="TxtNCDev" FilterType="Custom, Numbers" ValidChars=".," />
</div>
<div class="col-md-6">
<label>
<asp:Literal ID="LtlTipoAnticipo" runat="server"></asp:Literal></label>
<asp:HiddenField ID="HdnTipoAmortizacion" runat="server" Value="" />
</div>
</div>
</div>
<div class="chequesie1" runat="server" id="DivContadoOtros" visible="false">
<div class="row">
@@ -563,21 +585,21 @@
<div class="chequesie2">
<div class="row">
<label class="col-md-2">Total:</label>
<label class="col-md-1">Total:</label>
<div class="col-md-3 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtImporteContado" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" ReadOnly="true" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="TxtImporteContado" FilterType="Custom, Numbers" ValidChars=".," />
</div>
<label id="lblCambio" class="col-md-2">Cambio:</label>
<label id="lblCambio" class="col-md-1">Cambio:</label>
<div class="col-md-3 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtCambio" CssClass="form-control input-sm " Enabled="false" runat="server" MaxLength="12" Width="100px" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FTBECambio" runat="server" TargetControlID="TxtCambio" FilterType="Custom, Numbers" ValidChars=".," />
<br />
</div>
<label id="lblCambio2" class="col-md-2">Sob/falt:</label>
<label id="lblCambio2" class="col-md-1">Sob/falt:</label>
<div class="col-md-3 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtFaltante" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
@@ -1008,7 +1030,6 @@
<asp:UpdatePanel class="modal-dialog" runat="server" ID="UpModalPago" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content">
<div class="modal-header ">
<h4 class="modal-title">
@@ -1016,9 +1037,6 @@
</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="form-group col-md-12 form-md-line-input">
<asp:DropDownList ID="DdlTipoTransaccion" CssClass="form-control input-sm select2me" ClientIDMode="Static" runat="server" DataTextField="TipoTransaccion" DataValueField="CveTipoTransaccion" ValidationGroup="GrpGuardarPago" Width="100%">
@@ -1093,6 +1111,162 @@
</asp:UpdatePanel>
</div>
<div id="DivAnticipos" class="modal ADS fade" role="dialog">
<asp:UpdatePanel runat="server" ID="UpAnticipos" UpdateMode="Conditional" RenderMode="Inline">
<ContentTemplate>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header ">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">
<asp:Label runat="server">Anticipos/NC del Cliente:&nbsp;<asp:Literal ID="LtlCliente" runat="server"></asp:Literal></asp:Label>
</h4>
</div>
<div class="modal-body">
<div class="row" runat="server" id="divAmortizacionTipo" visible="false">
<div class="col-md-4">
Tipo Amortización:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlTipoAmortizacionAnticipo" runat="server" AutoPostBack="true" Width="250px" CssClass="select2me" CausesValidation="true" OnSelectedIndexChanged="DdlTipoAmortizacionAnticipo_SelectedIndexChanged">
<asp:ListItem Text="Seleccionar" Value="-1"></asp:ListItem>
<asp:ListItem Text="Amortización anticipo con nota de crédito" Value="2"></asp:ListItem>
</asp:DropDownList>
</div>
<asp:RequiredFieldValidator ID="RfvDdlTipoAmortizacionAnticipo" runat="server" Display="None" ControlToValidate="DdlTipoAmortizacionAnticipo" InitialValue="-1" ErrorMessage="Debe Seleccionarse un tipo" ValidationGroup="VGAnticiposClientes"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="CEDdlTipoAmortizacionAnticipo" runat="server" HighlightCssClass="vco" TargetControlID="RfvDdlTipoAmortizacionAnticipo" Width="300px"></ajax:ValidatorCalloutExtender>
<div class="row" style="text-align: center;" runat="server" id="divAnticipoMsg" visible="false">
<asp:Label ID="Label2" runat="server" Text="Se aplicará descuento por el total de las amortizaciones en los productos" CssClass="alert alert-warning" Style="padding: 5px; margin-bottom: 5px; padding-right: 25px;"></asp:Label>
</div>
</div>
<div class="row" id="divAmortizacionTipoRelacion" runat="server" visible="false">
<div class="col-md-4">
Tipo Relación:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlTipoRelacionAnticipo" runat="server" Width="250px" CssClass="select2me">
<asp:ListItem Text="07 - CFDI por aplicación de anticipo" Value="7"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="row" id="DivConceptoNC" runat="server" visible="false">
<div class="col-md-4">
Concepto:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlNCPSAnt" runat="server" DataTextField="PSCodigo" DataValueField="CvePS" Width="250px" CssClass="select2me"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVNCPSAnt" runat="server" InitialValue="-1" ControlToValidate="DdlNCPSAnt" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Concepto''</b> es necesario, por favor ingréselo." ValidationGroup="VGAnticiposClientes"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCERFVNCPSAnt" runat="server" HighlightCssClass="vco" TargetControlID="RFVNCPSAnt" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row" id="DivFechaAnticipoCliente" runat="server" visible="false">
<b>
<label class="col-md-2">Fecha:</label></b>
<div class="col-md-4">
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 80% !important; padding: 0px;">
<asp:TextBox ID="TxtFechaAnticipoCliente" runat="server" ClientIDMode="Static" CssClass="form-control" CausesValidation="true" MaxLength="10" AutoPostBack="true" OnTextChanged="TxtFechaAnticipoCliente_TextChanged"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="ImgFechaAnticipoCliente" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MEEFechaAnticipoCliente" runat="server" TargetControlID="TxtFechaAnticipoCliente" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CEFechaAnticipoCliente" TargetControlID="TxtFechaAnticipoCliente" PopupButtonID="ImgFechaAnticipoCliente" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:CompareValidator ID="CvFechaAnticipoCliente" runat="server" ControlToValidate="TxtFechaAnticipoCliente" Display="None" Operator="DataTypeCheck" Type="Date" ValidationGroup="VGAnticiposClientes" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Fecha''</b> no tiene el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)."></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VcoFechaAnticipoCliente" runat="server" Enabled="True" HighlightCssClass="vco" TargetControlID="CvFechaAnticipoCliente" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
</div>
</div>
<br />
<div style="max-height: 300px; overflow-y: auto;">
<div class="row" style="margin-left: 0px; text-align: right" align="left">
<div class="col-md-2">
<asp:LinkButton ID="LnkRecargaAnticipos" NavigateUrl="#" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-refresh'></i> Actualizar" runat="server" OnClick="LnkRecargaAnticipos_Click" />
</div>
<div style="margin-right: 15px">
<input type="text" id="TxtBusquedaAnticipos" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusquedaAnticipos','{0}')", GVAnticipos.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaAnticipos','{0}')", GVAnticipos.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
</div>
<br />
<asp:GridView ID="GVAnticipos" runat="server" AutoGenerateColumns="False" ClientIDMode="Static" EmptyDataText="No se encontraron Anticipos del Cliente"
ToolTip="Listado de Anticipos" CssClass="GVAnticipos table table-striped table-hover Widthall mysmallbtn" data-height="300" Style="text-align: center;" GridLines="None"
DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="Chk" runat="server" />
<asp:LinkButton ID="LnkSolicitarActivarAnticipo" Visible="false" NavigateUrl="#" CssClass="btn btn-circle btn-sm blue" Text="<i class='fa fa-check'></i>" ToolTip="Solicitar activar anticipo" runat="server" OnClick="LnkSolicitarActivarAnticipo_Click" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Folio</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlFactura" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Fecha</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha", "{0:d}") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Saldo</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlAnticipos" runat="server" Text='<%# Eval("Saldo", "{0:N2}") %>'></asp:Literal>&nbsp;
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<HeaderTemplate>Moneda Venta</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="MonedaVenta" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Moneda</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlAbreviatura" runat="server" Text='<%# Eval("Abreviatura") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<HeaderTemplate>Atención A</HeaderTemplate>
<ItemTemplate>
<asp:Literal runat="server" Text='<%# Eval("AtencionA") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Amort. Ant.</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LblTotalAnticipos" runat="server" ClientIDMode="Static" Text="0.00" Visible="false"></asp:Label>
<asp:TextBox ID="TxtAnticipo" CssClass="CSGATxtAnticipo" runat="server" CausesValidation="true" MaxLength="12" Width="76px"></asp:TextBox>
<asp:CompareValidator ID="CVAmortAnti" runat="server" ControlToValidate="TxtAnticipo" Display="None" ErrorMessage="El campo <b>''Amortización de Anticipos''</b> no tiene el formato correcto, por favor corrija e intente de nuevo (Solo formato numérico)." Operator="DataTypeCheck" Type="Currency" ValidationGroup="VGAnticiposClientes"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VCOAmortAnti" runat="server" HighlightCssClass="vco" TargetControlID="CVAmortAnti" Width="300px"></ajax:ValidatorCalloutExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="T.C." Visible="false">
<ItemTemplate>
<asp:TextBox ID="TxtTC" runat="server" Width="50px" Enabled="false"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="BtnAceptarAnticipos" runat="server" Text="Aceptar" class="btn btn-primary" ValidationGroup="VGAnticiposClientes" />
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
@@ -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));
}

View File

@@ -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<br/> ")
End If
End If
'If respFactura IsNot Nothing Then
' If Not respFactura.Factura.TimbrarFactura() Then
' msBuild.Append("La factura no se pudo timbrar<br/> ")
' End If
'End If
If respFactura IsNot Nothing Then
msBuild.Append($"Pago Registrado correctamente.")
For Each m In respFactura.Mensajes
msBuild.AppendFormat("<br/> {0}", m)
Next
If respNC IsNot Nothing Then
For Each m In respNC.Mensajes
msBuild.AppendFormat("<br/> {0}", m)
Next
End If
Else
msBuild.Append($"Pago Registrado correctamente.<br/><br/> <a href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&TICKET=1&REGENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>")
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} <br/>", 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} <br/>", msg)
Next
SbAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF Factura</a></li></ul><br/>", 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} <br/><a href='/Ventas/Clientes.aspx?CveCliente={CveCliente}&op=ant'>Ir Activar</a>", 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("<a class=""Texto"" href=""/Bancos/IE.aspx?CveIE={0}"">{1}</a>", e.Row.DataKey("CveIE"), e.Row.DataKey("Folio"))
Else
e.Row.FCLiteral("LtlFactura").Text = String.Format("<a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">{1}</a>", 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