diff --git a/App_Code/ClsCompras.vb b/App_Code/ClsCompras.vb
index 030f28eaf..0a3410f83 100644
--- a/App_Code/ClsCompras.vb
+++ b/App_Code/ClsCompras.vb
@@ -191,12 +191,12 @@ Public Class ClsCompras
Return Retorno
End Function
- Public Function AddCompra(TipoDocto As String, Descripcion As String, Serie As String, Folio As String, FolioSecundario As String, CveProveedor As Integer, SubTotal As Double, Descuentos As Double, Amortizacion As Double, IVA As Double,
- RetIVA As Double, RetISR As Double, IEPS As Double, OtrosImpuestos As Double, Redondeo As Double, Total As Double, Fecha As Date, CveMoneda As Integer, TipoCambio As Double, FechaVencimiento As Date,
+ Public Function AddCompra(TipoDocto As String, Descripcion As String, Serie As String, Folio As String, FolioSecundario As String, CveProveedor As Integer, SubTotal As Decimal, Descuentos As Decimal, Amortizacion As Decimal, IVA As Decimal,
+ RetIVA As Decimal, RetISR As Decimal, IEPS As Decimal, OtrosImpuestos As Decimal, Redondeo As Decimal, Total As Decimal, Fecha As Date, CveMoneda As Integer, TipoCambio As Decimal, FechaVencimiento As Date,
AplicaNotaCredito As Boolean, Observaciones As String, CveEstatusCompra As Integer, CvePrePoliza As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional IdPoliza As Integer = -1,
Optional CveOC As Integer = -1, Optional CveCajaChica As Integer = -1, Optional CvePersonal As Integer = -1, Optional NumeroReembolso As String = "-1", Optional CveProveedorSucursal As Integer = -1,
- Optional AplicoPromocion As Boolean = False, Optional PorcentajeIVA As Double = 0, Optional CveMetodoPago As Integer = -1, Optional CveRetIVAConcepto As Integer = -1, Optional CveConceptoContableAlmacen As Integer = -1,
- Optional CveRetISRConcepto As Integer = -1, Optional NoDeducible As Boolean = False, Optional CveTipoCompra As Integer = -1, Optional TotalOriginal As Double = 0, Optional CveTipoConcepto As Integer = 1, Optional CveFactura As Integer = -1,
+ Optional AplicoPromocion As Boolean = False, Optional PorcentajeIVA As Decimal = 0, Optional CveMetodoPago As Integer = -1, Optional CveRetIVAConcepto As Integer = -1, Optional CveConceptoContableAlmacen As Integer = -1,
+ Optional CveRetISRConcepto As Integer = -1, Optional NoDeducible As Integer = 0, Optional CveTipoCompra As Integer = -1, Optional TotalOriginal As Decimal = 0, Optional CveTipoConcepto As Integer = 1, Optional CveFactura As Integer = -1,
Optional CveContrato As Integer = -1, Optional EsImportacion As Boolean = False, Optional CveSubProyecto As Integer = -1, Optional DoctosRelacionados As String = "-1", Optional CveFolioGarantia As Integer = -1) As Boolean
Dim Retorno As Boolean = False
@@ -243,7 +243,7 @@ Public Class ClsCompras
.Add("@CveRetIVAConcepto", SqlDbType.Int).Value = CveRetIVAConcepto
.Add("@CveConceptoContableAlmacen", SqlDbType.Int).Value = CveConceptoContableAlmacen
.Add("@CveRetISRConcepto", SqlDbType.Int).Value = CveRetISRConcepto
- .Add("@NoDeducible", SqlDbType.Bit).Value = NoDeducible
+ .Add("@NoDeducible", SqlDbType.TinyInt).Value = NoDeducible
.Add("@CveTipoCompra", SqlDbType.Int).Value = CveTipoCompra
.Add("@TotalOriginal", SqlDbType.Money).Value = TotalOriginal
.Add("@CveTipoConcepto", SqlDbType.Int).Value = CveTipoConcepto
@@ -276,15 +276,13 @@ Public Class ClsCompras
Return Retorno
End Function
Public Function UpdateCompra(Descripcion As String, FolioSecundario As String, FechaVencimiento As Date, AplicaNotaCredito As Boolean, Observaciones As String, CveEstatusCompra As Integer,
- Descuento As Double, SubTotal As Double, IVA As Double, Total As Double, CveUsuario As Integer, CveCompra As Integer, Optional CveCajaChica As Integer = -1, Optional CvePersonal As Integer = -1,
- Optional CveProveedorSucursal As Integer = -1, Optional PorcentajeIVA As Double = 0, Optional NumeroReembolso As String = "", Optional CveTipoCompra As Integer = -1, Optional NoDeducible As Boolean = False,
+ Descuento As Decimal, SubTotal As Decimal, IVA As Decimal, Total As Decimal, CveUsuario As Integer, CveCompra As Integer, Optional CveCajaChica As Integer = -1, Optional CvePersonal As Integer = -1,
+ Optional CveProveedorSucursal As Integer = -1, Optional PorcentajeIVA As Decimal = 0, Optional NumeroReembolso As String = "", Optional CveTipoCompra As Integer = -1, Optional NoDeducible As Integer = 0,
Optional CveFactura As Integer = -1, Optional CveContrato As Integer = -1, Optional CveRetIVAConcepto As Integer = -1, Optional CveRetISRConcepto As Integer = -1, Optional CveSubProyecto As Integer = -1,
Optional CveFolioGarantia As Integer = -1) As Boolean
Dim Retorno As Boolean = False
-
-
DataAdapter("PA_Comp_CompraUpdate")
With SqlAdapter.SelectCommand.Parameters
@@ -306,7 +304,7 @@ Public Class ClsCompras
.Add("@PorcentajeIVA", SqlDbType.Float).Value = PorcentajeIVA
.Add("@NumeroReembolso", SqlDbType.VarChar).Value = NumeroReembolso
.Add("@CveTipoCompra", SqlDbType.Int).Value = CveTipoCompra
- .Add("@NoDeducible", SqlDbType.Bit).Value = NoDeducible
+ .Add("@NoDeducible", SqlDbType.Int).Value = NoDeducible
.Add("@CveFactura", SqlDbType.Int).Value = CveFactura
.Add("@CveContrato", SqlDbType.Int).Value = CveContrato
.Add("@CveRetIVAConcepto", SqlDbType.Int).Value = CveRetIVAConcepto
@@ -515,10 +513,10 @@ Public Class ClsCompras
Return Retorno
End Function
- Public Function UpdateCompraDetalle(CvePS As Integer, Cantidad As Double, PU As Double, IVA As Double, Total As Double, Descuento As Double, Observaciones As String, CveSubProyecto As Integer, CvePresupuestoEgreso As Integer, CveActivoFijo As Integer, CveCompraDetalle As Integer, Optional AplicaCostoIndirecto As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveTipoGasto As Integer = -1,
+ Public Function UpdateCompraDetalle(CvePS As Integer, Cantidad As Decimal, PU As Decimal, IVA As Decimal, Total As Decimal, Descuento As Decimal, Observaciones As String, CveSubProyecto As Integer, CvePresupuestoEgreso As Integer, CveActivoFijo As Integer, CveCompraDetalle As Integer, Optional AplicaCostoIndirecto As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveTipoGasto As Integer = -1,
Optional AF_Medida As Integer = -1, Optional AF_TipoMantenimiento As Integer = -1, Optional Referencia As String = "",
- Optional RetIVA As Double = 0, Optional RetISR As Double = 0, Optional IEPSPS As Double = 0, Optional IEPSPSIVA As Double = 0,
- Optional IVAPorcentaje As Double = 0, Optional RetIVAPorcentaje As Double = 0, Optional RetISRPorcentaje As Double = 0, Optional IEPSPSPorcentaje As Double = 0, Optional IEPSPSIVAPorcentaje As Double = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1) As Boolean
+ Optional RetIVA As Decimal = 0, Optional RetISR As Decimal = 0, Optional IEPSPS As Decimal = 0, Optional IEPSPSIVA As Decimal = 0,
+ Optional IVAPorcentaje As Decimal = 0, Optional RetIVAPorcentaje As Decimal = 0, Optional RetISRPorcentaje As Decimal = 0, Optional IEPSPSPorcentaje As Decimal = 0, Optional IEPSPSIVAPorcentaje As Decimal = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1) As Boolean
Dim Retorno As Boolean = False
@@ -542,12 +540,12 @@ Public Class ClsCompras
.Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal
.Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto
.Add("@Referencia", SqlDbType.VarChar).Value = Referencia
- .Add("@RetIVA", SqlDbType.Float).Value = RetIVA
- .Add("@RetISR", SqlDbType.Float).Value = RetISR
- .Add("@IEPSPS", SqlDbType.Float).Value = IEPSPS
- .Add("@IEPSPSIVA", SqlDbType.Float).Value = IEPSPSIVA
+ .Add("@RetIVA", SqlDbType.Money).Value = RetIVA
+ .Add("@RetISR", SqlDbType.Money).Value = RetISR
+ .Add("@IEPSPS", SqlDbType.Money).Value = IEPSPS
+ .Add("@IEPSPSIVA", SqlDbType.Money).Value = IEPSPSIVA
- .Add("@IVAPorcentaje", SqlDbType.Float).Value = IVAPorcentaje
+ .Add("@IVAPorcentaje", SqlDbType.Money).Value = IVAPorcentaje
.Add("@RetIVAPorcentaje", SqlDbType.Float).Value = RetIVAPorcentaje
.Add("@RetISRPorcentaje", SqlDbType.Float).Value = RetISRPorcentaje
.Add("@IEPSPSPorcentaje", SqlDbType.Float).Value = IEPSPSPorcentaje
diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb
index 66bc4f23a..69145f2ca 100644
--- a/App_Code/ClsContabilidad.vb
+++ b/App_Code/ClsContabilidad.vb
@@ -1254,7 +1254,6 @@ Public Class ClsContabilidad
Return Retorno
End Function
-
Public Function ContabilizaDesContabilizaPrePoliza(CvePrePoliza As Integer, Contabilizar As Boolean, CveEmpresa As Integer, Optional Folio As Integer = -1) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Conta_PrePolizasContabilizarDescontabilizar")
@@ -1281,7 +1280,6 @@ Public Class ClsContabilidad
Return Retorno
End Function
-
Public Function ContabilizarPrePoliza(CvePrePoliza As Integer, CveUsuario As Integer, Empresa As Empresa, Optional Fecha As Date = MinFecha, Optional Concepto As String = "",
Optional ObjConta As ClsContPAQi = Nothing, Optional pIDPoliza As Integer = -1) As Boolean
Dim StrLog As New StringBuilder
@@ -1301,8 +1299,6 @@ Public Class ClsContabilidad
Else
If CvePrePoliza <= 0 Then Return False
-
-
Dim ContaCompartida As Boolean = False
If ObjConta Is Nothing Then
@@ -1337,11 +1333,6 @@ Public Class ClsContabilidad
CodigoNumeroPoliza = Data.Rows(0)("CodigoNumeroPoliza").ToString
CvePlantillaPoliza = Data.Rows(0)("CvePlantillaPoliza").ToString.ToEntero
- 'FolioFiscal = Data.Rows(0)("FolioFiscal").ToString
- 'MetodoPagoSAT = Data.Rows(0)("ClaveSAT").ToString
- 'CveMoneda = Data.Rows(0)("CveMoneda").ToString.ToEntero
- 'Total = Data.Rows(0)("Total").ToString.ToDecimal
-
If FolioFijo > 0 Then CodigoNumeroPoliza = "CHQ"
'tiene prioridad el concepto en parametro
@@ -1359,18 +1350,6 @@ Public Class ClsContabilidad
ContaFolio = ObjConta.Folio.ToString
End If
-
-
- 'If Empresa.Funcionalidad(522).ToString = "1" Then
- ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString
- ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month
- ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year
-
- ' ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, "-1", Empresa.BDContPAQi, Ejercicio, Periodo, ContaFolio)
-
- 'End If
-
-
If tIdPoliza > 0 AndAlso GetContabilizacionDiarioDetalle(CvePrePoliza) Then
Dim tipoMovimiento As Boolean = False
Dim CveConceptoContable As Integer
@@ -1423,9 +1402,6 @@ Public Class ClsContabilidad
StrLog.AppendFormat(" Error 1.2 - ")
Exit For
End If
-
-
-
End If
Else
OcurrioError = True
@@ -1436,7 +1412,6 @@ Public Class ClsContabilidad
Next
-
'Obtenemos los valores de la causacion y los agregamos
If Not OcurrioError AndAlso ContabilizarCausacion Then
If GetCausacionesValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then
@@ -1494,7 +1469,6 @@ Public Class ClsContabilidad
End If
-
If IdProveedor <= 0 Then
IdProveedor = ObjConta.AddProveedor(IdCtaContProveedores, RFC, RazonSocial, "")
If IdProveedor <= 0 Then
@@ -1520,12 +1494,8 @@ Public Class ClsContabilidad
StrLog.AppendFormat(" Error 1.6 - ")
Mensaje.Append("La Poliza o la Cuenta no son válidas ")
End If
-
-
End If
-
Next
-
End If
End If
@@ -1543,8 +1513,6 @@ Public Class ClsContabilidad
End If
End If
-
-
If OcurrioError Then
If Not ContaCompartida Then ObjConta.RollBack()
Else
@@ -1565,8 +1533,6 @@ Public Class ClsContabilidad
StrLog.AppendFormat(" Error 3.1 - ")
End If
-
-
Catch ex As Exception
StrLog.AppendFormat(" Error 4.1 - ")
If Not ContaCompartida Then ObjConta.RollBack()
@@ -1577,13 +1543,13 @@ Public Class ClsContabilidad
If Not ContaCompartida Then ObjConta.Dispose()
End If
+
StrLog.AppendFormat(" - Con Retorno ({0}) - OcurrioError ({1}) ", Retorno, OcurrioError)
StrLog.AppendFormat(" - Fin")
StrLog.ToString.GuardaLogAD("LogContabilizacion")
Return Retorno
End Function
-
Public Function GetCuentaDobleConta(IdCtaContable As Integer, CveEmpresa As Integer) As Boolean
Dim Retorno As Boolean = False
@@ -1768,11 +1734,8 @@ Public Class ClsContabilidad
Return Retorno
End Function
-
-
#End Region
-
Public Function GetCuentasConceptos(CveTipoSaldo As Integer, CveEmpresa As Integer, Optional CveCliente As Integer = -1,
Optional CveProveedor As Integer = -1,
Optional CveClasificacion As Integer = -1,
@@ -1801,8 +1764,6 @@ Public Class ClsContabilidad
Return Retorno
End Function
-
-
#Region " C O N T A B I L I D A D - T I P O - P O L I Z A "
Public Function GetConta_TiposPoliza(CveEmpresa As Integer) As Boolean
Dim Retorno As Boolean = False
@@ -3407,8 +3368,6 @@ Public Class ClsContabilidad
#End Region
-
-
#Region " CONTABILIDAD SIG "
@@ -5996,7 +5955,7 @@ Public Class ClsContabilidad
Return Retorno
End Function
- Public Function AddCuentasAsignaciones(Optional CveConceptoContable As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCuenta As Integer = -1,
+ Public Function AddCuentasAsignaciones(CveConceptoContable As Integer, CveEmpresa As Integer, CveCuenta As Integer,
Optional CveProveedor As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveClasificacion As Integer = -1,
Optional CveAlmacen As Integer = -1, Optional PorcentajeIVA As Decimal = -1, Optional CveConceptoNomina As Decimal = -1, Optional CveBancoCuenta As Integer = -1,
Optional CveSubProyecto As Integer = -1, Optional CveActivoFijo As Integer = -1, Optional CveTipoGasto As Integer = -1, Optional CveCredito As Integer = -1,
@@ -6442,7 +6401,7 @@ Public Class ClsContabilidad
If MsgPrePoliza <> "" Then MsgPrePoliza.GuardaLogAD("LogPrePoliza")
If MensajePolizaDescuadre = "" AndAlso AutoConta Then
- If UsuarioActual.Empresa.TipoContabilidad = 2 Then ' eltipocontabilidad deberá activarse en el PA
+ If UsuarioActual.Empresa.TipoContabilidad = 2 Then ' el tipocontabilidad deberá activarse en el PA
If Not ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
MensajePolizaDescuadre = Mensaje.ToString ' regresa el mensaje de contabilización
End If
diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb
index c8fa05f1a..984ed624c 100644
--- a/App_Code/ClsPaginas.vb
+++ b/App_Code/ClsPaginas.vb
@@ -7338,7 +7338,8 @@ Public Class ClsPaginas
ImporteMovimiento = (PorcentajePago * CompraActual.IVANoDeducible).RoundSQL
ImporteMN = (ImporteMovimiento * CompraActual.TC).RoundSQL
If CompraActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 280, CompraActual.SerieFolio, Concepto, Ret.IdCtaContIVANoAcreditable, CveCompra:=CompraActual.CveCompra, CveProveedor:=CompraActual.CveProveedor, CveIE:=Pago.CveIE, PorcentajeImpuesto:=CompraActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=CompraActual.TC, TipoCambioPago:=TCValuacionPago, ImporteME:=ImporteME, CveSubProyecto:=CompraActual.CveSubProyecto) Then ErrorMovtos = True
+ Dim tConceptoIVA As Integer = If(CompraActual.CompraNoDeducible = 1, 280, 380) '280. iva no deducible en su totalidad
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, tConceptoIVA, CompraActual.SerieFolio, Concepto, Ret.IdCtaContIVANoAcreditable, CveCompra:=CompraActual.CveCompra, CveProveedor:=CompraActual.CveProveedor, CveIE:=Pago.CveIE, PorcentajeImpuesto:=CompraActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=CompraActual.TC, TipoCambioPago:=TCValuacionPago, ImporteME:=ImporteME, CveSubProyecto:=CompraActual.CveSubProyecto) Then ErrorMovtos = True
End If
End If
'si tiene RET IVA y su proporcion
@@ -7513,6 +7514,7 @@ Public Class ClsPaginas
Public Property EsImportacion As Boolean = False
Public Property TC As Decimal = 1
Public Property Total As Decimal
+ Public Property CompraNoDeducible As Integer = 0
Public Property IVA As Decimal
Public Property IVADeducible As Decimal
Public Property IVANoDeducible As Decimal = 0
@@ -7538,18 +7540,6 @@ Public Class ClsPaginas
Ret.CveConceptoAcreditable = 19
Ret.CveConceptoxAcreditar = 14
End If
- 'If UsuarioActual.Empresa.TipoContabilidad = 2 Then
- ' Dim IdCtaIVAXAcreditar, IdCtaIVAAcreditable, IdCtaIVANOAcreditable As Integer
- ' Dim dt As DataTable = ClsPaginas.GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA)
- ' If dt.Rows.Count > 0 Then
- ' IdCtaIVAXAcreditar = dt.Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
- ' IdCtaIVAAcreditable = dt.Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
- ' IdCtaIVANOAcreditable = dt.Rows(0)("IdCtaIVANoAcreditable").ToString.ToEntero
- ' End If
- ' Ret.IdCtaContableAcreditable = IdCtaIVAAcreditable
- ' Ret.IdCtaContablexAcreditar = IdCtaIVAXAcreditar
- ' Ret.IdCtaContIVANoAcreditable = IdCtaIVANOAcreditable
- 'End If
Return Ret
End Get
End Property
@@ -7894,8 +7884,8 @@ Public Class ClsPaginas
End If
'concepto pago
- Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia)
If Pago.TipoPago = "A" AndAlso Not ErrorMovtos Then ' A N T I C I P O
+ Concepto = String.Format("{0} Ant:{1}", VentaActual.ClienteNombre, Pago.Referencia)
Dim Ret As New ConceptosRetenciones
'Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(6, VentaActual.CveMoneda, True, 1)
If Pago.CveMonedaPago > 1 Then
@@ -7909,6 +7899,7 @@ Public Class ClsPaginas
End If
End If
If Pago.TipoPago = "NC" AndAlso Not ErrorMovtos Then ' N O T A D E C R E D I T O
+ Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia)
Dim Ret As New ConceptosRetenciones
Dim ConPrePNC As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(6, VentaActual.CveMoneda, True, 2)
If Pago.CveMonedaPago > 1 Then
@@ -7922,6 +7913,7 @@ Public Class ClsPaginas
End If
End If
If Pago.TipoPago = "I" AndAlso Not ErrorMovtos Then ' I N G R E S O S X C O M P R O B A R
+ Concepto = String.Format("{0} IxC:{1}", VentaActual.ClienteNombre, Pago.Referencia)
Dim Ret As New ConceptosRetenciones
If VentaActual.UsuarioActual.Empresa.TipoContabilidad = 2 Then
'If ObjConta.GetRetCuenta(66, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
@@ -7988,6 +7980,7 @@ Public Class ClsPaginas
End If
If Diferencia <> 0 Then
+ Concepto = String.Format("{0} Ref:{1}", VentaActual.ClienteNombre, Pago.Referencia)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Diferencia, Diferencia, ConceptoContable, Concepto, Concepto, IdCtaContable, CveVenta:=VentaActual.CveVenta, CveSubProyecto:=VentaActual.CveSubProyecto, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE) Then
ErrorMovtos = True
End If
diff --git a/Bancos/ClientesAbonar.aspx.vb b/Bancos/ClientesAbonar.aspx.vb
new file mode 100644
index 000000000..615b51eb0
--- /dev/null
+++ b/Bancos/ClientesAbonar.aspx.vb
@@ -0,0 +1,2991 @@
+Imports System.Data
+Imports Extensiones
+
+Partial Class Ventas_ClientesAbonar
+ Inherits ClsPaginas
+
+
+#Region "Propiedades"
+ Private ReadOnly Property CveCliente As Integer
+ Get
+ Return ViewState("CveCliente").ToString.ToEntero
+ End Get
+ End Property
+ Private Property CveMoneda As Integer
+ Get
+ Return ViewState("CveMoneda").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveMoneda") = value
+ End Set
+ End Property
+
+ Private Property CveMonedaPago As Integer
+ Get
+ Return ViewState("CveMonedaPago").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveMonedaPago") = value
+ End Set
+ End Property
+ Private Property CveMonedaFiltro As Integer
+ Get
+ Return IfNull(ViewState("CveMonedaFiltro"), "0").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveMonedaFiltro") = value
+ End Set
+ End Property
+ Private Property FechaIngreso As Date
+ Get
+ Return ViewState("FechaIngreso").ToString.ToDate
+ End Get
+ Set(value As Date)
+ ViewState("FechaIngreso") = value
+ End Set
+ End Property
+ Private Property CveSubProyecto As Integer
+ Get
+ Return ViewState("CveSubProyecto").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveSubProyecto") = value
+ End Set
+ End Property
+ Private Property CveClienteSucursal As Integer
+ Get
+ Return If(IsNothing(ViewState("CveClienteSucursal")), -1, ViewState("CveClienteSucursal").ToString.ToEntero)
+ End Get
+ Set(value As Integer)
+ ViewState("CveClienteSucursal") = value
+ End Set
+ End Property
+ Private Property DTFuenteRecaudacion As DataTable
+ Get
+ Return CType(ViewState("DTFuenteRecaudacion"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DTFuenteRecaudacion") = value
+ End Set
+ End Property
+
+ Private Property DtIngresos As DataTable
+ Get
+ Return CType(ViewState("DtIngresos"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtIngresos") = value
+ End Set
+ End Property
+ Private Property DtPrestamos As DataTable
+ Get
+ Return CType(ViewState("DtPrestamos"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtPrestamos") = value
+ End Set
+ End Property
+
+ Private Property IdCuentaBancaria As Integer
+ Get
+ Return ViewState("IdCuentaBancaria").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IdCuentaBancaria") = value
+ End Set
+ End Property
+ Private Property IdCuentaBancariaComplementaria As Integer
+ Get
+ Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IdCuentaBancariaComplementaria") = value
+ End Set
+ End Property
+
+ Private Property NombreComercial As String
+ Get
+ Return ViewState("NombreComercial").ToString
+ End Get
+ Set(value As String)
+ ViewState("NombreComercial") = value
+ End Set
+ End Property
+
+ Private Property IdCuentaCliente As Integer
+ Get
+ Return ViewState("IdCuentaCliente").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IdCuentaCliente") = value
+ End Set
+ End Property
+ Private ReadOnly Property IdCtaContMonedaExtranjera As Integer
+ Get
+ Return ViewState("IdCtaContMonedaExtranjera").ToString.ToEntero
+ End Get
+ End Property
+
+ Private ReadOnly Property IdCtaContComplementaria As Integer
+ Get
+ Return ViewState("IdCtaContComplementaria").ToString.ToEntero
+ End Get
+ End Property
+
+ Private ReadOnly Property IdCtaContRetIVA As Integer
+ Get
+ Return ViewState("IdCtaContRetIVA").ToString.ToEntero
+ End Get
+ End Property
+ Private ReadOnly Property IdCtaContRetISR As Integer
+ Get
+ Return ViewState("IdCtaContRetISR").ToString.ToEntero
+ End Get
+ End Property
+ Private Property IdCtaAnticipo As Integer
+ Get
+ Return ViewState("IdCtaAnticipo").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IdCtaAnticipo") = value
+ End Set
+ End Property
+ Private Property IdCtaContMonedaExtranjeraAnticipo As Integer
+ Get
+ Return ViewState("IdCtaContMonedaExtranjeraAnticipo").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IdCtaContMonedaExtranjeraAnticipo") = value
+ End Set
+ End Property
+ Private Property IdCtaContMonedaComplementariaAnticipo As Integer
+ Get
+ Return ViewState("IdCtaContMonedaComplementariaAnticipo").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IdCtaContMonedaComplementariaAnticipo") = value
+ End Set
+ End Property
+
+ Private Property Mail As String
+ Get
+ If ViewState("Mail") Is Nothing Then
+ Return ""
+ Else
+ Return ViewState("Mail").ToString
+ End If
+ End Get
+ Set(value As String)
+ ViewState("Mail") = value
+ End Set
+ End Property
+
+ Private Property CFDIRelacionadoSustitucion As String
+ Get
+ If ViewState("CFDIRelacionadoSustitucion") Is Nothing Then
+ Return "-1"
+ Else
+ Return ViewState("CFDIRelacionadoSustitucion").ToString
+ End If
+ End Get
+ Set(value As String)
+ ViewState("CFDIRelacionadoSustitucion") = value
+ End Set
+ End Property
+ Private Property FechaCorteIE As DateTime
+ Get
+ Return ViewState("FechaCorteIE").ToString.ToDateTime
+ End Get
+ Set(value As DateTime)
+ ViewState("FechaCorteIE") = value
+ End Set
+ End Property
+ Private Property IDPoliza As Integer
+ Get
+ Return ViewState("IDPoliza").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IDPoliza") = value
+ End Set
+ End Property
+ Private Property FolioIECancelado As String
+ Get
+ If ViewState("FolioIECancelado") Is Nothing Then
+ Return "-1"
+ Else
+ Return ViewState("FolioIECancelado").ToString
+ End If
+ End Get
+ Set(value As String)
+ ViewState("FolioIECancelado") = value
+ End Set
+ End Property
+ Private Property ComplementoSustitucionGenerado As Boolean
+ Get
+ Return CBool(ViewState("ComplementoSustitucionGenerado"))
+ End Get
+ Set(value As Boolean)
+ ViewState("ComplementoSustitucionGenerado") = value
+ End Set
+ End Property
+ Private Property Fecha As Date
+ Get
+ Return ViewState("Fecha").ToString.ToDate
+ End Get
+ Set(value As Date)
+ ViewState("Fecha") = value
+ End Set
+ End Property
+#End Region
+
+ Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
+ If Not Page.IsPostBack Then
+ CveMonedaPago = -1
+ If Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToString.ToEntero > 0 Then
+ ViewState("CveCliente") = Request("CveCliente").ToString.ToEntero
+ 'ViewState("CveUsuario") = IfNultl(Request("CveUsuario"), "-1").ToStrirowComisionesng.ToEntero
+ ViewState("CveMonedaFiltro") = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero
+ ViewState("CveMoneda") = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero
+ ViewState("FechaI") = IfNull(Request("FechaI"), "-1").ToString.ToEntero
+ ViewState("FechaE") = IfNull(Request("FechaE"), "-1").ToString.ToEntero
+ ViewState("CveSubProyecto") = IfNull(Request("CveSubProyecto"), "-1").ToString.ToEntero
+ ViewState("CveClienteSucursal") = IfNull(Request("CveClienteSucursal"), "-1").ToString.ToEntero
+
+ ViewState("IdCtaAnticipo") = 0
+ ViewState("IdCtaContMonedaExtranjeraAnticipo") = 0
+ ViewState("IdCtaContMonedaComplementariaAnticipo") = 0
+
+ DdlProveedorIntermediario.setEsWebService(True)
+ DdlProveedorIntermediario.Attributes.Add("data-metodo", "getproveedores")
+ DdlProveedorIntermediario.SelectedText = "Seleccione"
+ DdlProveedorIntermediario.SelectedValue = "-1"
+
+ FechaCorteIE = DateTime.Now
+
+ Dim dia As Integer = If(UsuarioActual.CveEmpresa = 13, Now.Day - 1, Now.Day)
+ Fecha = (dia.ToString + "/" + Now.Month.ToString + "/" + Now.Year.ToString).ToDate
+
+ If UsuarioActual.Empresa.Funcionalidad(712) = "1" Then
+ PorletIntermediario.Visible = True
+ End If
+
+ If CargaCliente(CveCliente, CveMonedaFiltro) Then
+
+ IdCuentaBancaria = 0
+
+ TxtOtrosImportes.Attributes.Add("onKeyUp", String.Format("FnSuma(this,{0},{1},-1);", "TxtTotal", 0))
+ 'TxtAnticipo.Attributes.Add("onKeyUp", String.Format("FnSuma(this,{0},{1},-1);", "null", 0))
+
+ If CveMoneda > 0 Then LbTipoMoneda.Text = String.Format("Pago en {0}", GlobalDTMonedas.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda)).Rows(0)("Moneda"))
+
+ If CveMoneda = 2 Then
+ ChkPagarPesos.Visible = True
+ TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ DivTCDolaresDolares.Visible = True
+ TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
+ ElseIf CveMoneda = 1 Then
+ ChkPagarDolares.Visible = True
+ TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ ElseIf CveMoneda = -1 Then
+ TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
+ TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ End If
+
+ If UsuarioActual.TienePermisoProceso(209) Or UsuarioActual.TienePermisoProceso(204) Then
+ HlSaldarCuentasIncobrables.Visible = True
+ End If
+
+ End If
+
+ If CveMonedaFiltro = -1 Then
+ ChkPagarPesos.Visible = False
+ ChkPagarDolares.Visible = False
+ End If
+
+ RegistraScript($"TipoCambioActual = {GlobalTipoCambio(Fecha).FormatoNumero(4)}")
+ End If
+
+ RVTxtFechaDocumento.MaximumValue = Now.ToString("dd/MM/yyyy")
+
+
+ If UsuarioActual.CveEmpresa.Contiene(13, 83, 158) Then
+ LnkAccionesModalSeleccionLayout.Visible = True
+
+ End If
+
+ End If
+
+ If (CveMonedaFiltro = 2 And ChkPagarPesos.Checked) Then
+ RegistraScript("document.getElementById('DivTC').style.display = 'block';")
+ End If
+
+ End Sub
+
+ Private Sub CargaTipoTransaccion()
+ DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Ing' AND Estatus = 1 ")
+ DdlTipoTransaccion.DataBind()
+ DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
+ RecargaCuentasDepositos()
+ End Sub
+
+ Private Sub CargaCuentas()
+ DdlCuenta.Items.Clear()
+ Dim CveTipoCuenta As Integer = 2
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then CveTipoCuenta = -1 'que se muestren todas, para empresa acumuladores
+
+ Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa, CveTipoCuenta:=CveTipoCuenta)
+
+ If ChkPagarPesos.Checked Then
+ dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1))
+ RegistraScript("CambiaPesosDolares();")
+ ElseIf ChkPagarDolares.Checked Then
+ dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 2))
+ RegistraScript("CambiaDolaresPesos();")
+ Else
+ If CveMonedaFiltro > 0 Then
+ dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMonedaFiltro))
+ End If
+ End If
+
+ DdlCuenta.DataSource = dt
+ DdlCuenta.DataBind()
+ DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1"))
+ End Sub
+
+ Private Function CargaCliente(tCveCliente As Integer, tCveMoneda As Integer) As Boolean
+ Dim Retorno As Boolean = False
+ Dim ObjCliente As New ClsClientes()
+ If ObjCliente.GetClientes(tCveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+ Retorno = True
+ CargaCuentas()
+ CargaTipoTransaccion()
+
+ TxtFechaDocumento.Text = Now.ToShortDateString.ToString
+
+ TxtAboneA.Enabled = False
+ LbEncabezado.Text = String.Format("{1}", CveCliente, ObjCliente.NombreComercial)
+ TxtAboneA.Text = ObjCliente.NombreComercial
+ NombreComercial = ObjCliente.NombreComercial
+ TxtImporte.Attributes.Add("disabled", "disabled")
+ If DdlTipoTransaccion.SelectedValue = "1" Then RFVFolio.Enabled = True Else RFVFolio.Enabled = False
+ ViewState("CtaCliente") = ObjCliente.IdCtaContClientes
+ ViewState("IdCuentaCliente") = ObjCliente.IdCtaContClientes
+ ViewState("IdCtaContMonedaExtranjera") = ObjCliente.IdCtaContMonedaExtranjera
+ ViewState("IdCtaContComplementaria") = ObjCliente.IdCtaContComplementaria
+ ViewState("IdCtaContRetIVA") = ObjCliente.IdCtaContRetIVA
+ ViewState("IdCtaContRetISR") = ObjCliente.IdCtaContRetISR
+
+ ViewState("IdCtaAnticipo") = ObjCliente.IdCtaContAnticipos
+ ViewState("IdCtaContMonedaExtranjeraAnticipo") = ObjCliente.IdCtaMonedaExtranjeraAnticipos
+ ViewState("IdCtaContMonedaComplementariaAnticipo") = ObjCliente.IdCtaContCompAnticipos
+
+ Mail = String.Format("{0};{1}", ObjCliente.CobranzaCorreo, ObjCliente.NotificarA)
+
+ If Request("FechaI") IsNot Nothing Then ViewState("FechaI") = Request("FechaI") Else ViewState("FechaI") = "-1"
+ If Request("FechaF") IsNot Nothing Then ViewState("FechaF") = Request("FechaF") Else ViewState("FechaF") = "-1"
+
+ If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
+
+ 'Dim CveClasificacionCol1 As Integer = 21514
+ 'Dim CveClasificacionCol2 As Integer = 21916
+ 'Dim CveClasificacionCol3 As Integer = 21520
+ 'Dim CveClasificacionCol4 As Integer = 21519
+ 'Dim CveClasificacionCol5 As Integer = 21547
+ 'Dim CveClasificacionCol6 As Integer = 21572
+ 'Dim CveClasificacionCol7 As Integer = 21571
+ divAnticipo.Visible = True
+ divPrestamo.Visible = True
+
+ GvCxC.Columns(17).HeaderText = "Comisión Venta" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol1).FiltroPrimeroValor("Clasificacion").Substring(0, 10)
+ GvCxC.Columns(18).HeaderText = "Gastos Manejo" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol2).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(19).HeaderText = "Servicio Inspección" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol3).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(20).HeaderText = "Seguro" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol4).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(21).HeaderText = "Aduana Mex" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol5).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(22).HeaderText = "Diversos" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol6).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(23).HeaderText = "Aduana USA" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol7).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(24).HeaderText = "Material Empaque" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol7).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(25).HeaderText = "Semilla" 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionCol7).FiltroPrimeroValor("Clasificacion").Substring(0, 12)
+ GvCxC.Columns(26).HeaderText = "Total Gastos"
+
+ DvLiquidacion1.Visible = True
+ DvLiquidacion2.Visible = True
+
+ DtIngresos = CargaIngresos(2)
+ DtPrestamos = CargaPrestamos(1)
+ End If
+
+ CargaDatos(tCveMoneda)
+ Else
+ Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
+ End If
+ End If
+ ObjCliente.Dispose()
+ Return Retorno
+ End Function
+
+ Private Sub CargaDatos(pCveMoneda As Integer)
+ Dim Mov As New ClsMovimientos
+ Dim FechaI As String = IfNull(Request("FechaI"), "-1")
+ Dim FechaF As String = IfNull(Request("FechaF"), "-1")
+
+ Dim FechaCorte As Date = DateTime.Now.AddYears(1).ToShortDateString.ToString.ToDate
+
+ Dim SumDescuentoProntoPago As Double = 0.0
+ If Mov.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, FechaI, FechaF, pCveMoneda, CveSubProyecto, UsuarioActual.CveEmpresa, CveClienteSucursal, FechaCorte:=FechaCorte) Then
+ Dim TmpCxCAux As DataTable
+ TmpCxCAux = Mov.DtResultados.FiltraParametros("Saldo > 0", "Fecha,SerieFolio")
+ SumDescuentoProntoPago = TmpCxCAux.SUM("DescuentoProntoPago")
+
+ GvCxC.DataSource = Mov.DtResultados.FiltraParametros("Saldo > 0", "Fecha,SerieFolio")
+ CveMoneda = pCveMoneda
+
+ End If
+ Mov.Dispose()
+ GvCxC.DataBind()
+
+ TxtImporte.Text = ""
+ TxtObservaciones.Text = ""
+ If SumDescuentoProntoPago > 0.0 Then
+ GvCxC.Columns(14).Visible = True 'MOSTRAR DESCUENTO PRONTO PAGO
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ GvCxC.Columns(15).Visible = True 'HABILITAR NC
+ End If
+ End If
+
+ UPVentas.Update()
+ End Sub
+
+ Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
+ 'recargo la moneda con la que se va a pagar
+ Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue)
+ Dim moneda As Integer = 0
+ If DdlCuenta.SelectedValue > 0 Then
+ moneda = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
+ End If
+
+ CveMonedaPago = moneda
+
+ If dr IsNot Nothing Then
+ If ChkPagarPesos.Checked Then
+ CveMoneda = 2
+ RegistraScript("document.getElementById('DivTC').style.display = 'block';")
+ RegistraScript("CambiaPesosDolares();")
+ TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda))
+ ElseIf ChkPagarPesos.Checked = False Then
+ CveMoneda = dr("CveMoneda").ToString.ToEntero
+ RegistraScript("document.getElementById('DivTC').style.display = 'none';")
+ RegistraScript("CambiaDolaresPesos();")
+ TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda))
+ End If
+
+ If ChkPagarDolares.Checked Then
+ CveMoneda = 1
+ TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda))
+ End If
+
+ IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero
+ IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero
+
+ ValidaCuentaDePagoFormaDePago()
+ End If
+
+ CargaDatos(CveMoneda)
+
+
+ ' si no tiene CveMoneda, o es -1, cuando cambia de cuenta filtra las facturas
+ If IfNull(Request("CveMoneda"), "-1").ToString.ToEntero = -1 Then
+ CargaDatos(-1)
+
+ moneda = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
+ If moneda = 1 Then
+ 'DivTC.Visible = True
+ DivTCDolares.Visible = False
+ TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", moneda))
+ ElseIf moneda = 2 Then
+ 'DivTC.Visible = False
+ RegistraScript("document.getElementById('DivTC').style.display = 'none';")
+ DivTCDolares.Visible = True
+ TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", moneda))
+ End If
+ End If
+
+ If HdnTipoTransaccion.Value = "Ing" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
+ If UsuarioActual.CveEmpresa = 119 Then
+ Dim ObjFolios As New ClsGralFolios
+ If ObjFolios.GetFolios("RMF", UsuarioActual.CveEmpresa) Then
+ Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo'"))
+ If DT.Rows.Count > 0 Then
+ TxtFolio.Text = DT.Rows(0)("FActual").ToString.ToEntero
+ End If
+ ObjFolios.Dispose()
+ End If
+ Else
+ Dim Folio As Long
+ Dim Banco As New ClsBancos
+ Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
+ Banco.Dispose()
+ TxtFolio.Text = Folio.ToString
+
+ End If
+
+ Else
+ TxtFolio.Text = ""
+
+ End If
+
+
+ End Sub
+
+ Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
+ Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
+ If dr IsNot Nothing Then
+ HdnTipoTransaccion.Value = dr("Tipo").ToString
+ End If
+ RecargaCuentasDepositos()
+ 'CargaCuentas()
+ ValidaCuentaDePagoFormaDePago()
+ End Sub
+
+ Protected Sub GvCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound
+
+ If e.Row.RowType = DataControlRowType.DataRow Then
+ Dim moneda As Integer = 0
+ If e.Row.RowIndex = 0 Then
+ e.Row.BackColor = Drawing.Color.LightGray
+ e.Row.FCDropDownList("DdlTG").Visible = False
+ e.Row.FCTextBox("TxtLiqCol1").Visible = False
+ e.Row.FCTextBox("TxtLiqCol2").Visible = False
+ e.Row.FCTextBox("TxtLiqCol3").Visible = False
+ e.Row.FCTextBox("TxtLiqCol4").Visible = False
+ e.Row.FCTextBox("TxtLiqCol5").Visible = False
+ e.Row.FCTextBox("TxtLiqCol6").Visible = False
+ e.Row.FCTextBox("TxtLiqCol7").Visible = False
+ e.Row.FCTextBox("TxtLiqCol8").Visible = False
+ e.Row.FCTextBox("TxtLiqCol9").Visible = False
+ e.Row.FCTextBox("TxtLiqColT").Visible = False
+ e.Row.FCTextBox("TxtAmort").Visible = False
+ e.Row.FCTextBox("TxtAmort2").Visible = False
+ e.Row.FCDropDownList("DdlAnti").Visible = False
+ e.Row.FCDropDownList("DdlAnti2").Visible = False
+
+ End If
+ If e.Row.RowIndex = 1 Then
+ e.Row.Cells(0).Width = Unit.Pixel(25)
+ e.Row.Cells(1).Width = Unit.Pixel(90)
+ e.Row.Cells(2).Width = Unit.Pixel(70)
+ e.Row.Cells(3).Width = Unit.Pixel(70)
+ e.Row.Cells(6).Width = Unit.Pixel(50)
+ e.Row.Cells(7).Width = Unit.Pixel(70)
+ e.Row.Cells(8).Width = Unit.Pixel(50)
+ 'e.Row.Cells(9).Width = Unit.Pixel(90)
+ 'e.Row.Cells(10).Width = Unit.Pixel(80)
+ 'e.Row.Cells(11).Width = Unit.Pixel(60)
+ End If
+
+ e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Right
+ e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Right
+
+ If e.Row.DBCampo("Saldo").ToDecimal < 0 Then e.Row.Cells(11).ForeColor = Drawing.Color.Red
+ If e.Row.DBCampo("DiasVencidos").ToDecimal > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(5).ForeColor = Drawing.Color.Red
+ If e.Row.DBCampo("Original").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = ""
+ If e.Row.DBCampo("Abonado").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = ""
+ If e.Row.DBCampo("Saldo").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = ""
+
+ Select Case RblTipoPago.SelectedValue
+ Case "1"
+ If DdlCuenta.SelectedValue > 0 Then
+ moneda = CveMonedaPago
+ ElseIf RblTipoPago.SelectedValue = "1" Then
+ e.Row.FCCheckBox("Chk").Enabled = False
+ e.Row.FCTextBox("TxtAbonar").Enabled = False
+ End If
+ Case "3"
+ moneda = CveMonedaPago
+
+ End Select
+
+ If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() > 0 Then
+ e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1},{5}); FnCambia({2},this,{1},0,{3},{4}); FnSeleccionaNC({5},{6},{0});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda, e.Row.FCCheckBox("Chk").ClientID, e.Row.FCCheckBox("ChkGenerarNC").ClientID, e.Row.DBCampo("CveVenta")))
+ Else
+ e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1},{5}); FnCambia({2},this,{1},0,{3},{4},{5});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda, e.Row.DBCampo("CveVenta")))
+ End If
+
+ If Not UsuarioActual.Empresa.Funcionalidad(536) = "1" Then
+ If e.Row.DBCampo("TipoDocto") = "Rem" Then
+ e.Row.FCCheckBox("Chk").Visible = False ' que no se pueda pagar si es remisión
+ e.Row.Cells(0).ToolTip = "El documento es remisión y no se puede realizar el pago"
+ End If
+ End If
+
+
+ If e.Row.DBCampo("CveVenta").ToEntero > 0 Then
+ e.Row.FCLiteral("LtlAux").Text = String.Format("Ir", e.Row.DBCampo("CveCliente").ToEntero, e.Row.DBCampo("CveVenta").ToEntero)
+ e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,{2},{3});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), CveMonedaFiltro, moneda))
+
+ If UsuarioActual.Empresa.Funcionalidad(157).ToDecimal <> 0 Then
+ e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnLimites({0},this,{1},{2},2);", e.Row.FCCheckBox("Chk").ClientID, -UsuarioActual.Empresa.Funcionalidad(157), UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal))
+ e.Row.FCRangeValidator("RVComision").MinimumValue = -UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal
+ e.Row.FCRangeValidator("RVComision").MaximumValue = UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal
+ e.Row.FCRangeValidator("RVComision").Enabled = True
+ Else
+ e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2,{2},{3});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), CveMonedaFiltro, moneda))
+ e.Row.FCRangeValidator("RVComision").MinimumValue = 0.00
+ e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Saldo")
+ End If
+
+ If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() > 0 AndAlso e.Row.DBCampo("DiasVencidos").ToEntero() <= 5 Then
+ e.Row.FCCheckBox("ChkGenerarNC").Visible = True
+ e.Row.FCCheckBox("ChkGenerarNC").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1},{5}); FnCambia({2},this,{1},0,{3},{4}); FnEditarImporte({2}, {0});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo").ToDecimal - e.Row.DBCampo("DescuentoProntoPago").ToDecimal, e.Row.FCCheckBox("ChkGenerarNC").ClientID, CveMonedaFiltro, moneda, e.Row.DBCampo("CveVenta")))
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then '' si es empresa agrícola
+
+ e.Row.FCDropDownList("DdlTG").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
+ e.Row.FCDropDownList("DdlTG").DataBind()
+
+ e.Row.FCTextBox("TxtLiqCol1").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol2").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol3").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol4").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol5").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol6").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol7").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol8").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtLiqCol9").Attributes.Add("class", $"ClsSelLiq ClsSelLiqVenta{e.Row.DBCampo("CveVenta")}")
+
+ e.Row.FCTextBox("TxtLiqColT").Attributes.Add("class", $"ClsSelLiqVentaTotal{e.Row.DBCampo("CveVenta")}")
+ e.Row.FCTextBox("TxtAmort").Attributes.Add("class", $"ClsSelLiqAnt")
+ e.Row.FCTextBox("TxtAmort2").Attributes.Add("class", $"ClsSelLiqAnt")
+
+ e.Row.FCTextBox("TxtLiqCol1").Attributes.Add("onkeyup", $"SumaLiq (this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol2").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol3").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol4").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol5").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol6").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol7").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol8").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtLiqCol9").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtAmort").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+ e.Row.FCTextBox("TxtAmort2").Attributes.Add("onkeyup", $"SumaLiq(this,{e.Row.DBCampo("CveVenta")},{CveMonedaFiltro},{ moneda})")
+
+ e.Row.FCDropDownList("DdlAnti").DataSource = DtIngresos
+ e.Row.FCDropDownList("DdlAnti").DataBind()
+ e.Row.FCDropDownList("DdlAnti").Items.Insert(0, New ListItem("-", "-1"))
+
+ e.Row.FCDropDownList("DdlAnti2").DataSource = DtIngresos
+ e.Row.FCDropDownList("DdlAnti2").DataBind()
+ e.Row.FCDropDownList("DdlAnti2").Items.Insert(0, New ListItem("-", "-1"))
+
+ End If
+
+ Else
+ e.Row.FCTextBox("TxtAbonar").Visible = False
+ e.Row.FCTextBox("TxtComision").Visible = False
+ e.Row.FCCheckBox("Chk").Visible = False
+ End If
+
+ If e.Row.DBCampo("CveVenta").ToEntero > 0 Then
+ If e.Row.DataKey("ClaveMetodoPagoSAT") = "PUE" Then
+ e.Row.FCLiteral("LtlComplemento").Text = ""
+ End If
+ Else
+ e.Row.FCLiteral("LtlComplemento").Visible = False
+ End If
+
+ End If
+ End Sub
+
+ Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
+
+ 'SI ES EMPRESA DE ACUMULADORES DEBE OBLIGAR A SUBIR UN ARCHIVO
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ Dim files = Anexo.getfiles()
+ If files IsNot Nothing Then
+ If files.Archivos IsNot Nothing Then
+ If files.Archivos.Count = 0 Then
+ Alert("Debe anexar un archivo", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ Else
+ Alert("Debe anexar un archivo", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ Else
+ Alert("Debe anexar un archivo", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ End If
+
+ If RblTipoPago.SelectedValue = "1" Then
+
+ Dim ValFechaDocumento As Boolean = False
+ Dim FoliosFechasValFechaDocumento As New StringBuilder
+ FoliosFechasValFechaDocumento.AppendLine("Se seleccionaron facturas con fecha de mes superior al mes del pago: ")
+
+ For Each gvRowVal As GridViewRow In GvCxC.Rows
+
+ If gvRowVal.FCCheckBox("Chk").Checked Then
+
+ Dim FechaFactura As Date = gvRowVal.DataKey("Fecha").ToDate
+ Dim FechaDocumento As Date = TxtFechaDocumento.Text.ToDate
+
+ Dim AnioFactura As Integer = FechaFactura.Year
+ Dim MesFactura As Integer = FechaFactura.Month
+
+ Dim AnioDocumento As Integer = FechaDocumento.Year
+ Dim MesDocumento As Integer = FechaDocumento.Month
+
+ If UsuarioActual.Empresa.UsaAC = False Then
+ If AnioFactura > AnioDocumento Then
+ FoliosFechasValFechaDocumento.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("Fecha").ToDate.ToString("dd/MM/yyyy") } ")
+ ValFechaDocumento = True
+ ElseIf AnioFactura = AnioDocumento And MesFactura > MesDocumento Then
+ FoliosFechasValFechaDocumento.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("Fecha").ToDate.ToString("dd/MM/yyyy") } ")
+ ValFechaDocumento = True
+ End If
+
+ End If
+ End If
+ Next
+
+ If ValFechaDocumento Then
+ Alert(FoliosFechasValFechaDocumento.ToString, TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ End If
+
+ If Not TxtImporte.Text.ToDecimal > 0 Then
+ Alert("Debe de llevar un Importe", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not (TxtFolio.Text.Trim <> "" Or RblTipoPago.SelectedValue = "2" Or RblTipoPago.SelectedValue = "3") Then
+ Alert("Debe de llevar un Folio", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If TxtPrestamoImporte.Text.ToDecimal <> 0 AndAlso DdlPrestamo.SelectedValue = "-1" Then
+ Alert("Debe seleccionar un préstamo al especificar un valor.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ 'valida que no exceda lo seleccionado. con el valor del ie
+ If (RblTipoPago.SelectedValue = "3" AndAlso HdnIngresoImporte.Value.ToDecimal < TxtTotal.Text.ToDecimal) Then
+ Alert("Importe excedido para la aplicación", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim Cuenta As String = ""
+ Dim CuentaDeposito As String = ""
+
+ Dim seleccion As Integer = 0
+ For Each gvr As GridViewRow In GvCxC.Rows
+ If gvr.FCCheckBox("Chk").Checked Then
+ seleccion += 1
+ 'si hay liquidación-
+ If gvr.FCDropDownList("DdlAnti").SelectedValue = "-1" AndAlso gvr.FCTextBox("TxtAmort").Text.ToDecimal <> 0 Then
+ Alert("Importe de anticipo especificado y no seleccionado. F: " & gvr.DataKey("SerieFolio"), TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ End If
+ Next
+
+ If seleccion = 0 Then
+ Alert("No ha seleccionado ninguna factura para abonar.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim CvePrePoliza As Integer = 0
+ Dim IDPoliza As Integer = 0
+ Dim FolioPoliza As String = ""
+ Dim CveIE As Integer = -1
+ Dim CveVentasPago As New List(Of Integer)
+ Dim SeriesPago As New List(Of String)
+
+ Dim MsgError As String = ""
+ Dim NCGeneradas As New List(Of RespuestaNotaCredrito)
+ Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura)
+
+ Dim ImporteSeleccionado As Decimal = 0
+
+ '02-05-2018 MANDAMOS CANCELAR EL COMPLEMENTO A SUSTITUIR
+ Dim ErrorCancelarIE As Boolean = False
+
+
+ Dim ObjIE As New ClsBancos()
+ Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
+ Dim ObjVentasSaldos As New ClsVentas(ObjIE.IniciaTransacSQL)
+ Dim ObjEvento As New ClsOIEventos(ObjIE.IniciaTransacSQL)
+ Dim ObjConta As ClsContPAQi = Nothing
+
+ Try
+ Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
+ Dim filemove As String = ""
+ Dim Comprobante As String = ""
+ ComplementoSustitucionGenerado = False
+
+ For Each fileItem As Archivo In filesgral
+ Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
+ filemove = fileItem.filename
+ Next
+
+ Dim ConceptoPoliza As String = String.Format("{0} {1}", TxtAboneA.Text, TxtObservaciones.Text)
+
+ If DdlCuenta.SelectedValue > 0 Then
+ CveMoneda = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
+ Else
+ CveMoneda = IfNull(Request("CveMoneda"), "1").ToString.ToEntero
+ End If
+
+ CvePrePoliza = ObjMov.AddPrePolizas("Ventas/ClientesAbonar", 11, TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal, 1, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+ If RblTipoPago.SelectedValue = "1" Then
+ Dim CveCuentaDeposito As Integer = 0
+ Dim TipoCambio As Decimal = 0
+
+ If DdlCuentaDeposito.Items.Count > 0 Then
+ CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero
+ End If
+
+ If CveMoneda = 2 Then
+ If TxtTCDolares.Visible Then
+ TipoCambio = TxtTCDolares.Text.ToDecimal
+ Else
+ TipoCambio = If(CveMonedaFiltro = -1, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal) 'GlobalTipoCambio(TxtFechaDocumento.Text).ToString.ToDecimal
+ End If
+ Else
+ If TxtTC.Visible Then
+ TipoCambio = TxtTC.Text.ToDecimal
+ End If
+ End If
+
+ Dim CveProvIntermediario As Integer
+ If ChkProveedorIntermediario.Checked Then
+ CveProvIntermediario = If(DdlProveedorIntermediario.SelectedValue.ToEntero <= 0, -1, DdlProveedorIntermediario.SelectedValue.ToEntero)
+ End If
+ CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtAboneA.Text.Trim, TxtImporte.Text.ToDecimal, GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TipoCambio, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito, CveProveedorIntermediario:=CveProvIntermediario)
+ Else
+ If RblTipoPago.SelectedValue.Contiene("3") Then 'ixc
+ CveIE = DdlIngreso.SelectedValue.ToEntero
+ If CveMonedaPago = 2 And Not ChkPagarPesos.Checked Then CveMoneda = 2
+ If ChkPagarDolares.Checked Then CveMoneda = 2
+ If ChkPagarPesos.Checked Then CveMoneda = 1
+ End If
+
+ End If
+
+ If CveIE > 0 OrElse RblTipoPago.SelectedValue.Contiene("2", "3") Then
+
+ 'Guardar archivo
+ If filemove <> "" Then
+ filemove.FilesMove(CveIE.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
+ End If
+
+ 'inserto los movimientos de la conta para abonar al saldo
+ If CvePrePoliza > 0 Then
+
+ Dim CvePlantillaPoliza As Integer = 11
+ Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:
"
+ Dim idCuentaContabilizacion As Long = 1
+ Dim CveCuentaContabilizacion As Long = 1
+ Dim dtConceptos As DataTable = Nothing
+ Dim tipoCambioPago As Decimal
+ Dim TipoCambioGeneral As Decimal = 1
+ Dim CveSubProyectoContabilizar As Integer = -1
+ Dim CveSubProyectoMaximo As Integer = -1
+ Dim CuentasContablesInvalidas As New StringBuilder
+ Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
+ Dim TipoCambioFluctuacion As Decimal = 1
+ Dim FechaUltimaFluctuacion As Date = MinFecha
+
+ Dim tFecha As Date = TxtFechaDocumento.Text.ToDate
+ Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha)
+
+ Dim ImportePrestamo As Decimal = 0
+ Dim TCPrestamo As Decimal = 0
+
+ If CveSubProyectoMaximo <= 0 Then 'sino se seleccionó del combo, busca en el listado el primero
+
+ For Each Gvr As GridViewRow In GvCxC.Rows
+ If Gvr.FCCheckBox("Chk").Checked Then
+ CveSubProyectoMaximo = Gvr.DataKey("CveSubProyecto").ToEntero
+ Exit For
+ End If
+ Next
+ End If
+
+ If TxtPrestamoImporte.Text.ToDecimal <> 0 Then 'amortización del préstamo
+ ImportePrestamo = TxtPrestamoImporte.Text.ToDecimal
+ Dim tCveProv As Integer = DtPrestamos.FiltroPrimeroValor("CveProveedor", "CveIE=" & DdlPrestamo.SelectedValue).ToEntero
+ Dim tFechaIE As Date = DtPrestamos.FiltroPrimeroValor("FechaDocumento", "CveIE=" & DdlPrestamo.SelectedValue).ToDate
+ TCPrestamo = DtPrestamos.FiltroPrimeroValor("TipoCambio", "CveIE=" & DdlPrestamo.SelectedValue).ToDecimal
+ If CveMoneda = 1 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImportePrestamo, ImportePrestamo, 57, TxtFolio.Text, TxtObservaciones.Text, 0, CveIE:=DdlPrestamo.SelectedValue.ToEntero, CveSubProyecto:=CveSubProyectoMaximo, TipoCambio:=tipoCambioPago, CveProveedor:=tCveProv) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ Else
+ If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
+ If tFechaIE <= UltimaFluctuacion.FechaFluctuacion Then
+ FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion
+ TCPrestamo = UltimaFluctuacion.TCFluctuacion
+ End If
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImportePrestamo, ImportePrestamo, 349, TxtFolio.Text, TxtObservaciones.Text, 0, CveIE:=DdlPrestamo.SelectedValue.ToEntero, CveSubProyecto:=CveSubProyectoMaximo, TipoCambio:=TCPrestamo, ImporteME:=ImportePrestamo, CveProveedor:=tCveProv) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImportePrestamo, ((ImportePrestamo * TCPrestamo) - ImportePrestamo).RoundSQL, 350, TxtFolio.Text, TxtObservaciones.Text, 0, CveIE:=DdlPrestamo.SelectedValue.ToEntero, CveSubProyecto:=CveSubProyectoMaximo, TipoCambio:=TCPrestamo, ImporteME:=ImportePrestamo, CveProveedor:=tCveProv) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+
+ End If
+
+ If TxtPrestamoIntereses.Text.ToDecimal <> 0 AndAlso MsgError = "" Then
+ tipoCambioPago = If(TxtTCDolares.Visible, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal)
+ Dim ImporteIntereses As Decimal = (TxtPrestamoIntereses.Text.ToDecimal * tipoCambioPago).RoundSQL
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteIntereses, ImporteIntereses, 51, TxtFolio.Text, TxtObservaciones.Text, 0, CveIE:=DdlPrestamo.SelectedValue.ToEntero, CveSubProyecto:=CveSubProyectoMaximo, TipoCambio:=tipoCambioPago, CveClasificacion:=21927) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+
+ 'inserto las ventas que voy a pagar
+ For Each gvr As GridViewRow In GvCxC.Rows
+
+ If gvr.FCCheckBox("Chk").Checked Then
+
+ Dim ObjFactura As Modelos.Factura = Nothing
+ Dim EsAnticipoEspecial As Boolean = False
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ ObjFactura = New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
+ End If
+
+ Dim VentaActual As New Venta(UsuarioActual)
+ VentaActual.CveVenta = gvr.DataKey("CveVenta").ToEntero
+ VentaActual.Fecha = gvr.DataKey("Fecha").ToDate
+ VentaActual.CveCliente = gvr.DataKey("CveCliente").ToEntero
+ VentaActual.CveMoneda = gvr.DataKey("CveMoneda").ToEntero
+ VentaActual.TipoDocto = gvr.DataKey("TipoDocto")
+ VentaActual.SerieFolio = gvr.DataKey("SerieFolio")
+ VentaActual.ClienteNombre = NombreComercial
+ VentaActual.TC = gvr.DataKey("TipoCambio").ToDecimal
+ VentaActual.Total = gvr.DataKey("Original").ToDecimal
+ VentaActual.IVA = gvr.DataKey("IVA").ToDecimal
+ VentaActual.IEPS = gvr.DataKey("IEPS").ToDecimal
+ VentaActual.RetIVA = gvr.DataKey("RetIVA").ToDecimal
+ VentaActual.RetISR = gvr.DataKey("RetISR").ToDecimal
+
+ VentaActual.PorcentajeIVA = gvr.DataKey("PorcentajeIVA").ToDecimal
+ VentaActual.CveSubProyecto = gvr.DataKey("CveSubProyecto").ToEntero
+ VentaActual.IdCtaContableCliente = IIf(VentaActual.CveMoneda = 1, IdCuentaCliente, IdCtaContMonedaExtranjera)
+ VentaActual.IdCtaContableClienteComplementaria = IdCtaContComplementaria
+ VentaActual.IdCtaContableClienteAnticipo = IdCtaAnticipo
+ 'Importe de pago
+ Dim Pago As New VentaPago
+ Pago.Fecha = TxtFechaDocumento.Text.ToDate
+ Pago.CveIE = CveIE
+ Pago.CveMonedaPago = CveMoneda
+ Pago.ImportePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
+ Pago.ImportePagoVenta = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
+ Pago.Referencia = TxtFolio.Text
+
+ If RblTipoPago.SelectedValue = "3" Then
+ Pago.TipoPago = "I"
+ Pago.FechaDocumentoRelacionado = FechaIngreso
+ End If
+
+ 'Tipos de cambio
+ If Pago.CveMonedaPago = 1 AndAlso VentaActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
+ Pago.TCPago = TxtTC.Text.ToDecimal
+ ElseIf Pago.CveMonedaPago = 2 AndAlso VentaActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
+ Pago.TCPago = IIf(TxtTCDolaresDolares.Visible, TxtTCDolaresDolares.Text.ToDecimal, TxtTCDolares.Text.ToDecimal)
+ ElseIf Pago.CveMonedaPago = 2 AndAlso VentaActual.CveMoneda = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ Pago.TCPago = TxtTCDolares.Text.ToDecimal
+ End If
+ tipoCambioPago = Pago.TCPago
+
+ If gvr.FCTextBox("TxtComision").Text.ToDecimal <> 0 Then Pago.OtroGastoIngreso = gvr.FCTextBox("TxtComision").Text.ToDecimal
+
+ 'If gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then
+ ' EsAnticipoEspecial = True
+ ' Pago.AplicaTraslado = False
+ ' Dim IdCtaContable As Integer = If(EsAnticipoEspecial, IdCtaAnticipo, IdCuentaCliente)
+ ' If VentaActual.CveMoneda = 2 Then IdCtaContable = If(EsAnticipoEspecial, IdCtaContMonedaExtranjeraAnticipo, IdCtaContMonedaExtranjera)
+
+ ' If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, Pago.ImportePago, 3, VentaActual.SerieFolio, VentaActual.SerieFolio, IdCtaContable, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyectoContabilizar, CveCliente:=ViewState("CveCliente").ToString.ToEntero, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, Contabilizable:=False) Then
+ ' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 95, VentaActual.SerieFolio, VentaActual.SerieFolio, IdCtaContable, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyectoContabilizar, CveCliente:=ViewState("CveCliente").ToString.ToEntero, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, Contabilizable:=False) Then
+ ' MsgError = "No se pudo insertar la póliza"
+ ' End If
+ ' Else
+ ' MsgError = "No se pudo insertar la póliza"
+ ' End If
+ 'End If
+
+ If UsuarioActual.Empresa.Funcionalidad(590) = "1" AndAlso MsgError = "" Then '' si es empresa agrícola
+ Dim FluctuacionAnticipo As Decimal = 0
+ Dim ImporteLiq1 As Decimal = gvr.FCTextBox("TxtLiqCol1").Text.ToDecimal
+ Dim ImporteLiq2 As Decimal = gvr.FCTextBox("TxtLiqCol2").Text.ToDecimal
+ Dim ImporteLiq3 As Decimal = gvr.FCTextBox("TxtLiqCol3").Text.ToDecimal
+ Dim ImporteLiq4 As Decimal = gvr.FCTextBox("TxtLiqCol4").Text.ToDecimal
+ Dim ImporteLiq5 As Decimal = gvr.FCTextBox("TxtLiqCol5").Text.ToDecimal
+ Dim ImporteLiq6 As Decimal = gvr.FCTextBox("TxtLiqCol6").Text.ToDecimal
+ Dim ImporteLiq7 As Decimal = gvr.FCTextBox("TxtLiqCol7").Text.ToDecimal
+ Dim ImporteLiq8 As Decimal = gvr.FCTextBox("TxtLiqCol8").Text.ToDecimal
+ Dim ImporteLiq9 As Decimal = gvr.FCTextBox("TxtLiqCol9").Text.ToDecimal
+
+ Dim CveClasificacionCol1 As Integer = 21514 'comisiones sobre venta
+ Dim CveClasificacionCol2 As Integer = 21916 ' manejo
+ Dim CveClasificacionCol3 As Integer = 21917 'servicios de inspección
+ Dim CveClasificacionCol4 As Integer = 21918 ' seguro liquidación
+ Dim CveClasificacionCol5 As Integer = 21561 ' gastos aduanales mex
+ Dim CveClasificacionCol6 As Integer = 21920 ' diveros
+ Dim CveClasificacionCol7 As Integer = 21919 'gastos aduanales usa
+ Dim CveClasificacionCol8 As Integer = 21211 'material Empaque
+ Dim CveClasificacionCol9 As Integer = 21207 'Semilla
+
+ Dim CveSubProyectoLiquidacion As Integer = gvr.DataKey("CveSubProyecto").ToEntero
+ Dim CveConceptoLiquidacion As Integer = 51
+ Dim ConceptoPartida As String = gvr.DataKey("SerieFolio") & " " & gvr.FCDropDownList("DdlTG").SelectedItem.Text
+
+ If ImporteLiq1 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq1, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq1 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol1, ImporteME:=If(CveMoneda > 1, ImporteLiq1, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq2 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq2, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq2 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol2, ImporteME:=If(CveMoneda > 1, ImporteLiq2, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq3 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq3, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq3 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol3, ImporteME:=If(CveMoneda > 1, ImporteLiq3, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq4 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq4, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq4 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol4, ImporteME:=If(CveMoneda > 1, ImporteLiq4, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq5 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq5, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq5 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol5, ImporteME:=If(CveMoneda > 1, ImporteLiq5, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq6 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq6, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq6 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol6, ImporteME:=If(CveMoneda > 1, ImporteLiq6, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq7 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq7, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq7 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol7, ImporteME:=If(CveMoneda > 1, ImporteLiq7, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq8 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq8, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq8 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol8, ImporteME:=If(CveMoneda > 1, ImporteLiq8, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If ImporteLiq9 <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteLiq9, gvr.DataKey("SerieFolio"), CveConceptoLiquidacion, ConceptoPartida, Now, -1, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyectoLiquidacion, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteLiq9 * tipoCambioPago, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=0, CveClasificacion:=CveClasificacionCol9, ImporteME:=If(CveMoneda > 1, ImporteLiq9, 0), CveTipoGasto:=gvr.FCDropDownList("DdlTG").SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza" : Exit For
+ End If
+ End If
+
+ If MsgError = "" AndAlso gvr.FCDropDownList("DdlAnti").SelectedValue.ToEntero > 0 Then
+ Dim TCP As Decimal = 0
+ Dim FolioPago As String = " "
+ If DtIngresos IsNot Nothing Then
+ TCP = DtIngresos.FiltroPrimeroValor("TipoCambio", String.Format("CveIE={0}", gvr.FCDropDownList("DdlAnti").SelectedValue))
+ FolioPago = DtIngresos.FiltroPrimeroValor("Folio", String.Format("CveIE={0}", gvr.FCDropDownList("DdlAnti2").SelectedValue))
+ Dim tTCPFecha As Date = DtIngresos.FiltroPrimeroValor("FechaDocumento", String.Format("CveIE={0}", gvr.FCDropDownList("DdlAnti").SelectedValue)).ToDate
+ 'considera fluctuación
+ If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
+ If tTCPFecha <= UltimaFluctuacion.FechaFluctuacion Then
+ tTCPFecha = UltimaFluctuacion.FechaFluctuacion
+ TCP = UltimaFluctuacion.TCFluctuacion
+ End If
+ End If
+ End If
+ 'se calcula la fluctuación de la aplicación del anticipo, para sumarla en el concepto de fluctuación más abajo
+ FluctuacionAnticipo = ((TCP - tipoCambioPago) * gvr.FCTextBox("TxtAmort").Text.ToDecimal).RoundSQL
+ MsgError = RegistraAmortizacionAnticipo(ObjMov, CvePrePoliza, gvr.FCDropDownList("DdlAnti").SelectedValue.ToEntero, gvr.FCTextBox("TxtAmort").Text.ToDecimal, TCP, gvr.DataKey("CveVenta").ToEntero, gvr.DataKey("SerieFolio").ToString, FolioPago)
+ End If
+
+ If MsgError = "" AndAlso gvr.FCDropDownList("DdlAnti2").SelectedValue.ToEntero > 0 Then
+ Dim TCP As Decimal = 0
+ Dim FolioPago As String = " "
+ If DtIngresos IsNot Nothing Then
+ TCP = DtIngresos.FiltroPrimeroValor("TipoCambio", String.Format("CveIE={0}", gvr.FCDropDownList("DdlAnti2").SelectedValue))
+ FolioPago = DtIngresos.FiltroPrimeroValor("Folio", String.Format("CveIE={0}", gvr.FCDropDownList("DdlAnti2").SelectedValue))
+ Dim tTCPFecha As Date = DtIngresos.FiltroPrimeroValor("FechaDocumento", String.Format("CveIE={0}", gvr.FCDropDownList("DdlAnti2").SelectedValue)).ToDate
+ 'considera fluctuación
+ If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
+ If tTCPFecha <= UltimaFluctuacion.FechaFluctuacion Then
+ tTCPFecha = UltimaFluctuacion.FechaFluctuacion
+ TCP = UltimaFluctuacion.TCFluctuacion
+ End If
+ End If
+
+ End If
+ 'se calcula la fluctuación de la aplicación del anticipo, para sumarla en el concepto de fluctuación más abajo
+ FluctuacionAnticipo += ((TCP - tipoCambioPago) * gvr.FCTextBox("TxtAmort2").Text.ToDecimal).RoundSQL
+ MsgError = RegistraAmortizacionAnticipo(ObjMov, CvePrePoliza, gvr.FCDropDownList("DdlAnti2").SelectedValue.ToEntero, gvr.FCTextBox("TxtAmort2").Text.ToDecimal, TCP, gvr.DataKey("CveVenta").ToEntero, gvr.DataKey("SerieFolio").ToString, FolioPago)
+ End If
+
+ If ImportePrestamo <> 0 Then
+ If TCPrestamo > 0 Then
+ FluctuacionAnticipo += ((TCPrestamo - tipoCambioPago) * ImportePrestamo).RoundSQL
+ ImportePrestamo = 0
+ End If
+ End If
+ Pago.ImporteFluctuacionAdicional = FluctuacionAnticipo
+ End If
+
+ If MsgError = "" AndAlso AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then
+ MsgError = "No se pudo insertar la póliza"
+ Exit For
+ End If
+
+ ' Case 134 'Pago Intermediario
+ If RblTipoPago.SelectedValue = "2" Then
+ Dim ImporteMovimiento As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - gvr.FCTextBox("TxtComision").Text.ToDecimal
+ Dim ImporteMN As Decimal = (ImporteMovimiento * tipoCambioPago).RoundSQL
+ Dim IdCtaContable As Integer = 0
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 134, VentaActual.SerieFolio, VentaActual.SerieFolio, VentaActual.IdCtaContableCliente, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyectoContabilizar, CveProveedor:=DdlProveedorPagoInt.SelectedValue.ToEntero) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+
+ 'PARA EMITIR COMPLEMENTO PAGO
+ CveVentasPago.Add(gvr.DataKey("CveVenta").ToEntero)
+ SeriesPago.Add(gvr.DataKey("SerieFolio"))
+
+
+ If gvr.FCCheckBox("ChkGenerarNC").Checked AndAlso ObjFactura IsNot Nothing Then
+ ObjFactura.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()
+ ListaFacturasGenerarNC.Add(ObjFactura)
+ End If
+
+ End If
+ Next
+
+ If RblTipoPago.SelectedValue = "1" AndAlso MsgError = "" Then
+
+ CveSubProyectoContabilizar = CveSubProyectoMaximo
+
+ If CveMoneda = 2 Then
+ 'If IdCuentaBancariaComplementaria > 0 Then
+ If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=TxtImporte.Text.Trim.ToDecimal, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), TxtObservaciones.Text, 204, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancariaComplementaria, -1, CveIE, -1, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, (TxtImporte.Text.Trim.ToDecimal * tipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal, 0), TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ Else
+ If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(590) = "1" AndAlso MsgError = "" Then '' si es empresa agrícola
+ If TxtAnticipo.Text.ToDecimal <> 0 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtAnticipo.Text.ToDecimal, TxtFolio.Text, 66, TxtObservaciones.Text, Now, -1, -1, CveIE, -1, -1, CveSubProyecto, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=TxtAnticipo.Text.ToDecimal, TipoCambio:=tipoCambioPago, PorcentajeImpuesto:=0, ImporteME:=If(CveMoneda > 1, TxtAnticipo.Text.ToDecimal, 0)) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ If CveMoneda > 1 Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtAnticipo.Text.ToDecimal, TxtFolio.Text, 226, TxtObservaciones.Text, Now, -1, -1, CveIE, -1, -1, CveSubProyecto, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=((TxtAnticipo.Text.ToDecimal * tipoCambioPago) - TxtAnticipo.Text.ToDecimal).RoundSQL, TipoCambio:=tipoCambioPago, PorcentajeImpuesto:=0, ImporteME:=If(CveMoneda > 1, TxtAnticipo.Text.ToDecimal, 0)) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+
+ End If
+
+ End If
+
+ If MsgError = "" AndAlso UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
+ If Not ObjMov.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
+ MsgError = "No se pudo simplificar los movimientos"
+ Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError)
+ End If
+ End If
+
+ If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 3) Then
+ If ObjMov.ValorPolizaDescuadre > 0 Then
+ MsgError = ObjMov.MensajePolizaDescuadre & " La diferencia es de: " & ObjMov.ValorDiferencia
+ End If
+ End If
+
+ 'Conta ContPAQ
+ If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
+ If idCuentaContabilizacion > 0 Then
+ If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
+ IDPoliza = ObjMov.ContaIdPoliza
+ FolioPoliza = ObjMov.ContaFolio
+ Else
+ Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico")
+ MsgError = "Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico"
+ End If
+ Else
+ Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidas))
+ End If
+ End If
+ Else
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ Else
+ MsgError = "No se insertó el encabezado"
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso MsgError = "" Then
+ If MsgError = "" Then
+ If ListaFacturasGenerarNC.Count > 0 Then
+
+ For Each Fac As Modelos.Factura In ListaFacturasGenerarNC
+ Dim ListaNC As New List(Of Modelos.Factura)
+ ListaNC.Add(Fac)
+ Dim Resp = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaNC)
+
+ If Resp IsNot Nothing AndAlso Resp.Respuesta IsNot Nothing AndAlso Resp.Respuesta.CveVenta > 0 Then
+ NCGeneradas.Add(Resp)
+ Else
+ MsgError = "No se pudo generar la nota de crédito"
+ Exit For
+ End If
+ Next
+
+ If MsgError = "" Then
+ If NCGeneradas.Count <> ListaFacturasGenerarNC.Count Then
+ MsgError = "No se generaron las notas de crédito seleccionadas"
+ End If
+ End If
+
+ End If
+ End If
+ End If
+
+ Dim ErrorAC As Boolean = False
+
+ If MsgError = "" Then
+ If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
+ Dim Fecha As Date = TxtFechaDocumento.Text.Trim.ToDate
+ ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
+ ObjConta.IniciaTransacSQL()
+ Dim Facturas As New StringBuilder
+
+ IDPoliza = ObjConta.AddPoliza(1, String.Format("Recaudado: {0}, {1}", TxtAboneA.Text, TxtObservaciones.Text), TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal, UsuarioActual.CveUsuario, Fecha)
+ FolioPoliza = ObjConta.Folio.ToString
+
+
+ Dim ConceptoRenglon As String
+ If IDPoliza > 0 Then
+ Dim PorcentajePago As Double = 1
+ Dim Total As Double
+ Dim ObjVentas As New ClsVentas
+ Dim ImporteOP = 0.0
+ Dim IdCuentaOP = -1
+
+ For Each gvr As GridViewRow In GvCxC.Rows
+ If gvr.FCCheckBox("Chk").Checked Then
+ If gvr.DataKey("Original").ToDecimal > 0 Then PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal Else PorcentajePago = 1
+
+ If ObjVentas.GetPresupuestosVentas(gvr.DataKey("CveVenta").ToEntero) Then
+ For Each drt As DataRow In ObjVentas.DtResultados.Rows
+ Total = drt("TotalPresupuesto").ToString.ToDecimal * PorcentajePago
+ ConceptoRenglon = String.Format("{0} {1}", gvr.DataKey("SerieFolio"), drt("FuenteRecaudacionRubroIngreso").ToString)
+ If Total > 0 Then
+ If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaDevengado").ToString.ToEntero, False, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For : Exit For
+
+ If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaRecaudado").ToString.ToEntero, True, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For : Exit For
+ End If
+
+ Next
+ If ErrorAC Then Exit For
+
+ Facturas.AppendFormat(" {0}", gvr.DataKey("SerieFolio"))
+ End If
+
+ End If
+ Next
+ ObjVentas.Dispose()
+
+ 'AFECTAR MATRIZ EGRESOS
+ ConceptoRenglon = String.Format("Recaudado: {0} - F.{1}", TxtAboneA.Text, Facturas.ToString)
+ If ObjConta.AddMovimiento(IDPoliza, IdCuentaBancaria, False, TxtImporte.Text.ToDecimal, "", ConceptoRenglon, 0, Fecha, "") Then
+ If TxtImporte.Text.ToDecimal - ImporteOP > 0 Then
+ If Not ObjConta.AddMovimiento(IDPoliza, ViewState("CtaCliente").ToString.ToEntero, True, TxtImporte.Text.ToDecimal - ImporteOP, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True
+ End If
+ Else
+ ErrorAC = True
+ End If
+
+ Else
+ ErrorAC = True
+ End If
+
+ If Not ErrorAC Then
+ ErrorAC = Not ObjConta.AjustaPoliza(IDPoliza)
+ End If
+
+ If Not ErrorAC Then
+ ErrorAC = Not ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0)
+ End If
+
+ End If
+ End If
+
+ If ErrorAC Then
+ MsgError = "Error al Agregar la Póliza de Armonización Contable"
+ End If
+
+ Catch ex As Exception
+ MsgError = "Ocurrió un error al guardar el movimiento"
+ OnError("Ocurrió un error al guardar el movimiento", ex)
+ End Try
+
+ If MsgError = "" Then
+ ObjIE.Commit()
+ If ObjConta IsNot Nothing Then ObjConta.Commit()
+
+ Dim StrMsg As New StringBuilder
+ StrMsg.AppendFormat("Abono Registrado Correctamente. Folio {1} ", CveIE, ObjIE.Folio)
+
+ If IDPoliza > 0 Then StrMsg.AppendFormat("Poliza: {1} ", IDPoliza, FolioPoliza)
+
+ Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
+
+ For Each RespuestaNotaCredito In NCGeneradas
+ If RespuestaNotaCredito IsNot Nothing AndAlso RespuestaNotaCredito.Respuesta IsNot Nothing Then
+ Try
+ Dim ObjTimbradoNC As New Timbrado
+ Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, RespuestaNotaCredito.ObjFacturaNC)
+ If Not TimbroNC Then
+ Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError)
+ End If
+ ObjTimbradoNC = Nothing
+ Catch ex As Exception
+ OnError("Ocurrió un error al timbrar la NC.", ex)
+ End Try
+ StrMsg.AppendFormat("Nota de crédito generada correctamente.
Folio: {1} ", RespuestaNotaCredito.Respuesta.CveVenta, RespuestaNotaCredito.Respuesta.SerieFolio)
+ End If
+ Next
+ Alert($"{StrMsg.ToString}
{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
+
+ Else
+ If ObjConta IsNot Nothing Then ObjConta.RollBack()
+ ObjIE.RollBack()
+ Alert(MsgError, TipoMensaje.MsgAdvertencia)
+ End If
+
+ ObjIE.Dispose()
+ ObjVentasSaldos.Dispose()
+ ObjMov.Dispose()
+ If ObjConta IsNot Nothing Then ObjConta.Dispose()
+ ObjEvento.Dispose()
+
+ UPVentas.Update()
+
+ If MsgError = "" Then
+ LimpiaCampos()
+ End If
+
+ End Sub
+
+ Private Function RegistraAmortizacionAnticipo(ByRef ObjMov As ClsContabilidad, CvePrePoliza As Integer, CveIE As Integer, Importe As Decimal, tipoCambioPago As Decimal, CveVenta As Integer, ReferenciaVenta As String, ReferenciaPago As String) As String
+ Dim MsgError As String = ""
+ If CveMonedaPago = 2 Then
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, Importe, ReferenciaVenta, 92, ReferenciaVenta, TxtFechaDocumento.Text, IdCtaContMonedaExtranjeraAnticipo, -1, CveIE, CveCliente:=CveCliente, ImporteMX:=Importe, CveVenta:=CveVenta, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, If(CveMoneda = 1 AndAlso TxtTC.Visible, Importe / TxtTC.Text.ToDecimal, Importe), ReferenciaVenta, 227, TxtObservaciones.Text + If(TxtTC.Visible, $" TC:{TxtTC.Text}", If(CveMoneda = 2, $" TC:{tipoCambioPago}", "")), TxtFechaDocumento.Text, IdCtaContMonedaComplementariaAnticipo, -1, CveIE, CveCliente:=ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, (Importe * tipoCambioPago) - Importe, Importe), ImporteME:=If(CveMoneda = 2, Importe, 0), CveVenta:=CveVenta, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ Else
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, Importe, ReferenciaVenta, 92, ReferenciaVenta, TxtFechaDocumento.Text, IdCtaAnticipo, -1, CveIE, CveCliente:=ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, Importe * tipoCambioPago, Importe), ImporteME:=If(CveMoneda = 2, Importe, 0), CveVenta:=CveVenta, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+
+ Return MsgError
+
+ End Function
+
+#Region " N O T A - D E - C R E D I T O"
+ Private Class RespuestaNotaCredrito
+ Public Property ObjFacturaNC As Modelos.Factura
+ Public Property Respuesta As Modelos.Factura.MMensajeFactura
+ End Class
+
+ Private Function GenerarNC(SqlTransaccion As SqlClient.SqlTransaction, ObjConta As ClsContPAQi, ListaVentasGenerarNC As List(Of Modelos.Factura)) As RespuestaNotaCredrito
+ Dim Retorno As New RespuestaNotaCredrito()
+ Try
+
+ Dim ObjFacturaDevolucion = New Modelos.Factura(UsuarioActual)
+ ObjFacturaDevolucion.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.HTML
+ ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario
+ ObjFacturaDevolucion.UsuarioCreo = UsuarioActual.Usuario
+
+ Dim CveSubProyecto As Integer = Me.CveSubProyecto
+ Dim CveMoneda As Integer = Me.CveMoneda
+ Dim CveCliente As Integer = Me.CveCliente
+
+ If CveSubProyecto <= 0 Then
+ CveSubProyecto = ListaVentasGenerarNC(0).CveSubProyecto
+ End If
+
+ If CveMoneda <= 0 Then
+ CveMoneda = ListaVentasGenerarNC(0).CveMoneda
+ End If
+
+ If CveCliente <= 0 Then
+ CveCliente = ListaVentasGenerarNC(0).CveCliente
+ End If
+
+ Dim Folio As Integer = -1
+ Dim Serie As String = "-1"
+
+ ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa
+ ObjFacturaDevolucion.TipoCambio = If(Me.CveMoneda = 1, 1, GlobalTipoCambio(Now).FormatoNumero(4).ToDecimal())
+ ObjFacturaDevolucion.ConvertirPesos = False
+ ObjFacturaDevolucion.CveMoneda = CveMoneda
+ ObjFacturaDevolucion.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda}")
+ ObjFacturaDevolucion.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {CveMoneda}")
+ ObjFacturaDevolucion.Serie = Serie
+ ObjFacturaDevolucion.Folio = Folio
+ ObjFacturaDevolucion.Fecha = Now
+ ObjFacturaDevolucion.CvePrePoliza = -1
+ ObjFacturaDevolucion.CveMetodoPago = 0
+ ObjFacturaDevolucion.CondicionesPago = 0 ' 0 - Contado, 1 - Credito (CHECAR)
+ ObjFacturaDevolucion.FormaPago = 0
+
+ ObjFacturaDevolucion.TipoDocto = "Egs"
+ ObjFacturaDevolucion.Fecha = Now
+
+ If UsuarioActual.Empresa.Funcionalidad(350) = "1" Then
+ ObjFacturaDevolucion.Version = "4.0"
+ Else
+ ObjFacturaDevolucion.Version = "3.3"
+ End If
+
+ ObjFacturaDevolucion.CveMetodoPago33 = 1
+ ObjFacturaDevolucion.MetodoPago33 = "PUE - Pago en una sola exhibición"
+ ObjFacturaDevolucion.ClaveMetodoPagoSAT = "PUE"
+
+ Dim drtt As DataRow = GlobalDTTipoTransacciones.FiltroPrimero("CveTipoTransaccion =" & DdlTipoTransaccion.SelectedValue)
+ Dim dra As DataRow = GlobalDTVtaFormaPago.FiltroPrimero("CveFormaPago = " & drtt("CveFormaPago"))
+
+ ObjFacturaDevolucion.CveFormaPago33 = dra("CveFormaPago").ToString
+ ObjFacturaDevolucion.FormaPago33 = dra("FormaPagoSAT").ToString
+ ObjFacturaDevolucion.FormaPagoSAT33 = dra("ClaveFormaPagoSAT").ToString
+
+ ObjFacturaDevolucion.CveSubProyecto = CveSubProyecto
+ ObjFacturaDevolucion.SetSubProyecto()
+
+ ObjFacturaDevolucion.CveCliente = CveCliente
+ ObjFacturaDevolucion.SetCliente()
+
+ Dim ObjCliente As New ClsClientes
+ If ObjCliente.GetClientes(ObjFacturaDevolucion.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+
+ ObjFacturaDevolucion.CveUsoCFDI = 2
+ ObjFacturaDevolucion.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", 2))
+ ObjFacturaDevolucion.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", 2))
+
+ ObjFacturaDevolucion.DtDetalle = CreaDTDetalleNC()
+
+ CargaImpuestos(ObjFacturaDevolucion, ListaVentasGenerarNC, ObjCliente.DesglosaIEPS, ObjCliente.RetIVA, ObjCliente.RetISR)
+
+ End If
+ End If
+
+ If ObjCliente.GetSucursales(CveCliente) Then
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+ ObjFacturaDevolucion.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero())
+ Else
+ ObjFacturaDevolucion.CveClienteSucursal = -1
+ End If
+ End If
+ ObjCliente.Dispose()
+
+ ObjFacturaDevolucion.CveTipoRelacion = 1
+ ObjFacturaDevolucion.TipoRelacion = "01"
+ ObjFacturaDevolucion.DtVentasRelacionadas = New DataTable
+ ObjFacturaDevolucion.DtVentasRelacionadas.Columns.Add("CveVenta", GetType(Integer))
+
+ Dim Fol As New List(Of String)
+ For Each Fac In ListaVentasGenerarNC
+ Fol.Add(Fac.FolioFiscal)
+
+ Dim RowVenta As DataRow = ObjFacturaDevolucion.DtVentasRelacionadas.NewRow
+ RowVenta("CveVenta") = Fac.CveVenta
+
+ ObjFacturaDevolucion.DtVentasRelacionadas.Rows.Add(RowVenta)
+ Next
+
+ ObjFacturaDevolucion.UUIDRelacionados = Fol
+
+ Select Case ObjFacturaDevolucion.TipoDocto
+ Case "Ing"
+ ObjFacturaDevolucion.TipoDocumento = "Factura"
+ Case "REM"
+ ObjFacturaDevolucion.TipoDocumento = "Remision"
+ Case "Cot"
+ ObjFacturaDevolucion.TipoDocumento = "Cotizacion"
+ Case "Egs"
+ ObjFacturaDevolucion.TipoDocumento = "Nota de Crédito"
+ Case "Dev"
+ ObjFacturaDevolucion.TipoDocumento = "Nota de Devolución"
+ Case Else
+ ObjFacturaDevolucion.TipoDocumento = ""
+ End Select
+
+ ObjFacturaDevolucion.FechaPago = Now
+
+ ObjFacturaDevolucion.CveCorte = -1
+ 'ObjFacturaDevolucion.CveMesa = -1
+ ObjFacturaDevolucion.NumeroPersonas = 0
+ ObjFacturaDevolucion.CveContrato = -1
+ ObjFacturaDevolucion.DescripcionContrato = ""
+ ObjFacturaDevolucion.CveClienteSucursal = -1
+ ObjFacturaDevolucion.Entrega = ""
+ ObjFacturaDevolucion.CveAlmacen = -1
+
+ Dim DtVentasNC = InicializaDTVentasNC()
+
+ Dim TotalImporte As Decimal = ObjFacturaDevolucion.DtDetalle.SUMD("TotalImporte")
+ Dim ImporteIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUMD("ImporteIVA")
+ Dim ImporteRetIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUMD("ImporteRetIVA")
+ Dim ImporteRetISR As Decimal = ObjFacturaDevolucion.DtDetalle.SUMD("ImporteRetISR")
+ Dim ImporteIEPS As Decimal = ObjFacturaDevolucion.DtDetalle.SUMD("ImporteIEPS")
+ Dim Descuento As Decimal = ObjFacturaDevolucion.DtDetalle.SUMD("Descuento")
+ Dim Amortizacion As Decimal = 0
+
+ Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
+
+ 'DETALLES
+ ObjFacturaDevolucion.SubTotal = TotalImporte
+ ObjFacturaDevolucion.Descuento = Descuento
+ ObjFacturaDevolucion.Amortizacion = Amortizacion
+ ObjFacturaDevolucion.IVA = ImporteIVA
+ ObjFacturaDevolucion.RetIVA = ImporteRetIVA
+ ObjFacturaDevolucion.RetISR = ImporteRetISR
+ ObjFacturaDevolucion.IEPS = ImporteIEPS
+ ObjFacturaDevolucion.Total = Total
+ ObjFacturaDevolucion.TotalOtrosConceptos = 0
+
+ For Each Fac In ListaVentasGenerarNC
+ Dim Drt = DtVentasNC.NewRow
+ Drt("CveVenta") = Fac.CveVenta
+ Drt("Importe") = Fac.DescuentoProntoPago
+ Drt("FolioFiscal") = Fac.FolioFiscal
+ DtVentasNC.Rows.Add(Drt)
+ Next
+
+ DtVentasNC.AcceptChanges()
+
+ ObjFacturaDevolucion.DtVentasNC = DtVentasNC
+
+ ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion, ListaVentasGenerarNC)
+
+ Try
+ Dim Resp = ObjFacturaDevolucion.EmitirFactura(False, Transac:=SqlTransaccion, ObjContPaqTransac:=ObjConta)
+ Retorno.Respuesta = Resp
+ Catch ex As Exception
+ OnError("Ocurrió un error al guardar la NC de pronto pago", ex)
+ Retorno.Respuesta = Nothing
+ End Try
+ Retorno.ObjFacturaNC = ObjFacturaDevolucion
+
+ Catch ex As Exception
+ OnError("Ocurrió un error al generar la NC de pronto pago", ex)
+ Retorno = Nothing
+ End Try
+
+ Return Retorno
+
+ End Function
+
+ Private Function PreParaTimbre(Obj As Modelos.Factura, ListaVentasGenerarNC As List(Of Modelos.Factura)) As CFDITimbre
+ Dim Timbre As New CFDITimbre
+ Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
+ Timbre.Comprobante.Folio = Obj.Folio.ToString()
+ Timbre.Comprobante.Serie = Obj.Serie
+ Timbre.Comprobante.Fecha = Obj.FechaCP
+ Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
+ Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
+ Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
+ Timbre.Comprobante.SubTotal = Obj.SubTotal
+ Timbre.Comprobante.Descuentos = Obj.Descuento
+ Timbre.Comprobante.Moneda = Obj.MonedaSAT
+ Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString())
+ Timbre.Comprobante.Total = Obj.Total
+
+ Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
+ If Timbre.Comprobante.LugarExpedicion = "" Then
+ Dim aa As String = "no se guardo lugar de expedicion"
+ aa.GuardaLog()
+ End If
+
+ Timbre.Comprobante.Confirmacion = ""
+
+ If Obj.FacturarSucursal Then
+ Timbre.Receptor.RFC = Obj.ClienteSucursal.RFC
+ Timbre.Receptor.Nombre = Obj.ClienteSucursal.Nombre
+ Timbre.Receptor.DomicilioFiscalReceptor = Obj.ClienteSucursal.CP
+ Else
+ Timbre.Receptor.RFC = Obj.Cliente.RFC
+ If UsuarioActual.Empresa.Funcionalidad(350) = "1" Then
+ Timbre.Receptor.Nombre = Obj.Cliente.Nombre
+ Else
+ Timbre.Receptor.Nombre = Obj.Cliente.Nombre + " " + Obj.Cliente.RegimenSociedad
+ End If
+ Timbre.Receptor.DomicilioFiscalReceptor = Obj.Cliente.CP
+ End If
+
+ Timbre.Receptor.RegimenFiscalReceptor = Obj.Cliente.CodigoRegimenFiscal
+
+ Timbre.Receptor.ResidenciaFiscal = ""
+ Timbre.Receptor.NumeroRegistroTributario = ""
+ Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI
+
+ If ListaVentasGenerarNC IsNot Nothing Then
+ Timbre.CFDIRelacionados.UUID.Clear()
+
+ Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {Obj.CveTipoRelacion}")
+
+ Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString()
+ Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString()
+
+ For Each Fac In ListaVentasGenerarNC
+ Timbre.CFDIRelacionados.UUID.Add(Fac.FolioFiscal)
+ Next
+ End If
+
+ Dim totSubTotal As Decimal = If(UsuarioActual.Empresa.CvePAC = 3, Obj.DtDetalle.SUMD("Total"), Obj.SubTotal) 'Obj.SubTotal
+ Dim totIVA As Decimal = Obj.IVA
+ Dim totRetIVA As Decimal = Obj.RetIVA
+ Dim totRetISR As Decimal = Obj.RetISR
+
+ Dim i As Integer = 1
+
+ 'detalles
+ Dim tPS As String = ""
+
+ For Each drr As DataRow In Obj.DtDetalle.Rows
+ If drr("PS").ToString().Length = 1 Then
+ tPS = drr("Obs").ToString()
+ Else
+ If drr("PS").ToString().Length = 0 Then
+ tPS = ""
+ Else
+ tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
+ End If
+ End If
+
+ tPS = tPS.Replace("|", " ")
+
+ If tPS.Length >= 1000 Then
+ Dim tPSRecortado = tPS.Remove(999, tPS.Length - 999)
+ tPS = tPSRecortado
+ End If
+
+ 'condicionante, especial
+ If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" ' les comentan que no debe de ir la etiqueta de "unidad" en el producto
+
+ Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString().ToDecimal,
+ .Descripcion = tPS,
+ .ValorUnitario = drr("PU").ToString().ToDecimal,
+ .Importe = If(UsuarioActual.Empresa.CvePAC = 3, drr("Total").ToString().ToDecimal.RoundSQL(2), drr("TotalImporte").ToString().ToDecimal),
+ .Descuento = drr("Descuento").ToString().ToDecimal.RoundSQL(2),
+ .Unidad = drr("UM").ToString(),
+ .ClaveUnidad = drr("SATClaveUM").ToString(),
+ .ClaveProdServ = drr("SATClaveProdServ").ToString(),
+ .Noidentificacion = drr("Noidentificacion").ToString(),
+ .CuentaPredial = drr("CuentaPredial").ToString(),
+ .ImporteGravaIVAAdicional = drr("ImporteIEPS").ToString().ToDecimal,
+ .ObjetoImpuesto = drr("CodigoObjetoImpuesto").ToString()}
+ 'verifica suma subtotales
+ If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal.RoundSQL(2) <> concepto.Importe.RoundSQL(2) AndAlso Math.Abs(totSubTotal.RoundSQL(2) - concepto.Importe.RoundSQL(2)) <= 0.01 Then 'proceso de ajusta de decimales
+ concepto.Importe = totSubTotal
+ End If
+ totSubTotal = totSubTotal - concepto.Importe
+
+ 'siempre estaremos agregando el iva, auqnue sea en importe cero o tasa cero, para que se emita la factura
+ ' If drr("ImporteIVA").ToString().ToDouble > 0 Then
+
+ 'si es ingreso amortizado por la totalidad, y arroja el valor total de cero, no debe de impuestos, y si la BASE de calculo es mayor a cero
+ If Timbre.Comprobante.Total > 0 AndAlso concepto.Importe - concepto.Descuento + concepto.ImporteGravaIVAAdicional > 0 Then
+ concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = (concepto.Importe - concepto.Descuento + concepto.ImporteGravaIVAAdicional).RoundSQL(6), .TasaOCuota = drr("PorcentajeIVA").ToString().ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString().ToDecimal})
+ End If
+
+ If drr("ImporteIEPS").ToString().ToDouble > 0 Then
+ concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = (concepto.Importe - concepto.Descuento).RoundSQL(6), .TasaOCuota = drr("PorcentajeIEPS").ToString().ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString().ToDecimal})
+ End If
+
+ If drr("ImporteRetIVA").ToString().ToDouble > 0 Then 'si hay retenciones
+ concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = (concepto.Importe - concepto.Descuento).RoundSQL(6), .TasaOCuota = drr("PorcentajeRetIVA").ToString().ToDecimal, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString().ToDecimal})
+ End If
+
+ If drr("ImporteRetISR").ToString().ToDouble > 0 Then 'retención de ISR
+ concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = (concepto.Importe - concepto.Descuento).RoundSQL(6), .TasaOCuota = drr("PorcentajeRetISR").ToString().ToDecimal, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString().ToDecimal})
+ End If
+
+ Timbre.Conceptos.Add(concepto)
+ i += 1
+ Next
+
+ Return Timbre
+ End Function
+
+
+ Private Sub AgregaTempDTNC(ByRef TmpDT As DataTable, CvePS As Integer, PS As String, Codigo As String, CodigoPS As String, CveTipoPS As Integer, CveTipoInvPS As Integer, CveUM As Integer, UM As String,
+ CveClasificacion As Integer, Clasificacion As String, CveProyecto As Integer, CveSubProyecto As Integer,
+ Obs As String, Cantidad As Double, PU As Double, PorcentajeIVA As Double, ImporteIVA As Double, PorcentajeRetIVA As Double, ImporteRetIVA As Double,
+ PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double,
+ Total As Double, Serie As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String,
+ SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer,
+ CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer)
+
+ Dim Row As DataRow = Nothing
+ Row = TmpDT.NewRow()
+
+ Row("Consec") = TmpDT.Rows.Count + 1
+ Row("Orden") = TmpDT.Rows.Count + 1
+
+ Row("CvePS") = CvePS
+ Row("PS") = PS
+ Row("Codigo") = Codigo
+ Row("CodigoPS") = CodigoPS
+ Row("CveTipoPS") = CveTipoPS
+ Row("CveTipoInvPS") = CveTipoInvPS
+
+ Row("CveUM") = CveUM
+ Row("UM") = UM
+
+ Row("CveClasificacion") = CveClasificacion
+ Row("Clasificacion") = Clasificacion
+ Row("CveProyecto") = CveProyecto
+ Row("Proyecto") = ""
+ Row("CveSubProyecto") = CveSubProyecto
+ Row("SubProyecto") = ""
+
+ Row("Obs") = Obs
+ Row("Cantidad") = Cantidad
+ Row("PU") = Math.Round(PU, 6)
+ Row("PorcentajeIVA") = PorcentajeIVA
+ Row("IVA") = PorcentajeIVA
+ Row("ImporteIVA") = Math.Round(ImporteIVA, 2)
+ Row("PorcentajeRetIVA") = PorcentajeRetIVA
+ Row("ImporteRetIVA") = Math.Round(ImporteRetIVA, 2)
+ Row("PorcentajeRetISR") = PorcentajeRetISR
+ Row("ImporteRetISR") = Math.Round(ImporteRetISR, 2)
+ Row("PorcentajeIEPS") = PorcentajeIEPS
+ Row("ImporteIEPS") = Math.Round(ImporteIEPS, 2)
+ Row("IEPS") = Math.Round(ImporteIEPS, 2)
+ Row("TipoDescuento") = TipoDescuento
+ Row("Descuento") = Math.Round(Descuento, 2)
+ Row("Total") = Math.Round(Total, 2)
+ Row("TotalImporte") = Math.Round(Total, 2)
+
+ Row("Serie") = Serie
+ Row("TiempoEntrega") = TiempoEntrega
+ Row("CvePresupuestoIngreso") = CvePresupuestoIngreso
+ Row("EntregaDirecta") = EntregaDirecta
+ Row("SATClaveProdServ") = SATClaveProdServ
+ Row("SATClaveUM") = SATClaveUM
+
+ 'Contratos
+ Row("CveContratoDetalle") = CveContratoDetalle
+ Row("CveVentaDetalle") = CveVentaDetalle
+ Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
+ Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
+ Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
+ Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
+ Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
+ If DrPS IsNot Nothing Then
+ Row("CodigoObjetoImpuesto") = DrPS("CodigoObjetoImpuesto")
+ End If
+ TmpDT.Rows.Add(Row)
+ End Sub
+
+ Private Sub CargaImpuestos(ByRef ObjFacturaDevolucion As Modelos.Factura, ListaVentasGenerarNC As List(Of Modelos.Factura), ClienteDesglosaIEPS As Boolean, ClienteRetIVA As Decimal, ClienteRetISR As Decimal)
+ Dim DtImpuestos As New DataTable
+ DtImpuestos.Columns.Add("ImportePU", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteTotal", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteRetIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeRetISR", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteRetISR", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeIEPS", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteIEPS", GetType(Decimal))
+ DtImpuestos.Columns.Add("CveSubProyecto", GetType(Integer))
+ DtImpuestos.AcceptChanges()
+ Dim AcumuladoNC As Decimal = 0
+
+ For Each Fac In ListaVentasGenerarNC
+ DtImpuestos.Merge(CargaDtImpuestosNC(Fac.CveVenta, Fac.DescuentoProntoPago), True, MissingSchemaAction.Ignore)
+ Next
+
+ DtImpuestos = CargaTotalesImpuestos(DtImpuestos)
+
+ Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, ObjFacturaDevolucion.CveSubProyecto).Rows(0)
+
+ Dim Cantidad As Decimal = 1
+ Dim CveProyecto As Integer = DrSubProyecto("CveProyecto").ToString().ToEntero()
+ Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero
+ Dim SubProyecto = DrSubProyecto("SubProyecto").ToString
+ Dim Proyecto = DrSubProyecto("Proyecto").ToString
+
+ Dim CveSATNC As Integer
+ Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
+ Dim NCBonificacion As Integer = 0
+ If ArrayNC.Length > 6 Then 'CONCEPTO DE PRONTO PAGO
+ CveSATNC = ArrayNC(6).ToEntero()
+ End If
+ Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("")
+
+ For Each Dr As DataRow In DtImpuestos.Rows
+ AgregaTempDTNC(ObjFacturaDevolucion.DtDetalle, DrPS("CvePS").ToString.ToEntero, DrPS("PS").ToString, DrPS("Codigo").ToString, DrPS("PSCodigo").ToString, DrPS("CveTipoPS").ToString.ToEntero, DrPS("Inv_CveMetodoInventario").ToString.ToEntero,
+ DrPS("CveUM").ToString.ToEntero, DrPS("UnidadMedida").ToString, DrPS("CveClasificacion").ToString.ToEntero, DrPS("Clasificacion").ToString, CveProyecto, CveSubProyecto,
+ "", Cantidad, Dr("ImportePU").ToString.ToDecimal, Dr("PorcentajeIVA").ToString.ToDecimal, Dr("ImporteIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("ImporteRetIVA").ToString.ToDecimal,
+ Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("ImporteRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("ImporteIEPS").ToString.ToDecimal, -1, 0.0, Dr("ImporteTotal").ToString.ToDecimal, "", "", -1, -1,
+ DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1)
+ Next
+
+ End Sub
+
+ Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable
+ Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
+
+ Dim TmpDT As DataTable = Nothing
+ Dim ObjVentas As New ClsVentas
+
+ If ObjVentas.GetVentaDetalle(CveVentaNC) Then
+ TmpDT = ObjVentas.DtResultados
+ TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
+ TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
+ End If
+
+ If ObjVentas.GetVenta(CveVentaNC, UsuarioActual.CveEmpresa) Then
+ If ObjVentas.DtResultados.Rows.Count > 0 Then
+ Total = ObjVentas.DtResultados()(0)("Total").ToString.ToDecimal
+ SubTotal = ObjVentas.DtResultados()(0)("SubTotal").ToString.ToDecimal
+ End If
+ End If
+ ObjVentas.Dispose()
+
+ Dim DtImpuestosLocal = TmpDT.FiltraParametros("", "", {"PorcentajeIVA", "PorcentajeRetIVA", "PorcentajeRetISR", "PorcentajeIEPS", "CveSubProyecto"}).Copy
+ DtImpuestosLocal.Columns.Add("ImportePU", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteTotal", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteIVA", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteRetIVA", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteRetISR", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteIEPS", GetType(Decimal))
+
+ Dim ImporteReferencia As Decimal = Total
+ Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100
+ Dim FiltroStr As String = ""
+ Dim ImporteTotalConcepto As Decimal = 0
+ For Each Dr As DataRow In DtImpuestosLocal.Rows
+ FiltroStr = String.Format("ISNULL(PorcentajeIVA,0) = {0} AND ISNULL(PorcentajeRetIVA,0) = {1} AND ISNULL(PorcentajeRetISR,0) = {2} AND ISNULL(PorcentajeIEPS,0) = {3} AND ISNULL(CveSubProyecto,0) = {4} ", Dr("PorcentajeIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("CveSubProyecto"))
+ ImporteTotalConcepto = Porcentaje * (TmpDT.SUMD("TotalImporte", FiltroStr) - TmpDT.SUMD("Descuento", FiltroStr))
+
+ Dr("ImportePU") = ImporteTotalConcepto.RoundSQL(6)
+ Dr("ImporteTotal") = ImporteTotalConcepto.RoundSQL(2)
+
+ Dr("ImporteIVA") = (ImporteTotalConcepto * Dr("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
+ Dr("ImporteRetIVA") = (ImporteTotalConcepto * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2)
+ Dr("ImporteRetISR") = (ImporteTotalConcepto * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2)
+ Dr("ImporteIEPS") = (ImporteTotalConcepto * Dr("PorcentajeIEPS").ToString().ToDecimal()).RoundSQL(2)
+
+ 'Dr("ImporteIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIVA", FiltroStr), 2)
+ 'Dr("ImporteRetIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetIVA", FiltroStr), 2)
+ 'Dr("ImporteRetISR") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetISR", FiltroStr), 2)
+ 'Dr("ImporteIEPS") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIEPS", FiltroStr), 2)
+
+ '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal)
+ Next
+ 'codigo para ajuste de centavo, si el importe total no cuadra con los totales
+ Dim difTmp As Decimal = Importe - (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR"))
+ If Math.Abs(difTmp) >= 0.01 Then
+ 'asusto la diferencia en el último concepto
+ Dim ImporteAjustado As Decimal = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString.ToDecimal + difTmp
+ DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal") = ImporteAjustado
+ DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImportePU") = ImporteAjustado
+ End If
+ 'CARGA FACTURA A LA CUAL SE APLICA LA NC
+ 'CargaNCDT(CveVentaNC, Importe.ToDecimal)
+ Return DtImpuestosLocal
+ End Function
+
+ Private Function CargaTotalesImpuestos(DtImpuestos As DataTable) As DataTable
+ Dim query = From dr In DtImpuestos
+ Group By PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal,
+ PorcentajeRetIVA = dr("PorcentajeRetIVA").ToString.ToDecimal,
+ PorcentajeRetISR = dr("PorcentajeRetISR").ToString.ToDecimal,
+ PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal
+ Into x = Group
+ Select ImportePU = x.Sum(Function(s) s("ImportePU").ToString.ToDecimal),
+ ImporteTotal = x.Sum(Function(s) s("ImporteTotal").ToString.ToDecimal),
+ ImporteIVA = x.Sum(Function(s) Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)), ' Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)) * (1 + PorcentajeIEPS) * PorcentajeIVA,
+ ImporteRetIVA = x.Sum(Function(s) Math.Round(s("ImporteRetIVA").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetIVA,
+ ImporteRetISR = x.Sum(Function(s) Math.Round(s("ImporteRetISR").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetISR,
+ ImporteIEPS = x.Sum(Function(s) Math.Round(s("ImporteIEPS").ToString.ToDecimal, 2)), 'Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeIEPS,
+ PorcentajeIVA = PorcentajeIVA,
+ PorcentajeRetIVA = PorcentajeRetIVA,
+ PorcentajeRetISR = PorcentajeRetISR,
+ PorcentajeIEPS = PorcentajeIEPS
+
+ Return query.QueryToDataTable(False)
+ End Function
+
+ Protected Function CreaDTDetalleNC() As DataTable
+ Dim TmpDT = New DataTable
+ TmpDT.Columns.Add("CveVenta", GetType(Integer))
+ TmpDT.Columns.Add("Consec", GetType(Integer))
+ TmpDT.Columns.Add("Cantidad", GetType(Decimal))
+ TmpDT.Columns.Add("Codigo", GetType(String))
+ TmpDT.Columns.Add("CveUM", GetType(Integer))
+ TmpDT.Columns.Add("UM", GetType(String))
+ TmpDT.Columns.Add("SATClaveUM", GetType(String))
+ TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
+ TmpDT.Columns.Add("Clasificacion", GetType(String))
+ TmpDT.Columns.Add("CvePS", GetType(Integer))
+ TmpDT.Columns.Add("PS", GetType(String))
+ TmpDT.Columns.Add("CodigoPS", GetType(String))
+ TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
+ TmpDT.Columns.Add("NoIdentificacion", GetType(String))
+ TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
+ TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
+ TmpDT.Columns.Add("Serie", GetType(String))
+ TmpDT.Columns.Add("CuentaPredial", GetType(String))
+ TmpDT.Columns.Add("Obs", GetType(String))
+ TmpDT.Columns.Add("TiempoEntrega", GetType(String))
+ TmpDT.Columns.Add("PU", GetType(Decimal))
+ TmpDT.Columns.Add("IVA", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
+ TmpDT.Columns.Add("IEPS", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
+ TmpDT.Columns.Add("Descuento", GetType(Decimal))
+ TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
+ TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
+ TmpDT.Columns.Add("Total", GetType(Decimal))
+ 'Para uso del módulo contable
+ TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
+ TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
+ TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
+ TmpDT.Columns.Add("CveProyecto", GetType(Integer))
+ TmpDT.Columns.Add("Proyecto", GetType(String))
+ TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
+ TmpDT.Columns.Add("SubProyecto", GetType(String))
+ TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer))
+ 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
+ TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
+ TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
+ 'Contratos
+ TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
+ 'Remisiones a Facturas
+ TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
+ TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
+ TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
+ 'Pedido2 a Facturas
+ TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
+ TmpDT.Columns.Add("Origen", GetType(Integer))
+ 'Ordenes Servicio
+ TmpDT.Columns.Add("CveOS", GetType(Integer))
+ TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
+ TmpDT.Columns.Add("SeFacturara", GetType(Integer))
+ TmpDT.Columns.Add("Folio", GetType(Integer))
+ TmpDT.Columns.Add("Estatus", GetType(String))
+ 'Ordenamiento
+ TmpDT.Columns.Add("Orden", GetType(Integer))
+ TmpDT.Columns.Add("TipoDocto", GetType(String))
+ 'OC
+ TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
+ TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
+ TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
+ TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
+ TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
+ TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal))
+ TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
+ TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
+ TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
+ TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
+ TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
+ TmpDT.Columns.Add("CveTamaño", GetType(Integer))
+ TmpDT.Columns.Add("EsCargo", GetType(Boolean))
+ TmpDT.Columns.Add("CodigoObjetoImpuesto", GetType(String))
+
+ Return TmpDT
+ End Function
+ Private Function InicializaDTVentasNC() As DataTable
+ Dim DtVentasNC = New DataTable
+ DtVentasNC.Columns.Add("CveVenta", GetType(Integer))
+ DtVentasNC.Columns.Add("Importe", GetType(Decimal))
+ DtVentasNC.Columns.Add("FolioFiscal", GetType(String))
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TC", .DataType = GetType(Decimal), .DefaultValue = 1})
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TCCambioValuacion", .DataType = GetType(Decimal), .DefaultValue = 1})
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "CveEstatusFactura", .DataType = GetType(Integer), .DefaultValue = -1})
+
+ Return DtVentasNC
+ End Function
+#End Region
+
+
+ Private Sub LimpiaCampos()
+ TxtFolio.Text = ""
+ TxtObservaciones.Text = ""
+ TxtImporte.Text = ""
+ TxtTotal.Text = ""
+ TxtFechaDocumento.Text = Now.ToShortDateString
+ DdlCuenta.SelectedValue = "-1"
+ DdlTipoTransaccion.SelectedValue = "-1"
+
+ CFDIRelacionadoSustitucion = "-1"
+ FechaCorteIE = DateTime.Now.ToDate
+ IDPoliza = -1
+ FolioIECancelado = ""
+
+ Anexo.Text = ""
+
+ If UsuarioActual.Empresa.UsaAC Then
+ TxtOtrosImportes.Text = ""
+ UpDatos.Update()
+ CargaDatos(-1)
+ Else
+ UpDatos.Update()
+ CargaDatos(If(Request("CveMoneda") IsNot Nothing AndAlso Request("CveMoneda").ToString.ToEntero > 0, Request("CveMoneda").ToString.ToEntero, -1))
+ End If
+
+ End Sub
+
+ Private Sub RblTipoPago_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoPago.SelectedIndexChanged
+ Select Case RblTipoPago.SelectedValue
+ Case "1"
+ DdlProveedorPagoInt.Items.Clear()
+ DivDatosBancarios.Visible = True
+ TxtFolio.Enabled = True
+ divAbonese.Visible = True
+ divIntermediario.Visible = False
+ PanelIngresos.Visible = False
+ Case "3"
+ ' Ingresos por comprobar
+ DdlProveedorPagoInt.Items.Clear()
+ DivDatosBancarios.Visible = False
+ PanelIngresos.Visible = True
+ TxtFolio.Enabled = True
+ divAbonese.Visible = True
+ divIntermediario.Visible = False
+ 'filtro primero por los de la moneda
+ CargaIngresos(CveMonedaFiltro)
+
+ If ChkPagarDolares.Checked Then
+ CveMonedaPago = 2
+ CveMoneda = 1
+ TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", 2))
+ Else
+ CveMonedaPago = 1
+ End If
+ CargaDatos(CveMoneda)
+ Case Else
+
+ divAbonese.Visible = False
+ Dim ObjProveedores As New ClsCompProveedores
+ ObjProveedores.GetProveedorProsepago(UsuarioActual.CveEmpresa)
+
+ divIntermediario.Visible = True
+ DdlProveedorPagoInt.DataSource = ObjProveedores.DtResultados
+ ObjProveedores.Dispose()
+ DdlProveedorPagoInt.DataBind()
+
+ DivDatosBancarios.Visible = False
+ TxtFolio.Enabled = False
+ PanelIngresos.Visible = False
+
+ End Select
+
+ CargaDatos(CveMoneda)
+ UpDatos.Update()
+ End Sub
+
+ Private Function CargaIngresos(tCveMoneda As Integer) As DataTable
+ Dim dtt As DataTable = Nothing
+ Dim Deudores As New ClsMovimientos
+ If Deudores.GetIngresosSaldosDetalle(CveCliente, tCveMoneda, UsuarioActual.CveEmpresa) Then
+ DdlIngreso.DataSource = Deudores.DtResultados.FiltraParametros("CveCliente > 0 AND Saldo > 0 AND CveIE > 0")
+ dtt = Deudores.DtResultados.FiltraParametros("CveCliente > 0 AND Saldo > 0 AND CveIE > 0")
+ End If
+ Deudores.Dispose()
+
+ DdlIngreso.DataBind()
+ DdlIngreso.Items.Insert(0, New ListItem("-", "-1"))
+ Return dtt
+ End Function
+
+ Private Function CargaPrestamos(tCveMoneda As Integer) As DataTable
+ Dim dtt As DataTable = Nothing
+ Dim Deudores As New ClsMovimientos
+ If Deudores.GetDocumentosxPagarDetalle(CveCliente, tCveMoneda, 2, UsuarioActual.CveEmpresa) Then
+ DdlPrestamo.DataSource = Deudores.DtResultados '.FiltraParametros("CveCliente > 0 AND Saldo > 0 AND CveIE > 0")
+ dtt = Deudores.DtResultados
+ End If
+ Deudores.Dispose()
+
+ DdlPrestamo.DataBind()
+ DdlPrestamo.Items.Insert(0, New ListItem("-", "-1"))
+ Return dtt
+ End Function
+
+ Protected Sub ChkAjusteOI_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ChkAjusteOI.CheckedChanged
+
+ If ChkAjusteOI.Checked Then
+ TxtOtrosImportes.Visible = True
+ TxtTotal.Visible = True
+ GvCxC.Columns(13).Visible = True
+ Else
+ TxtOtrosImportes.Visible = False
+ TxtTotal.Visible = False
+ GvCxC.Columns(13).Visible = False
+ TxtOtrosImportes.Text = ""
+ TxtTotal.Text = ""
+ RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);")
+ End If
+
+ UpDatos.Update()
+ UPVentas.Update()
+ End Sub
+
+#Region " PAGAR CON PESOS "
+ Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs)
+ If ChkPagarPesos.Checked Then
+ DivTCDolaresDolares.Visible = False
+ RegistraScript("$get('DivTC').style.display = 'block';")
+ CargaCuentas()
+ If RblTipoPago.SelectedValue = "3" Then
+ CargaIngresos(1)
+ End If
+ TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ Else
+ DivTCDolaresDolares.Visible = True
+ 'RegistraScript("document.getElementById('DivTC').style.display = 'none';")
+ CargaCuentas()
+ TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ End If
+ UpDatos.Update()
+
+ CargaDatos(2)
+ RegistraScript("CambiaPesosDolares();")
+ End Sub
+#End Region
+
+#Region "PAGAR CON DOLARES"
+ Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs)
+ If ChkPagarDolares.Checked Then
+ DivTCDolares.Visible = True
+ CargaCuentas()
+ If RblTipoPago.SelectedValue = "3" Then
+ CargaIngresos(2)
+ RegistraScript("CambiaDolaresPesos();")
+ End If
+ TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
+ TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ Else
+ DivTCDolares.Visible = False
+ CargaCuentas()
+ TxtFechaDocumento.Attributes.Remove("onchange")
+ End If
+ UpDatos.Update()
+
+ CargaDatos(1)
+ RegistraScript("CambiaDolaresPesos();")
+ End Sub
+#End Region
+
+#Region " CUENTAS DEPOSITOS"
+ Private Sub CargaCuentasDepositos()
+ DdlCuentaDeposito.Items.Clear()
+ If DdlTipoTransaccion.SelectedValue > 0 Then ' transferencias y layout
+ trCuentaDeposito.Visible = False
+
+ Dim dtc As DataTable = GlobalDTCuentasDepositosClientes(UsuarioActual.CveEmpresa, CveCliente:=CveCliente)
+
+ If dtc IsNot Nothing Then
+ If DdlTipoTransaccion.SelectedValue = "9" Then
+
+ DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'")
+
+ If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then
+ trCuentaDeposito.Visible = True
+ DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
+ Else
+ BtnIEGuardar.Enabled = False
+ Alert("El Cliente no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia)
+ End If
+ Else
+ DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'")
+ If dtc.Rows.Count >= 1 Then
+ trCuentaDeposito.Visible = True
+ DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
+ End If
+ End If
+
+ End If
+ DdlCuentaDeposito.DataBind()
+ Else
+ trCuentaDeposito.Visible = False
+ DdlCuentaDeposito.Items.Clear()
+ End If
+
+ UpCuentaDeposito.Update()
+ UpDatos.Update()
+
+ End Sub
+
+ Private Sub RecargaCuentasDepositos()
+
+ Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
+ If dr IsNot Nothing Then
+ HdnTipoTransaccion.Value = dr("Tipo").ToString
+ HdnTipoTransaccionAbreviatura.Value = dr("Abreviatura").ToString
+ End If
+ CargaCuentasDepositos()
+ End Sub
+ Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs)
+ Dim dtc As DataTable = GlobalDTCuentasDepositosClientes(UsuarioActual.CveEmpresa, CveCliente:=CveCliente, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero)
+
+ If dtc IsNot Nothing AndAlso dtc.Rows.Count = 1 Then
+ If dtc.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then
+ TrReferenciaCIE.Visible = True
+ TxtReferenciaCIE.Text = dtc.Rows(0)("Referencia").ToString
+ Else
+ TrReferenciaCIE.Visible = False
+ End If
+ End If
+
+ UpCuentaDeposito.Update()
+ End Sub
+#End Region
+
+#Region " COMPLEMENTOS PAGO "
+ Private Function EmitirComplementoPago(CveIE As Integer, CveVentas As List(Of Integer), Series As List(Of String)) As String
+
+ If Not UsuarioActual.Empresa.FacturaProduccion Then
+ Return ""
+ End If
+
+ If Not ChkComplementoPago.Checked Then
+ Return ""
+ End If
+
+ Dim Retorno As New StringBuilder
+
+ 'For i = 0 To CveVentas.Count - 1
+ Dim ObjBancos As New ClsBancos
+
+ If ObjBancos.GetComplementoPagosRep(-1, Now.AddYears(-2), Now, CveIE, -1, 1, UsuarioActual.CveEmpresa, -1) Then
+ If Not ObjBancos.DtResultados.Rows.Count > 0 Then
+ ObjBancos.Dispose()
+ Alert("No se generaron complementos de pago porque no hay facturas con método de pago PPD", TipoMensaje.MsgAdvertencia)
+ Return ""
+ End If
+ End If
+
+ ObjBancos.IniciaTransacSQL()
+
+ If ObjBancos.GeneraTimbrePago(CveIE, -1, UsuarioActual, CveCliente, CFDIRelacionado:=CFDIRelacionadoSustitucion, EsRegeneracion:=False) Then
+ ObjBancos.Commit()
+ ComplementoSustitucionGenerado = True
+
+ PDFReciboDePagos(-1, -1, ObjBancos.CveComplementoPago, False)
+
+ 'Dim LigaDescargaXML = $"../Empresas/{UsuarioActual.CveEmpresa}/XML/Pag/{ObjBancos.ComplementoSerieFolio}.xml"
+ 'Dim LigaDescargaPDF = $"../Empresas/{UsuarioActual.CveEmpresa}/PDF/Pag/{ObjBancos.ComplementoSerieFolio}.pdf"
+ Retorno.AppendFormat(" Complemento de pago {0} ", ObjBancos.ComplementoSerieFolio)
+ Retorno.AppendFormat("XML ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}&CveIE={2}", ObjBancos.ComplementoSerieFolio, ObjBancos.CveComplementoPago, CveIE)))
+ Retorno.AppendFormat("PDF ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}&CveIE={2}", ObjBancos.ComplementoSerieFolio, ObjBancos.CveComplementoPago, CveIE)))
+
+ Dim ResultadoMail As Integer
+ Dim ObjMail As New ClsSisMail()
+ Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
+ LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = $"{UsuarioActual.Empresa.Ruta}\XML\Pag\{ObjBancos.ComplementoSerieFolio}.xml"})
+ LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = $"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{ObjBancos.ComplementoSerieFolio}.pdf"})
+
+ 'Dim Mail As String = "demo@adsistemas.mx"
+ Dim Asunto As String = "Envío de complemento de pago"
+ Dim Cuerpo As String = "Complemento de Pago"
+
+ If ObjMail.SendMail(UsuarioActual.Empresa, Mail, Asunto, Cuerpo, "", LSRutasMail) Then
+ ResultadoMail = 1
+ Else
+ ResultadoMail = 3
+ Alert("No se pudo enviar el correo", TipoMensaje.MsgAdvertencia)
+ End If
+ Else
+ ComplementoSustitucionGenerado = False
+ Retorno.AppendFormat($" Complemento de pago NO generado . {ObjBancos.Mensaje}")
+ ObjBancos.RollBack()
+ End If
+
+ ObjBancos.Dispose()
+
+ ' Next
+
+ Return Retorno.ToString
+ End Function
+
+
+#End Region
+
+#Region "SALDAR CUENTAS"
+
+
+ Private Sub BtnSaldarCuentasIncobrables_Click(sender As Object, e As EventArgs) Handles BtnSaldarCuentasIncobrables.Click
+ Dim ObjConta As New ClsContabilidad
+ ObjConta.IniciaTransacSQL()
+ Dim CvePrePoliza As Integer = 0
+ Dim MsgError As String = ""
+
+ 'Dim ObjIE As New ClsBancos
+ Dim FechaUltimaFluctuacion As Date = MinFecha
+ Dim TipoCambioFluctuacion As Decimal = 1
+
+ Dim tFecha As Date = TxtFechaIncobrable.Text.ToDate
+ Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha)
+
+ If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
+ If UltimaFluctuacion.FechaFluctuacion <= tFecha Then
+ FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion
+ TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion
+ End If
+ End If
+
+ CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFechaIncobrable.Text.ToDate, TxtObsSaldarIncobrable.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+
+ For Each gr As GridViewRow In GvCxC.Rows
+ If gr.FCCheckBox("Chk").Checked Then
+ Dim IdCtaContable As Integer = IdCuentaCliente
+ Dim PorcentajePago As Decimal = gr.DataKey("Saldo").ToDecimal / gr.DataKey("Original").ToDecimal
+ Dim Saldo As Decimal = gr.DataKey("Saldo").ToDecimal
+ Dim RETIVA As Decimal = gr.DataKey("RetIVA").ToDecimal
+ Dim SubTotal As Decimal = PorcentajePago * (gr.DataKey("SubTotal").ToDecimal.RoundSQL - gr.DataKey("Descuento").ToDecimal.RoundSQL).RoundSQL
+ Dim IVA As Decimal = PorcentajePago * gr.DataKey("IVA").ToDecimal.RoundSQL
+ Dim IEPS As Decimal = PorcentajePago * gr.DataKey("IEPS").ToDecimal.RoundSQL
+ Dim TCVenta As Decimal = gr.DataKey("TipoCambio").ToDecimal
+ Dim FechaVenta As Date = gr.DataKey("Fecha").ToDate
+ Dim tCveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero
+ Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaIncobrable.Text.ToDate).FormatoNumero(4)
+ Dim CveConceptoDeduccion As Integer = DdlTipoDeduccion.SelectedValue.ToEntero
+
+
+ 'si la fecha del documento es anterior a su ultima fluctuación. toma el Tc de la fluctuacion
+ If tCveMoneda = 2 Then
+ If FechaVenta < FechaUltimaFluctuacion Then
+ TCVenta = TipoCambioFluctuacion
+ End If
+ End If
+
+
+ 'condicionante
+ Dim ClienteMovto As Boolean = True
+ Dim SubtotalMovto As Boolean = False
+ Dim CveConceptoCliente As Integer = 2
+ Dim ImpuestosMovto As Boolean = False
+
+ Dim IdCuentaContableNoDeducible As Integer = 0
+ Dim CveSubProyecto As Integer = gr.DataKey("CveSubProyecto").ToEntero
+ Dim ConceptoPartida As String = TxtObsSaldarIncobrable.Text.Trim & " " & gr.DataKey("SerieFolio").ToString
+
+ If CveConceptoDeduccion = 255 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(266).ToEntero
+ If CveConceptoDeduccion = 179 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(559).ToEntero
+ If CveConceptoDeduccion = 263 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(537).ToEntero
+ If CveConceptoDeduccion = 252 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(581).ToEntero
+ If CveConceptoDeduccion = 78 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.IdCuentaOtrosIngresos
+
+ If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) Then
+
+ ClienteMovto = False : Saldo = Saldo * -1
+ ImpuestosMovto = True : IVA = IVA * -1
+
+ 'RETIVA = RETIVA * -1
+
+ RETIVA = ((SubTotal * RETIVA / gr.DataKey("SubTotal").ToDecimal.RoundSQL) * -1).RoundSQL(2)
+
+ CveConceptoCliente = 1
+ 'falta cuenta incobrable
+ IdCuentaContableNoDeducible = 3114
+
+ End If
+
+ Dim UsaComplementaria As Boolean = True
+
+ 'If UsuarioActual.CveEmpresa = 119 Then
+ ' UsaComplementaria = True
+ 'End If
+
+ If MsgError = "" Then
+
+ If tCveMoneda = 2 Then
+ IdCtaContable = IdCtaContMonedaExtranjera
+ Else
+ IdCtaContable = IdCuentaCliente
+ End If
+ Dim ConPreP As ConceptosTipoSaldo = ClsPaginas.ObtenerCveConceptoPrePoliza(6, tCveMoneda, True, 1)
+
+ 'normal
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, ConPreP.CveConcepto, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo), TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+
+ If UsaComplementaria AndAlso tCveMoneda = 2 Then
+ 'complementaria
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, 0, gr.DataKey("SerieFolio").ToString, ConPreP.CveConceptoComplementario, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContComplementaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, (Saldo * TCVenta) - Saldo).RoundSQL, ImporteME:=Saldo, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+ End If
+
+ 'fluctuación.
+ If tCveMoneda = 2 Then
+ Dim ImporteFluctuacion As Decimal = 0
+ ImporteFluctuacion = Saldo * (TCPago - TCVenta)
+
+ If CveSubProyecto <= 0 Then
+ MsgError = $"No se pudo obtener el sub proyecto de la venta {gr.DataKey("SerieFolio").ToString}"
+ End If
+
+ If TCPago > TCVenta Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 64, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=0, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), TipoCambio:=TCVenta, TipoCambioPago:=TCPago, CveSubProyecto:=CveSubProyecto) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+ Else
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 65, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=0, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), TipoCambio:=TCVenta, TipoCambioPago:=TCPago, CveSubProyecto:=CveSubProyecto) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+ End If
+
+ 'cuando hay pago en dólares, se ajusta el concepto de subtotal,
+ SubTotal = (Saldo * TCVenta) + ImporteFluctuacion - (IVA * TCVenta) - (IEPS * TCVenta)
+
+ End If
+
+
+ If (IVA > 0 Or UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) And IVA < 0) AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, gr.DataKey("SerieFolio").ToString, 13, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IVA, IVA * TCVenta), PorcentajeImpuesto:=gr.DataKey("PorcentajeIVA").ToDecimal, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+
+ If (RETIVA > 0 Or UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) And RETIVA < 0) AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, RETIVA, gr.DataKey("SerieFolio").ToString, 8, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContRetIVA, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, RETIVA, RETIVA * TCVenta), TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+
+ If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, gr.DataKey("SerieFolio").ToString, 38, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IEPS, IEPS * TCVenta), TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+
+ 'al gasto,Subtotal
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, gr.DataKey("SerieFolio").ToString, CveConceptoDeduccion, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCuentaContableNoDeducible, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=SubTotal, CveSubProyecto:=CveSubProyecto, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
+ MsgError = "Ocurrio un error al saldar el movimiento"
+ End If
+
+ If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then
+ If ObjConta.ValorPolizaDescuadre > 0 Then
+ MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia
+ GuardaLogAD($"Ventas/ClientesAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
+ Exit For
+ End If
+ End If
+
+ End If
+ End If
+ Next
+
+ If MsgError = "" Then
+ 'ObjConta.RollBack()
+ ObjConta.Commit()
+ CargaDatos(CveMonedaFiltro)
+ RegistraScript("$('#ModalSaldarCuentaIncobrable').modal('hide')")
+ Alert(String.Format("Los movimientos se saldaron correctamente. Ver PrePóliza", CvePrePoliza), TipoMensaje.MsgInformacion)
+
+ Else
+ ObjConta.RollBack()
+ Alert(MsgError, TipoMensaje.MsgError)
+ End If
+
+ BtnSaldarCuentasIncobrables.Visible = False
+ ObjConta.Dispose()
+ End Sub
+
+
+ Private Sub ValidaCuentaDePagoFormaDePago()
+
+ If Not (DdlTipoTransaccion.SelectedValue.ToEntero > 0 And DdlCuenta.SelectedValue.ToEntero > 0) Then
+ Exit Sub
+ End If
+
+ Dim DTTipoTransacciones As DataTable = GlobalDTTipoTransacciones.FiltraParametros($"CveTipoTransaccion={DdlTipoTransaccion.SelectedValue}")
+ Dim DTCuentas As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros($"CveCuenta={DdlCuenta.SelectedValue}")
+
+ Dim ClaveFormaPagoSAT As String = ""
+ Dim Cuentapago As String = ""
+ Dim CuentaBeneficiario As String = ""
+
+
+ If DTTipoTransacciones.Rows.Count > 0 Then
+ ClaveFormaPagoSAT = DTTipoTransacciones.Rows(0)("ClaveFormaPagoSAT").ToString
+ Else
+ Alert("La forma de pago no tiene una forma de pago SAT", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If DTCuentas.Rows.Count > 0 Then
+ CuentaBeneficiario = DTCuentas.Rows(0)("NumCuenta").ToString
+ Else
+ Alert("No se pudo encontrar la cuenta", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+
+ Dim Mensaje As String = ""
+ Cuentapago = ""
+
+
+ Select Case ClaveFormaPagoSAT.ToString
+ Case "01"
+ ' no tiene restricciones
+ Case "02"
+ If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(11, 18) Then
+ Mensaje = "La cuenta ordenante no cumple con el formato esperado."
+ End If
+
+ If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
+ Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
+ End If
+ Case "03"
+ If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10, 16, 18) Then
+ Mensaje = "La cuenta ordenante no cumple con el formato esperado."
+ End If
+ If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 18)) Then
+ Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
+ End If
+ Case "04"
+
+ If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(16) Then
+ Mensaje = "La cuenta ordenante no cumple con el formato esperado."
+ End If
+
+ If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
+ Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
+ End If
+
+ Case "05"
+ If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10, 11, 15, 16, 18, 50) Then
+ Mensaje = "La cuenta ordenante no cumple con el formato esperado."
+ End If
+
+ If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
+ Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
+ End If
+ Case "06"
+ If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10) Then
+ Mensaje = "La cuenta ordenante no cumple con el formato esperado."
+ End If
+
+ CuentaBeneficiario = ""
+ Case "28"
+ If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(16) Then
+ Mensaje = "La cuenta ordenante no cumple con el formato esperado."
+ End If
+
+ If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
+ Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
+ End If
+ Case "29"
+ If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(15, 16) Then
+ Mensaje = "La cuenta ordenante no cumple con el formato esperado."
+ End If
+
+ If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
+ Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
+ End If
+
+ Case Else
+
+
+
+ End Select
+
+ LblValidaCeuntaTipoTransaccion.Text = Mensaje
+
+ If Not Mensaje.Length = 0 Then
+ 'Alert(Mensaje, TipoMensaje.MsgAdvertencia)
+ LblValidaCeuntaTipoTransaccion.Visible = True
+ Else
+ LblValidaCeuntaTipoTransaccion.Visible = False
+ End If
+
+ UpGuardar.Update()
+
+ End Sub
+
+#End Region
+
+ Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs)
+ CambiaTipoMoneda()
+ End Sub
+ Private Sub CambiaTipoMoneda()
+ Dim dia As Integer = If(UsuarioActual.CveEmpresa = 13, TxtFechaDocumento.Text.ToDate.Day - 1, TxtFechaDocumento.Text.ToDate.Day)
+ Fecha = (dia.ToString + "/" + TxtFechaDocumento.Text.ToDate.Month.ToString + "/" + TxtFechaDocumento.Text.ToDate.Year.ToString).ToDate
+
+ If TxtTC.Visible Then
+ TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ End If
+
+ If DivTCDolares.Visible Then
+ TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ End If
+
+ If DivTCDolaresDolares.Visible Then
+ TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4)
+ End If
+
+ Dim moneda As Integer = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
+ If CveMonedaFiltro = -1 Then
+ RegistraScript(String.Format("FnCambia(0,0,0,0,-1,{0});", moneda))
+ Else
+ RegistraScript(String.Format("FnCambia(0,0,0,0,1,{0});", moneda))
+ End If
+
+ UpDatos.Update()
+ End Sub
+
+ Private Sub DdlIngreso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlIngreso.SelectedIndexChanged
+ 'saco la moneda de la selección
+ HdnIngresoImporte.Value = 0
+ If DdlIngreso.SelectedValue.ToEntero > 0 Then
+ Dim Banco As New ClsBancos
+
+ If Banco.GetBancosIE(DdlIngreso.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
+ CveMonedaPago = Banco.CveMoneda
+ Dim Deudores As New ClsMovimientos
+ If Deudores.GetIngresosSaldosDetalle(CveCliente, -1, UsuarioActual.CveEmpresa) Then
+ HdnIngresoImporte.Value = Deudores.DtResultados.FiltroPrimeroValor("Saldo", String.Format("CveIE = {0}", DdlIngreso.SelectedValue))
+ TxtTCDolares.Text = Deudores.DtResultados.FiltroPrimeroValor("TipoCambio", String.Format("CveIE = {0}", DdlIngreso.SelectedValue))
+ FechaIngreso = Deudores.DtResultados.FiltroPrimeroValor("FechaDocumento", String.Format("CveIE = {0}", DdlIngreso.SelectedValue))
+ End If
+ Deudores.Dispose()
+ End If
+ IdCuentaBancariaComplementaria = 0
+ Banco.Dispose()
+ Else
+ CveMonedaPago = -1
+ End If
+
+
+ If CveMonedaPago = 1 Then
+ 'DivTC.Visible = True
+ DivTCDolares.Visible = False
+ TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", CveMonedaPago))
+ ElseIf CveMonedaPago = 2 Then
+ 'DivTC.Visible = False
+ RegistraScript("document.getElementById('DivTC').style.display = 'none';")
+ DivTCDolares.Visible = True
+ TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", CveMonedaPago))
+ End If
+
+ CargaDatos(CveMoneda)
+
+ End Sub
+
+ Private Sub RVTxtFechaDocumento_Init(sender As Object, e As EventArgs) Handles RVTxtFechaDocumento.Init
+ RVTxtFechaDocumento.MaximumValue = DateTime.Now.ToShortDateString
+ Calendario.EndDate = DateTime.Now
+
+ End Sub
+
+
+#Region "LIQUIDACION"
+
+ Protected Sub TimTiempo_Tick(sender As Object, e As EventArgs)
+ Dim a As String = "se recarga para que no pierda sesión el registro puede tardar más de una hora en llenar todos los datos" 'solo para que se ejecute sin que afecte a lo demás
+ End Sub
+
+ Protected Sub ChkLiquidacion_CheckedChanged(sender As Object, e As EventArgs)
+ ActivaDesactivaLiquidacion()
+ End Sub
+
+ Private Sub ActivaDesactivaLiquidacion()
+
+ If ChkLiquidacion.Checked Then
+ TimTiempo.Enabled = True 'para que no me saque
+ GvCxC.Columns(4).Visible = False
+ GvCxC.Columns(5).Visible = False
+ GvCxC.Columns(6).Visible = False
+ GvCxC.Columns(7).Visible = False
+
+ '16-24
+ GvCxC.Columns(16).Visible = True
+ GvCxC.Columns(17).Visible = True
+ GvCxC.Columns(18).Visible = True
+ GvCxC.Columns(19).Visible = True
+ GvCxC.Columns(20).Visible = True
+ GvCxC.Columns(21).Visible = True
+ GvCxC.Columns(22).Visible = True
+ GvCxC.Columns(23).Visible = True
+ GvCxC.Columns(24).Visible = True
+ GvCxC.Columns(25).Visible = True
+ GvCxC.Columns(26).Visible = True
+ GvCxC.Columns(27).Visible = True 'anticipos
+ GvCxC.Columns(28).Visible = True 'anticipos2
+
+ GvCxC.Columns(29).Visible = False
+ GvCxC.Columns(30).Visible = False
+
+
+ Else
+ TimTiempo.Enabled = False
+ GvCxC.Columns(4).Visible = True
+ GvCxC.Columns(5).Visible = True
+ GvCxC.Columns(6).Visible = True
+ GvCxC.Columns(7).Visible = True
+
+ GvCxC.Columns(16).Visible = False
+ GvCxC.Columns(17).Visible = False
+ GvCxC.Columns(18).Visible = False
+ GvCxC.Columns(19).Visible = False
+ GvCxC.Columns(20).Visible = False
+ GvCxC.Columns(21).Visible = False
+ GvCxC.Columns(22).Visible = False
+ GvCxC.Columns(23).Visible = False
+ GvCxC.Columns(24).Visible = False
+ GvCxC.Columns(25).Visible = False
+ GvCxC.Columns(26).Visible = False
+ GvCxC.Columns(27).Visible = False 'anticipos
+ GvCxC.Columns(28).Visible = False 'anticipos2
+
+ GvCxC.Columns(29).Visible = True
+ GvCxC.Columns(30).Visible = True
+
+ End If
+
+ UPVentas.Update()
+ End Sub
+
+#End Region
+
+
+
+ Protected Sub LnkAccionesModalSeleccionLayout_Click(sender As Object, e As EventArgs)
+
+ TxtModalLayoutExcel.Text = "[]"
+ UpModalSeleccionLayout.Update()
+ RegistraScript("$('#ModalSeleccionLayout').modal('show');")
+
+ End Sub
+
+
+ Protected Sub LnkSeleccionLayout_Click(sender As Object, e As EventArgs)
+
+ Dim ProcesoOK As Boolean = True
+ Dim CountRegistros As Integer = 0
+ Dim TotalSeleccion As Decimal = 0D
+
+ Dim SBNoEncontradosEnLista As New StringBuilder
+ Dim SBPagoMayorASaldo As New StringBuilder
+
+ If TxtModalLayoutExcel.getfiles().Archivos.Count > 0 Then
+ Dim file As Archivo = TxtModalLayoutExcel.getfiles().Archivos(0)
+ Dim Directorio As String = Server.MapPath("~") & file.path
+ Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
+
+ Dim DTExcel As New DataTable
+ Dim ErrorArchivo = False
+ Dim ErrorExcel = False
+
+ DTExcel = ReadExcelFile(Directorio + file.filename, True)
+
+ If Not DTExcel.Columns(0).ColumnName.ToUpper = "FOLIO" Then
+ Alert("El nombre de la primera columna debe ser 'Folio'. Favor de corregirlo", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not DTExcel.Columns(1).ColumnName.ToUpper = "IMPORTE PAGO" Then
+ Alert("El nombre de la segunda columna debe ser 'Importe Pago'.Favor de corregirlo." & DTExcel.Columns(1).ColumnName, TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
+ ChkLiquidacion.Checked = True
+ ActivaDesactivaLiquidacion()
+ End If
+
+ For Each Drow As DataRow In DTExcel.Rows
+
+ Dim SerieFolioBusqueda As String = Drow("Folio").ToString.Trim.ToUpper
+ Dim ImportePago As Decimal = Drow("Importe Pago").ToString.ToDecimal.RoundSQL(2)
+ Dim SerieFolioEncontrado As Boolean = False
+
+ If ImportePago >= 0 Then
+
+ For Each GvRow As GridViewRow In GvCxC.Rows
+
+ Dim SerieFolioGv As String = GvRow.DataKey("SerieFolio").Trim.ToUpper
+
+ If SerieFolioBusqueda = SerieFolioGv Then
+ SerieFolioEncontrado = True
+ Dim SaldoGV As Decimal = GvRow.DataKey("Saldo").ToDecimal
+ If ImportePago = 0 Then ImportePago = SaldoGV 'si no se especifica cantidad toma la totalidad del saldo
+ Dim Diferencia As Decimal = SaldoGV - ImportePago
+
+ If Diferencia < 0 Then
+
+ If Math.Abs(Diferencia) > 0.01 Then
+ SBPagoMayorASaldo.AppendLine($"Factura: {SerieFolioBusqueda} Importe de pago {ImportePago.ToString("###,###,###.00")} es mayor al saldo {SaldoGV.ToString("###,###,###.00")} ")
+ ProcesoOK = False
+ Exit For
+ Else
+ ImportePago = SaldoGV
+ End If
+ End If
+
+ GvRow.FCCheckBox("Chk").Checked = True
+ GvRow.FCTextBox("TxtAbonar").Text = ImportePago.ToString("###,###,###.00")
+
+ If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
+
+ GvRow.FCDropDownList("DdlTG").SelectedTextExist(Drow("Tipo").ToString)
+ GvRow.FCTextBox("TxtLiqCol1").Text = Drow("Comisión").ToString
+ GvRow.FCTextBox("TxtLiqCol2").Text = Drow("Gastos").ToString
+ GvRow.FCTextBox("TxtLiqCol3").Text = Drow("Inspeccion").ToString
+ GvRow.FCTextBox("TxtLiqCol4").Text = Drow("Seguro").ToString
+ GvRow.FCTextBox("TxtLiqCol5").Text = Drow("AduanaMex").ToString
+ GvRow.FCTextBox("TxtLiqCol6").Text = Drow("Diversos").ToString
+ GvRow.FCTextBox("TxtLiqCol7").Text = Drow("AduanaUSA").ToString
+ GvRow.FCTextBox("TxtLiqCol8").Text = Drow("MaterialEmpaque").ToString
+ GvRow.FCTextBox("TxtLiqCol9").Text = Drow("Semilla").ToString
+
+ GvRow.FCDropDownList("DdlAnti").SelectedTextLikeIfExist(Drow("FolioAnticipo1").ToString)
+ GvRow.FCTextBox("TxtAmort").Text = Drow("ImporteAnticipo1").ToString
+ GvRow.FCDropDownList("DdlAnti2").SelectedTextLikeIfExist(Drow("FolioAnticipo2").ToString)
+ GvRow.FCTextBox("TxtAmort2").Text = Drow("ImporteAnticipo2").ToString
+
+ End If
+
+ TotalSeleccion = TotalSeleccion + ImportePago
+ CountRegistros = CountRegistros + 1
+
+ Exit For
+ End If
+ Next
+
+ If Not SerieFolioEncontrado Then
+ SBNoEncontradosEnLista.AppendLine($"{SerieFolioBusqueda} ")
+ End If
+ End If
+ Next
+
+ Else
+ Alert("Se debe seleccionar un archivo", TipoMensaje.MsgError)
+ End If
+
+ If ProcesoOK Then
+
+ Alert($"Facturas seleccionadas: {CountRegistros} {SBNoEncontradosEnLista.ToString}")
+ RegistraScript("$('#ModalSeleccionLayout').modal('hide');")
+ TxtImporte.Text = TotalSeleccion.ToString("###,###,###.00")
+
+ UPVentas.Update()
+ UpDatos.Update()
+ Else
+
+ If SBPagoMAyorASaldo.ToString.Length > 0 Then
+ Alert($"Facturas con pagos mayores a saldo: {SBPagoMAyorASaldo.ToString}", TipoMensaje.MsgAdvertencia)
+ End If
+
+ End If
+
+
+ End Sub
+
+ 'Public Sub SelectedTextLikeIfExist(ByRef Rbl As RadioButtonList, Value As String)
+ ' Try
+
+ ' For Each item As ListItem In Rbl.Items
+ ' If item.Value.Contains(Value) Then
+ ' item.Selected = True
+ ' End If
+ ' Next
+ ' Catch ex As Exception
+
+ ' End Try
+ 'End Sub
+
+ Protected Sub LnkDescargaFormato_Click(sender As Object, e As EventArgs)
+
+ Dim Directorio As String = ""
+ Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\LayoutPagoCliente.xlsx"
+ If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
+ Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\LayoutPagoClienteLiquidacion.xlsx"
+ End If
+
+ If Not (Directorio = "") Then
+
+ Dim Archivo As New IO.FileInfo(Directorio)
+ If Archivo.Exists Then
+ Response.Clear()
+ Response.ClearHeaders()
+ Response.ClearContent()
+ Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
+ Response.AddHeader("Content-Length", Archivo.Length.ToString())
+ Response.ContentType = "text/plain"
+ Response.Flush()
+ Response.TransmitFile(Archivo.FullName)
+ Response.End()
+ End If
+ End If
+
+ End Sub
+End Class
diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb
index 72d33c057..d944e15da 100644
--- a/Bancos/IE.aspx.vb
+++ b/Bancos/IE.aspx.vb
@@ -2610,15 +2610,19 @@ Partial Class Bancos_IE
'Cuando es Egreso sin factura, se registra una compra tipo anticipo
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "EGSCREDITO" Then
- CveConceptoCompra = 48 'Anticipo Acreedores
+ CveConceptoCompra = 10 'Anticipo Acreedores
CveConceptoContable = 30 'Bancos
CveCreditoDetalle = DdlCreditoDetalle.SelectedValue.ToEntero
Dim Estatus As Integer = 2
- If HdnCveTipoCredito.Value = "1" Then
+ Dim tesCrediproveedor As Boolean = False
+ 'falta especificar que deterina esta consideración en SIG
+ If HdnCveTipoCredito.Value = "1" AndAlso tesCrediproveedor Then
Estatus = 103
'cuando es crediproveedores es, pago a documentos por pagar
CveConceptoCompra = 57
End If
+
+
ObjIE.UpdateCreditosDetalle(Estatus, CveCreditoDetalle)
If HdnImporteCredito.Value.ToDouble > 0 AndAlso TxtImporte.Text.ToDouble > HdnImporteCredito.Value.ToDouble Then
diff --git a/Bancos/PolizaCheque.aspx b/Bancos/PolizaCheque.aspx
index 32ed1c0b4..02274a49d 100644
--- a/Bancos/PolizaCheque.aspx
+++ b/Bancos/PolizaCheque.aspx
@@ -16,7 +16,7 @@
diff --git a/Bancos/PolizaCheque.aspx.vb b/Bancos/PolizaCheque.aspx.vb
index 2b460b21e..a571d5eac 100644
--- a/Bancos/PolizaCheque.aspx.vb
+++ b/Bancos/PolizaCheque.aspx.vb
@@ -3,12 +3,12 @@ Imports Extensiones
Imports System.IO
Imports System.Linq
Imports System.Web.Services
-
+Imports Stimulsoft.Report.BarCodes
+
Partial Class Bancos_PolizaCheque
- Inherits ClsPaginas
-
- ' Private Shared missing As Object = System.Reflection.Missing.Value
-
+ Inherits ClsPaginas
+
+
#Region "Propiedades"
Private Property NombreArchivo As String
Get
@@ -92,9 +92,9 @@ Partial Class Bancos_PolizaCheque
Get
Return CType(ViewState("CveTurno"), Integer)
End Get
- End Property
+ End Property
#End Region
-
+
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
@@ -188,36 +188,24 @@ Partial Class Bancos_PolizaCheque
DdlPlantilla.SelectedValue = "36"
DdlPlantilla.Enabled = False
End If
+
+
+ DdlProveedores.txtText.Value = "Seleccione"
+ DdlProveedores.txtValue.Value = "-1"
+ DdlProveedores.setEsWebService(True)
+ DdlProveedores.Attributes.Add("data-metodo", "getproveedores")
+
+ CargaDDLPersonal()
+
+
End If
End Sub
- Protected Sub BtnBuscarProveedor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarProveedor.Click
- ViewState("CveProveedor") = HdnCveProveedor.Value.ToEntero
- CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1")
- DdlPlantilla_SelectedIndexChanged(DdlPlantilla, e)
- End Sub
-
- Private Sub CargaProveedor(ByVal CveProveedor As Integer, RFC As String)
- Dim ObjProveedor As New ClsCompProveedores()
-
-
- If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
- If ObjProveedor.DtResultados.Rows.Count > 0 Then
- TxtPagueseA.Text = ObjProveedor.RazonSocial
- TxtNotificarA.Text = ObjProveedor.NotificarA.Trim
- Else
- Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
- End If
- End If
- ObjProveedor.Dispose()
-
- End Sub
Private Sub CargaPlantillas(TipoPlantilla As Integer)
- 'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
- 'GvPlantillas.DataBind()
+
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
DdlPlantilla.DataBind()
DdlPlantilla.Items.Insert(0, New ListItem("Seleccione", "-1"))
@@ -227,14 +215,6 @@ Partial Class Bancos_PolizaCheque
DdlCuenta.Items.Clear()
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
-
-
-
-
- 'If DdlTipoTransaccion.SelectedValue.ToEntero = 3 Then
- ' dt = dt.FiltraParametros("CveTipoCuenta = 7")
- 'End If
-
'cuando es layout
If DdlTipoTransaccion.SelectedValue.ToEntero = 9 Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1))
@@ -247,9 +227,6 @@ Partial Class Bancos_PolizaCheque
dt = dt.FiltraParametros("UsaLayoutGrupos = 1")
End If
-
-
-
DdlCuenta.DataSource = dt 'GlobalDTBancosCuentas(UsuarioActual.CveUsuario)
DdlCuenta.DataBind()
DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
@@ -262,31 +239,13 @@ Partial Class Bancos_PolizaCheque
DdlTipoTransaccion.DataBind()
End Sub
- 'Private Sub CargaProyecto()
- ' DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa)
- ' DdlProyecto.DataBind()
- 'End Sub
-
- 'Private Sub CargaSubProyecto()
- ' DdlSubProyecto.Items.Clear()
- ' DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero)
- ' DdlSubProyecto.DataBind()
- ' DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
- 'End Sub
-
-
- 'Protected Sub DdlProyectoAsignado_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
- ' CargaSubProyecto()
- 'End Sub
-
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
- 'CargaFolio()
+
CargaCuenta()
End Sub
Private Sub CargaFolio()
If HdnTipoTransaccion.Value = "" Then CargaHdnTipoTransaccion()
- 'If HdnTipoTransaccion.Value = "Egs" Then
If DdlTipoTransaccion.SelectedValue.ToEntero > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
If UsuarioActual.CveEmpresa = 119 AndAlso IfNull(Request("Tipo"), "") = "Ing" Then
Dim ObjFolios As New ClsGralFolios
@@ -305,10 +264,8 @@ Partial Class Bancos_PolizaCheque
TxtFolio.Text = Folio.ToString
End If
End If
- 'Else
- 'TxtFolio.Text = ""
- 'End If
+
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
If dr IsNot Nothing Then
CveMoneda = dr("CveMoneda").ToString.ToEntero
@@ -335,11 +292,6 @@ Partial Class Bancos_PolizaCheque
Public Shared Function wsGetCuentas(ByVal prefixText As String, ByVal count As Integer) As String()
-
- 'Dim dt As DataTable = CType(Session("DtCuentas"), DataTable)
- 'Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
- 'dt = Conta.getCuentasCheque(Prefijo)
- 'Conta.Dispose()
Dim items As New List(Of String)(count)
Dim dbrows As DataRow()
@@ -371,6 +323,21 @@ Partial Class Bancos_PolizaCheque
End Function
Protected Sub DdlPlantilla_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPlantilla.SelectedIndexChanged
+
+ DdlPersonal.SelectedValueExist(-1)
+ DdlProveedores.txtText.Value = "Seleccione"
+ DdlProveedores.txtValue.Value = "-1"
+ TxtPagueseA.Text = ""
+
+
+ If DdlPlantilla.SelectedValue.ToEntero = 56 Then
+ DdlProveedores.Visible = False
+ DdlPersonal.Visible = True
+ Else
+ DdlProveedores.Visible = True
+ DdlPersonal.Visible = False
+ End If
+
Dim IdCtaFondoGarantia As Integer
If ViewState("CveProveedor").ToString.ToEntero > 0 Then
@@ -418,64 +385,62 @@ Partial Class Bancos_PolizaCheque
CodigoCuenta = ""
NombreCuenta = ""
- If UsuarioActual.Empresa.UsaContabilidad Then
- If UsuarioActual.Empresa.TipoContabilidad = 1 AndAlso drt("CveCuenta").ToString.ToEntero > 0 Then
- Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", drt("CveCuenta").ToString))
+ If UsuarioActual.Empresa.TipoContabilidad = 1 AndAlso drt("CveCuenta").ToString.ToEntero > 0 Then
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", drt("CveCuenta").ToString))
+
+ If drr IsNot Nothing Then
+ CveCuenta = drt("CveCuenta").ToString.ToEntero
+ CodigoCuenta = drr("CuentaFormato").ToString()
+ NombreCuenta = drr("Nombre").ToString()
+
+ End If
+ EsComodin = 0
+ End If
+ If UsuarioActual.Empresa.TipoContabilidad = 2 Then
+ If drt("IdCtaContable").ToString.ToEntero > 0 Then 'DtCuentasContables
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", drt("IdCtaContable").ToString))
If drr IsNot Nothing Then
- CveCuenta = drt("CveCuenta").ToString.ToEntero
+ IdCuenta = drt("IdCtaContable").ToString.ToEntero
CodigoCuenta = drr("CuentaFormato").ToString()
NombreCuenta = drr("Nombre").ToString()
- 'Cuenta = drr("Nombre").ToString()
+
End If
EsComodin = 0
- End If
- If UsuarioActual.Empresa.TipoContabilidad = 2 Then
- If drt("IdCtaContable").ToString.ToEntero > 0 Then 'DtCuentasContables
- Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", drt("IdCtaContable").ToString))
+
+ ElseIf drt("CveConcepto").ToString = "30" Then
+ 'saco la clave de la cuenta bancaria seleccionada
+ If DdlCuenta.SelectedValue.ToEntero > 0 And drt("CveConcepto").ToString = "30" Then 'DtCuentasContables
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCuentaBancos(DdlCuenta.SelectedValue.ToEntero)))
If drr IsNot Nothing Then
- IdCuenta = drt("IdCtaContable").ToString.ToEntero
+ IdCuenta = drr("Id").ToString.ToEntero
CodigoCuenta = drr("CuentaFormato").ToString()
NombreCuenta = drr("Nombre").ToString()
- 'Cuenta = drr("Nombre").ToString()
+ EsComodin = 1
End If
- EsComodin = 0
-
-
- ElseIf drt("CveConcepto").ToString = "30" Then
- 'saco la clave de la cuenta bancaria seleccionada
- If DdlCuenta.SelectedValue.ToEntero > 0 And drt("CveConcepto").ToString = "30" Then 'DtCuentasContables
- Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCuentaBancos(DdlCuenta.SelectedValue.ToEntero)))
- If drr IsNot Nothing Then
- IdCuenta = drr("Id").ToString.ToEntero
- CodigoCuenta = drr("CuentaFormato").ToString()
- NombreCuenta = drr("Nombre").ToString()
- ' Cuenta = drr("Nombre").ToString()
- EsComodin = 1
- End If
- End If
- ElseIf drt("CveConcepto").ToString.ToEntero = 135 And IdCtaFondoGarantia > 0 Then
-
- Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCtaFondoGarantia))
-
- IdCuenta = IdCtaFondoGarantia
- CodigoCuenta = drr("CuentaFormato").ToString()
- NombreCuenta = drr("Nombre").ToString()
- 'Cuenta = drr("Nombre").ToString()
-
- EsComodin = 0
End If
+ ElseIf drt("CveConcepto").ToString.ToEntero = 135 And IdCtaFondoGarantia > 0 Then
+
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCtaFondoGarantia))
+
+ IdCuenta = IdCtaFondoGarantia
+ CodigoCuenta = drr("CuentaFormato").ToString()
+ NombreCuenta = drr("Nombre").ToString()
+
+
+ EsComodin = 0
End If
End If
+
Dim dr As DataRow = DtMovimientos.NewRow
dr("IdCuenta") = IdCuenta
dr("CveCuenta") = CveCuenta
dr("CodigoCuenta") = CodigoCuenta & " " & NombreCuenta
- dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
+ dr("Cuenta") = Cuenta
dr("RazonSocial") = drt("RazonSocial")
dr("Concepto") = TxtObservaciones.Text
dr("TipoMovto") = If(drt("TipoMovto").ToString = "False", 0, 1)
@@ -487,7 +452,7 @@ Partial Class Bancos_PolizaCheque
dr("Proyecto") = drt("Proyecto")
dr("Personal") = drt("Personal")
dr("CvePersonal") = drt("CvePersonal")
- 'dr("CveConcepto") = drt("CveConcepto")
+
DtMovimientos.Rows.Add(dr)
@@ -582,7 +547,7 @@ Partial Class Bancos_PolizaCheque
GeneraLayout()
End If
- End Sub
+ End Sub
#Region "LAYOUT"
Private Function CreaArchivo() As Boolean
DirectoryExistsCreate(String.Format("{0}Layout", UsuarioActual.Empresa.Ruta))
@@ -706,72 +671,70 @@ Partial Class Bancos_PolizaCheque
End If
Return UCase(Retorno)
- End Function
-
- 'Este metodo es el de las altas
- 'Private Function GeneraLineaLayout(CvePersonal As Integer, ObjPersonal As ClsRH) As String
- ' Dim Retorno As String = ""
-
- ' If ObjPersonal.GetPersonal(CvePersonal, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
- ' Dim TipoRegistro As String = "02" 'Estatico
- ' Dim Nombre As String = GeneraCampo(ObjPersonal.DtResultados(0)("Nombres").ToString, 20)
- ' Dim ApellidoPaterno As String = GeneraCampo(ObjPersonal.DtResultados(0)("APaterno").ToString, 20)
- ' Dim ApellidoMaterno As String = GeneraCampo(ObjPersonal.DtResultados(0)("AMaterno").ToString, 20)
- ' Dim FechaNacimiento As String = ObjPersonal.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("yyyy-MM-dd")
- ' Dim EstadoCivil As String = "S" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
- ' Dim Curp As String = GeneraCampo(ObjPersonal.DtResultados(0)("CURP").ToString, 18)
- ' Dim Sexo As String = GeneraCampo(ObjPersonal.DtResultados(0)("Genero").ToString, 1)
- ' Dim Nacionalidad As String = GeneraCampo("M", 3) 'Requiere cuadre entre nuestra tabla y el catalogo del banco
- ' Dim PaisOrigen As String = "MEX" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
- ' Dim Ocupacion As String = "OFI" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
- ' Dim FechaIngreso As String = ObjPersonal.DtResultados(0)("FechaIngreso").ToString.ToDate.ToString("yyyy-MM-dd")
- ' Dim Calle As String = GeneraCampo(ObjPersonal.DtResultados(0)("Calle").ToString, 50)
- ' Dim NumeroExterior As String = GeneraCampo(ObjPersonal.DtResultados(0)("NumExt").ToString, 8)
- ' Dim NumeroInterior As String = GeneraCampo(ObjPersonal.DtResultados(0)("NumInt").ToString, 8)
- ' Dim Colonia As String = GeneraCampo(ObjPersonal.DtResultados(0)("Colonia").ToString, 30)
- ' Dim CP As String = GeneraCampo(ObjPersonal.DtResultados(0)("CP").ToString, 5)
- ' Dim Poblacion As String = GeneraCampo("MEXICO", 30)
- ' Dim Estado As String = GeneraCampo(ObjPersonal.DtResultados(0)("Estado").ToString, 25)
- ' Dim TelefonoParticular As String = GeneraCampo(ObjPersonal.DtResultados(0)("Telefono").ToString, 10)
- ' Dim TelefonoOficina As String = GeneraCampo(ObjPersonal.DtResultados(0)("Telefono").ToString, 10)
- ' Dim ExtensionOficina As String = "000000" 'No tenemos este campo
- ' Dim Celular As String = GeneraCampo(ObjPersonal.DtResultados(0)("Celular").ToString, 10)
- ' Dim CorreoElectronico As String = GeneraCampo(ObjPersonal.DtResultados(0)("Correo").ToString, 50)
- ' Dim TipoProducto As String = "A0" 'Estatico
- ' Dim SubProducto As String = "245" 'Estatico
- ' Dim CuentaUniversal As String = GeneraCampo("", 2) 'Este valor se captura vacío
- ' Dim TipoCuenta As String = GeneraCampo("A", 2) 'Requiere cuadre entre nuestra tabla y el catalogo del banco
- ' Dim NumeroTDD As String = GeneraCampo("0000" + ObjPersonal.DtResultados(0)("Correo").ToString, 20)
- ' Dim Oficina As String = GeneraCampo(ObjPersonal.DtResultados(0)("Sucursal").ToString, 4)
- ' Dim MontoDisperciones As String = "000000000000000" 'Estatico
- ' Dim NumeroDisperciones As String = "0" 'Estatico
- ' Dim OficinaEntrega As String = "0000" 'Estatico
- ' Dim Beneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("Nombres").ToString, 20)
- ' Dim ApellidoPaternoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("APaterno").ToString, 20)
- ' Dim ApellidoMaternoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("AMaterno").ToString, 20)
- ' Dim ParentescoBeneficiario As String = "SD" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
- ' Dim SexoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("Genero").ToString, 1)
- ' Dim FechaNacimientoBeneficiario As String = ObjPersonal.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("yyyy-MM-dd")
-
- ' Retorno = TipoRegistro + Nombre + ApellidoPaterno + ApellidoMaterno + FechaNacimiento + EstadoCivil + Curp + Sexo + Nacionalidad + PaisOrigen + Ocupacion + FechaIngreso + Calle + NumeroExterior + NumeroInterior +
- ' Colonia + CP + Poblacion + Estado + TelefonoParticular + TelefonoOficina + ExtensionOficina + Celular + CorreoElectronico + TipoProducto + SubProducto + CuentaUniversal + TipoCuenta + NumeroTDD + Oficina +
- ' MontoDisperciones + NumeroDisperciones + OficinaEntrega + Beneficiario + ApellidoPaternoBeneficiario + ApellidoMaternoBeneficiario + ParentescoBeneficiario + SexoBeneficiario + FechaNacimientoBeneficiario
-
- ' End If
-
- ' Return Retorno
- 'End Function
-
+ End Function
+
+ 'Este metodo es el de las altas
+ 'Private Function GeneraLineaLayout(CvePersonal As Integer, ObjPersonal As ClsRH) As String
+ ' Dim Retorno As String = ""
+
+ ' If ObjPersonal.GetPersonal(CvePersonal, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
+ ' Dim TipoRegistro As String = "02" 'Estatico
+ ' Dim Nombre As String = GeneraCampo(ObjPersonal.DtResultados(0)("Nombres").ToString, 20)
+ ' Dim ApellidoPaterno As String = GeneraCampo(ObjPersonal.DtResultados(0)("APaterno").ToString, 20)
+ ' Dim ApellidoMaterno As String = GeneraCampo(ObjPersonal.DtResultados(0)("AMaterno").ToString, 20)
+ ' Dim FechaNacimiento As String = ObjPersonal.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("yyyy-MM-dd")
+ ' Dim EstadoCivil As String = "S" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
+ ' Dim Curp As String = GeneraCampo(ObjPersonal.DtResultados(0)("CURP").ToString, 18)
+ ' Dim Sexo As String = GeneraCampo(ObjPersonal.DtResultados(0)("Genero").ToString, 1)
+ ' Dim Nacionalidad As String = GeneraCampo("M", 3) 'Requiere cuadre entre nuestra tabla y el catalogo del banco
+ ' Dim PaisOrigen As String = "MEX" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
+ ' Dim Ocupacion As String = "OFI" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
+ ' Dim FechaIngreso As String = ObjPersonal.DtResultados(0)("FechaIngreso").ToString.ToDate.ToString("yyyy-MM-dd")
+ ' Dim Calle As String = GeneraCampo(ObjPersonal.DtResultados(0)("Calle").ToString, 50)
+ ' Dim NumeroExterior As String = GeneraCampo(ObjPersonal.DtResultados(0)("NumExt").ToString, 8)
+ ' Dim NumeroInterior As String = GeneraCampo(ObjPersonal.DtResultados(0)("NumInt").ToString, 8)
+ ' Dim Colonia As String = GeneraCampo(ObjPersonal.DtResultados(0)("Colonia").ToString, 30)
+ ' Dim CP As String = GeneraCampo(ObjPersonal.DtResultados(0)("CP").ToString, 5)
+ ' Dim Poblacion As String = GeneraCampo("MEXICO", 30)
+ ' Dim Estado As String = GeneraCampo(ObjPersonal.DtResultados(0)("Estado").ToString, 25)
+ ' Dim TelefonoParticular As String = GeneraCampo(ObjPersonal.DtResultados(0)("Telefono").ToString, 10)
+ ' Dim TelefonoOficina As String = GeneraCampo(ObjPersonal.DtResultados(0)("Telefono").ToString, 10)
+ ' Dim ExtensionOficina As String = "000000" 'No tenemos este campo
+ ' Dim Celular As String = GeneraCampo(ObjPersonal.DtResultados(0)("Celular").ToString, 10)
+ ' Dim CorreoElectronico As String = GeneraCampo(ObjPersonal.DtResultados(0)("Correo").ToString, 50)
+ ' Dim TipoProducto As String = "A0" 'Estatico
+ ' Dim SubProducto As String = "245" 'Estatico
+ ' Dim CuentaUniversal As String = GeneraCampo("", 2) 'Este valor se captura vacío
+ ' Dim TipoCuenta As String = GeneraCampo("A", 2) 'Requiere cuadre entre nuestra tabla y el catalogo del banco
+ ' Dim NumeroTDD As String = GeneraCampo("0000" + ObjPersonal.DtResultados(0)("Correo").ToString, 20)
+ ' Dim Oficina As String = GeneraCampo(ObjPersonal.DtResultados(0)("Sucursal").ToString, 4)
+ ' Dim MontoDisperciones As String = "000000000000000" 'Estatico
+ ' Dim NumeroDisperciones As String = "0" 'Estatico
+ ' Dim OficinaEntrega As String = "0000" 'Estatico
+ ' Dim Beneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("Nombres").ToString, 20)
+ ' Dim ApellidoPaternoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("APaterno").ToString, 20)
+ ' Dim ApellidoMaternoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("AMaterno").ToString, 20)
+ ' Dim ParentescoBeneficiario As String = "SD" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
+ ' Dim SexoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("Genero").ToString, 1)
+ ' Dim FechaNacimientoBeneficiario As String = ObjPersonal.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("yyyy-MM-dd")
+
+ ' Retorno = TipoRegistro + Nombre + ApellidoPaterno + ApellidoMaterno + FechaNacimiento + EstadoCivil + Curp + Sexo + Nacionalidad + PaisOrigen + Ocupacion + FechaIngreso + Calle + NumeroExterior + NumeroInterior +
+ ' Colonia + CP + Poblacion + Estado + TelefonoParticular + TelefonoOficina + ExtensionOficina + Celular + CorreoElectronico + TipoProducto + SubProducto + CuentaUniversal + TipoCuenta + NumeroTDD + Oficina +
+ ' MontoDisperciones + NumeroDisperciones + OficinaEntrega + Beneficiario + ApellidoPaternoBeneficiario + ApellidoMaternoBeneficiario + ParentescoBeneficiario + SexoBeneficiario + FechaNacimientoBeneficiario
+
+ ' End If
+
+ ' Return Retorno
+ 'End Function
+
#End Region
-
-
+
+
Protected Sub GvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMov.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).Width = Unit.Pixel(110)
e.Row.Cells(1).Width = Unit.Pixel(200)
- 'e.Row.Cells(2).Width = Unit.Pixel(150)
- 'e.Row.Cells(3).Width = Unit.Pixel(150)
e.Row.Cells(2).Width = Unit.Pixel(120)
e.Row.Cells(3).Width = Unit.Pixel(303)
e.Row.Cells(4).Width = Unit.Pixel(72)
@@ -806,9 +769,21 @@ Partial Class Bancos_PolizaCheque
Dim TotalCargos, TotalAbonos, ImporteDocumento As Decimal
Dim CvePrePoliza As Integer
+ Dim ValidaConcepto30 As Boolean = False
+
+ Dim PaguesA As String = TxtPagueseA.Text.Trim
+ Dim CveProveedorSeleccionado As Integer = -1
+ Dim CvePersonalSeleccionado As Integer = -1
+
+
+ If DdlPlantilla.SelectedValue.ToEntero = 56 Then
+ CvePersonalSeleccionado = DdlPersonal.SelectedValue.ToEntero
+ Else
+ CveProveedorSeleccionado = DdlProveedores.txtValue.Value.ToEntero
+ End If
+
+
- Dim ValidaConcepto30 As Boolean = False
-
If DdlCuenta.SelectedValue.ToEntero <= 0 Then
If UsuarioActual.CveEmpresa <> 126 Then
Alert("Seleccione la Cuenta Bancaria", TipoMensaje.MsgAdvertencia)
@@ -817,6 +792,7 @@ Partial Class Bancos_PolizaCheque
End If
End If
+
For Each Gvr As GridViewRow In GvMov.Rows
TotalCargos += Gvr.FCTextBox("TxtCargo").Text.ToDecimal
@@ -854,23 +830,13 @@ Partial Class Bancos_PolizaCheque
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
Dim ObjNom As New ClsNominas(ObjIE.IniciaTransacSQL)
- 'Dim Conta As ClsContPAQi = Nothing
Dim IDPoliza As Integer = 0
Dim CveIE As Integer
Dim MsgError As String = ""
Dim idCuentaContabilizacion As Long = 1
- 'If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
- ' Conta = New ClsContPAQi(UsuarioActual.Empresa)
- ' Conta.IniciaTransacSQL()
- ' IDPoliza = Conta.AddPoliza(2, TxtObservaciones.Text, TotalCargos, TotalAbonos, UsuarioActual.CveUsuario, TxtFechaDocumento.Text.ToDate)
- ' 'inserto la póliza
- ' NumPoliza = Conta.Folio
- ' If IDPoliza = 0 Then
- ' MsgError = "No se pudo insertar la póliza contable."
- ' End If
- 'End If
+
If MsgError = "" Then
ImporteDocumento = TxtImporte.Text.ToDecimal
@@ -879,7 +845,7 @@ Partial Class Bancos_PolizaCheque
Try
Dim ConceptoPoliza As String = TxtObservaciones.Text
- If ConceptoPoliza = "" Then ConceptoPoliza = TxtPagueseA.Text
+ If ConceptoPoliza = "" Then ConceptoPoliza = PaguesA
Dim CveMoneda As Integer = 1
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
If dr IsNot Nothing Then
@@ -889,7 +855,7 @@ Partial Class Bancos_PolizaCheque
Dim TC As Decimal = If(CveMoneda > 1, GlobalTipoCambio(TxtFechaDocumento.Text.ToDate), 1)
Dim CveTipoPoliza As Integer = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla).FiltroPrimeroValor("TipoPoliza", String.Format("CvePlantillaPoliza={0}", DdlPlantilla.SelectedValue)).ToEntero
CvePrePoliza = ObjMov.AddPrePolizas("PolizaCheque/Guardar", DdlPlantilla.SelectedValue.ToEntero, TotalCargos, TotalAbonos, 1, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=CveTipoPoliza)
- CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImporteDocumento, CveMoneda, If(CveMoneda > 1, TC, 0.0), TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, PaguesA, ImporteDocumento, CveMoneda, If(CveMoneda > 1, TC, 0.0), TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CveIE > 0 Then
'inserto los movimientos de la conta para abonar al saldo
@@ -901,7 +867,7 @@ Partial Class Bancos_PolizaCheque
Dim Importe As Double = 0
Dim TipoMovto As Boolean = False
Dim IdCtaContable As Integer = 0
- Dim CveProveedor As Integer = -1
+ 'Dim CveProveedor As Integer = -1
'inserto las compras que voy a pagar
For Each gvr As GridViewRow In GvMov.Rows
@@ -917,17 +883,18 @@ Partial Class Bancos_PolizaCheque
Importe = gvr.FCTextBox("TxtCargo").Text.ToDouble
TipoMovto = False
End If
- CveProveedor = gvr.DataKey("CveProveedor").ToEntero
- If HdnCveProveedor.Value.ToEntero > 0 Then CveProveedor = HdnCveProveedor.Value.ToEntero
+
+ If Not CveProveedorSeleccionado > 0 Then
+ CveProveedorSeleccionado = gvr.DataKey("CveProveedor").ToEntero
+ End If
+
+ If Not CvePersonalSeleccionado > 0 Then
+ CvePersonalSeleccionado = gvr.DataKey("CvePersonal").ToEntero
+ End If
If Importe <> 0 Then
- 'If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
- ' If Not Conta.AddMovimiento(IDPoliza, gvr.DataKey("IDCuenta").ToEntero, TipoMovto, Importe, gvr.FCLiteral("LtlReferencia").Text, gvr.FCTextBox("TxtConcepto").Text, 0, TxtFechaDocumento.Text.ToDate, "") Then
- ' MsgError = "No se pudo insertar movimiento contable"
- ' Exit For
- ' End If
- 'End If
+
If MsgError = "" Then
If idCuentaContabilizacion = 1 AndAlso (IdCtaContable = 0) Then
@@ -942,14 +909,14 @@ Partial Class Bancos_PolizaCheque
Importe = Importe * TC
End If
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, Referencia, gvr.DataKey("CveConcepto").ToEntero, TxtObservaciones.Text, Now, gvr.DataKey("IDCuenta").ToEntero, -1, CveIE, CveProveedor:=CveProveedor, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, ImporteMX:=Importe, TipoCambio:=TC, CveCuenta:=gvr.DataKey("CveCuenta").ToEntero) Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, Referencia, gvr.DataKey("CveConcepto").ToEntero, TxtObservaciones.Text, Now, gvr.DataKey("IDCuenta").ToEntero, -1, CveIE, CveProveedor:=CveProveedorSeleccionado, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CvePersonal:=CvePersonalSeleccionado, ImporteMX:=Importe, TipoCambio:=TC, CveCuenta:=gvr.DataKey("CveCuenta").ToEntero) Then
MsgError = "no se pudo insertar el detalle de la póliza2"
End If
If gvr.DataKey("CveConcepto").ToEntero = 30 Then
If CveMoneda > 1 AndAlso UsuarioActual.CveEmpresa = 119 Then
'Agregamos complementaria
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, 0, gvr.FCTextBox("TxtConcepto").Text, 204, TxtObservaciones.Text, Now, dr("IDCtaContableComplementaria").ToString.ToEntero, -1, CveIE:=CveIE, CveProveedor:=CveProveedor, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, ImporteMX:=Importe * TC - Importe, ImporteME:=Importe, TipoCambio:=TC) Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, 0, gvr.FCTextBox("TxtConcepto").Text, 204, TxtObservaciones.Text, Now, dr("IDCtaContableComplementaria").ToString.ToEntero, -1, CveIE:=CveIE, CveProveedor:=CveProveedorSeleccionado, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CvePersonal:=CvePersonalSeleccionado, ImporteMX:=Importe * TC - Importe, ImporteME:=Importe, TipoCambio:=TC) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
End If
@@ -973,8 +940,6 @@ Partial Class Bancos_PolizaCheque
MsgError = "No se pudo actualizar el periodo de la nómina"
End If
- 'Generamos el Layout
- 'GeneraLayout()
End If
Else
@@ -992,7 +957,6 @@ Partial Class Bancos_PolizaCheque
If MsgError = "" Then
If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then
If ObjMov.ValorPolizaDescuadre > 0 Then
- ' MsgError = ObjMov.MensajePolizaDescuadre
GuardaLogAD($"PolizaCheque/Guardar Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
End If
Else
@@ -1004,7 +968,6 @@ Partial Class Bancos_PolizaCheque
If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" Then
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
- 'Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion)
IDPoliza = ObjMov.ContaIdPoliza
Else
MsgError = "Error al contabilizar"
@@ -1017,7 +980,6 @@ Partial Class Bancos_PolizaCheque
If MsgError = "" Then
ObjIE.Commit()
- 'If Conta IsNot Nothing Then Conta.Commit()
If filemove <> "" Then
filemove.FilesMove(CveIE.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
@@ -1046,145 +1008,26 @@ Partial Class Bancos_PolizaCheque
Else
Alert(MsgError.ToString, TipoMensaje.MsgError)
ObjIE.RollBack()
- 'If Conta IsNot Nothing Then Conta.RollBack()
+
End If
Else
Alert("Debe de llevar un importe", TipoMensaje.MsgAdvertencia)
- 'If Conta IsNot Nothing Then Conta.RollBack()
+
End If
- Else
- 'If Conta IsNot Nothing Then Conta.RollBack()
+
+
End If
ObjIE.Dispose()
ObjMov.Dispose()
ObjNom.Dispose()
- 'If Conta IsNot Nothing Then Conta.Dispose()
+
Else
Alert("La suma de los movimientos no son iguales", TipoMensaje.MsgAdvertencia)
End If
End Sub
- '' -------------------------------------- codigo para generar la poliza del cheque
-
- 'If pIDPoliza > 0 Then
- 'Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa)
-
- ' If ObjPoliza.GetPoliza(pIDPoliza, -1, -1, -1, -1) Then
- ' dtMovs = ObjPoliza.DtResultados
- ' End If
- ' ObjPoliza.Dispose()
-
- ' ''Movimientos Póliza
- ' If dtMovs IsNot Nothing Then
-
- 'Dim TotalAbonos, TotalCargos As Double
- ' TotalAbonos = 0 : TotalCargos = 0
- ' For Each Row As DataRow In dtMovs.Rows
- ''Cantidad
- ''If Row("AplicaParaConcepto").ToString.ToEntero > 0 Then
- ' Hoja.Range("B" & CeldaF & ": B" & CeldaF).Value = Row("CuentaFormato").ToString
- ''Unidad
- ''If Row("AplicaParaConcepto").ToString.ToEntero > 0 Then
- ' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Value = Row("Nombre").ToString
- ''Concepto y Descripción
- ' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = If(Row("Cargo").ToString.ToDouble > 0, Row("Cargo").ToString.ToDouble.FormatoNumero, "")
- ''P Unitario
- ''Morro el precio unitario si va a ir?
- ' Hoja.Range("G" & CeldaF & ":G" & CeldaF).Value = If(Row("Abono").ToString.ToDouble > 0, Row("Abono").ToString.ToDouble.FormatoNumero, "")
-
- ' TotalCargos += Row("Cargo").ToString.ToDouble
- ' TotalAbonos += Row("Abono").ToString.ToDouble
-
- ' If dtMovs.Rows.Count > 1 AndAlso CeldaF - CeldaI < dtMovs.Rows.Count - 1 Then
- ' CeldaF = CeldaF + 1
- ' Libro.Application.Run("AddRow", (CeldaF - 1).ToString, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
- ' missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
- ' Libro.Save()
- ' Libro.Application.DisplayAlerts = False
- ' Libro.Application.ScreenUpdating = False
- ' End If
-
- ' Next
-
- 'Dim AddedRow As Integer = CeldaF - CeldaI
-
- ' Hoja.Range("F" & (50 + AddedRow).ToString & ":F" & (50 + AddedRow).ToString).Value = TotalCargos.FormatoNumero
- ' Hoja.Range("G" & (50 + AddedRow).ToString & ":G" & (50 + AddedRow).ToString).Value = TotalAbonos.FormatoNumero
- ' Hoja.Range("C" & (52 + AddedRow).ToString & ":C" & (52 + AddedRow).ToString).Value = UsuarioRegistro
- ''Hoja.Range("E" & (13 + AddedRow).ToString & ":E" & (13 + AddedRow).ToString).Value = LblAmortizacion.Text.Trim.ToDouble(TC).FormatoNumero
- ''Hoja.Range("E" & (14 + AddedRow).ToString & ":E" & (14 + AddedRow).ToString).Value = TxtSubTotal2.Text.Trim.ToDouble(TC).FormatoNumero
- ''Hoja.Range("E" & (15 + AddedRow).ToString & ":E" & (15 + AddedRow).ToString).Value = TxtIVA.Text.Trim.ToDouble(TC).FormatoNumero
-
-
- ' End If
- ' End If
-
-
- 'Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs) Handles LnkAgregar.Click
- ' If HdnCveCuenta.Value.ToEntero = 0 Then
- ' Alert("Seleccione una cuenta contable")
- ' Exit Sub
- ' End If
-
- ' If TxtCargoImporte.Text = "" AndAlso TxtAbonoImporte.Text = "" Then
- ' Alert("Ingrese un importe.")
- ' Exit Sub
- ' End If
-
- ' If HdnCveCuenta.Value.ToEntero > 0 AndAlso (TxtCargoImporte.Text.ToDouble > 0 Or TxtAbonoImporte.Text.ToDouble > 0) Then
-
- ' Dim Cuenta As String = ""
- ' Dim CodigoCuenta As String = ""
- ' If DdlCuentaContable.SelectedValue.ToEntero > 0 Then 'DtCuentasContables
- ' Dim drr As DataRow = DtCuentasContables.FiltroPrimero("Id=" & DdlCuentaContable.SelectedValue)
- ' If drr IsNot Nothing Then
- ' CodigoCuenta = drr("CuentaFormato").ToString()
- ' Cuenta = drr("Nombre").ToString()
- ' End If
- ' End If
-
- ' Dim dr As DataRow = DtMovimientos.NewRow
- ' dr("IdCuenta") = HdnCveCuenta.Value.ToEntero
- ' dr("CodigoCuenta") = CodigoCuenta
- ' dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
- ' dr("Referencia") = TxtReferencia.Text
- ' dr("Concepto") = TxtConceptoContable.Text
- ' dr("Cargo") = TxtCargoImporte.Text.ToDouble
- ' dr("Abono") = TxtAbonoImporte.Text.ToDouble
-
- ' DtMovimientos.Rows.Add(dr)
-
- ' TxtTotalAbonos.Text = DtMovimientos.SUM("Abono").FormatoNumero
- ' TxtTotalCargos.Text = DtMovimientos.SUM("Cargo").FormatoNumero
-
- ' 'ArregloMovs.Add(Mov)
- ' GvMov.DataSource = DtMovimientos
- ' GvMov.DataBind()
-
- ' 'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
- ' If DdlCuenta.SelectedValue.ToEntero > 0 Then
- ' Dim drr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta=" & DdlCuenta.SelectedValue)
- ' If drr IsNot Nothing Then
- ' TxtImporte.Text = (DtMovimientos.SUM("Abono", "IdCuenta =" & drr("IdCtaContable").ToString) - DtMovimientos.SUM("Cargo", "IdCuenta =" & drr("IdCtaContable").ToString)).ToString.FormatoNumero
- ' UPPDocumento.Update()
- ' End If
- ' End If
-
- ' HdnCveCuenta.Value = "0"
- ' DdlCuentaContable.SelectedValue = "0"
-
- ' TxtReferencia.Text = ""
- ' TxtConceptoContable.Text = ""
- ' TxtCargoImporte.Text = ""
- ' TxtAbonoImporte.Text = ""
-
- ' End If
-
- 'End Sub
-
-
Protected Sub GvMov_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvMov.RowDeleting
@@ -1226,9 +1069,28 @@ Partial Class Bancos_PolizaCheque
End If
End If
Return Retorno
- End Function
+ End Function
+
+
+ Protected Sub CargaDDLPersonal()
+ DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
+ DdlPersonal.DataBind()
+ DdlPersonal.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End Sub
+
+ Protected Sub DdlPersonal_SelectedIndexChanged(sender As Object, e As EventArgs)
+ TxtPagueseA.Text = DdlPersonal.SelectedItem.Text
+ UPPDocumento.Update()
+ End Sub
+
+
+
+ Protected Sub DdlProveedores_selectedindexchange(sender As Object, e As EventArgs)
+ TxtPagueseA.Text = DdlProveedores.txtText.Value
+ UPPDocumento.Update()
+ End Sub
End Class
diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb
index 6d219e9f4..9c608cf81 100644
--- a/Bancos/PopIECompras.aspx.vb
+++ b/Bancos/PopIECompras.aspx.vb
@@ -637,6 +637,7 @@ Partial Class Bancos_PopIECompras
CompraActual.IdCtaContableProv = CtaProveedor
CompraActual.IdCtaContableProvComplementaria = IdCtaProveedorExtranjera
CompraActual.EsImportacion = CBool(dr("EsImportacion"))
+ CompraActual.CompraNoDeducible = dr("NoDeducible").ToString.ToEntero
If Validada Then
TxtFolio.Enabled = True
@@ -1606,23 +1607,10 @@ Partial Class Bancos_PopIECompras
End Select
Dim ObjConta As ClsContPAQi = Nothing
- If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then
+ If MsgError = "" AndAlso ObjMov.ValidacionesPrePoliza(CvePrePoliza, 5, UsuarioActual) Then
If ObjMov.ValorPolizaDescuadre > 0 Then
MsgError = ObjMov.MensajePolizaDescuadre
GuardaLogAD($"Bancos/PopIECompras | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
- Else
- If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
- If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
- ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
- ObjConta.IniciaTransacSQL()
- End If
- If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjConta) Then
- IdPoliza = ObjMov.ContaIdPoliza
- Else
- Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
- MsgError = "Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico"
- End If
- End If
End If
End If
diff --git a/Bancos/ProveedoresAbonar.aspx b/Bancos/ProveedoresAbonar.aspx
index 412f0db79..ea7236cd2 100644
--- a/Bancos/ProveedoresAbonar.aspx
+++ b/Bancos/ProveedoresAbonar.aspx
@@ -369,7 +369,7 @@
diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb
index 7dd4fa5af..152534d86 100644
--- a/Bancos/ProveedoresAbonar.aspx.vb
+++ b/Bancos/ProveedoresAbonar.aspx.vb
@@ -687,18 +687,15 @@ Partial Class Bancos_ProveedoresAbonar
Validada = False
If Valida.EsValida = 2 Then 'Cancelada
-
'estatus inventario, no surtida
If gvr.DataKey("EstatusInventario") = "1" Then
MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1} , relacione su factura nueva para descontar saldo ", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
Else
MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1} con movimientos de almacen, relacione su factura nueva para descontar saldo ", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
End If
-
Else
MsgValidadas.AppendFormat("Factura No se pudo Validar: {0} - {1} ", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
End If
-
End If
End If
End If
@@ -767,7 +764,6 @@ Partial Class Bancos_ProveedoresAbonar
Dim FolioFijo As Integer = 0
Dim TipoCambio As Decimal = 0
-
'cheque
If DdlTipoTransaccion.SelectedValue = "1" AndAlso UsuarioActual.CveEmpresa.Contiene(13, 83) Then FolioFijo = TxtFolio.Text.ToEntero
@@ -799,7 +795,6 @@ Partial Class Bancos_ProveedoresAbonar
If Not ObjGrales.UpdateCuentasDepositosEstatusPagoElectronicoGrupos(DdlCuentaDeposito.SelectedValue.ToEntero, -1, -1, "-1", TxtReferenciaCIE.Text.Trim, TxtConceptoCIE.Text.Trim) Then
MsgError = "Error al actualziar Cuanta Referencia y Concepto Deposito."
End If
-
End If
End If
@@ -834,6 +829,8 @@ Partial Class Bancos_ProveedoresAbonar
CompraActual.Total = gvr.DataKey("Total").ToDecimal
CompraActual.IVA = gvr.DataKey("IVA").ToDecimal
CompraActual.IVADeducible = gvr.DataKey("IVADeducible").ToDecimal
+ CompraActual.IVANoDeducible = gvr.DataKey("IVANoDeducible").ToDecimal
+ CompraActual.CompraNoDeducible = gvr.DataKey("NoDeducible").ToEntero
CompraActual.IEPS = gvr.DataKey("IEPS").ToDecimal
CompraActual.RetIVA = gvr.DataKey("RetIVA").ToDecimal
CompraActual.RetISR = gvr.DataKey("RetISR").ToDecimal
@@ -843,15 +840,15 @@ Partial Class Bancos_ProveedoresAbonar
CompraActual.EsImportacion = gvr.DataKey("EsImportacion") = "1"
CompraActual.UsuarioActual = UsuarioActual
CompraActual.CveSubProyecto = gvr.DataKey("CveSubProyecto").ToEntero
+
CompraActual.IdCtaContableProv = If(CompraActual.CveMoneda >= 2, IdCtaProveedorExtranjera, CtaProveedor)
CompraActual.IdCtaContableProvComplementaria = IdCtaContComplementaria
-
'Importe de pago
Pago.ImportePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
-
'Tipos de cambio
If Pago.CveMonedaPago = 1 AndAlso CompraActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
- Pago.TCPago = TxtTC.Text.ToDecimal
+ Pago.TCPago = 1 ' TxtTC.Text.ToDecimal
+ Pago.ImportePago = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TxtTC.Text.ToDecimal).RoundSQL
ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
Pago.TCPago = TxtTCDolaresDolares.Text.ToDecimal
ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActual.CveMoneda = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
@@ -1107,7 +1104,7 @@ Partial Class Bancos_ProveedoresAbonar
If IDPoliza > 0 AndAlso UsuarioActual.Empresa.TipoContabilidad = 2 Then Msg.AppendFormat(" Póliza ", IDPoliza)
If UsuarioActual.TienePermisoProceso(354) Then 'visualizar la póliza al registros
- Msg.AppendFormat("
Ver Póliza ", CvePrePoliza)
+ Msg.AppendFormat("Ver Póliza ", CvePrePoliza)
End If
Dim Mensaje As String = String.Format("El Documento se generó correctamente.
{0} ", Msg.ToString)
@@ -1516,7 +1513,6 @@ Partial Class Bancos_ProveedoresAbonar
#Region " NOTIFICACION PAGO "
-
Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean)
Try
@@ -1555,263 +1551,8 @@ Partial Class Bancos_ProveedoresAbonar
GuardaLog("Error al enviar notificación de pago ProveedoresAbonar --> " & ex.StackTrace.ToString)
End Try
-
-
End Sub
-
-
- 'Private Sub NotificacionPago(CveIE As Integer, CorreoNotificarA As String)
-
- ' If Not DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(9, 17) Then
-
- ' Dim Body As String = GeneraCorreo(CveIE)
- ' Dim Comprobante = If(ComprobanteIE <> "", String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ComprobanteIE), "") 'Archivo Adjunto
-
- ' Dim File As Byte() = Nothing
- ' If UsuarioActual.Empresa.Funcionalidad(545).ToEntero > 0 Then
- ' File = NewGeneraBytesCxP(CveProveedor, UsuarioActual.Nombre)
- ' End If
-
- ' Dim Hilo As New Threading.Thread(Sub() MandaCorreo(CorreoNotificarA, "Notificaciones de pago", Body, CveIE, Comprobante, File))
- ' Hilo.Start()
- ' End If
-
- 'End Sub
-
- 'Private Sub MandaCorreo(Para As String, Asunto As String, Body As String, CveIE As Integer, Comprobante As String, File As Byte())
- ' 'Dim Parametros As List(Of String) = DirectCast(Data, List(Of String))
-
- ' Dim Mail As New ClsSisMail()
- ' Para = If(Para IsNot Nothing, Para, "")
- ' Asunto = If(Asunto IsNot Nothing, Asunto, "")
- ' Body = If(Body IsNot Nothing, Body, "")
-
- ' Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail)
- ' If Comprobante IsNot Nothing AndAlso Comprobante <> "" Then
- ' ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = Comprobante})
- ' End If
-
- ' If File IsNot Nothing Then
- ' ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = File, .NombreArchivo = "EstadoCuentaCxP.pdf"})
- ' End If
-
- ' If Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, Archivos:=ListaArchivos) Then
- ' Dim objIE As New ClsBancos
- ' objIE.UpdateBancos_IENotificaciones(1, "-1", "-1", CveIE)
- ' objIE.Dispose()
- ' End If
- 'End Sub
-
- 'Private Function GeneraCorreo(CveIE As Integer) As String
- ' Dim strBody As New StringBuilder
- ' Dim objIE As New ClsBancos
-
- ' If objIE.GetBancosIE(CveIE, UsuarioActual.CveEmpresa) Then
- ' strBody.Append(" ")
- ' strBody.Append(" ")
- ' strBody.Append(" ")
- ' strBody.Append(" ")
- ' strBody.Append(" ")
- ' strBody.AppendFormat("
")
-
-
- ' 'MOVIMIENTOS CHEQUE
- ' If objIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then
- ' Dim Textov33 As String = ""
- ' If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then
- ' Textov33 = "Favor de emitir complemento de pago de los siguientes documentos"
- ' End If
-
- ' strBody.AppendFormat("
")
-
- ' strBody.Append("")
- ' End If
-
- ' objIE.Dispose()
- ' Return strBody.ToString
- 'End Function
-
#End Region
#Region "SALDAR CUENTAS"
@@ -1950,31 +1691,17 @@ Partial Class Bancos_ProveedoresAbonar
End If
Next
-
-
If MsgError.Trim.Length = 0 AndAlso CvePrePoliza > 0 Then
- If MsgError = "" AndAlso ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then
+ If MsgError = "" AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, 5, UsuarioActual) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia
GuardaLogAD($"Bancos/ProveedoresAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
- Else
- If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
-
- If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
- ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion)
- Else
- 'Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
- MsgError = "Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico"
- End If
-
- End If
End If
End If
End If
-
If MsgError = "" Then
ObjConta.Commit()
CargaDatos(CveMoneda)
diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx
index d628b144e..8ff5dbd78 100644
--- a/Compras/Compras.aspx
+++ b/Compras/Compras.aspx
@@ -1,8 +1,6 @@
<%@ Page Title="Compras - Registro de Facturas" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" ValidateRequest="false" CodeFile="Compras.aspx.vb" Inherits="Compras_Compras" EnableEventValidation="false" %>
-
-
-
+
@@ -284,9 +282,7 @@
diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb
index 30fc968ec..cbeea38ae 100644
--- a/Compras/Compras.aspx.vb
+++ b/Compras/Compras.aspx.vb
@@ -11,6 +11,7 @@ Imports Newtonsoft.Json
Imports Extensiones
Imports MoreLinq
+
Partial Class Compras_Compras
Inherits ClsPaginas
@@ -1041,6 +1042,11 @@ Partial Class Compras_Compras
End Property
Private Property RetIVAOriginal As Double
Get
+
+ If ViewState("RetIVAOriginal") Is Nothing Then
+ ViewState("RetIVAOriginal") = 0
+ End If
+
Return ViewState("RetIVAOriginal").ToString.ToDouble
End Get
Set(value As Double)
@@ -1049,6 +1055,10 @@ Partial Class Compras_Compras
End Property
Private Property RetISROriginal As Double
Get
+ If ViewState("RetISROriginal") Is Nothing Then
+ ViewState("RetISROriginal") = 0
+ End If
+
Return ViewState("RetISROriginal").ToString.ToDouble
End Get
Set(value As Double)
@@ -1056,15 +1066,15 @@ Partial Class Compras_Compras
End Set
End Property
- Private Property TotalOriginal As Double
+ Private Property TotalOriginal As Decimal
Get
If ViewState("TotalOriginal") Is Nothing Then
Return 0
Else
- Return ViewState("TotalOriginal").ToString.ToDouble
+ Return ViewState("TotalOriginal").ToString.ToDecimal
End If
End Get
- Set(value As Double)
+ Set(value As Decimal)
ViewState("TotalOriginal") = value
End Set
End Property
@@ -1090,12 +1100,10 @@ Partial Class Compras_Compras
ViewState("EmpresasOC") = value
End Set
End Property
-
Private Property DtPendientesAlmacen As DataTable
Get
DtPendientesAlmacen = DirectCast(ViewState("DtPendientesAlmacen"), DataTable)
End Get
-
Set(ByVal value As DataTable)
ViewState("DtPendientesAlmacen") = value
End Set
@@ -1109,19 +1117,12 @@ Partial Class Compras_Compras
ViewState("CveTipoConcepto") = value
End Set
End Property
-
-
-
-
Private Property CveRetISRConceptoOriginal As Integer
Get
-
If ViewState("CveRetISRConceptoOriginal") Is Nothing Then
ViewState("CveRetISRConceptoOriginal") = -1
End If
-
Return ViewState("CveRetISRConceptoOriginal").ToString.ToEntero
-
End Get
Set(value As Integer)
ViewState("CveRetISRConceptoOriginal") = value
@@ -1140,7 +1141,6 @@ Partial Class Compras_Compras
End Property
Public Property FechaCompraOriginal As Date
-
Get
Return ViewState("FechaCompraOriginal").ToString.ToDate
End Get
@@ -1152,7 +1152,6 @@ Partial Class Compras_Compras
Private Property UUIDSList As List(Of String)
Get
-
If ViewState("UUIDSList") Is Nothing Then
Return New List(Of String)
Else
@@ -1168,7 +1167,6 @@ Partial Class Compras_Compras
Private Property NumeroReembolsoOriginal As String
Get
-
If ViewState("NumeroReembolsoOriginal") Is Nothing Then
ViewState("NumeroReembolsoOriginal") = ""
End If
@@ -1178,13 +1176,10 @@ Partial Class Compras_Compras
Set(value As String)
ViewState("NumeroReembolsoOriginal") = value
End Set
-
-
End Property
Private Property EsDevolucionApoyoLogistico As Boolean
Get
-
If ViewState("EsDevolucionApoyoLogistico") Is Nothing Then
ViewState("EsDevolucionApoyoLogistico") = False
End If
@@ -1197,21 +1192,16 @@ Partial Class Compras_Compras
Private Property TipoCompraOriginal As Integer
Get
-
If ViewState("TipoCompraOriginal") Is Nothing Then
ViewState("TipoCompraOriginal") = -1
End If
-
Return ViewState("TipoCompraOriginal").ToString.ToEntero
-
End Get
Set(value As Integer)
ViewState("TipoCompraOriginal") = value
End Set
End Property
-
-
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip")
@@ -1242,12 +1232,6 @@ Partial Class Compras_Compras
btnProrateo2.Visible = True
End If
- '****************************************************************
- 'If UsuarioActual.CveEmpresa = 72 Then
- ' LiRecepcion.Visible = True
- ' DdlRecepcion.SelectedValue = "2"
- 'End If
-
TipoCambio = 1
IvaAcumulado = 0
TotalAlmacen = 0
@@ -1261,7 +1245,7 @@ Partial Class Compras_Compras
ListaDocumentos = New List(Of String)
TotalGeneral = 0
- CompraSaldo = 0
+ CompraSaldo = 0
ViewState("CvePersonal") = -1
IdCuentaBancaria = 0
@@ -1306,8 +1290,6 @@ Partial Class Compras_Compras
TieneOC = False
CveMoneda = -1
-
-
ImgAnticiposPendientes.Attributes.Add("OnClick", "MuestraAnticipos();")
'ImgCerrar.Attributes.Add("OnClick", "$('#DivAnticipos').hide(200);")
'BtnCancelar.Attributes.Add("OnClick", "$('#DivAddEq').hide();")
@@ -1320,7 +1302,6 @@ Partial Class Compras_Compras
RBLPago.Visible = True
If UsuarioActual.Empresa.UsaAC Then RBLPago.Items.RemoveAt(2) 'Elimina Reembolso cuando es AC
-
If UsuarioActual.Empresa.UsaAC Then
TrReembolso.Visible = True
GvPS.Columns(1).Visible = True
@@ -1329,13 +1310,10 @@ Partial Class Compras_Compras
TxtOC.Attributes.Add("onkeypress", "fncBuscaOC(event);")
-
-
If UsuarioActual.CveEmpresa = 66 And UsuarioActual.TienePermisoProceso(96) Then
ChkProgramarPago.Visible = True
End If
-
'CARGA PERSONAL
'Dim ObjPersonal As New ClsRH
'ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa)
@@ -1363,7 +1341,6 @@ Partial Class Compras_Compras
End If
-
'Carga Proveedor
If Request("CveProveedor") IsNot Nothing AndAlso IsNumeric(Request("CveProveedor")) AndAlso Request("CveProveedor").ToEntero > 0 Then
ViewState("CveProveedor") = Request("CveProveedor")
@@ -1399,7 +1376,6 @@ Partial Class Compras_Compras
InicializaAplicaNCFact()
DivReembolso.Visible = False
RBLPago.Items(2).Enabled = False
-
End If
If DdlTipoComprobante.SelectedValue = "DEV" Then
@@ -1410,8 +1386,6 @@ Partial Class Compras_Compras
CambiaEjercicioAC()
End If
-
-
If UsuarioActual.Empresa.Funcionalidad(123) <> "" And Not UsuarioActual.TienePermisoProceso(156) Then
If Not ValidaCierrePeriodo() Then
Alert("El periodo de la compra actual ya se encuentra cerrado. No podra registrar la compra.", TipoMensaje.MsgAdvertencia)
@@ -1454,20 +1428,13 @@ Partial Class Compras_Compras
ViewState("CveCompra") = Request("CveCompra")
CargaCompra()
BtnGuardar.Enabled = False
- 'TdIVA.Visible = True
- 'DdlIVA.Enabled = False
-
DivConsignaciones.Visible = False
-
' 2018/05/25 - Muestra Boton Agregar Guia
LnkAgregarGuia.Visible = True
UpLnkPaqueteriaGuias.Update()
DivEsNoDeducible.Visible = True
DivActualizarVincular.Visible = True
-
DVModalAnticipoFechaEjecucion.Visible = True
-
-
Else
ViewState("CveProveedor") = -1
@@ -1617,14 +1584,11 @@ Partial Class Compras_Compras
divDevAuto.Visible = True
End If
-
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
GVAnticipos.Columns(6).Visible = True
DVAntComiciones.Visible = True
End If
-
-
If DdlTipoComprobante.SelectedValue = "NC" Then
NCSeleccionFacturasRelacionadas(UUIDSList)
End If
@@ -1634,7 +1598,6 @@ Partial Class Compras_Compras
DdlTipoComprobante.Items.Clear()
DdlTipoComprobante.Items.Add(New ListItem("Devolución", "DEV"))
DdlTipoComprobante.SelectedValueExist("DEV")
-
End If
End If
@@ -1916,6 +1879,7 @@ Partial Class Compras_Compras
DdlTipoCompra.Items.Add(New ListItem("NC Con Productos", "6"))
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
DdlTipoCompra.Items.Add(New ListItem("NC Por Devolución", "11"))
+ DdlTipoCompra.Items.Add(New ListItem("Garantía", "12"))
Case "T"
DdlTipoCompra.Items.Clear()
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
@@ -2120,7 +2084,6 @@ Partial Class Compras_Compras
End If
-
SubTotal2 = SubTotalReal - Descuentos
If Descuentos > 0 Then
@@ -2164,10 +2127,8 @@ Partial Class Compras_Compras
HFDiferenciaCompra.Value = TxtTotal.Text
-
- LblRetIVA.Text = (If(SubTotal2 > 0, (RetencionIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%"
- LblRetISR.Text = (If(SubTotal2 > 0, (RetencionISR / SubTotal2), 0) * 100).FormatoNumero(3)
-
+ 'LblRetIVA.Text = TmpDT.MAX("PorcentajeRetIVA").ToString '(If(SubTotal2 > 0, (RetencionIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%"
+ 'LblRetISR.Text = TmpDT.MAX("PorcentajeRetISR").ToString '(If(SubTotal2 > 0, (RetencionISR / SubTotal2), 0) * 100).FormatoNumero(3)
'ASIGNA VALORES ORIGINALES PARA GUARDAR
AsignaValoresOriginales(SubTotal, SubTotal2, IVA, RetencionIVA, RetencionISR, Total)
@@ -2293,12 +2254,8 @@ Partial Class Compras_Compras
DdlRetIVAConcepto.Items.Add(New ListItem("Resico", "5"))
DdlRetIVAConcepto.Items.Add(New ListItem("General.", "6"))
End If
-
End If
-
End If
-
-
UpPS.Update()
End Sub
@@ -2469,13 +2426,12 @@ Partial Class Compras_Compras
HdnCompraSaldo.Value = TotalTemp.ToString
CompraSaldo = TotalTemp
- LblRetIVA.Text = (If(Subtotal2Temp > 0, (RetIVATemp / Subtotal2Temp), 0) * 100).FormatoNumero(3) + "%"
- LblRetISR.Text = (If(Subtotal2Temp > 0, (RetISRTemp / Subtotal2Temp), 0) * 100).FormatoNumero(3)
+ LblRetIVA.Text = If(RetIVATemp > 0, (TmpDT.MAX("RetIVAPorcentaje").ToDecimal() * 100).FormatoNumero(3), "")
+ LblRetISR.Text = If(RetISRTemp > 0, (TmpDT.MAX("RetISRPorcentaje").ToDecimal() * 100).FormatoNumero(3), "")
'ASIGNA VALORES ORIGINALES PARA GUARDAR
AsignaValoresOriginales(SubtotalTemp, Subtotal2Temp, IVATemp, RetIVATemp, RetISRTemp, Total)
-
End Sub
'''
@@ -2580,7 +2536,6 @@ Partial Class Compras_Compras
HdnCveProveedor.Value = CveProveedor.ToString
ViewState("CveProveedor") = CveProveedor
-
ImgBtnBuscarOC.OnClientClick = String.Format("AbrirVentana('/OC/PopUpBuscarReq.aspx?V=VOCCOMP&P={0}&T={1}&Masterimpoup=true',1000,600,'S'); return false;", CveProveedor, DdlTipoComprobante.SelectedValue)
@@ -2590,7 +2545,6 @@ Partial Class Compras_Compras
GvCreditosRelacionados.DataSource = ObjBancos.DtResultados
GvCreditosRelacionados.Visible = True
GvCreditosRelacionados.DataBind()
- 'romCreditosTabla.Visible = True
GvCreditos.Visible = False
GvCreditosRelacionados.Visible = True
@@ -2605,8 +2559,6 @@ Partial Class Compras_Compras
LblImporteCreditos.Visible = True
ObjBancos.Dispose()
- 'RegistraScript("CargaProveedor(""" & CveProveedor & """);")
-
'CargaEncabezado
'ViewState("FolioFiscal") = ObjCompra.DtResultados.Rows(0)("FolioFiscal").ToString
TxtSerie.Text = dr("Serie").ToString
@@ -2621,18 +2573,7 @@ Partial Class Compras_Compras
DdlTipoCompra.SelectedValueExist(dr("CveTipoCompra"))
TipoCompraOriginal = dr("CveTipoCompra").ToString.ToEntero
CveTipoConcepto = dr("CveTipoConcepto").ToString.ToEntero
-
- ChkEsNoDeducible.Checked = Boolean.Parse(dr("NoDeducible").ToString)
- 'Select Case dr("PorcentajeIVA").ToString.ToDouble
- ' Case 0
- ' DdlIVA.SelectedValue = "1"
- ' Case 0.16
- ' DdlIVA.SelectedValue = "1.16"
- ' Case 0.08
- ' DdlIVA.SelectedValue = "1.08"
- 'End Select
- 'If dr("PorcentajeIVA").ToString.ToDouble = 0 Then DdlIVA.SelectedValue = "1" Else DdlIVA.SelectedValue = "1.16"
-
+ ChkEsNoDeducible.Checked = dr("NoDeducible").ToString.ToEntero > 0
LblMetodoPago.Text = dr("MetodoPagoSAT").ToString
If UsuarioActual.Empresa.UsaAC Then
@@ -2679,7 +2620,7 @@ Partial Class Compras_Compras
If TipoCambio <> TipoCambioOriginal Then LblTCO.Text = String.Format(" TC Original: {0}", TipoCambioOriginal.ToString("N4"))
- AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble)
+ AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDecimal)
CalculaTotalPorDevengar()
TxtDocumentoImporteFE.Text = dr("Total").ToString
RVDocumentoImporte.MaximumValue = dr("Total").ToString.FormatoNumero(2)
@@ -2695,8 +2636,8 @@ Partial Class Compras_Compras
LblUsuarioCaptura.Text = dr("Usuario").ToString
LitFechCaptura.Text = dr("FechaIng").ToString.ToDate.ToShortDateString
LitFechCaptura.ToolTip = dr("FechaIng").ToString
- LblRetIVA.Text = Math.Round((dr("RetIVA").ToString.ToDouble / TxtSubTotal2.Text.ToDouble) * 100, 4).FormatoNumero(3) + "%"
- LblRetISR.Text = Math.Round((dr("RetISR").ToString.ToDouble / TxtSubTotal2.Text.ToDouble) * 100, 4).FormatoNumero(3)
+ LblRetIVA.Text = If(dr("RetIVA").ToString.ToDecimal > 0, TmpDT.MAX("RetIVAPorcentaje").ToDecimal * 100, 0).ToString.FormatoNumero(3) '(If(SubTotal2 > 0, (RetencionIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%"
+ LblRetISR.Text = If(dr("RetISR").ToString.ToDecimal > 0, TmpDT.MAX("RetISRPorcentaje").ToDecimal * 100, 0).ToString.FormatoNumero(3) '(If(SubTotal2 > 0, (RetencionISR / SubTotal2), 0) * 100).FormatoNumero(3)
If dr("TipoFactura").ToString <> "CFDi" Then LblTipoFact.Text = dr("TipoFactura").ToString : divTipoFactura.Visible = True
ViewState("CveFactura") = dr("CveFactura").ToString.ToEntero
ViewState("IdPoliza") = dr("IdPoliza").ToString.ToEntero
@@ -2707,16 +2648,12 @@ Partial Class Compras_Compras
HplProveedor.Visible = True
CargaProveedor(CveProveedor, "-1")
-
DdlRetIVAConcepto.SelectedValueExist(dr("CveRetIVAConcepto").ToString)
DdlRetISRConcepto.SelectedValueExist(dr("CveRetISRConcepto").ToString)
-
CveRetIVAConceptoOriginal = If(dr("CveRetIVAConcepto").ToString.ToEntero > 0, dr("CveRetIVAConcepto").ToString.ToEntero, -1)
CveRetISRConceptoOriginal = If(dr("CveRetISRConcepto").ToString.ToEntero > 0, dr("CveRetISRConcepto").ToString.ToEntero, -1)
-
If dr("CveTipoConcepto").ToString.ToEntero = 1 Then LblProveedor.Text = "Proveedor:" Else LblProveedor.Text = "Acreedor:"
-
HdnCveEstatusFactura.Value = dr("CveEstatusFactura").ToString
LblCompraEstatus.Text = dr("EstatusFactura").ToString
If dr("CveEstatusFactura").ToString = "2" Then ChkProgramarPago.Checked = True
@@ -3223,7 +3160,6 @@ Partial Class Compras_Compras
HplImporte.Visible = False
HplImporte.Text = ""
HplImporte.NavigateUrl = ""
-
Else
If Saldo <= 0 Then
LblCompraEstatus.Text = "PAGADA"
@@ -3235,26 +3171,20 @@ Partial Class Compras_Compras
HplImporte.Visible = True
HplImporte.Text = String.Format("$ {0}", Total.FormatoNumero())
HplImporte.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=700&width=920", CveProveedor, CveCompra)
-
-
Else
If Saldo < Total Then
LblCompraEstatus.Text = "ABONADA"
LblCompraEstatus.Font.Bold = True
-
End If
LblCompraEstatus.ForeColor = Drawing.Color.Navy
trSaldo.Visible = True
HplSaldoAuxiliar.Text = String.Format("$ {0}", Saldo.FormatoNumero())
HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=700&width=920", CveProveedor, CveCompra)
-
End If
End If
-
UpEstatus.Update()
Else
-
If CveCompra > 0 Then
LblCompraEstatus.Font.Bold = True
LblCompraEstatus.ForeColor = Drawing.Color.Navy
@@ -3262,9 +3192,7 @@ Partial Class Compras_Compras
HplSaldoAuxiliar.Text = String.Format("$ {0}", Saldo.FormatoNumero())
HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=700&width=920", CveProveedor, CveCompra)
End If
-
End If
-
End Sub
Private Sub CargaMonedas()
@@ -3273,9 +3201,6 @@ Partial Class Compras_Compras
End Sub
Private Sub CargarAlmacen()
- 'ddlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2)") 'solo muestra tipo material y herramientas
- 'ddlAlmacen.DataBind()
-
Dim DtAlmacenes = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2,7,14,19)")
If DdlTipoCompra.SelectedValue = "10" Then
@@ -3285,12 +3210,9 @@ Partial Class Compras_Compras
ddlAlmacenAdd.DataSource = DtAlmacenes
DdlAlmacenDevolucion.DataSource = DtAlmacenes
End If
-
ddlAlmacenAdd.DataBind()
DdlAlmacenDevolucion.DataBind()
-
DdlAlmacenDevolucion.Items.Insert(0, New ListItem("Seleccione", "-1"))
-
End Sub
Protected Sub CargaFuncionariosEmpleados()
@@ -4391,18 +4313,12 @@ Partial Class Compras_Compras
x = x + 1
End If
Next
-
If Not (CveCompraRefacturacion > 0 AndAlso ChkRefacturacionConAlmacen.Checked) Then
-
If x = 0 AndAlso GvInv.Rows.Count > 0 Then
Alert("Favor de seleccionar un producto en la pestaña de almacen", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
-
End If
-
-
-
End If
End If
@@ -4433,7 +4349,6 @@ Partial Class Compras_Compras
Alert("No se ha completado la asignacion de proyectos en la compra. ", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
-
CveSubProyecto = Row("CveSubProyecto").ToString.ToEntero
If Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then 'If NotHas117 AndAlso Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then
@@ -4453,13 +4368,15 @@ Partial Class Compras_Compras
'SI LA CANTIDAD EN SERIE/LOTE NO ES IGUAL A CANTIDAD EN GVPS
'Dim DtDetalles As DataTable
Dim Cantidad As Integer
+ Dim ValidaSerie As Boolean = True
If GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True Then
For Each Dr As DataRow In DtInv.Rows
+
If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then
Cantidad = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS").ToString)).Rows.Count
If Cantidad < Dr("Cantidad").ToString.ToEntero Then
- Alert("No hay productos a los que no se le ha asociado Serie-Lote", TipoMensaje.MsgError)
+ Alert("No hay productos a los que no se le ha asociado Serie", TipoMensaje.MsgError)
Exit Sub
End If
End If
@@ -4622,9 +4539,17 @@ Partial Class Compras_Compras
Exit Sub
End If
- 'If Not AjustaIva() Then
- ' Exit Sub
- 'End If
+ If Not AjustaIVA() Then
+ Exit Sub
+ End If
+
+ If Not AjustaRetIVA() Then
+ Exit Sub
+ End If
+
+ If Not AjustaRetISR() Then
+ Exit Sub
+ End If
If DdlFolioGarantia.Visible AndAlso DdlFolioGarantia.SelectedValue <> "-1" Then
If Not ValidaFolioGarantia() Then Exit Sub
@@ -4883,25 +4808,19 @@ Partial Class Compras_Compras
'si el registro es manual, toma el mismo dato
If CveFactura <= 0 Then TotalOriginal = TxtTotal.Text.ToDecimal
- For Each GvRow As GridViewRow In GvPS.Rows
- If GvRow.RowType = DataControlRowType.DataRow Then
-
- If GvRow.FCCheckBox("ChkEsNoDeduciblePS").Checked = False Then
- EsNoDeducible = False
- Exit For
- End If
-
- End If
- Next
-
Dim DoctosRelacionados As String = GeneraStrinDoctosRelacionados()
+ ' deducible tiene 2 valores 1. totalmente no deducible, 2. parcialmente no deducible
+ Dim tNoDeducible As Integer = If(ChkEsNoDeducible.Checked, 1, 0)
+ If (tNoDeducible > 0) Then
+ tNoDeducible = If(TmpDT.MIN("NoDeducible") = "False", 2, 1)
+ End If
- If ObjCompras.AddCompra(DdlTipoComprobante.SelectedValue, TxtDescripcion.Text.Trim, TxtSerie.Text.Trim, TxtFolio.Text.Trim, TxtFolioSecundario.Text.Trim, CveProveedor, TxtSubTotal.Text.ToDouble, TxtDescuento.Text.ToDouble,
- LblAmortizacion.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtIEPS.Text.ToDouble, TxtOtrosImpuestos.Text.ToDouble,
- TxtRedondeo.Text.ToDouble, TxtTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate, DdlMoneda.SelectedValue.ToEntero, TipoCambio, TxtFechaPago.Text.Trim.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
+ If ObjCompras.AddCompra(DdlTipoComprobante.SelectedValue, TxtDescripcion.Text.Trim, TxtSerie.Text.Trim, TxtFolio.Text.Trim, TxtFolioSecundario.Text.Trim, CveProveedor, TxtSubTotal.Text.Todecimal, TxtDescuento.Text.Todecimal,
+ LblAmortizacion.Text.Todecimal, TxtIVA.Text.Todecimal, TxtRetIVA.Text.Todecimal, TxtRetISR.Text.Todecimal, TxtIEPS.Text.Todecimal, TxtOtrosImpuestos.Text.Todecimal,
+ TxtRedondeo.Text.Todecimal, TxtTotal.Text.Todecimal, TxtFecha.Text.Trim.ToDate, DdlMoneda.SelectedValue.ToEntero, TipoCambio, TxtFechaPago.Text.Trim.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, IdPoliza, CveCajaChica:=CveCajaChica, CvePersonal:=CvePersonal, NumeroReembolso:=NumeroReembolso, CveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero,
AplicoPromocion:=ChkOCPromocion.Checked, PorcentajeIVA:=PorcentajeIVA, CveMetodoPago:=CveMetodoPago, CveRetIVAConcepto:=If(DdlRetIVAConcepto.Items.Count > 0, DdlRetIVAConcepto.SelectedValue.ToEntero, -1), CveConceptoContableAlmacen:=CveConceptoContableAlmacen,
- CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=EsNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, TotalOriginal:=TotalOriginal, CveTipoConcepto:=CveTipoConcepto,
+ CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=tNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, TotalOriginal:=TotalOriginal, CveTipoConcepto:=CveTipoConcepto,
EsImportacion:=EsImportacion, CveFactura:=CveFactura, CveSubProyecto:=CveSubProyectoPrincipal, DoctosRelacionados:=DoctosRelacionados, CveFolioGarantia:=DdlFolioGarantia.SelectedValue.ToEntero) Then
ViewState("CveCompra") = ObjCompras.CveCompra
@@ -4981,8 +4900,6 @@ Partial Class Compras_Compras
End Select
End Select
End If
-
-
If UsuarioActual.Empresa.UsaAC AndAlso Not TieneError Then
If TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0 Then
@@ -4991,10 +4908,7 @@ Partial Class Compras_Compras
''POLIZA COMPROMETIDO SOLO SI NO SE VINCULA OC
If HdnVCveOC.Value.ToEntero > 0 Then
- ' IDPolizaComprometido = ObjContaAC.AddPoliza( 4, "Comprometido", Total, Total, UsuarioActual.CveUsuario, Now)
- ' If IDPolizaComprometido <= 0 Then
- ' ErrorComprometido = True
- ' End If
+
IDPolizaComprometido = 1
TotalPorDevengar = TotalPorDevengar * 2
Else
@@ -5292,7 +5206,6 @@ Partial Class Compras_Compras
If Not ErrorAC AndAlso Not TieneError Then
-
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
If UsuarioActual.CveEmpresa = 119 AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0 Or DdlTipoComprobante.SelectedValue = "Ant") Then
@@ -5310,7 +5223,6 @@ Partial Class Compras_Compras
For Each Row As DataRow In TmpDT.Rows
Dim TipoRecepcion As Integer = -1
-
''INVENTARIOS
If GvInv.Rows.Count > indiceTR Then
If GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then
@@ -5550,8 +5462,12 @@ Partial Class Compras_Compras
Dim ListAlmacenes = (From CveAlmacen In DtInv.AsEnumerable() Where CveAlmacen.Field(Of Integer)("CveAlmacen") > 0 Select CveAlmacen.Field(Of Integer)("CveAlmacen")).Distinct().ToList
Dim indice = 0
Dim ImporteConcepto As Decimal = 0
-
- If DdlTipoComprobante.SelectedValue = "Fac" AndAlso CveCompraRefacturacion <= 0 Then
+ Dim CveConceptoMovimiento As Integer = 2
+ 'apoyo logistico/garantia
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso DdlTipoCompra.SelectedValue = "12" Then
+ CveConceptoMovimiento = 13
+ End If
+ If (DdlTipoComprobante.SelectedValue = "Fac" AndAlso CveCompraRefacturacion <= 0) OrElse CveConceptoMovimiento = 13 Then
For Each tCveAlmacen As Integer In ListAlmacenes
If GvInv.Rows(indice).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then
@@ -5562,7 +5478,7 @@ Partial Class Compras_Compras
Dim fecha As Date = TxtFecha.Text.ToDate
If Not UsuarioActual.Empresa.UsaAC Then fecha = Now
- CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, 2, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G2")
+ CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, CveConceptoMovimiento, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G2")
If CveMovimientoInventario <= 0 Then
ErrorMovInv = True
@@ -5602,7 +5518,6 @@ Partial Class Compras_Compras
Next
End If
Else
-
'UNIDAD BASE - EQUIVALENCIAS - INVENTARIO
If UsuarioActual.CveEmpresa = 1 Then
DtEquivalencias = New DataTable
@@ -5619,8 +5534,6 @@ Partial Class Compras_Compras
CveUnidad = CveUnidadBase
End If
End If
-
-
ImporteConcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, PUInv, PUInv * TipoCambioGuardar) - If(DdlMoneda.SelectedValue.ToEntero = 1, tDescuento, tDescuento * TipoCambioGuardar)
'si no es por serie lote
ImporteConcepto = If(UsuarioActual.Empresa.UsaAC, ImporteConcepto * IVA, ImporteConcepto)
@@ -5630,22 +5543,13 @@ Partial Class Compras_Compras
Exit For
End If
End If
-
End If
-
-
i = i + 1
contadorAlamcen = contadorAlamcen + 1
Next
End If
-
-
Next
End If
-
-
-
-
End If
If AplicarCostoIndirecto(ObjInventario, ObjCompras) Then
@@ -5853,18 +5757,8 @@ Partial Class Compras_Compras
Dim CuentasContablesInvalidas As New StringBuilder
Dim ConceptoPersonal As String = ""
Dim IdCtaIVAXAcreditar As Integer = 0
- ' Dim IdCtaIVAAcreditable As Integer = 0
Dim GuardoConcepto18 As Boolean = False
- 'If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows.Count > 0 Then
- ' IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
- ' ' IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
- 'End If
-
- '********************** Variables '**********************
-
- '****** Pagos
-
'Bancos (30)
Dim importeBanco As Decimal = 0
If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso (Not DivTarjeta.Visible Or DdlTarjeta.SelectedValue.ToEntero = -1) Then
@@ -6078,10 +5972,6 @@ Partial Class Compras_Compras
ErrorPrepoliza = True
End If
-
-
-
-
'daskldaskldmaskldanmlksd
If importeMovimiento <> 0 Then
For Each gvRowCredito As GridViewRow In GvCreditos.Rows
@@ -6130,17 +6020,9 @@ Partial Class Compras_Compras
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteDifCredito, ImporteDifCreditoMN, 21, Referencia, Concepto, CtaProveedorAcreedores, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIECredito, CveCreditoDetalle:=CveCreditoDetalleTemp, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteME:=If(tipoCambioActual = 1, 0, ImporteDifCredito), CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
-
-
End If
End If
-
-
-
Next
-
-
-
End If
'If TipoCreditoInteres Then
@@ -6179,10 +6061,6 @@ Partial Class Compras_Compras
IdCtaContable = CtaProveedorExtranjera
End If
-
-
-
-
Case 30 'Bancos
importeMovimiento = importeBanco + importeCajaChica 'Uno de los dos debe ser 0
If CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then
@@ -6391,8 +6269,6 @@ Partial Class Compras_Compras
If RBLPago.SelectedValue.ToEntero = 4 Then
Exit Select 'Es credito el concepto 6 se agrega en CASE 17
End If
-
-
Dim DifSubTotatles As Decimal = 0D
If CveCompraRefacturacion > 0 Then
@@ -6588,7 +6464,6 @@ Partial Class Compras_Compras
End If
End If
-
Dim CveMovimientoAlmacen As Integer = -1
'If importeMovimiento <> 0 Then
@@ -6685,11 +6560,8 @@ Partial Class Compras_Compras
ErrorPrepoliza = True
End If
Else
-
If Not CveCompraRefacturacion > 0 Then
-
Dim CveSubProyecto240 As Integer = TmpDT.MAX("CveSubProyecto").ToEntero
-
If CveSubProyecto240 <= 0 Then
Alert("Debe de asignar un sub proyecto o centro de costos", TipoMensaje.MsgAdvertencia)
ErrorPrepoliza = True
@@ -6700,7 +6572,6 @@ Partial Class Compras_Compras
ErrorPrepoliza = True
End If
End If
-
End If
Case 6
Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
@@ -6712,7 +6583,6 @@ Partial Class Compras_Compras
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero
End If
End If
-
If importeMN <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual,
CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=SeContabiliza) Then
@@ -6720,43 +6590,26 @@ Partial Class Compras_Compras
End If
End If
Next
-
End Select
- 'End If
-
End If
'falta el registro de la NC cuando es
Dim RegistroCuentaPuente As Boolean = False
'NC CON PRODUCTOS - CUENTA PUENTE
-
- If DdlTipoComprobante.SelectedValue = "NC" And DdlTipoCompra.SelectedValue.ToEntero = 9 Then
+ If DdlTipoComprobante.SelectedValue = "NC" And DdlTipoCompra.SelectedValue.Contiene("9", "12") Then
RegistraConcepto225 = True
End If
-
If RegistraConcepto225 Then
importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 And ISNULL(AplicaCostoIndirecto,0) <> 1 And ISNULL(CveTipoPS,0) = 2").ToString.ToDecimal
importeMN = importeMovimiento * tipoCambioActual * Multiplicador
'no es necesario, ya se está interpretandoe l usado como producto
- 'If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then 'cuando es emp acumuladora
-
- ' Dim Valor As Decimal = 0
- ' For Each RowAcum As DataRow In GlobalDTAcumTamaños().FiltraParametros("CveEmpresa = 140").Rows
- ' Dim TotalTamanio = TmpDT.FiltroPrimeroValor("Total", $"CvePS={RowAcum("CvePSCargo")}").ToDecimal()
- ' If TotalTamanio > 0 Then
- ' Valor += TotalTamanio
- ' End If
- ' Next
-
- ' importeMovimiento += Valor
- ' importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- 'End If
-
Dim ConceptoContabilizacionNC = 225
+ Dim tCveClasif As Integer = -1
+ Dim tCveSubProyecto As Integer = TmpDT.FiltroPrimeroValor("CveSubProyecto", "CveSubProyecto > 0 ").ToEntero
Dim CveMovimientoDevolucion As Integer = -1
'CUANDO NO SE RECIBE LA MERCANCIA EN COMPRAS, SE REGISTRA EL 225, SI SE ESTA REGISTRANDO LA DEVOLUCION EN ALMACEN, SE REGISTRA EL 68
@@ -6764,11 +6617,10 @@ Partial Class Compras_Compras
ConceptoContabilizacionNC = 68
CveMovimientoDevolucion = Devolucion.CveMovimiento
End If
-
- If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(ConceptoContabilizacionNC, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
- End If
+ 'cuando es garantía.
+ If DdlTipoCompra.SelectedValue = "12" Then
+ ConceptoContabilizacionNC = 259
+ tCveClasif = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion > 0 ").ToEntero
End If
Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
@@ -6776,20 +6628,12 @@ Partial Class Compras_Compras
If importeMovimiento > 0 Or TxtTotal.Text.ToDecimal = 0 Then
RegistroCuentaPuente = True
Dim ImporteTransito As Decimal = 0
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
-
'SI ES GASTO DE ALMACEN NO DEBE CONTABILIZAR CONCEPTO 68
If DdlTipoCompra.SelectedValue = "10" AndAlso ConceptoContabilizacionNC = 68 Then
SeContabiliza = False
IdCtaContable = 0
End If
-
'se lleva saldo de Mercancía en tránsito
-
If ChkNCInvNC.Checked Then
For Each Gvr As GridViewRow In GVNCInv.Rows
If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
@@ -6797,10 +6641,8 @@ Partial Class Compras_Compras
ErrorMovInv = True
Exit For
End If
-
End If
Next
-
Dim diferenciaTransito As Decimal = 0
For Each Gvr As GridViewRow In GVNCInvAlmacen.Rows
If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
@@ -6820,7 +6662,6 @@ Partial Class Compras_Compras
End If
End If
Next
-
'la diferencia se va aplicar sobre los
'Dim diferenciaTransito As Decimal = ImporteTransito - importeMN.RoundSQL
@@ -6837,21 +6678,17 @@ Partial Class Compras_Compras
End If
End If
Else
-
Dim DiferenciaDevolucion As Decimal = importeMovimiento - TotalRealDevolucion
If TotalRealDevolucion <> 0 Then
If Math.Abs(DiferenciaDevolucion) > 0 Then
- Dim CveSubProyecto69 As Integer = TmpDT.FiltroPrimeroValor("CveSubProyecto", "CveSubProyecto > 0 ").ToEntero
- Dim CveClasificacion69 As Integer = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion > 0 ").ToEntero
- Dim IdCtaContable69 As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacion69}").ToString.ToEntero
Dim tMovto As Boolean = False
If UsuarioActual.CveEmpresa = 119 Then
tMovto = True
Else
DiferenciaDevolucion = -DiferenciaDevolucion
End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, tMovto, DiferenciaDevolucion.RoundSQL(), Referencia, 69, Concepto, FechaMovimiento, IdCtaContable69, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=DiferenciaDevolucion, ImporteME:=If(tipoCambioActual = 1, 0, DiferenciaDevolucion), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, Contabilizable:=SeContabiliza, CveSubProyecto:=CveSubProyecto69, CveClasificacion:=CveClasificacion69) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, tMovto, DiferenciaDevolucion.RoundSQL(), Referencia, 69, Concepto, FechaMovimiento, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=DiferenciaDevolucion, ImporteME:=If(tipoCambioActual = 1, 0, DiferenciaDevolucion), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, Contabilizable:=SeContabiliza, CveSubProyecto:=tCveSubProyecto, CveClasificacion:=tCveClasif) Then
ErrorPrepoliza = True
End If
End If
@@ -6859,7 +6696,7 @@ Partial Class Compras_Compras
ErrorPrepoliza = True
End If
Else
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento.RoundSQL, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMovimiento * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, Contabilizable:=SeContabiliza) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento.RoundSQL, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMovimiento * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveClasificacion:=tCveClasif, CveSubProyecto:=tCveSubProyecto, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
End If
@@ -6869,7 +6706,7 @@ Partial Class Compras_Compras
If UsuarioActual.CveEmpresa.Contiene(119) Then
Dim ContienePSNeteoBonif As Boolean = False
For Each Dr As DataRow In TmpDT.Rows
- If Dr("CveClasificacion").ToString.ToEntero.Contiene(20319) Or DdlTipoCompra.SelectedValue.ToEntero = 11 Then 'clasificación de Bonificación, no se incluirá en el neteo
+ If Dr("CveClasificacion").ToString.ToEntero.Contiene(20319) Or DdlTipoCompra.SelectedValue.Contiene("11") Then 'clasificación de Bonificación, no se incluirá en el neteo
ContienePSNeteoBonif = True
Exit For
End If
@@ -6879,8 +6716,6 @@ Partial Class Compras_Compras
importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveClasificacion = 20319 ").ToString.ToDecimal
importeMN = importeMovimiento * tipoCambioActual * Multiplicador
Dim IdCtaContableDescCompra As Integer = UsuarioActual.Empresa.Funcionalidad(405).ToEntero
-
-
Dim CveSubProyecto259 As Integer = TmpDT.MAX("CveSubProyecto").ToEntero
If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza, CveSubProyecto:=CveSubProyecto259) Then
@@ -6890,11 +6725,8 @@ Partial Class Compras_Compras
Else
ErrorPrepoliza = True
End If
-
End If
End If
-
-
End If
'ChkNCInvNC
@@ -6926,17 +6758,14 @@ Partial Class Compras_Compras
Dim DTDistinct = DT.Copy
If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
-
For Each drowdis As DataRow In DTDistinct.Rows
If drowdis("CveTipoGasto").ToString = "" Then
drowdis("CveTipoGasto") = 0
End If
If drowdis("TipoGasto").ToString.Trim = "" Then
drowdis("TipoGasto") = "ND"
-
End If
Next
-
DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF, 0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"})
Else
@@ -6946,7 +6775,6 @@ Partial Class Compras_Compras
End If
If drowdis("TipoGasto").ToString.Trim = "" Then
drowdis("TipoGasto") = "ND"
-
End If
Next
DTDistinct.AcceptChanges()
@@ -6961,7 +6789,6 @@ Partial Class Compras_Compras
Dim tTipoMovimiento As Boolean = TipoMovimiento
If DTDistinct.Rows.Count > 0 Then
For Each Row2 As DataRow In DTDistinct.Rows
-
tTipoMovimiento = TipoMovimiento
'DETERMINA IMPORTE
If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
@@ -6971,7 +6798,6 @@ Partial Class Compras_Compras
End If
'se debe de restar el costo indirecto, si se recibió por OC sobre el importe del gasto, por si ya está incuido
importeMovimiento = importeMovimiento - CostoIndirectoAcum176
-
importeMN = importeMovimiento * tipoCambioActual * Multiplicador '[IPP] EL 6 DEBE SER POSITIVO 27/AGOSTO/2018
'CLASIFICACION
@@ -7009,8 +6835,6 @@ Partial Class Compras_Compras
importeMovimiento = -importeMovimiento
importeMN = -importeMN
End If
-
-
Dim usacomplementariaProveedor As Boolean = False
usacomplementariaProveedor = If(tipoCambioActual > 1, True, False)
@@ -7431,9 +7255,7 @@ Partial Class Compras_Compras
ErrorMovtosCxP = AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta)
End If
-
End If
-
End If
Else
@@ -7459,12 +7281,6 @@ Partial Class Compras_Compras
IdCtaContable = CtaProveedorAnticiposExtranjera
End If
- 'Agregamos el 21/37/60
-
-
- 'Dim ImporComisionAnticipo As Decimal = Ant.ImporteComision
- 'Dim importeMNComision As Decimal = ImporComisionAnticipo * tipoCambioActual * Multiplicador
-
If Not usacomplementariaAnticipo Then
ImporteAntMN = TipoCambioAnt * ImporteAnt
End If
@@ -7489,13 +7305,10 @@ Partial Class Compras_Compras
Pago.TCPago = Ant.TCCompra
Pago.CveMonedaPago = If(Ant.TCCompra > 1, 2, 1)
Pago.OtroGastoIngreso = ImporComisionAnticipo
-
ErrorPrepoliza = AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta)
End If
-
End If
-
End If
If UsuarioActual.CveEmpresa.Contiene(83) Then
@@ -7509,7 +7322,6 @@ Partial Class Compras_Compras
'Simplificacion de PrePolizas
If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
-
If Not ObjConta.UpdatePrePolizasDetalleBloquear(Ant.CvePrePoliza, False) Then
ErrorPrepoliza = True
Alert("No se pudo desbloquear los movimientos", TipoMensaje.MsgError)
@@ -7521,10 +7333,8 @@ Partial Class Compras_Compras
End If
End If
End If
-
Next
importeMovimiento = 0
-
End If
End Select
@@ -7534,19 +7344,10 @@ Partial Class Compras_Compras
End If
'5, 305, 306, 311
If importeMovimiento <> 0 Or (CveConceptoOriginal = 5 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Fac", "Ant")) Or (ConceptoContable.Contiene(18) AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not GuardoConcepto18) Then
- 'Conta ContPAQ
-
-
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
-
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveSubProyecto:=CveSubProyectoInsertar, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
Exit For
End If
-
End If
Next
@@ -7768,7 +7569,6 @@ Partial Class Compras_Compras
End If
-
'VALIDAR ERRORES
If ErrorAC OrElse ErrorPrepoliza OrElse ErrorPrepolizaDescuadre OrElse ErrorDetalles OrElse ErrorMovDev OrElse ErrorMovtosCxP OrElse ErrorMovtosRetIVA OrElse ErrorMovtosRetISR OrElse ErrorMovtosEstimaciones OrElse ErrorMovtosIE OrElse ErrorMovtosIVA OrElse ErrorMovInv OrElse TieneError OrElse ErrorAF OrElse ErrorOC OrElse ErrorBitacora OrElse ErrorAddAcarreos OrElse ErrorCreditosCompra Then
If ErrorDetalles Then
@@ -7990,7 +7790,6 @@ Partial Class Compras_Compras
Dim DoctosRelacionados As String = "-1"
Dim listaUUIDSRelacionados As New List(Of String)
-
If UUIDSList.Count > 0 Then
For Each s As String In UUIDSList
If s.Trim.Length > 0 Then
@@ -8004,8 +7803,6 @@ Partial Class Compras_Compras
End If
Return DoctosRelacionados
-
-
End Function
Private Function AsignarSubProyectoPrincipal() As Integer
@@ -8216,77 +8013,257 @@ Partial Class Compras_Compras
Dim IVADetalles As Decimal = TmpDT.SUMD("IVA", " IVA > 0 ")
Dim DiferenciaIVas As Decimal = TxtIVA.Text.ToDecimal - IVADetalles
+ If Math.Abs(DiferenciaIVas) > 0 Then
+ If Math.Abs(DiferenciaIVas) <= 0.05 Then
- If Math.Abs(DiferenciaIVas) > 0.05 Then
+ Dim DTConsulta As New DataTable
+ DTConsulta = TmpDT.FiltraParametros(" IVA > 0 ")
- Dim DTConsulta As New DataTable
- DTConsulta = TmpDT.FiltraParametros(" IVA > 0 ")
+ If DTConsulta.Rows.Count > 0 Then
- If DTConsulta.Rows.Count > 0 Then
-
- Dim IndiceContador As Integer = 0
- Dim IndiceUltimo As Integer = 0
- Dim CantidadRegistroConIVA As Decimal
-
- For Each dRow As DataRow In TmpDT.Rows
- If dRow("IVA").ToString.ToDecimal > 0 Then
- IndiceUltimo = IndiceContador
- CantidadRegistroConIVA = CantidadRegistroConIVA + 1
- End If
- IndiceContador = IndiceContador + 1
- Next
-
- IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
- DiferenciaIVas = TxtIVA.Text.ToDecimal - IVADetalles
-
- If Math.Abs(DiferenciaIVas) > 0.0D Then
-
- If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then
-
- Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA
-
- For Each dRow As DataRow In TmpDT.Rows
- dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido
- Next
-
- Else
- TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas
- End If
-
- TmpDT.AcceptChanges()
-
- End If
-
- End If
-
- 'Revalidacion de ajuste
- IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
- DiferenciaIVas = TxtIVA.Text.ToDecimal - IVADetalles
-
- If Math.Abs(DiferenciaIVas) > 0.01D Then
- Respuesta = False
- If IVADetalles > 0 Then
+ Dim IndiceContador As Integer = 0
+ Dim IndiceUltimo As Integer = 0
+ Dim CantidadRegistroConIVA As Decimal
For Each dRow As DataRow In TmpDT.Rows
If dRow("IVA").ToString.ToDecimal > 0 Then
- dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas
- TmpDT.AcceptChanges()
- Respuesta = True
- Exit For
+ IndiceUltimo = IndiceContador
+ CantidadRegistroConIVA = CantidadRegistroConIVA + 1
End If
+ IndiceContador = IndiceContador + 1
Next
- Else
- Alert("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia)
- Respuesta = False
- End If
- Else
- Respuesta = True
- End If
+ IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
+ DiferenciaIVas = TxtIVA.Text.ToDecimal - IVADetalles
+ If Math.Abs(DiferenciaIVas) > 0.0D Then
+
+ If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then
+
+ Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA
+
+ For Each dRow As DataRow In TmpDT.Rows
+ dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido
+ Next
+
+ Else
+ TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas
+ End If
+
+ TmpDT.AcceptChanges()
+
+ End If
+
+ End If
+
+ 'Revalidacion de ajuste
+ IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
+ DiferenciaIVas = TxtIVA.Text.ToDecimal - IVADetalles
+
+ If Math.Abs(DiferenciaIVas) > 0.01D Then
+ Respuesta = False
+ If IVADetalles > 0 Then
+
+ For Each dRow As DataRow In TmpDT.Rows
+ If dRow("IVA").ToString.ToDecimal > 0 Then
+ dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas
+ TmpDT.AcceptChanges()
+ Respuesta = True
+ Exit For
+ End If
+ Next
+
+ Else
+ Alert("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia)
+ Respuesta = False
+ End If
+ Else
+ Respuesta = True
+ End If
+
+ Else
+ Alert("existe una diferencia de más de 0.05 entre el IVA de la compra y los detalles.", TipoMensaje.MsgAdvertencia)
+ Respuesta = False
+ End If
Else
- Alert("existe una diferencia de más de 0.05 entre el IVA de la compra y los detalles.", TipoMensaje.MsgAdvertencia)
- Respuesta = False
+ Respuesta = True
+ End If
+
+ Return Respuesta
+
+ End Function
+
+ Private Function AjustaRetIVA() As Boolean
+
+ Dim Respuesta As Boolean = False
+
+ Dim RetIVADetalles As Decimal = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
+ Dim DiferenciaRetIVA As Decimal = TxtRetIVA.Text.ToDecimal - RetIVADetalles
+
+ If Math.Abs(DiferenciaRetIVA) > 0 Then
+ If Math.Abs(DiferenciaRetIVA) <= 0.05 Then
+
+ Dim DTConsulta As New DataTable
+ DTConsulta = TmpDT.FiltraParametros(" RetIVA > 0 ")
+
+ If DTConsulta.Rows.Count > 0 Then
+
+ Dim IndiceContador As Integer = 0
+ Dim IndiceUltimo As Integer = 0
+ Dim CantidadRegistroConRetIVA As Decimal
+
+ For Each dRow As DataRow In TmpDT.Rows
+ If dRow("RetIVA").ToString.ToDecimal > 0 Then
+ IndiceUltimo = IndiceContador
+ CantidadRegistroConRetIVA = CantidadRegistroConRetIVA + 1
+ End If
+ IndiceContador = IndiceContador + 1
+ Next
+
+ RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
+ DiferenciaRetIVA = TxtRetIVA.Text.ToDecimal - RetIVADetalles
+
+ If Math.Abs(DiferenciaRetIVA) > 0.0D Then
+
+ If (TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA) < 0 Then
+
+ Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetIVA) / CantidadRegistroConRetIVA
+
+ For Each dRow As DataRow In TmpDT.Rows
+ dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal - AjusteteDividido
+ Next
+
+ Else
+ TmpDT.Rows(IndiceUltimo)("RetIVA") = TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA
+ End If
+
+ TmpDT.AcceptChanges()
+
+ End If
+
+ End If
+
+ 'Revalidacion de ajuste
+ RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
+ DiferenciaRetIVA = TxtRetIVA.Text.ToDecimal - RetIVADetalles
+
+ If Math.Abs(DiferenciaRetIVA) > 0.01D Then
+ Respuesta = False
+ If RetIVADetalles > 0 Then
+
+ For Each dRow As DataRow In TmpDT.Rows
+ If dRow("RetIVA").ToString.ToDecimal > 0 Then
+ dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal + DiferenciaRetIVA
+ TmpDT.AcceptChanges()
+ Respuesta = True
+ Exit For
+ End If
+ Next
+
+ Else
+ Alert("Los productos especificados en el listado no tienen asignado impuesto RetIVA, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia)
+ Respuesta = False
+ End If
+ Else
+ Respuesta = True
+ End If
+
+ Else
+ Alert("existe una diferencia de más de 0.05 entre el RetIVA de la compra y los detalles.", TipoMensaje.MsgAdvertencia)
+ Respuesta = False
+ End If
+ Else
+ Respuesta = True
+
+ End If
+
+ Return Respuesta
+
+ End Function
+
+
+
+ Private Function AjustaRetISR() As Boolean
+
+ Dim Respuesta As Boolean = False
+
+ Dim RetISRDetalles As Decimal = TmpDT.SUMD("RetISR", " RetISR > 0 ")
+ Dim DiferenciaRetISR As Decimal = TxtRetISR.Text.ToDecimal - RetISRDetalles
+
+ If Math.Abs(DiferenciaRetISR) > 0 Then
+ If Math.Abs(DiferenciaRetISR) <= 0.05 Then
+
+ Dim DTConsulta As New DataTable
+ DTConsulta = TmpDT.FiltraParametros(" RetISR > 0 ")
+
+ If DTConsulta.Rows.Count > 0 Then
+
+ Dim IndiceContador As Integer = 0
+ Dim IndiceUltimo As Integer = 0
+ Dim CantidadRegistroConRetISR As Decimal
+
+ For Each dRow As DataRow In TmpDT.Rows
+ If dRow("RetISR").ToString.ToDecimal > 0 Then
+ IndiceUltimo = IndiceContador
+ CantidadRegistroConRetISR = CantidadRegistroConRetISR + 1
+ End If
+ IndiceContador = IndiceContador + 1
+ Next
+
+ RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ")
+ DiferenciaRetISR = TxtRetISR.Text.ToDecimal - RetISRDetalles
+
+ If Math.Abs(DiferenciaRetISR) > 0.0D Then
+
+ If (TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR) < 0 Then
+
+ Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetISR) / CantidadRegistroConRetISR
+
+ For Each dRow As DataRow In TmpDT.Rows
+ dRow("RetISR") = dRow("RetISR").ToString.ToDecimal - AjusteteDividido
+ Next
+
+ Else
+ TmpDT.Rows(IndiceUltimo)("RetISR") = TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR
+ End If
+
+ TmpDT.AcceptChanges()
+
+ End If
+
+ End If
+
+ 'Revalidacion de ajuste
+ RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ")
+ DiferenciaRetISR = TxtRetISR.Text.ToDecimal - RetISRDetalles
+
+ If Math.Abs(DiferenciaRetISR) > 0.01D Then
+ Respuesta = False
+ If RetISRDetalles > 0 Then
+
+ For Each dRow As DataRow In TmpDT.Rows
+ If dRow("RetISR").ToString.ToDecimal > 0 Then
+ dRow("RetISR") = dRow("RetISR").ToString.ToDecimal + DiferenciaRetISR
+ TmpDT.AcceptChanges()
+ Respuesta = True
+ Exit For
+ End If
+ Next
+
+ Else
+ Alert("Los productos especificados en el listado no tienen asignado impuesto RetISR, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia)
+ Respuesta = False
+ End If
+ Else
+ Respuesta = True
+ End If
+
+ Else
+ Alert("existe una diferencia de más de 0.05 entre el RetISR de la compra y los detalles.", TipoMensaje.MsgAdvertencia)
+ Respuesta = False
+ End If
+ Else
+ Respuesta = True
End If
Return Respuesta
@@ -8721,11 +8698,15 @@ Partial Class Compras_Compras
Dim TmpCveRetIVAConcepto As Integer = If(CveRetIVAConceptoOriginal <> DdlRetIVAConcepto.SelectedValue.ToEntero, DdlRetIVAConcepto.SelectedValue.ToEntero, -1)
Dim TmpCveRetISRConcepto As Integer = If(CveRetISRConceptoOriginal <> DdlRetISRConcepto.SelectedValue.ToEntero, DdlRetISRConcepto.SelectedValue.ToEntero, -1)
+ Dim tNoDeducible As Integer = If(ChkEsNoDeducible.Checked, 1, 0)
+ If (tNoDeducible > 0) Then
+ tNoDeducible = If(TmpDT.MIN("NoDeducible") = "False", 2, 1)
+ End If
If ObjCompra.UpdateCompra(TxtDescripcion.Text.Trim, TxtFolioSecundario.Text.Trim, TxtFechaPago.Text.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
- TxtDescuento.Text.ToDouble, TxtSubTotal.Text.ToDouble, TxtIVA.Text.ToDouble, TxtTotal.Text.ToDouble,
+ TxtDescuento.Text.ToDecimal, TxtSubTotal.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtTotal.Text.ToDecimal,
UsuarioActual.CveUsuario, CveCompra, CveCajaChica:=DdlRembolsoCajaChica.SelectedValue.ToEntero, CvePersonal:=DdlRembolsoPersonal.SelectedValue.ToEntero, CveProveedorSucursal:=If(DdlProveedorSucursal.SelectedValue.ToEntero > 0, DdlProveedorSucursal.SelectedValue.ToEntero, -1), PorcentajeIVA:=PorcentajeIVA, NumeroReembolso:=TxtRembolsoNumero.Text,
- CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, NoDeducible:=EsNoDeducible, CveRetIVAConcepto:=TmpCveRetIVAConcepto, CveRetISRConcepto:=TmpCveRetISRConcepto, CveSubProyecto:=CveSubProyectoPrincipal, CveFolioGarantia:=DdlFolioGarantia.SelectedValue.ToEntero) Then
+ CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, NoDeducible:=tNoDeducible, CveRetIVAConcepto:=TmpCveRetIVAConcepto, CveRetISRConcepto:=TmpCveRetISRConcepto, CveSubProyecto:=CveSubProyectoPrincipal, CveFolioGarantia:=DdlFolioGarantia.SelectedValue.ToEntero) Then
If Not ComparaDatatables() Then
@@ -9071,10 +9052,10 @@ Partial Class Compras_Compras
Dim CveAFCompra = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1)
If Row("CveCompraDetalle").ToString.ToEntero > 0 Then
- If Not ObjCompra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble,
- Row("Descuento").ToString.ToDouble, Row("Obs").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, CveAF, Row("CveCompraDetalle").ToString.ToEntero, CvePersonal:=CvePersonal, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia,
- RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble,
- IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False), CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero) Then
+ If Not ObjCompra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal, Row("IVA").ToString.ToDecimal, Row("Total").ToString.ToDecimal,
+ Row("Descuento").ToString.ToDecimal, Row("Obs").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, CveAF, Row("CveCompraDetalle").ToString.ToEntero, CvePersonal:=CvePersonal, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia,
+ RetIVA:=Row("RetIVA").ToString.ToDecimal, RetISR:=Row("RetISR").ToString.ToDecimal, IEPSPS:=Row("IEPSPS").ToString.ToDecimal, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDecimal,
+ IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDecimal, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDecimal, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDecimal, IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDecimal, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDecimal, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso ChkEsNoDeducible.Checked, True, False), CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero) Then
Retorno = False
Exit For
@@ -9662,8 +9643,8 @@ Partial Class Compras_Compras
For Each Row As DataRow In TmpDT.Rows
- If Not Compra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble,
- Row("Descuento").ToString.ToDouble, Row("Observaciones").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, -2, Row("CveCompraDetalle").ToString.ToEntero, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero) Then
+ If Not Compra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal, Row("IVA").ToString.ToDecimal, Row("Total").ToString.ToDecimal,
+ Row("Descuento").ToString.ToDecimal, Row("Observaciones").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, -2, Row("CveCompraDetalle").ToString.ToEntero, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero) Then
Retorno = False
Exit For
@@ -10700,12 +10681,6 @@ Partial Class Compras_Compras
GvInv.DataSource = DtInv
GvInv.DataBind()
- 'If (GvInv.Rows.Count > 0) Then
- ' GvInv.UseAccessibleHeader = True
- ' GvInv.HeaderRow.TableSection = TableRowSection.TableHeader
- ' RegistraScript("OrdenarGVInv();")
- 'End If
-
InicializaCargaEvidenciaAlmacen()
'CARGA VALORES YA SELECCIONADOS DE CONSIGNACION
@@ -10740,10 +10715,19 @@ Partial Class Compras_Compras
Protected Sub GVINV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInv.RowDataBound
-
-
If e.Row.RowType = DataControlRowType.DataRow Then
+ If UsuarioActual.Empresa.UsaAC Then e.Row.FCCheckBox("cbInv").Enabled = False
+
+ Dim StrTipo As String = "CveTipoAlmacen IN (1,2,7,14,19)"
+ If DdlTipoCompra.SelectedValue.Contiene("9", "12") Then StrTipo = "CveTipoAlmacen IN (21)"
+ If EsDevolucionApoyoLogistico Then StrTipo = "CveTipoAlmacen = 27"
+ e.Row.FCDropDownList("ddlEAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrTipo)
+
+ e.Row.FCDropDownList("ddlEAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1"))
+ e.Row.FCDropDownList("ddlEAlmacen").DataBind()
+ If UsuarioActual.Empresa.UsaAC Then e.Row.FCDropDownList("ddlEAlmacen").Enabled = False
+
'SI USA SERIE-LOTE INVENTARIO
If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then
e.Row.FCButton("BtnSerieLote").Visible = True
@@ -10756,7 +10740,9 @@ Partial Class Compras_Compras
Else
e.Row.FCButton("BtnSerieLote").Visible = False
e.Row.FCTextBox("TbCantidad").Enabled = True
- e.Row.FCTextBox("TbCantidad").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", e.Row.DBCampo("Cantidad")))
+ e.Row.FCTextBox("TbCantidad").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF"))))
+ e.Row.FCTextBox("TbCantidad").Text = If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF"))
+
End If
'SIEMPRE ENABLED FALSE
@@ -10778,74 +10764,23 @@ Partial Class Compras_Compras
If Not OCVinculada Then
e.Row.Cells(3).Text = e.Row.DBCampo("PSCodigo").ToString
End If
-
Else
If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then
e.Row.FCTextBox("TbCantidad").Enabled = False
Else
e.Row.FCTextBox("TbCantidad").Enabled = True
End If
-
e.Row.FCCheckBox("cbInv").Enabled = False
End If
-
- If UsuarioActual.Empresa.UsaAC Then
- e.Row.FCCheckBox("cbInv").Enabled = False
- End If
-
-
- If EsDevolucionApoyoLogistico Then
- e.Row.FCDropDownList("ddlEAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen = 27") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
-
- Else
- e.Row.FCDropDownList("ddlEAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(If(DdlTipoCompra.SelectedValue.ToEntero = 9, "CveTipoAlmacen IN (21)", "CveTipoAlmacen IN (1,2,7,14,19)")) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
- End If
-
-
-
- e.Row.FCDropDownList("ddlEAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1"))
- e.Row.FCDropDownList("ddlEAlmacen").DataBind()
- 'e.Row.FCDropDownList("ddlEAlmacen").SelectedValue = If(e.Row.DBCampo("CveAlmacen").ToEntero <= 0, "-1", e.Row.DBCampo("CveAlmacen"))
- If UsuarioActual.Empresa.UsaAC Then e.Row.FCDropDownList("ddlEAlmacen").Enabled = False
-
-
If UsuarioActual.Empresa.Funcionalidad(567) = "1" Then
If e.Row.FCDropDownList("ddlEAlmacen").Items.Count > 1 Then
-
e.Row.FCDropDownList("ddlEAlmacen").SelectedIndex = 1
e.Row.FCCheckBox("cbInv").Checked = True
-
ddlAlmacenConsignacion_SelectedIndexChanged(e.Row.FCDropDownList("ddlEAlmacen"), Nothing)
CambiaTotalDevengar(Nothing, Nothing)
End If
End If
-
-
- If Not e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then
- e.Row.FCTextBox("TbCantidad").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF"))))
- e.Row.FCTextBox("TbCantidad").Text = If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF"))
- End If
-
- 'e.Row.FCImageButton("btnImgDestino").Attributes.Add("onclick", "javascript:$('#DivAlmacen').show(500); PosicionaObjeto(this.id,'DivAlmacen'); CargarValores('" & e.Row.RowIndex & "','" & e.Row.DBCampo("Cantidad") & "','" & e.Row.DBCampo("PS").Replace("'", "\'") & "'); ")
- ' e.Row.FCImageButton("btnImgDestino").ID = e.Row.FCImageButton("btnImgDestino").ID.ToString + e.Row.RowIndex.ToString
- 'e.Row.Cells(6).ToolTip = "Enviar a otro Almacén."
-
- If e.Row.DBCampo("Consec").ToEntero = 0 Then
- e.Row.BackColor = Drawing.Color.PaleGreen
- End If
-
- If UsuarioActual.CveEmpresa = 66 Then
- e.Row.FCDropDownList("DdlRecibirInv").Items.RemoveAt(1)
- End If
-
- 'If isAlmacenistaGluyas() Then
- ' Dim dt As DataTable = Nothing
- ' dt = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS=2", "PS")
- ' e.Row.FCDropDownList("Ddlnewps").DataSource = dt 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
- ' e.Row.FCDropDownList("Ddlnewps").DataBind()
- ' e.Row.FCDropDownList("Ddlnewps").Items.Insert(0, New ListItem("Seleccione", "-1"))
- ' dt.Dispose()
- 'End If
+ If e.Row.DBCampo("Consec").ToEntero = 0 Then e.Row.BackColor = Drawing.Color.PaleGreen
'Consignaciones
If CveConsignacion > 0 Then
@@ -10856,7 +10791,6 @@ Partial Class Compras_Compras
If e.Row.DBCampo("CveAlmacenConsignacion").ToEntero > 0 Then
e.Row.FCDropDownList("ddlAlmacenConsignacion").SelectedValueExist(e.Row.DBCampo("CveAlmacenConsignacion"))
End If
-
''CARGA CONSIGNACIONES
e.Row.FCDropDownList("DdlVinculaConsignacion").DataSource = DtConsignaciones.FiltraParametros(String.Format("CveAlmacenSalida = {0} OR {0} = '-1'", e.Row.FCDropDownList("ddlAlmacenConsignacion").SelectedValue))
e.Row.FCDropDownList("DdlVinculaConsignacion").DataBind()
@@ -10866,7 +10800,6 @@ Partial Class Compras_Compras
e.Row.FCDropDownList("DdlVinculaConsignacion").SelectedValueExist(e.Row.DBCampo("NoConsignacion"))
e.Row.FCHiddenField("HdnNoConsignacion").Value = e.Row.DBCampo("NoConsignacion")
End If
-
If e.Row.DBCampo("CveConsignacion").ToEntero > 0 Then
e.Row.FCHiddenField("HdnCveConsignacion").Value = e.Row.DBCampo("CveConsignacion")
e.Row.FCHiddenField("HdnPS").Value = e.Row.DBCampo("HdnPS")
@@ -10882,8 +10815,6 @@ Partial Class Compras_Compras
End If
If Not UsuarioActual.Empresa.UsaAC Then
-
-
e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividirCompra").ClientID))
e.Row.FCTextBox("TxtDividir").Text = ""
@@ -10894,31 +10825,20 @@ Partial Class Compras_Compras
e.Row.FCTextBox("TxtDividir").Visible = False
End If
End If
-
End If
'HEADER GvInv
If e.Row.RowType = DataControlRowType.Header Then
Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2,7,14,19)"
+ ' iliana, horacio, marco, RMF. 2017.03.13
+ If UsuarioActual.CveUsuario.Contiene(1397, 1517, 1565) Then StrAlmacenes = "CveTipoAlmacen IN (1,2,7,14,12,19)"
+ If DdlTipoCompra.SelectedValue.ToEntero = 9 Then StrAlmacenes = "CveTipoAlmacen IN (21)"
+ ' salidas de garantía
+ If DdlTipoCompra.SelectedValue.ToEntero = 12 Then StrAlmacenes = "CveTipoAlmacen IN (21)"
+ If DdlTipoCompra.SelectedValue.ToEntero = 10 Then StrAlmacenes = $"Modalidad = 0"
+ If EsDevolucionApoyoLogistico Then StrAlmacenes = " CveTipoAlmacen = 27"
- If UsuarioActual.CveUsuario.Contiene(1397, 1517, 1565) Then ' iliana, horacio, marco, RMF. 2017.03.13
- StrAlmacenes = "CveTipoAlmacen IN (1,2,7,14,12,19)"
- End If
-
-
- If DdlTipoCompra.SelectedValue.ToEntero = 9 Then
- StrAlmacenes = "CveTipoAlmacen IN (21)"
- End If
-
- If DdlTipoCompra.SelectedValue.ToEntero = 10 Then
- StrAlmacenes = $"Modalidad = 0"
- End If
-
- If EsDevolucionApoyoLogistico Then
- StrAlmacenes = " CveTipoAlmacen = 27"
- End If
-
- e.Row.FCDropDownList("ddlAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
+ e.Row.FCDropDownList("ddlAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes)
e.Row.FCDropDownList("ddlAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1"))
e.Row.FCDropDownList("ddlAlmacen").DataBind()
@@ -10931,19 +10851,14 @@ Partial Class Compras_Compras
e.Row.FCDropDownList("ddlAlmacenConsignacionGeneral").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4)
e.Row.FCDropDownList("ddlAlmacenConsignacionGeneral").DataBind()
-
If UsuarioActual.Empresa.Funcionalidad(567) = "1" Then
If e.Row.FCDropDownList("ddlAlmacen").Items.Count > 1 Then
e.Row.FCDropDownList("ddlAlmacen").SelectedIndex = 1
e.Row.FCCheckBox("cbAll").Checked = True
-
cbAll_CheckedChanged(e.Row.FCCheckBox("cbAll"), Nothing)
ddlAlmacen_SelectedIndexChanged(e.Row.FCDropDownList("ddlAlmacen"), Nothing)
-
End If
End If
-
-
End If
End Sub
@@ -10958,81 +10873,6 @@ Partial Class Compras_Compras
InicializaCargaEvidenciaAlmacen()
End Sub
- 'Protected Sub btnAgregarEq_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
-
-
- ' Dim eq As New ClsProductosServicios
- ' Dim Unidad As String = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString
- ' Dim CvePS As Integer = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CvePS").ToString.ToEntero
- ' Dim CveUM As Integer = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveUM").ToString.ToEntero
- ' Dim PU As Double = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("PU").ToString.ToDouble
-
- ' Dim tCve As Integer = 0
- ' Dim ErrorUM As Boolean = False
-
- ' If UsuarioActual.Empresa.UsaInventarios And CveUM = 0 Then
- ' Dim UM As New ClsUnidadesMedida
- ' tCve = UM.AddUnidadMedida(TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString, TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1)
-
- ' If tCve > 0 Then
- ' TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveUM") = tCve
- ' Else
- ' ErrorUM = True
- ' End If
-
-
- ' End If
-
- ' If Not ErrorUM Then
-
- ' If eq.AddPSEquivalencias(CvePS, CveUM, txtCantidadEq.Text.ToDecimal, False, PU, UsuarioActual.CveUsuario) Then
- ' TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveEq") = 1
-
- ' End If
-
-
- ' End If
-
-
- ' GvPS.DataSource = TmpDT
- ' GvPS.DataBind()
-
- ' eq.Dispose()
-
- ' txtCantidadEq.Text = ""
- 'End Sub
-
-
- 'Protected Sub Enviar_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAdd.Click
-
- ' If TbCantidadAlm.Text.ToDouble < DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad").ToString.ToDouble And TbCantidadAlm.Text.ToDouble > 0 Then
-
- ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad") = DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad").ToString.ToDouble - TbCantidadAlm.Text.ToDouble
- ' AddDTEnvio(TbCantidadAlm.Text.ToDouble,
- ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("UM").ToString,
- ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveUM").ToString.ToEntero,
- ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CvePS").ToString().ToEntero,
- ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PS").ToString,
- ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PU").ToString.ToDouble,
- ' ddlAlmacenAdd.SelectedValue.ToEntero, DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveEq").ToString.ToEntero)
-
-
- ' Else
- ' Alert("El campo cantidad es necesario que sea mayor que 0 y menor al registro seleccionado.")
-
-
- ' End If
-
- ' TbCantidadAlm.Text = ""
- ' ddlAlmacenAdd.SelectedIndex = 0
- ' UpINV.Update()
-
- ' ' Alert(TmpDT.Rows.Count.ToString)
-
-
-
- 'End Sub
-
Protected Sub cbAll_CheckedChanged(sender As Object, e As EventArgs)
For i As Integer = 0 To GvInv.Rows.Count - 1
@@ -13839,16 +13679,18 @@ Partial Class Compras_Compras
End If
End Sub
Protected Sub BtnCancelarCompra2_Click(sender As Object, e As EventArgs)
+
RegistraScript("$('#DivCancelarCompra').modal('hide');")
+ If (Not UsuarioActual.TienePermisoProceso(315)) And GvInvMov.Rows.Count > 0 Then
+ Alert("La compra no se puede cancelar debido a que tiene movimientos de almacén.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
Dim ObjComprasComprobacion As New ClsCompras
-
-
If ObjComprasComprobacion.GetComprasPagosConciliados(CveCompra, UsuarioActual.CveEmpresa) Then
Dim TienePagosConciliados As Boolean = False
-
If ObjComprasComprobacion.DtResultados.Rows.Count > 0 Then
TienePagosConciliados = True
Dim PagosConciliados As New StringBuilder
@@ -13856,8 +13698,6 @@ Partial Class Compras_Compras
For Each Drow As DataRow In ObjComprasComprobacion.DtResultados.Rows
PagosConciliados.AppendLine($"{Drow("Folio").ToString} ")
Next
-
-
Alert($"La compra no se puede cancelar, tiene pagos conciliados: {PagosConciliados.ToString}", TipoMensaje.MsgAdvertencia)
End If
@@ -13865,12 +13705,13 @@ Partial Class Compras_Compras
ObjComprasComprobacion.Dispose()
Exit Sub
End If
-
-
End If
ObjComprasComprobacion.Dispose()
Dim cvemovimientoentrada As Integer = -1
+
+
+
'DEVOLUCIÓN AUTOMATICA
If CheckDevAuto.Checked Then
Dim ErrorMovInv As Boolean = False
@@ -13934,6 +13775,7 @@ Partial Class Compras_Compras
ObjCompra.Dispose()
End If
+
Dim ObjAC As ClsContPAQi = Nothing
If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso UsuarioActual.Empresa.TipoContabilidad = 2 Then
ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
@@ -13993,7 +13835,8 @@ Partial Class Compras_Compras
dr("Concepto").ToString, TxtFechaCancelacion.Text.ToDate, dr("IdCtaContable").ToString.ToEntero, dr("IdSegmentoNegocio").ToString.ToEntero, dr("CveIE").ToString.ToEntero,
dr("CveVenta").ToString.ToEntero, dr("CveCompra").ToString.ToEntero, dr("CveSubProyecto").ToString.ToEntero, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero,
dr("CveMovimientoAlmacen").ToString.ToEntero, dr("CveActivoFijo").ToString.ToEntero, -1, -1, dr("CveCreditoDetalle").ToString.ToEntero,
- ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero, CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero,
+ ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero,
+ PorcentajeImpuesto:=dr("PorcentajeImpuesto").ToString.ToDecimal, CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero,
CveCompraAmortizacion:=dr("CveCompraAmortizacion").ToString.ToEntero) Then
ErrorCancelar = True
Exit For
@@ -14084,7 +13927,6 @@ Partial Class Compras_Compras
End If
End If
-
'CANCELA COMPRA
If Not ErrorCancelar Then
If Not ObjCompras.UpdateEstatusCompra(CveCompra, -2) Then
@@ -14092,7 +13934,6 @@ Partial Class Compras_Compras
End If
End If
-
If Not ErrorCancelar Then
If ObjAC IsNot Nothing Then
ObjAC.Commit()
@@ -14116,8 +13957,6 @@ Partial Class Compras_Compras
ObjAC.Dispose()
End If
-
-
End Sub
Private Sub btnProrateo_Click(sender As Object, e As EventArgs) Handles btnProrateo.Click, btnProrateo2.Click
@@ -14982,7 +14821,7 @@ Partial Class Compras_Compras
OCVinculada = True
UpPSS.Update()
- AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble)
+ AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDecimal)
If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero)
@@ -16357,7 +16196,7 @@ Partial Class Compras_Compras
#End Region
#Region " TOTALES: VALIDA Y CALCULA "
- Private Sub AsignaValoresOriginales(SubTotal As Double, SubTotal2 As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Double)
+ Private Sub AsignaValoresOriginales(SubTotal As Double, SubTotal2 As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Decimal)
SubTotalOriginal = SubTotal
SubTotal2Original = SubTotal2
IVAOriginal = IVA
@@ -16461,9 +16300,8 @@ Partial Class Compras_Compras
UpAnticipos.Update()
End If
-
- LblRetIVA.Text = (If(SubTotal2 > 0, (RetIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%"
- LblRetISR.Text = (If(SubTotal2 > 0, (RetISR / SubTotal2), 0) * 100).FormatoNumero(3)
+ LblRetIVA.Text = TmpDT.MAX("RetIVAPorcentaje").ToString '(If(SubTotal2 > 0, (RetencionIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%"
+ LblRetISR.Text = TmpDT.MAX("RetISRPorcentaje").ToString '(If(SubTotal2 > 0, (RetencionISR / SubTotal2), 0) * 100).FormatoNumero(3)
'IMPORTES DE RESTRICCION
TxtDocumentoImporteFE.Text = Total.ToString.FormatoNumero(2)
@@ -16858,9 +16696,9 @@ Partial Class Compras_Compras
- TxtRetIVAModal.Text = FormatoNumero(GvRow.DataKey("RetIVAPorcentaje").ToDouble * 100, 0)
- TxtRetISRModal.Text = FormatoNumero(GvRow.DataKey("RetISRPorcentaje").ToDouble * 100, 0)
- TxtIEPSModal.Text = FormatoNumero(GvRow.DataKey("IEPSPSPorcentaje").ToDouble * 100, 0)
+ TxtRetIVAModal.Text = FormatoNumero(GvRow.DataKey("RetIVAPorcentaje").ToDouble * 100, 2)
+ TxtRetISRModal.Text = FormatoNumero(GvRow.DataKey("RetISRPorcentaje").ToDouble * 100, 2)
+ TxtIEPSModal.Text = FormatoNumero(GvRow.DataKey("IEPSPSPorcentaje").ToDouble * 100, 2)
ViewState("RetIVA") = GvRow.DataKey("RetIVAPorcentaje").ToDouble
ViewState("RetISR") = GvRow.DataKey("RetISRPorcentaje").ToDouble
@@ -17063,14 +16901,14 @@ Partial Class Compras_Compras
End If
If TxtIEPSModal.Text = "" Then
- TxtIEPSModal.Text = FormatoNumero(PS("IEPSPorcentaje").ToString.ToDecimal * 100, 0)
+ TxtIEPSModal.Text = FormatoNumero(PS("IEPSPorcentaje").ToString.ToDecimal * 100, 2)
End If
ViewState("IEPSPSIVA") = If(PS("IEPSGrabaIVA").ToString = "True", PS("IEPSPorcentaje").ToString.ToDouble, 0)
'TxtIVAModal.Text = FormatoNumero(ViewState("IVAPS").ToString().ToDouble * 100, 0)
- TxtRetIVAModal.Text = FormatoNumero(ViewState("RetIVA").ToString().ToDouble * 100, 0)
- TxtRetISRModal.Text = FormatoNumero(ViewState("RetISR").ToString().ToDouble * 100, 0)
+ TxtRetIVAModal.Text = FormatoNumero(ViewState("RetIVA").ToString().ToDouble * 100, 2)
+ TxtRetISRModal.Text = FormatoNumero(ViewState("RetISR").ToString().ToDouble * 100, 2)
If (CveFactura > 0 Or CveCompra > 0) And TxtIEPS.Text.ToDecimal = 0 And PS("IEPSPorcentaje").ToString.ToDecimal > 0 Then
@@ -19506,14 +19344,6 @@ Partial Class Compras_Compras
Dim CveMovimientoAlmacen = -1
Dim CveOCDetalle = -1
Dim CveAlmacen = -1
- Dim IdCtaContableAlmacen As Integer = -1
- Dim CveCuentaAlmacen As Integer = -1
- Dim IdCtaContableRecepcionOC = -1
- Dim IdCtaContableRecepcionOCME = -1
- Dim IdCtaContableRecepcionOCComplementaria = -1
- Dim IdCtaContableRecepcionOCER = -1
- Dim IdCtaContableRecepcionOCERME = -1
- Dim IdCtaContableRecepcionOCERComplementaria = -1
Dim Fecha As Date = TxtFecha.Text.ToDate
Dim CveProveedorInvOC As Integer = -1
Dim ProveedorNombre As String = ""
@@ -19530,29 +19360,6 @@ Partial Class Compras_Compras
Dim CveMoneda As Integer = 1
Dim PS As String = ""
- If ObjConta.GetRetCuenta(176, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableRecepcionOC = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero
- End If
-
- If ObjConta.GetRetCuenta(228, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableRecepcionOCME = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero
- End If
-
- If ObjConta.GetRetCuenta(229, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableRecepcionOCComplementaria = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero
- End If
-
- If ObjConta.GetRetCuenta(177, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableRecepcionOCER = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero
- End If
-
- If ObjConta.GetRetCuenta(232, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableRecepcionOCERME = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero
- End If
-
- If ObjConta.GetRetCuenta(233, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableRecepcionOCERComplementaria = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero
- End If
'AJUSTES EN PREPOLIZA - SALIDA CONTABLE (CON SALIDA DE VENTA O SIN SALIDA)
For Each DrDiferencias As DataRow In DtInvOCDiferencias.FiltraParametros("ConceptoSalida IN (0,1)").Rows
@@ -19574,8 +19381,6 @@ Partial Class Compras_Compras
CveMovimientoAlmacen = DrDiferencias("CveMovimiento").ToString.ToEntero
TCInvOC = DrDiferencias("TipoCambioAjuste").ToString.ToDecimal
- IdCtaContableAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DrDiferencias("CveAlmacen").ToString.ToEntero}").ToEntero
-
Dim CveClasificacionCostoOC = TmpDT.FiltroPrimeroValor("CveClasificacion", "ISNULL(TipoAF, 0) <> 2 And ISNULL(CveAlmacen, 0) = 0 And ISNULL(AplicaCostoIndirecto, 0) <> 1 And ISNULL(CveTipoPS, 0) = 2").ToEntero
Dim IdCtaContable69 As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero
@@ -19598,13 +19403,13 @@ Partial Class Compras_Compras
Dim DifImporte As Decimal = DiferenciaInvOC - (ImporteME + ImporteMEComp)
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, 177, ConceptoPartida, Fecha, IdCtaContableRecepcionOCER, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=CveSubProyecto) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, 177, ConceptoPartida, Fecha, -1, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=CveSubProyecto) Then
Retorno = False
Exit For
End If
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteME, SerieFolio, 228, ConceptoPartida, Fecha, IdCtaContableRecepcionOCME, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=ImporteME, ImporteME:=ImporteME, TipoCambio:=TCInvOC, CveOCDetalle:=CveOCDetalle) Then
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMEComp, SerieFolio, 229, ConceptoPartida, Fecha, IdCtaContableRecepcionOCComplementaria, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=ImporteMEComp, ImporteME:=ImporteME, TipoCambio:=TCInvOC, CveOCDetalle:=CveOCDetalle) Then
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteME, SerieFolio, 228, ConceptoPartida, Fecha, -1, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=ImporteME, ImporteME:=ImporteME, TipoCambio:=TCInvOC, CveOCDetalle:=CveOCDetalle) Then
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMEComp, SerieFolio, 229, ConceptoPartida, Fecha, -1, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=ImporteMEComp, ImporteME:=ImporteME, TipoCambio:=TCInvOC, CveOCDetalle:=CveOCDetalle) Then
If DifImporte <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DifImporte, SerieFolio, 69, ConceptoPartida, Fecha, IdCtaContable69, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=DifImporte, ImporteME:=DifImporte, TipoCambio:=TCInvOC, CveOCDetalle:=CveOCDetalle, CveClasificacion:=CveClasificacionCostoOC, CveSubProyecto:=CveSubProyecto) Then
Retorno = False
Exit For
@@ -19619,8 +19424,8 @@ Partial Class Compras_Compras
End If
Else
'2018.11.24 se cambia concepto 177, de cargo a abono negativo., petición MALL
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, If(ConceptoSalida = 0, 177, 177), ConceptoPartida, Fecha, IdCtaContableRecepcionOCER, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=CveSubProyecto) Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DiferenciaInvOC, SerieFolio, 176, ConceptoPartida, Fecha, IdCtaContableRecepcionOC, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=DiferenciaInvOC, CveOCDetalle:=CveOCDetalle) Then
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, If(ConceptoSalida = 0, 177, 177), ConceptoPartida, Fecha, -1, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=CveSubProyecto) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DiferenciaInvOC, SerieFolio, 176, ConceptoPartida, Fecha, -1, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=DiferenciaInvOC, CveOCDetalle:=CveOCDetalle) Then
Retorno = False
Exit For
End If
@@ -19653,7 +19458,6 @@ Partial Class Compras_Compras
End If
End If
-
Return Retorno
End Function
@@ -19712,7 +19516,11 @@ Partial Class Compras_Compras
Protected Sub DdlTipoCompra_SelectedIndexChanged(sender As Object, e As EventArgs)
- If DdlTipoCompra.SelectedValue.ToEntero.Contiene(9, 10) Then 'Al seleccionar apoyo logístico se cargan los amancenes de devoculcion proveedor para dar entrada
+ If DdlTipoCompra.SelectedValue.ToEntero.Contiene(9, 10, 12) Then 'Al seleccionar apoyo logístico se cargan los amancenes de devoculcion proveedor para dar entrada
+ 'cambia si hay ps con uso de serie
+ For Each dr As DataRow In TmpDT.Rows
+ dr("CveMetodoInventario") = 1
+ Next
CargaGvInv()
End If
@@ -19725,6 +19533,10 @@ Partial Class Compras_Compras
If DdlFolioGarantia.SelectedValue.ToEntero <> -1 Then
ValidaFolioGarantia(True)
+ 'visualizar el div de almacen
+ Pnlalmaceninventarios.Visible = True
+ paneldevolucion.Visible = False
+ uppAlmacenGral.Update()
End If
End Sub
@@ -19805,34 +19617,22 @@ Partial Class Compras_Compras
#Region "ES NO DEDUCIBLE"
Protected Sub ChkEsNoDeducible_CheckedChanged1(sender As Object, e As EventArgs)
+ AplicarNoDeducible()
+ End Sub
+
+ Private Sub AplicarNoDeducible()
If ChkEsNoDeducible.Checked Then
EsNoDeducible = True
dvNoDeducible.Visible = True
GvPS.Columns(11).Visible = True
- UpEsNoDeduciblePS.Visible = True
+ DivEsNoDeducible.Visible = True
Else
EsNoDeducible = False
dvNoDeducible.Visible = False
GvPS.Columns(11).Visible = False
- UpEsNoDeduciblePS.Visible = False
+ DivEsNoDeducible.Visible = False
End If
- 'DivEsNoDeducible.Visible = False
- 'For Each Dr As DataRow In TmpDT.Rows
- ' Dim Total As Double = Dr("IVA").ToString.ToDouble - (Dr("RetIVA").ToString.ToDouble + Dr("RetISR").ToString.ToDouble) + Dr("IEPSPS").ToString.ToDouble + Dr("IEPSPSIVA").ToString.ToDouble
- ' Dr("Total") = Dr("Total").ToString.ToDouble + Total
- ' Dr("PU") = Dr("Total").ToString.ToDouble / Dr("Cantidad").ToString.ToDouble
- ' Dr("IVA") = 0
- ' Dr("IVAPorcentaje") = 0
- ' Dr("RetIVA") = 0
- ' Dr("RetIVAPorcentaje") = 0
- ' Dr("RetISR") = 0
- ' Dr("RetISRPorcentaje") = 0
- ' Dr("IEPSPS") = 0
- ' Dr("IEPSPSPorcentaje") = 0
- ' Dr("IEPSPSIVA") = 0
- ' Dr("IEPSPSIVAPorcentaje") = 0
- 'Next
- 'TmpDT.AcceptChanges()
+
AddPS2(EsNoDeducible:=EsNoDeducible)
UpPS.Update()
End Sub
@@ -20492,8 +20292,6 @@ Partial Class Compras_Compras
Protected Sub BtnModalEliminarCompra_Click(sender As Object, e As EventArgs)
-
-
Dim ObjAC As ClsContPAQi = Nothing
Dim Comp As New ClsCompras()
Dim ObjEventos As New ClsOIEventos(Comp.IniciaTransacSQL())
@@ -20526,8 +20324,6 @@ Partial Class Compras_Compras
End If
End If
-
-
Try
If ObjInventarios.GetInv_ComprasMov(CveCompra, UsuarioActual.CveEmpresa) Then
Dim DTInventarios As DataTable = ObjInventarios.DtResultados
@@ -20601,9 +20397,6 @@ Partial Class Compras_Compras
End If
-
-
-
If Not ErrorCompra Then
If Not Comp.DeleteCompra(CveCompra, False) Then
ErrorCompra = True
@@ -20626,85 +20419,159 @@ Partial Class Compras_Compras
ObjConta.Dispose()
End Sub
-
- Private Sub ProratearDeducible()
+#End Region
- ChkEsNoDeducible_CheckedChanged1(Nothing, Nothing)
-
-
- Dim DTProtateo As DataTable = TmpDT.Clone
+#Region "PRORATEAR 8.5%"
+ Private Sub Proratear85Deducible()
+ ChkEsNoDeducible.Checked = True
+ AplicarNoDeducible()
Dim Consec As Integer = 1
- For Each dRowOriginal As DataRow In TmpDT.Rows
+ Dim DT_Agrupado As DataTable = TmpDT.Clone
+ Dim DTProtateo As DataTable = TmpDT.Clone
+ Dim DT_IVAS As DataTable = TmpDT.FiltraParametros("", "", {"IVAPorcentaje", "RetIVAPorcentaje", "RetISRPorcentaje", "IEPSPSPorcentaje", "IEPSPSIVAPorcentaje"})
+ For Each drIva As DataRow In DT_IVAS.Rows
+ drIva("IVAPorcentaje") = drIva("IVAPorcentaje").ToString.ToDecimal
+ drIva("RetIVAPorcentaje") = drIva("RetIVAPorcentaje").ToString.ToDecimal
+ drIva("RetISRPorcentaje") = drIva("RetISRPorcentaje").ToString.ToDecimal
+ drIva("IEPSPSPorcentaje") = drIva("IEPSPSPorcentaje").ToString.ToDecimal
+ drIva("IEPSPSIVAPorcentaje") = drIva("IEPSPSIVAPorcentaje").ToString.ToDecimal
+ Next
+ DT_IVAS.AcceptChanges()
+ For Each dRow As DataRow In TmpDT.Rows
+ dRow("IVAPorcentaje") = dRow("IVAPorcentaje").ToString.ToDecimal
+ dRow("RetIVAPorcentaje") = dRow("RetIVAPorcentaje").ToString.ToDecimal
+ dRow("RetISRPorcentaje") = dRow("RetISRPorcentaje").ToString.ToDecimal
+ dRow("IEPSPSPorcentaje") = dRow("IEPSPSPorcentaje").ToString.ToDecimal
+ dRow("IEPSPSIVAPorcentaje") = dRow("IEPSPSIVAPorcentaje").ToString.ToDecimal
+ Next
+ TmpDT.AcceptChanges()
+
+ Dim psCvePs As Integer = 700562
+ Dim rowPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, psCvePs).Rows(0)
+
+ Dim psPSCodigo As String = rowPS("PSCodigo").ToString
+ Dim psCveClasificacion As Integer = rowPS("CveClasificacion").ToString.ToEntero
+ Dim psClasificacion As String = rowPS("Clasificacion").ToString
+ Dim psCveUM As Integer = rowPS("CveUM").ToString.ToEntero
+ Dim psUM As String = rowPS("UnidadMedida").ToString
+
+ For Each drIva As DataRow In DT_IVAS.Rows
+
+ Dim nRowAgrupado As DataRow = DT_Agrupado.NewRow
+ Dim drIVAPorcentaje As Decimal = drIva("IVAPorcentaje").ToString.ToDecimal
+ Dim drRetIVAPorcentaje As Decimal = drIva("RetIVAPorcentaje").ToString.ToDecimal
+ Dim drRetISRPorcentaje As Decimal = drIva("RetISRPorcentaje").ToString.ToDecimal
+ Dim drIEPSPSPorcentaje As Decimal = drIva("IEPSPSPorcentaje").ToString.ToDecimal
+ Dim drIEPSPSIVAPorcentaje As Decimal = drIva("IEPSPSIVAPorcentaje").ToString.ToDecimal
+ nRowAgrupado("Consec") = Consec
+
+ nRowAgrupado("Cantidad") = 1
+ nRowAgrupado("CveUM") = psCveUM
+ nRowAgrupado("UM") = psUM
+ nRowAgrupado("CvePS") = psCvePs
+ nRowAgrupado("PS") = psPSCodigo
+ nRowAgrupado("CveClasificacion") = psCveClasificacion
+ nRowAgrupado("Clasificacion") = psClasificacion
+
+ nRowAgrupado("IVAPorcentaje") = drIva("IVAPorcentaje")
+ nRowAgrupado("RetIVAPorcentaje") = drIva("RetIVAPorcentaje")
+ nRowAgrupado("RetISRPorcentaje") = drIva("RetISRPorcentaje")
+ nRowAgrupado("IEPSPSPorcentaje") = drIva("IEPSPSPorcentaje")
+ nRowAgrupado("IEPSPSIVAPorcentaje") = drIva("IEPSPSIVAPorcentaje")
+
+ nRowAgrupado("PU") = TmpDT.SUMD("PU", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("IVA") = TmpDT.SUMD("IVA", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("RetIVA") = TmpDT.SUMD("RetIVA", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("RetISR") = TmpDT.SUMD("RetISR", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("IEPSPS") = TmpDT.SUMD("IEPSPS", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("IEPSPSIVA") = TmpDT.SUMD("IEPSPSIVA", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("Descuento") = TmpDT.SUMD("Descuento", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("Total") = TmpDT.SUMD("Total", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
+ nRowAgrupado("NoDeducible") = 0
+
+ Consec = Consec + 1
+
+ DT_Agrupado.Rows.Add(nRowAgrupado)
+
+ Next
+ DT_Agrupado.AcceptChanges()
+
+ Consec = 1
+ For Each dRowOriginal As DataRow In DT_Agrupado.Rows
Dim dRow91_5 As DataRow = DTProtateo.NewRow
Dim dRow8_5 As DataRow = DTProtateo.NewRow
dRow91_5.ItemArray = dRowOriginal.ItemArray
dRow8_5.ItemArray = dRowOriginal.ItemArray
- Dim Mul91_5 As Decimal = 0.915D
Dim Mul85 As Decimal = 0.085D
-
-
- dRow91_5("Consec") = Consec
- dRow91_5("PU") = dRow91_5("PU").ToString.ToDecimal * Mul91_5
- dRow91_5("IVA") = dRow91_5("IVA").ToString.ToDecimal * Mul91_5
- dRow91_5("RetIVA") = dRow91_5("RetIVA").ToString.ToDecimal * Mul91_5
- dRow91_5("RetISR") = dRow91_5("RetISR").ToString.ToDecimal * Mul91_5
- dRow91_5("IEPSPS") = dRow91_5("IEPSPS").ToString.ToDecimal * Mul91_5
- dRow91_5("IEPSPSIVA") = dRow91_5("IEPSPSIVA").ToString.ToDecimal * Mul91_5
- dRow91_5("Total") = dRow91_5("Total").ToString.ToDecimal * Mul91_5
- dRow91_5("NoDeducible") = 1
-
-
- dRow8_5("Consec") = Consec + 1
+ Dim Mul91_5 As Decimal = 0.915D
+ dRow8_5("Consec") = Consec
dRow8_5("PU") = dRow8_5("PU").ToString.ToDecimal * Mul85
dRow8_5("IVA") = dRow8_5("IVA").ToString.ToDecimal * Mul85
dRow8_5("RetIVA") = dRow8_5("RetIVA").ToString.ToDecimal * Mul85
dRow8_5("RetISR") = dRow8_5("RetISR").ToString.ToDecimal * Mul85
dRow8_5("IEPSPS") = dRow8_5("IEPSPS").ToString.ToDecimal * Mul85
dRow8_5("IEPSPSIVA") = dRow8_5("IEPSPSIVA").ToString.ToDecimal * Mul85
+ dRow8_5("Descuento") = dRow8_5("Descuento").ToString.ToDecimal * Mul85
dRow8_5("Total") = dRow8_5("Total").ToString.ToDecimal * Mul85
dRow8_5("NoDeducible") = 0
+ psCvePs = 700563
+ rowPS = GlobalDTPS(UsuarioActual.CveEmpresa, psCvePs).Rows(0)
- DTProtateo.Rows.Add(dRow91_5)
+ psPSCodigo = rowPS("PSCodigo").ToString
+ psCveClasificacion = rowPS("CveClasificacion").ToString.ToEntero
+ psClasificacion = rowPS("Clasificacion").ToString
+ psCveUM = rowPS("CveUM").ToString.ToEntero
+ psUM = rowPS("UnidadMedida").ToString
+ dRow91_5("CveUM") = psCveUM
+ dRow91_5("UM") = psUM
+ dRow91_5("CvePS") = psCvePs
+ dRow91_5("PS") = psPSCodigo
+ dRow91_5("CveClasificacion") = psCveClasificacion
+ dRow91_5("Clasificacion") = psClasificacion
+
+ dRow91_5("Consec") = Consec + 1
+ dRow91_5("PU") = dRow91_5("PU").ToString.ToDecimal * Mul91_5
+ dRow91_5("IVA") = dRow91_5("IVA").ToString.ToDecimal * Mul91_5
+ dRow91_5("RetIVA") = dRow91_5("RetIVA").ToString.ToDecimal * Mul91_5
+ dRow91_5("RetISR") = dRow91_5("RetISR").ToString.ToDecimal * Mul91_5
+ dRow91_5("IEPSPS") = dRow91_5("IEPSPS").ToString.ToDecimal * Mul91_5
+ dRow91_5("IEPSPSIVA") = dRow91_5("IEPSPSIVA").ToString.ToDecimal * Mul91_5
+ dRow91_5("Descuento") = dRow91_5("Descuento").ToString.ToDecimal * Mul91_5
+ dRow91_5("Total") = dRow91_5("Total").ToString.ToDecimal * Mul91_5
+ dRow91_5("NoDeducible") = 1
DTProtateo.Rows.Add(dRow8_5)
-
+ DTProtateo.Rows.Add(dRow91_5)
Consec = Consec + 2
-
Next
-
DTProtateo.AcceptChanges()
TmpDT = DTProtateo
BtnProrateoDeducible.Visible = False
-
+ UpParametros.Update()
AddPS2(True)
End Sub
Private Sub BtnProrateoDeducible_Click(sender As Object, e As EventArgs) Handles BtnProrateoDeducible.Click
- ProratearDeducible()
+ Proratear85Deducible()
End Sub
-
#End Region
-
-
End Class
-
-
Public Class MMensajeDevolucion
Public Property CveMovimiento As Integer
Public Property TieneError As Boolean
diff --git a/Compras/ReembolsosComprobaciones.aspx b/Compras/ReembolsosComprobaciones.aspx
index 855f4c6e4..2aeabc214 100644
--- a/Compras/ReembolsosComprobaciones.aspx
+++ b/Compras/ReembolsosComprobaciones.aspx
@@ -320,7 +320,7 @@
+ DataKeyNames="CveCompra,FechaCompra,CveProveedor,CveMoneda,Proveedor,SerieFolio,SubTotal,IVA,RetIVA,RetISR,IEPS,Total,TipoCambio,IdCtaContProveedores,IdCtaContAcreedor,CvePrePoliza,IdPoliza,CveRetIVAConcepto,CveRetISRConcepto,IVAPorcentaje,IVADeducible,IVANoDeducible,CveTipoConcepto,CveSubProyecto,IVAPorPagar,NoDeducible">
diff --git a/Compras/ReembolsosComprobaciones.aspx.vb b/Compras/ReembolsosComprobaciones.aspx.vb
index 0cbbb003f..95a0f5c77 100644
--- a/Compras/ReembolsosComprobaciones.aspx.vb
+++ b/Compras/ReembolsosComprobaciones.aspx.vb
@@ -709,6 +709,7 @@ Partial Class Compras_ReembolsosComprobaciones
CompraActual.PorcentajeIVA = gvr.DataKey("IVAPorcentaje").ToDecimal
CompraActual.UsuarioActual = UsuarioActual
CompraActual.CveSubProyecto = gvr.DataKey("CveSubProyecto").ToEntero
+ CompraActual.CompraNoDeducible = gvr.DataKey("NoDeducible").ToEntero
CompraActual.IdCtaContableProv = IdCtaProveedor
ImportePagar = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb
index 3ba7985ce..90208a628 100644
--- a/Contabilidad/RegPrePolizaS.aspx.vb
+++ b/Contabilidad/RegPrePolizaS.aspx.vb
@@ -2978,7 +2978,7 @@ Partial Class ContabilidadC_RegPrePolizaS
End If
End If
If CveIE > 0 AndAlso gvr.DataKey("CveConceptoContable").ToEntero = 30 Then
- MensajeAlert.AppendFormat("
Folio Bancario: {1}", CveIE, FolioIE)
+ MensajeAlert.AppendFormat(" Folio Bancario: {1}", CveIE, FolioIE)
End If
Next
diff --git a/Inventarios/EntradasSalidas.aspx b/Inventarios/EntradasSalidas.aspx
index 774a35263..55b2b3859 100644
--- a/Inventarios/EntradasSalidas.aspx
+++ b/Inventarios/EntradasSalidas.aspx
@@ -382,7 +382,6 @@
diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb
index 439943a3e..141c03289 100644
--- a/Inventarios/EntradasSalidas.aspx.vb
+++ b/Inventarios/EntradasSalidas.aspx.vb
@@ -1480,10 +1480,9 @@ Partial Class Inventarios_EntradasSalidas
Dim FechaCaducidadVal As Date = If(RowPS("AplicaCaducidad").ToString = "True", FechaCaducidad, MinFecha)
-
If RowPS("AplicaSerie").ToString = "True" And (String.IsNullOrEmpty(Serie.Trim()) OrElse Serie = "-1") Then
- 'SI NO ES USADO O GARANTIA
- If Not Me.CveTipoAlmacenSeleccionado.Contiene(6, 22) Then
+ 'SI NO ES USADO O GARANTIA O SALIDA APOYO LOGISTICO
+ If Not Me.CveTipoAlmacenSeleccionado.Contiene(6, 22, 21) Then
Valido = False
Alert("El producto requiere Serie", TipoMensaje.MsgAdvertencia)
End If
@@ -1500,8 +1499,13 @@ Partial Class Inventarios_EntradasSalidas
Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue))
If drA2 IsNot Nothing Then
tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero
+ 'codigo temporal
+ If UsuarioActual.CveEmpresa = 140 AndAlso drA2("CveTipoAlmacen").ToString = "21" Then
+ Serie = ""
+ End If
End If
+
'salida
If Valido AndAlso DdlConcepto.SelectedValue.Contiene({"3", "5", "7", "8", "11", "12", "13", "15", "16", "17", "20", "21", "30", "31"}) Then ' salida de almacen
@@ -1523,7 +1527,6 @@ Partial Class Inventarios_EntradasSalidas
End If
End If
-
If Valido Then
Dim CveClasificacion As Integer
'Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS")
@@ -1911,8 +1914,12 @@ Partial Class Inventarios_EntradasSalidas
CveClasificacion = drr("CveClasificacion").ToString.ToEntero
IdCtaContableOtro = drr("IdCuentaCostos").ToString.ToEntero
End If
+ Case 3
+ CveConceptoContable = 51
+ EsContabilizable = True
Case Else
CveConceptoContable = 95
+
End Select
'2-78
diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb
index ccf7e3e44..a30689857 100644
--- a/Ventas/Clientes.aspx.vb
+++ b/Ventas/Clientes.aspx.vb
@@ -3978,9 +3978,8 @@ Partial Class Clientes
End If
End If
End If
-
-
-
+ Else
+ Respuesta = True
End If
Return Respuesta