|
|
|
|
@@ -85,6 +85,14 @@ Partial Class Ventas
|
|
|
|
|
End Property
|
|
|
|
|
|
|
|
|
|
'Local
|
|
|
|
|
Private Property DtPorcentajeMarcas As DataTable
|
|
|
|
|
Get
|
|
|
|
|
Return If(IsNothing(ViewState("DtPorcentajeMarcas")), Nothing, CType(ViewState("DtPorcentajeMarcas"), DataTable))
|
|
|
|
|
End Get
|
|
|
|
|
Set(value As DataTable)
|
|
|
|
|
ViewState("DtPorcentajeMarcas") = value
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
|
Private Property TmpDT As DataTable
|
|
|
|
|
Get
|
|
|
|
|
Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable))
|
|
|
|
|
@@ -265,6 +273,14 @@ Partial Class Ventas
|
|
|
|
|
ViewState("ListaRemisionesNC") = value
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
|
Private Property ListaNCDesc As List(Of Modelos.Factura)
|
|
|
|
|
Get
|
|
|
|
|
Return If(IsNothing(ViewState("ListaNCDesc")), Nothing, CType(ViewState("ListaNCDesc"), List(Of Modelos.Factura)))
|
|
|
|
|
End Get
|
|
|
|
|
Set(value As List(Of Modelos.Factura))
|
|
|
|
|
ViewState("ListaNCDesc") = value
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
|
Private Property Pedidos2Lista As List(Of Integer)
|
|
|
|
|
Get
|
|
|
|
|
Return If(IsNothing(ViewState("Pedidos2Lista")), Nothing, CType(ViewState("Pedidos2Lista"), List(Of Integer)))
|
|
|
|
|
@@ -2463,7 +2479,7 @@ Partial Class Ventas
|
|
|
|
|
InicializaAplicarNC()
|
|
|
|
|
|
|
|
|
|
If CveCliente > 0 Then
|
|
|
|
|
CargaRestriccionesCreditoCliente()
|
|
|
|
|
CargaRestriccionesCreditoCliente(CveVenta:=Me.CveVenta)
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If Not CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(403).ToString = "1" Then
|
|
|
|
|
@@ -2512,6 +2528,11 @@ Partial Class Ventas
|
|
|
|
|
End If
|
|
|
|
|
TxtFecha.Enabled = True
|
|
|
|
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
|
|
|
|
|
TbDescuentosRNC.Visible = True
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
CargaPorcentajeMarcas()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub ConfiguraEmpresa()
|
|
|
|
|
@@ -4947,7 +4968,7 @@ Partial Class Ventas
|
|
|
|
|
TrVistaPrevia.Visible = True
|
|
|
|
|
|
|
|
|
|
If Not (ModalidadEdicion AndAlso DdlTipoComprobante.SelectedValue = "Rem") Then
|
|
|
|
|
CargaRestriccionesCreditoCliente(True)
|
|
|
|
|
CargaRestriccionesCreditoCliente(True, Me.CveVenta)
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -5001,7 +5022,7 @@ Partial Class Ventas
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False)
|
|
|
|
|
Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False, Optional CveVenta As Integer = -1)
|
|
|
|
|
Dim ObjCliente As New ClsClientes()
|
|
|
|
|
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
|
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
|
|
|
@@ -6120,7 +6141,11 @@ Partial Class Ventas
|
|
|
|
|
#Region " EMITIR IMPRIMIR - GUARDAR "
|
|
|
|
|
|
|
|
|
|
Protected Sub BtnEmitirImprimir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEmitirImprimir.Click
|
|
|
|
|
Try
|
|
|
|
|
EmitirImprimir()
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
OnError(ex.ToString(), ex)
|
|
|
|
|
End Try
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub EmitirImprimir()
|
|
|
|
|
@@ -6525,7 +6550,6 @@ Partial Class Ventas
|
|
|
|
|
' Exit Sub
|
|
|
|
|
'End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If ObjFactura.CveCliente > 0 Or CveEmpresaCRM > 0 Then
|
|
|
|
|
If TmpDT.Rows.Count > 0 Then
|
|
|
|
|
|
|
|
|
|
@@ -6597,7 +6621,8 @@ Partial Class Ventas
|
|
|
|
|
EsNCAmortizacion = True
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjFactura, TmpDT, ObjFactura.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS, ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion)
|
|
|
|
|
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjFactura, TmpDT, ObjFactura.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS,
|
|
|
|
|
ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion)
|
|
|
|
|
|
|
|
|
|
'SI ES REFACTURACION
|
|
|
|
|
Dim ObjNC As List(Of Object) = Nothing
|
|
|
|
|
@@ -6620,30 +6645,21 @@ Partial Class Ventas
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'SI ES amortizacion 3.3
|
|
|
|
|
'SI ES AMORTIZACION 3.3
|
|
|
|
|
Dim Obj2 As New List(Of Object)
|
|
|
|
|
|
|
|
|
|
Dim NCDescuento As Boolean = (ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0)
|
|
|
|
|
If ErrorList.Count = 0 Then
|
|
|
|
|
' cambiar la condicion para saber si hay seleccionado
|
|
|
|
|
If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
|
|
|
|
|
|
|
|
|
|
If TieneAnticipo Then
|
|
|
|
|
CreaObjetosVentaAmortizacion(ObjVentas, FolioFiscalRelacionado, CveAnticipoPadre)
|
|
|
|
|
|
|
|
|
|
If (TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2") OrElse NCDescuento Then
|
|
|
|
|
Try
|
|
|
|
|
If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, ObjFacturaDevolucion, ObjBancos, Nothing, Nothing) Then
|
|
|
|
|
|
|
|
|
|
CreaObjetosVentaAmortizacion(ObjVentas, FolioFiscalRelacionado, CveAnticipoPadre, NCDescuento:=NCDescuento)
|
|
|
|
|
If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, ObjFacturaDevolucion, ObjBancos, Nothing,
|
|
|
|
|
Nothing, NCDescuento:=NCDescuento) Then
|
|
|
|
|
Obj2.Add(ObjFacturaDevolucion)
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
ErrorList.Add("No se pudo generarse la nota de crédito de amortización")
|
|
|
|
|
End Try
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
@@ -6820,7 +6836,6 @@ Partial Class Ventas
|
|
|
|
|
End Try
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim SeTimbro As Boolean = False
|
|
|
|
|
Dim SeTimbroNC As Boolean = False
|
|
|
|
|
Dim EstatusSMS = 0
|
|
|
|
|
@@ -7084,7 +7099,8 @@ Partial Class Ventas
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Private Sub CreaObjetosVentaAmortizacion(ObjVentas As ClsVentas, FolioFiscalRelacionado As String, CveAnticipoPadre As Integer, Optional CveVentasPadre As Integer = -1)
|
|
|
|
|
Private Sub CreaObjetosVentaAmortizacion(ObjVentas As ClsVentas, FolioFiscalRelacionado As String, CveAnticipoPadre As Integer,
|
|
|
|
|
Optional CveVentasPadre As Integer = -1, Optional NCDescuento As Boolean = False)
|
|
|
|
|
ObjFacturaDevolucion = New Modelos.Factura
|
|
|
|
|
|
|
|
|
|
ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario
|
|
|
|
|
@@ -7098,7 +7114,6 @@ Partial Class Ventas
|
|
|
|
|
ObjFacturaDevolucion.CveVentaRelacion = ObjVentas.CveVenta
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa
|
|
|
|
|
ObjFacturaDevolucion.TipoCambio = If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.Trim.ToDecimal)
|
|
|
|
|
ObjFacturaDevolucion.ConvertirPesos = ChkConvertirDoctoPesos.Checked
|
|
|
|
|
@@ -7139,6 +7154,7 @@ Partial Class Ventas
|
|
|
|
|
|
|
|
|
|
ObjFacturaDevolucion.CveTipoRelacion = DdlTipoRelacionAnticipo.SelectedValue.ToEntero
|
|
|
|
|
ObjFacturaDevolucion.TipoRelacion = "07"
|
|
|
|
|
|
|
|
|
|
Dim Fol As New List(Of String)
|
|
|
|
|
Fol.Add(FolioFiscalRelacionado)
|
|
|
|
|
ObjFacturaDevolucion.UUIDRelacionados = Fol
|
|
|
|
|
@@ -7199,7 +7215,23 @@ Partial Class Ventas
|
|
|
|
|
ObjFacturaDevolucion.Det_FechaOrdenCompra = TxtDet_FechaOrdenCompra.Text.Trim
|
|
|
|
|
ObjFacturaDevolucion.MonedaAbreviatura = ""
|
|
|
|
|
|
|
|
|
|
'Totales, Y se llena TmpDTImpuestos
|
|
|
|
|
'DETALLES
|
|
|
|
|
If NCDescuento Then
|
|
|
|
|
ObjFacturaDevolucion.DtDetalle = CreaDTDetalleNCDescuento()
|
|
|
|
|
|
|
|
|
|
ObjFacturaDevolucion.SubTotal = ObjFacturaDevolucion.DtDetalle.SUM("Total").ToDecimal()
|
|
|
|
|
ObjFacturaDevolucion.Descuento = ObjFacturaDevolucion.DtDetalle.SUM("Descuento").ToDecimal()
|
|
|
|
|
ObjFacturaDevolucion.Amortizacion = 0
|
|
|
|
|
ObjFacturaDevolucion.IVA = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIVA").ToDecimal()
|
|
|
|
|
ObjFacturaDevolucion.RetIVA = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetIVA").ToDecimal()
|
|
|
|
|
ObjFacturaDevolucion.RetISR = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetISR").ToDecimal()
|
|
|
|
|
ObjFacturaDevolucion.IEPS = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIEPS").ToDecimal()
|
|
|
|
|
|
|
|
|
|
Dim Total As Decimal = (ObjFacturaDevolucion.SubTotal + ObjFacturaDevolucion.IVA + ObjFacturaDevolucion.IEPS) - (ObjFacturaDevolucion.Descuento + ObjFacturaDevolucion.RetIVA + ObjFacturaDevolucion.RetISR + ObjFacturaDevolucion.Amortizacion)
|
|
|
|
|
ObjFacturaDevolucion.Total = Total
|
|
|
|
|
Else
|
|
|
|
|
ObjFacturaDevolucion.DtDetalle = TmpDT
|
|
|
|
|
|
|
|
|
|
ObjFacturaDevolucion.SubTotal = TxtSubTotal.Text.ToDecimal
|
|
|
|
|
ObjFacturaDevolucion.Descuento = LblDescuentos.Text.Trim.ToDecimal
|
|
|
|
|
ObjFacturaDevolucion.Amortizacion = LblAmortizacion.Text.Trim.ToDecimal
|
|
|
|
|
@@ -7208,6 +7240,8 @@ Partial Class Ventas
|
|
|
|
|
ObjFacturaDevolucion.RetISR = TxtRetISR.Text.ToDecimal
|
|
|
|
|
ObjFacturaDevolucion.IEPS = TxtIEPS.Text.ToDecimal
|
|
|
|
|
ObjFacturaDevolucion.Total = TxtTotal.Text.ToDecimal
|
|
|
|
|
End If
|
|
|
|
|
'Totales, Y se llena TmpDTImpuestos
|
|
|
|
|
|
|
|
|
|
'ObjFactura.BZDescripcion = TxtBZDescripcion.Text.Trim
|
|
|
|
|
'ObjFactura.BZNombreCorto = TxtBZNombreCorto.Text.Trim
|
|
|
|
|
@@ -7255,12 +7289,10 @@ Partial Class Ventas
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If TxtTotal.Text.ToDecimal <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = TxtTotal.Text.ToDecimal : DR("Orden") = 100 : DR("TipoImpuesto") = "0" : TmpDTImpuestos.Rows.Add(DR)
|
|
|
|
|
|
|
|
|
|
ObjFacturaDevolucion.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'otros
|
|
|
|
|
ObjFacturaDevolucion.Det_FechaOrdenCompra = TxtDet_FechaOrdenCompra.Text.Trim
|
|
|
|
|
ObjFacturaDevolucion.Det_OrdenCompra = TxtDet_OrdenCompra.Text.Trim
|
|
|
|
|
@@ -7273,8 +7305,6 @@ Partial Class Ventas
|
|
|
|
|
ObjFacturaDevolucion.CveMoneda = 1
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
'DETALLES
|
|
|
|
|
ObjFacturaDevolucion.DtDetalle = TmpDT
|
|
|
|
|
ObjFacturaDevolucion.DtFirmas = DTmpF
|
|
|
|
|
|
|
|
|
|
'CLIENTE
|
|
|
|
|
@@ -7331,10 +7361,11 @@ Partial Class Ventas
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean
|
|
|
|
|
Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi,
|
|
|
|
|
ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos, Optional NCDescuento As Boolean = False) As Boolean
|
|
|
|
|
Dim ProcesoCorrecto As Boolean = True
|
|
|
|
|
|
|
|
|
|
'Generamos el nuevo folio
|
|
|
|
|
'GENERAMOS EL NUEVO FOLIO
|
|
|
|
|
Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL())
|
|
|
|
|
|
|
|
|
|
If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then
|
|
|
|
|
@@ -7347,7 +7378,21 @@ Partial Class Ventas
|
|
|
|
|
DT.Dispose()
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
'** genero los datos de la NC
|
|
|
|
|
If NCDescuento Then
|
|
|
|
|
|
|
|
|
|
If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
|
|
|
|
|
DtVentasNC.Rows(0)("Importe") = factura.Total
|
|
|
|
|
DtVentasNC.Rows(0)("TC") = factura.TipoCambio
|
|
|
|
|
DtVentasNC.Rows(0)("TCCambioValuacion") = factura.TipoCambio
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion)
|
|
|
|
|
|
|
|
|
|
'Registramos la venta
|
|
|
|
|
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, factura.DtDetalle, -1, ObjContPaq, ObjBancos, EsNCAmortizacion:=True, NCDescuento:=True)
|
|
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
'GENERO LOS DATOS DE LA NC
|
|
|
|
|
Dim tmpcon As DataTable = TmpDT.Clone
|
|
|
|
|
tmpcon.Clear()
|
|
|
|
|
|
|
|
|
|
@@ -7407,7 +7452,7 @@ Partial Class Ventas
|
|
|
|
|
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
'**** impuestos locales
|
|
|
|
|
'**** IMPUESTOS LOCALES
|
|
|
|
|
|
|
|
|
|
factura.DtDetalle = tmpcon
|
|
|
|
|
Dim TotalSubTotal As Decimal = tmpcon.SUM("TotalImporte").ToDecimal
|
|
|
|
|
@@ -7441,34 +7486,10 @@ Partial Class Ventas
|
|
|
|
|
'Registramos la venta
|
|
|
|
|
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, tmpcon, -1, ObjContPaq, ObjBancos, EsNCAmortizacion:=True)
|
|
|
|
|
|
|
|
|
|
''Timbramos
|
|
|
|
|
'If factura.TipoDocto.Contiene("Ing", "Egs", "Ant") Then
|
|
|
|
|
' If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso UsuarioActual.Empresa.FacturaProduccion Then
|
|
|
|
|
|
|
|
|
|
' Dim sw As New Diagnostics.Stopwatch
|
|
|
|
|
' sw.Start()
|
|
|
|
|
|
|
|
|
|
' ''factura INGRESO / EGRESO
|
|
|
|
|
' Dim ObjTimbrado As New Modelos.Timbrado
|
|
|
|
|
' Dim FM As New Modelos.FemsaFactura
|
|
|
|
|
' Dim TmpDT7Eleven As New DataTable
|
|
|
|
|
' Dim TmpDTComplementosTimbrado As New DataTable
|
|
|
|
|
|
|
|
|
|
' 'PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
|
|
|
|
|
' '**
|
|
|
|
|
' ObjTimbrado.TimbrarFactura(UsuarioActual, factura, FM, TmpDT, TmpDTImpuestos, TmpDT7Eleven, TmpDTComplementosTimbrado, Ruta, LstFordASN, TxtFordGSDB.Text)
|
|
|
|
|
|
|
|
|
|
' sw.Stop()
|
|
|
|
|
' 'GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString, UsuarioActual.Empresa.CvePAC)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
' End If
|
|
|
|
|
'End If
|
|
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
ErrorList.Add("No se encontró un producto para generar la nota de crédito")
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Return ProcesoCorrecto
|
|
|
|
|
End Function
|
|
|
|
|
@@ -8934,7 +8955,7 @@ Partial Class Ventas
|
|
|
|
|
#Region " GUARDAR - VENTA, PREPOLIZAS, INV, ESTIMACIONES, AC, NOTA DE CRÉDITO "
|
|
|
|
|
Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, 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 EsNCAmortizacion As Boolean = False)
|
|
|
|
|
ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False)
|
|
|
|
|
|
|
|
|
|
Dim Msgok As New StringBuilder
|
|
|
|
|
Dim CveAlmacenTraspasoOrigen As Integer = -1
|
|
|
|
|
@@ -9255,10 +9276,10 @@ Partial Class Ventas
|
|
|
|
|
|
|
|
|
|
If ErrorList.Count = 0 Then
|
|
|
|
|
'prepoliza
|
|
|
|
|
GuardarVentaPrePolizas(ObjConta, factura, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion)
|
|
|
|
|
GuardarVentaPrePolizas(ObjConta, factura, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento)
|
|
|
|
|
If ErrorList.Count = 0 Then
|
|
|
|
|
'inventarios
|
|
|
|
|
If Not EsNCAmortizacion Then
|
|
|
|
|
If Not EsNCAmortizacion AndAlso Not NCDescuento Then
|
|
|
|
|
If GuardarVentaInventarios(ObjInventario, ObjConta, factura) Then
|
|
|
|
|
ErrorList.Add("Ocurrio un error al Guardar Inventario")
|
|
|
|
|
End If
|
|
|
|
|
@@ -9284,7 +9305,7 @@ Partial Class Ventas
|
|
|
|
|
End Sub
|
|
|
|
|
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 Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False)
|
|
|
|
|
ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False)
|
|
|
|
|
|
|
|
|
|
Dim CveIE As Integer = -1
|
|
|
|
|
Dim DT As DataTable = Nothing
|
|
|
|
|
@@ -9303,7 +9324,7 @@ Partial Class Ventas
|
|
|
|
|
If DdlTipoComprobante.SelectedValue <> "Cot" Then
|
|
|
|
|
If factura.CvePrePoliza > 0 Then
|
|
|
|
|
|
|
|
|
|
If ProcesoPrepolizas(ObjConta, factura, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion) Then
|
|
|
|
|
If ProcesoPrepolizas(ObjConta, factura, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento) 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")
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
@@ -9314,7 +9335,7 @@ Partial Class Ventas
|
|
|
|
|
End Sub
|
|
|
|
|
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,
|
|
|
|
|
ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False) As Boolean
|
|
|
|
|
ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False) As Boolean
|
|
|
|
|
Try
|
|
|
|
|
Dim DT As DataTable
|
|
|
|
|
Dim CvePlantilaPoliza As Integer
|
|
|
|
|
@@ -9960,8 +9981,16 @@ Partial Class Ventas
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(344) = "1" Then
|
|
|
|
|
If ListaRemisionesNC IsNot Nothing Then
|
|
|
|
|
For Each ObjRNC As Modelos.Factura In ListaRemisionesNC
|
|
|
|
|
Dim ListaNC As List(Of Modelos.Factura) = Nothing
|
|
|
|
|
|
|
|
|
|
If NCDescuento Then
|
|
|
|
|
ListaNC = ListaNCDesc
|
|
|
|
|
Else
|
|
|
|
|
ListaNC = ListaRemisionesNC
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If ListaNC IsNot Nothing Then
|
|
|
|
|
For Each ObjRNC As Modelos.Factura In ListaNC
|
|
|
|
|
If ObjRNC.TipoDocto = "RNC" Then
|
|
|
|
|
importeMovimiento = ObjRNC.TotalRemNCAplicado * -1
|
|
|
|
|
importeMX = importeMovimiento * tipoCambio * Multiplicador
|
|
|
|
|
@@ -10101,7 +10130,7 @@ Partial Class Ventas
|
|
|
|
|
|
|
|
|
|
importeMovimiento = 0
|
|
|
|
|
Case 150 'Descuento sobre ventas
|
|
|
|
|
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion Then
|
|
|
|
|
If (ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion) OrElse NCDescuento Then
|
|
|
|
|
|
|
|
|
|
Dim ConceptoContableAplicar = 150
|
|
|
|
|
Dim CveVentaAplicar = ObjFactura.CveVenta
|
|
|
|
|
@@ -13815,6 +13844,13 @@ Partial Class Ventas
|
|
|
|
|
UpINV.Update()
|
|
|
|
|
UPPPS.Update()
|
|
|
|
|
End Sub
|
|
|
|
|
Private Sub CargaPorcentajeMarcas()
|
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
|
|
|
If ObjPS.GetPorcentajeMarcas(CveCliente) Then
|
|
|
|
|
DtPorcentajeMarcas = ObjPS.DtResultados.Copy()
|
|
|
|
|
End If
|
|
|
|
|
ObjPS.Dispose()
|
|
|
|
|
End Sub
|
|
|
|
|
Private Function AgregarProductoServicio(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
|
|
|
|
|
PU As Decimal, Descuento As Decimal,
|
|
|
|
|
CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String,
|
|
|
|
|
@@ -13891,13 +13927,6 @@ Partial Class Ventas
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If Not ClienteDesglosaIEPS Then
|
|
|
|
|
If Not RegeneraIEPS Then
|
|
|
|
|
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString.ToDecimal)
|
|
|
|
|
End If
|
|
|
|
|
DrPS("IEPSPorcentaje") = 0
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
'verifica si tiene ventaminima
|
|
|
|
|
If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then
|
|
|
|
|
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
|
|
|
|
|
@@ -13907,6 +13936,56 @@ Partial Class Ventas
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If Not ClienteDesglosaIEPS Then
|
|
|
|
|
If Not RegeneraIEPS Then
|
|
|
|
|
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString.ToDecimal)
|
|
|
|
|
End If
|
|
|
|
|
DrPS("IEPSPorcentaje") = 0
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
'VERIFICA SI APLICAN CONDICIONES COMERCIALES
|
|
|
|
|
If DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then
|
|
|
|
|
'VERIFICA SI EL PRODUCTO TIENE ESPECIFICADA UNA MARCA
|
|
|
|
|
If Not String.IsNullOrEmpty(DrPS("CveMarca").ToString()) AndAlso DrPS("CveMarca").ToString().ToEntero() > 0 Then
|
|
|
|
|
Dim RowPorcentaje = DtPorcentajeMarcas.FiltroPrimero($"CveMarca={DrPS("CveMarca").ToString()}")
|
|
|
|
|
'REALIZA LOS DESCUENTOS DE ACUERDO AL PORCENTAJE POR MARCA
|
|
|
|
|
If RowPorcentaje IsNot Nothing Then
|
|
|
|
|
Dim PorcentajeProducto = RowPorcentaje("PorcentajeProducto").ToString().ToDecimal() / 100D
|
|
|
|
|
Dim PorcentajeProducto2 = RowPorcentaje("PorcentajeProducto2").ToString().ToDecimal() / 100D
|
|
|
|
|
Dim PorcentajeProducto3 = RowPorcentaje("PorcentajeProducto3").ToString().ToDecimal() / 100D
|
|
|
|
|
|
|
|
|
|
Dim TotalInicial = (Cantidad * (PU)) - Descuento
|
|
|
|
|
Dim TotalFinal = TotalInicial
|
|
|
|
|
'SI APLICA EL PRIMER DESCUENTO
|
|
|
|
|
If PorcentajeProducto > 0 Then
|
|
|
|
|
Dim Descuento1 = TotalInicial * PorcentajeProducto
|
|
|
|
|
Dim Total2 = (TotalInicial - Descuento1)
|
|
|
|
|
|
|
|
|
|
'SI APLICA EL SEGUNDO DESCUENTO
|
|
|
|
|
If PorcentajeProducto2 > 0 Then
|
|
|
|
|
Dim Descuento2 = Total2 * PorcentajeProducto2
|
|
|
|
|
Dim Total3 = (Total2 - Descuento2)
|
|
|
|
|
|
|
|
|
|
'SI APLICA EL TERCER DESCUENTO
|
|
|
|
|
If PorcentajeProducto3 > 0 Then
|
|
|
|
|
Dim Descuento3 = Total3 * PorcentajeProducto3
|
|
|
|
|
TotalFinal = Total3 - Descuento3
|
|
|
|
|
Else
|
|
|
|
|
TotalFinal = Total3
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
TotalFinal = Total2
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
TotalFinal = TotalInicial
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Descuento += ((Cantidad * PU) - TotalFinal)
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
|
|
|
|
|
|
|
|
|
|
Row("PU") = PU
|
|
|
|
|
@@ -13939,8 +14018,6 @@ Partial Class Ventas
|
|
|
|
|
|
|
|
|
|
Row("IVA") = Row("PorcentajeIVA")
|
|
|
|
|
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales)
|
|
|
|
|
Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales)
|
|
|
|
|
Row("PorcentajeRetIVA") = ClienteRetIVA
|
|
|
|
|
@@ -14575,7 +14652,7 @@ Partial Class Ventas
|
|
|
|
|
ConfiguraTipoDocto()
|
|
|
|
|
End If
|
|
|
|
|
End Sub
|
|
|
|
|
Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True)
|
|
|
|
|
Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True, Optional NCDescuento As Boolean = False)
|
|
|
|
|
|
|
|
|
|
Dim TotalSubTotal As Decimal = TmpDT.SUM("TotalImporte").ToDecimal
|
|
|
|
|
Dim TotalDescuentos As Decimal = TmpDT.SUM("Descuento").ToDecimal
|
|
|
|
|
@@ -16721,15 +16798,30 @@ Partial Class Ventas
|
|
|
|
|
Private Function ValidaPagosContado() As Boolean
|
|
|
|
|
Dim Retorno = False
|
|
|
|
|
|
|
|
|
|
If (UsuarioActual.CveEmpresa = 140) AndAlso (Not PermiteCredito) AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) And TxtTotal.Text.ToDecimal > 0 Then
|
|
|
|
|
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso (UsuarioActual.CveEmpresa = 140) AndAlso (Not PermiteCredito) AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) And TxtTotal.Text.ToDecimal > 0 Then
|
|
|
|
|
Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia)
|
|
|
|
|
Retorno = True
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
|
|
|
|
|
Dim TotalNC As Decimal = If(ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0, ListaNCDesc.Sum(Function(f) f.TotalRemNCAplicado), 0)
|
|
|
|
|
If TotalNC > 0 Then
|
|
|
|
|
If (DtPagos.SUM("Importe").ToString.ToDecimal + Total - TxtCambio.Text.ToDecimal) > TotalNC Then
|
|
|
|
|
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
|
|
|
|
|
Retorno = True
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
If (DtPagos.SUM("Importe").ToString.ToDecimal + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
|
|
|
|
|
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
|
|
|
|
|
Retorno = True
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
If (DtPagos.SUM("Importe").ToString.ToDecimal + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
|
|
|
|
|
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
|
|
|
|
|
Retorno = True
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Return Retorno
|
|
|
|
|
End Function
|
|
|
|
|
@@ -16931,7 +17023,7 @@ Partial Class Ventas
|
|
|
|
|
End Sub
|
|
|
|
|
Private Sub GeneraGlobalDTCliente()
|
|
|
|
|
Dim Objclientes As New ClsClientes
|
|
|
|
|
If Objclientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=-1,TipoCliente:=-1) Then
|
|
|
|
|
If Objclientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=-1, TipoCliente:=-1) Then
|
|
|
|
|
Application("GlobalDTCliente") = Objclientes.DtResultados
|
|
|
|
|
End If
|
|
|
|
|
Objclientes.Dispose()
|
|
|
|
|
@@ -20504,6 +20596,16 @@ Partial Class Ventas
|
|
|
|
|
ObjMovtos.Dispose()
|
|
|
|
|
GvRemisionesNC.DataBind()
|
|
|
|
|
End Sub
|
|
|
|
|
Private Sub CargaDescRNC()
|
|
|
|
|
Dim ObjMovtos As New ClsMovimientos()
|
|
|
|
|
If ObjMovtos.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, -1, TipoDocto:="RNC") Then
|
|
|
|
|
GvDescNC.DataSource = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act' AND CveVenta > 0", "Moneda, OrdenVencimiento, FechaVencimiento")
|
|
|
|
|
End If
|
|
|
|
|
ObjMovtos.Dispose()
|
|
|
|
|
GvDescNC.DataBind()
|
|
|
|
|
|
|
|
|
|
UpDescNC.Update()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Protected Sub GvCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
|
@@ -20540,8 +20642,13 @@ Partial Class Ventas
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
AplicarNC(DdlNCPS.SelectedValue.ToEntero)
|
|
|
|
|
|
|
|
|
|
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlNCPS.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
|
RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC")
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False)
|
|
|
|
|
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
|
|
|
If DrPS Is Nothing Then
|
|
|
|
|
Alert("Ocurrió un error al cargar la información del producto. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError)
|
|
|
|
|
Exit Sub
|
|
|
|
|
@@ -20556,11 +20663,6 @@ Partial Class Ventas
|
|
|
|
|
Exit Sub
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If DdlTipoComprobante.SelectedValue = "Ant" Then CveAnticipo = CveVenta
|
|
|
|
|
|
|
|
|
|
DdlTipoComprobante.SelectedValueExist("Egs")
|
|
|
|
|
|
|
|
|
|
'CREAMOS DT PARA UTILIZAR AL TIMBRAR
|
|
|
|
|
InicializaDTVentasNC()
|
|
|
|
|
|
|
|
|
|
@@ -20579,6 +20681,13 @@ Partial Class Ventas
|
|
|
|
|
DtImpuestos.AcceptChanges()
|
|
|
|
|
|
|
|
|
|
If AplicaNCMasiva Then
|
|
|
|
|
If NCDescuento Then
|
|
|
|
|
For Each Gvr As GridViewRow In GvDescNC.Rows
|
|
|
|
|
If Gvr.FCCheckBox("ChkAplicar").Checked Then
|
|
|
|
|
DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal), True, MissingSchemaAction.Ignore)
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
Else
|
|
|
|
|
For Each Gvr As GridViewRow In GvCxC.Rows
|
|
|
|
|
If Gvr.FCCheckBox("ChkCxC").Checked Then
|
|
|
|
|
DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal), True, MissingSchemaAction.Ignore)
|
|
|
|
|
@@ -20586,6 +20695,7 @@ Partial Class Ventas
|
|
|
|
|
CargaNCDT(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal)
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal)
|
|
|
|
|
End If
|
|
|
|
|
@@ -20613,16 +20723,25 @@ Partial Class Ventas
|
|
|
|
|
Exit Sub
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DtImpuestos = query.QueryToDataTable(False)
|
|
|
|
|
|
|
|
|
|
If Not NCDescuento Then
|
|
|
|
|
LimpiaDocumentoNC()
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero
|
|
|
|
|
Dim SubProyecto = DrSubProyecto("SubProyecto").ToString
|
|
|
|
|
Dim CveProyecto = DrSubProyecto("CveProyecto").ToString.ToEntero
|
|
|
|
|
Dim Proyecto = DrSubProyecto("Proyecto").ToString
|
|
|
|
|
|
|
|
|
|
AplicaNC = True
|
|
|
|
|
|
|
|
|
|
If Not NCDescuento Then
|
|
|
|
|
|
|
|
|
|
If DdlTipoComprobante.SelectedValue = "Ant" Then CveAnticipo = CveVenta
|
|
|
|
|
|
|
|
|
|
DdlTipoComprobante.SelectedValueExist("Egs")
|
|
|
|
|
|
|
|
|
|
For Each Dr As DataRow In DtImpuestos.Rows
|
|
|
|
|
AgregaTempDT(DrPS("CvePS").ToString.ToEntero, DrPS("PS").ToString, DrPS("Codigo").ToString, DrPS("PSCodigo").ToString, DrPS("CveTipoPS").ToString.ToEntero, DrPS("Inv_CveMetodoInventario").ToString.ToEntero,
|
|
|
|
|
DrPS("CveUM").ToString.ToEntero, DrPS("UnidadMedida").ToString, DrPS("CveClasificacion").ToString.ToEntero, DrPS("Clasificacion").ToString, CveProyecto, Proyecto, CveSubProyecto, SubProyecto,
|
|
|
|
|
@@ -20631,22 +20750,19 @@ Partial Class Ventas
|
|
|
|
|
DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1)
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
TrTipoRelacion.Visible = True
|
|
|
|
|
DdlTiposRelacion.SelectedValueExist("1")
|
|
|
|
|
|
|
|
|
|
GvPS.DataSource = TmpDT
|
|
|
|
|
GvPS.DataBind()
|
|
|
|
|
|
|
|
|
|
CalculaTotalesVenta(True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TrTipoRelacion.Visible = True
|
|
|
|
|
DdlTiposRelacion.SelectedValueExist("1")
|
|
|
|
|
|
|
|
|
|
'condicióon, en la que se verifica que el importe total de aplicación de la nota de crédito sea igual al del total de la nota de crédito, ej. saldo de la factura 1000.01 y la nota de crédito se generó po 1000.00
|
|
|
|
|
If Not AplicaNCMasiva Then
|
|
|
|
|
Dim TT As Decimal = TxtNCImporte.Text.ToDecimal
|
|
|
|
|
If TT > TxtTotal.Text.ToDecimal Then TT = TxtTotal.Text.ToDecimal
|
|
|
|
|
CargaNCDT(CveVenta, TT)
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
'verifica el tipo de cambio que se actualice
|
|
|
|
|
If DdlMoneda.SelectedValue <> "1" Then
|
|
|
|
|
@@ -20656,11 +20772,10 @@ Partial Class Ventas
|
|
|
|
|
UpPS.Update()
|
|
|
|
|
|
|
|
|
|
LBNotaCredito.Visible = False
|
|
|
|
|
RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC")
|
|
|
|
|
AplicaNC = True
|
|
|
|
|
|
|
|
|
|
CambiaTipoDocto()
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable
|
|
|
|
|
@@ -20684,8 +20799,6 @@ Partial Class Ventas
|
|
|
|
|
Else
|
|
|
|
|
Total = TxtTotal.Text.ToDecimal
|
|
|
|
|
SubTotal = TxtSubTotal.Text.ToDecimal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
|
|
|
|
|
|
@@ -22061,7 +22174,10 @@ Partial Class Ventas
|
|
|
|
|
Protected Sub BtnGuardarRemisiones_Click(sender As Object, e As EventArgs) Handles BtnGuardarRemisiones.Click
|
|
|
|
|
If GvRem.Rows.Count > 0 Or GvRemPS.Rows.Count > 0 Then
|
|
|
|
|
'Checa las facturas selecionadas
|
|
|
|
|
VerificaRemisiones(DTRemisiones)
|
|
|
|
|
If Not VerificaRemisiones(DTRemisiones) Then
|
|
|
|
|
Alert("La cantidad/total debe ser mayor que 0", TipoMensaje.MsgAdvertencia)
|
|
|
|
|
Exit Sub
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Dim dtSeleccionadas As DataTable = DTRemisiones.FiltraParametros("Aplicado = True")
|
|
|
|
|
Dim CveContrato = DTRemisiones.FiltroPrimeroValor("CveContrato", "Aplicado = True").ToEntero
|
|
|
|
|
@@ -22231,8 +22347,17 @@ Partial Class Ventas
|
|
|
|
|
|
|
|
|
|
RegistraScript("$('#DivRemisiones').modal('hide');", "DivRemisionesHide")
|
|
|
|
|
End Sub
|
|
|
|
|
Private Sub VerificaRemisiones(ByRef dt As DataTable)
|
|
|
|
|
Private Function VerificaRemisiones(ByRef dt As DataTable) As Boolean
|
|
|
|
|
Dim Valido As Boolean = True
|
|
|
|
|
If ChkRemProductos.Checked Then
|
|
|
|
|
|
|
|
|
|
Valido = Not (From GvRow In GvRemPS.Rows.Cast(Of GridViewRow)
|
|
|
|
|
Let Cantidad = GvRow.FCTextBox("TxtCantidadRem").Text.Trim().ToEntero(), Aplicar = GvRow.FCCheckBox("Chk").Checked
|
|
|
|
|
Where GvRow.RowType = DataControlRowType.DataRow AndAlso Cantidad <= 0 AndAlso Aplicar
|
|
|
|
|
Select GvRow
|
|
|
|
|
).Any
|
|
|
|
|
|
|
|
|
|
If Valido Then
|
|
|
|
|
For Each Gvr As GridViewRow In GvRemPS.Rows
|
|
|
|
|
If Gvr.RowType = DataControlRowType.DataRow Then
|
|
|
|
|
Dim ChkAplicar As CheckBox = Gvr.FCCheckBox("Chk")
|
|
|
|
|
@@ -22244,6 +22369,8 @@ Partial Class Ventas
|
|
|
|
|
dt.AcceptChanges()
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
For Each Gvr As GridViewRow In GvRem.Rows
|
|
|
|
|
If Gvr.RowType = DataControlRowType.DataRow Then
|
|
|
|
|
@@ -22257,7 +22384,9 @@ Partial Class Ventas
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
End If
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Return Valido
|
|
|
|
|
End Function
|
|
|
|
|
Private Sub CargaConceptosRemisionPorFacturar(CveRemisiones As String, TipoCargas As Integer)
|
|
|
|
|
Dim ObjClientes As New ClsClientes
|
|
|
|
|
If ObjClientes.GetVentasRemisionesTotales(CveCliente, CveRemisiones, TipoCargas) Then
|
|
|
|
|
@@ -22877,7 +23006,7 @@ Partial Class Ventas
|
|
|
|
|
CambiaTipoDocto()
|
|
|
|
|
CambiaSucursalGeneral()
|
|
|
|
|
CargaAnticipos(CveCliente)
|
|
|
|
|
CargaRestriccionesCreditoCliente()
|
|
|
|
|
CargaRestriccionesCreditoCliente(CveVenta:=-1)
|
|
|
|
|
UpParametros.Update()
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
@@ -23274,4 +23403,158 @@ Partial Class Ventas
|
|
|
|
|
RegistraScript("CerrarModalRemNC();")
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
Protected Sub LnkDescuentosRNC_Click(sender As Object, e As EventArgs)
|
|
|
|
|
CargaDescRNC()
|
|
|
|
|
RegistraScript("$('#ModalAplicarDescuentoNC').modal('show'); ")
|
|
|
|
|
End Sub
|
|
|
|
|
Protected Sub BtnAplicarDesc_Click(sender As Object, e As EventArgs)
|
|
|
|
|
Dim CveSATNC = "84111506"
|
|
|
|
|
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
|
|
|
|
|
|
|
|
|
|
If DrPS Is Nothing Then
|
|
|
|
|
Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
|
|
|
Exit Sub
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
AplicaNCMasiva = True
|
|
|
|
|
|
|
|
|
|
If ListaNCDesc Is Nothing Then
|
|
|
|
|
ListaNCDesc = New List(Of Modelos.Factura)
|
|
|
|
|
Else
|
|
|
|
|
ListaNCDesc.Clear()
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Dim TotalRemNCAplicado As Decimal = 0
|
|
|
|
|
For Each GvRow As GridViewRow In GvDescNC.Rows
|
|
|
|
|
If GvRow.RowType = DataControlRowType.DataRow Then
|
|
|
|
|
If GvRow.FCCheckBox("ChkAplicar").Checked Then
|
|
|
|
|
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
|
|
|
|
|
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
|
|
|
|
|
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
|
|
|
|
|
|
|
|
|
|
If RemNC.TotalRemNCAplicado <= 0 Then
|
|
|
|
|
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
|
|
|
|
|
ListaNCDesc.Clear()
|
|
|
|
|
Exit Sub
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
ListaNCDesc.Add(RemNC)
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
LblDescuentosRNC.Text = TotalRemNCAplicado.FormatoNumero
|
|
|
|
|
LblTotalNC.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado).FormatoNumero
|
|
|
|
|
|
|
|
|
|
Dim CvePS = DrPS("CvePS").ToString().ToEntero()
|
|
|
|
|
|
|
|
|
|
AplicarNC(CvePS, True)
|
|
|
|
|
|
|
|
|
|
UpPS.Update()
|
|
|
|
|
|
|
|
|
|
RegistraScript("$('#ModalAplicarDescuentoNC').modal('hide'); ")
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Protected Function CreaDTDetalleNCDescuento() As DataTable
|
|
|
|
|
Dim Dt As DataTable = TmpDT.Clone()
|
|
|
|
|
Dt.Rows.Clear()
|
|
|
|
|
|
|
|
|
|
Dim CveSATNC = "84111506"
|
|
|
|
|
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
|
|
|
|
|
|
|
|
|
|
If DrPS Is Nothing Then
|
|
|
|
|
Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
|
|
|
Return Dt
|
|
|
|
|
End If
|
|
|
|
|
Dim CvePS = DrPS("CvePS").ToString().ToEntero()
|
|
|
|
|
|
|
|
|
|
Dim TotalCalculableImpuestos As Decimal = 0
|
|
|
|
|
Dim PU = Math.Round(ListaNCDesc.Sum(Function(RNC) RNC.TotalRemNCAplicado), 6) ' el precio unitario puede llevar hasta 6 decimales permitidos
|
|
|
|
|
Dim Cantidad As Decimal = 1
|
|
|
|
|
Dim Descuento As Decimal = 0
|
|
|
|
|
|
|
|
|
|
Dim Row As DataRow = Dt.NewRow()
|
|
|
|
|
Row("CveProyecto") = DdlProyecto.SelectedValue.ToEntero()
|
|
|
|
|
Row("Proyecto") = DdlProyecto.SelectedItem.Text
|
|
|
|
|
Row("CveSubProyecto") = DdlSubProyecto.SelectedValue.ToEntero()
|
|
|
|
|
Row("SubProyecto") = DdlSubProyecto.SelectedItem.Text
|
|
|
|
|
Row("SerieLote") = "-1"
|
|
|
|
|
Row("TiempoEntrega") = ""
|
|
|
|
|
Row("Orden") = Dt.Rows.Count + 1
|
|
|
|
|
Row("Cantidad") = Cantidad
|
|
|
|
|
Row("CveUM") = DrPS("CveUM").ToString().ToEntero()
|
|
|
|
|
Row("UM") = ""
|
|
|
|
|
Row("CveClasificacion") = DrPS("CveClasificacion").ToString().ToEntero()
|
|
|
|
|
Row("Clasificacion") = ""
|
|
|
|
|
Row("CvePS") = CvePS
|
|
|
|
|
Row("Obs") = ""
|
|
|
|
|
|
|
|
|
|
TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
|
|
|
|
|
|
|
|
|
|
Row("PU") = PU
|
|
|
|
|
Row("Codigo") = DrPS("Codigo")
|
|
|
|
|
Row("NoIdentificacion") = DrPS("Codigo")
|
|
|
|
|
Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
|
|
|
|
|
Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
|
|
|
|
|
Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
|
|
|
|
|
Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
|
|
|
|
|
|
|
|
|
|
If Modalidad = "U" Then
|
|
|
|
|
Row("Consec") = Index
|
|
|
|
|
Else
|
|
|
|
|
Row("Consec") = TmpDT.Rows.Count + 1
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Row("PS") = DrPS("PS")
|
|
|
|
|
Row("CodigoPS") = DrPS("PSCodigo").ToString
|
|
|
|
|
Row("CveTipoPS") = DrPS("CveTipoPS")
|
|
|
|
|
Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
|
|
|
|
|
Row("CveTamaño") = DrPS("CveTamaño")
|
|
|
|
|
Row("CveClasificacion") = DrPS("CveClasificacion")
|
|
|
|
|
Row("Clasificacion") = DrPS("Clasificacion")
|
|
|
|
|
|
|
|
|
|
If DrPS("IVA").ToString.Contiene("-1", "") Then
|
|
|
|
|
Row("PorcentajeIVA") = PorcentajeIVA
|
|
|
|
|
Else
|
|
|
|
|
Row("PorcentajeIVA") = DrPS("IVA")
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Row("IVA") = Row("PorcentajeIVA")
|
|
|
|
|
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
|
|
|
|
|
Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales)
|
|
|
|
|
Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales)
|
|
|
|
|
Row("PorcentajeRetIVA") = ClienteRetIVA
|
|
|
|
|
Row("PorcentajeRetISR") = ClienteRetISR
|
|
|
|
|
Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
|
|
|
|
|
Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
|
|
|
|
|
Row("IEPS") = Row("ImporteIEPS")
|
|
|
|
|
Row("Descuento") = Math.Round(Descuento, NumeroDecimales)
|
|
|
|
|
Row("TipoDescuento") = HdnTipoDescuento.Value
|
|
|
|
|
Row("Total") = (Cantidad * PU)
|
|
|
|
|
Row("TotalImporte") = Math.Round(Cantidad * PU, NumeroDecimales)
|
|
|
|
|
|
|
|
|
|
Row("SATClaveProdServ") = DrPS("SATClavePS")
|
|
|
|
|
Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
|
|
|
|
|
|
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
|
|
|
Row("CvePresupuestoIngreso") = Me.DdlFuenteRecaudacion.SelectedValue
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Row("EntregaDirecta") = -1
|
|
|
|
|
'Contratos
|
|
|
|
|
Row("CveContratoDetalle") = -1
|
|
|
|
|
Row("CveVentaDetalle") = -1
|
|
|
|
|
Row("CveMovimientoDetallePedido") = -1
|
|
|
|
|
Row("CveOrdenCompraDetalle") = -1
|
|
|
|
|
Row("CveVentaDetalleRemision") = -1
|
|
|
|
|
Row("CveVentaDetalleCotizacion") = -1
|
|
|
|
|
Row("CveVentaDetallePedido2") = -1
|
|
|
|
|
Row("CuentaPredial") = "-1"
|
|
|
|
|
Row("Consec") = 1
|
|
|
|
|
|
|
|
|
|
'RECARGAR GV
|
|
|
|
|
Dt.Rows.Add(Row)
|
|
|
|
|
|
|
|
|
|
Return Dt
|
|
|
|
|
End Function
|
|
|
|
|
End Class
|