-cambios en conceptos
This commit is contained in:
@@ -9360,7 +9360,7 @@ Partial Class Ventas
|
||||
|
||||
Dim CveTipoRetencion As Integer = 0
|
||||
If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then
|
||||
CveTipoRetencion = DdlTipoRetencion.SelectedValue.ToEntero()
|
||||
CveTipoRetencion = factura.CveTipoRetencion
|
||||
End If
|
||||
|
||||
factura.CvePrePoliza = ObjConta.AddPrePolizas("Ventas/GuardarVenta", factura.CvePlantillaPoliza, factura.Total, factura.Total, factura.CveMoneda, factura.Fecha, If(CveEmpresaCRM > 0, LblEmpresaCRM.Text, factura.Cliente.Nombre), factura.CveUsuario, factura.CveEmpresa)
|
||||
@@ -19169,7 +19169,7 @@ Partial Class Ventas
|
||||
Conexion.Open()
|
||||
Dim cmd = Conexion.CreateCommand()
|
||||
cmd.CommandType = CommandType.Text
|
||||
cmd.CommandText = "Select * FROM [Hoja1$]"
|
||||
cmd.CommandText = "Select * FROM [Hoja1$] WHERE Cantidad >=1"
|
||||
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
DataAdapter.Fill(dt)
|
||||
Case Else
|
||||
@@ -19222,6 +19222,8 @@ Partial Class Ventas
|
||||
|
||||
dt.TableName = "Datos"
|
||||
|
||||
Dim DtSubProyecto As DataTable = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
||||
DtSubProyecto.CaseSensitive = False
|
||||
If Not ErrorArchivo Then
|
||||
NumRow = 1
|
||||
Dim RowNoEncontrados As String = ""
|
||||
@@ -19246,8 +19248,6 @@ Partial Class Ventas
|
||||
NumRow = NumRow + 1
|
||||
|
||||
If Proyecto <> "" Then
|
||||
Dim DtSubProyecto As DataTable = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
||||
DtSubProyecto.CaseSensitive = False
|
||||
DrProyecto = DtSubProyecto.FiltroPrimero($"(SubProyecto) = '{Proyecto}'")
|
||||
If DrProyecto IsNot Nothing Then
|
||||
CveSubProyecto = DrProyecto("CveSubProyecto").ToString.ToEntero
|
||||
@@ -19260,38 +19260,80 @@ Partial Class Ventas
|
||||
End If
|
||||
|
||||
If Codigo <> "" Then
|
||||
Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c)
|
||||
If StrArray.Length > 0 Then
|
||||
If CBool(StrArray(0)) = True Then
|
||||
CvePS = StrArray(1).ToEntero
|
||||
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa, Codigo:=Codigo) Then
|
||||
If ObjPS.CvePS > 0 Then
|
||||
CvePS = ObjPS.CvePS
|
||||
CveUM = ObjPS.CveUnidadMedida
|
||||
|
||||
Else
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
Else
|
||||
RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
End If
|
||||
End Using
|
||||
|
||||
'Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c)
|
||||
'If StrArray.Length > 0 Then
|
||||
' If CBool(StrArray(0)) = True Then
|
||||
' CvePS = StrArray(1).ToEntero
|
||||
' Else
|
||||
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
' End If
|
||||
'End If
|
||||
ElseIf CodigoBarras <> "" Then
|
||||
Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c)
|
||||
If StrArray.Length > 0 Then
|
||||
If CBool(StrArray(0)) = True Then
|
||||
CvePS = StrArray(1).ToEntero
|
||||
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa, CodigoBarras:=CodigoBarras) Then
|
||||
If ObjPS.CvePS > 0 Then
|
||||
CvePS = ObjPS.CvePS
|
||||
CveUM = ObjPS.CveUnidadMedida
|
||||
|
||||
Else
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
Else
|
||||
RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
End If
|
||||
End Using
|
||||
'Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c)
|
||||
'If StrArray.Length > 0 Then
|
||||
' If CBool(StrArray(0)) = True Then
|
||||
' CvePS = StrArray(1).ToEntero
|
||||
' Else
|
||||
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
' End If
|
||||
'End If
|
||||
ElseIf ProductoServicio <> "" Then
|
||||
Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c)
|
||||
If StrArray.Length > 0 Then
|
||||
If CBool(StrArray(0)) = True Then
|
||||
CvePS = StrArray(1).ToEntero
|
||||
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa, CodigoBarras:=CodigoBarras) Then
|
||||
If ObjPS.CvePS > 0 Then
|
||||
CvePS = ObjPS.CvePS
|
||||
CveUM = ObjPS.CveUnidadMedida
|
||||
Else
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
Else
|
||||
RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
End If
|
||||
End Using
|
||||
'Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c)
|
||||
'If StrArray.Length > 0 Then
|
||||
' If CBool(StrArray(0)) = True Then
|
||||
' CvePS = StrArray(1).ToEntero
|
||||
' Else
|
||||
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
' End If
|
||||
'End If
|
||||
Else
|
||||
RowNoEncontrados &= "<\BR> - En la fila " & NumRow & " no se especificó código, código de barras ó descripción."
|
||||
End If
|
||||
|
||||
If CvePS > 0 Then
|
||||
CveUM = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero
|
||||
'CveUM = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero
|
||||
|
||||
AgregarProductoServicio(Cantidad, CveUM, UM, -1, "",
|
||||
CvePS, HdnPS.Value, Observaciones, PrecioUnitario, HdnDescuento.Value.ToDecimal,
|
||||
@@ -19343,17 +19385,21 @@ Partial Class Ventas
|
||||
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
||||
End If
|
||||
End Sub
|
||||
Private Function GetPS(Opt As String, Valor As String) As String
|
||||
Dim StrReturn As String = String.Empty
|
||||
Dim CvePS As Integer = 0
|
||||
CvePS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString.ToEntero
|
||||
If CvePS > 0 Then
|
||||
StrReturn = "True|" & CvePS.ToString
|
||||
Else
|
||||
StrReturn = "False| - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt
|
||||
End If
|
||||
Return StrReturn
|
||||
End Function
|
||||
|
||||
|
||||
'Private dtps As DataTable = Nothing
|
||||
'Private Function GetPS(Opt As String, Valor As String) As String
|
||||
' Dim StrReturn As String = String.Empty
|
||||
' Dim CvePS As Integer = 0
|
||||
' If dtps Is Nothing Then dtps = GlobalDTPS(UsuarioActual.CveEmpresa)
|
||||
' CvePS = dtps.FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString().ToEntero()
|
||||
' If CvePS > 0 Then
|
||||
' StrReturn = "True|" & CvePS.ToString
|
||||
' Else
|
||||
' StrReturn = "False| - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt
|
||||
' End If
|
||||
' Return StrReturn
|
||||
'End Function
|
||||
#End Region
|
||||
|
||||
#Region "P E D I D O S"
|
||||
@@ -21553,13 +21599,22 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
DdlTipoComprobante.SelectedValue = "Egs"
|
||||
Dim AplicaImpuestosLocales As Boolean = False
|
||||
|
||||
AplicarNC(DdlNCPS.SelectedValue.ToEntero, EsNCAmortizacion:=ChkAplicaNCAnticipo.Checked)
|
||||
Dim ObjCliente As New ClsClientes
|
||||
If ObjCliente.GetClienteImpuestosLocales(CveCliente) Then
|
||||
'se cargan impuestos locales
|
||||
Dim DtClienteImpuesto As DataTable = ObjCliente.DtResultados.FiltraParametros("Seleccionado = 1", "Orden")
|
||||
AplicaImpuestosLocales = (DtClienteImpuesto IsNot Nothing AndAlso DtClienteImpuesto.Rows.Count > 0)
|
||||
End If
|
||||
ObjCliente.Dispose()
|
||||
|
||||
AplicarNC(DdlNCPS.SelectedValue.ToEntero, EsNCAmortizacion:=ChkAplicaNCAnticipo.Checked, AplicaImpuestosLocales:=AplicaImpuestosLocales)
|
||||
|
||||
RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC")
|
||||
End Sub
|
||||
|
||||
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False)
|
||||
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True)
|
||||
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)
|
||||
@@ -21576,6 +21631,12 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not AplicaImpuestosLocales Then
|
||||
TmpDTImpuestos.Rows.Clear()
|
||||
GvImpuestosLocales2.DataSource = TmpDTImpuestos
|
||||
GvImpuestosLocales2.DataBind()
|
||||
End If
|
||||
|
||||
'CREAMOS DT PARA UTILIZAR AL TIMBRAR
|
||||
InicializaDTVentasNC()
|
||||
|
||||
@@ -21597,13 +21658,13 @@ Partial Class Ventas
|
||||
If AplicaNCMasiva Then
|
||||
If NCDescuento Then
|
||||
For Each RNC In ListaNCDesc
|
||||
DtImpuestos.Merge(CargaDtImpuestosNC(RNC.CveVenta, RNC.TotalRemNCAplicado, NCDescuento:=True), True, MissingSchemaAction.Ignore)
|
||||
DtImpuestos.Merge(CargaDtImpuestosNC(RNC.CveVenta, RNC.TotalRemNCAplicado, NCDescuento:=True, AplicaImpuestosLocales:=AplicaImpuestosLocales), True, MissingSchemaAction.Ignore)
|
||||
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)
|
||||
DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal, AplicaImpuestosLocales:=AplicaImpuestosLocales), True, MissingSchemaAction.Ignore)
|
||||
'CARGA FACTURA A LA CUAL SE APLICA LA NC
|
||||
AcumuladoNC += Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal
|
||||
CargaNCDT(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal)
|
||||
@@ -21611,7 +21672,7 @@ Partial Class Ventas
|
||||
Next
|
||||
End If
|
||||
Else
|
||||
DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal)
|
||||
DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal, AplicaImpuestosLocales:=AplicaImpuestosLocales)
|
||||
|
||||
If EsNCAmortizacion Then
|
||||
If DtAnticipoAmortizacion Is Nothing Then
|
||||
@@ -21713,7 +21774,7 @@ Partial Class Ventas
|
||||
GvPS.DataSource = TmpDT
|
||||
GvPS.DataBind()
|
||||
|
||||
CalculaTotalesVenta(True)
|
||||
CalculaTotalesVenta(RecalculaImpuestosLocales:=AplicaImpuestosLocales)
|
||||
|
||||
TrTipoRelacion.Visible = True
|
||||
DdlTiposRelacion.SelectedValueExist("1")
|
||||
@@ -21738,14 +21799,21 @@ Partial Class Ventas
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal, Optional NCDescuento As Boolean = False) As DataTable
|
||||
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal, Optional NCDescuento As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True) As DataTable
|
||||
Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
|
||||
|
||||
Dim TmpDT As DataTable = Nothing
|
||||
Dim TmpDTImpuestos As DataTable = Nothing
|
||||
Dim ObjVentas As New ClsVentas
|
||||
|
||||
If ObjVentas.GetVentaImpuestosLocales(CveVentaNC) Then
|
||||
If ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||
TmpDTImpuestos = ObjVentas.DtResultados.Copy()
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjVentas.GetVentaDetalle(CveVentaNC) Then
|
||||
TmpDT = ObjVentas.DtResultados
|
||||
TmpDT = ObjVentas.DtResultados.Copy()
|
||||
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||
End If
|
||||
@@ -21775,10 +21843,19 @@ Partial Class Ventas
|
||||
Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100
|
||||
Dim FiltroStr As String = ""
|
||||
Dim importePuTemp As Decimal = 0
|
||||
Dim TotalImpuestosLocales As Decimal = 0
|
||||
If TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then
|
||||
TotalImpuestosLocales = TmpDTImpuestos.SUM("Importe").ToDecimal()
|
||||
End If
|
||||
|
||||
For Each Dr As DataRow In DtImpuestosLocal.Rows
|
||||
FiltroStr = String.Format("ISNULL(PorcentajeIVA,0) = {0} AND ISNULL(PorcentajeRetIVA,0) = {1} AND ISNULL(PorcentajeRetISR,0) = {2} AND ISNULL(PorcentajeIEPS,0) = {3} AND ISNULL(CveSubProyecto,0) = {4} ", Dr("PorcentajeIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("CveSubProyecto"))
|
||||
importePuTemp = (Porcentaje * (TmpDT.SUM("TotalImporte", FiltroStr).ToDecimal() - TmpDT.SUM("Descuento", FiltroStr).ToDecimal()))
|
||||
|
||||
If Not AplicaImpuestosLocales Then
|
||||
importePuTemp = importePuTemp - TotalImpuestosLocales
|
||||
End If
|
||||
|
||||
Dr("ImporteTotal") = importePuTemp.RoundSQL(2)
|
||||
|
||||
|
||||
@@ -21795,9 +21872,13 @@ Partial Class Ventas
|
||||
Dr("ImportePU") = importePuTemp.RoundSQL(6) 'Dr("ImporteTotal").ToString.ToDecimal.RoundSQL(2) '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal)
|
||||
Next
|
||||
|
||||
|
||||
Dim importeNC = (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR"))
|
||||
If AplicaImpuestosLocales Then
|
||||
Importe = Importe + TotalImpuestosLocales
|
||||
End If
|
||||
'codigo para ajuste de centavo, si el importe total no cuadra con los totales
|
||||
Dim difTmp As Decimal = Importe - (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR"))
|
||||
Dim difTmp As Decimal = Importe - importeNC
|
||||
|
||||
If Math.Abs(difTmp) >= 0.01 Then
|
||||
'asusto la diferencia en el último concepto
|
||||
Dim ImporteAjustado As Decimal = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString.ToDecimal + difTmp
|
||||
|
||||
Reference in New Issue
Block a user