Impuestos en remisiones de NC, validacion de cotizaciones

This commit is contained in:
2020-11-06 20:02:12 -07:00
parent 7bf581ec2d
commit d49ea482d8
4 changed files with 718 additions and 371 deletions

View File

@@ -551,6 +551,8 @@ Namespace Modelos
Public Property SeTimbro As Boolean Public Property SeTimbro As Boolean
Public Property SeTimbroNotaCredito As Boolean Public Property SeTimbroNotaCredito As Boolean
Public Property CveEstatus As Integer Public Property CveEstatus As Integer
Public Property CveMovimientoUsado As Integer
Public Property FolioUsado As String
End Class End Class
Public Function RegenerarPrePolizas(Optional TransaccionCompartida As SqlClient.SqlTransaction = Nothing, Optional ObjACTransac As ClsContPAQi = Nothing) As Boolean Public Function RegenerarPrePolizas(Optional TransaccionCompartida As SqlClient.SqlTransaction = Nothing, Optional ObjACTransac As ClsContPAQi = Nothing) As Boolean
@@ -707,7 +709,7 @@ Namespace Modelos
Next Next
End If End If
GuardarVenta(Me, ObjVentas, ObjConta, ObjInventario, ObjContr, DtDetalle, Me.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS, ObjEventos, ObjCGame, ObjClientes, ObjAcum:=ObjAcum) GuardarVenta(Me, ObjVentas, ObjConta, ObjInventario, ObjContr, DtDetalle, Me.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS, ObjEventos, ObjCGame, ObjClientes, ObjAcum:=ObjAcum, Resp:=Retorno)
'SI ES REFACTURACION 'SI ES REFACTURACION
Dim ObjNC As List(Of Object) = Nothing Dim ObjNC As List(Of Object) = Nothing
@@ -1341,7 +1343,7 @@ Namespace Modelos
End If End If
End Sub End Sub
Public Sub GuardarVenta(ByRef factura As Modelos.Factura, ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, ByRef TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNotaCredito As Boolean = False, Optional ObjAcum As ClsAcumuladores = Nothing) Public Sub GuardarVenta(ByRef factura As Modelos.Factura, ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, ByRef TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNotaCredito As Boolean = False, Optional ObjAcum As ClsAcumuladores = Nothing, ByRef Optional Resp As MMensajeFactura = Nothing)
Dim Msgok As New StringBuilder Dim Msgok As New StringBuilder
factura.CvePrePoliza = ObjConta.AddPrePolizas("Modelos/GuardarVentaM", factura.CvePlantillaPoliza, factura.TotalTC, factura.TotalTC, factura.CveMoneda, factura.Fecha, If(factura.CveEmpresaCRM > 0, factura.EmpresaCRM, factura.Cliente.Nombre), factura.CveUsuario, factura.CveEmpresa) factura.CvePrePoliza = ObjConta.AddPrePolizas("Modelos/GuardarVentaM", factura.CvePlantillaPoliza, factura.TotalTC, factura.TotalTC, factura.CveMoneda, factura.Fecha, If(factura.CveEmpresaCRM > 0, factura.EmpresaCRM, factura.Cliente.Nombre), factura.CveUsuario, factura.CveEmpresa)
@@ -1375,11 +1377,6 @@ Namespace Modelos
factura.Timbre.Comprobante.Serie = ObjVentas.Serie factura.Timbre.Comprobante.Serie = ObjVentas.Serie
factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString
If Not GuardarUsados(ObjVentas.IniciaTransacSQL, ObjVentas, factura) Then
ErrorList.Add("Error al guardar usados")
End If
If factura.TipoDocto = "Egs" AndAlso NuevaFactura = 1 Then If factura.TipoDocto = "Egs" AndAlso NuevaFactura = 1 Then
If DtVentasNC Is Nothing Then If DtVentasNC Is Nothing Then
InicializaDTVentasNC() InicializaDTVentasNC()
@@ -1452,6 +1449,11 @@ Namespace Modelos
End If End If
Next Next
'GUARDAR USADOS
If Not GuardarUsados(ObjAcum, ObjVentas, ObjInventario, factura, Resp) Then
ErrorList.Add("Error al guardar usados")
End If
'BONIFICACION USADOS 'BONIFICACION USADOS
If UsadosBonificacion IsNot Nothing AndAlso UsadosBonificacion.Count > 0 AndAlso TipoBonificacion > 0 Then If UsadosBonificacion IsNot Nothing AndAlso UsadosBonificacion.Count > 0 AndAlso TipoBonificacion > 0 Then
For Each CveMovto In UsadosBonificacion For Each CveMovto In UsadosBonificacion
@@ -1627,10 +1629,10 @@ Namespace Modelos
If ErrorList.Count = 0 Then If ErrorList.Count = 0 Then
'prepoliza 'prepoliza
GuardarVentaPrePolizas(factura, ObjConta, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos) GuardarVentaPrePolizas(factura, ObjConta, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, ObjInventario:=ObjInventario)
If ErrorList.Count = 0 Then If ErrorList.Count = 0 Then
'inventarios 'inventarios
GuardarVentaInventarios(factura, ObjInventario, ObjConta) GuardarVentaInventarios(factura, ObjInventario, ObjConta, ObjVentas, ObjAcum)
'GuardaRecepcionUsados(factura, ObjInventario, ObjConta) 'GuardaRecepcionUsados(factura, ObjInventario, ObjConta)
@@ -1910,7 +1912,7 @@ Namespace Modelos
DtVentasNC.Rows.Add(Dr) DtVentasNC.Rows.Add(Dr)
End If End If
End Sub End Sub
Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, ByRef ObjVentas As ClsVentas, factura As Modelos.Factura) As Boolean Private Function GuardarUsados(ByRef ObjAcum As ClsAcumuladores, ByRef ObjVentas As ClsVentas, ByRef ObjInventario As ClsInventarios, factura As Modelos.Factura, ByRef Optional Resp As MMensajeFactura = Nothing) As Boolean
Dim Resultado As Boolean = True Dim Resultado As Boolean = True
If UsuarioActual.Empresa.Funcionalidad(533).ToEntero > 0 AndAlso factura.TipoDocto.Contiene("Ing", "Rem") Then If UsuarioActual.Empresa.Funcionalidad(533).ToEntero > 0 AndAlso factura.TipoDocto.Contiene("Ing", "Rem") Then
@@ -1918,8 +1920,6 @@ Namespace Modelos
If factura.TipoDocto = "Ing" AndAlso factura.Cliente.EsDistribuidor Then If factura.TipoDocto = "Ing" AndAlso factura.Cliente.EsDistribuidor Then
Dim CvePSPSA As Integer = UsuarioActual.Empresa.Funcionalidad(533).ToEntero Dim CvePSPSA As Integer = UsuarioActual.Empresa.Funcionalidad(533).ToEntero
Dim ObjAcum As New ClsAcumuladores(SqlTransaccion)
For Each drow As DataRow In factura.DtDetalle.Rows For Each drow As DataRow In factura.DtDetalle.Rows
If drow("CveTamaño").ToString.ToEntero > 0 And (CvePSPSA <> drow("CvePS").ToString.ToEntero) Then If drow("CveTamaño").ToString.ToEntero > 0 And (CvePSPSA <> drow("CvePS").ToString.ToEntero) Then
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToEntero, drow("CveTamaño").ToString.ToEntero, 2, factura.CveVenta, UsuarioActual.CveUsuario, If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToEntero, drow("CveTamaño").ToString.ToEntero, 2, factura.CveVenta, UsuarioActual.CveUsuario,
@@ -1944,6 +1944,64 @@ Namespace Modelos
End If End If
End If End If
'SI ES UNA RNC DE CARGO GENERA EL MOVIMIENTO DE ALMACEN AQUI
If factura.TipoDocto = "RNC" AndAlso factura.Num1 = 1 AndAlso factura.DtMovimientosUsados IsNot Nothing AndAlso ObjAcum IsNot Nothing Then
'Dim Mensaje As String = ""
Dim CveMovimiento = ObjInventario.AddMovimiento(factura.CveAlmacen, factura.CveConceptoMovimiento, 1, factura.Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, factura.CveVenta,
CveSubProyecto, CveActivoFijo:=-1, Guia:="", Observaciones:=factura.ObservacionesMovimiento, CvePersonal:=-1, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, Modulo:="RU/G")
If CveMovimiento <= 0 Then
'Mensaje = "Error al guardar los movimientos"
Resultado = False
Else
For Each Dr As DataRow In factura.DtMovimientosUsados.Rows
Dim ImporteConcepto As Decimal = 0
If factura.CveConceptoMovimiento = 42 AndAlso factura.CveMoneda = 2 Then
ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(factura.Fecha).ToDecimal
Else
ImporteConcepto = Dr("PU").ToString.ToDecimal
End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
'Mensaje = "Error al guardar los movimientos"
Resultado = False
Exit For
End If
If CveVenta > 0 AndAlso Not ObjVentas.UpdateVentaUsadoRecibido(CveVenta, Dr("CvePS").ToString.ToEntero, True, CveMovimiento) Then
'Mensaje = "Error al actualizar el recibo de los usados"
Resultado = False
Exit For
End If
'si es selectedvalue = 42, es entrada ,3 -salida
Dim CveConceptoUsados As Integer = If(factura.CveConceptoMovimiento = 42, 1, 2)
If factura.Cliente.EsDistribuidor AndAlso factura.CveConceptoMovimiento = 42 AndAlso Dr("CveTamaño").ToString.ToEntero > 0 Then
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, CveVenta, UsuarioActual.CveUsuario,
UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then
' Mensaje = "Error al guardar Movimientos de distribuidor"
Resultado = False
Exit For
End If
End If
Next
End If
Resp.CveMovimientoUsado = CveMovimiento
If CveMovimiento > 0 Then
If ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) Then
Resp.FolioUsado = ObjInventario.DtResultados.FiltroPrimeroValor("Folio")
End If
End If
End If
Return Resultado Return Resultado
End Function End Function
@@ -1968,7 +2026,7 @@ Namespace Modelos
Return Resultado Return Resultado
End Function End Function
Private Sub GuardarVentaPrePolizas(ByRef factura As Modelos.Factura, ByRef ObjConta As ClsContabilidad, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing) Private Sub GuardarVentaPrePolizas(ByRef factura As Modelos.Factura, ByRef ObjConta As ClsContabilidad, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjInventario As ClsInventarios = Nothing)
Dim CveIE As Integer = -1 Dim CveIE As Integer = -1
Dim DT As DataTable = Nothing Dim DT As DataTable = Nothing
@@ -1986,7 +2044,7 @@ Namespace Modelos
'P R E P O L I Z A S 'P R E P O L I Z A S
If Me.TipoDocto <> "Cot" Then If Me.TipoDocto <> "Cot" Then
If Me.CvePrePoliza > 0 Then If Me.CvePrePoliza > 0 Then
If ProcesoPrepolizas(factura, ObjConta, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos) Then If ProcesoPrepolizas(factura, ObjConta, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, ObjInventario:=ObjInventario) Then
ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico") ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
End If End If
Else Else
@@ -1997,7 +2055,7 @@ Namespace Modelos
Private Function ProcesoPrepolizas(ObjFactura As Factura, ByRef ObjConta As ClsContabilidad, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi, Private Function ProcesoPrepolizas(ObjFactura As Factura, ByRef ObjConta As ClsContabilidad, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi,
Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing,
Optional ByRef DtRemisionesRelacionadas As DataTable = Nothing, Optional SeCancelaRemisionProceso As Boolean = False, Optional CancelarRemisiones As Boolean = False, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing, Optional ByRef DtRemisionesRelacionadas As DataTable = Nothing, Optional SeCancelaRemisionProceso As Boolean = False, Optional CancelarRemisiones As Boolean = False, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing,
Optional CveEstatusRefacturacion As Integer = 0) As Boolean Optional CveEstatusRefacturacion As Integer = 0, Optional ByRef ObjInventario As ClsInventarios = Nothing) As Boolean
Dim ErrorPrepoliza As Boolean = False Dim ErrorPrepoliza As Boolean = False
Try Try
Dim DT As DataTable Dim DT As DataTable
@@ -2177,6 +2235,41 @@ Namespace Modelos
IdCtaContableCliente = IdCtaContable IdCtaContableCliente = IdCtaContable
CveCuentaCliente = CveCuenta CveCuentaCliente = CveCuenta
Dim CveMovimiento As Integer = -1
Dim CveAlmacen As Integer = -1
If ObjInventario IsNot Nothing AndAlso ObjInventario.GetInv_Mov(ObjFactura.CveVenta, UsuarioActual.CveEmpresa) Then
CveMovimiento = ObjInventario.DtResultados.FiltroPrimeroValor("CveMovimiento", "CvePS IS NULL AND CveConcepto = 42").ToEntero()
CveAlmacen = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen", "CvePS IS NULL AND CveConcepto = 42").ToEntero()
End If
'VERIFICA SI TIENE MOVIMIENTO DE ENTRADA DE USADO
If CveMovimiento > 0 AndAlso CveAlmacen > 0 Then
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
Dim Importe68 As Decimal = ObjInventario.DtResultados.SUMD("Total").RoundSQL
Dim IdCtaContable68 = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={CveAlmacen}").ToEntero
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, Importe68, Referencia, 68, Concepto, FechaMovimiento, IdCtaContable68, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=Importe68, Contabilizable:=False) Then
ErrorPrepoliza = True
End If
Dim Importe318 As Decimal = importeMovimiento - Importe68
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, Importe318, Referencia, 318, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=Importe318, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
End If
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
End If
Else
ErrorPrepoliza = True
End If
Else
If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 278, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 278, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True ErrorPrepoliza = True
@@ -2184,6 +2277,7 @@ Namespace Modelos
Else Else
ErrorPrepoliza = True ErrorPrepoliza = True
End If End If
End If
importeMovimiento = 0 importeMovimiento = 0
ObjFactura.SeGuardoPrePoliza = True ObjFactura.SeGuardoPrePoliza = True
@@ -3487,7 +3581,7 @@ Namespace Modelos
Return OcurrioError Return OcurrioError
End Function End Function
Private Function GuardarVentaInventarios(ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad) As Boolean Private Function GuardarVentaInventarios(ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, ObjVentas As ClsVentas, ObjAcum As ClsAcumuladores) As Boolean
Dim OcurrioError As Boolean = False Dim OcurrioError As Boolean = False
If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then
@@ -4311,7 +4405,7 @@ Namespace Modelos
If CveEstatusFacturaAsignado <= 0 Then If CveEstatusFacturaAsignado <= 0 Then
Try Try
If ObjFactura.FolioFiscal <> "" Then If ObjFactura.FolioFiscal <> "" Then
If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Dev", "Egs", "RNC") Then If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Dev", "Egs") Then
Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), UsuarioActual.Empresa.FacturaProduccion) Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), UsuarioActual.Empresa.FacturaProduccion)
@@ -4891,6 +4985,8 @@ Namespace Modelos
CveEstatus = 12 CveEstatus = 12
Case "Com" Case "Com"
CveEstatus = 9 CveEstatus = 9
Case "Cot"
CveEstatus = 10
Case "Ped", "DPe" Case "Ped", "DPe"
CveEstatus = 14 CveEstatus = 14
End Select End Select
@@ -5591,6 +5687,7 @@ Namespace Modelos
Public Property FacturaMateriales As Integer Public Property FacturaMateriales As Integer
Public Property TipoDescuento As Integer Public Property TipoDescuento As Integer
Public Property SubProyectoPorcentajeIVA As Double Public Property SubProyectoPorcentajeIVA As Double
Public Property PorcentajeIVA As Double
Public Property CveAlmacenOrigenContrato As Integer Public Property CveAlmacenOrigenContrato As Integer
Public Property CveDevolucion As Integer Public Property CveDevolucion As Integer
Public Property TotalOtrosConceptos As Decimal Public Property TotalOtrosConceptos As Decimal
@@ -5604,6 +5701,9 @@ Namespace Modelos
Public Property CveAnticipo As Integer Public Property CveAnticipo As Integer
Public Property RemisionesLista As List(Of Integer) Public Property RemisionesLista As List(Of Integer)
Public Property CveAlmacen As Integer Public Property CveAlmacen As Integer
Public Property CveConceptoMovimiento As Integer
Public Property ObservacionesMovimiento As String
Public Property DtMovimientosUsados As DataTable
Public Property CveAlmacenDevolucion As Integer Public Property CveAlmacenDevolucion As Integer
Public Property CveVenta As Integer Public Property CveVenta As Integer
Public Property CveEmpresa As Integer Public Property CveEmpresa As Integer
@@ -5982,15 +6082,17 @@ Namespace Modelos
Public Property FemsaFactura As Modelos.FemsaFactura Public Property FemsaFactura As Modelos.FemsaFactura
Public Sub SetSubProyecto() Public Sub SetSubProyecto()
If CveSubProyecto > 0 Then If CveSubProyecto > 0 AndAlso UsuarioActual IsNot Nothing Then
SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}")) SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
End If End If
End Sub End Sub
Public Sub SetSubProyectoMatriz() Public Sub SetSubProyectoMatriz()
If UsuarioActual IsNot Nothing Then
Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1") Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1")
If Not IsNothing(Row) Then If Not IsNothing(Row) Then
SubProyectoMatriz = New Modelos.SubProyectoModel(Row) SubProyectoMatriz = New Modelos.SubProyectoModel(Row)
End If End If
End If
End Sub End Sub
Public Sub SetCliente() Public Sub SetCliente()
If CveCliente > 0 Then If CveCliente > 0 Then
@@ -6033,7 +6135,7 @@ Namespace Modelos
End Sub End Sub
Public Sub SetSubProyecto(obj As ClsPaginas) Public Sub SetSubProyecto(obj As ClsPaginas)
If CveSubProyecto > 0 AndAlso Not IsNothing(obj) Then If CveSubProyecto > 0 AndAlso Not IsNothing(obj) Then
SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}")) SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveEmpresa:=obj.UsuarioActual.CveEmpresa).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
End If End If
End Sub End Sub
Public Sub SetSubProyectoMatriz(obj As ClsPaginas) Public Sub SetSubProyectoMatriz(obj As ClsPaginas)

