BDH. Generacion de RNC desde URL en Recepcion de Usados

This commit is contained in:
2022-01-12 21:26:13 -07:00
parent 13119a2575
commit f384107d06
5 changed files with 1226 additions and 1116 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -8512,7 +8512,7 @@ Partial Class Ventas
End If
'SI ES AMORTIZACION 3.3
Dim Obj2 As New List(Of Object)
Dim ListaNotasCreditoGeneradas As New List(Of Modelos.Factura)
Dim NCDescuento As Boolean = ((ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0) OrElse (ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0))
If ErrorList.Count = 0 Then
' cambiar la condicion para saber si hay seleccionado
@@ -8534,7 +8534,7 @@ Partial Class Ventas
CreaObjetosVentaAmortizacion(ObjVentas, FolioFiscalRelacionado, CveVentaRelacionada, NCDescuento:=NCDescuento)
If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, ObjFacturaDevolucion, ObjBancos, Nothing,
Nothing, NCDescuento:=NCDescuento, ListaNCDescuento:=ListaNCDesc, IndexNC:=(If(DtVentasNC IsNot Nothing, DtVentasNC.Rows.Count - 1, 0))) Then
Obj2.Add(ObjFacturaDevolucion)
ListaNotasCreditoGeneradas.Add(ObjFacturaDevolucion)
End If
End If
@@ -8547,7 +8547,7 @@ Partial Class Ventas
CreaObjetosVentaBonificacion(ObjVentas, FolioFiscalRelacionado, CveVentaRelacionada, NCDescuento:=NCDescuento)
If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, ObjFacturaBonificacion, ObjBancos, Nothing,
Nothing, NCDescuento:=NCDescuento, ListaNCDescuento:=ListaNCBonificacion, IndexNC:=(DtVentasNC.Rows.Count - 1)) Then
Obj2.Add(ObjFacturaBonificacion)
ListaNotasCreditoGeneradas.Add(ObjFacturaBonificacion)
End If
End If
@@ -8556,7 +8556,7 @@ Partial Class Ventas
OnError("Ocurrió un error al generar nota de crédito de amortización", ex)
ErrorList.Add("No se pudo generar la nota de crédito de amortización")
End Try
If Obj2 Is Nothing AndAlso Obj2.Count = 0 Then
If ListaNotasCreditoGeneradas Is Nothing AndAlso ListaNotasCreditoGeneradas.Count = 0 Then
ErrorList.Add("No se pudo generar la nota de crédito de amortización")
End If
End If
@@ -8583,7 +8583,7 @@ Partial Class Ventas
CveVentaNCProntoPago = RespFacturaProntoPago.Mensaje.CveVenta
SerieFolioNCProntoPago = RespFacturaProntoPago.Mensaje.SerieFolio
Obj2.Add(RespFacturaProntoPago.ObjFacturaProntoPago)
ListaNotasCreditoGeneradas.Add(RespFacturaProntoPago.ObjFacturaProntoPago)
End If
End If
Else
@@ -8774,7 +8774,7 @@ Partial Class Ventas
If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then
'FACTURA INGRESO/EGRESO
Dim ObjTimbrado As New Timbrado
Dim FM As New Modelos.FemsaFactura
Dim TmpDT7Eleven As New DataTable
Dim TmpDTComplementosTimbrado As New DataTable
@@ -8785,34 +8785,35 @@ Partial Class Ventas
'DOCUMENTO ACTUAL
If DebeTimbrar Then
Dim ObjTimbrado As New Timbrado
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
Dim MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
If Not GeneroDescuentoProntoPago AndAlso Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro 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 DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
ofa.Timbre.CFDIRelacionados.UUID.Clear()
ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID)
End If
ObjTimbrado.TimbrarFactura(UsuarioActual, ofa)
GeneraPDFFactura(ChkEnviarFactura.Checked)
End If
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
If GeneroDescuentoProntoPago AndAlso Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro Then
If ListaNotasCreditoGeneradas.Count > 0 Then
Try
Dim ofa As Modelos.Factura = CType(Obj2(Obj2.Count - 1), Modelos.Factura)
'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC
ofa.Timbre.CFDIRelacionados.UUID.Clear()
ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID)
For Each NCGenerada In ListaNotasCreditoGeneradas
If NCGenerada.Timbre IsNot Nothing Then
NCGenerada.Timbre.CFDIRelacionados.UUID.Clear()
NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
ObjTimbrado.TimbrarFactura(UsuarioActual, ofa)
GeneraPDFFactura(ChkEnviarFactura.Checked)
Dim ObjTimbradoNC As New Timbrado
Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada)
If Not TimbroNC Then
Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError)
End If
ObjTimbradoNC = Nothing
End If
Next
Catch ex As Exception
OnError("Ocurrió un error al timbrar la nota de credito", ex)
OnError("Ocurrió un error al timbrar la NC.", ex)
End Try
End If
If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then
@@ -8820,29 +8821,26 @@ Partial Class Ventas
End If
If Not SeTimbro Then
Alert(ObjTimbrado.MensajeErrorCFDI, TipoMensaje.MsgError)
Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
End If
'CANCELAR FACTURA ANTERIOR
If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
If Me.ObjFacturaNC IsNot Nothing Then
Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA
Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, ObjTimbrado.UUID)
Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura)
End If
End If
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
ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" Then
GeneraPDFCBB(ObjFactura.FechaCP, Nothing, ObjFactura.SerieFolio, False)
''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
End If
End If
@@ -9069,7 +9067,7 @@ Partial Class Ventas
End If
ObjFactura = Nothing
Obj2 = Nothing
ListaNotasCreditoGeneradas = Nothing
End If
End If
@@ -9147,6 +9145,11 @@ Partial Class Ventas
ObjFacturaDevolucion.CveTipoRelacion = DdlTipoRelacionAnticipo.SelectedValue.ToEntero()
ObjFacturaDevolucion.TipoRelacion = "07"
If NCDescuento Then
ObjFacturaDevolucion.CveTipoRelacion = 1
ObjFacturaDevolucion.TipoRelacion = "01"
End If
Dim Fol As New List(Of String)
Fol.Add(FolioFiscalRelacionado)
ObjFacturaDevolucion.UUIDRelacionados = Fol
@@ -9421,8 +9424,8 @@ Partial Class Ventas
ObjFacturaBonificacion.UsoCFDI = DdlUsoCFDI.SelectedItem.Text
ObjFacturaBonificacion.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}")
ObjFacturaBonificacion.CveTipoRelacion = DdlTipoRelacionAnticipo.SelectedValue.ToEntero()
ObjFacturaBonificacion.TipoRelacion = "07"
ObjFacturaBonificacion.CveTipoRelacion = 1
ObjFacturaBonificacion.TipoRelacion = "01"
Dim Fol As New List(Of String)
Fol.Add(FolioFiscalRelacionado)
@@ -11735,7 +11738,7 @@ Partial Class Ventas
Dim CveTamanio As Integer = GlobalDTAcumTamaños().FiltroPrimeroValor("CveTamaño", $"CvePSCargo={CvePSCargo}").ToEntero()
If CveTamanio > 0 Then
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Row("Cantidad").ToString().ToDecimal(), CveTamanio, 6, factura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0D, "") Then
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Row("Cantidad").ToString().ToDecimal(), CveTamanio, 6, factura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0D, "", Now) Then
ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.")
Exit For
End If
@@ -22937,7 +22940,7 @@ Partial Class Ventas
'Else
'End If
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs", "RNC") Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then
Dim sb As New StringBuilder()
Dim sbExtra As New StringBuilder()
@@ -27423,10 +27426,14 @@ Partial Class Ventas
'Dim RNCCargo = ListaNC.Where(Function(f) f.CveVenta = RNCBonificacion.CveVentaRNCCargo).FirstOrDefault()
For Each RowCargo As DataRow In TmpDT.FiltraParametros("EsCargo = True", Orderby:="PU").Rows
Dim CantidadCargo = RowCargo("Cantidad").ToString().ToDecimal()
Dim ImportePU As Decimal = GlobalDTAcumTamaños().FiltroPrimeroValor("Bonificacion", $"CvePSCargo={RowCargo("CvePS")}").ToDecimal()
Dim TotalCalculableImpuestosCargo As Decimal = (CantidadCargo * ImportePU)
Dim TotalCargo As Decimal = TotalCalculableImpuestosCargo + (TotalCalculableImpuestosCargo * RowCargo("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2)
Dim PorcentajeAplicado = (RNCBonificacion.TotalRemNCAplicado / RNCBonificacion.Total)
Dim PorcentajeAplicado = (RNCBonificacion.TotalRemNCAplicado / TotalCargo)
Dim Cantidad As Decimal = RowCargo("Cantidad").ToString().ToDecimal() '* PorcentajeAplicado
Dim Cantidad As Decimal = RowCargo("Cantidad").ToString().ToDecimal() * PorcentajeAplicado
Dim Obs = RowCargo("CodigoPS").ToString()
@@ -27436,7 +27443,7 @@ Partial Class Ventas
'Dim ImportePU = RowCargo("PUBonificacion").ToString().ToDecimal
Dim ImportePU As Decimal = GlobalDTAcumTamaños().FiltroPrimeroValor("Bonificacion", $"CvePSCargo={RowCargo("CvePS")}").ToDecimal()
Dim TotalCalculableImpuestos As Decimal = (Cantidad * ImportePU)
@@ -31051,7 +31058,7 @@ Partial Class Ventas
For Each drow As DataRow In factura.DtDetalle.Rows
If drow("CveTamaño").ToString.ToEntero > 0 And (CvePSPSA <> drow("CvePS").ToString.ToEntero) Then
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToDecimal, drow("CveTamaño").ToString.ToEntero, CveConcepto, factura.CveVenta, UsuarioActual.CveUsuario,
UsuarioActual.CveEmpresa, 0D, "") Then
UsuarioActual.CveEmpresa, 0D, "", Now) Then
Resultado = False
Exit For
End If
@@ -31427,15 +31434,18 @@ Partial Class Ventas
If GvRow.FCCheckBox("ChkAplicar").Checked Then
Dim Rows = TmpDTRNCDetalle.Select($"CveVentaDetalleRNC = {GvRow.DataKey("CveVentaDetalleRNC").ToEntero()}")
For Each row In Rows
row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
If GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal() > 0 Then
row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
Dim TotalCalculableImpuestos As Decimal = row("Cantidad").ToString().ToDecimal() * row("PU").ToString().ToDecimal()
Dim IVA As Decimal = (TotalCalculableImpuestos * row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL()
Dim TotalCalculableImpuestos As Decimal = row("Cantidad").ToString().ToDecimal() * row("PU").ToString().ToDecimal()
Dim IVA As Decimal = (TotalCalculableImpuestos * row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL()
row("IVA") = IVA
row("Total") = (TotalCalculableImpuestos + IVA).RoundSQL
row("IVA") = IVA
row("Total") = (TotalCalculableImpuestos + IVA).RoundSQL
TmpDTRNCDetalleSelecciondas.Rows.Add(row.ItemArray)
End If
TmpDTRNCDetalleSelecciondas.Rows.Add(row.ItemArray)
Next
End If
End If
@@ -31461,18 +31471,25 @@ Partial Class Ventas
If GvRow.FCCheckBox("ChkAplicar").Checked AndAlso GvRow.DataKey("CveVenta").ToEntero() = Dr("CveVenta").ToString().ToEntero() Then
Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
Dim PU = GvRow.DataKey("PU").ToDecimal()
Dim PorcentajeIVA As Decimal = GvRow.DataKey("PorcentajeIVA").ToDecimal()
If Cantidad > 0 Then
Dim PU = GvRow.DataKey("PU").ToDecimal()
Dim PorcentajeIVA As Decimal = GvRow.DataKey("PorcentajeIVA").ToDecimal()
Dim TotalCalculableImpuestos As Decimal = (Cantidad * PU)
Dim ImporteIVA As Decimal = (TotalCalculableImpuestos * PorcentajeIVA).RoundSQL(2)
Dim TotalCalculableImpuestos As Decimal = (Cantidad * PU)
Dim ImporteIVA As Decimal = (TotalCalculableImpuestos * PorcentajeIVA).RoundSQL(2)
Dim TotalRNCDetalle As Decimal = (TotalCalculableImpuestos + ImporteIVA)
Dim TotalRNCDetalle As Decimal = (TotalCalculableImpuestos + ImporteIVA)
TotalRNC += TotalRNCDetalle
TotalRNC += TotalRNCDetalle
If RemNC.CveVentaRNCCargo <= 0 Then
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero()
If RemNC.CveVentaRNCCargo <= 0 Then
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero()
End If
Else
Alert($"La cantidad seleccionada debe ser mayor a 0.", TipoMensaje.MsgAdvertencia)
ListaNCDesc.Clear()
ListaNCBonificacion.Clear()
Exit Sub
End If
End If
@@ -31581,15 +31598,17 @@ Partial Class Ventas
If GvRow.FCCheckBox("ChkAplicar").Checked Then
Dim Rows = TmpDTRNCBonificacionDetalle.Select($"CveVentaDetalleRNC = {GvRow.DataKey("CveVentaDetalleRNC").ToEntero()}")
For Each row In Rows
row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
If GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal() > 0 Then
row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
Dim TotalCalculableImpuestos As Decimal = row("Cantidad").ToString().ToDecimal() * row("PU").ToString().ToDecimal()
Dim IVA As Decimal = (TotalCalculableImpuestos * row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL()
Dim TotalCalculableImpuestos As Decimal = row("Cantidad").ToString().ToDecimal() * row("PU").ToString().ToDecimal()
Dim IVA As Decimal = (TotalCalculableImpuestos * row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL()
row("IVA") = IVA
row("Total") = (TotalCalculableImpuestos + IVA).RoundSQL
row("IVA") = IVA
row("Total") = (TotalCalculableImpuestos + IVA).RoundSQL
TmpDTRNCBonificacionDetalleSeleccionadas.Rows.Add(row.ItemArray)
TmpDTRNCBonificacionDetalleSeleccionadas.Rows.Add(row.ItemArray)
End If
Next
End If
End If
@@ -31607,20 +31626,28 @@ Partial Class Ventas
If GvRow.FCCheckBox("ChkAplicar").Checked AndAlso GvRow.DataKey("CveVenta").ToEntero() = Dr("CveVenta").ToString().ToEntero() Then
Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
Dim PU = GvRow.DataKey("PU").ToDecimal()
Dim PorcentajeIVA As Decimal = GvRow.DataKey("PorcentajeIVA").ToDecimal()
If Cantidad > 0 Then
Dim PU = GvRow.DataKey("PU").ToDecimal()
Dim PorcentajeIVA As Decimal = GvRow.DataKey("PorcentajeIVA").ToDecimal()
Dim TotalCalculableImpuestos As Decimal = (Cantidad * PU)
Dim ImporteIVA As Decimal = (TotalCalculableImpuestos * PorcentajeIVA).RoundSQL(2)
Dim TotalCalculableImpuestos As Decimal = (Cantidad * PU)
Dim ImporteIVA As Decimal = (TotalCalculableImpuestos * PorcentajeIVA).RoundSQL(2)
Dim TotalRNCDetalle As Decimal = (TotalCalculableImpuestos + ImporteIVA)
Dim TotalRNCDetalle As Decimal = (TotalCalculableImpuestos + ImporteIVA)
TotalRNC += TotalRNCDetalle
TotalRNC += TotalRNCDetalle
If RemNC.CveVentaRNCCargo <= 0 Then
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero()
If RemNC.CveVentaRNCCargo <= 0 Then
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero()
End If
Else
Alert($"La cantidad seleccionada debe ser mayor a 0.", TipoMensaje.MsgAdvertencia)
ListaNCDesc.Clear()
ListaNCBonificacion.Clear()
Exit Sub
End If
End If
End If