+
@@ -3021,7 +3027,7 @@
if (CveClasificacion = "20517") {
regex = "[1X]|"
//regex = "[*]|"
- //SI ES OPTIMA
+ //SI ES OPTIMA
} else if (CveClasificacion = "20511") {
regex = "[1X]|"
}
@@ -3692,7 +3698,7 @@
}
function showDivEC() {
-
+
$('#<%= TxtNombreCliente.ClientID %>').val('');
$('#<%= TxtDireccionCliente.ClientID %>').val('');
$('#<%= TxtNumExtCliente.ClientID %>').val('');
diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb
index adfdc2a1d..f0c31cc24 100644
--- a/Ventas/PV.aspx.vb
+++ b/Ventas/PV.aspx.vb
@@ -566,6 +566,14 @@ Partial Class PV
ViewState("Index") = value
End Set
End Property
+ Private Property CveVentaDetalle As Integer
+ Get
+ Return ViewState("CveVentaDetalle").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveVentaDetalle") = value
+ End Set
+ End Property
Private ReadOnly Property AplicarVentaFacturada As Boolean
Get
@@ -722,6 +730,14 @@ Partial Class PV
ViewState("TmpDTMetodosPago") = value
End Set
End Property
+ Private Property DTBCIUsados As DataTable
+ Get
+ Return If(IsNothing(ViewState("DTBCIUsados")), Nothing, CType(ViewState("DTBCIUsados"), DataTable))
+ End Get
+ Set(value As DataTable)
+ ViewState("DTBCIUsados") = value
+ End Set
+ End Property
#End Region
@@ -1002,6 +1018,7 @@ Partial Class PV
ViewState("ClienteRetIVA") = 0
ViewState("ClienteRetISR") = 0
ViewState("EnviarCorreoCliente") = False
+ CveVentaDetalle = -1
EstablecioFolio = False
EstatusCliente = False
RemisionesLista = New List(Of Integer)
@@ -1112,6 +1129,12 @@ Partial Class PV
HdnCveCliente.Value = "-1"
End If
+ 'CARGA VENTA
+ If Request("CveVenta") IsNot Nothing Then
+ ViewState("CveVenta") = Request("CveVenta").ToString().ToEntero()
+ CargaVenta()
+ End If
+
'CARGA PARA FACTURAR
ViewState("CveRemision") = IfNull(Request("CveRemision").ToEntero, 0)
ViewState("CveCotizacion") = IfNull(Request("CveCotizacion").ToEntero, 0)
@@ -1191,6 +1214,650 @@ Partial Class PV
End If
End Sub
+ Private Function CargaVenta() As Boolean
+ Dim Retorno As Boolean = False
+ 'CARGA PARA FACTURACION
+ Dim CveRemision As Integer = IfNull(ViewState("CveRemision"), 0).ToString.ToEntero
+ Dim CveCotizacion As Integer = IfNull(ViewState("CveCotizacion"), 0).ToString.ToEntero
+ Dim CveVenta As Integer = Me.CveVenta
+ CveVenta = If(CveRemision > 0, CveRemision, CveVenta)
+ CveVenta = If(CveCotizacion > 0, CveCotizacion, CveVenta)
+ CveVenta = If(CvePedido > 0, CvePedido, CveVenta)
+ Dim SerieFolioPadre As String
+ Dim ObjVentas As New ClsVentas()
+ Try
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
+
+ If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
+ Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Rows(0)
+ Dim CveCliente As Integer = DbRowVenta("CveCliente").ToString.ToEntero
+
+ Dim ObjUsados As New ClsVentas
+ Dim DtUsados As DataTable = Nothing
+ If ObjUsados.GetVentasUsados(CveVenta, DdlSubProyectoDatos.SelectedValue.ToEntero(), DbRowVenta("Fecha").ToString.ToDateTime, UsuarioActual.CveEmpresa) Then
+ DtUsados = ObjUsados.DtResultados
+ End If
+ ObjUsados.Dispose()
+
+ 'Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString.ToEntero
+ 'CargaEncabezado
+ DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString
+
+ 'contado 0, credito 1, terminal 2
+ If ObjVentas.DtResultados(0)("CondicionesPago").ToString.ToEntero = 1 Then
+ RBLPago.SelectedValue = "1"
+ RBLPago_SelectedIndexChanged(Nothing, Nothing)
+ UPCondicionesPago.Update()
+ ElseIf ObjVentas.DtResultados(0)("CondicionesPago").ToString.ToEntero = 0 Then
+ RBLPago.SelectedValue = "2"
+ RBLPago.Items(0).Enabled = False
+ RBLPago_SelectedIndexChanged(Nothing, Nothing)
+ UPCondicionesPago.Update()
+ Else
+ DdlCuentasTerminal.SelectedValue = DbRowVenta("CveCuentaTerminal").ToString
+ RBLPago.SelectedValue = "3"
+ RBLPago.Items(0).Enabled = False
+ RBLPago_SelectedIndexChanged(Nothing, Nothing)
+ UPCondicionesPago.Update()
+ End If
+
+ 'CargaDetalle
+ If ObjVentas.GetVentaDetalle(CveVenta) Then
+ TmpDT = ObjVentas.DtResultados.Copy()
+ TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
+ TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
+ TmpDT.Columns.Add("ConsecPSPadre", GetType(Integer))
+ GvPS.DataSource = TmpDT
+ GvPS.DataBind()
+
+ End If
+
+ 'ESCONDE ACCIONES
+ UpnTools.Update()
+
+ HdnCveCliente.Value = CveCliente.ToString
+ ViewState("CveCliente") = CveCliente
+ ViewState("CveEmpresaCRM") = DbRowVenta("CveEmpresaCRM").ToString.ToEntero
+ ViewState("CveAcercamientoCRM") = DbRowVenta("CveAcercamientoCRM").ToString.ToEntero
+ Entrega = DbRowVenta("Entrega").ToString
+ Vigencia = DbRowVenta("Vigencia").ToString.ToDate.ToShortDateString
+ HplSaldoAuxiliar.Text = DbRowVenta("Saldo").ToString.FormatoNumero(2)
+ If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then
+ HplSaldoAuxiliar.Visible = False
+ End If
+ HdnPagado.Value = DbRowVenta("Pagado").ToString
+ TxtTotal.Text = DbRowVenta("Total").ToString.FormatoNumero(2)
+ HdnVentaSaldo.Value = (SaldoVenta).ToString
+ CvePrePoliza = DbRowVenta("CvePrePoliza").ToString.ToEntero
+ CveVentaFacturada = DbRowVenta("CveVentaFacturada").ToString.ToEntero
+
+ DdlMoneda.SelectedValue = DbRowVenta("CveMoneda").ToString
+ CambiaMoneda()
+
+ If CveCliente > 0 Then
+ CargaCliente(CveCliente, -1) 'Estatus activo, se requiere para cargar una factura en la que el cliente a sido eliminado
+ End If
+
+ ViewState("CveAlmacenTransitorio") = DbRowVenta("CveAlmacenTraspasoDestino").ToString.ToEntero
+ DevolucionAlmacen = DbRowVenta("EsDevolucionVenta").ToString.ToEntero
+
+ 'sino esta cargada la información del metodo de pago que le corresponde, la recarga para que se le pueda asignar
+ If DdlMetodoPago33.SelectedValue <> DbRowVenta("CveMetodoPago33").ToString Then
+ CargaFormaPago(DbRowVenta("CveMetodoPago33").ToString.ToEntero)
+ End If
+ DdlMetodoPago33.SelectedValueExist(DbRowVenta("CveMetodoPago33").ToString)
+ DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString.ToEntero)
+
+ If DdlFormaPago33.SelectedValue <> DbRowVenta("CveFormaPago33").ToString And DbRowVenta("CveFormaPago33").ToString <> "" Then
+ 'sino está seleccionada la asginada la debe de cargar
+ Dim Nombre As String = GlobalDTVtaFormaPago().FiltroPrimeroValor("FormaPagoSAT", String.Format("CveFormaPago={0}", DbRowVenta("CveFormaPago33")))
+ DdlFormaPago33.Items.Add(New ListItem(Nombre, DbRowVenta("CveFormaPago33").ToString))
+ DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString.ToEntero)
+ End If
+
+ DdlUsoCFDI.SelectedValueExist(DbRowVenta("CveUsoCFDI").ToString)
+
+ If DbRowVenta("CveTipoRelacion").ToString.ToEntero > 0 Then
+ TrTipoRelacion.Visible = True
+ DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString.ToEntero)
+ HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString
+ End If
+
+ ViewState("FolioFiscal") = DbRowVenta("FolioFiscal").ToString
+ LblSerie.Text = DbRowVenta("Serie").ToString
+ ViewState("Serie") = DbRowVenta("Serie").ToString
+ ViewState("Folio") = DbRowVenta("Folio").ToString.ToEntero
+ TxtFolio.Text = DbRowVenta("Folio").ToString
+ LblFolioFiscal.Text = DbRowVenta("FolioFiscal").ToString
+ TxtFecha.Text = DbRowVenta("Fecha").ToString
+ TxtSubTotal.Text = DbRowVenta("SubTotal").ToString.FormatoNumero(2)
+ LblDescuentos.Text = DbRowVenta("Descuento").ToString.FormatoNumero(2)
+ LblAmortizacion.Text = DbRowVenta("Amortizacion").ToString.FormatoNumero(2)
+ TxtSubTotal2.Text = (TxtSubTotal.Text.Replace(",", "").Trim.Trim.ToDouble - LblDescuentos.Text.Replace(",", "").Trim.Trim.ToDouble - LblAmortizacion.Text.Replace(",", "").Trim.Trim.ToDouble).FormatoNumero(2)
+ TxtIVA.Text = DbRowVenta("IVA").ToString.FormatoNumero(2)
+ TxtRetIVA.Text = DbRowVenta("RetIVA").ToString.FormatoNumero(2)
+ If TxtRetIVA.Text.ToDecimal() > 0 Then
+ TrRetIVA.Style.Add("display", "")
+ UsuarioActual.Empresa.MostrarRetIVA = True
+ If TmpDT IsNot Nothing Then
+ Dim PorcentajeRetIVA = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100)
+ LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2)
+ End If
+
+ End If
+ TxtRetISR.Text = DbRowVenta("RetISR").ToString.FormatoNumero(2)
+ TxtIEPS.Text = DbRowVenta("IEPS").ToString.FormatoNumero(2)
+ TrIEPS.Visible = TxtIEPS.Text.ToDouble > 0
+ TxtTotal.Text = DbRowVenta("Total").ToString.FormatoNumero(2)
+ HdnTotalVenta.Value = DbRowVenta("Total").ToString.FormatoNumero(2)
+ TxtMotivoDescuento.Text = DbRowVenta("MotivoDescuento").ToString
+ TxtObsFact.Text = DbRowVenta("Observaciones").ToString
+ LblUsuario.Text = DbRowVenta("Nombre").ToString
+ LblSeTimbro.Text = DbRowVenta("SeTimbro").ToString
+ LblMail.Text = DbRowVenta("EnvioMail").ToString
+ TxtFechaPago.Text = DbRowVenta("FechaVencimiento").ToString
+ TxtFechaVencimientoCotizacion.Text = Vigencia
+ HdnIVAOriginal.Value = TxtIVA.Text
+ DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion"))
+
+ If DbRowVenta("CveTipoRelacion").ToString.ToEntero > 0 Then
+ TrTipoRelacion2.Visible = True
+ LblTipoRelacion.Text = DbRowVenta("TipoRelacion").ToString
+ HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString
+ End If
+
+
+ 'Envio Direccion
+ If DbRowVenta("CveDireccionEnvio").ToString.ToEntero > 0 AndAlso DbRowVenta("CveDireccionEnvio").ToString IsNot Nothing Then
+ ChkDireccionEnvio.Checked = True
+ DdlDireccionEnvio.SelectedValueExist(DbRowVenta("CveDireccionEnvio").ToString.ToEntero)
+ DdlDireccionEnvio.Enabled = False
+ ChkDireccionEnvio.Enabled = False
+ DdlDireccionEnvio.Visible = True
+ trDireccionEnvio.Visible = True
+ End If
+
+
+ TxtTipoCambio.Text = DbRowVenta("TipoCambio").ToString
+
+ ViewState("SelloCancelacion") = DbRowVenta("SelloCancelacion").ToString
+ ViewState("FechaCancelacion") = DbRowVenta("FechaCancelacion").ToString.ToDateTime
+ TxtAtencionA.Text = DbRowVenta("AtencionA").ToString
+ TxtTelefonoGenerico.Text = DbRowVenta("TelefonoGenerico").ToString
+ CveVentaPadre = DbRowVenta("CveVentaPadre").ToString.ToEntero
+ SerieFolioPadre = DbRowVenta("SerieFolioPadre").ToString
+
+ If DdlVendedor.SelectedValue.ToEntero > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then
+ DdlVendedor.Enabled = False
+ End If
+
+ If CveVentaPadre > 0 Then
+ If IsNothing(Request("CveDevolucion")) AndAlso IsNumeric(Request("CveDevolucion")) Then
+ DdlNCFactura.Visible = True
+ Else
+ DdlNCFactura.Visible = False
+ End If
+ trNCFactura.Visible = True
+ LblSerieFolioPadre.Visible = True
+ LblSerieFolioPadre.Text = String.Format("
{1}", CveVentaPadre, SerieFolioPadre)
+
+ End If
+
+ DdlSucursalCliente.SelectedValueExist(DbRowVenta("CveClienteSucursal").ToString)
+
+ If DdlSubProyectoDatos.Items.Count = 0 Then
+ DdlSubProyectoDatos.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End If
+ DdlSubProyectoDatos.SelectedValueExistInsert(DbRowVenta("CveSubProyecto").ToString, DbRowVenta("SubProyecto").ToString)
+ CargarAlmacenes()
+
+
+ CargaClienteSucursal(DbRowVenta("CveClienteSucursal").ToString.ToEntero)
+
+ If DbRowVenta("CveContrato").ToString.ToEntero > 0 Then
+ CveContrato = DbRowVenta("CveContrato").ToString.ToEntero
+ End If
+
+ IdPoliza = DbRowVenta("IdPoliza").ToString.ToEntero
+
+ 'Carga si es Contabilizada
+ If IdPoliza > 0 Then
+ HLContabilizada.Text = "Si"
+ HLContabilizada.NavigateUrl = $"/Contabilidad/RegPoliza.aspx?IdPoliza={DbRowVenta("IdPoliza")}"
+ trContabilizada.Visible = True
+
+ End If
+
+ If DbRowVenta("IdPolizaCancelacion").ToString.ToEntero > 0 Then
+ HPLContaCancelacion.Text = "Cancelación"
+ HPLContaCancelacion.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", DbRowVenta("IdPolizaCancelacion"))
+ trContabilizada.Visible = True
+ End If
+
+ 'CARGA IMPUESTOS LOCALES
+ If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then
+ If ObjVentas.DtResultados.Rows.Count > 0 Then
+ TrOtros.Visible = True
+ TmpDTImpuestos = ObjVentas.DtResultados
+ GvImpuestosLocales2.DataSource = ObjVentas.DtResultados
+ GvImpuestosLocales2.DataBind()
+
+ GvImpuestosLocales2.Enabled = False
+ GvImpuestosLocales2.Visible = True
+ End If
+ End If
+
+ DdlVendedor.SelectedValue = DbRowVenta("CveVendedor").ToString
+ DdlTipoComprobante.Enabled = False
+ 'TxtDocto.Enabled = False
+ DeshabilitarEdicion()
+
+ 'CargaLeyendasFiscales
+ ViewState("VentaFolio") = If(LblSerie.Text.Trim.Length = 0, TxtFolio.Text.Trim, LblSerie.Text.Trim & "-" & TxtFolio.Text.Trim)
+
+ CalculaTotalesVenta(False)
+
+ tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot")
+ tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot")
+
+ If DbRowVenta("TipoDocto").ToString = "Rem" Then
+
+ For Each Gvr As GridViewRow In GvPS.Rows
+ Gvr.FCLinkButton("imgE").Visible = False
+ Gvr.FCLinkButton("imgD").Visible = False
+ Next
+
+ 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR
+ If TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then
+ TrEmitir.Visible = False
+ BtnPermisoEditarRemision.Visible = True
+ 'ACTIVA CONVERSION DE MONEDA
+ If DdlMoneda.SelectedValue.ToEntero = 1 Then
+ TrConversionDolares.Visible = True
+ ChkConvertirDolares.Enabled = True
+ TxtTipoCambioDlls.Enabled = True
+ Else
+ TrConversionTipoCambio.Visible = True
+ ChkConvertirDoctoPesos.Enabled = True
+ TxtTipoCambio.Enabled = True
+ End If
+ End If
+
+ End If
+
+ If UsuarioActual.CveEmpresa = 48 Then
+ TxtFecha.AutoPostBack = True
+ End If
+
+ UpPS.Update()
+ UpContado.Update()
+ UpEstatus.Update()
+ Retorno = True
+
+ Else
+ ViewState("CveVenta") = -1
+ Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia)
+ End If
+ End If
+ Catch ex As Exception
+ OnError("Ocurrió un error al cargar la venta", ex)
+ End Try
+ ObjVentas.Dispose()
+ Return Retorno
+ End Function
+
+#Region "E D I T A R - R E M I S I O N"
+ Private Sub DeshabilitarEdicion()
+ 'PORLET CLIENTE
+ 'DESACTIVA CAMBIO DE CLIENTE
+ HlCliente.Attributes.Remove("class")
+ HlCliente.Attributes.Add("class", "Texto disabled")
+ TxtCodigo.ReadOnly = True
+ ChkEnviarFactura.Enabled = False
+ ChkDireccionEnvio.Enabled = False
+ TxtAtencionA.Enabled = False
+ TxtFechaVencimientoCotizacion.Enabled = False
+
+ TxtCantidad.Enabled = False
+ DdlClasificacion.Enabled = False
+
+ DdlPS.Enabled = False
+ TxtObsPS.Enabled = False
+ TxtPrecio.Enabled = False
+ ImgDescPU.Attributes.Clear()
+ ImgDescTotal.Attributes.Clear()
+ LbAgregar.Enabled = False
+ DdlCuentasTerminal.Enabled = False
+
+ For Each Row As GridViewRow In GvPS.Rows
+ Row.FCLiteral("LtlConsecutivo").Text = (Row.RowIndex + 1).ToString()
+ Next
+ GvPS.Columns(ColumnaEditar).HeaderText = ""
+ GvPS.Columns(ColumnaEliminar).HeaderText = ""
+ 'GvPS.Columns(ColumnaEliminar).Visible = False
+
+ TxtObsFact.Enabled = False
+ TxtMotivoDescuento.Enabled = False
+ 'GvLeyendasFiscales.Enabled = False
+ TxtSubTotal.ReadOnly = True
+ TxtIVA.ReadOnly = True
+ TxtRetIVA.ReadOnly = True
+ TxtRetISR.ReadOnly = True
+ TxtIEPS.ReadOnly = True
+ TxtTotal.ReadOnly = True
+
+ 'Sección Detalle
+ DdlMoneda.Enabled = False
+ 'DdlSucursalEjecucion.Enabled = False
+ 'DdlSucursalCobranza.Enabled = False
+ DdlVendedor.Enabled = False
+ DdlSucursalCliente.Enabled = False
+
+ ChkConvertirDoctoPesos.Enabled = False
+ ChkConvertirDolares.Enabled = False
+ TxtTipoCambio.Enabled = False
+ TxtTipoCambioDlls.Enabled = False
+
+ 'Condiciones de Pago
+ RBLPago.Enabled = False
+ DdlFormaPago33.Enabled = False
+ DdlUsoCFDI.Enabled = False
+ DdlMetodoPago33.Enabled = False
+ 'TxtNumCtaPago.Enabled = False
+ If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") Then
+ TxtFechaPago.ReadOnly = Not UsuarioActual.TienePermisoProceso(260)
+ Else
+ TxtFechaPago.ReadOnly = False
+ End If
+
+ imgCalendario.Enabled = False
+
+ BtnEmitirImprimir.Visible = False
+ End Sub
+ Private Sub HabilitarEdicion()
+ TxtCodigo.ReadOnly = False
+ ChkEnviarFactura.Enabled = True
+ ChkDireccionEnvio.Enabled = True
+ TxtAtencionA.Enabled = True
+ TxtFechaVencimientoCotizacion.Enabled = True
+
+ TxtCantidad.Enabled = True
+ DdlClasificacion.Enabled = True
+
+ DdlPS.Enabled = True
+ TxtObsPS.Enabled = True
+ TxtPrecio.Enabled = True
+ ImgDescPU.Attributes.Clear()
+ ImgDescTotal.Attributes.Clear()
+ LbAgregar.Enabled = True
+ DdlCuentasTerminal.Enabled = True
+
+ For Each Row As GridViewRow In GvPS.Rows
+ Row.FCLiteral("LtlConsecutivo").Text = (Row.RowIndex + 1).ToString()
+ Next
+ GvPS.Columns(ColumnaEditar).HeaderText = ""
+ GvPS.Columns(ColumnaEliminar).HeaderText = ""
+
+ TxtObsFact.Enabled = True
+ TxtMotivoDescuento.Enabled = True
+ TxtSubTotal.ReadOnly = False
+ TxtIVA.ReadOnly = False
+ TxtRetIVA.ReadOnly = False
+ TxtRetISR.ReadOnly = False
+ TxtIEPS.ReadOnly = False
+ TxtTotal.ReadOnly = False
+
+ 'Sección Detalle
+ DdlMoneda.Enabled = True
+ DdlVendedor.Enabled = True
+ DdlSucursalCliente.Enabled = True
+
+ ChkConvertirDoctoPesos.Enabled = True
+ ChkConvertirDolares.Enabled = True
+ TxtTipoCambio.Enabled = True
+ TxtTipoCambioDlls.Enabled = True
+
+ 'Condiciones de Pago
+ RBLPago.Enabled = True
+ DdlFormaPago33.Enabled = True
+ DdlUsoCFDI.Enabled = True
+ DdlMetodoPago33.Enabled = True
+
+ If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") Then
+ TxtFechaPago.ReadOnly = Not UsuarioActual.TienePermisoProceso(260)
+ Else
+ TxtFechaPago.ReadOnly = False
+ End If
+
+ imgCalendario.Enabled = True
+ End Sub
+ Private Sub BtnPermisoEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnPermisoEditarRemision.Click
+ HabilitarEdicion()
+ BtnPermisoEditarRemision.Visible = False
+ BtnEditarRemision.Visible = True
+ TxtObsFact.Enabled = True
+ DdlUsoCFDI.Enabled = True
+ DdlMetodoPago33.Enabled = True
+ DdlFormaPago33.Enabled = True
+ UPCondicionesPago.Update()
+ RBLPago.Enabled = True
+
+ ViewState("CveClienteAnterior") = CveCliente
+
+ 'SI EL DETALLE NO TIENE MOVIMIENTOS DE INVENTARIO ES VISIBLE
+ Dim CantidadFacturadaRemision = 0.0
+ For Each Gvr As GridViewRow In GvPS.Rows
+ Gvr.FCLinkButton("imgE").Visible = Not Gvr.DataKey("CantidadFacturadaRem").ToString.ToDouble > 0 AndAlso Gvr.DataKey("EsCargo") = "True"
+ Gvr.FCLinkButton("imgD").Visible = Not Gvr.DataKey("CantidadInventario").ToString.ToDouble > 0 AndAlso Gvr.DataKey("EsCargo") = "True"
+ CantidadFacturadaRemision += Gvr.DataKey("CantidadFacturadaRem").ToString.ToDouble
+ Next
+
+ 'ACTIVA CAMBIO DE CLIENTE - SI NO TIENE NADA FACTURADO
+ If Not CantidadFacturadaRemision > 0 AndAlso UsuarioActual.TienePermisoProceso(284) Then
+ HlCliente.Attributes.Remove("class")
+ HlCliente.Attributes.Add("class", "Texto")
+ TxtCodigo.ReadOnly = False
+ End If
+
+ TxtCantidad.Enabled = True
+ DdlClasificacion.Enabled = True
+ DdlPS.Enabled = True
+ TxtObsPS.Enabled = True
+ TxtPrecio.Enabled = True
+ LbAgregar.Enabled = True
+ ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';")
+ LblSubTotal1.Text = TxtSubTotal.Text
+ LblAmort.Text = TxtSubTotal.Text
+
+ UpPS.Update()
+ UpCliente.Update()
+ UPObservaciones.Update()
+ End Sub
+
+ Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click
+ Dim OcurrioError As Boolean = False
+
+ CreaObjetosVenta()
+
+ Dim ObjVentas As New ClsVentas
+ ObjVentas.IniciaTransacSQL()
+
+ Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
+ Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
+ Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL())
+ Dim ObjAC As ClsContPAQi = Nothing
+
+ Dim Moneda As Integer = DdlMoneda.SelectedValue.ToEntero
+ Dim TipoCambio As Double = TxtTipoCambio.Text.ToDouble
+ Try
+ 'CONVERTIR REMISION - TIPO MONEDA -DOLARES A PESOS
+ If DdlMoneda.SelectedValue.ToEntero <> 2 AndAlso ChkConvertirDolares.Checked Then
+
+ For Each Row As DataRow In TmpDT.Rows
+ Row("PU") = Math.Round(Row("PU").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, 6)
+ Row("Total") = Math.Round(Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, NumeroDecimales)
+ Row("TotalImporte") = Math.Round(Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, NumeroDecimales)
+ Row("Descuento") = Math.Round(Row("Descuento").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteIEPS") = Math.Round(Row("ImporteIEPS").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteIVA") = Math.Round(Row("ImporteIVA").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteRetIVA") = Math.Round(Row("ImporteRetIVA").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteRetISR") = Math.Round(Row("ImporteRetISR").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Next
+
+ Dim ImpuestosLocales As Double = 0
+ For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
+ If gvr.RowType = DataControlRowType.DataRow Then
+ gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal).FormatoNumero
+ ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ End If
+ Next
+
+ TxtSubTotal.Text = TmpDT.SUM("Total").ToDecimal.FormatoNumero
+ LblDescuentos.Text = TmpDT.SUM("Descuento").ToDecimal.FormatoNumero
+ LblAmortizacion.Text = Math.Round(LblAmortizacion.Text.Trim.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales).FormatoNumero
+ TxtIVA.Text = TmpDT.SUM("ImporteIVA").ToDecimal.FormatoNumero
+ TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal.FormatoNumero
+ TxtRetISR.Text = TmpDT.SUM("ImporteRetISR").ToDecimal.FormatoNumero
+ TxtIEPS.Text = TmpDT.SUM("ImporteIEPS").ToDecimal.FormatoNumero
+ TxtTotal.Text = (TxtSubTotal.Text.ToDecimal - LblDescuentos.Text.ToDecimal - LblAmortizacion.Text.ToDecimal + TxtIVA.Text.ToDecimal + TxtIEPS.Text.ToDecimal - TxtRetIVA.Text.ToDecimal - TxtRetISR.Text.ToDecimal - ImpuestosLocales).ToDecimal.FormatoNumero
+
+ TipoCambio = TxtTipoCambioDlls.Text.Trim.ToDecimal
+ Moneda = 2
+ End If
+
+ 'CONVERTIR REMISION - TIPO MONEDA -PESO A DOLARES
+ If DdlMoneda.SelectedValue.ToEntero <> 1 AndAlso ChkConvertirDoctoPesos.Checked Then
+ Dim Importe As Decimal
+ Dim TCC As Decimal = TxtTipoCambio.Text.Trim.ToDecimal
+ For Each Row As DataRow In TmpDT.Rows
+ Row("PU") = Math.Round(Row("PU").ToString.ToDecimal * TCC, 6)
+ Row("Total") = Math.Round(Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, NumeroDecimales)
+ Row("TotalImporte") = Math.Round(Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, NumeroDecimales)
+ Row("Descuento") = Math.Round(Row("Descuento").ToString.ToDecimal * TCC, NumeroDecimales)
+ Importe = Row("Total").ToString.ToDecimal - Row("Descuento").ToString.ToDecimal
+ Row("ImporteIEPS") = Math.Round(Importe * Row("PorcentajeIEPS").ToString.ToDecimal, NumeroDecimales)
+ Row("ImporteIVA") = Math.Round(Importe * Row("PorcentajeIVA").ToString.ToDecimal, NumeroDecimales)
+ Row("ImporteRetIVA") = Math.Round(Importe * Row("PorcentajeRetIVA").ToString.ToDecimal, NumeroDecimales)
+ Row("ImporteRetISR") = Math.Round(Importe * Row("PorcentajeRetISR").ToString.ToDecimal, NumeroDecimales)
+ Next
+
+ Dim ImpuestosLocales As Double = 0
+ For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
+ If gvr.RowType = DataControlRowType.DataRow Then
+ gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * TxtTipoCambio.Text.Trim.ToDecimal).FormatoNumero
+ ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * TxtTipoCambio.Text.Trim.ToDecimal, NumeroDecimales)
+ End If
+ Next
+
+ TxtSubTotal.Text = TmpDT.SUM("Total").ToDecimal.FormatoNumero
+ LblDescuentos.Text = TmpDT.SUM("Descuento").ToDecimal.FormatoNumero
+ LblAmortizacion.Text = Math.Round(LblAmortizacion.Text.Trim.ToDecimal * TxtTipoCambio.Text.Trim.ToDecimal, NumeroDecimales).FormatoNumero
+ TxtIVA.Text = TmpDT.SUM("ImporteIVA").ToDecimal.FormatoNumero
+ TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal.FormatoNumero
+ TxtRetISR.Text = TmpDT.SUM("ImporteRetISR").ToDecimal.FormatoNumero
+ TxtIEPS.Text = TmpDT.SUM("ImporteIEPS").ToDecimal.FormatoNumero
+ TxtTotal.Text = (TxtSubTotal.Text.ToDecimal - LblDescuentos.Text.ToDecimal - LblAmortizacion.Text.ToDecimal + TxtIVA.Text.ToDecimal + TxtIEPS.Text.ToDecimal - TxtRetIVA.Text.ToDecimal - TxtRetISR.Text.ToDecimal - ImpuestosLocales).ToDecimal.FormatoNumero
+
+
+ TipoCambio = 1
+ Moneda = 1
+ End If
+
+ 'Actualizo los parametros de la venta
+ If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDecimal, LblDescuentos.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtIEPS.Text.ToDecimal, TxtTotal.Text.ToDecimal, Moneda, TipoCambio, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim,
+ UsuarioActual.CveEmpresa, CveVenta, 0, 0,
+ Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1),
+ PedidoContrato:="", AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero,
+ CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, TipoDocto:="Rem", CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal,
+ OrdenCompra:="", RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=0) Then
+ OcurrioError = True
+ End If
+
+ 'Cargo de nueva cuenta el detalle de Ventas (Conceptos)
+ If Not OcurrioError Then
+ Dim index As Integer = 0
+ For Each Row As DataRow In TmpDT.Rows
+ Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString.ToEntero()
+ If CveVentaDetalle > 0 Then
+ If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal(), Row("ImporteIEPS").ToString.ToDecimal(), Row("Obs").ToString, UsuarioActual.CveUsuario) Then
+ OcurrioError = True
+ Exit For
+ End If
+ Else
+ If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero,
+ Row("PU").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString.ToDouble, Math.Round((Row("Total").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6),
+ Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, PorcentajeIVA:=Row("PorcentajeIVA").ToString.ToDecimal, IEPS:=Row("ImporteIEPS").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString,
+ CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1),
+ ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString) Then
+ OcurrioError = True
+ Exit For
+ Else
+ TmpDT.Rows(index)("CveVentaDetalle") = ObjVentas.CveVentaDetalle
+ End If
+ End If
+ index = index + 1
+ Next
+ End If
+
+ ObjFactura.DtDetalle = TmpDT
+
+ 'ELIMINA LOS DETALLES
+ If Not OcurrioError Then
+ Dim DtEliminados As New DataTable
+ If ObjVentas.GetVentaDetalle(CveVenta) Then
+ DtEliminados = ObjVentas.DtResultados.FiltraParametros("", "", {"CveVentaDetalle"})
+ For Each Dr1 As DataRow In DtEliminados.Rows
+ If TmpDT.FiltraParametros($"CveVentaDetalle = {Dr1("CveVentaDetalle")}").Rows.Count = 0 Then
+ If Not ObjVentas.RemoveVentasDetalle(CveVenta, Dr1("CveVentaDetalle").ToString.ToEntero) Then
+ OcurrioError = True
+ End If
+ End If
+ Next
+ Else
+ OcurrioError = True
+ End If
+ End If
+
+ 'OcurrioError = ProcesoPrepolizas(ObjConta, ObjFactura, -1, TmpDT, ObjAC, 1, ObjBancos, ObjVentas)
+
+ 'Actualizo impuestos locales
+ If Not OcurrioError Then
+ For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
+ If gvr.RowType = DataControlRowType.DataRow Then
+ If Not ObjVentas.UpdateVentaImpuestoLocales(CveVenta, gvr.DataKey("CveImpuestoLocal").ToString.ToEntero, gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal) Then
+ OcurrioError = True
+ End If
+ End If
+ Next
+ End If
+
+ 'REGENERAR LOS SALDOS
+ If Not OcurrioError Then
+ OcurrioError = Not ObjFactura.RegenerarPrePolizas(ObjVentas.IniciaTransacSQL(), ObjAC)
+ End If
+
+ Catch ex As Exception
+ OcurrioError = True
+ OnError("Ocurrió un error al actualizar la remisión", ex)
+ End Try
+
+ If OcurrioError Then
+ ObjVentas.RollBack()
+ Alert("Ocurrió un error al guardar los cambios. Por favor intente de nuevo.", TipoMensaje.MsgError)
+ Else
+ ObjVentas.Commit()
+ If ObjAC IsNot Nothing Then ObjAC.Commit()
+ Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:="BtnRefrescarPagina();")
+ End If
+
+ ObjVentas.Dispose()
+ ObjConta.Dispose()
+ ObjBancos.Dispose()
+ If ObjAC IsNot Nothing Then ObjAC.Dispose()
+ End Sub
+
+#End Region
+
#Region "PUNTO DE VENTA"
Private Sub CargaCorteCaja()
'Checar si hay un Turno Abierto
@@ -1474,9 +2141,17 @@ Partial Class PV
'CargaDetalle
If ObjVentas.GetVentaDetalle(CveVenta) Then
- TmpDT = ObjVentas.DtResultados
- GvPS.DataSource = ObjVentas.DtResultados
+ TmpDT = ObjVentas.DtResultados.Copy()
+ TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
+ TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
+
+ GvPS.DataSource = TmpDT
GvPS.DataBind()
+
+ For Each Gvr As GridViewRow In GvPS.Rows
+ Gvr.FCLinkButton("imgE").Visible = False
+ Gvr.FCLinkButton("imgD").Visible = False
+ Next
End If
'Carga Totales
@@ -1706,6 +2381,9 @@ Partial Class PV
CambiaSucursal()
UpParametros.Update()
End If
+ Else
+ CargaFormatoSucursal()
+ UpParametros.Update()
End If
If ObjCliente.GetSucursales(CveCliente) Then
@@ -2344,15 +3022,15 @@ Partial Class PV
Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion), If(Retorno.TieneError, "", Retorno.LigaPV))
Next
- Dim facBytes = DescargarFactura(Retorno.CveVenta, UsuarioActual.CveEmpresa)
- ImprimirbytesPDF(facBytes, ObjFactura.SerieFolio)
+ 'Dim facBytes = DescargarFactura(Retorno.CveVenta, UsuarioActual.CveEmpresa)
+ 'ImprimirbytesPDF(facBytes, ObjFactura.SerieFolio)
End If
End If
End Sub
Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, Optional GetBytes As Boolean = True) As Byte()
- Dim Url = New Uri(String.Format("http://{0}:{1}/Compras/PopUpVerFactura.aspx?P={2}", HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta))))
+ Dim Url = New Uri(String.Format("{0}://{1}:{2}/Compras/PopUpVerFactura.aspx?P={3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta))))
Dim File As Byte() = Nothing
Try
Using httpClient = New HttpClient()
@@ -2377,7 +3055,14 @@ Partial Class PV
#Region "OBJETO VENTA"
Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False)
- ObjFactura = New Modelos.Factura(UsuarioActual)
+
+ If Me.CveVenta > 0 Then
+ ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False)
+ Else
+ ObjFactura = New Modelos.Factura(UsuarioActual)
+ ObjFactura.CvePrePoliza = -1
+ End If
+
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
ObjFactura.TipoCambio = TxtTipoCambio.Text.Trim.ToDecimal
@@ -2393,7 +3078,6 @@ Partial Class PV
'ObjFactura.Folio = If(ExFolioFactura, FolioXML.ToEntero, -1)
ObjFactura.Serie = If(VistaPrevia, "VistaPrevia", LblSerie.Text)
ObjFactura.Fecha = New Date(TxtFecha.Text.Trim.ToDate.Year, TxtFecha.Text.Trim.ToDate.Month, TxtFecha.Text.Trim.ToDate.Day, Now.Hour, Now.Minute, Now.Second)
- ObjFactura.CvePrePoliza = -1
ObjFactura.CveMetodoPago = DdlMetodoPago.SelectedValue.ToEntero
ObjFactura.MetodoPago = DdlMetodoPago.SelectedItem.Text
ObjFactura.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {DdlMetodoPago.SelectedValue}")
@@ -2801,111 +3485,115 @@ Partial Class PV
TxtDescuento.Text = FormatoNumero(0, 2)
TxtPrecio.Text = ""
- If CvePSParametro > 0 Then
- Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
+ Try
+ If CvePSParametro > 0 Then
+ Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
- If drPS IsNot Nothing Then
- 'HdnUnidadMedida.Value = PS.Rows(0)("CveUnidadMedida").ToString
- HdnPS.Value = drPS("PS").ToString
- HdnCodigoPS.Value = drPS("PSCodigo").ToString
- HdnTipoPS.Value = drPS("CveTipoPS").ToString
- HdnTipoInv.Value = drPS("Inv_CveMetodoInventario").ToString
- HdnAplicaIEPS.Value = drPS("AplicaIEPS").ToString
- HdnPorcentajeIEPS.Value = drPS("IEPSPorcentaje").ToString
- 'Muestra la tabla de tamaños
- If drPS("CveTamaño").ToString().ToEntero() > 0 Then
- DivRecepcionUsados.Visible = True
- If DdlTipoComprobante.SelectedValue <> "Rem" Then
- GvRecepcionUsados.Columns(2).Visible = False
- Else
- GvRecepcionUsados.Columns(2).Visible = True
+ If drPS IsNot Nothing Then
+ 'HdnUnidadMedida.Value = PS.Rows(0)("CveUnidadMedida").ToString
+ HdnPS.Value = drPS("PS").ToString
+ HdnCodigoPS.Value = drPS("PSCodigo").ToString
+ HdnTipoPS.Value = drPS("CveTipoPS").ToString
+ HdnTipoInv.Value = drPS("Inv_CveMetodoInventario").ToString
+ HdnAplicaIEPS.Value = drPS("AplicaIEPS").ToString
+ HdnPorcentajeIEPS.Value = drPS("IEPSPorcentaje").ToString
+ 'Muestra la tabla de tamaños
+ If drPS("CveTamaño").ToString().ToEntero() > 0 Then
+ DivRecepcionUsados.Visible = True
+ If DdlTipoComprobante.SelectedValue <> "Rem" Then
+ GvRecepcionUsados.Columns(2).Visible = False
+ Else
+ GvRecepcionUsados.Columns(2).Visible = True
+ End If
End If
+
+ DdlUnidadMedida.Items.Clear()
+ If UsuarioActual.Empresa.UsaInventarios Then
+ DdlUnidadMedida.DataSource = GlobalDTProductosServiciosEquivalencias(CvePSParametro, -1, UsuarioActual.CveEmpresa)
+ Else
+ DdlUnidadMedida.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
+ End If
+ DdlUnidadMedida.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ DdlUnidadMedida.SelectedValue = "-1"
+ DdlUnidadMedida.DataBind()
+ DdlUnidadMedida.SelectedValueExist(drPS("CveUnidadMedida").ToString)
+
+ 'SUGIERE PRECIO
+ Dim PrecioSugerido = 0.0
+ PrecioSugerido = drPS("Precio").ToString.ToDouble
+ If UsuarioActual.CveEmpresa.Contiene(80, 119) Then
+ Dim CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("CvePrecioLista", $"CveCliente = {CveCliente}").ToEntero
+ If CvePrecioListaPS > 0 Then
+ Dim ObjPS As New ClsProductosServicios
+ If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then
+
+ PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDouble
+ If PrecioSugerido = 0 Then
+ Dim ObjInventarios As New ClsInventarios
+ Dim CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero)
+ ObjInventarios.Dispose()
+ Dim PorcentajePrecio = ObjPS.DtResultados.FiltroPrimeroValor("Porcentaje").ToDouble
+ If CostoPS > 0 And PorcentajePrecio > 0 Then
+ PrecioSugerido = ((PorcentajePrecio / 100) + 1) * CostoPS
+ End If
+ End If
+ ObjPS.Dispose()
+ End If
+ End If
+ End If
+ If PrecioSugerido > 0 Then
+ TxtPrecio.Text = PrecioSugerido.FormatoNumero()
+ RegistraScript("$get('LblPrecio1').innerText = formato_numero(" + PrecioSugerido.ToString + ", 2, '.', ',');")
+ End If
+
+
+ If IsNumeric(TxtCantidad.Text.Trim) Then
+ LblTotalPS.Text = (TxtCantidad.Text.Trim.ToDouble * TxtPrecio.Text.ToDouble).ToString.FormatoNumero(2)
+ Else
+ LblTotalPS.Text = "0.00"
+ End If
+
+ HdnIVAPS.Value = If(drPS("IVA").ToString = "-1", SubProyectoPorcentajeIVA.ToString(), drPS("IVA").ToString).ToString
+ HdnIVARetAPS.Value = drPS("RetIVA").ToString
+ HdnAsientoContable.Value = drPS("AsientoContableVentas").ToString
+ HdnCtaContable.Value = drPS("IdCtaContVentas").ToString
+ HdnAplicaParaConcepto.Value = drPS("AplicaParaConcepto").ToString
+ HdnCodigo.Value = drPS("Codigo").ToString
+ If DdlClasificacion.SelectedIndex = 0 Then
+ If drPS("CveClasificacion").ToString IsNot Nothing Then
+ DdlClasificacion.SelectedValueExist(drPS("CveClasificacion").ToString)
+ Else
+ Alert("El Productos/Servicio no tiene asignada una Clasificación.")
+ End If
+
+ End If
+ 'Descuento por clasificación
+ If drPS("CveClasificacion").ToString.ToEntero.Contiene(20516, 20515) Then
+ Dim clasificacionesDescuentos As New Dictionary(Of Integer, Double) From {
+ {20516, 0.23}, 'Descuento para lubricantes LTH
+ {20515, 0.24} 'Descuento para filtros LTH
+ }
+ TxtDescuento.Text = (PrecioSugerido * clasificacionesDescuentos(drPS("CveClasificacion").ToString.ToEntero)).ToString("F2")
+ End If
+
+ If ChkAjuste.Checked Then
+ CalculaMesesUso()
+ UpAjuste.Update()
+ End If
+
End If
+ ElseIf CvePSParametro = -2 Then
+ CargaPS(DdlClasificacion.SelectedValue.ToEntero, Ddl)
+ Else
DdlUnidadMedida.Items.Clear()
- If UsuarioActual.Empresa.UsaInventarios Then
- DdlUnidadMedida.DataSource = GlobalDTProductosServiciosEquivalencias(CvePSParametro, -1, UsuarioActual.CveEmpresa)
- Else
- DdlUnidadMedida.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
- End If
DdlUnidadMedida.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlUnidadMedida.SelectedValue = "-1"
DdlUnidadMedida.DataBind()
- DdlUnidadMedida.SelectedValueExist(drPS("CveUnidadMedida").ToString)
-
- 'SUGIERE PRECIO
- Dim PrecioSugerido = 0.0
- PrecioSugerido = drPS("Precio").ToString.ToDouble
- If UsuarioActual.CveEmpresa.Contiene(80, 119) Then
- Dim CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("CvePrecioLista", $"CveCliente = {CveCliente}").ToEntero
- If CvePrecioListaPS > 0 Then
- Dim ObjPS As New ClsProductosServicios
- If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then
-
- PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDouble
- If PrecioSugerido = 0 Then
- Dim ObjInventarios As New ClsInventarios
- Dim CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero)
- ObjInventarios.Dispose()
- Dim PorcentajePrecio = ObjPS.DtResultados.FiltroPrimeroValor("Porcentaje").ToDouble
- If CostoPS > 0 And PorcentajePrecio > 0 Then
- PrecioSugerido = ((PorcentajePrecio / 100) + 1) * CostoPS
- End If
- End If
- ObjPS.Dispose()
- End If
- End If
- End If
- If PrecioSugerido > 0 Then
- TxtPrecio.Text = PrecioSugerido.FormatoNumero()
- RegistraScript("$get('LblPrecio1').innerText = formato_numero(" + PrecioSugerido.ToString + ", 2, '.', ',');")
- End If
-
-
- If IsNumeric(TxtCantidad.Text.Trim) Then
- LblTotalPS.Text = (TxtCantidad.Text.Trim.ToDouble * TxtPrecio.Text.ToDouble).ToString.FormatoNumero(2)
- Else
- LblTotalPS.Text = "0.00"
- End If
-
- HdnIVAPS.Value = If(drPS("IVA").ToString = "-1", ViewState("IVA"), drPS("IVA").ToString).ToString
- HdnIVARetAPS.Value = drPS("RetIVA").ToString
- HdnAsientoContable.Value = drPS("AsientoContableVentas").ToString
- HdnCtaContable.Value = drPS("IdCtaContVentas").ToString
- HdnAplicaParaConcepto.Value = drPS("AplicaParaConcepto").ToString
- HdnCodigo.Value = drPS("Codigo").ToString
- If DdlClasificacion.SelectedIndex = 0 Then
- If drPS("CveClasificacion").ToString IsNot Nothing Then
- DdlClasificacion.SelectedValueExist(drPS("CveClasificacion").ToString)
- Else
- Alert("El Productos/Servicio no tiene asignada una Clasificación.")
- End If
-
- End If
- 'Descuento por clasificación
- If drPS("CveClasificacion").ToString.ToEntero.Contiene(20516, 20515) Then
- Dim clasificacionesDescuentos As New Dictionary(Of Integer, Double) From {
- {20516, 0.23}, 'Descuento para lubricantes LTH
- {20515, 0.24} 'Descuento para filtros LTH
- }
- TxtDescuento.Text = (PrecioSugerido * clasificacionesDescuentos(drPS("CveClasificacion").ToString.ToEntero)).ToString("F2")
- End If
-
- If ChkAjuste.Checked Then
- CalculaMesesUso()
- UpAjuste.Update()
- End If
-
End If
-
- ElseIf CvePSParametro = -2 Then
- CargaPS(DdlClasificacion.SelectedValue.ToEntero, Ddl)
- Else
- DdlUnidadMedida.Items.Clear()
- DdlUnidadMedida.Items.Insert(0, New ListItem("Seleccione", "-1"))
- DdlUnidadMedida.SelectedValue = "-1"
- DdlUnidadMedida.DataBind()
- End If
+ Catch ex As Exception
+ OnError("Ocurrió un error al cambiar el producto", ex)
+ End Try
UpClasificacion.Update()
UpPS.Update()
@@ -3339,13 +4027,17 @@ Partial Class PV
Row = TmpDT.NewRow()
ElseIf Modalidad = "U" Then
Dim Contador As Integer = 0
- For Each Dr As DataRow In TmpDT.Rows
- If Dr("Consec").ToString.ToEntero = Index Then
- Exit For
- End If
- Contador = Contador + 1
- Next
- Row = TmpDT.Rows(Contador)
+ If CveVentaDetalle <= 0 Then
+ For Each Dr As DataRow In TmpDT.Rows
+ If Dr("Consec").ToString.ToEntero = Index Then
+ Exit For
+ End If
+ Contador = Contador + 1
+ Next
+ Row = TmpDT.Rows(Contador)
+ Else
+ Row = TmpDT.Select($"CveVentaDetalle={CveVentaDetalle}")(0)
+ End If
End If
Dim TotalCalculableImpuestos As Decimal = 0
@@ -3738,6 +4430,8 @@ Partial Class PV
Modalidad = "U"
Index = GvRow.DataKey("Consec").ToEntero
ConsecutivoVenta = GvRow.DataKey("Consec").ToEntero
+ CveVentaDetalle = GvRow.DataKey("CveVentaDetalle").ToEntero
+
LnkAgregarPS.Text = "Actualizar"
DdlClasificacion.SelectedValueExist(GvRow.DataKey("CveClasificacion"))
CargaPS(DdlClasificacion.SelectedValue.ToEntero, DdlPS)
@@ -3756,7 +4450,9 @@ Partial Class PV
LblTotalPS.Text = GvRow.DataKey("Total")
ChkAgregar.Checked = False
divagregrarotrops.Visible = False
- Ajuste()
+ If CveVenta <= 0 Then
+ Ajuste()
+ End If
AddPolizaVirtual(DdlPS.SelectedValue.ToEntero())
UpVenta.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddVenta"), "EdicionVenta")
@@ -3771,19 +4467,28 @@ Partial Class PV
LimpiaAgregar()
UpVenta.Update()
Else
+ If Me.CveVentaDetalle > 0 Then
+ For Each Gvr As GridViewRow In GvPS.Rows
+ Gvr.FCLinkButton("imgE").Visible = Not Gvr.DataKey("CantidadFacturadaRem").ToString.ToDouble > 0 AndAlso Gvr.DataKey("EsCargo") = "True"
+ Gvr.FCLinkButton("imgD").Visible = Not Gvr.DataKey("CantidadInventario").ToString.ToDouble > 0 AndAlso Gvr.DataKey("EsCargo") = "True"
+ Next
+ End If
+ UpVenta.Update()
RegistraScript("$('#DivAddVenta').modal('hide');")
End If
End If
+ Me.CveVentaDetalle = -1
End Sub
Private Function AgregarPS() As Boolean
+ Dim CveVentaDetalle As Integer = Me.CveVentaDetalle
+
+ Dim EsCargo As Boolean = False
+ If CveVentaDetalle > 0 Then
+ EsCargo = CBool(TmpDT.FiltroPrimeroValor("EsCargo", $"CveVentaDetalle={CveVentaDetalle}"))
+ End If
'SELECCIONA EL PS DEPENDIENDO LA MODALIDAD (CODIGO BARRAS - DDL)
- Dim CvePS = -1
- 'If DIVCod.Visible Then
- ' CvePS = HdnCvePS.Value.ToEntero
- 'Else
- CvePS = DdlPS.SelectedValue.ToEntero
- 'End If
+ Dim CvePS = DdlPS.SelectedValue.ToEntero
If ValidaAgregarPS(CvePS, DdlUnidadMedida.SelectedValue.ToEntero, TxtPrecio.Text.Trim.ToDouble, HdnTipoPS.Value.ToEntero, TxtCantidad.Text.ToDecimal) Then
@@ -3799,15 +4504,17 @@ Partial Class PV
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(TxtCantidad.Text.ToDecimal, DdlUnidadMedida.SelectedValue.ToEntero, DdlUnidadMedida.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text,
CvePS, "", TxtObsPS.Text.Trim, If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal), Descuento,
CveProyecto, Proyecto, DdlSubProyectoDatos.SelectedValue.ToEntero, DdlSubProyectoDatos.SelectedItem.Text,
- SerieLote:="", TiempoEntrega:="", CuentaPredial:="", RegeneraIEPS:=ClienteDesglosaIEPS)
+ SerieLote:="", TiempoEntrega:="", CuentaPredial:="", RegeneraIEPS:=ClienteDesglosaIEPS, CveVentaDetalle:=CveVentaDetalle, EsCargo:=EsCargo)
+
+ If CveVentaDetalle <= 0 AndAlso Not EsCargo Then
+ Dim ListaPSCargo = CalculaUsados(Consec)
+ If ListaPSCargo.Count > 0 Then
+ CalculaRecepcionUsados(GvRecepcionUsados, CvePS, ListaPSCargo)
+ End If
- Dim ListaPSCargo = CalculaUsados(Consec)
- If ListaPSCargo.Count > 0 Then
- CalculaRecepcionUsados(GvRecepcionUsados, CvePS, ListaPSCargo)
End If
Return True
@@ -5040,7 +5747,8 @@ Partial Class PV
Private Sub CargaBCIAjuste()
Dim ObjGral As New ClsGenerales
If ObjGral.BCIUsadoGet(UsuarioActual.CveEmpresa) Then
- DdlBCIAjuste.DataSource = ObjGral.DtResultados
+ DTBCIUsados = ObjGral.DtResultados.Copy()
+ DdlBCIAjuste.DataSource = DTBCIUsados
End If
ObjGral.Dispose()
DdlBCIAjuste.DataBind()
@@ -5065,6 +5773,8 @@ Partial Class PV
Dim DtTamanios = GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CvePSCargo > 0")
CargaModelos()
+ CargaBCIAjuste()
+
GvRecepcionUsados.DataSource = DtTamanios
GvRecepcionUsadosModal.DataSource = DtTamanios
@@ -5073,13 +5783,13 @@ Partial Class PV
DdlTipoUso.DataBind()
DdlTipoDefecto.DataBind()
DdlFacturas.DataBind()
+
GvRecepcionUsados.DataBind()
GvRecepcionUsadosModal.DataBind()
CreaDTmpDTAjustes()
CreaDTmpDTRecepcionUsados()
CreaDTmpDTPolizaVirtual()
- CargaBCIAjuste()
DdlDistribuidor.setEsWebService(True)
DivChkAjuste.Visible = True
End Sub
@@ -5095,16 +5805,8 @@ Partial Class PV
Protected Sub GvRecepcionUsados_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvRecepcionUsados.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
-
- Dim ObjGral As New ClsGenerales
- If ObjGral.BCIUsadoGet(UsuarioActual.CveEmpresa) Then
- e.Row.FCDropDownList("DdlBCIUsado").DataSource = ObjGral.DtResultados.FiltraParametros(String.Format("CveTamaño = {0}", e.Row.DataKey("CveTamaño")))
- End If
- 'DdlBCIUsado.Items.Insert(0, New ListItem("Seleccione", "-1"))
- 'DdlBCIUsado.SelectedValueExist(-1)
+ e.Row.FCDropDownList("DdlBCIUsado").DataSource = DTBCIUsados.FiltraParametros(String.Format("CveTamaño = {0}", e.Row.DataKey("CveTamaño")))
e.Row.FCDropDownList("DdlBCIUsado").DataBind()
- 'e.Row.FCDropDownList("DdlBCIUsado").SelectedValue = e.Row.DBCampo("CveBCIUsado")
-
End If
End Sub