View File

@@ -1052,10 +1052,11 @@ Partial Class Inventarios_RecepcionUsados
Protected Sub Guardar(Optional GenerarRNC As Boolean = False) Protected Sub Guardar(Optional GenerarRNC As Boolean = False)
If GvM.Rows.Count > 0 Then If GvM.Rows.Count > 0 Then
Dim Msg As New StringBuilder() Dim Msg As New StringBuilder()
Dim Resp As Modelos.Factura.MMensajeFactura = Nothing
Dim ObjInventario As New ClsInventarios Dim ObjInventario As New ClsInventarios
Dim ObjAcum As New ClsAcumuladores(ObjInventario.IniciaTransacSQL()) Dim ObjAcum As New ClsAcumuladores(ObjInventario.IniciaTransacSQL())
Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL()) Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL())
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
Dim ErrorMovInv As Boolean = False Dim ErrorMovInv As Boolean = False
Dim ErrorAC As Boolean = False Dim ErrorAC As Boolean = False
@@ -1089,31 +1090,38 @@ Partial Class Inventarios_RecepcionUsados
CveVenta = -1 CveVenta = -1
End If End If
If Not ErrorMovInv AndAlso GenerarRNC AndAlso ObjRemisionNC IsNot Nothing Then If Not ErrorMovInv AndAlso GenerarRNC AndAlso ObjRemisionNC IsNot Nothing Then
CargaDTDetalleRNC() CargaDTDetalleRNC()
Dim Resp = ObjRemisionNC.EmitirFactura(False, ObjInventario.IniciaTransacSQL) Resp = ObjRemisionNC.EmitirFactura(False, ObjInventario.IniciaTransacSQL)
For Each mensaje2 As String In Resp.Mensajes 'For Each mensaje2 As String In Resp.Mensajes
Msg.AppendFormat("<br>{0}", mensaje2) ' Msg.AppendFormat("<br>{0}", mensaje2)
Next 'Next
If Resp.TieneError Then ErrorMovInv = True If Resp.TieneError Then ErrorMovInv = True
Alert(Msg.ToString, If(Resp.CveVenta > 0, TipoMensaje.MsgInformacion, TipoMensaje.MsgAdvertencia)) 'Alert(Msg.ToString, If(Resp.CveVenta > 0, TipoMensaje.MsgInformacion, TipoMensaje.MsgAdvertencia))
CveVenta = Resp.CveVenta CveVenta = Resp.CveVenta
End If End If
Dim Mensaje As String = ""
Dim FolioInv As String = ""
If GenerarRNC Then
CveMovimiento = Resp.CveMovimientoUsado
FolioInv = Resp.FolioUsado
Else
CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, CveConcepto, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, CveConcepto, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta,
CveSubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero, CveSubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero,
Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text, Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text,
PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor, Modulo:="RU/G") PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor, Modulo:="RU/G")
If CveMovimiento <= 0 Then If CveMovimiento <= 0 Then
Alert("No se pudo almacenar el movimiento correctamente", TipoMensaje.MsgError) Mensaje = "Error al guardar los movimientos"
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") ErrorMovInv = True
ObjInventario.RollBack() 'deshace lo insertado
Else Else
Dim Mensaje As String = "" FolioInv = ObjInventario.Folio.ToString()
For Each Dr As DataRow In DtMovimientos.Rows For Each Dr As DataRow In DtMovimientos.Rows
@@ -1134,6 +1142,7 @@ Partial Class Inventarios_RecepcionUsados
ErrorMovInv = True ErrorMovInv = True
Exit For Exit For
End If End If
'si es selectedvalue = 42, es entrada ,3 -salida 'si es selectedvalue = 42, es entrada ,3 -salida
Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 42, 1, 2) Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 42, 1, 2)
@@ -1149,10 +1158,27 @@ Partial Class Inventarios_RecepcionUsados
End If End If
Next Next
'GENERA LA PREPOLIZA DE ALMACEN VS EL CONCEPTO DE RNC
'If Not ErrorMovInv Then
' ErrorMovInv = Not GeneraPrePoliza(CveMovimiento, ObjInventario, ObjConta, True)
'End If
End If
End If
If Not ErrorMovInv Then
If Resp IsNot Nothing Then
For Each mensaje2 As String In Resp.Mensajes
Msg.AppendFormat("<br>{0}", mensaje2)
Next
End If
End If
If Not ErrorMovInv Then If Not ErrorMovInv Then
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b><a href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}' target='_blank'>{0}</a></b>", FolioInv, CveMovimiento)
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b><a href='Inventarios/EntradasSalidas.aspx?CveMovimiento={1}'>{0}</a></b>", ObjInventario.Folio, CveMovimiento)
Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
If IDPoliza > 0 Then Msg = Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza) If IDPoliza > 0 Then Msg = Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza)
@@ -1174,8 +1200,6 @@ Partial Class Inventarios_RecepcionUsados
CveMovimiento = 0 CveMovimiento = 0
Alert("ocurrió un Error al registrar los movimientos", TipoMensaje.MsgError) Alert("ocurrió un Error al registrar los movimientos", TipoMensaje.MsgError)
End If End If
End If
End If End If
Catch ex As Exception Catch ex As Exception
ObjInventario.RollBack() 'deshace lo insertado ObjInventario.RollBack() 'deshace lo insertado
@@ -1202,6 +1226,94 @@ Partial Class Inventarios_RecepcionUsados
End Sub End Sub
Private Function GeneraPrePoliza(CveMovimiento As Integer, ByRef ObjInventario As ClsInventarios, ByRef ObjConta As ClsContabilidad, EsContabilizable As Boolean) As Boolean
Dim Correcto As Boolean = True
Try
Dim DtCostos As DataTable = Nothing
Dim ValorInventario As Decimal = 0
Dim ValorInventarioME As Decimal = 0
ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa)
Dim CveVenta As Integer = ObjInventario.CveVenta
Dim CveAlmacen As Integer = ObjInventario.CveAlmacen
Dim SerieFolio As String = ObjInventario.DtResultados.Rows(0)("SerieFolioVenta").ToString
Dim MovAlmacen As Boolean = True
Dim CveConcepto As Integer = ObjInventario.DtResultados.Rows(0)("CveConcepto").ToString().ToEntero()
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & CveConcepto).ToEntero
If OrigenMov = 1 Then MovAlmacen = False Else MovAlmacen = True
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
DtCostos = ObjInventario.DtResultados
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
Dim IdCtaContable As Integer = 0
Dim ConceptoPoliza As String = String.Format("{0}-{1}", "Salida de Almacen", SerieFolio)
If tmpCostos.Rows.Count > 0 Then
Dim Concepto As String = ConceptoPoliza
Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv_EntradaSalida", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={CveAlmacen}").ToEntero
Dim tCveConcepto As Integer = 278
For Each RowInv As DataRow In tmpCostos.Rows
ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal.RoundSQL
If tCveConcepto = 69 Then
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, CveSubProyecto:=tCveSubProyecto, Contabilizable:=EsContabilizable) Then
Correcto = False
Exit For
End If
Next
IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={CveAlmacen}").ToEntero
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, DtCostos.SUMD("Total").RoundSQL, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total").RoundSQL, Contabilizable:=EsContabilizable) Then
Correcto = False
End If
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
Correcto = False
End If
End If
'CONTABILIZAR - SIMPLIFICAR
If Correcto Then
If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
Correcto = False
End If
End If
'If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
' If ObjContaContPAQ Is Nothing Then
' ObjContaContPAQ = New ClsContPAQi(UsuarioActual.Empresa)
' ObjContaContPAQ.IniciaTransacSQL()
' End If
' If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaContPAQ) Then
' Retorno = False
' End If
'End If
End If
Else
Correcto = False
End If
Else
Correcto = False
End If
Catch ex As Exception
OnError("Ocurrió un error al guadar la prepoliza", ex)
Correcto = False
End Try
Return Correcto
End Function
#End Region #End Region
#Region " ADD INVENTARIO INICIAL " #Region " ADD INVENTARIO INICIAL "
@@ -2451,6 +2563,12 @@ Partial Class Inventarios_RecepcionUsados
ObjRemisionNC.IEPS = ImporteIEPS ObjRemisionNC.IEPS = ImporteIEPS
ObjRemisionNC.Total = Total ObjRemisionNC.Total = Total
ObjRemisionNC.TotalOtrosConceptos = 0 ObjRemisionNC.TotalOtrosConceptos = 0
ObjRemisionNC.DtMovimientosUsados = DtMovimientos
ObjRemisionNC.CveAlmacen = DdlAlmacen.SelectedValue.ToEntero()
ObjRemisionNC.ObservacionesMovimiento = TxtObservaciones.Text
ObjRemisionNC.CveConceptoMovimiento = CveConcepto
End Sub End Sub
Protected Sub CargaTamaños() Protected Sub CargaTamaños()

