This commit is contained in:
rakcsle
2022-01-19 01:31:30 -07:00
29 changed files with 13784 additions and 12773 deletions

View File

@@ -2770,6 +2770,10 @@
</div>
</div>
<div class="portlet-body form">
<asp:UpdatePanel runat="server" ID="UPPDatosUsado" UpdateMode="Conditional">
<ContentTemplate>
<div class="row">
<div class="col-md-4">
<label>Tipo Servicio:</label>
@@ -2832,7 +2836,8 @@
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>

View File

@@ -34,7 +34,7 @@ Partial Class PV
Private Property FolioXML As String
Private Property SubTotal As Decimal
Private Property Total As Decimal = 0
Private Property Descuentos As Decimal = 0
'Private Property Descuentos As Decimal = 0
Private Property EmisorRFC As String
Private Property ReceptorRFC As String
Private Property TrasladoIVA As Decimal = 0
@@ -83,6 +83,15 @@ Partial Class PV
End Set
End Property
Private Property DtPorcentajeMarcas As DataTable
Get
Return If(IsNothing(ViewState("DtPorcentajeMarcas")), Nothing, CType(ViewState("DtPorcentajeMarcas"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtPorcentajeMarcas") = value
End Set
End Property
Private Property RemisionesLista As List(Of Integer)
Get
Return If(IsNothing(ViewState("RemisionesLista")), Nothing, CType(ViewState("RemisionesLista"), List(Of Integer)))
@@ -2576,6 +2585,12 @@ Partial Class PV
If Not String.IsNullOrEmpty(ObjCliente.Vendedor) Then
LbVendedor.Text = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Vendedor", $"CveVendedor = {ObjCliente.Vendedor}")
End If
' si es empresa acumuladores
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
CargaPorcentajeMarcas()
End If
Else
TrEsDistribuidor.Visible = False
End If
@@ -2697,6 +2712,14 @@ Partial Class PV
UPCondicionesPago.Update()
End Sub
Private Sub CargaPorcentajeMarcas()
Dim ObjPS As New ClsProductosServicios
If ObjPS.GetPorcentajeMarcas(CveCliente) Then
DtPorcentajeMarcas = ObjPS.DtResultados.Copy()
End If
ObjPS.Dispose()
End Sub
Private Sub CambiaSucursal()
CargaFormatoSucursal()
CargaFolios()
@@ -3744,6 +3767,10 @@ Partial Class PV
ObjFactura.ErrorList.Add("No existe un almacen configurado como 'Servicio a Domicilio' en esta sucursal.")
End If
If TmpDTAjustes IsNot Nothing AndAlso TmpDTAjustes.Rows.Count > 0 Then
ObjFactura.EsGarantia = True
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al generar la venta", ex)
@@ -4134,6 +4161,176 @@ Partial Class PV
UpAddVenta.Update()
UPPDescuento.Update()
End Sub
Partial Class Descuentos
Public ImporteDescuento As Decimal = 0
Public CvePromocionDetalle As Integer = -1
Public PU As Decimal = 0
Public EsPUModificado As Boolean = False
Public ImporteProntoPago As Decimal = 0
End Class
Private Function CalcularDescuentos(CvePS As Integer, Cantidad As Decimal, PU As Decimal) As Descuentos
Dim Descuento As Decimal = HdnDescuento.Value.ToDecimal
If HdnTipoDescuento.Value = "0" Then
Descuento = HdnDescuento.Value.ToDecimal * Cantidad
End If
Dim ValidaCondicionesComerciales As Boolean = True
'AGREGA PROMOCION EN EL DESCUENTO
Dim TipoPromo As Integer = 0
Dim TotalPromocion As Decimal = 0
Dim PromocionPorcentaje As Decimal = 0
Dim PUModificado As Decimal = 0
Dim SeAjustoPU As Boolean = False
Dim PUPromocion As Decimal = 0
Dim CantMinima As Integer = 0
Dim CveMarcaPS As Integer = 0
Dim CveClasifPS As Integer = 0
Dim CveRinTamañoPS As Integer = 0
Dim CvePromocionDetalle As Integer = 0
Dim IncluyeImpuestos As Boolean = False
Dim TipoAplicacion As Integer = 1 ' 1 - descuento, 2 en PU
Dim ObjDescuento As New Descuentos
If DdlSubProyectoDatos.SelectedValue = "11842" Then '' E141, el subproyecto: Franquicia, no proceden las promociones
Return ObjDescuento
End If
Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DrPS IsNot Nothing Then
CveMarcaPS = DrPS("CveMarca").ToString().ToEntero()
CveClasifPS = DrPS("CveClasificacion").ToString().ToEntero()
CveRinTamañoPS = DrPS("CveRinTamaño").ToString().ToEntero()
If CveClasifPS = 20636 Then
ValidaCondicionesComerciales = False
End If
End If
Dim dr As DataRow = Nothing
If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then
dr = DtPromociones.FiltroPrimero(String.Format("CvePS = {0} AND (CveSubProyecto = {1} OR CveSubProyecto IS NULL) AND (CveRinTamaño = {2} OR CveRinTamaño IS NULL) AND ((TipoPromocion <> 3 AND (CantidadMinima <= {3} OR CantidadMinima IS NULL)) OR (TipoPromocion = 3 AND CantidadMinima <= {3} ))", CvePS, DdlSubProyectoDatos.SelectedValue, CveRinTamañoPS, Cantidad), Orderby:="CantidadMinima desc ")
If dr Is Nothing Then
'verifica marca, si tiene asignada la promocion
dr = DtPromociones.FiltroPrimero(String.Format("CvePS IS NULL AND CveClasificacion = {0} AND (CveMarca = {1} OR CveMarca IS NULL) AND (CveSubProyecto = {2} OR CveSubProyecto IS NULL) AND (CveRinTamaño = {3} OR CveRinTamaño IS NULL) AND ((TipoPromocion <> 3 AND (CantidadMinima <= {4} OR CantidadMinima IS NULL)) OR (TipoPromocion = 3 AND CantidadMinima <= {4} )) ", CveClasifPS, CveMarcaPS, DdlSubProyectoDatos.SelectedValue, CveRinTamañoPS, Cantidad), Orderby:="CantidadMinima desc")
End If
End If
Dim Cant As Integer = 1
If dr IsNot Nothing Then
TipoPromo = dr("TipoPromocion").ToString().ToEntero()
CantMinima = dr("CantidadMinima").ToString().ToEntero()
IncluyeImpuestos = dr("IncluyeImpuestos").ToString() = "True"
PromocionPorcentaje = dr("Promocion").ToString().ToDecimal
PUPromocion = dr("PUPromocion").ToString().ToDecimal
CvePromocionDetalle = dr("CvePromocionDetalle").ToString().ToEntero()
TipoAplicacion = dr("TipoAplicacion").ToString().ToEntero()
If CantMinima > 0 Then
Cant = Math.Floor(Cantidad / CantMinima).ToEntero()
End If
End If
Dim PorcentajeIVA As Decimal = ViewState("SubProyectoPorcentajeIVA").ToString.ToDecimal ''Math.Round(ViewState("SubProyectoPorcentajeIVA").ToString.ToDecimal, 2).ToDecimal
TotalPromocion = Math.Round(PUPromocion * Cant / (1 + If(IncluyeImpuestos, PorcentajeIVA, 0)), 6)
If TipoPromo = 1 Then 'Promocion por Importe $
If TipoAplicacion = 2 Then
Descuento = 0
SeAjustoPU = True
PUModificado = Math.Round(PUPromocion / (1 + If(IncluyeImpuestos, PorcentajeIVA, 0)), 6)
Else
Descuento = Descuento + PU - TotalPromocion
End If
ElseIf TipoPromo = 2 Then 'Promocion por %
Descuento = Descuento + ((PU * PromocionPorcentaje / 100) * Cantidad)
ElseIf TipoPromo = 3 Then 'Promocion por Cantidad
If Cantidad >= CantMinima Then
Descuento = Descuento + TotalPromocion
Else
CvePromocionDetalle = -1
End If
End If
'VERIFICA SI APLICAN CONDICIONES COMERCIALES
If ValidaCondicionesComerciales AndAlso 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
'(AHORA LOS DESCUENTOS SON ACUMULABLES)
'Descuento = 0
Dim PorcentajeProducto = RowPorcentaje("PorcentajeProducto").ToString().ToDecimal() / 100D
Dim PorcentajeProducto2 = RowPorcentaje("PorcentajeProducto2").ToString().ToDecimal() / 100D
Dim PorcentajeProducto3 = RowPorcentaje("PorcentajeProducto3").ToString().ToDecimal() / 100D
Dim TotalInicial As Decimal = (Cantidad * (PU)) '- Descuento
Dim TotalFinal = TotalInicial
'SI APLICA EL PRIMER DESCUENTO
If PorcentajeProducto > 0 Then
Dim Descuento1 As Decimal = (TotalInicial * PorcentajeProducto).RoundSQL(2)
Dim Total2 = (TotalInicial - Descuento1)
'SI APLICA EL SEGUNDO DESCUENTO
If PorcentajeProducto2 > 0 Then
Dim Descuento2 As Decimal = (Total2 * PorcentajeProducto2).RoundSQL(2)
Dim Total3 = (Total2 - Descuento2)
'SI APLICA EL TERCER DESCUENTO
If PorcentajeProducto3 > 0 Then
Dim Descuento3 As Decimal = (Total3 * PorcentajeProducto3).RoundSQL(2)
TotalFinal = Total3 - Descuento3
Else
TotalFinal = Total3
End If
Else
TotalFinal = Total2
End If
Else
TotalFinal = TotalInicial
End If
If PorcentajeProducto > 0 Then
Descuento += ((Cantidad * PU) - TotalFinal)
End If
'SI TIENE PRONTO PAGO CALCULA EL IMPORTE
If DdlTipoComprobante.SelectedValue = "Ing" AndAlso RowPorcentaje("ProntoPago").ToString().ToDecimal() > 0 Then
Dim TotalProntoPago As Decimal = (Cantidad * (PU)) - Descuento
Dim PorcentajeProntoPago = RowPorcentaje("ProntoPago").ToString().ToDecimal() / 100D
ObjDescuento.ImporteProntoPago = (TotalProntoPago * PorcentajeProntoPago).RoundSQL(2)
End If
End If
End If
End If
ObjDescuento.ImporteDescuento = Descuento
ObjDescuento.CvePromocionDetalle = CvePromocionDetalle
If SeAjustoPU Then
ObjDescuento.PU = PUModificado
ObjDescuento.EsPUModificado = True
End If
Return ObjDescuento
End Function
Protected Sub DdlPS_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlPS.selectedindexchange
DdlPSIndexChange(DdlPS.SelectedValue.ToEntero, DdlPS)
End Sub
@@ -5114,15 +5311,22 @@ Partial Class PV
Descuento = HdnDescuento.Value.ToDecimal * TxtCantidad.Text.ToDecimal
End If
Dim ObjDescuento As New Descuentos
If DrPS("CveClasificacion").ToString.ToEntero.Contiene(20516, 20515) Then
Descuento = ((Cantidad * PU) * ClasificacionesDescuentos(DrPS("CveClasificacion").ToString.ToEntero))
ObjDescuento.ImporteDescuento = ((Cantidad * PU) * ClasificacionesDescuentos(DrPS("CveClasificacion").ToString.ToEntero))
End If
ObjDescuento = CalcularDescuentos(CvePS, Cantidad, PU)
If ObjDescuento.EsPUModificado Then
PU = ObjDescuento.PU
End If
Dim CveProyecto As Integer = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).Rows(0)("CveProyecto").ToString.ToEntero
Dim Proyecto As String = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).Rows(0)("Proyecto").ToString
Dim Consec = AgregarProductoServicio(Cantidad, DdlUnidadMedida.SelectedValue.ToEntero, DdlUnidadMedida.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text,
CvePS, "", TxtObsPS.Text.Trim, PU, Descuento,
CvePS, "", TxtObsPS.Text.Trim, PU, ObjDescuento.ImporteDescuento,
CveProyecto, Proyecto, DdlSubProyectoDatos.SelectedValue.ToEntero, DdlSubProyectoDatos.SelectedItem.Text,
Serie:="", TiempoEntrega:="", CuentaPredial:="", RegeneraIEPS:=ClienteDesglosaIEPS, CveVentaDetalle:=CveVentaDetalle, EsCargo:=EsCargo)
@@ -6773,12 +6977,12 @@ Partial Class PV
DdlBCIAjuste.DataSource = DTBCIUsados.FiltraParametros($"CveTamaño={CveTamanio}")
DdlBCIAjuste.DataBind()
DdlBCIAjuste.Items.Insert(0, New ListItem("Seleccione", "-1"))
RFVAnio.Enabled = True
CVAnio.Enabled = True
If CveTamanio = 16 Then 'motobaterias
DdlBCIAjuste.Items.Insert(0, New ListItem(" - ", "0"))
RFVAnio.Enabled = False
CVAnio.Enabled = False
End If
UPPDatosUsado.Update() ''refresca el RFV
'UPPDatosUsado.Update() ''refresca el RFV
Else
DdlBCIAjuste.Items.Insert(0, New ListItem(" - ", "0"))
End If

View File

@@ -36,25 +36,25 @@
<div class="portlet light smmallpadding traspasorow bordered">
<div class="portlet-title">
<div class="caption font-green">
<span class="caption-subject bold uppercase" style="line-height: 2;">Facturas Pendientes Por Respuesta</span>
<span class="caption-subject bold uppercase" style="line-height: 1;">Facturas Pendientes Por Respuesta</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body rowpadding">
<div class="row">
<div class="col-md-12">
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 5px; text-align: right" align="left">
<div class="row" style="margin-left: 0px; text-align: right" align="left">
<div style="margin-right: 15px">
<input type="text" id="TxtBusqueda1" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusqueda1','{0}')", GvDatos.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvDatos.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="portlet-body rowpadding">
<div class="row">
<div class="col-md-12">
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontraron solicitudes de cancelación"
DataKeyNames="CveVenta,CveCliente,Folio,TipoDocto,Nombre,FolioFiscal,Total,SubTotal,RFCCliente"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD mysmallbtn" data-sort="true" GridLines="None" Width="99%">
@@ -84,25 +84,24 @@
<div id="DivRefacturar" runat="server" visible="false" class="portlet light smmallpadding traspasorow bordered">
<div class="portlet-title">
<div class="caption font-green">
<span class="caption-subject bold uppercase" style="line-height: 2;">Facturas Pendientes Por Refacturar</span>
<span class="caption-subject bold uppercase" style="line-height: 2;">Facturas Pendientes de cancelar provenientes de refacturación</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body rowpadding">
<div class="row">
<div class="col-md-12">
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 5px; text-align: right" align="left">
<div class="row" style="margin-left: 0px; text-align: right" align="left">
<div style="margin-right: 15px">
<input type="text" id="TxtBusqueda2" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusqueda2','{0}')", GvRefacturaciones.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvRefacturaciones.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="portlet-body rowpadding">
<div class="row">
<div class="col-md-12">
<asp:GridView ID="GvRefacturaciones" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontraron solicitudes de cancelación"
DataKeyNames="CveVenta,CveCliente,Folio,TipoDocto,Nombre,FolioFiscal,Total,SubTotal,RFCCliente,FolioFiscalSustitucion"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD mysmallbtn" data-sort="true" GridLines="None" Width="99%" OnRowDataBound="GvDatos_RowDataBound">
@@ -114,11 +113,9 @@
<asp:BoundField HeaderText="Importe" DataField="Total" DataFormatString="{0:N2}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Mon" DataField="Abreviatura" ItemStyle-Width="30px" />
<asp:BoundField HeaderText="Fecha Solicitud" DataField="FechaCambioEstatus" ItemStyle-Width="160px" />
<asp:BoundField HeaderText="Fecha Cancelacion" DataField="FechaCancelacion" ItemStyle-Width="160px" />
<asp:BoundField HeaderText="Estatus" DataField="EstatusFactura" ItemStyle-Width="160px" />
<asp:BoundField HeaderText="Serie Folio Nuevo" DataField="SerieFolioSustitucion" ItemStyle-Width="25%" />
<asp:BoundField HeaderText="Folio Sustitucion" DataField="FolioFiscalSustitucion" ItemStyle-Width="25%" />
<asp:BoundField HeaderText="Motivo" DataField="MotivoCancelacion" ItemStyle-Width="25%" />
<asp:HyperLinkField HeaderText="Folio Sustitución" DataTextField="SerieFolioSustitucion" DataNavigateUrlFields="CveVentaSustitucion" ItemStyle-Width="100px" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" />
<asp:BoundField HeaderText="Motivo" DataField="MotivoCancelacion" ItemStyle-Width="25%" />
<asp:TemplateField ItemStyle-Width="35px" HeaderText="Verificar">
<ItemTemplate>
<asp:LinkButton ID="LnkValidarRefac" runat="server" OnClick="BtnValidarRefacturacion_Click" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-check'></i>" data-toggle="confirmation" data-popout="true" data-original-title="¿Está seguro que desea verificar la cancelación?" data-btn-ok-label="si"></asp:LinkButton>
@@ -129,7 +126,6 @@
<asp:LinkButton ID="LnkCancelar" Visible="false" runat="server" OnClick="BtnCancelarDocumento_Click" CssClass="btn btn-circle btn-sm red" Text="<i class='fa fa-check'></i>" data-toggle="confirmation" data-popout="true" data-original-title="¿Está seguro que desea cancelar el documento?" data-btn-ok-label="si"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField HeaderText="Refacturación" Text="Refacturar" DataNavigateUrlFields="CveVenta" ItemStyle-Width="100px" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveDevolucion={0}&NuevaFactura=1" />
</Columns>
<RowStyle CssClass="Texto" />
<HeaderStyle CssClass="Titulos" />

View File

@@ -11,6 +11,7 @@ using System.Web.UI.WebControls;
using Extensiones;
using static Extensiones.ModExtensiones;
using Microsoft.Reporting.WebForms;
using System.Net.Http;
public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
@@ -455,20 +456,20 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.DBCampo("PuedeRefacturar").ToString().ToEntero() == 0)
{
e.Row.Cells[14].Text = "";
}
//if (e.Row.DBCampo("PuedeRefacturar").ToString().ToEntero() == 0)
//{
// e.Row.Cells[14].Text = "";
//}
if (e.Row.DBCampo("PuedeRefacturar").ToString().ToEntero() == 1 && e.Row.DBCampo("CveEstatusFactura").ToString().ToEntero() == 23)
{
e.Row.FCLinkButton("LnkValidarRefac").Visible = false;
}
//if (e.Row.DBCampo("PuedeRefacturar").ToString().ToEntero() == 1 && e.Row.DBCampo("CveEstatusFactura").ToString().ToEntero() == 23)
//{
// e.Row.FCLinkButton("LnkValidarRefac").Visible = false;
//}
if (e.Row.DBCampo("PuedeRefacturar").ToString().ToEntero() == 0 && e.Row.DBCampo("CveEstatusFactura").ToString().ToEntero() == 23 && e.Row.DBCampo("CveVentaSustitucion").ToEntero() > 0)
{
e.Row.FCLinkButton("LnkCancelar").Visible = true;
e.Row.FCLinkButton("LnkValidarRefac").Visible = false;
//e.Row.FCLinkButton("LnkValidarRefac").Visible = false;
}
}
}
@@ -483,6 +484,32 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
Alert("No se encontro la factura para enviar el acuse", TipoMensaje.MsgAdvertencia);
}
}
private byte[] DescargarPDF(string Parametros)
{
var Url = new Uri(string.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", ClsPaginas.UrlSitio, Parametros));
byte[] File = null;
try
{
using (var httpClient = new HttpClient())
{
httpClient.Timeout = new TimeSpan(0, 15, 0);
using (var request = new HttpRequestMessage(HttpMethod.Get, Url))
{
request.Headers.Add("ADSToken", Encripta(string.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO={2}", UsuarioActual.CveEmpresa, DateTime.UtcNow.Ticks, UsuarioActual.CveUsuario)));
var response = httpClient.SendAsync(request).Result;
if (response.StatusCode == System.Net.HttpStatusCode.OK)
File = response.Content.ReadAsByteArrayAsync().Result;
}
}
}
catch (Exception ex)
{
File = null;
this.OnError("Ocurrió un error al descargar la factura", ex);
}
return File;
}
public void ImprimeCancelacion(int CveVenta)
{
@@ -491,32 +518,34 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
var ObjFactura = new Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa);
string SelloCancelacion = "";
string FechaCancelacion = "";
DataTable DtDatos = null;
//string SelloCancelacion = "";
//string FechaCancelacion = "";
//DataTable DtDatos = null;
using (ClsVentas ObjVentas = new ClsVentas())
{
if (ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa))
{
DtDatos = ObjVentas.DtResultados.Copy();
//using (ClsVentas ObjVentas = new ClsVentas())
//{
// if (ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa))
// {
// DtDatos = ObjVentas.DtResultados.Copy();
DataRow drv = DtDatos.Rows[0];
SelloCancelacion = drv["SelloCancelacion"].ToString();
FechaCancelacion = drv["FechaCancelacion"].ToString().ToDateTime().ToString("dd/MM/yyyy HH:mm:ss");
}
}
// DataRow drv = DtDatos.Rows[0];
// SelloCancelacion = drv["SelloCancelacion"].ToString();
// FechaCancelacion = drv["FechaCancelacion"].ToString().ToDateTime().ToString("dd/MM/yyyy HH:mm:ss");
// }
//}
List<ReportParameter> parametros = new List<ReportParameter>();
parametros.Add(new ReportParameter("FechaCancelacion", FechaCancelacion.ToString()));
parametros.Add(new ReportParameter("FolioFiscal", ObjFactura.FolioFiscal));
parametros.Add(new ReportParameter("RFCEmisor", UsuarioActual.Empresa.RFC));
parametros.Add(new ReportParameter("SelloCancelacion", SelloCancelacion));
//List<ReportParameter> parametros = new List<ReportParameter>();
//parametros.Add(new ReportParameter("FechaCancelacion", FechaCancelacion.ToString()));
//parametros.Add(new ReportParameter("FolioFiscal", ObjFactura.FolioFiscal));
//parametros.Add(new ReportParameter("RFCEmisor", UsuarioActual.Empresa.RFC));
//parametros.Add(new ReportParameter("SelloCancelacion", SelloCancelacion));
byte[] ObjetoPDF = StreamPDF(@"Empresas\Grales\Formatos\AcuseCancelacion.rdlc", DtDatos, parametros, "AcuseCancelacion" + CveVenta);
//byte[] ObjetoPDF = StreamPDF(@"Empresas\Grales\Formatos\AcuseCancelacion.rdlc", DtDatos, parametros, "AcuseCancelacion" + CveVenta);
byte[] ObjetoPDF = DescargarPDF(Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta)));
List<ClsSisMail.ArchivoMail> LSRutasMail = new List<ClsSisMail.ArchivoMail>();
List <ClsSisMail.ArchivoMail> LSRutasMail = new List<ClsSisMail.ArchivoMail>();
string Asunto = string.Empty;
string Cuerpo = string.Empty;

