diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index 7ab6aed8c..7fcdf4e14 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -921,7 +921,23 @@ - + + + + + +
+
+ + Atención! + El Proveedor tiene Saldo a favor pendiente por aplicar +
+
+
+
+ + +
diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 032328419..2bb05d1a2 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -714,6 +714,18 @@ Partial Class Compras_Compras ViewState("CveMetodoPago") = value End Set End Property + + Private Property MetodoPagoOC As Integer + Get + If ViewState("MetodoPagoOC") Is Nothing Then + ViewState("MetodoPagoOC") = -1 + End If + Return ViewState("MetodoPagoOC").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("MetodoPagoOC") = value + End Set + End Property Private Property TipoCambio As Decimal Get Return ViewState("TipoCambio").ToString.ToDecimal @@ -1018,6 +1030,20 @@ Partial Class Compras_Compras End Set End Property + Private Property CveIEAnticipo As Integer + Get + If ViewState("CveIEAnticipo") Is Nothing Then + ViewState("CveIEAnticipo") = -1 + End If + Return ViewState("CveIEAnticipo").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveIEAnticipo") = value + End Set + End Property + + + Public Property FechaCompraOriginal As Date Get Return ViewState("FechaCompraOriginal").ToString.ToDate @@ -3967,6 +3993,11 @@ Partial Class Compras_Compras '------------------ INICIA VALIDACIONES ------------------ + If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 Then + Alert("La orden de compra se definió de contado, favor de especificar la compra de contado.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim CveSubProyectoPrincipal As Integer = AsignarSubProyectoPrincipal() If Not CveSubProyectoPrincipal > 0 Then @@ -13656,6 +13687,7 @@ Partial Class Compras_Compras CargaOC() End Sub Private Sub CargaOC() + MetodoPagoOC = -1 Dim EntregaDirecta As Integer = 0 DivOCSolicitudAnticipo.Visible = False DivOCSolicitudAnticipoModal.Visible = False @@ -13694,6 +13726,7 @@ Partial Class Compras_Compras HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) + MetodoPagoOC = OC.DtResultados.Rows(0)("EntregaDirecta").ToString.ToEntero End If End If Next @@ -13709,6 +13742,7 @@ Partial Class Compras_Compras HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) + MetodoPagoOC = OC.DtResultados.Rows(0)("EntregaDirecta").ToString.ToEntero End If End If Next @@ -13751,7 +13785,9 @@ Partial Class Compras_Compras Protected Sub BtnVOC_Click(sender As Object, e As EventArgs) VinculaOC() End Sub + Private Sub VinculaOC() + CveIEAnticipo = -1 If TxtOC.Text <> "" Then 'VARIABLES @@ -13798,6 +13834,7 @@ Partial Class Compras_Compras If ObjOC.DtResultados.Rows(0)("CveIEAnticipo").ToString.ToEntero > 0 Then FoliosOCAnticipo += $"{ObjOC.DtResultados.Rows(0)("FolioOC").ToString}," FoliosOCAnticipoIE += $"{ObjOC.DtResultados.Rows(0)("FolioIEAnticipo").ToString}," + CveIEAnticipo = ObjOC.DtResultados.Rows(0)("CveIEAnticipo").ToString.ToEntero DivOCSolicitudAnticipo.Visible = True DivOCSolicitudAnticipoModal.Visible = True End If @@ -13889,6 +13926,9 @@ Partial Class Compras_Compras If DivOCSolicitudAnticipo.Visible And FoliosOCAnticipo.Length > 0 Then LtSolicitudAnticipoFoliosOC.Text = $"La(s) siguiente(s) OC: {FoliosOCAnticipo.Substring(0, FoliosOCAnticipo.Length - 1)}. tienen vinculado un anticipo" LtSolicitudAnticipoFoliosIE.Text = $" {FoliosOCAnticipoIE.Substring(0, FoliosOCAnticipoIE.Length - 1)}" + + DVAtencionOCAnticipo.Visible = True + UpDVAtencionOCAnticipo.Update() End If 'PROMOCIONES @@ -14436,13 +14476,39 @@ Partial Class Compras_Compras 'ANTICIPO OC If DivOCSolicitudAnticipo.Visible Then + + If CveIEAnticipo > 0 Then + DVAtencionOCAnticipo.Visible = True + UpDVAtencionOCAnticipo.Update() + End If + + Dim scripsSeccion As String = "" + For Each gvRow As GridViewRow In GVAnticipos.Rows + If gvRow.DataKey("CveIE").ToEntero = CveIEAnticipo Then + Dim Chk As CheckBox = gvRow.FCCheckBox("Chk") + scripsSeccion = scripsSeccion & $"$('#{Chk.ClientID}').click();" + 'RegistraScript($"$('#{Chk.ClientID}').click();", "100") + End If + Next + RegistraScript("MuestraAnticipos();", "MuestaAnticiposOC") + RegistraScript(" + setTimeout(function() { + " & scripsSeccion & " + }, 200) + ") UpAnticipos.Update() + End If CalculaTotales() CompraEstaVinculadaOC = True + + If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 Then + Alert("La orden de compra se definió de contado, favor de especificar la compra de contado.", TipoMensaje.MsgAdvertencia) + End If + End Sub Private Sub VinculacionAsync(Optional VinculacionCompleta As Boolean = False) diff --git a/OC/OC.aspx b/OC/OC.aspx index eaf90f554..a0f785195 100644 --- a/OC/OC.aspx +++ b/OC/OC.aspx @@ -455,7 +455,7 @@ Método de pago: - + @@ -1563,6 +1563,89 @@
+ + + +
+ + + +
+
+
+ + Anticipos +
+
+ +
+
+
+ +
+ +
+
+ + + + + + % + +
+
+
+
+ +
+
+ + + + + + $ + +
+ +
+
+
+
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ + + + + + +
+
+
+ + +
@@ -2912,10 +2995,34 @@ $('#<%= TxtSAImPorcentaje.ClientID%>').val(FormatoNumero(importe, 2).replace(/,/g, "")); }); + + <%--$('#<%= TxtSAImPorcentajeContado.ClientID%>').keyup(function () { + console.log($(this).val()); + var importe = (ToDouble($(this).val()) / 100) * ToDouble($get("LblTotal").value.replace(/,/g, '')); + $('#<%= TxtSAImporteContado.ClientID%>').val( FormatoNumero(importe, 2).replace(/,/g, "") ); + }); + $('#<%= TxtSAImporteContado.ClientID%>').keyup(function () { + var importe = (100 * ToDouble($(this).val())) / ToDouble($get("LblTotal").value.replace(/,/g, "")); + $('#<%= TxtSAImPorcentajeContado.ClientID%>').val(FormatoNumero(importe, 2).replace(/,/g, "")); + });--%> + + + $get('HdnWidth').value = $("#DivConceptosContenido").width(); }); + + function SAImPorcentajeContadokeyup() { + var importe = (ToDouble($('#TxtSAImPorcentajeContado').val()) / 100) * ToDouble($get("LblTotal").value.replace(/,/g, '')); + $('#TxtSAImporteContado').val(FormatoNumero(importe, 2).replace(/,/g, "")); + } + + function SAImporteContadokeyup() { + var importe = (100 * ToDouble($('#TxtSAImporteContado').val())) / ToDouble($get("LblTotal").value.replace(/,/g, "")); + $('#TxtSAImPorcentajeContado%>').val(FormatoNumero(importe, 2).replace(/,/g, "")); + } + function showDivEC(CveCotizacion) { $('#<%=TxtMotivoEliminacion.ClientID%>').val(""); $('#divEliminarCotizacion').modal(); diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index ad8408dbc..5f11e2541 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -2,6 +2,7 @@ Option Strict On Imports System.Data +Imports System.Data.SqlClient Imports System.IO Imports Extensiones Imports GemBox.Spreadsheet @@ -2820,6 +2821,15 @@ Partial Class OC_OC End If + If Not TieneError AndAlso DdlMetodoPago.SelectedValue.ToEntero = 0 AndAlso TipoOC = "OC" Then + + If Not GeneraAnticpoContado(CveOrdenCompra, OC.IniciaTransacSQL()) Then + TieneError = True + End If + + End If + + If Not TieneError Then If Conta IsNot Nothing Then Conta.Commit() OC.Commit() @@ -3207,6 +3217,15 @@ Partial Class OC_OC + + 'If Not TieneError AndAlso DdlMetodoPago.SelectedValue.ToEntero = 0 AndAlso TipoOC = "OC" Then + + ' If Not GeneraAnticpoContado(CveOrdenCompra, OC.IniciaTransacSQL()) Then + ' TieneError = True + ' End If + + 'End If + 'COMMIT If Not TieneError Then 'If MonedaTexto <> DdlMoneda.SelectedItem.Text Then @@ -3258,6 +3277,9 @@ Partial Class OC_OC End If End If + + + 'TERMINA TODO POR SI OCURRIÓ ALGO RARO If TieneError Then If OC IsNot Nothing Then OC.RollBack() @@ -5379,7 +5401,12 @@ Partial Class OC_OC End Sub Private Sub EnviaCorreoSolicitudAnticipo(CveEvento As Integer) Dim Param As New List(Of String) + Dim DtPara As DataTable = GlobalDTUsuarios(DdlSAUsuario.SelectedValue.ToString.ToEntero, CveEmpresaActual) + If DdlMetodoPago.SelectedValue.ToEntero = 0 Then + DtPara = GlobalDTUsuarios(DdlSAUsuarioContado.SelectedValue.ToString.ToEntero, CveEmpresaActual) + End If + Param.Add(DtPara.Rows(0)("Correo").ToString()) 'Para Param.Add("Solicitud de anticipo de Orden de Compra") 'Asunto Param.Add(GeneraCorreoAnticipo(lblFolio.Text, DtPara.Rows(0)("Nombre").ToString(), String.Format("http://sig.adssistemas.mx/OI/EventoDetalle.aspx?CveTipoEvento=1&CveEvento={0}", CveEvento), TxtSAImporte.Text, DdlProveedores.SelectedText)) @@ -8846,4 +8873,80 @@ Partial Class OC_OC End Sub + + Protected Sub DdlMetodoPago_SelectedIndexChanged(sender As Object, e As EventArgs) + + DVAnticposContado.Visible = False + + If DdlMetodoPago.SelectedValue.ToEntero = 0 Then + DVAnticposContado.Visible = True + DdlSAUsuarioContado.DataSource = GlobalDTUsuarios(-1, CveEmpresaActual).FiltraParametros("CvePlataforma = 1", "Nombre") + DdlSAUsuarioContado.DataBind() + DdlSAUsuarioContado.Items.Insert(0, New ListItem("Seleccione", "-1")) + 'CargaAnticiposSolicitudesContado() + End If + + UpPanelDVAnticiposContado.Update() + End Sub + + + Protected Function GeneraAnticpoContado(CveOrdenCompraContado As Integer, ByRef transaccionSql As SqlTransaction) As Boolean + + Dim respuesta As Boolean = False + + If TxtSAImporteContado.Text.ToDecimal > LblTotal.Text.ToDecimal Then + Alert("El importe solicitado supera el saldo de la orden de compra", TipoMensaje.MsgAdvertencia) + Return False + End If + + Dim Descripcion As New StringBuilder + Descripcion.AppendFormat("Importe anticipo : ${0} ({1}%) - Pagar anticipo - Observacion: {2} ", TxtSAImporteContado.Text.FormatoNumero, TxtSAImPorcentajeContado.Text, CveOrdenCompraContado, TxtSAObservacionesContado.Text) + Descripcion.AppendFormat("Orden de compra : {0} - Ir a la orden de compra - Imprimir OC", Folio, CveOrdenCompraContado, Encripta(String.Format("OP=OC&CVEOC={0}", CveOrdenCompraContado))) + + + Dim Asunto As String = $"{lblFolio.Text} - Solicitud de anticipo " + Dim ObjOC As New ClsOC(transaccionSql) + Dim ObjOI As New ClsOIEventos(ObjOC.IniciaTransacSQL) + Dim TieneError As Boolean = False + + If ObjOI.AddEventoTarea(Asunto, Descripcion.ToString, 1, UsuarioActual.CveUsuario, DdlSAUsuarioContado.SelectedValue.ToString.ToEntero, NowADS(), NowADS().AddMinutes(15), -1, 1, -1, "-1", -1, -1, -1, -1, -1, CveOrdenCompraContado.ToEntero, -1, -1, UsuarioActual.CveUsuario, -1, CveEmpresaActual) Then + If Not ObjOC.AddSolicitudAnticipo(CveOrdenCompraContado, TxtSAImporteContado.Text.ToDecimal, CveEmpresaActual) Then + TieneError = True + End If + Else + TieneError = True + End If + + If Not ObjOI.AddEventoBitacora($"Solicitud de anticipo de orden de compra por ${TxtSAImporteContado.Text.FormatoNumero}", "-1", UsuarioActual.CveUsuario, CveEmpresaActual, CveOC:=CveOrdenCompraContado) Then + TieneError = True + End If + + If Not TieneError Then + EnviaCorreoSolicitudAnticipo(ObjOI.CveEvento) + 'LIMPIA + DdlSAUsuarioContado.SelectedValue = "-1" + TxtSAImporteContado.Text = "" + TxtSAObservacionesContado.Text = "" + TxtSAImPorcentajeContado.Text = "" + Alert("La solicitud de anticipo ha sido enviada correctamente.", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrió un error al hacer la solicitud de anticipo.", TipoMensaje.MsgError) + End If + + + If TieneError Then + respuesta = False + Else + respuesta = True + End If + + Return respuesta + + End Function + + + + + End Class +