This commit is contained in:
janeth arvizu
2019-11-22 12:24:13 -07:00
12 changed files with 2583 additions and 2563 deletions

View File

@@ -1716,7 +1716,7 @@ Partial Class PV
End If
End If
ObjCliente.Dispose()
UPCondicionesPago.Update()
End Sub
Private Sub CambiaSucursal()

View File

@@ -1003,7 +1003,9 @@
</table>
<%--</asp:Panel>--%>
<asp:GridView ID="GvPS" GridLines="None" runat="server" data-tableheader="#tbps" ShowHeader="true" AutoGenerateColumns="False" DataKeyNames="Consec,CvePS,Total, IEPS, CveClasificacion,CveUM,CveProyecto,CveSubProyecto,TipoDocto,PS,Obs,Cantidad,PU,Descuento,IVA,CantidadInventario,CantidadFacturadaRem,CveVentaDetalle" CssClass="table table-striped table-advance table-hover Widthall Sortable mysmallbtn ScrollAD" Style="min-width: 980px;">
<asp:GridView ID="GvPS" GridLines="None" runat="server" data-tableheader="#tbps" ShowHeader="true" AutoGenerateColumns="False"
DataKeyNames="Consec,CvePS,Total, IEPS, CveClasificacion,CveUM,CveProyecto,CveSubProyecto,TipoDocto,PS,Obs,Cantidad,PU,Descuento,IVA,CantidadInventario,CantidadFacturadaRem,CveVentaDetalle"
CssClass="table table-striped table-advance table-hover Widthall Sortable mysmallbtn ScrollAD" Style="min-width: 980px;">
<Columns>
<%--0--%>
<asp:TemplateField ItemStyle-Font-Size="6pt">

View File