View File

@@ -637,7 +637,7 @@
<td><b>Serie - Folio:</b></td>
<td>
<asp:Label ID="LblSerie" runat="server"></asp:Label>-
<asp:TextBox ID="TxtFolio" runat="server" BorderStyle="None" Text="000" MaxLength="7" Width="60px" ValidationGroup="GrpEmitirImprimir" Style="text-align: left"></asp:TextBox>
<asp:TextBox ID="TxtFolio" runat="server" BorderStyle="None" Text="000" MaxLength="7" Width="60px" ValidationGroup="GrpEmitirImprimir" Style="text-align: left" autopostback="true"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVFolio" runat="server" ControlToValidate="TxtFolio" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Folio''</b> es necesario, por favor ingréselo." ValidationGroup="GrpEmitirImprimir"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender10" runat="server" HighlightCssClass="vco" TargetControlID="RFVFolio" Width="350px"></ajax:ValidatorCalloutExtender>
<asp:CompareValidator ID="CVFolio" runat="server" ControlToValidate="TxtFolio" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Folio''</b> no tiene el formato correcto, solo formato numérico." Operator="DataTypeCheck" Type="Integer" ValidationGroup="GrpEmitirImprimir"></asp:CompareValidator>
@@ -5725,7 +5725,7 @@
<asp:Button ID="BtnRefacturacionConfirmarAceptacion" runat="server" ClientIDMode="Static" Text="Refacturacion Aceptacion Documento" Style="display: none;" />
<asp:Button ID="BtnRefrescarPagina" runat="server" ClientIDMode="Static" Text="Refrescar" Style="display: none;" />
<asp:Button ID="BtnAplicaNuevaNC" runat="server" ClientIDMode="Static" Text="AplicarNC" Style="display: none;" />
<asp:HiddenField ID="HdnCveVentaAcuse" runat="server" ClientIDMode="Static" Value="0" />
<%--FLETES--%>
<div id="ModalFletes" class="modal ADS fade" role="dialog">
<asp:UpdatePanel ID="UpFletes" class="modal-dialog rowpadding" tabindex="-1" runat="server" UpdateMode="Conditional">
@@ -7080,10 +7080,10 @@
</div>
<div class="row" id="DivRelacionadasCancelacion" runat="server" visible="false">
<div class="col-md-6">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
Facturas Padre
Facturas que impiden su cancelación
</div>
</div>
<div class="row">
@@ -7097,9 +7097,8 @@
</asp:GridView>
</div>
</div>
</div>
<div class="col-md-6">
<%-- <div class="col-md-6">
<div class="row">
<div class="col-md-12">
Facturas Hijo
@@ -7117,7 +7116,7 @@
</div>
</div>
</div>
</div>--%>
</div>
<br />
<div class="row" id="DivMotivoCancelacion" runat="server">
@@ -7803,24 +7802,54 @@
</div>
</div>
<div class="row">
<div class="col-md-2">
<label>Motivo:</label>
</div>
<div class="col-md-10">
<asp:DropDownList ID="DdlMotivoRefacturacion" CssClass=" form-control input-sm select2me" runat="server" Width="100%" DataTextField="MotivoCancelacion" DataValueField="CveMotivoCancelacion">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVDdlMotivoRefac" runat="server" CssClass="help-block errorimput" Display="Dynamic" InitialValue="-1" ControlToValidate="DdlMotivoRefacturacion" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Motivo''</b> es necesario, por favor ingréselo." ValidationGroup="GrpMotivo"></asp:RequiredFieldValidator>
<div class="col-md-12">
<asp:Label ID="LbExtraRefacturacion" runat="server"></asp:Label>
</div>
</div>
<div class="row">
<div class="col-md-2">
<label>Descripción:</label>
</div>
<div class="col-md-10">
<asp:TextBox ID="TxtMotivoRefac" runat="server" Height="100" Width="100%" TextMode="MultiLine" CausesValidation="true" MaxLength="500"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVTxtMotivoRefac" runat="server" Display="Dynamic" CssClass="help-block errorimput" ControlToValidate="TxtMotivoRefac" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Descripción''</b> es necesario, por favor ingréselo." ValidationGroup="GrpMotivo"></asp:RequiredFieldValidator>
<div class="row" id="DivRelacionadasRefacturacion" runat="server" visible="false">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
Facturas que impiden su cancelación
</div>
</div>
<div class="row">
<div class="col-md-12">
<asp:GridView ID="GvFacturasPadreRefacturar" runat="server" DataKeyNames="CveVenta" CssClass="table table-striped table-hover Widthall" AutoGenerateColumns="False" ClientIDMode="Static" EmptyDataText="" GridLines="None">
<Columns>
<asp:HyperLinkField DataTextField="SerieFolio" HeaderText="Serie Folio" Target="_blank" DataNavigateUrlFields="CveVenta" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" />
<asp:BoundField DataField="TipoDocto" HeaderText="Tipo" />
<asp:BoundField DataField="FolioFiscal" HeaderText="Folio Fiscal" />
</Columns>
</asp:GridView>
</div>
</div>
</div>
</div>
<div class="row" id="DivMotivoRefacturacionTexto" runat="server">
<div class="col-md-12">
<div class="row">
<div class="col-md-2">
<label>Motivo:</label>
</div>
<div class="col-md-10">
<asp:DropDownList ID="DdlMotivoRefacturacion" CssClass=" form-control input-sm select2me" runat="server" Width="100%" DataTextField="MotivoCancelacion" DataValueField="CveMotivoCancelacion">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVDdlMotivoRefac" runat="server" CssClass="help-block errorimput" Display="Dynamic" InitialValue="-1" ControlToValidate="DdlMotivoRefacturacion" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Motivo''</b> es necesario, por favor ingréselo." ValidationGroup="GrpMotivo"></asp:RequiredFieldValidator>
</div>
</div>
<div class="row">
<div class="col-md-2">
<label>Descripción:</label>
</div>
<div class="col-md-10">
<asp:TextBox ID="TxtMotivoRefac" runat="server" Height="100" Width="100%" TextMode="MultiLine" CausesValidation="true" MaxLength="500"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVTxtMotivoRefac" runat="server" Display="Dynamic" CssClass="help-block errorimput" ControlToValidate="TxtMotivoRefac" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Descripción''</b> es necesario, por favor ingréselo." ValidationGroup="GrpMotivo"></asp:RequiredFieldValidator>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<asp:LinkButton ID="BtnMotivoRefacturacion" runat="server" CssClass="btn btn-primary" ValidationGroup="GrpMotivo"> Refacturar</asp:LinkButton>
@@ -9285,7 +9314,8 @@
$('#BtnMateriales').click();
}
function BtnEnviarMailCancelacion() {
function BtnEnviarMailCancelacion(CveVenta) {
HdnCveVentaAcuse.value = CveVenta;
$('#BtnEnviarMailCancelacion').click();
}
function BtnRefacturacionConfirmar() {
@@ -9304,6 +9334,10 @@
$('#BtnAplicaNuevaNC').click();
}
function BtnAplicaNuevaNC() {
$('#BtnAplicaNuevaNC').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(); });

