Cancelacion de NC con RNC relacionadas
This commit is contained in:
@@ -5020,7 +5020,23 @@ Public Class ClsVentas
|
|||||||
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
Public Function GetRNCRelacionadas(CveVenta As Integer) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
DataAdapter("PA_Vta_RNCRelacionadasGet")
|
||||||
|
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
|
||||||
|
End With
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al obtener las ventas con usados.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
|
|||||||
@@ -2962,6 +2962,80 @@ Namespace Modelos
|
|||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If UsuarioActual.Empresa.Funcionalidad(344) = "1" Then
|
||||||
|
Dim ListaNC As List(Of Modelos.Factura) = New List(Of Factura)
|
||||||
|
Dim DtRNCRelacionas As DataTable = Nothing
|
||||||
|
|
||||||
|
If ObjVentas.GetRNCRelacionadas(CveVenta) Then
|
||||||
|
DtRNCRelacionas = ObjVentas.DtResultados.Copy
|
||||||
|
End If
|
||||||
|
|
||||||
|
If DtRNCRelacionas IsNot Nothing Then
|
||||||
|
For Each RowRNC As DataRow In DtRNCRelacionas.Rows
|
||||||
|
ListaNC.Add(New Modelos.Factura(UsuarioActual, RowRNC("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa) With {.TotalRemNCAplicado = RowRNC("ImporteAplicado").ToString().ToDecimal()})
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
If ListaNC IsNot Nothing Then
|
||||||
|
For Each ObjRNC As Modelos.Factura In ListaNC
|
||||||
|
If ObjRNC.TipoDocto = "RNC" Then
|
||||||
|
importeMovimiento = ObjRNC.TotalRemNCAplicado
|
||||||
|
importeMX = importeMovimiento * tipoCambio * Multiplicador
|
||||||
|
FechaMovimiento = ObjFactura.FechaPago
|
||||||
|
CveSubProyectoContabilizar = CveSubProyectoVenta
|
||||||
|
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||||
|
|
||||||
|
If tipoCambio = 1 Then
|
||||||
|
IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
|
||||||
|
Else
|
||||||
|
IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera
|
||||||
|
End If
|
||||||
|
|
||||||
|
IdCtaContableCliente = IdCtaContable
|
||||||
|
|
||||||
|
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), 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), 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, Contabilizable:=False) Then
|
||||||
|
ErrorPrepoliza = 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), 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), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||||
|
ErrorPrepoliza = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
ErrorPrepoliza = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
importeMovimiento = 0
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
End If
|
||||||
Else
|
Else
|
||||||
If ObjFactura.DtAnticipos IsNot Nothing Then
|
If ObjFactura.DtAnticipos IsNot Nothing Then
|
||||||
For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows
|
For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows
|
||||||
@@ -4910,7 +4984,7 @@ Namespace Modelos
|
|||||||
'CANCELA PREPOLIZA
|
'CANCELA PREPOLIZA
|
||||||
If Not ErrorCancelar Then
|
If Not ErrorCancelar Then
|
||||||
ErrorCancelar = ProcesoPrepolizas(ObjFactura, ObjConta, -1, ObjFactura.DtDetalle, ObjAC, -1, ObjBancos, ObjVentas, ObjEventos, DtRemisionesRelacionadas:=DtRemisionesRelacionadas, SeCancelaRemisionProceso:=SeCancelaRemisionProceso,
|
ErrorCancelar = ProcesoPrepolizas(ObjFactura, ObjConta, -1, ObjFactura.DtDetalle, ObjAC, -1, ObjBancos, ObjVentas, ObjEventos, DtRemisionesRelacionadas:=DtRemisionesRelacionadas, SeCancelaRemisionProceso:=SeCancelaRemisionProceso,
|
||||||
CancelarRemisiones:=CancelarRemisiones, ListaRemisionesCancelar:=ListaRemisionesCancelar, CveEstatusRefacturacion:=CveEstatusRefacturacion)
|
CancelarRemisiones:=CancelarRemisiones, ListaRemisionesCancelar:=ListaRemisionesCancelar, CveEstatusRefacturacion:=CveEstatusRefacturacion, ObjInventario:=ObjInventario)
|
||||||
MensajeError = "Ocurrió un error al generar la prepoliza de cancelación."
|
MensajeError = "Ocurrió un error al generar la prepoliza de cancelación."
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|||||||
@@ -8240,7 +8240,7 @@ Partial Class Ventas
|
|||||||
Dim GeneroDescuentoProntoPago As Boolean = False
|
Dim GeneroDescuentoProntoPago As Boolean = False
|
||||||
|
|
||||||
'SOLO GENERAR NC POR DESCUENTO PRONTO PAGO SI EL PAGO ES DE CONTADO
|
'SOLO GENERAR NC POR DESCUENTO PRONTO PAGO SI EL PAGO ES DE CONTADO
|
||||||
If RBLPago.SelectedValue = "2" AndAlso ObjFactura.DescuentoProntoPago > 0 Then
|
If ErrorList.Count = 0 AndAlso RBLPago.SelectedValue = "2" AndAlso ObjFactura.DescuentoProntoPago > 0 Then
|
||||||
Dim ImportePagado = DtPagos.SUM("Importe").ToString().ToDecimal
|
Dim ImportePagado = DtPagos.SUM("Importe").ToString().ToDecimal
|
||||||
Dim ImporteRNC As Decimal = LblDescuentosRNC.Text.ToDecimal()
|
Dim ImporteRNC As Decimal = LblDescuentosRNC.Text.ToDecimal()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user