@@ -101,6 +101,14 @@ Partial Class Ventas
ViewState("TmpDT") = value
End Set
End Property
Private Property TmpDTDescNC As DataTable
Get
Return If(IsNothing(ViewState("TmpDTDescNC")), Nothing, CType(ViewState("TmpDTDescNC"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTDescNC") = value
End Set
End Property
Private Property TmpDTError As DataTable
Get
Return If(IsNothing(ViewState("TmpDTError")), Nothing, CType(ViewState("TmpDTError"), DataTable))
@@ -2528,10 +2536,6 @@ Partial Class Ventas
End If
TxtFecha.Enabled = True
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
TbDescuentosRNC.Visible = True
End If
CargaPorcentajeMarcas()
End Sub
@@ -4224,10 +4228,12 @@ Partial Class Ventas
End If
End If
End If
'Si es Empresa de Acumuladores
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
'Si ya se surtió y recibió
If DbRowVenta("SaldoAlmacen").ToString.ToDecimal > 0 And (DtUsados Is Nothing Or DtUsados.Rows.Count = 0) Then
If (DbRowVenta("SaldoAlmacen").ToString.ToDecimal > 0 And (DtUsados Is Nothing Or DtUsados.Rows.Count = 0)) OrElse (TmpDT.MAX("CveTipoPS") = "1") Then
BtnsFacturar.Visible = True
Else
BtnsFacturar.Visible = False
@@ -5682,12 +5688,12 @@ Partial Class Ventas
'Dim TipoDescuento As Integer
Dim Cantidad, PU, Descuento, CantidadInventario As Decimal
Dim CuentaPredial As String
Cantidad = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDecimal
PU = Math.Round(GvPS.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDecimal, 6)
Descuento = Math.Round(GvPS.Rows(e.RowIndex).FCTextBox("TxtDescuento").Text.ToDecimal, NumeroDecimales)
CuentaPredial = GvPS.Rows(e.RowIndex).FCTextBox("TxtPredial").Text.Trim
Dim CantidadOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Cantidad").ToDecimal()
Dim DatarowPS As DataRow = Nothing
DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString.ToEntero).FiltroPrimero("") ' Estado = -1
@@ -5708,8 +5714,9 @@ Partial Class Ventas
Dim CvePS As Integer = DatarowPS("CvePS").ToString.ToEntero
CantidadInventario = GvPS.Rows(e.RowIndex).DataKey("CantidadInventario").ToString.ToDecimal
Dim ValidaExistencia As Boolean = True
If CantidadInventario > 0 Then 'si ya hay algo surtido, que no valide existencia
If (CantidadInventario > 0) OrElse (Cantidad <= CantidadOriginal) Then 'si ya hay algo surtido, que no valide existencia
ValidaExistencia = False
End If
@@ -5747,7 +5754,7 @@ Partial Class Ventas
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) Then
If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS}") < TxtCantidad.Text.ToDouble Then
Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
@@ -7234,18 +7241,7 @@ Partial Class Ventas
'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
PreparaNCDescuento(ObjFacturaDevolucion)
Else
ObjFacturaDevolucion.DtDetalle = TmpDT
@@ -7403,8 +7399,9 @@ Partial Class Ventas
DtVentasNC.Rows(0)("TCCambioValuacion") = factura.TipoCambio
End If
ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion)
factura.Timbre = PreParaTimbre(ObjFacturaDevolucion)
factura.CveVentaPadre = Me.CveVenta
'Registramos la venta
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, factura.DtDetalle, -1, ObjContPaq, ObjBancos, EsNCAmortizacion:=True, NCDescuento:=True)
@@ -13726,6 +13723,10 @@ Partial Class Ventas
If ValidaAgregarPS(CvePS, DdlUnidadMedida.SelectedValue.ToEntero, TxtPrecio.Text.Trim.ToDouble, HdnTipoPS.Value.ToEntero) Then
If UsuarioActual.Empresa.Funcionalidad(572) = "1" AndAlso Not TbDescuentosRNC.Visible Then
TbDescuentosRNC.Visible = True
End If
If UsuarioActual.Empresa.Funcionalidad(507) = DdlPS.SelectedValue Then
CvePSAmortizacion = DdlPS.SelectedValue.ToEntero.ToEntero
End If
@@ -13760,8 +13761,57 @@ Partial Class Ventas
End If
End If
AgregarProductoServicio(TxtCantidad.Text.ToDecimal, DdlUnidadMedida.SelectedValue.ToEntero, DdlUnidadMedida.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text,
CvePS, "", TxtObsPS.Text.Trim, If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal), Descuento,
Dim Cantidad As Decimal = TxtCantidad.Text.ToDecimal
Dim PU As Decimal = If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal)
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1
'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
AgregarProductoServicio(Cantidad, DdlUnidadMedida.SelectedValue.ToEntero, DdlUnidadMedida.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text,
CvePS, "", TxtObsPS.Text.Trim, PU, Descuento,
DdlProyecto.SelectedValue.ToEntero, DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedItem.Text,
SerieLote:=If(DIVCod.Visible, TxtCodigoSerie.Text.Trim, ""), TiempoEntrega:=TxtTiempoEntrega.Text, CuentaPredial:=TxtCuentaPredial.Text.Trim, RegeneraIEPS:=ClienteDesglosaIEPS)
@@ -13987,49 +14037,49 @@ Partial Class Ventas
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
''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)
' 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 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
' '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)
' Descuento += ((Cantidad * PU) - TotalFinal)
End If
End If
' End If
' End If
End If
'End If
TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
Row("PU") = PU
@@ -15182,9 +15232,7 @@ Partial Class Ventas
If DtMovimientos.Rows.Count > 0 Then
Dim GeneroMovimientoAlmacen As Boolean = False
For Each dr As DataRow In DtMovimientos.Rows
'Obtenemos los Movimientos de salida
If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then
@@ -15210,32 +15258,69 @@ Partial Class Ventas
If ErrorList.Count = 0 AndAlso MovDetalle.Rows.Count > 0 Then
Dim CveMovimientoSalidaPorTraspaso As Integer = -1
'SALIDA DEFINITIVA DEL SISTEMA
If UsuarioActual.Empresa.Funcionalidad(575) = "1" Then
'Le damos salida normal
If ConSalida Then
'Le damos salida de apartado por traspaso
CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada)
GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 40, CveMoneda, CveRemision, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0
If Not CveMovimientoSalidaPorTraspaso > 0 Then
OcurrioError = True
Exit For
End If
If Not GeneroMovimientoAlmacen Then
OcurrioError = True
Exit For
End If
'Le damos entrada al general por traspaso
If Not OcurrioError Then
GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
If Not GeneroMovimientoAlmacen Then
GeneroMovimientoAlmacen = GenerarMovimientoAlmacenVirtual(ObjInventario, ObjFactura) > 0
If Not GeneroMovimientoAlmacen Then
If Not GeneroMovimientoAlmacen Then
OcurrioError = True
End If
End If
End If
End If
Else
'Le damos salida de apartado por traspaso
CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada)
If Not CveMovimientoSalidaPorTraspaso > 0 Then
OcurrioError = True
Exit For
End If
End If
'Le damos salida normal
If ConSalida AndAlso Not OcurrioError Then
GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 3, CveMoneda, ObjFactura.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0
'Le damos entrada al general por traspaso
If Not OcurrioError Then
GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0
If Not GeneroMovimientoAlmacen Then
OcurrioError = True
Exit For
End If
End If
'Le damos salida normal
If ConSalida AndAlso Not OcurrioError Then
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
GeneroMovimientoAlmacen = GenerarMovimientoAlmacenVirtual(ObjInventario, ObjFactura) > 0
If Not GeneroMovimientoAlmacen Then
OcurrioError = True
End If
End If
If Not OcurrioError Then
GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 3, CveMoneda, ObjFactura.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0
If Not GeneroMovimientoAlmacen Then
OcurrioError = True
Exit For
End If
End If
If Not GeneroMovimientoAlmacen Then
OcurrioError = True
Exit For
End If
End If
@@ -15250,6 +15335,24 @@ Partial Class Ventas
End If
ElseIf ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, 3, -1, UsuarioActual.CveEmpresa) Then
'If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
' Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados.Rows(0)("CveTipoAlmacen").ToString().ToEntero()
' If CveTipoAlmacen = 24 Then
' Dim RowMov As DataRow = ObjInventario.DtResultados.Rows(0)
' Dim CveMovimientoSalida As Integer = RowMov("CveMovimiento").ToString().ToEntero()
' Dim CveAlmacen As Integer = RowMov("CveAlmacen").ToString().ToEntero()
' Dim CveMoneda As Integer = RowMov("CveMoneda").ToString().ToEntero()
' GeneroMovimientoAlmacen = GenerarMovimientoAlmacenVirtual(ObjInventario, CveMovimientoSalida, CveAlmacen, CveMoneda) > 0
' If Not GeneroMovimientoAlmacen Then
' OcurrioError = True
' Exit For
' End If
' End If
'End If
'Esquema viejo, evitamos que aparezca por surtir
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
OcurrioError = True
@@ -15478,6 +15581,121 @@ Partial Class Ventas
End If
'Return Not OcurrioError
End Function
Private Function GenerarMovimientoAlmacenVirtual(ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura) As Integer
Dim OcurrioError As Boolean = False
Dim CveMovimientoVirtual As Integer = -1
Dim DtPSVirtual As New DataTable("DtTamanios")
DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer)))
DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal)))
DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer)))
Dim DtTamanios As DataTable = Nothing
Dim ObjAcumuladores As New ClsAcumuladores
If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then
DtTamanios = ObjAcumuladores.DtResultados.Copy()
End If
ObjAcumuladores.Dispose()
Dim CveConceptoMovimientoVirtual As Integer = 3
Dim CveAlmacenVirtual As Integer = -1
For Each GvRow As DataRow In ObjFactura.DtDetalle.Rows
For Each Tam As DataRow In DtTamanios.Rows
If Tam("CveTamaño").ToString() = GvRow("CveTamaño").ToString() Then
Dim CvePSCargo = Tam("CvePSCargo").ToString().ToEntero()
Dim Row As DataRow = DtPSVirtual.NewRow()
Row("CvePS") = CvePSCargo
Row("Cantidad") = GvRow("Cantidad").ToString().ToDecimal()
Row("PU") = 0
Row("CveUM") = GvRow("CveUM").ToString().ToEntero()
DtPSVirtual.Rows.Add(Row)
End If
Next
Next
CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={ObjFactura.CveSubProyecto}").ToEntero()
If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 Then
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1)
If CveMovimientoVirtual > 0 Then
For Each RowUsado As DataRow In DtPSVirtual.Rows
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble()
Dim PU As Double = RowUsado("PU").ToString().ToDouble()
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then
OcurrioError = True
Exit For
End If
Next
Else
OcurrioError = True
End If
Else
OcurrioError = True
End If
If DtPSVirtual.Rows.Count = 0 Then
OcurrioError = True
End If
'Dim ContadorMovtosDetalles = 0
'Dim DtMovDetalle As DataTable = Nothing
'If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
' DtMovDetalle = ObjInventario.DtResultados.Copy()
'End If
''Creamos el movimiento
'Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, 2, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoSalida)
'If CveMovimientoInventario > 0 Then
' 'Agregamos los detalles
' For Each MovDet As DataRow In DtMovDetalle.Rows
' Dim Cantidad = MovDet("Cantidad").ToString.ToDecimal
' Dim CveUnidad As Integer = MovDet("CveUM").ToString.ToEntero
' Dim PU As Decimal = MovDet("PU").ToString.ToDecimal
' Dim CveProducto As Integer = MovDet("CvePS").ToString.ToEntero
' Dim SerieLote As String = MovDet("SerieLote").ToString
' If Cantidad < 0 Then
' Alert("Ocurrió un Error al generar los movimientos de almacén. Por favor comuniquese con atención SIG.", TipoMensaje.MsgError)
' OcurrioError = True
' Exit For
' End If
' If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, SerieLote:=SerieLote) Then
' ContadorMovtosDetalles += 1
' Else
' OcurrioError = True
' Exit For
' End If
' Next
' 'VALIDA QUE SE HALLAN AGREGADO DETALLES AL MOVIMIENTO
' If ContadorMovtosDetalles = 0 Then
' OcurrioError = True
' End If
'Else
' OcurrioError = True
'End If
If OcurrioError Then
Return -1
Else
Return CveMovimientoVirtual
End If
End Function
Private Function SalidaAlmacenMateriales(ByRef ObjInventario As ClsInventarios, CveOS As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean
Dim TieneError As Boolean = False
@@ -16841,18 +17059,25 @@ Partial Class Ventas
End Sub
Private Function ValidaPagosContado() As Boolean
Dim Retorno = False
'SI TIENE SALDO PENDIENTE VALIDA SI TIENE PAGOS
If Me.SaldoVenta > 0 Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso (UsuarioActual.Empresa.Funcionalidad(531) = "1") 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 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
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
Dim TotalNC As Decimal = If(ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0, LblTotalNC.Text.Trim().ToDecimal(), 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
@@ -16860,11 +17085,6 @@ Partial Class Ventas
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
@@ -20626,7 +20846,7 @@ Partial Class Ventas
Private Sub CargaCxC()
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, DdlSucursalCliente.SelectedValue.ToEntero) Then
Dim DtTemporal As DataTable = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act' AND CveVenta > 0", "Moneda, OrdenVencimiento, FechaVencimiento")
Dim DtTemporal As DataTable = ObjMovtos.DtResultados.FiltraParametros("TipoDocto <> 'RNC' AND Tipo = 'Act' AND CveVenta > 0", "Moneda, OrdenVencimiento, FechaVencimiento")
GvCxC.DataSource = DtTemporal
End If
ObjMovtos.Dispose()
@@ -20726,10 +20946,8 @@ Partial Class Ventas
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
For Each RNC In ListaNCDesc
DtImpuestos.Merge(CargaDtImpuestosNC(RNC.CveVenta, RNC.TotalRemNCAplicado, NCDescuento:=True), True, MissingSchemaAction.Ignore)
Next
Else
For Each Gvr As GridViewRow In GvCxC.Rows
@@ -20780,14 +20998,32 @@ Partial Class Ventas
AplicaNC = True
If Not NCDescuento Then
If NCDescuento Then
TmpDTDescNC = TmpDT.Clone()
TmpDTDescNC.Clear()
For Each Dr As DataRow In DtImpuestos.Rows
AgregaTempDT(TmpDTDescNC, 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,
TxtNCObservaciones.Text.Trim, 1, Dr("ImportePU").ToString.ToDecimal, Dr("PorcentajeIVA").ToString.ToDecimal, Dr("ImporteIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("ImporteRetIVA").ToString.ToDecimal,
Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("ImporteRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("ImporteIEPS").ToString.ToDecimal, -1, 0.0, Dr("ImporteTotal").ToString.ToDecimal, "", "", -1, -1,
DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1)
Next
TrTipoRelacion.Visible = True
DdlTiposRelacion.SelectedValueExist("1")
'verifica el tipo de cambio que se actualice
If DdlMoneda.SelectedValue <> "1" Then
TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString
End If
Else
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,
AgregaTempDT(TmpDT, 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,
TxtNCObservaciones.Text.Trim, 1, Dr("ImportePU").ToString.ToDecimal, Dr("PorcentajeIVA").ToString.ToDecimal, Dr("ImporteIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("ImporteRetIVA").ToString.ToDecimal,
Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("ImporteRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("ImporteIEPS").ToString.ToDecimal, -1, 0.0, Dr("ImporteTotal").ToString.ToDecimal, "", "", -1, -1,
@@ -20817,14 +21053,14 @@ Partial Class Ventas
LBNotaCredito.Visible = False
CambiaTipoDocto()
End If
End Sub
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal, Optional NCDescuento As Boolean = False) As DataTable
Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
Dim TmpDT As DataTable = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVentaDetalle(CveVentaNC) Then
@@ -20874,12 +21110,15 @@ Partial Class Ventas
DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal") = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString.ToDecimal + difTmp
End If
If Not NCDescuento Then
Me.TmpDT = TmpDT
End If
'CARGA FACTURA A LA CUAL SE APLICA LA NC
'CargaNCDT(CveVentaNC, Importe.ToDecimal)
Return DtImpuestosLocal
End Function
Private Sub AgregaTempDT(CvePS As Integer, PS As String, Codigo As String, CodigoPS As String, CveTipoPS As Integer, CveTipoInvPS As Integer, CveUM As Integer, UM As String,
Private Sub AgregaTempDT(ByRef TmpDT As DataTable, CvePS As Integer, PS As String, Codigo As String, CodigoPS As String, CveTipoPS As Integer, CveTipoInvPS As Integer, CveUM As Integer, UM As String,
CveClasificacion As Integer, Clasificacion As String, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String,
Obs As String, Cantidad As Double, PU As Double, PorcentajeIVA As Double, ImporteIVA As Double, PorcentajeRetIVA As Double, ImporteRetIVA As Double,
PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double,
@@ -21160,7 +21399,7 @@ Partial Class Ventas
Dim ImporteRetISR As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeRetISR").ToString.ToDecimal
Dim ImporteIEPS As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeIEPS").ToString.ToDecimal
AgregaTempDT(Gv.DataKey("CvePS").ToString.ToEntero, Gv.DataKey("PS").ToString, Gv.DataKey("Codigo").ToString, Gv.DataKey("CodigoPS").ToString,
AgregaTempDT(TmpDT, Gv.DataKey("CvePS").ToString.ToEntero, Gv.DataKey("PS").ToString, Gv.DataKey("Codigo").ToString, Gv.DataKey("CodigoPS").ToString,
Gv.DataKey("CveTipoPS").ToString.ToEntero, Gv.DataKey("CveTipoInvPS").ToString.ToEntero,
Gv.DataKey("CveUM").ToString.ToEntero, Gv.DataKey("UM").ToString, Gv.DataKey("CveClasificacion").ToString.ToEntero,
Gv.DataKey("Clasificacion").ToString, Gv.DataKey("CveProyecto").ToString.ToEntero, Gv.DataKey("Proyecto").ToString,
@@ -23412,7 +23651,7 @@ Partial Class Ventas
#End Region
#Region "D E S C U E N T O S X R E M I S I O N D E N O T A D E C R E D I T O"
Protected Sub BtnAplicarRemisionNC_Click(sender As Object, e As EventArgs)
If ListaRemisionesNC Is Nothing Then
ListaRemisionesNC = New List(Of Modelos.Factura)
@@ -23498,107 +23737,32 @@ Partial Class Ventas
RegistraScript("$('#ModalAplicarDescuentoNC').modal('hide'); ")
End Sub
Protected Sub PreparaNCDescuento(ByRef factura As Modelos.Factura)
If TmpDTDescNC IsNot Nothing Then
factura.DtDetalle = TmpDTDescNC
'**** IMPUESTOS LOCALES
Protected Function CreaDTDetalleNCDescuento() As DataTable
Dim Dt As DataTable = TmpDT.Clone()
Dt.Rows.Clear()
Dim TotalSubTotal As Decimal = TmpDTDescNC.SUM("TotalImporte").ToDecimal
Dim TotalDescuentos As Decimal = TmpDTDescNC.SUM("Descuento").ToDecimal
Dim CveSATNC = "84111506"
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
Dim TotalIVA As Decimal = TmpDTDescNC.SUM("ImporteIVA").ToDecimal
Dim TotalIEPS As Decimal = TmpDTDescNC.SUM("ImporteIEPS").ToDecimal
Dim TotalRetIVA As Decimal = TmpDTDescNC.SUM("ImporteRetIVA").ToDecimal
Dim TotalRetISR As Decimal = TmpDTDescNC.SUM("ImporteRetISR").ToDecimal
Dim Total As Decimal = 0
Dim TotalImpuestosLocales As Decimal = 0
Total = (TotalSubTotal - TotalDescuentos + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales)
factura.SubTotal = TotalSubTotal
factura.Descuento = TotalDescuentos
factura.IVA = TotalIVA
factura.IEPS = TotalIEPS
factura.RetIVA = TotalRetIVA
factura.RetISR = TotalRetISR
factura.Total = Total
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()
End Sub
#End Region
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