diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 9d76674c8..1a081cf99 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -1068,7 +1068,7 @@ Public Class ClsClientes ' Return Retorno 'End Function Public Function AddSucursal(CveCliente As Integer, Sucursal As String, CveUsuario As Integer, Ciudad As String, Colonia As String, CP As String, Direccion As String, Estado As String, Localidad As String, Pais As String, NoExt As String, NoInt As String, Telefono As String, Correo As String, CorreoCotizacion As String, Contacto As String, CveVendedor As Integer, NumCtaPago As String, CveMetodoPago As Integer, - LimiteCredito As Decimal, CveResponsableSucursal As Integer, CveUsoCFDI As Integer, CveFormaPago33 As Integer, CveMetodoPago33 As Integer, Optional LT As String = "0", Optional LG As String = "0") As Boolean + LimiteCredito As Decimal, CveResponsableSucursal As Integer, CveUsoCFDI As Integer, CveFormaPago33 As Integer, CveMetodoPago33 As Integer, Optional LT As String = "0", Optional LG As String = "0", Optional RFC As String = "") As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_SucursalClienteAdd") @@ -1101,6 +1101,7 @@ Public Class ClsClientes .Add("@LT", SqlDbType.VarChar).Value = LT .Add("@LG", SqlDbType.VarChar).Value = LG + .Add("@RFC", SqlDbType.VarChar).Value = RFC End With @@ -1120,7 +1121,7 @@ Public Class ClsClientes Return Retorno End Function Public Function UpdateSucursal(Sucursal As String, Estatus As Boolean, CveCliente As Integer, CveClienteSucursal As Integer, Ciudad As String, Colonia As String, CP As String, Direccion As String, Estado As String, Localidad As String, Pais As String, NoExt As String, NoInt As String, Telefono As String, Correo As String, CorreoCotizacion As String, Contacto As String, CveVendedor As Integer, NumCtaPago As String, CveMetodoPago As Integer, - LimiteCredito As Decimal, CveResponsableSucursal As Integer, CveUsoCFDI33 As Integer, CveFormaPago33 As Integer, CveMetodoPago33 As Integer, Optional LT As String = "0", Optional LG As String = "0") As Boolean + LimiteCredito As Decimal, CveResponsableSucursal As Integer, CveUsoCFDI33 As Integer, CveFormaPago33 As Integer, CveMetodoPago33 As Integer, Optional LT As String = "0", Optional LG As String = "0", Optional RFC As String = "-1") As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_SucursalClienteUpdate") @@ -1155,7 +1156,8 @@ Public Class ClsClientes .Add("@LT", SqlDbType.VarChar).Value = LT - .Add("@LG", SqlDbType.VarChar).Value = LG + .Add("@LG", SqlDbType.VarChar).Value = LG + .Add("@RFC", SqlDbType.VarChar).Value = RFC End With diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index a654c7650..ee571bfd0 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -341,7 +341,7 @@ Public Class ClsVentas Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveUsoCFDI As Integer = -1, Optional OrdenCompra As String = "-1", Optional CveCuentaTerminal As Integer = -1, Optional CveTipoRelacion As Integer = -1, Optional ImpuestoLocal As Double = 0, Optional CveTipoAmortizacionAnticipo As Integer = -1, Optional CveVentaRelacion As Integer = -1, Optional ImporteRelacion As Decimal = -1, Optional CveEmpresaCRM As Integer = -1, Optional EsInterno As Integer = -1, Optional CveAcercamientoCRM As Integer = -1, Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False, Optional Kilometraje As Double = 0, Optional EsAmortizacion As Boolean = False, Optional CveTipoRetencion As Integer = 0, - Optional CorreoNotificacion As String = "", Optional FormaPaqueteria As Integer = 1) As Boolean + Optional CorreoNotificacion As String = "", Optional FormaPaqueteria As Integer = 1, Optional FacturarSucursal As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_VentasAdd") @@ -432,6 +432,7 @@ Public Class ClsVentas .Add("@CveTipoRetencion", SqlDbType.TinyInt).Value = CveTipoRetencion .Add("@CorreoNotificacion", SqlDbType.VarChar).Value = CorreoNotificacion .Add("@FormaPaqueteria", SqlDbType.Int).Value = FormaPaqueteria + .Add("@FacturarSucursal", SqlDbType.Bit).Value = FacturarSucursal .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue End With diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index da59d111c..4ca5dafc2 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5613,6 +5613,7 @@ Namespace Modelos Public Property Pagado As Decimal Public Property DescuentoProntoPago As Decimal Public Property CveVentaRNCCargo As Integer + Public Property FacturarSucursal As Boolean = False 'Public Property Sucursal As SucursalModel Public Property SubProyecto As Modelos.SubProyectoModel @@ -9079,6 +9080,7 @@ Namespace Modelos FormatoFactura = "" Sucursal = "" CorreoSucursal = "" + RFC = "" End Sub Public Sub New() MyBase.New() @@ -9095,6 +9097,8 @@ Namespace Modelos End Get End Property Public Property CveSucursal As Integer + Public Property RFC As String + Public Property Nombre As String Public Property Calle As String Public Property Direccion As String Public Property NoExt As String @@ -9114,6 +9118,7 @@ Namespace Modelos Public Property TelefonoSucursal As String Public Property ImprimeNombreSucursal As String + End Class diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 520ae6bce..4e0244fe1 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -725,7 +725,7 @@ Public Class Timbrado If Msg = String.Empty Then 'Nodo receptor - Msg = CFDi.ReceptorCfd(Ventas.Cliente.RFC, Ventas.Cliente.Nombre, "", "", Ventas.ClaveUsoCFDI) + Msg = CFDi.ReceptorCfd(ObjCFDITimbre.Receptor.RFC, ObjCFDITimbre.Receptor.Nombre, "", "", Ventas.ClaveUsoCFDI) If Msg = String.Empty Then 'Nodo conceptos, se agregan los PS @@ -941,7 +941,7 @@ Public Class Timbrado Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Ventas.Cliente.RFC, Ventas.TotalTC, FolioFiscal, RutaCBB) + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ObjCFDITimbre.Receptor.RFC, Ventas.TotalTC, FolioFiscal, RutaCBB) ''Genero la addenda de 7-Eleven 'If sevenElevenNumProveedor <> "" AndAlso sevenElevenFolio <> "" AndAlso sevenElevenTienda <> "" AndAlso sevenElevenFecha <> "" AndAlso sevenElevenFecha <> "__/__/____" Then diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index e81cadbb6..3c9ac4d86 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -443,14 +443,14 @@ --%>
- + - - - + + + - +
@@ -460,14 +460,14 @@ - + - +
@@ -638,13 +638,13 @@
-
- +
+
- +
@@ -692,7 +692,9 @@
- Sucursales y/o Departamentos + + +
@@ -704,7 +706,8 @@ - + @@ -787,8 +790,8 @@ - Sucursal/Depto - + +
@@ -1008,16 +1011,16 @@
- - - - - - - - - - + + + + + + + + + +
@@ -1126,11 +1129,11 @@
- +
- + @@ -2369,7 +2372,7 @@
Archivos - + @@ -2377,7 +2380,7 @@ Reenviar Complemento - + <%-- @@ -2428,10 +2431,10 @@ - - - - + + + + @@ -4535,8 +4538,8 @@ @@ -4654,7 +4657,9 @@
- Datos de la Sucursal + + + @@ -4670,7 +4675,9 @@
- +
@@ -4738,10 +4745,17 @@
-
- - - +
+
+ + + +
+
+ + + +
@@ -7069,6 +7083,6 @@ } - + diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index 4601aba6d..c2b28c20a 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -1421,6 +1421,7 @@ Partial Class Clientes 'TxtEstado.Text = ObjClientes.Estado 'TxtPais.Text = ObjClientes.Pais TxtRFC.Text = ObjClientes.RFC + TxtCP.Text = ObjClientes.CP.ToString TxtTelefono.Text = ObjClientes.Telefono TxtContacto.Text = ObjClientes.Contacto @@ -1898,7 +1899,16 @@ Partial Class Clientes GvDireccionesEnvio.DataSource = ObjClientes.DtResultados End If ObjClientes.Dispose() - GvDireccionesEnvio.DataBind() + GvDireccionesEnvio.DataBind() + + If TxtRFC.Text = "XAXX010101000" Then + GvDireccionesEnvio.HeaderRow.FCLiteral("LtlNombreSucursal").Text = "Cliente" + LtlNombreSucursal.Text = "Cliente" + LtlNombreSucursalTitulo.Text = "Cliente" + LtlTituloSurcusalCliente.Text = "Datos del cliente" + LtlGvSucursalesCliente.Text = "Clientes" + End If + UpAgregarSucursal.Update() UpDatos.Update() End Sub Public Sub CargaAFAsignados() @@ -2976,15 +2986,13 @@ Partial Class Clientes Dim LT As String = If(txtLt.Text.ToDouble <> 0, txtLt.Text, "0") Dim LG As String = If(txtLg.Text.ToDouble <> 0, txtLg.Text, "0") + Dim RFC As String = If(String.IsNullOrEmpty(TxtRFCSucursal.Text), "-1", TxtRFCSucursal.Text) If CveCliente > 0 Then If Actualizar Then - Dim Estatus As Boolean = ChkEstatusSucursal.Checked - - If ObjCliente.UpdateSucursal(TxtNombreSucursal.Text.Trim, Estatus, CveCliente, CveClienteSuc, TxtCiudadSucursal.Text.Trim, TxtColoniaSucursal.Text.Trim, TxtCPSucursal.Text.Trim, TxtDireccionSucursal.Text.Trim, TxtEstadoSucursal.Text.Trim, TxtLocalidadSucursal.Text.Trim, TxtPaisSucursal.Text.Trim, TxtNumExtSucursal.Text.Trim, TxtNumIntSucursal.Text.Trim, TxtTelefonoSucursal.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), TxtCorreoSucursal.Text.Trim, TxtCorreoSucursalCotizacion.Text.Trim, TxtContactoSucursal.Text.Trim, DdlVendedorSucursal.SelectedValue.ToEntero, TxtNumeroCuenta.Text, DdlMetodoPagoSucursal.SelectedValue.ToEntero, TxtLimiteCreditoSucursal.Text.ToDecimal, DdlResponsableSucursal.SelectedValue.ToEntero, DdlSucursalUsoCFDI.SelectedValue.ToEntero, DdlSucursalFormaPago33.SelectedValue.ToEntero, DdlSucursalMetodoPago33.SelectedValue.ToEntero, LT:=LT, LG:=LG) Then @@ -3126,6 +3134,7 @@ Partial Class Clientes Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GVSucursales.RowEditing Me.Actualizar = True + Me.DivRFCSucursal.Visible = False Me.CveClienteSuc = GVSucursales.DataKeys(e.NewEditIndex).Value.ToString.ToEntero @@ -3146,6 +3155,8 @@ Partial Class Clientes TxtNumExtSucursal.Text = ObjCliente.DtResultados.Rows(0)("NoExt").ToString TxtNumIntSucursal.Text = ObjCliente.DtResultados.Rows(0)("NoInt").ToString TxtTelefonoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Telefono").ToString + TxtRFCSucursal.Text = ObjCliente.DtResultados.Rows(0)("RFC").ToString + DivRFCSucursal.Visible = Not String.IsNullOrEmpty(TxtRFCSucursal.Text.Trim()) TxtCorreoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Correo").ToString TxtCorreoSucursalCotizacion.Text = ObjCliente.DtResultados(0)("CorreoCotizacion").ToString TxtContactoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Contacto").ToString diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index c2f070605..4a73d5907 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -417,11 +417,33 @@
+ <%-- + + + --%> - - + + + @@ -6880,6 +6902,132 @@ + <%-- MODAL SUCURSAL --%> +
Sucursal y/o Departamento + Comandos
Facturar Sucursal : + +
Sucursal : - - + + + : +
+
+ + +
+
+ +
+
+
+ + + +
+ +
+
+ + Datos del cliente +
+
+
+
+
+
+
+ +
+
+ + + +
+
+
+
+ + + +
+
+
+ + + +
+
+
+ + + +
+
+ + +
+
+
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+ +
+ + + +
+ +
+ + + + +
+ +
+
+ + + +
+ +
+ + + + +
+ +
+
+
+ + + + +
+
@@ -7744,75 +7892,75 @@ function LimpiaModal() { $('#<%= TxtDireccion.ClientID %>').val(''); - $('#<%= TxtColonia.ClientID %>').val(''); - $('#<%= TxtCiudad.ClientID %>').val(''); - $('#<%= TxtEstado.ClientID %>').val(''); - $('#<%= TxtCP.ClientID %>').val(''); - } + $('#<%= TxtColonia.ClientID %>').val(''); + $('#<%= TxtCiudad.ClientID %>').val(''); + $('#<%= TxtEstado.ClientID %>').val(''); + $('#<%= TxtCP.ClientID %>').val(''); + } - function BtnMateriales() { - $('#BtnMateriales').click(); - } + function BtnMateriales() { + $('#BtnMateriales').click(); + } - function BtnEnviarMailCancelacion() { - $('#BtnEnviarMailCancelacion').click(); - } - function BtnRefacturacionConfirmar() { - $('#BtnRefacturacionConfirmar').click(); - } - function BtnRefacturacionConfirmarAceptacion(Liga) { - $('#BtnRefacturacionConfirmarAceptacion').click(); - } - function BtnRefrescarPagina() { - $('#BtnRefrescarPagina').click(); - } - function Recargar() { - $('#BtnRefrescarPagina').click(); - } - function BtnAplicaNuevaNC() { - $('#BtnAplicaNuevaNC').click(); - } + function BtnEnviarMailCancelacion() { + $('#BtnEnviarMailCancelacion').click(); + } + function BtnRefacturacionConfirmar() { + $('#BtnRefacturacionConfirmar').click(); + } + function BtnRefacturacionConfirmarAceptacion(Liga) { + $('#BtnRefacturacionConfirmarAceptacion').click(); + } + function BtnRefrescarPagina() { + $('#BtnRefrescarPagina').click(); + } + function Recargar() { + $('#BtnRefrescarPagina').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(); }); + $('.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(); }); - $("body").on("mouseenter", ".select2-container.select2-container--default.select2-container--open .select2-dropdown li", function (event) { - var $this = $(this); - var ind = $this.index(); - $(".select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable tr.active").removeClass('active'); - $(".select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable tr:nth-child(" + (ind + 2) + ")").addClass('active'); - //log($this); - }); - var scrollfuncion = function () { - var stop = this.scrollTop; - $(".select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable").scrollTop(stop); - } - function CargaExistenciaAlmacenes(data, params) { - var div = $('
'); - $('.select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable').remove(); - $('.select2-container.select2-container--default.select2-container--open .select2-dropdown').prepend(div); - var table = $('
'); div.append(table); - var tbody = $(''); table.append(tbody); - $(".select2-container--default .select2-results>.select2-results__options").off("scroll", scrollfuncion); - $(".select2-container--default .select2-results>.select2-results__options").scroll(scrollfuncion); - var indexd = 0; - data.forEach(function (item) { - if (indexd == 0) { - var tr = $(''); tbody.append(tr); - var td; - for (var key in item) { - if (!(key == "text" || key == "id")) { td = $('' + key + ''); tr.append(td); } - } - } - var tr = $(''); tbody.append(tr); + $("body").on("mouseenter", ".select2-container.select2-container--default.select2-container--open .select2-dropdown li", function (event) { + var $this = $(this); + var ind = $this.index(); + $(".select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable tr.active").removeClass('active'); + $(".select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable tr:nth-child(" + (ind + 2) + ")").addClass('active'); + //log($this); + }); + var scrollfuncion = function () { + var stop = this.scrollTop; + $(".select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable").scrollTop(stop); + } + function CargaExistenciaAlmacenes(data, params) { + var div = $('
'); + $('.select2-container.select2-container--default.select2-container--open .select2-dropdown .select2anothertable').remove(); + $('.select2-container.select2-container--default.select2-container--open .select2-dropdown').prepend(div); + var table = $('
'); div.append(table); + var tbody = $(''); table.append(tbody); + $(".select2-container--default .select2-results>.select2-results__options").off("scroll", scrollfuncion); + $(".select2-container--default .select2-results>.select2-results__options").scroll(scrollfuncion); + var indexd = 0; + data.forEach(function (item) { + if (indexd == 0) { + var tr = $(''); tbody.append(tr); + var td; + for (var key in item) { + if (!(key == "text" || key == "id")) { td = $('' + key + ''); tr.append(td); } + } + } + var tr = $(''); tbody.append(tr); - var td; - for (var key in item) { - if (!(key == "text" || key == "id")) { - if ((item[key] > 0)) { - td = $('' + item[key] + ''); tr.append(td); - } else { - if ('<%= UsuarioActual.Empresa.Funcionalidad(566) %>' == '1') { + var td; + for (var key in item) { + if (!(key == "text" || key == "id")) { + if ((item[key] > 0)) { + td = $('' + item[key] + ''); tr.append(td); + } else { + if ('<%= UsuarioActual.Empresa.Funcionalidad(566) %>' == '1') { var buscarAlmacenes = "CargaExistenciasSucursales(" + item.id + ",'" + item.text + "');" td = $('' + item[key] + ' '); tr.append(td); } else { @@ -7951,17 +8099,17 @@ function ConvertirPesos(ChkConvertirDoctoPesos) { //LIMPIA $('#<%= LtlTotalConvertido.ClientID %>').text(''); - $("#TrConversionPesosTexto").hide(); + $("#TrConversionPesosTexto").hide(); - //CALCULA - if (ChkConvertirDoctoPesos.checked) { - ConvertirDllsPesos(); - } - } + //CALCULA + if (ChkConvertirDoctoPesos.checked) { + ConvertirDllsPesos(); + } + } - function ConvertirPesosDlls() { - var totalPesos = FormatoNumero(ToDouble($get('TxtTotal').value) / ToDouble($get('TxtTipoCambioDlls').value), 2) - $('#<%= LblDolaresConvertidos.ClientID %>').text(totalPesos); + function ConvertirPesosDlls() { + var totalPesos = FormatoNumero(ToDouble($get('TxtTotal').value) / ToDouble($get('TxtTipoCambioDlls').value), 2) + $('#<%= LblDolaresConvertidos.ClientID %>').text(totalPesos); $("#TrConversionDolaresTexto").show(); } @@ -8098,5 +8246,26 @@ } }; + function showDivAgregarSucursal() { + + $('#<%= TxtNombreSucursal.ClientID %>').val(''); + $('#<%= TxtDireccionSucursal.ClientID %>').val(''); + $('#<%= TxtNumExtSucursal.ClientID %>').val(''); + $('#<%= TxtNumIntSucursal.ClientID %>').val(''); + $('#<%= TxtCPSucursal.ClientID %>').val(''); + $('#<%= TxtColoniaSucursal.ClientID %>').val(''); + $('#<%= TxtTelefonoSucursal.ClientID %>').val(''); + $('#<%= TxtCiudadSucursal.ClientID %>').val(''); + $('#<%= TxtLocalidadSucursal.ClientID %>').val(''); + $('#<%= TxtEstadoSucursal.ClientID %>').val(''); + $('#<%= TxtPaisSucursal.ClientID %>').val(''); + $('#<%= TxtCorreoSucursal.ClientID %>').val(''); + $('#divAgregarSucursal').modal(); + } + + function hideDivAgregarSucursal() { + $('#divAgregarSucursal').modal('hide'); + } +
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 9d25b9949..b6d1b85e8 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -1764,6 +1764,23 @@ Partial Class Ventas ViewState("CvePrecioLista") = value End Set End Property + Private Property FacturarSucursal As Boolean + Get + Return CBool(IfNull(ViewState("FacturarSucursal"), "False", ViewState("FacturarSucursal"))) + End Get + Set(value As Boolean) + ViewState("FacturarSucursal") = value + End Set + End Property + + Private Property ClienteSucursal As Modelos.SucursalModel + Get + Return CType(ViewState("ClienteSucursal"), Modelos.SucursalModel) + End Get + Set(value As Modelos.SucursalModel) + ViewState("ClienteSucursal") = value + End Set + End Property #End Region @@ -4566,6 +4583,12 @@ Partial Class Ventas DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString()) + Me.FacturarSucursal = CBool(DbRowVenta("FacturarSucursal").ToString()) + + If Me.FacturarSucursal Then + HabilitarFacturacionSucursal() + End If + CargaPS(-1, DdlPS) 'CARGA GV DE OC RELACIONADAS @@ -4802,7 +4825,10 @@ Partial Class Ventas End Sub Private Sub CargaUsoCFDI() DdlUsoCFDI.DataSource = GlobalDTSATUsosCFDI(UsuarioActual.Empresa.EsPersonaFisica) + DdlSucursalUsoCFDI.DataSource = GlobalDTSATUsosCFDI(UsuarioActual.Empresa.EsPersonaFisica) + DdlUsoCFDI.DataBind() + DdlSucursalUsoCFDI.DataBind() End Sub Private Sub CargaTiposRelacion() DdlTiposRelacion.DataSource = GlobalDTVtaTiposRelacion @@ -5221,6 +5247,11 @@ Partial Class Ventas DdlSucursalCliente.Items.Insert(0, New ListItem("Matriz", "-1")) DdlSucursalCliente.DataBind() + 'SI UTILIZA EL RFC GENERICO PERMITE FACTURAR SUCURSAL + If (CveVenta <= 0 OrElse NuevaFactura = 1) AndAlso LblRFC.Text.Trim() = "XAXX010101000" Then + HabilitarFacturacionSucursal() + End If + 'CargaFolios() CargaDatosEstimaciones(CveCliente) @@ -5576,6 +5607,11 @@ Partial Class Ventas Private Sub CargaClienteSucursal(CveClienteSuc As Integer, Optional ByRef ObjVentas As ClsVentas = Nothing) + Me.ClienteSucursal = Nothing + Me.FacturarSucursal = False + LtlTitleRFCSucursal.Text = "" + LtlRFCSucursal.Text = "" + Dim ObjCliente As New ClsClientes If CveClienteSuc > 0 Then If ObjCliente.GetSucursales(CveCliente, CveClienteSuc) Then @@ -5612,6 +5648,32 @@ Partial Class Ventas UpParametros.Update() End If + 'SI EL CLIENTE TIENE RFC GENERICO Y LA SUCURSAL TIENE RFC DEBE FACTURAR LA SUCURSAL + If LblRFC.Text.Trim() = "XAXX010101000" AndAlso Not String.IsNullOrEmpty(ObjCliente.DtResultados.Rows(0)("RFC").ToString()) Then + Me.FacturarSucursal = True + + LtlTitleRFCSucursal.Text = "RFC:" + LtlRFCSucursal.Text = ObjCliente.DtResultados.Rows(0)("RFC").ToString() + + Me.ClienteSucursal = New Modelos.SucursalModel + Me.ClienteSucursal.Nombre = ObjCliente.DtResultados.Rows(0)("SucursalCliente").ToString() + Me.ClienteSucursal.RFC = ObjCliente.DtResultados.Rows(0)("RFC").ToString() + Me.ClienteSucursal.NoExt = CliNoExt + Me.ClienteSucursal.NoInt = CliNoInt + Me.ClienteSucursal.Localidad = CliLocalidad + Me.ClienteSucursal.Direccion = LblDireccion.Text + Me.ClienteSucursal.Colonia = LblColonia.Text + Me.ClienteSucursal.Municipio = LblCiudad.Text + Me.ClienteSucursal.Estado = LblEstado.Text + Me.ClienteSucursal.CP = LblCP.Text + Me.ClienteSucursal.Pais = CliPais + Me.ClienteSucursal.CorreoSucursal = CliCorreoCot.ToString() + Me.ClienteSucursal.TelefonoSucursal = LblTelefono.Text + Me.ClienteSucursal.Sucursal = If(DdlSucursalCliente.SelectedValue.ToEntero() > 0, DdlSucursalCliente.SelectedItem.Text, "") + Me.ClienteSucursal.ImprimeNombreSucursal = ImprimeNombreSucursal.ToString() + + End If + If CveVenta <= 0 Then CveMetodoPagoCliente = ObjCliente.DtResultados.Rows(0)("CveMetodoPago").ToString().ToEntero() @@ -5666,10 +5728,12 @@ Partial Class Ventas LnkRemisiones.Visible = If(UsuarioActual.TienePermisoProceso(199), True, False) : LnkOCs.Visible = True : LnkCotizaciones.Visible = True : LnkPedido2SinFacturar.Visible = True : InicializaAplicarNCMasiva() End If + ObjCliente.Dispose() + UPPVentas.Update() UpEstatus.Update() UPCondicionesPago.Update() - ObjCliente.Dispose() + UpCliente.Update() End Sub Private Function CargaCreditoDisponible(tCveCliente As Integer, tCveSucursalCliente As Integer, Optional ByRef ObjVentas As ClsVentas = Nothing) As Decimal Dim Retorno As Decimal = 0 @@ -6630,6 +6694,11 @@ Partial Class Ventas DtOCTmpDT = TmpDT.Copy TmpDTError = TmpDT.Copy + If (Me.FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso String.IsNullOrEmpty(Me.ClienteSucursal.RFC))) Then + Alert("La sucursal no tiene asignada un RFC.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + 'CUANDO ES PEDIDO SE DEBE ESPECIFICAR EL NUMERO DE CONTRATO If TrTipoPedido.Visible AndAlso DdlTipoPedido.SelectedIndex = 2 Then If String.IsNullOrEmpty(TxtObsFact.Text.Trim()) Then @@ -7904,6 +7973,10 @@ Partial Class Ventas 'ObjFacturaDevolucion.SetSucursal(Me) ObjFacturaDevolucion.ClienteSucursal = New Modelos.SucursalModel + If Me.ClienteSucursal IsNot Nothing Then + ObjFacturaDevolucion.ClienteSucursal.RFC = Me.ClienteSucursal.RFC + ObjFacturaDevolucion.ClienteSucursal.Nombre = Me.ClienteSucursal.Nombre + End If ObjFacturaDevolucion.ClienteSucursal.NoExt = CliNoExt ObjFacturaDevolucion.ClienteSucursal.NoInt = CliNoInt ObjFacturaDevolucion.ClienteSucursal.Localidad = CliLocalidad @@ -8140,6 +8213,11 @@ Partial Class Ventas 'ObjFacturaBonificacion.SetSucursal(Me) ObjFacturaBonificacion.ClienteSucursal = New Modelos.SucursalModel + If Me.ClienteSucursal IsNot Nothing Then + ObjFacturaBonificacion.ClienteSucursal.Nombre = Me.ClienteSucursal.Nombre + ObjFacturaBonificacion.ClienteSucursal.RFC = Me.ClienteSucursal.RFC + End If + ObjFacturaBonificacion.ClienteSucursal.NoExt = CliNoExt ObjFacturaBonificacion.ClienteSucursal.NoInt = CliNoInt ObjFacturaBonificacion.ClienteSucursal.Localidad = CliLocalidad @@ -8371,7 +8449,6 @@ Partial Class Ventas ObjFactura = New Modelos.Factura End If - ObjFactura.Version = "3.3" ObjFactura.CveUsuario = UsuarioActual.CveUsuario ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa @@ -8383,7 +8460,7 @@ Partial Class Ventas ObjFactura.Moneda = DdlMoneda.SelectedItem.Text ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {DdlMoneda.SelectedValue}") ObjFactura.TipoDocto = If(IfNull(ViewState("CveRemision"), 0).ToString().ToEntero() > 0, "Ing", DdlTipoComprobante.SelectedValue) - + ObjFactura.FacturarSucursal = (Me.FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso Not String.IsNullOrEmpty(Me.ClienteSucursal.RFC))) 'ObjFactura.RefDocto = TxtDocto.Text.Trim 'si es cancelacion, debe de conservar el folio actual @@ -8832,8 +8909,12 @@ Partial Class Ventas 'ObjFactura.CveSubProyecto = DdlSubProyectoDatos.SelectedValue.ToEntero() ObjFactura.SetSubProyectoMatriz(Me) ObjFactura.SetSubProyecto(Me) - ObjFactura.ClienteSucursal = New Modelos.SucursalModel + ObjFactura.ClienteSucursal = New Modelos.SucursalModel() If Not CveEmpresaCRM > 0 Then + If Me.ClienteSucursal IsNot Nothing Then + ObjFactura.ClienteSucursal.RFC = Me.ClienteSucursal.RFC + ObjFactura.ClienteSucursal.Nombre = Me.ClienteSucursal.Nombre + End If ObjFactura.ClienteSucursal.NoExt = CliNoExt ObjFactura.ClienteSucursal.NoInt = CliNoInt ObjFactura.ClienteSucursal.Localidad = CliLocalidad @@ -9232,7 +9313,12 @@ Partial Class Ventas ObjFacturaDevolucion.CveSubProyecto = DdlSubProyectoDatos.SelectedValue.ToEntero() ObjFacturaDevolucion.SetSubProyectoMatriz(Me) ObjFacturaDevolucion.SetSubProyecto(Me) + ObjFacturaDevolucion.ClienteSucursal = New Modelos.SucursalModel + If Me.ClienteSucursal IsNot Nothing Then + ObjFacturaDevolucion.ClienteSucursal.RFC = Me.ClienteSucursal.RFC + ObjFacturaDevolucion.ClienteSucursal.Nombre = Me.ClienteSucursal.Nombre + End If ObjFacturaDevolucion.ClienteSucursal.NoExt = CliNoExt ObjFacturaDevolucion.ClienteSucursal.NoInt = CliNoInt ObjFacturaDevolucion.ClienteSucursal.Localidad = CliLocalidad @@ -9245,6 +9331,7 @@ Partial Class Ventas ObjFacturaDevolucion.ClienteSucursal.CorreoSucursal = CliCorreoCot.ToString() ObjFacturaDevolucion.ClienteSucursal.TelefonoSucursal = LblTelefono.Text ObjFacturaDevolucion.ClienteSucursal.Sucursal = If(DdlSucursalCliente.SelectedValue.ToEntero() > 0, DdlSucursalCliente.SelectedItem.Text, "") + ObjFacturaDevolucion.ClienteSucursal.ImprimeNombreSucursal = ImprimeNombreSucursal.ToString() 'ENVIO DIRECCION ObjFacturaDevolucion.EnviarA = New Modelos.EnviarAModel @@ -9292,13 +9379,18 @@ Partial Class Ventas Timbre.Comprobante.Confirmacion = "" - Timbre.Receptor.RFC = Obj.Cliente.RFC - Timbre.Receptor.Nombre = Obj.Cliente.Nombre + If Obj.FacturarSucursal Then + Timbre.Receptor.RFC = Obj.ClienteSucursal.RFC + Timbre.Receptor.Nombre = Obj.ClienteSucursal.Nombre + Else + Timbre.Receptor.RFC = Obj.Cliente.RFC + Timbre.Receptor.Nombre = Obj.Cliente.Nombre + End If + Timbre.Receptor.ResidenciaFiscal = "" Timbre.Receptor.NumeroRegistroTributario = "" Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI - If HdnTipoDescuento.Value = "3" And DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero() > 0 Then Timbre.CFDIRelacionados.TipoRelacion = "07" @@ -9367,8 +9459,6 @@ Partial Class Ventas End If - - Dim totSubTotal As Decimal = Obj.SubTotal Dim totIVA As Decimal = Obj.IVA Dim totRetIVA As Decimal = Obj.RetIVA @@ -9936,7 +10026,7 @@ Partial Class Ventas CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero() > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False), - Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion, CveTipoRetencion:=factura.CveTipoRetencion, CorreoNotificacion:=TxtCorreoNotificaciones.Text, FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero) Then + Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion, CveTipoRetencion:=factura.CveTipoRetencion, CorreoNotificacion:=TxtCorreoNotificaciones.Text, FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") Else If factura.TipoDocto.Contiene("Dev", "Egs") Or DtVentasNC IsNot Nothing Or CveEstatusRefacturacion = 1 Then @@ -15027,7 +15117,11 @@ Partial Class Ventas DdlVendedor.SelectedValue = "0" DdlVendedor.Items.Insert(0, New ListItem("Sin Asignar", "0")) + + DdlVendedorSucursal.DataSource = DdlVendedor.DataSource + DdlVendedor.DataBind() + DdlVendedorSucursal.DataBind() DdlVendedor.SelectedValueExist(CveVendedorActual) @@ -16709,6 +16803,84 @@ Partial Class Ventas Protected Sub TxtFolio_TextChanged(sender As Object, e As System.EventArgs) Handles TxtFolio.TextChanged ViewState("EstablecioFolio") = True End Sub + Private Sub HabilitarFacturacionSucursal() + trsucursalciente.Visible = True + LnkAgregarSucursal.Visible = True + LblSucursal.Text = "Cliente" + If (CveVenta <= 0 OrElse NuevaFactura = 1) Then + DdlSucursalCliente.Enabled = True + End If + DdlSucursalCliente_SelectedIndexChanged(DdlSucursalCliente, EventArgs.Empty) + + UpCliente.Update() + End Sub + + Protected Sub ChkFacturarSucursal_CheckedChanged(sender As Object, e As EventArgs) + + End Sub + Protected Sub LnkAgregarSucursal_Click(sender As Object, e As EventArgs) + RegistraScript("showDivAgregarSucursal();") + End Sub + + Protected Sub BtnAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregarSucursal.Click + + Dim LT As String = "0" + Dim LG As String = "0" + + If CveCliente > 0 Then + Dim ObjCliente As New ClsClientes + Try + If ObjCliente.AddSucursal(CveCliente, TxtNombreSucursal.Text.Trim, UsuarioActual.CveUsuario, TxtCiudadSucursal.Text.Trim, TxtColoniaSucursal.Text.Trim, TxtCPSucursal.Text.Trim, TxtDireccionSucursal.Text.Trim, TxtEstadoSucursal.Text.Trim, TxtLocalidadSucursal.Text.Trim, TxtPaisSucursal.Text.Trim, TxtNumExtSucursal.Text.Trim, TxtNumIntSucursal.Text.Trim, TxtTelefonoSucursal.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", ""), TxtCorreoSucursal.Text.Trim, "", "", + DdlVendedorSucursal.SelectedValue.ToEntero, "", -1, 0, -1, DdlSucursalUsoCFDI.SelectedValue.ToEntero, -1, -1, LT:=LT, LG:=LG, RFC:=TxtRFCSucursal.Text.Trim()) Then + TxtNombreSucursal.Text = "" + TxtCiudadSucursal.Text = "" + TxtColoniaSucursal.Text = "" + TxtCPSucursal.Text = "" + TxtDireccionSucursal.Text = "" + TxtEstadoSucursal.Text = "" + TxtLocalidadSucursal.Text = "" + TxtPaisSucursal.Text = "" + TxtNumExtSucursal.Text = "" + TxtNumIntSucursal.Text = "" + TxtTelefonoSucursal.Text = "" + TxtCorreoSucursal.Text = "" + + DdlVendedorSucursal.SelectedIndex = 0 + DdlSucursalUsoCFDI.SelectedIndex = 0 + + + Alert("La nueva Sucursal del Cliente se guardó correctamente.", TipoMensaje.MsgInformacion) + + 'VUELVE A CARGAR LAS SUCURSALES + DdlSucursalCliente.Items.Clear() + If ObjCliente.GetSucursales(CveCliente) Then + DdlSucursalCliente.DataSource = ObjCliente.DtResultados + If ObjCliente.DtResultados.Rows.Count > 0 Then + trsucursalciente.Visible = True + Else + trsucursalciente.Visible = False + End If + Else + trsucursalciente.Visible = False + DdlSucursalCliente.DataSource = Nothing + End If + DdlSucursalCliente.Items.Insert(0, New ListItem("Matriz", "-1")) + DdlSucursalCliente.DataBind() + + End If + Catch ex As Exception + OnError("Ocurrió un error al agregar la sucursal", ex) + End Try + ObjCliente.Dispose() + + End If + + UpCliente.Update() + RegistraScript("hideDivAgregarSucursal();") + + End Sub + + Private Sub ConfiguraTipoDocto() 'Esconde Todo @@ -17824,6 +17996,11 @@ Partial Class Ventas Dim TotalT As Decimal = TxtTotal.Text.ToDecimal Dim RFCReceptor As String = LblRFC.Text.Trim + 'SI SE FACTURO LA SUCURSAL DEL CLIENTE TOMA EL RFC DE ESTA + If FacturarSucursal AndAlso Me.ClienteSucursal IsNot Nothing Then + RFCReceptor = Me.ClienteSucursal.RFC + End If + Dim SWatch As New Stopwatch SWatch.Start() @@ -20040,6 +20217,12 @@ Partial Class Ventas Dim TotalT As Decimal = TxtTotal.Text.ToDecimal Dim RFCReceptor As String = LblRFC.Text.Trim + + 'SI SE FACTURO LA SUCURSAL DEL CLIENTE TOMA EL RFC DE ESTA + If FacturarSucursal AndAlso Me.ClienteSucursal IsNot Nothing Then + RFCReceptor = Me.ClienteSucursal.RFC + End If + Dim SWatch As New Stopwatch SWatch.Start() Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True) @@ -25953,6 +26136,12 @@ Partial Class Ventas Return Retorno End Function Private Sub EmitirDocumentoNuevo(TipoDoctoNuevo As String) + + If (FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso String.IsNullOrEmpty(Me.ClienteSucursal.RFC))) Then + Alert("La sucursal no tiene asignada un RFC.", TipoMensaje.MsgAdvertencia) + Exit Sub + 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