View File

@@ -245,7 +245,7 @@
<asp:HyperLink ID="HLOrdenServicio" Target="_blank" runat="server" Visible="false"> <i class="fa fa-plus"></i> Genera O. S.</asp:HyperLink> <asp:HyperLink ID="HLOrdenServicio" Target="_blank" runat="server" Visible="false"> <i class="fa fa-plus"></i> Genera O. S.</asp:HyperLink>
</li> </li>
<li> <li>
<asp:LinkButton ID="LkCotizacionAutorizar" Target="_blank" runat="server" Visible="false"> <i class="fa fa-check"></i> Autorizar Cotización</asp:LinkButton> <asp:LinkButton ID="LkCotizacionAutorizar" runat="server" Visible="false"> <i class="fa fa-check"></i> Autorizar Cotización</asp:LinkButton>
</li> </li>
<li id="LiBuscarPrecio" runat="server" visible="false"> <li id="LiBuscarPrecio" runat="server" visible="false">
@@ -7099,8 +7099,13 @@
TxtImporte.value = FormatoNumero(Saldo, 2); TxtImporte.value = FormatoNumero(Saldo, 2);
} }
} else { } else {
if (SaldoMaximoUtilizable > 0) {
TxtImporte.value = ""; TxtImporte.value = "";
Chk.checked = false; Chk.checked = false;
} else {
TxtImporte.value = FormatoNumero(Saldo, 2);
}
} }
} else { } else {

View File

@@ -2167,7 +2167,7 @@ Partial Class Ventas
DdlSubProyectoDatos.Enabled = False DdlSubProyectoDatos.Enabled = False
BtnEmitirImprimir.Visible = False BtnEmitirImprimir.Visible = False
BtnCrearApartirDe.Visible = True BtnCrearApartirDe.Visible = True
If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue <> "Cot" Then BtnEditar.Visible = True If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then BtnEditar.Visible = True
'DdlEstatus.Enabled = True 'DdlEstatus.Enabled = True
DivFechaAnticipoCliente.Visible = True DivFechaAnticipoCliente.Visible = True
@@ -2222,8 +2222,14 @@ Partial Class Ventas
End If End If
If UsuarioActual.TienePermisoProceso(269) AndAlso Not DevolucionAlmacen = 2 Then If UsuarioActual.TienePermisoProceso(269) AndAlso Not DevolucionAlmacen = 2 Then
Dim ObjInventario As New ClsInventarios
If ObjInventario.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then
If ObjInventario.DtResultados.Rows.Count > 0 Then
DivDevAlm.Visible = True DivDevAlm.Visible = True
End If End If
End If
ObjInventario.Dispose()
End If
End If End If
@@ -3791,6 +3797,17 @@ Partial Class Ventas
End If End If
End If End If
Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero()
If UsuarioActual.Empresa.Funcionalidad(135) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso TipoEstatus = 5 Then
If UsuarioActual.TienePermisoProceso(159) Then
Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto")))
If TienePermiso <> "" Then
LbCancelarDocumento.Visible = True
End If
End If
End If
'CargaDetalle 'CargaDetalle
If ObjVentas.GetVentaDetalle(CveVenta) Then If ObjVentas.GetVentaDetalle(CveVenta) Then
TmpDT = ObjVentas.DtResultados TmpDT = ObjVentas.DtResultados
@@ -3885,17 +3902,26 @@ Partial Class Ventas
End If End If
'Verifico si tiene la funcionalidad (135)
If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then
'Reviso cuales son los supervisores 'Reviso cuales son los supervisores
Dim Objeto As New ClsVtaVendedores Dim Objeto As New ClsVtaVendedores
If Objeto.GetVendedores(UsuarioActual.CveEmpresa) Then If Objeto.GetVendedores(UsuarioActual.CveEmpresa) Then
Dim DTVendedores As New DataTable Dim DTVendedores As New DataTable
If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then
DTVendedores = Objeto.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) DTVendedores = Objeto.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor))
End If
'Verifico si es su supervisor asignado 'Verifico si es su supervisor asignado
If DTVendedores.Rows.Count > 0 Then If DTVendedores.Rows.Count > 0 Then
LkCotizacionAutorizar.Visible = True LkCotizacionAutorizar.Visible = True
If TipoEstatus = 2 Then
LkCotizacionAutorizar.Visible = False
ElseIf TipoEstatus = 2 Then
LkCotizacionAutorizar.Visible = False
End If
End If End If
DTVendedores.Dispose() DTVendedores.Dispose()
End If End If
@@ -4651,6 +4677,41 @@ Partial Class Ventas
End If End If
GvOCRelacionadas.DataBind() GvOCRelacionadas.DataBind()
'Verifico si tiene la funcionalidad (135)
If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135) = "1" Then
'Reviso cuales son los supervisores
Dim ObjVendedores As New ClsVtaVendedores
If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then
Dim DTVendedores As New DataTable
If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then
DTVendedores = ObjVendedores.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor))
End If
'Verifico si es su supervisor asignado
If DTVendedores.Rows.Count > 0 Then
If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then
BtnsFacturar.Visible = True
BtnGenerarRemision.Visible = True
Else
BtnsFacturar.Visible = False
BtnGenerarRemision.Visible = False
End If
End If
DTVendedores.Dispose()
End If
ObjVendedores.Dispose()
End If
If DdlTipoComprobante.SelectedValue = "Cot" Then
If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then
BtnsFacturar.Visible = False
BtnGenerarRemision.Visible = False
End If
End If
UpPS.Update() UpPS.Update()
UpContado.Update() UpContado.Update()
UpEstatus.Update() UpEstatus.Update()
@@ -10413,7 +10474,7 @@ Partial Class Ventas
If ErrorList.Count = 0 Then If ErrorList.Count = 0 Then
'prepoliza 'prepoliza
GuardarVentaPrePolizas(ObjConta, factura, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento, ListaNCDescuento:=ListaNCDescuento) GuardarVentaPrePolizas(ObjConta, factura, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento, ListaNCDescuento:=ListaNCDescuento, ObjInventario:=ObjInventario)
If ErrorList.Count = 0 Then If ErrorList.Count = 0 Then
'INVENTARIOS 'INVENTARIOS
@@ -10448,7 +10509,7 @@ Partial Class Ventas
Private Sub GuardarVentaPrePolizas(ByRef ObjConta As ClsContabilidad, factura As Modelos.Factura, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, Private Sub GuardarVentaPrePolizas(ByRef ObjConta As ClsContabilidad, factura As Modelos.Factura, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer,
ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing,
ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False, ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False,
Optional ValorMultiplicador As Integer = 1, Optional ListaNCDescuento As List(Of Modelos.Factura) = Nothing) Optional ValorMultiplicador As Integer = 1, Optional ListaNCDescuento As List(Of Modelos.Factura) = Nothing, Optional ObjInventario As ClsInventarios = Nothing)
Dim CveIE As Integer = -1 Dim CveIE As Integer = -1
Dim DT As DataTable = Nothing Dim DT As DataTable = Nothing
@@ -10467,7 +10528,7 @@ Partial Class Ventas
If DdlTipoComprobante.SelectedValue <> "Cot" Then If DdlTipoComprobante.SelectedValue <> "Cot" Then
If factura.CvePrePoliza > 0 Then If factura.CvePrePoliza > 0 Then
If ProcesoPrepolizas(ObjConta, factura, CveIE, TmpDTDetalleMovimientos, objContPaqi, ValorMultiplicador, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento, ListaNCDescuento:=ListaNCDescuento) Then If ProcesoPrepolizas(ObjConta, factura, CveIE, TmpDTDetalleMovimientos, objContPaqi, ValorMultiplicador, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento, ListaNCDescuento:=ListaNCDescuento, ObjInventario:=ObjInventario) Then
ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico") ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
End If End If
@@ -10478,7 +10539,8 @@ Partial Class Ventas
End Sub End Sub
Private Function ProcesoPrepolizas(ByRef ObjConta As ClsContabilidad, ObjFactura As Modelos.Factura, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi, Private Function ProcesoPrepolizas(ByRef ObjConta As ClsContabilidad, ObjFactura As Modelos.Factura, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi,
Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing,
ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False, Optional ListaNCDescuento As List(Of Modelos.Factura) = Nothing) As Boolean ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False,
Optional ListaNCDescuento As List(Of Modelos.Factura) = Nothing, Optional ObjInventario As ClsInventarios = Nothing) As Boolean
Try Try
Dim DT As DataTable Dim DT As DataTable
Dim CvePlantilaPoliza As Integer Dim CvePlantilaPoliza As Integer
@@ -11313,6 +11375,36 @@ Partial Class Ventas
IdCtaContableCliente = IdCtaContable IdCtaContableCliente = IdCtaContable
CveCuentaCliente = CveCuenta CveCuentaCliente = CveCuenta
Dim CveMovimiento As Integer = -1
Dim CveAlmacen As Integer = -1
If ObjInventario IsNot Nothing AndAlso ObjInventario.GetInv_Mov(ObjRNC.CveVenta, UsuarioActual.CveEmpresa) Then
CveMovimiento = ObjInventario.DtResultados.FiltroPrimeroValor("CveMovimiento", "CvePS IS NULL AND CveConcepto = 42").ToEntero()
CveAlmacen = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen", "CvePS IS NULL AND CveConcepto = 42").ToEntero()
End If
'VERIFICA SI TIENE MOVIMIENTO DE ENTRADA DE USADO
If CveMovimiento > 0 AndAlso CveAlmacen > 0 Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjRNC.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
End If
Dim SubTotalCalculado As Decimal = (importeMovimiento / (1D + ObjRNC.PorcentajeIVA)).ToDecimal
Dim Importe318 As Decimal = (SubTotalCalculado * ObjRNC.PorcentajeIVA).RoundSQL(2).ToDecimal()
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, Importe318, Referencia, 318, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjRNC.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=Importe318, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
End If
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, SubTotalCalculado, Referencia, 150, Concepto, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=ObjRNC.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=ObjRNC.DtDetalle.MAX("CveClasificacion").ToEntero(), CveSubProyecto:=ObjRNC.CveSubProyecto, ImporteMX:=SubTotalCalculado, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveCuenta:=CveCuenta, Contabilizable:=False) Then
ErrorPrepoliza = True
Else
ViewState("SeGuardoPrePoliza") = True
End If
Else
If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjRNC.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjRNC.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 278, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjRNC.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 278, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjRNC.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True ErrorPrepoliza = True
@@ -11320,6 +11412,7 @@ Partial Class Ventas
Else Else
ErrorPrepoliza = True ErrorPrepoliza = True
End If End If
End If
importeMovimiento = 0 importeMovimiento = 0
End If End If
@@ -12724,15 +12817,15 @@ Partial Class Ventas
'TIMBRADO NUEVO 'TIMBRADO NUEVO
Try Try
If CveVenta > 0 Then
ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False)
End If
pdf = PdfFactura(ObjFactura) pdf = PdfFactura(ObjFactura)
Catch ex As Exception Catch ex As Exception
Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError)
End Try End Try
If CveVenta > 0 Then
ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False)
End If
LocalSerieFolio = ObjFactura.SerieFolio LocalSerieFolio = ObjFactura.SerieFolio
LocalTipoDocto = ObjFactura.TipoDocto LocalTipoDocto = ObjFactura.TipoDocto
@@ -15780,6 +15873,7 @@ Partial Class Ventas
Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False) As Boolean Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
Try
If Not CvePS > 0 Then If Not CvePS > 0 Then
Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgError) Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgError)
Return False Return False
@@ -15824,7 +15918,6 @@ Partial Class Ventas
Row("Obs") = Obs Row("Obs") = Obs
Dim DrPS As DataRow = Nothing Dim DrPS As DataRow = Nothing
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1
@@ -15985,7 +16078,6 @@ Partial Class Ventas
End If End If
End If End If
'RECARGAR GV 'RECARGAR GV
TmpDT.Rows.Add(Row) TmpDT.Rows.Add(Row)
@@ -16075,10 +16167,15 @@ Partial Class Ventas
End If End If
Next Next
End If End If
Retorno = True Retorno = True
Catch ex As Exception
Retorno = False
OnError("Ocurrió un error al agregar el producto/servicio", ex)
End Try
Return Retorno Return Retorno
End Function End Function
@@ -19549,8 +19646,19 @@ Partial Class Ventas
LBDevolucionAlmacen.ToolTip = "¿Está seguro de Solicitar la Devolución de Almacén?" LBDevolucionAlmacen.ToolTip = "¿Está seguro de Solicitar la Devolución de Almacén?"
End If End If
If VentaSaldoAlmacen < 0 Then
If DevolucionAlmacen = 0 Then
LBAplicaDevolucion.Visible = True
ElseIf DevolucionAlmacen.Contiene(1, 2) Then
LBAplicaDevolucion.Visible = False
End If
ElseIf VentaSaldoAlmacen >= 0 Then
LBAplicaDevolucion.Visible = False
End If End If
End If
UpnTools.Update()
'UpInvDev.Update() 'UpInvDev.Update()
End Sub End Sub
Protected Sub LBDevolucionAlmacen_Click(sender As Object, e As EventArgs) Protected Sub LBDevolucionAlmacen_Click(sender As Object, e As EventArgs)
@@ -19578,8 +19686,9 @@ Partial Class Ventas
ObjVentas.Dispose() ObjVentas.Dispose()
Me.DevolucionAlmacen = EstatusDevolucion Me.DevolucionAlmacen = EstatusDevolucion
InicializaDevolucionAlmacen() InicializaDevolucionAlmacen()
UpnTools.Update() 'UpnTools.Update()
End Sub End Sub
@@ -20250,8 +20359,21 @@ Partial Class Ventas
End Sub End Sub
Private Sub LkCotizacionAutorizar_Click(sender As Object, e As EventArgs) Handles LkCotizacionAutorizar.Click Private Sub LkCotizacionAutorizar_Click(sender As Object, e As EventArgs) Handles LkCotizacionAutorizar.Click
EsSupervisor = True EsSupervisor = True
GeneraPDFCotizacion(True) Dim ActualizoEstatus As Boolean = False
Dim ObjVentas As New ClsVentas
If ObjVentas.UpdateEstatusFactura(8, FolioFiscal, "", Now, CveVenta) Then
ActualizoEstatus = True
End If
ObjVentas.Dispose()
If ActualizoEstatus Then
'GeneraPDFCotizacion(True)
Alert("La cotización ha sido enviada al correo de nuestro cliente:" & Mail) Alert("La cotización ha sido enviada al correo de nuestro cliente:" & Mail)
Else
Alert("No se pudo autorizar la cotización", TipoMensaje.MsgError)
End If
End Sub End Sub
#End Region #End Region