diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb
index c34d80562..5a6f2fb6d 100644
--- a/App_Code/ClsVentas.vb
+++ b/App_Code/ClsVentas.vb
@@ -2537,12 +2537,13 @@ Public Class ClsVentas
Return Retorno
End Function
- Public Function AddVentasRelacionadas(CveVenta As Integer, CveVentaRelacionada As Integer) As Boolean
+ Public Function AddVentasRelacionadas(CveVenta As Integer, CveVentaRelacionada As Integer, Optional FolioFiscal As String = "") As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_VentasRelacionadasAdd")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
.Add("@CveVentaRelacionada", SqlDbType.Int).Value = CveVentaRelacionada
+ .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal
End With
Try
SqlAdapter.Fill(Data)
diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx
index 91e5df9dd..8bf6b895a 100644
--- a/Ventas/Ventas.aspx
+++ b/Ventas/Ventas.aspx
@@ -353,7 +353,7 @@
Asignar Cuenta de Terminal
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index 4b9eb526c..545637366 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -2217,6 +2217,7 @@ Partial Class Ventas
CargaClasificaciones()
CargaPS(-1, DdlPS)
+ CargaPSRemision(-1, DdlPSRemision)
CargaPSPyME(-1, DdlPSPyME)
CreaDTVentas()
@@ -2303,7 +2304,7 @@ Partial Class Ventas
End If
'MUESTRA EL MODAL PARA PODER RELACIONAR FACTURAS
- If UsuarioActual.Empresa.Funcionalidad(592) = "1" Then
+ If UsuarioActual.TienePermisoProceso(321) Then
HlFacturasRelaciondas.Visible = True
End If
@@ -2313,7 +2314,7 @@ Partial Class Ventas
ViewState("CveVenta") = Request("CveVenta")
If CargaVenta() Then
- If UsuarioActual.Empresa.Funcionalidad(592) = "1" Then
+ If UsuarioActual.TienePermisoProceso(321) Then
CargaRelacionadasPendientes()
End If
@@ -4088,8 +4089,9 @@ Partial Class Ventas
'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text)
End If
-
- If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso LblFolioFiscal.Text.Trim = "" Then HplFolioFiscalModal.Visible = True
+ If UsuarioActual.TienePermisoProceso(318) Then
+ If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(LblFolioFiscal.Text.Trim) Then HplFolioFiscalModal.Visible = True
+ End If
Select Case DbRowVenta("TipoDocto").ToString()
Case "Ing"
@@ -5939,7 +5941,7 @@ Partial Class Ventas
Private Sub CargaRelacionadasPendientes()
- If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(592) = "1" Then
+ If CveVenta > 0 AndAlso UsuarioActual.TienePermisoProceso(321) Then
Me.TmpDTFacturasRelacionadas = New DataTable()
Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("CveVenta", GetType(Integer)))
Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("SerieFolio", GetType(String)))
@@ -6027,6 +6029,37 @@ Partial Class Ventas
UpFacturasRelacionadas.Update()
End If
+ End Sub
+
+ Protected Sub LnkAgregarFolioFiscalRelacionada_Click(sender As Object, e As EventArgs)
+ If CveVenta <= 0 OrElse EsCreaApartirDe Then
+ If Me.TmpDTFacturasRelacionadas Is Nothing Then
+ CreaTmpFacturasRelacionadas()
+ End If
+
+ 'If TmpDTFacturasRelacionadas.COUNT("CveVenta", $"CveVenta ={DdlFacturaARelacionar.SelectedValue.ToEntero()}") > 0 Then
+ ' Alert("La factura ya fue agregada", TipoMensaje.MsgAdvertencia)
+ ' Exit Sub
+ 'End If
+
+ Dim idx As Integer = TmpDTFacturasRelacionadas.MIN("CveVenta", $"CveVenta <= 0").ToEntero()
+ If idx = 0 Then
+ idx = -1
+ End If
+ Dim Row As DataRow = TmpDTFacturasRelacionadas.NewRow()
+
+ Row("CveVenta") = idx - 1
+ Row("SerieFolio") = "SIN ASIGNAR"
+ Row("FolioFiscal") = TxtFolioFiscalRelacionar.Text
+
+ Me.TmpDTFacturasRelacionadas.Rows.Add(Row)
+
+ GvFacturasRelacionadas.DataSource = Me.TmpDTFacturasRelacionadas
+ GvFacturasRelacionadas.DataBind()
+
+ UpFacturasRelacionadas.Update()
+ End If
+
End Sub
Protected Sub BtnAgregarFacturasRelaciondas_Click(sender As Object, e As EventArgs)
If CveVenta <= 0 OrElse EsCreaApartirDe Then
@@ -6453,6 +6486,9 @@ Partial Class Ventas
ElseIf LimiteRestanteSucursal < LimiteRestanteCliente Then
Retorno = LimiteRestanteSucursal
PorcentajeCredito = PorcentajeSaldoSucursal
+ ElseIf LimiteRestanteSucursal = LimiteRestanteCliente Then
+ Retorno = LimiteRestanteSucursal
+ PorcentajeCredito = PorcentajeSaldoSucursal
End If
Else
@@ -6522,6 +6558,29 @@ Partial Class Ventas
Objeto.ddlWS.Attributes.Add("data-AplicaparaVenta", "1")
End If
+ End Sub
+
+ Private Sub CargaPSRemision(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost)
+
+ Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1")
+
+ If Not UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1" Then
+ Objeto.ddl.Items.Clear()
+ 'Objeto.ddl.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, AplicaParaVenta:=1, Estatus:=1)
+ Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1, AplicaParaVenta:=1)
+ Objeto.ddl.DataBind()
+ Objeto.ddl.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2"))
+ Objeto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
+ Else
+ Dim cvesubproyecto As String = "-1"
+
+ Objeto.Attributes.Add("data-cvesubproyecto", cvesubproyecto)
+ Objeto.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString())
+ Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
+ Objeto.ddlWS.Attributes.Add("data-Estatus", "1")
+ Objeto.ddlWS.Attributes.Add("data-AplicaparaVenta", "1")
+ End If
+
End Sub
Private Sub CargaNC(pCveVenta As Integer)
If pCveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Or DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then
@@ -9088,6 +9147,13 @@ Partial Class Ventas
DtVentasNC.AcceptChanges()
End If
+ 'ASIGNAR RFC RECEPTOR
+ If ObjFacturaBonificacion.Timbre IsNot Nothing Then
+ If ObjFacturaBonificacion.Timbre.Receptor IsNot Nothing Then
+ ObjFacturaBonificacion.RFCReceptor = ObjFacturaBonificacion.Timbre.Receptor.RFC
+ End If
+ End If
+
End Sub
@@ -9957,6 +10023,13 @@ Partial Class Ventas
ObjFactura.DescuentoProntoPago = HdnProntoPago.Value.ToDecimal()
ObjFactura.NuevaFactura = Me.NuevaFactura
+
+ 'ASIGNAR RFC RECEPTOR
+ If ObjFactura.Timbre IsNot Nothing Then
+ If ObjFactura.Timbre.Receptor IsNot Nothing Then
+ ObjFactura.RFCReceptor = ObjFactura.Timbre.Receptor.RFC
+ End If
+ End If
End Sub
Private Sub CreaObjetosVentaDevolucion()
@@ -10249,6 +10322,13 @@ Partial Class Ventas
End If
ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion)
+
+ 'ASIGNAR RFC RECEPTOR
+ If ObjFacturaDevolucion.Timbre IsNot Nothing Then
+ If ObjFacturaDevolucion.Timbre.Receptor IsNot Nothing Then
+ ObjFacturaDevolucion.RFCReceptor = ObjFacturaDevolucion.Timbre.Receptor.RFC
+ End If
+ End If
End Sub
Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre
@@ -10354,7 +10434,7 @@ Partial Class Ventas
End If
'SI LAS FACTURAS SE RELACIONARAN MANUALMENTE SE AGREGAN
- If UsuarioActual.Empresa.Funcionalidad(592) = "1" AndAlso Me.AplicaRelacionManual AndAlso DdlTipoRelacionARelacionar.SelectedValue.ToEntero() > 0 Then
+ If UsuarioActual.TienePermisoProceso(321) AndAlso Me.AplicaRelacionManual AndAlso DdlTipoRelacionARelacionar.SelectedValue.ToEntero() > 0 Then
Dim CveTipoRelacion As Integer = DdlTipoRelacionARelacionar.SelectedValue.ToEntero()
@@ -10408,7 +10488,7 @@ Partial Class Ventas
Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString().ToDecimal,
.Descripcion = tPS,
.ValorUnitario = drr("PU").ToString().ToDecimal,
- .Importe = drr("TotalImporte").ToString().ToDecimal,
+ .Importe = If(UsuarioActual.Empresa.CvePAC = 3, drr("Total").ToString().ToDecimal, drr("TotalImporte").ToString().ToDecimal),
.Descuento = drr("Descuento").ToString().ToDecimal.RoundSQL(2),
.Unidad = drr("UM").ToString(),
.ClaveUnidad = drr("SATClaveUM").ToString(),
@@ -11001,11 +11081,20 @@ Partial Class Ventas
End If
End If
- If UsuarioActual.Empresa.Funcionalidad(592) = "1" AndAlso Me.AplicaRelacionManual Then
+ If UsuarioActual.TienePermisoProceso(321) AndAlso Me.AplicaRelacionManual Then
For Each GvRow As GridViewRow In GvFacturasRelacionadas.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
- If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, GvRow.DataKey("CveVenta").ToEntero()) Then
- ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico")
+ If GvRow.DataKey("CveVenta").ToEntero() > 0 Then
+ If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, GvRow.DataKey("CveVenta").ToEntero()) Then
+ ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico")
+ End If
+ Else
+ Dim FolioFiscalRelacionado As String = GvRow.DataKey("FolioFiscal")
+ If Not String.IsNullOrEmpty(FolioFiscalRelacionado) Then
+ If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, -1, FolioFiscal:=FolioFiscalRelacionado) Then
+ ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico")
+ End If
+ End If
End If
End If
Next
@@ -14809,6 +14898,19 @@ Partial Class Ventas
Alert("La amortización no se pudo realizar ya que los importes no cubren la totalidad del documento. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
End If
+ End If
+
+ If Amortizacion > SubTotalRef Then
+
+ '[IPP] LIMPIA LO SELECCIONADO EN CASO DE QUE NO SEA AMORTIZACIÓN DEL 100% 15Junio2018
+ Amortizacion = 0
+ For Each gvr As GridViewRow In GVAnticipos.Rows
+ gvr.FCCheckBox($"Chk{gvr.RowIndex}").Checked = False
+ Next
+ If CveVenta <= 0 Then
+ Alert($"La amortización no se pudo realizar ya que los importes exceden la totalidad del documento. Importe sugerido para amortizar:{SubTotalRef.FormatoNumero(2)}. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
+ End If
+
End If
LblAmortizacion.Text = Amortizacion.FormatoNumero(2)
@@ -16144,7 +16246,7 @@ Partial Class Ventas
Private Sub DdlSubProyectoDatos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubProyectoDatos.SelectedIndexChanged
CambiaSucursalGeneral()
End Sub
- Private Sub CambiaSucursalGeneral()
+ Private Sub CambiaSucursalGeneral(Optional RecargarPartidas As Boolean = True)
Dim ObjSubProyectos As New ClsSubProyectos
'Dim ObjSucursal As New ClsSucursales
If ObjSubProyectos.GetSubProyectos() Then
@@ -16158,7 +16260,7 @@ Partial Class Ventas
'DdlSubProyecto.SelectedValue = "-1"
DdlSubProyecto.DataBind()
DdlSubProyecto.SelectedValueExist(DdlSubProyectoDatos.SelectedValue)
- CambiaSucursal()
+ CambiaSucursal(RecargarPartidas)
DdlSubProyectoEjecucion.SelectedValueExist(DdlSubProyectoDatos.SelectedValue)
DdlSubProyectoCobranza.SelectedValueExist(DdlSubProyectoDatos.SelectedValue)
@@ -16176,12 +16278,16 @@ Partial Class Ventas
UpDetalle.Update()
End Sub
- Private Sub CambiaSucursal()
+ Private Sub CambiaSucursal(Optional RecargarPartidas As Boolean = True)
CargaFormatoSucursal()
CargaFolios()
CargaVendedores()
CargarAlmacenes()
- RecargaSucursalPartidas()
+
+ If RecargarPartidas Then
+ RecargaSucursalPartidas()
+ End If
+
DdlPS.Attributes.Remove("data-cvesubproyecto")
DdlPS.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue)
@@ -16191,6 +16297,7 @@ Partial Class Ventas
UpPS.Update()
End Sub
Private Sub RecargaSucursalPartidas()
+
Dim CveSubProyecto As Integer = DdlSubProyectoDatos.SelectedValue.ToEntero()
Dim SubProyecto As String = ""
If CveSubProyecto > 0 Then
@@ -23283,12 +23390,12 @@ Partial Class Ventas
Private Sub CargaPSPyME(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost)
- DdlPSPyME.setEsWebService(True)
+ Objeto.setEsWebService(True)
- DdlPSPyME.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue)
- DdlPSPyME.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString())
- DdlPSPyME.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
- DdlPSPyME.ddlWS.Attributes.Add("data-Estatus", "1")
+ Objeto.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue)
+ Objeto.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString())
+ Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
+ Objeto.ddlWS.Attributes.Add("data-Estatus", "1")
End Sub
@@ -24015,6 +24122,7 @@ Partial Class Ventas
Dim FileExtension As String = "-1"
Dim Filesgral As List(Of Archivo) = TxtFileCliente.getfiles().Archivos
Dim Filename As String = ""
+ Dim ErrorCarga As Boolean = False
For Each fileItem As Archivo In Filesgral
Try
@@ -24033,6 +24141,17 @@ Partial Class Ventas
Count = +1
Next
End If
+
+ If fileItem Is Nothing Then
+ ErrorCarga = True
+ Exit For
+ Else
+ If fileItem.FileUrl Is Nothing Then
+ ErrorCarga = True
+ Exit For
+ End If
+ End If
+
DtDocumentacionCliente(IndexDocumentoCliente)("RutaArchivo") = fileItem.FileUrl
DtDocumentacionCliente(IndexDocumentoCliente)("UpArchivo") = "1"
@@ -24045,6 +24164,11 @@ Partial Class Ventas
Next
+ If ErrorCarga Then
+ Alert("No se pudo cargar el archivo", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
GvDocumentosCliente.DataSource = DtDocumentacionCliente
GvDocumentosCliente.DataBind()
@@ -28319,8 +28443,11 @@ Partial Class Ventas
HuboCambioRemi = Not HuboCambioRemi
'TOTAL X CONCEPTO
If RblTipo.SelectedValue = "3" Then
+ 'DivPSRemision.Visible = False
ChkRemProductos.Visible = True
Else
+ 'DivPSRemision.Visible = True
+ CargaPSRemision(-1, DdlPSRemision)
ChkRemProductos.Visible = False
ChkRemProductos.Checked = False
End If
@@ -28329,6 +28456,12 @@ Partial Class Ventas
End Sub
Protected Sub BtnGuardarRemisiones_Click(sender As Object, e As EventArgs) Handles BtnGuardarRemisiones.Click
If GvRem.Rows.Count > 0 Or GvRemPS.Rows.Count > 0 Then
+
+ If RblTipo.SelectedValue.Contiene("1", "2") AndAlso DdlPSRemision.SelectedValue.ToEntero() <= 0 Then
+ Alert("Debe seleccionar un producto para facturar la remisión", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
'Checa las facturas selecionadas
If Not VerificaRemisiones(DTRemisiones) Then
Alert("La cantidad/total debe ser mayor que 0", TipoMensaje.MsgAdvertencia)
@@ -28430,9 +28563,9 @@ Partial Class Ventas
Next
IsTotalxConcepto = False
Dim PU As Decimal = dtSeleccionadas.SUM("SubTotal").ToDecimal
- Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa)(0)
+ Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSRemision.SelectedValue.ToEntero())(0)
Dim IVA As Double = If(dtSeleccionadas.SUM("Iva") > 0, dtSeleccionadas.SUM("Iva") / dtSeleccionadas.SUM("SubTotal"), 0.16)
- Dim rowSP As DataRow = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa)(0)
+ Dim rowSP As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa)(0)
AgregarProductoServicio(1, PS("CveUM").ToString().ToEntero(), PS("UnidadMedida").ToString(), PS("CveClasificacion").ToString().ToEntero(),
PS("Clasificacion").ToString(), PS("CvePS").ToString().ToEntero(), PS("PS").ToString(), "", PU, 0,
@@ -28458,8 +28591,8 @@ Partial Class Ventas
End If
Next
- Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa)(0)
- Dim rowSP As DataRow = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa)(0)
+ Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSRemision.SelectedValue.ToEntero())(0)
+ Dim rowSP As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa)(0)
Dim IVA As Double = If(dtSeleccionadas.SUM("Iva") > 0, dtSeleccionadas.SUM("Iva") / dtSeleccionadas.SUM("SubTotal"), 0.16)
For Each gvr As GridViewRow In GvRem.Rows
If gvr.FCCheckBox("Chk").Checked Then
@@ -29245,7 +29378,7 @@ Partial Class Ventas
End If
End If
ObjCliente.Dispose()
- DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty)
+ 'DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty)
TrVistaPrevia.Visible = True
TxtFechaVencimientoCotizacion.Text = Now.ToShortDateString
@@ -29255,7 +29388,7 @@ Partial Class Ventas
GvPS.Columns(18).Visible = True
CambiaTipoDocto()
- CambiaSucursalGeneral()
+ CambiaSucursalGeneral(RecargarPartidas:=False)
CargaAnticipos(CveCliente)
CargaRestriccionesCreditoCliente(CveVenta:=-1)
@@ -29276,6 +29409,14 @@ Partial Class Ventas
CalculaTotalesVenta()
+ Dim PorcentajeRetIVA = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100)
+
+ If PorcentajeRetIVA > 0 Then
+ TrRetIVA.Style.Add("display", "")
+ UsuarioActual.Empresa.MostrarRetIVA = True
+ DdlTipoRetencion.Visible = True
+ End If
+
UpnTools.Update()
UpCliente.Update()
UpParametros.Update()