No matener la conexion en toda la carga de la venta, validacion de saldos de RNC

This commit is contained in:
2022-07-01 19:35:55 -07:00
parent a2db87cd44
commit 8f91592b21

View File

@@ -4400,19 +4400,143 @@ Partial Class Ventas
CveVenta = If(CvePedido > 0, CvePedido, CveVenta) CveVenta = If(CvePedido > 0, CvePedido, CveVenta)
Dim DtAntRelacionados As DataTable = Nothing Dim DtAntRelacionados As DataTable = Nothing
Dim SerieFolioPadre As String
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas() 'CARGA DTs DE VENTAS
If CveVenta > 0 Then
Using ObjVentas As New ClsVentas()
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
DbRowVenta = ObjVentas.DtResultados.Copy().Rows(0)
Else
ViewState("CveVenta") = -1
Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia)
End If
End If
If DbRowVenta IsNot Nothing Then
If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then
DtAntRelacionados = ObjVentas.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Ant','Egs','Dev')") DtAntRelacionados = ObjVentas.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Ant','Egs','Dev')")
End If End If
Dim SerieFolioPadre As String 'CargaDetalle
If ObjVentas.GetVentaDetalle(CveVenta) Then
TmpDT = ObjVentas.DtResultados.Copy()
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
End If
'CargaFirmas
If ObjVentas.GetVentasFirmas(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
DTmpF = ObjVentas.DtResultados.Copy()
End If
End If
'CARGA IMPUESTOS LOCALES
If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
TmpDTImpuestos = ObjVentas.DtResultados.Copy()
End If
End If
'CARGA ANTICIPOS
If Not (CveRemision > 0 Or CveCotizacion > 0) Then
If DbRowVenta("TipoDocto").ToString().Contiene("Ing", "Ant") Then
'carga as notas de credito vinculadas
If ObjVentas.GetVentasAntNC(CveVenta, -1) Then
TmpDTDocumentosRelacionados = ObjVentas.DtResultados.Copy()
GvAntNC.DataSource = TmpDTDocumentosRelacionados
GvAntNC.Caption = " <table width='100%'><tr><td style='text-align:center'>(Anticipos/NC/IxC) Vinculados</td></tr></table>"
GvAntNC.DataBind()
End If
End If
If DbRowVenta("TipoDocto").ToString().Contiene("Egs", "Dev", "Ant") Then
Dim AplicaAmortizacion As Boolean = False
If DbRowVenta("TipoDocto").ToString().Contiene("Ant") Then AplicaAmortizacion = True
If ObjVentas.GetVentasAntNC(-1, CveVenta, AplicaAmortizacion) Then
TmpDTNCVinculadas = ObjVentas.DtResultados.Copy()
GvNC.DataSource = TmpDTNCVinculadas
GvNC.Caption = " <table width='100%'><tr><td style='text-align:center'>Ventas Aplicadas</td></tr></table>"
GvNC.DataBind()
InicializaDTVentasNC()
For Each Dr As DataRow In TmpDTNCVinculadas.Rows
If Dr("CveConceptoContable").ToString().ToEntero() = 91 Then
CargaNCDT(Dr("CveVenta").ToString().ToEntero(), Dr("Importe").ToString().ToDecimal, Dr("FolioFiscal").ToString(), TC:=Dr("TipoCambio").ToString().ToDecimal)
End If
Next
If GvNC.Rows.Count > 0 Then
ImgAntiPend.Visible = False
End If
End If
End If
End If
'CARGA REMISIONES
If ObjVentas.GetRemisionesRelacionadas(CveVenta, DbRowVenta("TipoDocto").ToString()) Then
GvRemisiones.Caption = " <table width='100%'><tr><td style='text-align:center'>Remisiones/Facturas</td></tr></table>"
GvRemisiones.DataSource = ObjVentas.DtResultados.Copy()
GvCancelarRemisiones.DataSource = ObjVentas.DtResultados.Copy()
GvRemisiones.DataBind()
GvCancelarRemisiones.DataBind()
'[IPP] SI ES REMISION PARA CANCELARLA NO DEBE TENER NINGUNA FACTURADA RELACIONADA - 24Abril2018
If DbRowVenta("TipoDocto").ToString().Contiene("Rem") And GvRemisiones.Rows.Count > 0 Then
LbCancelarDocumento.Visible = False
End If
'SI TIENE REMISIONES Y VA A CANCELAR ES NECESARIO EL MOVIMIENTO DE DEVOLUCION
If DbRowVenta("TipoDocto").ToString().Contiene("Ing", "Ant") AndAlso GvRemisiones.Rows.Count > 0 Then
ChkDevAlm.Checked = True
ChkDevAlm.Enabled = False
'LiDevolucionAlmacen.Visible = False
End If
End If
'SI ES COTIZACION PUEDE GENERAR UNA OC PARA MODIFICAR LOS IMPORTES
If DbRowVenta("TipoDocto").ToString() = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(583) = "1" Then
Dim DtOCGeneradas As DataTable = Nothing
If ObjVentas.GetVentasCotizacionesOC(Me.CveVenta, -1, UsuarioActual.CveEmpresa) Then
DtOCGeneradas = ObjVentas.DtResultados.Copy()
End If
If DtOCGeneradas IsNot Nothing AndAlso DtOCGeneradas.Rows.Count > 0 Then
LtGenerarOC.Visible = False
Else
LtGenerarOC.Visible = True
End If
End If
'CARGA GV DE OC RELACIONADAS
If ObjVentas.GetOCRelacionadas(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
DivOCRelacionadas.Visible = True
GvOCRelacionadas.DataSource = ObjVentas.DtResultados
GvOCRelacionadas.DataBind()
End If
End If
End If
End Using
End If
If DbRowVenta IsNot Nothing Then
'CARGAR PS
GvPS.DataSource = TmpDT
GvPS.DataBind()
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 CveCliente As Integer = DbRowVenta("CveCliente").ToString().ToEntero()
HdnCveVenta.Value = CveVenta.ToString() HdnCveVenta.Value = CveVenta.ToString()
@@ -4432,13 +4556,10 @@ Partial Class Ventas
Else Else
DivAdjuntar.Visible = False DivAdjuntar.Visible = False
End If End If
ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero() ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero()
Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString().ToEntero() Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString().ToEntero()
'CargaEncabezado 'CargaEncabezado
If Not (CveRemision > 0 Or CveCotizacion > 0) Then If Not (CveRemision > 0 Or CveCotizacion > 0) Then
@@ -4518,21 +4639,6 @@ Partial Class Ventas
TrServicioDomicilio.Visible = True TrServicioDomicilio.Visible = True
End If End If
'CargaDetalle
If ObjVentas.GetVentaDetalle(CveVenta) Then
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
'IEPS A NIVEL DETALLE
'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text)
End If
If UsuarioActual.TienePermisoProceso(318) Then If UsuarioActual.TienePermisoProceso(318) Then
If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(DbRowVenta("FolioFiscal").ToString.Trim) Then HplFolioFiscalModal.Visible = True If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(DbRowVenta("FolioFiscal").ToString.Trim) Then HplFolioFiscalModal.Visible = True
End If End If
@@ -4957,9 +5063,6 @@ Partial Class Ventas
TrTipoRelacion2.Visible = True TrTipoRelacion2.Visible = True
LblTipoRelacion.Text = DbRowVenta("TipoRelacion").ToString() LblTipoRelacion.Text = DbRowVenta("TipoRelacion").ToString()
HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString()
End If End If
@@ -5149,29 +5252,17 @@ Partial Class Ventas
GvPS.Columns(19).Visible = False GvPS.Columns(19).Visible = False
GvPS.Columns(20).Visible = False GvPS.Columns(20).Visible = False
'CargaFirmas GvFirmas.DataSource = DTmpF
If ObjVentas.GetVentasFirmas(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
DTmpF = ObjVentas.DtResultados
GvFirmas.DataSource = ObjVentas.DtResultados
GvFirmas.DataBind() GvFirmas.DataBind()
Else
GvFirmas.DataSource = Nothing
End If
End If
'CARGA IMPUESTOS LOCALES If TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then
If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
TrOtros.Visible = True TrOtros.Visible = True
TmpDTImpuestos = ObjVentas.DtResultados GvImpuestosLocales2.DataSource = TmpDTImpuestos
GvImpuestosLocales2.DataSource = ObjVentas.DtResultados
GvImpuestosLocales2.DataBind() GvImpuestosLocales2.DataBind()
GvImpuestosLocales2.Enabled = False GvImpuestosLocales2.Enabled = False
GvImpuestosLocales2.Visible = True GvImpuestosLocales2.Visible = True
End If End If
End If
DdlVendedor.SelectedValue = If(DbRowVenta("CveVendedor").ToString = "", "0", DbRowVenta("CveVendedor").ToString) 'si viene dbnull, que ponga cero. DdlVendedor.SelectedValue = If(DbRowVenta("CveVendedor").ToString = "", "0", DbRowVenta("CveVendedor").ToString) 'si viene dbnull, que ponga cero.
DdlTipoComprobante.Enabled = False DdlTipoComprobante.Enabled = False
@@ -5273,64 +5364,6 @@ Partial Class Ventas
'JJMQ 20160506: Se agrego para la validacion de pago de contado. 'JJMQ 20160506: Se agrego para la validacion de pago de contado.
'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "")
'CARGA ANTICIPOS
If Not (CveRemision > 0 Or CveCotizacion > 0) Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") Then
'carga as notas de credito vinculadas
If ObjVentas.GetVentasAntNC(CveVenta, -1) Then
GvAntNC.DataSource = ObjVentas.DtResultados
TmpDTDocumentosRelacionados = ObjVentas.DtResultados
GvAntNC.Caption = " <table width='100%'><tr><td style='text-align:center'>(Anticipos/NC/IxC) Vinculados</td></tr></table>"
GvAntNC.DataBind()
End If
End If
If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev", "Ant") Then
Dim AplicaAmortizacion As Boolean = False
If DdlTipoComprobante.SelectedValue.Contiene("Ant") Then AplicaAmortizacion = True
If ObjVentas.GetVentasAntNC(-1, CveVenta, AplicaAmortizacion) Then
GvNC.DataSource = ObjVentas.DtResultados
TmpDTNCVinculadas = ObjVentas.DtResultados
GvNC.Caption = " <table width='100%'><tr><td style='text-align:center'>Ventas Aplicadas</td></tr></table>"
GvNC.DataBind()
InicializaDTVentasNC()
For Each Dr As DataRow In ObjVentas.DtResultados.Rows
If Dr("CveConceptoContable").ToString().ToEntero() = 91 Then
CargaNCDT(Dr("CveVenta").ToString().ToEntero(), Dr("Importe").ToString().ToDecimal, Dr("FolioFiscal").ToString(), TC:=Dr("TipoCambio").ToString().ToDecimal)
End If
Next
End If
End If
End If
If GvNC.Rows.Count > 0 Then
ImgAntiPend.Visible = False
End If
'CARGA REMISIONES
If ObjVentas.GetRemisionesRelacionadas(CveVenta, DdlTipoComprobante.SelectedValue) Then
GvRemisiones.Caption = " <table width='100%'><tr><td style='text-align:center'>Remisiones/Facturas</td></tr></table>"
GvRemisiones.DataSource = ObjVentas.DtResultados
GvCancelarRemisiones.DataSource = ObjVentas.DtResultados
GvRemisiones.DataBind()
GvCancelarRemisiones.DataBind()
'[IPP] SI ES REMISION PARA CANCELARLA NO DEBE TENER NINGUNA FACTURADA RELACIONADA - 24Abril2018
If DdlTipoComprobante.SelectedValue.Contiene("Rem") And GvRemisiones.Rows.Count > 0 Then
LbCancelarDocumento.Visible = False
End If
'SI TIENE REMISIONES Y VA A CANCELAR ES NECESARIO EL MOVIMIENTO DE DEVOLUCION
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") AndAlso GvRemisiones.Rows.Count > 0 Then
ChkDevAlm.Checked = True
ChkDevAlm.Enabled = False
'LiDevolucionAlmacen.Visible = False
End If
End If
tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot")
tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot")
@@ -5391,10 +5424,22 @@ Partial Class Ventas
'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, Now, UsuarioActual.CveEmpresa) Then 'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, Now, UsuarioActual.CveEmpresa) Then
' DtGarantiasPendientes = ObjUsados.DtResultados.Copy() ' DtGarantiasPendientes = ObjUsados.DtResultados.Copy()
'End If 'End If
ObjUsados.Dispose() ObjUsados.Dispose()
Dim SaldoAlmacenExA As Decimal = 0
'Dim SaldoAlmacenUsados As Decimal = 0
Using ObjInventarios As New ClsInventarios
'VERIFICA SI HACE FALTA DEVOLVER PRODUCTOS Y USADOS EN ESPECIFICO
If ObjInventarios.GetSaldoVentaDetalleAlmacen(CveVenta, UsuarioActual.CveEmpresa) Then
SaldoAlmacenExA = ObjInventarios.DtResultados.SUMD("SaldoAlmacen", $"CveTipoAlmacen = 10")
'SaldoAlmacenUsados = ObjInventarios.DtResultados.SUMD("SaldoAlmacen", $"CveTipoAlmacen = 22")
End If
End Using
'Si ya se surtió y recibió 'Si ya se surtió y recibió
If DbRowVenta("SaldoAlmacen").ToString().ToDecimal > 0 OrElse TmpDT.MAX("CveTipoPS") = "1" Then If SaldoAlmacenExA > 0 OrElse TmpDT.MAX("CveTipoPS") = "1" Then
BtnsFacturar.Visible = True BtnsFacturar.Visible = True
End If End If
@@ -5460,19 +5505,6 @@ Partial Class Ventas
CargaCodigoUnico() CargaCodigoUnico()
'SI ES COTIZACION PUEDE GENERAR UNA OC PARA MODIFICAR LOS IMPORTES
If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(583) = "1" Then
Dim DtOCGeneradas As DataTable = Nothing
If ObjVentas.GetVentasCotizacionesOC(Me.CveVenta, -1, UsuarioActual.CveEmpresa) Then
DtOCGeneradas = ObjVentas.DtResultados.Copy()
End If
If DtOCGeneradas IsNot Nothing AndAlso DtOCGeneradas.Rows.Count > 0 Then
LtGenerarOC.Visible = False
Else
LtGenerarOC.Visible = True
End If
End If
DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString()) DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString())
Me.FacturarSucursal = CBool(DbRowVenta("FacturarSucursal").ToString()) Me.FacturarSucursal = CBool(DbRowVenta("FacturarSucursal").ToString())
@@ -5483,17 +5515,6 @@ Partial Class Ventas
CargaPS(-1, DdlPS) CargaPS(-1, DdlPS)
'CARGA GV DE OC RELACIONADAS
If CveVenta > 0 AndAlso ObjVentas.GetOCRelacionadas(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
DivOCRelacionadas.Visible = True
GvOCRelacionadas.DataSource = ObjVentas.DtResultados
End If
End If
GvOCRelacionadas.DataBind()
'Verifico si tiene la funcionalidad (135) 'Verifico si tiene la funcionalidad (135)
If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then
@@ -5560,12 +5581,7 @@ Partial Class Ventas
UpEstatus.Update() UpEstatus.Update()
Retorno = True Retorno = True
Else
ViewState("CveVenta") = -1
Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia)
End If End If
End If
ObjVentas.Dispose()
Return Retorno Return Retorno
End Function End Function
@@ -26690,6 +26706,33 @@ Partial Class Ventas
'GvRemisionesNCBon.DataSource = Me.TmpDTRNCBonificacionesSeleccionadas 'GvRemisionesNCBon.DataSource = Me.TmpDTRNCBonificacionesSeleccionadas
'GvRemisionesNCBon.DataBind() 'GvRemisionesNCBon.DataBind()
Dim SaldoMaximoUtilizable As Decimal = 0
If CargarSoloGarantias Then
Dim SaldoMaximo As Decimal = DtNC.SUMD("Saldo", "TipoRNC = 1 AND EsGarantia = True")
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = SaldoMaximo
Else
SaldoMaximoUtilizable = 0
End If
Else
Dim ObjAcum As New ClsAcumuladores
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2)
DivSMU.Visible = True
Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
Else
SaldoMaximoUtilizable = 0
End If
Else
SaldoMaximoUtilizable = 0
End If
ObjAcum.Dispose()
End If
If CveVentaUsado > 0 Then If CveVentaUsado > 0 Then
DivSMU.Visible = True DivSMU.Visible = True
@@ -26702,44 +26745,21 @@ Partial Class Ventas
End Using End Using
If DtDetalleUsado IsNot Nothing Then If DtDetalleUsado IsNot Nothing Then
Dim SaldoMaximoUsados As Decimal = DtDetalleUsado.SUM("Total", "EsCargo = True").ToDecimal() + DtDetalleUsado.SUM("ImporteIVA", "EsCargo = True").ToDecimal() Dim SaldoMaximoUsadosFactura As Decimal = DtDetalleUsado.SUM("Total", "EsCargo = True").ToDecimal() + DtDetalleUsado.SUM("ImporteIVA", "EsCargo = True").ToDecimal()
HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() If SaldoMaximoUtilizable < SaldoMaximoUsadosFactura Then
LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
End If LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUtilizable)
Else Else
If CargarSoloGarantias Then HdnSaldoMaximoUsados.Value = SaldoMaximoUsadosFactura.ToString()
Dim SaldoMaximo As Decimal = DtNC.SUMD("Saldo", "TipoRNC = 1 AND EsGarantia = True") LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsadosFactura)
If SaldoMaximo > 0 Then
HdnSaldoMaximoUsados.Value = SaldoMaximo.ToString()
LtlSMU.Text = SaldoMaximo.FormatoNumero(2)
Else
HdnSaldoMaximoUsados.Value = "0"
LtlSMU.Text = "0"
End If End If
Else Else
Dim ObjAcum As New ClsAcumuladores HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUtilizable)
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2) End If
DivSMU.Visible = True
Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
If SaldoMaximo > 0 Then
HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString()
LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2)
Else Else
HdnSaldoMaximoUsados.Value = "0" HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
LtlSMU.Text = "0" LtlSMU.Text = SaldoMaximoUtilizable.FormatoNumero(2)
End If
Else
'DivSMU.Visible = False
HdnSaldoMaximoUsados.Value = "0"
LtlSMU.Text = "0"
End If
ObjAcum.Dispose()
End If
End If End If
Else Else
HdnSaldoMaximoUsados.Value = "0" HdnSaldoMaximoUsados.Value = "0"
@@ -26778,9 +26798,44 @@ Partial Class Ventas
End If End If
GvDescNCCargos.DataBind() GvDescNCCargos.DataBind()
Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() Dim SaldoMaximoUtilizable As Decimal = 0
HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString()
LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) If CargarSoloGarantias Then
Dim SaldoMaximo As Decimal = DtNC.SUMD("Saldo", "TipoRNC = 1 AND EsGarantia = True")
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = SaldoMaximo
Else
SaldoMaximoUtilizable = 0
End If
Else
Dim ObjAcum As New ClsAcumuladores
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2)
DivSMU.Visible = True
Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
Else
SaldoMaximoUtilizable = 0
End If
Else
SaldoMaximoUtilizable = 0
End If
ObjAcum.Dispose()
End If
Dim SaldoMaximoUsadosFactura As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal()
If SaldoMaximoUtilizable < SaldoMaximoUsadosFactura Then
HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUtilizable)
Else
HdnSaldoMaximoUsados.Value = SaldoMaximoUsadosFactura.ToString()
LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsadosFactura)
End If
Else Else
HdnSaldoMaximoUsados.Value = "0" HdnSaldoMaximoUsados.Value = "0"
LblSaldoMaximoUsados.Text = "0" LblSaldoMaximoUsados.Text = "0"
@@ -26820,6 +26875,27 @@ Partial Class Ventas
GvRemisionesNCDetalle.DataBind() GvRemisionesNCDetalle.DataBind()
'GvRemisionesNCBon.DataBind() 'GvRemisionesNCBon.DataBind()
Dim SaldoMaximoUtilizable As Decimal = 0
If CargaSoloGarantias Then
Dim SaldoMaximo As Decimal = TmpDTRNCDetalle.SUMD("Total", "TipoRNC = 1")
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = SaldoMaximo
Else
SaldoMaximoUtilizable = 0
End If
Else
Dim ObjAcum As New ClsAcumuladores
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2)
DivSMU.Visible = True
SaldoMaximoUtilizable = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
Else
'DivSMU.Visible = False
SaldoMaximoUtilizable = 0
End If
ObjAcum.Dispose()
End If
If CveVentaUsado > 0 Then If CveVentaUsado > 0 Then
DivSMU.Visible = True DivSMU.Visible = True
@@ -26833,49 +26909,26 @@ Partial Class Ventas
If DtDetalleUsado IsNot Nothing Then If DtDetalleUsado IsNot Nothing Then
Dim SaldoMaximoUsados As Decimal = DtDetalleUsado.SUM("Total", "EsCargo = True").ToDecimal() + DtDetalleUsado.SUM("ImporteIVA", "EsCargo = True").ToDecimal() Dim SaldoMaximoUsados As Decimal = DtDetalleUsado.SUM("Total", "EsCargo = True").ToDecimal() + DtDetalleUsado.SUM("ImporteIVA", "EsCargo = True").ToDecimal()
HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
If SaldoMaximoUsados > 0 Then If SaldoMaximoUtilizable < SaldoMaximoUsados Then
HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUtilizable)
Else
HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString()
LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados)
Else
HdnSaldoMaximoUsados.Value = "0"
LtlSMU.Text = "0"
End If End If
End If End If
Else Else
If CargaSoloGarantias Then HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
Dim SaldoMaximo As Decimal = TmpDTRNCDetalle.SUMD("Total", "TipoRNC = 1") LtlSMU.Text = SaldoMaximoUtilizable.FormatoNumero(2)
If SaldoMaximo > 0 Then
HdnSaldoMaximoUsados.Value = SaldoMaximo.ToString()
LtlSMU.Text = SaldoMaximo.FormatoNumero(2)
Else
HdnSaldoMaximoUsados.Value = "0"
LtlSMU.Text = "0"
End If
Else
Dim ObjAcum As New ClsAcumuladores
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2)
DivSMU.Visible = True
HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString()
LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2)
Else
'DivSMU.Visible = False
HdnSaldoMaximoUsados.Value = "0"
LtlSMU.Text = "0"
End If
ObjAcum.Dispose()
End If
End If End If
UpModalRemisionesNC.Update() UpModalRemisionesNC.Update()
UpDescNC.Update() UpDescNC.Update()
End Sub End Sub
Private Sub CargaRNCDetalleDesc(Optional CargarSoloGarantias As Boolean = False) Private Sub CargaRNCDetalleDesc(Optional CargarSoloGarantias As Boolean = False)
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos() Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1) Then If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1) Then
@@ -26896,14 +26949,42 @@ Partial Class Ventas
End If End If
GvDescNCCargosDetalle.DataBind() GvDescNCCargosDetalle.DataBind()
Dim SaldoMaximoUtilizable As Decimal = 0
If CargarSoloGarantias Then
Dim SaldoMaximo As Decimal = TmpDTRNCDetalle.SUMD("Saldo", "TipoRNC = 1 AND EsGarantia = True")
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = SaldoMaximo
Else
SaldoMaximoUtilizable = 0
End If
Else
Dim ObjAcum As New ClsAcumuladores
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2)
DivSMU.Visible = True
Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal()
Else
SaldoMaximoUtilizable = 0
End If
Else
SaldoMaximoUtilizable = 0
End If
ObjAcum.Dispose()
End If
Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal()
If SaldoMaximoUsados > 0 Then If SaldoMaximoUtilizable < SaldoMaximoUsados Then
HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString()
LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUtilizable)
Else
HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString()
LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados)
Else
HdnSaldoMaximoUsados.Value = "0"
LblSaldoMaximoUsados.Text = "0"
End If End If
UpDescNC.Update() UpDescNC.Update()
@@ -26940,6 +27021,16 @@ Partial Class Ventas
GvRemisionesNCBonDetalle.DataSource = TmpDTRNCDetalle.FiltraParametros("TipoRNC = 2") GvRemisionesNCBonDetalle.DataSource = TmpDTRNCDetalle.FiltraParametros("TipoRNC = 2")
GvRemisionesNCBonDetalle.DataBind() GvRemisionesNCBonDetalle.DataBind()
Dim SaldoMaximoUtilizable As Decimal = 0
If TmpDTRNCBonificacionesSeleccionadas IsNot Nothing Then
Dim SaldoMaximo As Decimal = TmpDTRNCBonificacionesSeleccionadas.SUMD("Saldo")
If SaldoMaximo > 0 Then
SaldoMaximoUtilizable = SaldoMaximo
Else
SaldoMaximoUtilizable = 0
End If
End If
If DdlVentaUsado.SelectedValue.ToEntero() > 0 Then If DdlVentaUsado.SelectedValue.ToEntero() > 0 Then
Dim DtDetalleFactura As DataTable = Nothing Dim DtDetalleFactura As DataTable = Nothing
Using ObjVentas As New ClsVentas Using ObjVentas As New ClsVentas
@@ -26949,21 +27040,18 @@ Partial Class Ventas
End Using End Using
Dim ImporteBon As Decimal = DtDetalleFactura.SUMD("PUBonificacion") * (1 + DtDetalleFactura.MAX("PorcentajeIVA").ToDecimal()) Dim ImporteBon As Decimal = DtDetalleFactura.SUMD("PUBonificacion") * (1 + DtDetalleFactura.MAX("PorcentajeIVA").ToDecimal())
If SaldoMaximoUtilizable < ImporteBon Then
LtlSMUBon.Text = String.Format("{0:N2}", SaldoMaximoUtilizable)
HdnSMUBon.Value = SaldoMaximoUtilizable.ToString()
Else
LtlSMUBon.Text = String.Format("{0:N2}", ImporteBon) LtlSMUBon.Text = String.Format("{0:N2}", ImporteBon)
HdnSMUBon.Value = ImporteBon.ToString() HdnSMUBon.Value = ImporteBon.ToString()
End If
DtDetalleFactura.Dispose() DtDetalleFactura.Dispose()
Else Else
If TmpDTRNCBonificacionesSeleccionadas IsNot Nothing Then HdnSMUBon.Value = SaldoMaximoUtilizable.ToString()
Dim SaldoMaximo As Decimal = TmpDTRNCBonificacionesSeleccionadas.SUMD("Saldo") LtlSMUBon.Text = SaldoMaximoUtilizable.FormatoNumero(2)
If SaldoMaximo > 0 Then
HdnSMUBon.Value = SaldoMaximo.ToString()
LtlSMUBon.Text = SaldoMaximo.FormatoNumero(2)
Else
HdnSMUBon.Value = "0"
LtlSMUBon.Text = "0"
End If
End If
End If End If
UpModalRemisionesNC.Update() UpModalRemisionesNC.Update()
@@ -27077,6 +27165,9 @@ Partial Class Ventas
'LtlSMUBon.Text = String.Format("{0:N2}", SMUBon) 'LtlSMUBon.Text = String.Format("{0:N2}", SMUBon)
'HdnSMUBon.Value = SMUBon.ToString() 'HdnSMUBon.Value = SMUBon.ToString()
Dim SaldoMaximoUtilizable As Decimal = TmpDTRNCBonificacionesSeleccionadas.SUMD("Saldo")
If DdlVentaUsado.SelectedValue.ToEntero() > 0 Then If DdlVentaUsado.SelectedValue.ToEntero() > 0 Then
Dim DtDetalleFactura As DataTable = Nothing Dim DtDetalleFactura As DataTable = Nothing
Using ObjVentas As New ClsVentas Using ObjVentas As New ClsVentas
@@ -27086,15 +27177,20 @@ Partial Class Ventas
End Using End Using
Dim ImporteBon As Decimal = DtDetalleFactura.SUMD("PUBonificacion") * (1 + DtDetalleFactura.MAX("PorcentajeIVA").ToDecimal()) Dim ImporteBon As Decimal = DtDetalleFactura.SUMD("PUBonificacion") * (1 + DtDetalleFactura.MAX("PorcentajeIVA").ToDecimal())
If SaldoMaximoUtilizable < ImporteBon Then
LtlSMUBon.Text = String.Format("{0:N2}", SaldoMaximoUtilizable)
HdnSMUBon.Value = SaldoMaximoUtilizable.ToString()
Else
LtlSMUBon.Text = String.Format("{0:N2}", ImporteBon) LtlSMUBon.Text = String.Format("{0:N2}", ImporteBon)
HdnSMUBon.Value = ImporteBon.ToString() HdnSMUBon.Value = ImporteBon.ToString()
End If
DtDetalleFactura.Dispose() DtDetalleFactura.Dispose()
Else Else
Dim SaldoMaximo As Decimal = TmpDTRNCBonificacionesSeleccionadas.SUMD("Saldo") If SaldoMaximoUtilizable > 0 Then
If SaldoMaximo > 0 Then HdnSMUBon.Value = SaldoMaximoUtilizable.ToString()
HdnSMUBon.Value = SaldoMaximo.ToString() LtlSMUBon.Text = SaldoMaximoUtilizable.FormatoNumero(2)
LtlSMUBon.Text = SaldoMaximo.FormatoNumero(2)
Else Else
HdnSMUBon.Value = "0" HdnSMUBon.Value = "0"
LtlSMUBon.Text = "0" LtlSMUBon.Text = "0"