@@ -9402,6 +9408,7 @@
$('#C_LblDiferenciaCajaBloqueo').val(FormatoNumero(total));
}
+
function CalculaTotalPagoContado() {
var totalEfectivo = ToDouble($get("TxtImporteEfectivo").value);
@@ -9822,6 +9829,10 @@
$('#BtnAplicaNuevaNC').click();
}
+ function CargaMovimientosInventario() {
+ $('#BtnCargarInventario').click();
+ }
+
$('.DdlPS').on("select2:open", function (e) { $('.select2-container.select2-container--default .select2-dropdown .select2anothertable').remove(); });
$('.DdlPSPyME').on("select2:open", function (e) { $('.select2-container.select2-container--default .select2-dropdown .select2anothertable').remove(); });
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index 456043f51..9111ad6d6 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -600,7 +600,7 @@ Partial Class Ventas
Return IfNull(ViewState("MailCC"), "").ToString()
End Get
End Property
- Private ReadOnly Property CveVenta As Integer
+ Public ReadOnly Property CveVenta As Integer
Get
Return ViewState("CveVenta").ToString().ToEntero()
End Get
@@ -2078,22 +2078,6 @@ Partial Class Ventas
ViewState("DiasVencidosCliente") = value
End Set
End Property
- Private Property VentaSaldoAlmacen As Decimal
- Get
- Return ViewState("VentaSaldoAlmacen").ToString().ToDecimal
- End Get
- Set(value As Decimal)
- ViewState("VentaSaldoAlmacen") = value
- End Set
- End Property
- Private Property VentaSaldoAlmacenNC As Decimal
- Get
- Return IfNull(ViewState("VentaSaldoAlmacenNC"), 0, ViewState("VentaSaldoAlmacenNC").ToString().ToDecimal()).ToString().ToDecimal()
- End Get
- Set(value As Decimal)
- ViewState("VentaSaldoAlmacenNC") = value
- End Set
- End Property
Private Property SeCancelaRemisionProceso As Boolean
Get
Return CBool(ViewState("SeCancelaRemisionProceso").ToString())
@@ -2816,14 +2800,6 @@ Partial Class Ventas
'End If
'CargaDetalle de Almacen
- If Not LblAlertRefacInv.Visible Then
- If CveVentaPadre > 0 Then
- InventarioMov(CveVentaPadre)
- Else
- InventarioMov()
- End If
- End If
-
'PERMISO PARA CANCELAR PEDIDO
If GvInv.Rows.Count = 0 Then
If DdlTipoComprobante.SelectedValue.Contiene("Ped") And Not CveEstatus = 14 Then
@@ -2867,6 +2843,15 @@ Partial Class Ventas
ViewState("CveOS") = Request("CveOS")
CargaOS(CveOS)
Else
+
+ 'SI ES VENTA NUEVA, NO RECARGAR TAB DE ALMACEN
+ If CveVenta <= 0 Then
+ 'REMOVER EVENTO PARA RECARGAR ALMACEN
+ spanAlmacen.Attributes.Remove("onclick")
+ Tab.ActiveTabIndex = 1
+ Updatetabs.Update()
+ End If
+
'Modalidad Devoluciones y Refacturacion
If Request("CveDevolucion") IsNot Nothing AndAlso IsNumeric(Request("CveDevolucion")) AndAlso Request("CveDevolucion").ToEntero() > 0 Then
ViewState("CveDevolucion") = Request("CveDevolucion")
@@ -3113,7 +3098,7 @@ Partial Class Ventas
'End If
'CargaDetalle de Almacen
- InventarioMov()
+ 'InventarioMov()
If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then
@@ -4594,7 +4579,7 @@ Partial Class Ventas
'CARGA DTs DE VENTAS
If CveVenta > 0 Then
Using ObjVentas As New ClsVentas()
- If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
DbRowVenta = ObjVentas.DtResultados.Copy().Rows(0)
Else
@@ -4772,15 +4757,6 @@ Partial Class Ventas
ViewState("SaldoVenta") = DbRowVenta("Saldo").ToString()
AplicaCancelarRemision = CBool(DbRowVenta("AplicaCancelarRemision").ToString())
If AplicaCancelarRemision AndAlso CveEstatus.Contiene(2, 3) AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then DivCanRem.Visible = True
- VentaSaldoAlmacen = DbRowVenta("SaldoAlmacen").ToString().ToDecimal
-
- If DbRowVenta("TipoDocto").ToString().Contiene("Rem", "Dev") AndAlso VentaSaldoAlmacen <> 0 Then
- ChkDevAlm.Checked = True
- LiDevolucionAlmacen.Visible = True
- If DbRowVenta("TipoDocto").ToString() = "Dev" Then
- LblDevAlm.Text = "Salida de almacen"
- End If
- End If
If CveEstatus = 5 Then LbCancelarDocumento.Enabled = False
@@ -5673,21 +5649,7 @@ Partial Class Ventas
ObjUsados.Dispose()
- Dim SaldoAlmacenExA As Decimal = 0
- 'Dim SaldoAlmacenUsados As Decimal = 0
-
- Using ObjInventarios As New ClsInventarios
- 'VERIFICA SI HACE FALTA DEVOLVER PRODUCTOS Y USADOS EN ESPECIFICO
- If ObjInventarios.GetSaldoVentaDetalleAlmacen(CveVenta, UsuarioActual.CveEmpresa) Then
- SaldoAlmacenExA = ObjInventarios.DtResultados.SUMD("SaldoAlmacen", $"CveTipoAlmacen = 10")
- 'SaldoAlmacenUsados = ObjInventarios.DtResultados.SUMD("SaldoAlmacen", $"CveTipoAlmacen = 22")
- End If
- End Using
-
- 'Si ya se surtió y recibió
- If SaldoAlmacenExA > 0 OrElse TmpDT.MAX("CveTipoPS") = "1" Then
- BtnsFacturar.Visible = True
- End If
+ BtnsFacturar.Visible = True
'VERIFICA SI YA SE FACTURO COMPLETAMENTE
If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then
@@ -7767,7 +7729,6 @@ Partial Class Ventas
If DTFacNC IsNot Nothing AndAlso DTFacNC.Rows.Count > 0 Then
Me.CveEstatusRefacturacion = DTFacNC.Rows(0)("CveEstatusRefacturacion").ToString().ToEntero()
Me.DevolucionAlmacenNC = DTFacNC.Rows(0)("EsDevolucionVenta").ToString().ToEntero()
- Me.VentaSaldoAlmacenNC = DTFacNC.Rows(0)("SaldoAlmacen").ToString().ToDecimal
HdnRFCVenta.Value = DTFacNC.Rows(0)("ClienteRFC").ToString()
End If
Else
@@ -21767,6 +21728,23 @@ Partial Class Ventas
If RefacturarCancelada Then
Response.Redirect($"Ventas.aspx?CveDevolucion={CveVenta}&NuevaFactura=1")
Else
+ 'si es la empresa 119, Candado, no permite refacturar, si no se ha surtido y que no sea refacturación, para que cancele la factura mejor.
+ If UsuarioActual.CveEmpresa = 119 AndAlso LkRefacturacion.Visible AndAlso CveVentaPadre <= 0 Then
+ Dim PermiteRefacturarar As Boolean = True
+ Using ObjInv As New ClsInventarios
+ If ObjInv.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then
+ If ObjInv.DtResultados.Rows.Count > 0 Then
+ PermiteRefacturarar = False
+ End If
+ End If
+ End Using
+
+ If Not PermiteRefacturarar Then
+ Alert("La factura no se puede refacturar si no ha sido surtida previamente", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ End If
+
Dim script As String = ""
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then
Dim sb As New StringBuilder()
@@ -23541,22 +23519,22 @@ Partial Class Ventas
#Region " INVENTARIO POR ENTREGA"
Private Sub InventarioMov(Optional CveVentaPadre As Integer = -1)
If CveVentaPadre > 0 Then
- Dim ObjVentas As New ClsVentas()
- If ObjVentas.GetVenta(CveVentaPadre, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
- If ObjVentas.DtResultados.Rows.Count > 0 AndAlso ObjVentas.DtResultados.Rows(0)("TipoDocto").ToString() = "Ing" AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then
- ' Dim CveEstatusRefacturacion As Integer = ObjVentas.DtResultados.Rows(0)("CveEstatusRefacturacion").ToString().ToEntero()
+ Dim RowVentas As DataRow = Nothing
+ Using ObjVentas As New ClsVentas
+ If ObjVentas.GetVenta(CveVentaPadre, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
+ RowVentas = ObjVentas.DtResultados.Copy().Rows(0)
+ End If
+ End Using
- ' If CveEstatusRefacturacion = 2 Then
- CargaInventario(Me.CveVenta)
- 'End If
-
- Else
+ If RowVentas IsNot Nothing Then
+ If RowVentas("TipoDocto").ToString().Contiene("Ing") AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then
CargaInventario(Me.CveVenta)
End If
End If
- ObjVentas.Dispose()
Else
- CargaInventario(Me.CveVenta)
+ If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Dev") Then
+ CargaInventario(Me.CveVenta)
+ End If
End If
End Sub
Private Sub CargaInventario(CveVenta As Integer)
@@ -23572,14 +23550,6 @@ Partial Class Ventas
End If
ObjInv.Dispose()
- 'si es la empresa 119, Candado, no permite refacturar, si no se ha surtido y que no sea refacturación, para que cancele la factura mejor.
- If UsuarioActual.CveEmpresa = 119 AndAlso LkRefacturacion.Visible AndAlso VentaSaldoAlmacen = 0 And CveVentaPadre <= 0 Then
- LkRefacturacion.Visible = False
- End If
- If UsuarioActual.CveEmpresa = 119 AndAlso CveVenta = 620098 Then
- LkRefacturacion.Visible = True
- End If
-
End Sub
Private Sub CargaGVInv(DtTemporal As DataTable)
@@ -23645,9 +23615,9 @@ Partial Class Ventas
#Region " DEVOLUCION ALMACEN "
Private Sub InicializaDevolucionAlmacen()
- If Not GvInv.Rows.Count > 0 Then
- Exit Sub
- End If
+ 'If Not GvInv.Rows.Count > 0 Then
+ ' Exit Sub
+ 'End If
If CveVenta > 0 AndAlso (SaldoVenta = TxtTotal.Text.ToDecimal OrElse DdlTipoComprobante.SelectedValue = "Dev" OrElse (DdlTipoComprobante.SelectedValue = "Ped" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.COUNT("CveContratoDetalle", "CveContratoDetalle > 0") > 0)) Then 'And (DdlTipoComprobante.SelectedValue.Contiene({"Rem", "Ped"}) Or (DdlTipoComprobante.SelectedValue.Contiene({"Ing"}) And TxtFecha.Text.ToDate.Month = Now.Month And TxtFecha.Text.ToDate.Year = Now.Year)) Then
@@ -23667,17 +23637,17 @@ Partial Class Ventas
LBDevolucionAlmacen.ToolTip = "¿Está seguro de Solicitar la Devolución de Almacén?"
End If
- If VentaSaldoAlmacen < 0 Then
- If DevolucionAlmacen = 0 Then
- LBAplicaDevolucion.Visible = True
- ElseIf DevolucionAlmacen.Contiene(1, 2) Then
- LBAplicaDevolucion.Visible = False
- End If
- ElseIf VentaSaldoAlmacen >= 0 Then
- LBAplicaDevolucion.Visible = False
- End If
+ 'If VentaSaldoAlmacen < 0 Then
+ ' If DevolucionAlmacen = 0 Then
+ ' LBAplicaDevolucion.Visible = True
+ ' ElseIf DevolucionAlmacen.Contiene(1, 2) Then
+ ' LBAplicaDevolucion.Visible = False
+ ' End If
+ 'ElseIf VentaSaldoAlmacen >= 0 Then
+ ' LBAplicaDevolucion.Visible = False
+ 'End If
- If DdlTipoComprobante.SelectedValue = "Dev" AndAlso VentaSaldoAlmacen <> 0 Then
+ If DdlTipoComprobante.SelectedValue = "Dev" Then
LiDevolucionAlmacen.Visible = False
End If
@@ -23687,14 +23657,22 @@ Partial Class Ventas
'UpInvDev.Update()
End Sub
Protected Sub LBDevolucionAlmacen_Click(sender As Object, e As EventArgs)
+ Dim SaldoAlmacen As Decimal = 0
+
Dim ObjVentas As New ClsVentas
- If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=True) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Rows(0)
Me.DevolucionAlmacen = DbRowVenta("EsDevolucionVenta").ToString().ToEntero()
+ SaldoAlmacen = DbRowVenta("SaldoAlmacen").ToString().ToDecimal()
End If
End If
+ If SaldoAlmacen >= 0 Then
+ Alert("El movimiento ya fue devuelto.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
If Me.DevolucionAlmacen.Contiene(2) Then
InicializaDevolucionAlmacen()
UpnTools.Update()
@@ -24677,10 +24655,10 @@ Partial Class Ventas
End Sub
- Private Sub MostrarCondicionesCancelacion(Optional Extra As String = "")
+ Private Sub MostrarCondicionesCancelacion(Optional Extra As String = "", Optional SaldoAlmacen As Decimal = 0)
Dim SbCondiciones As New StringBuilder()
- If VentaSaldoAlmacen < 0 AndAlso ChkDevAlm.Checked Then
+ If SaldoAlmacen < 0 AndAlso ChkDevAlm.Checked Then
SbCondiciones.Append("*Se realizará una devolución en automatico al realizar la cancelación.")
End If
@@ -24705,11 +24683,9 @@ Partial Class Ventas
Dim sb As New StringBuilder()
Dim sbExtra As New StringBuilder()
- sb.Append("La factura se encuentra en el siguiente estatus del SAT:
")
-
+ sb.Append("La factura se encuentra en el siguiente estatus del SAT:
")
Dim TotalT As Decimal = TxtTotal.Text.ToDecimal
-
Dim RFCReceptor As String = ""
If String.IsNullOrEmpty(Me.RFCReceptorVenta) Then
@@ -24723,6 +24699,36 @@ Partial Class Ventas
RFCReceptor = Me.RFCReceptorVenta
End If
+ Dim SaldoAlmacen As Decimal = 0
+
+ Dim PermiteCancelar As Boolean = True
+ Using ObjVentas As New ClsVentas
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=True) Then
+ If ObjVentas.DtResultados.Rows.Count > 0 Then
+ Dim RowVenta As DataRow = ObjVentas.DtResultados.Rows(0)
+
+ SaldoAlmacen = RowVenta("SaldoAlmacen").ToString().ToDecimal()
+
+ If DdlTipoComprobante.SelectedValue.Contiene("Rem", "Dev") AndAlso SaldoAlmacen <> 0 Then
+ ChkDevAlm.Checked = True
+ LiDevolucionAlmacen.Visible = True
+ If DdlTipoComprobante.SelectedValue = "Dev" Then
+ LblDevAlm.Text = "Salida de almacen"
+ End If
+ End If
+ Else
+ PermiteCancelar = False
+ End If
+ Else
+ PermiteCancelar = False
+ End If
+ End Using
+
+ If Not PermiteCancelar Then
+ Alert("La venta no se puede cancelar si no ha sido surtida previamente", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
Dim SWatch As New Stopwatch
SWatch.Start()
@@ -24827,7 +24833,7 @@ Partial Class Ventas
End If
LblCancelarDocumento.Text = sb.ToString()
- MostrarCondicionesCancelacion(sbExtra.ToString())
+ MostrarCondicionesCancelacion(sbExtra.ToString(), SaldoAlmacen)
RegistraScript("$('#ModalCancelarDocumento').modal();")
UpCancelarDocumento.Update()
@@ -30142,12 +30148,14 @@ Partial Class Ventas
Exit Sub
End If
+ LBAplicaDevolucion.Visible = True
+
'SOLO APLICA DEVOLUCION SI TIENE MOVIMIENTOS DE ALMACEN
- If VentaSaldoAlmacen < 0 Then
- LBAplicaDevolucion.Visible = True
- ElseIf VentaSaldoAlmacen >= 0 Then
- LBAplicaDevolucion.Visible = False
- End If
+ 'If VentaSaldoAlmacen < 0 Then
+ ' LBAplicaDevolucion.Visible = True
+ 'ElseIf VentaSaldoAlmacen >= 0 Then
+ ' LBAplicaDevolucion.Visible = False
+ 'End If
Dim SeEsconde As Boolean = False
@@ -30197,7 +30205,7 @@ Partial Class Ventas
End Sub
Protected Sub BtnAplicaDevolucion_Click(sender As Object, e As EventArgs)
- 'VALIDACIONES
+
Dim Selecciono As Boolean = False
For Each Gv As GridViewRow In GvAplicaDevolucion.Rows
If Gv.FCCheckBox("Chk").Checked And Gv.FCTextBox("TxtCantidadAplicaDevolucion").Text.ToDouble > 0 Then
@@ -32813,6 +32821,11 @@ Partial Class Ventas
DivAdjuntar.Visible = True
End If
+ 'REMOVER EVENTO PARA RECARGAR ALMACEN
+ spanAlmacen.Attributes.Remove("onclick")
+ Tab.ActiveTabIndex = 1
+ Updatetabs.Update()
+
UpnTools.Update()
UpCliente.Update()
@@ -32919,6 +32932,30 @@ Partial Class Ventas
Exit Sub
End If
+ Dim TieneSoloServicios As Boolean = TmpDT.MAX("CveTipoPS") = "1"
+ 'SI ES REMISION Y TIENE PRODUCTOS, DEBE VERIFICAR EL ALMACEN
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Not TieneSoloServicios AndAlso DdlTipoComprobante.SelectedValue = "Rem" AndAlso TipoDoctoNuevo = "Ing" AndAlso Not TmpDT.MAX("CveTipoPS") = "1" Then
+ Dim SaldoAlmacenExA As Decimal = 0
+ 'Dim SaldoAlmacenUsados As Decimal = 0
+
+ Using ObjInventarios As New ClsInventarios
+ 'VERIFICA SI HACE FALTA DEVOLVER PRODUCTOS Y USADOS EN ESPECIFICO
+ If ObjInventarios.GetSaldoVentaDetalleAlmacen(CveVenta, UsuarioActual.CveEmpresa) Then
+ SaldoAlmacenExA = ObjInventarios.DtResultados.SUMD("SaldoAlmacen", $"CveTipoAlmacen = 10")
+ 'SaldoAlmacenUsados = ObjInventarios.DtResultados.SUMD("SaldoAlmacen", $"CveTipoAlmacen = 22")
+ End If
+ End Using
+
+ 'Si ya se surtió y recibió
+ If SaldoAlmacenExA <= 0 Then
+ BtnsFacturar.Visible = False
+ Alert("No se puede facturar hasta que se haya surtido la remisión", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ End If
+
+
If GvPagos.Rows.Count = 0 And UsuarioActual.Empresa.Funcionalidad(558).ToEntero() = 1 And RBLPago.SelectedValue.ToEntero() = 2 Then
Alert("No se puede facturar hasta que se haya especificado detalladamente la forma de pago", TipoMensaje.MsgAdvertencia)
Else
@@ -36488,5 +36525,50 @@ Partial Class Ventas
UpComercioExterior.Update()
End Sub
+ Protected Sub BtnCargarInventario_Click(sender As Object, e As EventArgs)
+ If Not LblAlertRefacInv.Visible Then
+ If CveVentaPadre > 0 Then
+ InventarioMov(CveVentaPadre)
+ Else
+ InventarioMov()
+ End If
+ End If
+
+ 'REMOVER EVENTO PARA RECARGAR ALMACEN
+ spanAlmacen.Attributes.Remove("onclick")
+ Tab.ActiveTabIndex = 1
+ Updatetabs.Update()
+ End Sub
+ Protected Sub LBAplicaDevolucion_Click(sender As Object, e As EventArgs)
+
+ Dim SaldoAlmacen As Decimal = 0
+
+ Dim PermiteCancelar As Boolean = True
+ Using ObjVentas As New ClsVentas
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=True) Then
+ If ObjVentas.DtResultados.Rows.Count > 0 Then
+ Dim RowVenta As DataRow = ObjVentas.DtResultados.Rows(0)
+ SaldoAlmacen = RowVenta("SaldoAlmacen").ToString().ToDecimal()
+ End If
+ End If
+ End Using
+
+ Dim PuedeAplicarDevolucion As Boolean = False
+
+ If SaldoAlmacen < 0 Then
+ If DevolucionAlmacen = 0 Then
+ PuedeAplicarDevolucion = True
+ ElseIf DevolucionAlmacen.Contiene(1, 2) Then
+ Alert("No se puede aplicar una devolución sobre el documento actual", TipoMensaje.MsgAdvertencia)
+ End If
+ ElseIf SaldoAlmacen >= 0 Then
+ Alert("No se puede aplicar una devolución sobre el documento actual", TipoMensaje.MsgAdvertencia)
+ End If
+
+ If PuedeAplicarDevolucion Then
+ RegistraScript("$('#DivAplicaDevolucion').modal('show');")
+ End If
+
+ End Sub
End Class