View File

@@ -1310,14 +1310,7 @@ Partial Class Ventas
ViewState("CveVentaUsadoDevolucionEfectivo") = value
End Set
End Property
Private Property CveFormaPago33Cliente As Integer
Get
Return If(IsNothing(ViewState("CveFormaPago33Cliente")), -1, ViewState("CveFormaPago33Cliente")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveFormaPago33Cliente") = value
End Set
End Property
Private Property RFCReceptorVenta As String
Get
@@ -1887,6 +1880,31 @@ Partial Class Ventas
ViewState("CveFormaPago33Venta") = value
End Set
End Property
Private Property CveMetodoPago33Cliente As Integer
Get
Return If(IsNothing(ViewState("CveMetodoPago33Cliente")), -1, ViewState("CveMetodoPago33Cliente")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveMetodoPago33Cliente") = value
End Set
End Property
Private Property CveFormaPago33Cliente As Integer
Get
Return If(IsNothing(ViewState("CveFormaPago33Cliente")), -1, ViewState("CveFormaPago33Cliente")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveFormaPago33Cliente") = value
End Set
End Property
Private Property CveVendedorVenta As Integer
Get
Return (IfNull(ViewState("CveVendedorVenta"), "-1", ViewState("CveVendedorVenta"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveVendedorVenta") = value
End Set
End Property
Private Property DiasCredito As Integer
Get
Return ViewState("DiasCredito").ToString().ToEntero()
@@ -2059,6 +2077,15 @@ Partial Class Ventas
End Set
End Property
Private Property EsGarantia As Boolean
Get
Return CBool(IfNull(ViewState("EsGarantia"), False, ViewState("EsGarantia")))
End Get
Set(value As Boolean)
ViewState("EsGarantia") = value
End Set
End Property
#End Region
'#Region "AuxiliarConta"
@@ -2149,6 +2176,8 @@ Partial Class Ventas
ViewState("ClienteRetISR") = 0
ViewState("CvePrecioLista") = 0
ViewState("CvePrecioListaCliente") = 0
Me.CveVendedorVenta = -1
Me.EsGarantia = False
idCuentaContabilizacion = 1
CveEmpresaCRM = 0
CveAcercamientoCRM = 0
@@ -3047,6 +3076,15 @@ Partial Class Ventas
End If
'QUITAR ESTAS OPCIONES SI LA FACTURA VA SER CANCELADA O ESTA CANCELADA
If CveEstatus.Contiene(4, 5, 12, 13, 20, 23) Then
LBNotaCredito.Visible = False
LnkAplicarRNCDevolucion.Visible = False
HLPagar.Visible = False
HLSaldarVenta.Visible = False
HlFacturasRelaciondas.Visible = False
End If
End If
''EN REALIDAD SE OCUPAN ESTAS COSAS DENTRO DEL POSTABCK ???
@@ -3098,8 +3136,6 @@ Partial Class Ventas
'End If
'UNA VEZ CARGADA LAS CONDICIONES DE PAGO INICIALMENTE, NO VUELVE A SOBREESCRIBIR EL VALOR
CveFormaPago33Cliente = -1
If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
trRotacion.Visible = True
@@ -4187,6 +4223,8 @@ Partial Class Ventas
ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero()
Me.EsGarantia = CBool(DbRowVenta("EsGarantia"))
Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString().ToEntero()
'CargaEncabezado
If Not (CveRemision > 0 Or CveCotizacion > 0) Then
@@ -4214,7 +4252,7 @@ Partial Class Ventas
'End If
If Not CveEstatus.Contiene(4, 5, 12, 13, 20) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then
If Not CveEstatus.Contiene(4, 5, 12, 13, 20, 23) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then
Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto")))
If TienePermiso <> "" Then
LkRefacturacion.Visible = True
@@ -4571,6 +4609,17 @@ Partial Class Ventas
Me.CveMetodoPago33Venta = DbRowVenta("CveMetodoPago33").ToString().ToEntero()
Me.CveFormaPago33Venta = DbRowVenta("CveFormaPago33").ToString().ToEntero()
Me.CveVendedorVenta = DbRowVenta("CveVendedor").ToString().ToEntero()
'SI YA TIENE UN VALOR ASIGNADO SELECCIONA EL GUARDADO
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveVenta > 0 AndAlso Me.CveVendedorVenta > 0 Then
Dim Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=1).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta))
'SI NO ENCUENTRA BUSCA EN LOS VENDEDORES DEL PV
If String.IsNullOrEmpty(Vendedor) Then
Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=4).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta))
End If
DdlVendedor.SelectedValueExistInsert(Me.CveVendedorVenta, Vendedor)
End If
If DdlFormaPago33.SelectedValue <> DbRowVenta("CveFormaPago33").ToString() And DbRowVenta("CveFormaPago33").ToString() <> "" Then
'sino está seleccionada la asginada la debe de cargar
@@ -5838,16 +5887,27 @@ Partial Class Ventas
Dim CveCotizacion As Integer = IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero()
Me.CveMetodoPago33Cliente = ObjCliente.CveMetodoPago33
Me.CveFormaPago33Cliente = ObjCliente.CveFormaPago33
If (CveVenta <= 0 AndAlso CveCotizacion <= 0) Or EsCreaApartirDe Or NuevaFactura = 1 OrElse ModalidadEdicion Then
'CveMetodoPagoCliente = ObjCliente.CveMetodoPago
DdlMetodoPago33.SelectedValueExist(ObjCliente.CveMetodoPago33)
CambiaMetodoPago33()
DdlFormaPago33.SelectedValueExist(ObjCliente.CveFormaPago33)
If UsuarioActual.Empresa.Funcionalidad(589) = "1" Then
'SI EL METODO DE PAGO ES PUE, SELECCIONA CONTADO
If Me.CveMetodoPago33Cliente = 1 Then
RBLPago.SelectedValue = "2"
ElseIf Me.CveMetodoPago33Cliente = 3 Then
RBLPago.SelectedValue = "1"
End If
RBLPago_SelectedIndexChanged(RBLPago, Nothing)
UPCondicionesPago.Update()
Else
DdlMetodoPago33.SelectedValueExist(ObjCliente.CveMetodoPago33)
CambiaMetodoPago33()
DdlFormaPago33.SelectedValueExist(ObjCliente.CveFormaPago33)
End If
DdlUsoCFDI.SelectedValueExist(ObjCliente.CveUsoCFDI)
End If
PlazoCobranza = ObjCliente.PlazoCobranza
@@ -6376,9 +6436,21 @@ Partial Class Ventas
If ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta <= 0) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) AndAlso RBLPago.SelectedValue = "1" AndAlso PermiteCredito Then
'FUNCIONALIDAD 702 - NO VERIFICAR LIMITE DE CRÉDITO Y CANDADOS DE VENTA
If Not UsuarioActual.Empresa.Funcionalidad(702) = "1" Then
RBLPago.SelectedValue = "1"
RBLPago_SelectedIndexChanged(Nothing, Nothing)
UPCondicionesPago.Update()
If UsuarioActual.Empresa.Funcionalidad(589) = "1" Then
'SI EL METODO DE PAGO ES PUE, SELECCIONA CONTADO
If Me.CveMetodoPago33Cliente = 1 Then
RBLPago.SelectedValue = "2"
ElseIf Me.CveMetodoPago33Cliente = 3 Then
RBLPago.SelectedValue = "1"
End If
RBLPago_SelectedIndexChanged(RBLPago, Nothing)
UPCondicionesPago.Update()
Else
RBLPago.SelectedValue = "1"
RBLPago_SelectedIndexChanged(RBLPago, Nothing)
UPCondicionesPago.Update()
End If
Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero())
@@ -8753,6 +8825,8 @@ Partial Class Ventas
Dim SeTimbroNC As Boolean = False
Dim EstatusSMS = 0
Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing
'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO
If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then
@@ -8769,12 +8843,14 @@ Partial Class Ventas
DebeTimbrar = False
End If
If UsuarioActual.TienePermisoProceso(335) Then
DebeTimbrar = False
End If
If ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then
If DebeTimbrar AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then
If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then
'FACTURA INGRESO/EGRESO
Dim FM As New Modelos.FemsaFactura
Dim TmpDT7Eleven As New DataTable
Dim TmpDTComplementosTimbrado As New DataTable
@@ -8783,64 +8859,50 @@ Partial Class Ventas
PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
End If
'DOCUMENTO ACTUAL
If DebeTimbrar Then
Dim ObjTimbrado As New Timbrado
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
Dim MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
Dim ObjTimbrado As New Timbrado
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
Dim MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
If DebeTimbrar AndAlso ListaNotasCreditoGeneradas.Count > 0 Then
Try
For Each NCGenerada In ListaNotasCreditoGeneradas
If NCGenerada.Timbre IsNot Nothing Then
NCGenerada.Timbre.CFDIRelacionados.UUID.Clear()
NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
Dim ObjTimbradoNC As New Timbrado
Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada)
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
If ListaNotasCreditoGeneradas.Count > 0 Then
Try
For Each NCGenerada In ListaNotasCreditoGeneradas
If NCGenerada.Timbre IsNot Nothing Then
NCGenerada.Timbre.CFDIRelacionados.UUID.Clear()
NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
Dim ObjTimbradoNC As New Timbrado
Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada)
If Not TimbroNC Then
Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError)
End If
ObjTimbradoNC = Nothing
If Not TimbroNC Then
Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError)
End If
Next
Catch ex As Exception
OnError("Ocurrió un error al timbrar la NC.", ex)
End Try
End If
If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then
EstatusSMS = EnviarSMSTimbrado(ObjEventos)
End If
If Not SeTimbro Then
Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
End If
'CANCELAR FACTURA ANTERIOR
If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
If Me.ObjFacturaNC IsNot Nothing Then
Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA
Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura)
End If
End If
ObjTimbradoNC = Nothing
End If
Next
Catch ex As Exception
OnError("Ocurrió un error al timbrar la NC.", ex)
End Try
End If
''NOTA DE CREDITO DE REFACTURACION
'If RefacturacionGeneroNC Then
' If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 Then
' Dim ofa As Modelos.Factura = CType(ObjNC(0), Modelos.Factura)
' SeTimbroNC = ObjTimbrado.TimbrarFactura(UsuarioActual, ofa)
' End If
'End If
If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then
EstatusSMS = EnviarSMSTimbrado(ObjEventos)
End If
If Not SeTimbro Then
Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
End If
'CANCELAR FACTURA ANTERIOR
If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
If Me.ObjFacturaNC IsNot Nothing Then
Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA
MsgCancelacionRefacturacion = Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura)
End If
End If
End If
End If
@@ -8987,6 +9049,17 @@ Partial Class Ventas
MensajeAlert.AppendFormat(String.Format("<br/>La nota de crédito <b>{0}</b> por descuento pronto pago se generó correctamente.<br/><br/>", SerieFolioNCProntoPago))
End If
If MsgCancelacionRefacturacion IsNot Nothing Then
If Not MsgCancelacionRefacturacion.HuboError Then
If MsgCancelacionRefacturacion.CveEstatus = 5 Then
MensajeAlert.AppendFormat("<br/>El folio <b>{0}</b> fue cancelado. <b><a target='_blank' class='Texto' href=""/Compras/PopUpVerFactura.aspx?P={1}"">Descargar Acuse</a></b>", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta)))
ElseIf MsgCancelacionRefacturacion.CveEstatus = 20 Then
MensajeAlert.AppendFormat("<br/>El folio <b>{0}</b> esta en proceso de cancelación. <b><a target='_blank' class='Texto' href=""/Compras/PopUpVerFactura.aspx?P={1}"">Descargar Acuse</a></b>", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta)))
End If
MensajeAlert.AppendFormat("&nbsp;<a target='_self' class='Texto' href=""javascript:BtnEnviarMailCancelacion({0});"">Enviar Acuse</a>.<br/><br/>", Me.ObjFacturaNC.CveVenta)
End If
End If
'MUESTA ALERT OK
' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-.
'Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";"))
@@ -10505,6 +10578,8 @@ Partial Class Ventas
ObjFactura.NuevaFactura = Me.NuevaFactura
ObjFactura.EsGarantia = Me.EsGarantia
'ASIGNAR RFC RECEPTOR
If ObjFactura.Timbre IsNot Nothing Then
If ObjFactura.Timbre.Receptor IsNot Nothing Then
@@ -11669,7 +11744,16 @@ Partial Class Ventas
ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la Factura.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
Exit For
Else
'VERIFICAR QUE EL DESCUENTO NO PASE EL 40%
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Row("CveClasificacion").ToString().ToEntero() <> 20519 AndAlso (Not Row("Obs").ToString().Contains("Descuento por garantía")) Then
Dim TotalDetalle = Math.Round((Row("Total").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6)
Dim DescuentoDetalle = Row("Descuento").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1))
Dim PorcentajeDescuento As Double = (DescuentoDetalle / TotalDetalle) * 100D
If PorcentajeDescuento > 40 Then
ErrorList.Add(String.Format("El descuento del producto/servicio {0} no puede ser mayor al 40%. Porcentaje Actual: {1}%", Row("CodigoPS"), PorcentajeDescuento.RoundSQL(2)))
Exit For
End If
End If
'Agregamos el gasto de contrato
If CveContrato > 0 AndAlso factura.TipoDocto = "Rem" AndAlso AplicaGastoContrato Then
@@ -16388,6 +16472,7 @@ Partial Class Ventas
TrRFC.Visible = False
'RBLPago.Enabled = False
RBLPago.SelectedValue = "2"
RBLPago_SelectedIndexChanged(RBLPago, EventArgs.Empty)
TxtFechaVencimientoCotizacion.Text = Now.ToString()
GvPS.Columns(5).Visible = True
ThTiempoEntrega.Visible = True
@@ -20352,8 +20437,66 @@ Partial Class Ventas
If Vigencia IsNot Nothing Then
If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
Alert("Esta factura no es cancelable.", TipoMensaje.MsgAdvertencia)
Exit Sub
sb.AppendFormat("<b>{0}</b> <br/>", Vigencia.EsCancelable)
DivRelacionadasRefacturacion.Visible = True
BtnMotivoRefacturacion.Visible = False
DivMotivoRefacturacionTexto.Visible = False
Dim Relacionados = Timbrado.ConsultarUUIDRelacionados(UsuarioActual.Empresa, FolioFiscal, UsuarioActual.Empresa.FacturaProduccion)
If Relacionados IsNot Nothing Then
Dim sbExtra As New StringBuilder()
If Relacionados.Codigo = 500 Then
sbExtra.Append("El servicio de verificación de documentos relacionados no esta disponible.")
Else
sbExtra.Append(Relacionados.Mensaje)
Dim SbHijos = New StringBuilder()
Dim SbPadres = New StringBuilder()
'If Relacionados.RelacionadosHijo IsNot Nothing Then
' For Each hijo In Relacionados.RelacionadosHijo
' SbHijos.AppendFormat("{0};", hijo.Uuid)
' Next
' If SbHijos.Length > 0 Then
' SbHijos.Remove(SbHijos.Length - 1, 1)
' End If
'End If
If Relacionados.RelacionadosPadre IsNot Nothing Then
For Each padre In Relacionados.RelacionadosPadre
SbPadres.AppendFormat("{0};", padre.Uuid)
Next
If SbPadres.Length > 0 Then
SbPadres.Remove(SbPadres.Length - 1, 1)
End If
End If
Using ObjVentas As New ClsVentas
'If SbHijos.Length > 0 Then
' If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbHijos.ToString(), UsuarioActual.CveEmpresa) Then
' GvFacturasHijosCancelar.DataSource = ObjVentas.DtResultados.Copy()
' End If
'End If
If SbPadres.Length > 0 Then
If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbPadres.ToString(), UsuarioActual.CveEmpresa) Then
GvFacturasPadreRefacturar.DataSource = ObjVentas.DtResultados.FiltraParametros($"CveVenta <> {CveVenta}")
End If
End If
End Using
'GvFacturasHijosCancelar.DataBind()
GvFacturasPadreRefacturar.DataBind()
End If
If sbExtra.Length > 0 Then
LbExtraRefacturacion.Text = $"<br><b>*{sbExtra.ToString()}</b>"
End If
End If
End If
If Vigencia.EsCancelable = "Cancelable sin aceptación" Then
@@ -21028,6 +21171,12 @@ Partial Class Ventas
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
'SI ES VENTA NUEVA, ASIGNA LA DEL CLIENTE
If (Me.CveVenta <= 0 OrElse Me.EsCreaApartirDe) AndAlso Me.CveFormaPago33Cliente > 0 Then
DdlFormaPago33.SelectedValueExist(Me.CveFormaPago33Cliente)
End If
'SI ES VENTA EXISTENTE, ASIGNA LA GUARDADA
If Me.CveVenta > 0 AndAlso (Not Me.EsCreaApartirDe) AndAlso Me.CveFormaPago33Venta > 0 Then
DdlFormaPago33.SelectedValueExist(Me.CveFormaPago33Venta)
End If
@@ -21059,6 +21208,11 @@ Partial Class Ventas
End If
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
'SI ES VENTA NUEVA, ASIGNA LA DEL CLIENTE
If (Me.CveVenta <= 0 OrElse Me.EsCreaApartirDe) AndAlso Me.CveFormaPago33Cliente > 0 Then
DdlFormaPago33.SelectedValueExist(Me.CveFormaPago33Cliente)
End If
'SI ES VENTA EXISTENTE, ASIGNA LA GUARDADA
If Me.CveVenta > 0 AndAlso (Not Me.EsCreaApartirDe) AndAlso (Not Me.ModalidadEdicion) AndAlso Me.CveFormaPago33Venta > 0 Then
DdlFormaPago33.SelectedValueExist(Me.CveFormaPago33Venta)
End If
@@ -22830,86 +22984,107 @@ Partial Class Ventas
#Region "Cancelar, Generar y mandar por correo el acuse de cancelación."
Private Sub BtnEnviarMailCancelacion_Click(sender As Object, e As EventArgs) Handles BtnEnviarMailCancelacion.Click
ImprimeCancelacion(CveVenta)
EnviarPDFCancelacion(HdnCveVentaAcuse.Value.ToEntero())
HdnCveVentaAcuse.Value = "0"
End Sub
Public Sub ImprimeCancelacion(CveVenta As Integer)
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
Dim drv As DataRow = ObjVentas.DtResultados.Rows(0)
Dim FolioFiscal = drv("FolioFiscal").ToString()
Dim SelloCancelacion = drv("SelloCancelacion").ToString()
Dim FechaCancelacion = drv("FechaCancelacion").ToString().ToDateTime.ToString("dd/MM/yyyy HH:mm:ss")
Dim RFC = UsuarioActual.Empresa.RFC
Dim Archivo As New System.IO.FileInfo("Empresas\Grales\Formatos\AcuseCancelacion.rdlc")
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("FechaCancelacion", FechaCancelacion.ToString()))
params.Add(New ReportParameter("FolioFiscal", FolioFiscal))
params.Add(New ReportParameter("RFCEmisor", RFC))
params.Add(New ReportParameter("SelloCancelacion", SelloCancelacion))
Private Function DescargarPDF(Parametros As String) As Byte()
Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", ClsPaginas.UrlSitio, Parametros))
Dim File As Byte() = Nothing
Try
Using httpClient = New HttpClient()
httpClient.Timeout = New TimeSpan(0, 15, 0)
Using request = New HttpRequestMessage(HttpMethod.Get, Url)
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO={2}", UsuarioActual.CveEmpresa, DateTime.UtcNow.Ticks, UsuarioActual.CveUsuario)))
Dim response = httpClient.SendAsync(request).Result
If response.StatusCode = Net.HttpStatusCode.OK Then
File = response.Content.ReadAsByteArrayAsync().Result
End If
End Using
End Using
Catch ex As Exception
File = Nothing
OnError("Ocurrió un error al descargar la factura", ex)
End Try
Dim ObjetoPDF As Byte() = StreamPDF("Empresas\Grales\Formatos\AcuseCancelacion.rdlc", ObjVentas.DtResultados, params, "AcuseCancelacion" & CveVenta)
Dim ObjMail As New ClsSisMail
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
Dim Asunto As String = String.Empty
Dim Cuerpo As String = String.Empty
Dim ResultadoMail As Integer
Dim sb As New StringBuilder()
If UsuarioActual.CveEmpresa = 119 Then
sb.Append("<!DOCTYPE html>")
sb.Append("<html>")
sb.Append("<head>")
sb.Append("<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>")
sb.Append(" <title>Acuse De Cancelación</title>")
sb.Append(" <meta charset=""utf-8"" />")
sb.Append("</head>")
sb.Append("<body>")
sb.Append(" <font face=""calibri"">")
sb.Append($" Estimado Cliente <b>{NombreCliente}</b>,<br /><br />")
sb.Append($" Le informamos que Agroquímicos JAM, S.A. DE C.V ha cancelado el CFDI <b>{Serie}-{Folio}</b>, el cual ha quedado sin Efectos Fiscales y encontrará adjunto en este correo el Acuse de <br />")
sb.Append($" cancelación del SAT.<br />")
sb.Append(" POR LO QUE PEDIMOS ELIMINARLO Y NO INCLUIRLO EN SU CONTABILIDAD, YA QUE PUEDE REPRESENTAR UN PROBLEMA FISCAL PARA USTED O SU EMPRESA CUANDO EL SAT REALICE UNA FUTURA AUDITORIA <br /> ")
sb.Append(" EN SU CONTABILIDAD. </font> ")
sb.Append(" <font face=""calibri"" size=""2"">")
sb.Append(" <br /><br /><br /><br /><br />")
sb.Append(" <i>Este correo se generó automaticamente, favor de no responder este mensaje.</i>")
sb.Append(" </font>")
sb.Append("</body>")
sb.Append("</html>")
Else
sb.Append("<!DOCTYPE html>")
sb.Append("<html>")
sb.Append("<head>")
sb.Append("<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>")
sb.Append(" <title>Acuse De Cancelación</title>")
sb.Append(" <meta charset=""utf-8"" />")
sb.Append("</head>")
sb.Append("<body>")
sb.Append(" <font face=""calibri"">")
sb.Append($" Estimado Cliente <b>{NombreCliente}</b>,<br /><br />")
sb.Append($" A través del presente medio la Empresa <b>{UsuarioActual.Empresa.Empresa} - {RFC}</b>, canceló el documento tipo <b>{DdlTipoComprobante.SelectedItem.Text}</b> <br />")
sb.Append($" con folio <b>{Serie}-{Folio}</b> y el Importe de <b>${TxtTotal.Text}</b>. <br /><br />")
sb.Append(" Le hacemos llegar el acuse de cancelación. </font> ")
sb.Append(" <font face=""calibri"" size=""2"">")
sb.Append(" <br /><br /><br /><br /><br />")
sb.Append(" <i>Este correo se generó automaticamente, favor de no responder este mensaje.</i>")
sb.Append(" </font>")
sb.Append("</body>")
sb.Append("</html>")
Return File
End Function
Public Sub EnviarPDFCancelacion(CveVenta As Integer)
Dim FacturaRef As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa)
If FacturaRef IsNot Nothing Then
Dim ObjetoPDF As Byte() = DescargarPDF(Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta)))
If ObjetoPDF IsNot Nothing Then
Dim RFC = UsuarioActual.Empresa.RFC
Dim ObjMail As New ClsSisMail
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
Dim Asunto As String = String.Empty
Dim Cuerpo As String = String.Empty
Dim ResultadoMail As Integer
Dim sb As New StringBuilder()
If UsuarioActual.CveEmpresa = 119 Then
sb.Append("<!DOCTYPE html>")
sb.Append("<html>")
sb.Append("<head>")
sb.Append("<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>")
sb.Append(" <title>Acuse De Cancelación</title>")
sb.Append(" <meta charset=""utf-8"" />")
sb.Append("</head>")
sb.Append("<body>")
sb.Append(" <font face=""calibri"">")
sb.Append($" Estimado Cliente <b>{FacturaRef.Cliente.Nombre}</b>,<br /><br />")
sb.Append($" Le informamos que Agroquímicos JAM, S.A. DE C.V ha cancelado el CFDI <b>{FacturaRef.SerieFolio}</b>, el cual ha quedado sin Efectos Fiscales y encontrará adjunto en este correo el Acuse de <br />")
sb.Append($" cancelación del SAT.<br />")
sb.Append(" POR LO QUE PEDIMOS ELIMINARLO Y NO INCLUIRLO EN SU CONTABILIDAD, YA QUE PUEDE REPRESENTAR UN PROBLEMA FISCAL PARA USTED O SU EMPRESA CUANDO EL SAT REALICE UNA FUTURA AUDITORIA <br /> ")
sb.Append(" EN SU CONTABILIDAD. </font> ")
sb.Append(" <font face=""calibri"" size=""2"">")
sb.Append(" <br /><br /><br /><br /><br />")
sb.Append(" <i>Este correo se generó automaticamente, favor de no responder este mensaje.</i>")
sb.Append(" </font>")
sb.Append("</body>")
sb.Append("</html>")
Else
sb.Append("<!DOCTYPE html>")
sb.Append("<html>")
sb.Append("<head>")
sb.Append("<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>")
sb.Append(" <title>Acuse De Cancelación</title>")
sb.Append(" <meta charset=""utf-8"" />")
sb.Append("</head>")
sb.Append("<body>")
sb.Append(" <font face=""calibri"">")
sb.Append($" Estimado Cliente <b>{FacturaRef.Cliente.Nombre}</b>,<br /><br />")
sb.Append($" A través del presente medio la Empresa <b>{UsuarioActual.Empresa.Empresa} - {RFC}</b>, canceló el documento tipo <b>{FacturaRef.TipodeComprobante}</b> <br />")
sb.Append($" con folio <b>{FacturaRef.SerieFolio}</b> y el Importe de <b>${FacturaRef.Total}</b>. <br /><br />")
sb.Append(" Le hacemos llegar el acuse de cancelación. </font> ")
sb.Append(" <font face=""calibri"" size=""2"">")
sb.Append(" <br /><br /><br /><br /><br />")
sb.Append(" <i>Este correo se generó automaticamente, favor de no responder este mensaje.</i>")
sb.Append(" </font>")
sb.Append("</body>")
sb.Append("</html>")
End If
Asunto = $"Acuse de Cancelación {FacturaRef.SerieFolio}"
Cuerpo = sb.ToString()
Dim DisplayName As String = ""
If UsuarioActual.CveEmpresa = 119 Then DisplayName = "Facturación Agroquímicos JAM"
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = ObjetoPDF, .NombreArchivo = $"AcuseCancelacion{FacturaRef.SerieFolio}.pdf"})
If ObjMail.SendMail(EmpresaActual, Mail, Asunto, Cuerpo, MailCC, LSRutasMail, Displayname:=DisplayName) Then
ResultadoMail = 1
Alert("El acuse de cancelación ha sido envíado correctamente.", JSBtnAceptar:="BtnRefrescarPagina();", ShowCloseButton:=False)
Else
ResultadoMail = 0
End If
sb.Clear()
FacturaRef.Dispose()
FacturaRef = Nothing
End If
Asunto = $"Acuse de Cancelacion {Serie}-{Folio}"
Cuerpo = sb.ToString()
Dim DisplayName As String = ""
If UsuarioActual.CveEmpresa = 119 Then DisplayName = "Facturación Agroquímicos JAM"
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = ObjetoPDF, .NombreArchivo = $"AcuseCancelacion{Serie}-{Folio}.pdf"})
If ObjMail.SendMail(EmpresaActual, Mail, Asunto, Cuerpo, MailCC, LSRutasMail, Displayname:=DisplayName) Then
ResultadoMail = 1
Alert("El acuse de cancelación ha sido envíado correctamente.", JSBtnAceptar:="BtnRefrescarPagina();")
Else
ResultadoMail = 0
End If
sb.Clear()
Else
Alert("No se pudo enviar el acuse de cancelación", TipoMensaje.MsgAdvertencia)
End If
ObjVentas.Dispose()
End Sub
Private Sub MostrarCondicionesCancelacion(Optional Extra As String = "")
@@ -22936,11 +23111,6 @@ Partial Class Ventas
Private Sub LbCancelarDocumento_Click(sender As Object, e As EventArgs) Handles LbCancelarDocumento.Click
'If VentaSaldoAlmacen <> 0 Then
' Alert("El pedido no se puede cancelar ya que tiene movimientos de almacén.<br/>Nota: Primero hay que hacer la devolución al almacén", TipoMensaje.MsgAdvertencia)
'Else
'End If
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then
Dim sb As New StringBuilder()
@@ -22989,50 +23159,55 @@ Partial Class Ventas
Dim Relacionados = Timbrado.ConsultarUUIDRelacionados(UsuarioActual.Empresa, FolioFiscal, UsuarioActual.Empresa.FacturaProduccion)
If Relacionados IsNot Nothing Then
sbExtra.Append(Relacionados.Mensaje)
If Relacionados.Codigo = 500 Then
sbExtra.Append("El servicio de verificación de documentos relacionados no esta disponible.")
Else
sbExtra.Append(Relacionados.Mensaje)
Dim SbHijos = New StringBuilder()
Dim SbPadres = New StringBuilder()
Dim SbHijos = New StringBuilder()
Dim SbPadres = New StringBuilder()
If Relacionados.RelacionadosHijo IsNot Nothing Then
For Each hijo In Relacionados.RelacionadosHijo
SbHijos.AppendFormat("{0};", hijo.Uuid)
Next
If SbHijos.Length > 0 Then
SbHijos.Remove(SbHijos.Length - 1, 1)
End If
End If
'If Relacionados.RelacionadosHijo IsNot Nothing Then
' For Each hijo In Relacionados.RelacionadosHijo
' SbHijos.AppendFormat("{0};", hijo.Uuid)
' Next
' If SbHijos.Length > 0 Then
' SbHijos.Remove(SbHijos.Length - 1, 1)
' End If
'End If
If Relacionados.RelacionadosPadre IsNot Nothing Then
For Each padre In Relacionados.RelacionadosPadre
SbPadres.AppendFormat("{0};", padre.Uuid)
Next
If SbPadres.Length > 0 Then
SbPadres.Remove(SbPadres.Length - 1, 1)
End If
End If
Using ObjVentas As New ClsVentas
If SbHijos.Length > 0 Then
If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbHijos.ToString(), UsuarioActual.CveEmpresa) Then
GvFacturasHijosCancelar.DataSource = ObjVentas.DtResultados.Copy()
If Relacionados.RelacionadosPadre IsNot Nothing Then
For Each padre In Relacionados.RelacionadosPadre
SbPadres.AppendFormat("{0};", padre.Uuid)
Next
If SbPadres.Length > 0 Then
SbPadres.Remove(SbPadres.Length - 1, 1)
End If
End If
If SbPadres.Length > 0 Then
If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbPadres.ToString(), UsuarioActual.CveEmpresa) Then
GvFacturasPadreCancelar.DataSource = ObjVentas.DtResultados.Copy()
Using ObjVentas As New ClsVentas
'If SbHijos.Length > 0 Then
' If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbHijos.ToString(), UsuarioActual.CveEmpresa) Then
' GvFacturasHijosCancelar.DataSource = ObjVentas.DtResultados.Copy()
' End If
'End If
If SbPadres.Length > 0 Then
If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbPadres.ToString(), UsuarioActual.CveEmpresa) Then
GvFacturasPadreCancelar.DataSource = ObjVentas.DtResultados.FiltraParametros($"CveVenta <> {CveVenta}")
End If
End If
End If
End Using
End Using
GvFacturasHijosCancelar.DataBind()
GvFacturasPadreCancelar.DataBind()
'GvFacturasHijosCancelar.DataBind()
GvFacturasPadreCancelar.DataBind()
End If
End If
End If
If String.IsNullOrEmpty(Vigencia.EsCancelable) Then
If UsuarioActual.Empresa.FacturaProduccion AndAlso Not String.IsNullOrEmpty(FolioFiscal) Then
Alert("No se pudo encontrar el estatus de la factura en el SAT.", TipoMensaje.MsgAdvertencia)
@@ -23258,7 +23433,7 @@ Partial Class Ventas
Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();")
Else
If resp.CveEstatus = 5 AndAlso Not EsRefacturacion Then
Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnEnviarMailCancelacion();", TextoConfirmacion:="&nbsp;&nbsp;&nbsp;&nbsp;Si&nbsp;&nbsp;&nbsp;&nbsp;", TextoCancelacion:="&nbsp;&nbsp;&nbsp;&nbsp;<a onclick='Recargar()'>No</>&nbsp;&nbsp;&nbsp;&nbsp;")
Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:=$"BtnEnviarMailCancelacion({CveVenta});", TextoConfirmacion:="&nbsp;&nbsp;&nbsp;&nbsp;Si&nbsp;&nbsp;&nbsp;&nbsp;", TextoCancelacion:="&nbsp;&nbsp;&nbsp;&nbsp;<a onclick='Recargar()'>No</>&nbsp;&nbsp;&nbsp;&nbsp;")
Else
If EsRefacturacion Then
If resp.CveEstatus = 20 Then
@@ -25896,7 +26071,10 @@ Partial Class Ventas
'sino tiene el permiso de peude generar NC
If Not UsuarioActual.TienePermisoProceso(175) Then
Exit Sub
'sino tiene el permiso de peude generar NC no directas, solo relacionadas por proceso
If Not UsuarioActual.TienePermisoProceso(334) Then 'sino tiene el 175 y tampoco el 334, que se salga
Exit Sub
End If
End If
AplicaNCMasiva = True
@@ -26772,7 +26950,7 @@ Partial Class Ventas
CveVentaUsadoDevolucionEfectivo = -1
DdlTipoComprobante.SelectedValue = "Egs"
DdlTipoComprobante.SelectedValueExistInsert("Egs", "Egresos")
Dim AplicaImpuestosLocales As Boolean = False
'Dim ObjCliente As New ClsClientes
@@ -30795,6 +30973,11 @@ Partial Class Ventas
TxtFolio.Text = FolioFijo.ToString()
End If
If EstablecioFolio AndAlso UsuarioActual.CveEmpresa = 140 Then ' CÓDIGO TEMPORAL 2022/01/17
FolioFijo = TxtFolio.Text.ToEntero()
ViewState("FolioActual") = FolioFijo
End If
Dim TipoDoctoViejo As String = DdlTipoComprobante.SelectedValue
DdlTipoComprobante.SelectedValue = TipoDoctoNuevo
TxtFecha.Text = Now.ToString()
@@ -31841,6 +32024,10 @@ Partial Class Ventas
End Sub
Protected Sub GeneraPolizaVentaWS(ObjFactura As Modelos.Factura)
Try
If UsuarioActual.CveUsuario.Contiene(3033, 3491) Then
Exit Sub
End If
'TipoPoliza: 01 Venta, 02 Ajuste, 03 Garantía
Dim TipoPoliza As Integer = 0
For Each Row As GridViewRow In GvCodigosUnicos.Rows