This commit is contained in:
2024-06-22 10:20:44 -07:00
6 changed files with 740 additions and 416 deletions

View File

@@ -609,7 +609,8 @@ Public Class ClsMovimientos
'CveAplicaNC 'CveAplicaNC
Public Function GetCxPProveedor(CveProveedor As Integer, FechaI As String, FechaF As String, CveUsuarioProgramo As Integer, CveUsuarioRegistro As Integer, Public Function GetCxPProveedor(CveProveedor As Integer, FechaI As String, FechaF As String, CveUsuarioProgramo As Integer, CveUsuarioRegistro As Integer,
CveUsuarioResponsable As Integer, CveClasificacionProveedor As Integer, CveMoneda As Integer, CveEstatus As Integer, CveProveedorSucursal As Integer, CveAplicaNC As Integer, CveUsuarioResponsable As Integer, CveClasificacionProveedor As Integer, CveMoneda As Integer, CveEstatus As Integer, CveProveedorSucursal As Integer, CveAplicaNC As Integer,
Optional FechaVI As String = "-1", Optional FechaVF As String = "-1", Optional CodigoProgramacion As String = "-1", Optional CveSubProyecto As Integer = -1) As Boolean Optional FechaVI As String = "-1", Optional FechaVF As String = "-1", Optional CodigoProgramacion As String = "-1", Optional CveSubProyecto As Integer = -1, Optional Opcion As Integer = 1,
Optional CveEmpresa As Integer = -1, Optional SaldoMayorA As Decimal = -999999999999, Optional SaldoMenorA As Decimal = 999999999999) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_Comp_ProveedorCxP") DataAdapter("PA_Comp_ProveedorCxP")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
@@ -628,7 +629,10 @@ Public Class ClsMovimientos
.Add("@FechaVF", SqlDbType.VarChar).Value = FechaVF .Add("@FechaVF", SqlDbType.VarChar).Value = FechaVF
.Add("@CodigoProgramacion", SqlDbType.VarChar).Value = CodigoProgramacion .Add("@CodigoProgramacion", SqlDbType.VarChar).Value = CodigoProgramacion
.Add("@CveSubProyecto", SqlDbType.SmallInt).Value = CveSubProyecto .Add("@CveSubProyecto", SqlDbType.SmallInt).Value = CveSubProyecto
.Add("@Opcion", SqlDbType.SmallInt).Value = Opcion
.Add("@CveEmpresaOp", SqlDbType.SmallInt).Value = CveEmpresa
.Add("@SaldoMayorA", SqlDbType.Money).Value = SaldoMayorA
.Add("@SaldoMenorA", SqlDbType.Money).Value = SaldoMenorA
End With End With

View File

@@ -253,14 +253,33 @@ public partial class Contabilidad_RepIVA : ClsPaginas
if (Archivo.Exists) if (Archivo.Exists)
{ {
Ruta = string.Format("{0}Formatos\\{1}", UsuarioActual.Empresa.Ruta, Formato); Ruta = string.Format("{0}Formatos\\{1}", UsuarioActual.Empresa.Ruta, Formato);
ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion); //ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
if (UsuarioActual.Empresa.Funcionalidad(713).ToEntero() == 1)
{
ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, DtIEPSA, DtIVAA, "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
}
else
{
//ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, new DataTable(), new DataTable(), "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
}
}else }else
{ {
Ruta = ModExtensiones.DirectorioBaseEmpresas + $@"Empresas\Grales\Formatos\{Formato}"; Ruta = ModExtensiones.DirectorioBaseEmpresas + $@"Empresas\Grales\Formatos\{Formato}";
//ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, DtIEPSA, DtIVAA, "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
if (UsuarioActual.Empresa.Funcionalidad(713).ToEntero() == 1)
{
ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, DtIEPSA, DtIVAA, "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion); ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, DtIEPSA, DtIVAA, "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
}
else
{
//ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion); //ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, new DataTable(), new DataTable(), "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
}
} }

Binary file not shown.

Binary file not shown.

View File

@@ -147,7 +147,7 @@
<ajax:TabContainer runat="server" ID="Tabs"> <ajax:TabContainer runat="server" ID="Tabs">
<ajax:TabPanel ID="TabIXC" runat="server" HeaderText="IXC" ClientIDMode="Static" OnClientClick="" > <ajax:TabPanel ID="TabIXC" runat="server" HeaderText="IXC" ClientIDMode="Static" OnClientClick="onClickTabs">
<ContentTemplate> <ContentTemplate>
@@ -195,7 +195,7 @@
</ContentTemplate> </ContentTemplate>
</ajax:TabPanel> </ajax:TabPanel>
<ajax:TabPanel ID="TabNCEXC" runat="server" HeaderText="NC-EXC" ClientIDMode="Static"> <ajax:TabPanel ID="TabNCEXC" runat="server" HeaderText="NC-EXC" ClientIDMode="Static" OnClientClick="onClickTabs">
<ContentTemplate> <ContentTemplate>
@@ -245,7 +245,7 @@
</ajax:TabPanel> </ajax:TabPanel>
<ajax:TabPanel ID="TabVentas" runat="server" HeaderText="Ventas" ClientIDMode="Static"> <ajax:TabPanel ID="TabVentas" runat="server" HeaderText="Ventas" ClientIDMode="Static" OnClientClick="onClickTabs">
<ContentTemplate> <ContentTemplate>
<div class="row" style="margin-left: 0px; margin-top: 15px; margin-bottom: 5px; text-align: right; margin-right: 5px;" align="left"> <div class="row" style="margin-left: 0px; margin-top: 15px; margin-bottom: 5px; text-align: right; margin-right: 5px;" align="left">
@@ -351,10 +351,99 @@
</ajax:TabPanel> </ajax:TabPanel>
<ajax:TabPanel ID="TabCompras" runat="server" HeaderText="Compras" ClientIDMode="Static"> <ajax:TabPanel ID="TabCompras" runat="server" HeaderText="Compras" ClientIDMode="Static" OnClientClick="onClickTabs" >
<ContentTemplate> <ContentTemplate>
<div class="row" style="margin-left: 0px; margin-top: 15px; margin-bottom: 5px; text-align: right; margin-right: 5px;" align="left">
<div class="col-md-6">
<input type="text" id="TxtBusquedaCompras" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusquedaCompras','{0}')", GvCxP.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaCompras','{0}')", GvCxP.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
</div>
<div class="row">
<div class="col-md-6">
<asp:UpdatePanel ID="UPCompras" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GvCxP" runat="server" AutoGenerateColumns="False" EmptyDataText="No se encontraron Cuentas X Pagar Pendientes"
DataKeyNames="CveCompra,ImporteProgramo,Saldo,SubTotal,IVA,IVADeducible,IVANoDeducible,IEPS,RetIVA,RetISR,Total,UUID,RFC,CveFactura,SerieFolio,Descripcion,CvePrePoliza,Fecha,CveProveedor,TipoCambio,TipoCambioOriginal, CveMoneda,CveRetIVAConcepto,IVAPorPagar,IVAPorPagarDeducible,IVAPorPagarNoDeducible,IEPSPorPagar,CveRetISRConcepto,PorcentajeIVA,CveTipoConcepto,CveSubProyecto,TotalOriginal,EsImportacion,NoDeducible"
Width="100%" CssClass="table table-striped table-advance table-hover Widthall ScrollAD" Style="text-align: center;" GridLines="None">
<Columns>
<%-- 0 --%>
<asp:TemplateField>
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="Chk" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<%-- 1 --%>
<asp:TemplateField ItemStyle-Width="115px" ItemStyle-HorizontalAlign="Left">
<HeaderTemplate>Factura</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="HplF" CssClass="Texto" NavigateUrl='<%# Eval("CveCompra", "/Compras/Compras.aspx?CveCompra={0}")%>' Text='<%# Eval("SerieFolio")%>' runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>
Tipo<br>
Docto
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlTipoDocto" runat="server" Text='<%# Eval("TipoDocto") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Left">
<HeaderTemplate>Proveedor</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlRazonsocial" runat="server" Text='<%# Eval("RazonSocial") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<%-- 5 --%>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>Fecha Compra</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha", "{0:d}") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<%-- 5 --%>
<asp:TemplateField ItemStyle-HorizontalAlign="Left">
<HeaderTemplate>Moneda</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlMoneda" runat="server" Text='<%# Eval("Moneda") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<%-- 8 --%>
<asp:TemplateField ItemStyle-HorizontalAlign="Right">
<HeaderTemplate>Monto Compra</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlSaldoOriginal" runat="server" Text='<%# Eval("Original", "{0:N2}") %>'></asp:Literal>&nbsp;
</ItemTemplate>
</asp:TemplateField>
<%-- 10 --%>
<asp:TemplateField ItemStyle-HorizontalAlign="Right">
<HeaderTemplate>Saldo</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlSaldo" runat="server" Text='<%# Eval("Saldo", "{0:N2}") %>'></asp:Literal>&nbsp;
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</ContentTemplate> </ContentTemplate>
</ajax:TabPanel> </ajax:TabPanel>
@@ -406,13 +495,19 @@
</asp:UpdatePanel> </asp:UpdatePanel>
<div style="display:none"> <div style="display:none">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="BtnonClickTabs" OnClick="BtnonClickTabs_Click" ClientIDMode="Static" /> <asp:Button runat="server" ID="BtnonClickTabs" OnClick="BtnonClickTabs_Click" ClientIDMode="Static" />
</ContentTemplate>
</asp:UpdatePanel>
</div> </div>
</asp:Content> </asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server"> <asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script> <script>
function onClickTabs() {
function onClickTabs(sender, args) {
$('#BtnonClickTabs').click(); $('#BtnonClickTabs').click();
} }
</script> </script>

View File

@@ -36,6 +36,15 @@ Partial Public Class General_SaldosMenores
End Set End Set
End Property End Property
Private Property DtDatosCompras As DataTable
Get
Return DirectCast(ViewState("DtDatosCompras"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtDatosCompras") = value
End Set
End Property
Private Property Tipo As Integer Private Property Tipo As Integer
Get Get
Return DirectCast(ViewState("Tipo"), Integer) Return DirectCast(ViewState("Tipo"), Integer)
@@ -45,32 +54,32 @@ Partial Public Class General_SaldosMenores
End Set End Set
End Property End Property
Private Property CveMoneda As Integer 'Private Property CveMoneda As Integer
Get ' Get
Return DirectCast(ViewState("CveMoneda"), Integer) ' Return DirectCast(ViewState("CveMoneda"), Integer)
End Get ' End Get
Set(value As Integer) ' Set(value As Integer)
ViewState("CveMoneda") = value ' ViewState("CveMoneda") = value
End Set ' End Set
End Property 'End Property
Private Property TCEspecifico As Double 'Private Property TCEspecifico As Double
Get ' Get
Return DirectCast(ViewState("TCEspecifico"), Double) ' Return DirectCast(ViewState("TCEspecifico"), Double)
End Get ' End Get
Set(value As Double) ' Set(value As Double)
ViewState("TCEspecifico") = value ' ViewState("TCEspecifico") = value
End Set ' End Set
End Property 'End Property
Private Property TipoCambio As Integer 'Private Property TipoCambio As Integer
Get ' Get
Return DirectCast(ViewState("TipoCambio"), Integer) ' Return DirectCast(ViewState("TipoCambio"), Integer)
End Get ' End Get
Set(value As Integer) ' Set(value As Integer)
ViewState("TipoCambio") = value ' ViewState("TipoCambio") = value
End Set ' End Set
End Property 'End Property
#End Region #End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
@@ -79,7 +88,23 @@ Partial Public Class General_SaldosMenores
End If End If
End Sub End Sub
Protected Sub BtnonClickTabs_Click(sender As Object, e As EventArgs) Protected Sub BtnonClickTabs_Click(sender As Object, e As EventArgs)
Consultar() 'Consultar()
GvDatosIXC.DataSource = Nothing
GvCxC.DataSource = Nothing
GvCxP.DataSource = Nothing
GvDatosIXC.DataBind()
GvCxC.DataBind()
GvCxP.DataBind()
DvSaldar.Visible = False
Upsaldar.Update()
UpDatos.Update()
UpDatosNCEXC.Update()
UPVentas.Update()
UPCompras.Update()
End Sub End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
Consultar() Consultar()
@@ -92,6 +117,7 @@ Partial Public Class General_SaldosMenores
DtDatosIXC = New DataTable DtDatosIXC = New DataTable
DtDatosNCEXC = New DataTable DtDatosNCEXC = New DataTable
DtDatosVentas = New DataTable DtDatosVentas = New DataTable
DtDatosCompras = New DataTable
DvSubProyectoSaldar1.Visible = False DvSubProyectoSaldar1.Visible = False
DvSubProyectoSaldar2.Visible = False DvSubProyectoSaldar2.Visible = False
@@ -117,12 +143,153 @@ Partial Public Class General_SaldosMenores
End If End If
End If End If
If Tabs.ActiveTab Is TabCompras Then
CargaDatosCompras()
If DtDatosCompras.Rows.Count > 0 Then
DvSaldar.Visible = True
End If
End If
Upsaldar.Update() Upsaldar.Update()
End Sub End Sub
Protected Sub BtnSaldar_Click(sender As Object, e As EventArgs) Protected Sub BtnSaldar_Click(sender As Object, e As EventArgs)
If Tabs.ActiveTab Is TabIXC Then If Tabs.ActiveTab Is TabIXC Then
SaldarIXC()
End If
If Tabs.ActiveTab Is TabVentas Then
SaldarVentas()
End If
If Tabs.ActiveTab Is TabCompras Then
SaldarCompras()
End If
Upsaldar.Update()
End Sub
Protected Sub CargaSucursales()
DdlSubProyectoSaldar.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa)
DdlSubProyectoSaldar.DataBind()
End Sub
#Region "I X C"
Protected Sub InicializaDatos()
txtFechaI.Text = $"01/01/{Now.Year}"
txtFechaF.Text = DateTime.Today.ToString()
TxtFecha.Text = DateTime.Today.ToString()
TxtSaldoMayorA.Text = "0"
TxtSaldoMenorA.Text = "1000"
CargaSucursales()
'
Tipo = -1
End Sub
Protected Sub CargaDatosIXC()
Dim FechaICorte As DateTime = MinFecha
Dim FechaFCorte As DateTime = MaxFecha
Dim ObjVenta As New ClsVentas()
Dim CveCliente As Integer = -1
If ObjVenta.GetRepAnticiposNCIXCDetalle(CveCliente, -1, txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 1, -1, -1, FechaICorte, FechaFCorte, -1, -1,
SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
GvDatosIXC.DataSource = ObjVenta.DtResultados
DtDatosIXC = ObjVenta.DtResultados
End If
ObjVenta.Dispose()
GvDatosIXC.DataBind()
UpDatos.Update()
End Sub
Protected Sub GvDatosIXC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosIXC.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Css As String = "Texto"
Dim Liga As String = ""
If e.Row.DataKey("Tipo").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales3"
e.Row.Cells(2).Text = e.Row.DBCampo("Moneda").ToString()
ElseIf e.Row.DataKey("CveCliente").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales2"
Select Case e.Row.DataKey("Tipo").ToEntero()
Case 1
e.Row.Cells(2).Text = "Anticipos"
Case 2
e.Row.Cells(2).Text = "NC X Aplicar"
Case 3
e.Row.Cells(2).Text = "Ingresos X Comprobar"
End Select
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() < 1 AndAlso e.Row.DataKey("CveIE").ToEntero() < 1 Then
e.Row.CssClass = "Totales"
e.Row.Cells(2).Text = e.Row.DataKey("NombreComercial")
e.Row.Cells(7).Text = ""
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() > 0 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
'If DdlTipo.SelectedValue.ToEntero() = 1 Then
' e.Row.Cells(4).Text = "$" & e.Row.DataKey("SubTotal").FormatoNumero()
'ElseIf DdlTipo.SelectedValue.ToEntero() = 2 Then
' e.Row.Cells(4).Text = "$" & e.Row.DataKey("Total").FormatoNumero()
'End If
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVenta")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
ElseIf e.Row.DataKey("CveIE").ToEntero() > 0 AndAlso e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("Total").FormatoNumero()
Liga = $"/Bancos/IE.aspx?&CveIE={e.Row.DataKey("CveIE")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
Else
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolioAmortizacion")
e.Row.Cells(3).Text = e.Row.DataKey("FechaAmortizacion").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(5).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(6).Text = "$" & e.Row.DataKey("SaldoAcumulativo").FormatoNumero()
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVentaAmortizacion")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
End If
If (e.Row.DataKey("CveVenta").ToEntero() > 0 OrElse e.Row.DataKey("CveIE").ToEntero() > 0) AndAlso (e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1) Then
e.Row.FCCheckBox("Chk").Visible = True
End If
End If
End Sub
Protected Sub SaldarIXC()
Dim ObjConta As New ClsContabilidad() Dim ObjConta As New ClsContabilidad()
ObjConta.IniciaTransacSQL() ObjConta.IniciaTransacSQL()
Dim CvePrePoliza As Integer = 0, CveVenta As Integer = -1, CveIE As Integer = -1 Dim CvePrePoliza As Integer = 0, CveVenta As Integer = -1, CveIE As Integer = -1
@@ -206,12 +373,150 @@ Partial Public Class General_SaldosMenores
CargaDatosIXC() CargaDatosIXC()
ObjConta.Dispose() ObjConta.Dispose()
End Sub
#End Region
#Region "N C E X C"
'/Compras/RepAnt-NC-EXCDetalle.aspx
Protected Sub CargaDatosNCEXC()
Dim FechaICorte As DateTime = MinFecha
Dim FechaFCorte As DateTime = MaxFecha
Dim ObjVenta As New ClsVentas()
Dim CveCliente As Integer = -1
If ObjVenta.GetRepAnticiposNCIXCDetalle(CveCliente, -1, txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 1, -1, -1, FechaICorte, FechaFCorte, -1, -1,
SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
GvDatosNCEXC.DataSource = ObjVenta.DtResultados
DtDatosNCEXC = ObjVenta.DtResultados
End If
ObjVenta.Dispose()
GvDatosIXC.DataBind()
UpDatos.Update()
End Sub
Protected Sub GvDatosNCEXC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosNCEXC.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Css As String = "Texto"
Dim Liga As String = ""
If e.Row.DataKey("Tipo").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales3"
e.Row.Cells(2).Text = e.Row.DBCampo("Moneda").ToString()
ElseIf e.Row.DataKey("CveCliente").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales2"
Select Case e.Row.DataKey("Tipo").ToEntero()
Case 1
e.Row.Cells(2).Text = "Anticipos"
Case 2
e.Row.Cells(2).Text = "NC X Aplicar"
Case 3
e.Row.Cells(2).Text = "Ingresos X Comprobar"
End Select
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() < 1 AndAlso e.Row.DataKey("CveIE").ToEntero() < 1 Then
e.Row.CssClass = "Totales"
e.Row.Cells(2).Text = e.Row.DataKey("NombreComercial")
e.Row.Cells(7).Text = ""
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() > 0 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVenta")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
ElseIf e.Row.DataKey("CveIE").ToEntero() > 0 AndAlso e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("Total").FormatoNumero()
Liga = $"/Bancos/IE.aspx?&CveIE={e.Row.DataKey("CveIE")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
Else
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolioAmortizacion")
e.Row.Cells(3).Text = e.Row.DataKey("FechaAmortizacion").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(5).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(6).Text = "$" & e.Row.DataKey("SaldoAcumulativo").FormatoNumero()
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVentaAmortizacion")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
End If End If
If Tabs.ActiveTab Is TabVentas Then If (e.Row.DataKey("CveVenta").ToEntero() > 0 OrElse e.Row.DataKey("CveIE").ToEntero() > 0) AndAlso (e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1) Then
e.Row.FCCheckBox("Chk").Visible = True
End If
End If
End Sub
#End Region
#Region "V E N T A S"
Protected Sub CargaDatosVentas()
Dim Mov As New ClsMovimientos
Dim FechaI As String = txtFechaI.Text
Dim FechaF As String = txtFechaF.Text
Dim FechaCorte As Date = NowADS().AddYears(1).ToShortDateString.ToString.ToDate
Dim SumDescuentoProntoPago As Double = 0.0
If Mov.GetCxCClienteDetalle(-1, FechaI, FechaF, -1, -1, UsuarioActual.CveEmpresa, -1, FechaCorte:=FechaCorte, Opcion:=2, SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
DtDatosVentas = Mov.DtResultados
'Dim TmpCxCAux As DataTable
'TmpCxCAux = Mov.DtResultados.FiltraParametros($"Saldo > {TxtSaldoMayorA.Text.ToDecimal} AND Saldo < {TxtSaldoMenorA.Text.ToDecimal} ", "Fecha,SerieFolio").AsEnumerable().Take(51).CopyToDataTable()
SumDescuentoProntoPago = DtDatosVentas.SUM("DescuentoProntoPago")
GvCxC.DataSource = DtDatosVentas
End If
Mov.Dispose()
GvCxC.DataBind()
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 GvCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCxC.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DataKey("CveVenta").ToEntero <= 0 Then
e.Row.BackColor = Drawing.Color.LightGray
e.Row.FCCheckBox("Chk").Visible = False
End If
End If
End Sub
Protected Sub SaldarVentas()
Dim ObjConta As New ClsContabilidad Dim ObjConta As New ClsContabilidad
ObjConta.IniciaTransacSQL() ObjConta.IniciaTransacSQL()
Dim CvePrePoliza As Integer = 0 Dim CvePrePoliza As Integer = 0
@@ -231,7 +536,7 @@ Partial Public Class General_SaldosMenores
End If End If
End If End If
CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFecha.Text.ToDate, TxtFecha.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFecha.Text.ToDate, TxtConcepto.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
For Each gr As GridViewRow In GvCxC.Rows For Each gr As GridViewRow In GvCxC.Rows
@@ -362,289 +667,190 @@ Partial Public Class General_SaldosMenores
ObjConta.Dispose() ObjConta.Dispose()
End If
TxtFecha.Text = DateTime.Today.ToString()
Upsaldar.Update()
End Sub End Sub
#Region "I X C"
Protected Sub InicializaDatos()
txtFechaI.Text = $"01/01/{Now.Year}"
txtFechaF.Text = DateTime.Today.ToString()
TxtFecha.Text = DateTime.Today.ToString()
TxtSaldoMayorA.Text = "0"
TxtSaldoMenorA.Text = "1000"
CargaSucursales()
Dim CveCliente As Integer = If(Request("CveCliente") Is Nothing, -1, Request("CveCliente").ToString().ToEntero())
CveMoneda = If(Request("CveMoneda") Is Nothing, -1, Request("CveMoneda").ToString().ToEntero())
txtFechaI.Text = If(Request("FechaI") Is Nothing, NowADS().ToString(), Request("FechaI").ToString())
txtFechaF.Text = If(Request("FechaF") Is Nothing, NowADS().ToString(), Request("FechaF").ToString())
TipoCambio = If(Request("TipoCambio") Is Nothing, 1, Request("TipoCambio").ToString().ToEntero())
TCEspecifico = If(Request("TCEspecifico") Is Nothing, -1, Request("TCEspecifico").ToString().ToDouble())
'RblTipoCambio.SelectedValue = TipoCambio.ToString()
'LiEspecifico.InnerText = TCEspecifico.FormatoNumero()
Dim FechaICorte As DateTime
FechaICorte = If(Request("FechaICorte") Is Nothing, DateTime.MinValue, Request("FechaICorte").ToString().ToDate())
Tipo = -1
End Sub
Protected Sub CargaSucursales()
DdlSubProyectoSaldar.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa)
DdlSubProyectoSaldar.DataBind()
End Sub
Protected Sub CargaDatosIXC()
Dim FechaICorte As DateTime = MinFecha
Dim FechaFCorte As DateTime = MaxFecha
Dim ObjVenta As New ClsVentas()
Dim CveCliente As Integer = -1
If ObjVenta.GetRepAnticiposNCIXCDetalle(CveCliente, -1, txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 1, -1, CveMoneda, FechaICorte, FechaFCorte, TipoCambio, TCEspecifico,
SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
GvDatosIXC.DataSource = ObjVenta.DtResultados
DtDatosIXC = ObjVenta.DtResultados
End If
ObjVenta.Dispose()
GvDatosIXC.DataBind()
UpDatos.Update()
End Sub
Protected Sub GvDatosIXC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosIXC.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Css As String = "Texto"
Dim Liga As String = ""
If e.Row.DataKey("Tipo").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales3"
e.Row.Cells(2).Text = e.Row.DBCampo("Moneda").ToString()
ElseIf e.Row.DataKey("CveCliente").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales2"
Select Case e.Row.DataKey("Tipo").ToEntero()
Case 1
e.Row.Cells(2).Text = "Anticipos"
Case 2
e.Row.Cells(2).Text = "NC X Aplicar"
Case 3
e.Row.Cells(2).Text = "Ingresos X Comprobar"
End Select
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() < 1 AndAlso e.Row.DataKey("CveIE").ToEntero() < 1 Then
e.Row.CssClass = "Totales"
e.Row.Cells(2).Text = e.Row.DataKey("NombreComercial")
e.Row.Cells(7).Text = ""
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() > 0 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
'If DdlTipo.SelectedValue.ToEntero() = 1 Then
' e.Row.Cells(4).Text = "$" & e.Row.DataKey("SubTotal").FormatoNumero()
'ElseIf DdlTipo.SelectedValue.ToEntero() = 2 Then
' e.Row.Cells(4).Text = "$" & e.Row.DataKey("Total").FormatoNumero()
'End If
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVenta")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
ElseIf e.Row.DataKey("CveIE").ToEntero() > 0 AndAlso e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("Total").FormatoNumero()
Liga = $"/Bancos/IE.aspx?&CveIE={e.Row.DataKey("CveIE")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
Else
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolioAmortizacion")
e.Row.Cells(3).Text = e.Row.DataKey("FechaAmortizacion").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(5).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(6).Text = "$" & e.Row.DataKey("SaldoAcumulativo").FormatoNumero()
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVentaAmortizacion")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
End If
If (e.Row.DataKey("CveVenta").ToEntero() > 0 OrElse e.Row.DataKey("CveIE").ToEntero() > 0) AndAlso (e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1) Then
e.Row.FCCheckBox("Chk").Visible = True
End If
End If
End Sub
#End Region #End Region
#Region "N C E X C" #Region "C O M P R A S"
'/Compras/RepAnt-NC-EXCDetalle.aspx
Protected Sub CargaDatosNCEXC()
Dim FechaICorte As DateTime = MinFecha
Dim FechaFCorte As DateTime = MaxFecha
Dim ObjVenta As New ClsVentas()
Dim CveCliente As Integer = -1
If ObjVenta.GetRepAnticiposNCIXCDetalle(CveCliente, -1, txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 1, -1, CveMoneda, FechaICorte, FechaFCorte, TipoCambio, TCEspecifico,
SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
GvDatosNCEXC.DataSource = ObjVenta.DtResultados
DtDatosNCEXC = ObjVenta.DtResultados
End If
ObjVenta.Dispose()
GvDatosIXC.DataBind()
UpDatos.Update()
End Sub Protected Sub CargaDatosCompras()
Protected Sub GvDatosNCEXC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosNCEXC.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Css As String = "Texto"
Dim Liga As String = ""
If e.Row.DataKey("Tipo").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales3"
e.Row.Cells(2).Text = e.Row.DBCampo("Moneda").ToString()
ElseIf e.Row.DataKey("CveCliente").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales2"
Select Case e.Row.DataKey("Tipo").ToEntero()
Case 1
e.Row.Cells(2).Text = "Anticipos"
Case 2
e.Row.Cells(2).Text = "NC X Aplicar"
Case 3
e.Row.Cells(2).Text = "Ingresos X Comprobar"
End Select
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() < 1 AndAlso e.Row.DataKey("CveIE").ToEntero() < 1 Then
e.Row.CssClass = "Totales"
e.Row.Cells(2).Text = e.Row.DataKey("NombreComercial")
e.Row.Cells(7).Text = ""
ElseIf e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 AndAlso e.Row.DataKey("CveVenta").ToEntero() > 0 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVenta")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
ElseIf e.Row.DataKey("CveIE").ToEntero() > 0 AndAlso e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1 Then
e.Row.CssClass = "SubTotales"
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolio")
e.Row.Cells(3).Text = e.Row.DataKey("Fecha").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("Total").FormatoNumero()
Liga = $"/Bancos/IE.aspx?&CveIE={e.Row.DataKey("CveIE")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
Else
e.Row.Cells(2).Text = e.Row.DataKey("SerieFolioAmortizacion")
e.Row.Cells(3).Text = e.Row.DataKey("FechaAmortizacion").ToDate().ToShortDateString()
e.Row.Cells(4).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(5).Text = "$" & e.Row.DataKey("ImporteAmortizacion").FormatoNumero()
e.Row.Cells(6).Text = "$" & e.Row.DataKey("SaldoAcumulativo").FormatoNumero()
Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DataKey("CveVentaAmortizacion")}"
e.Row.Cells(2).Text = $"<a class=""{Css}"" href=""{Liga}"">{e.Row.Cells(2).Text}</a>"
End If
If (e.Row.DataKey("CveVenta").ToEntero() > 0 OrElse e.Row.DataKey("CveIE").ToEntero() > 0) AndAlso (e.Row.DataKey("CveVentaAmortizacion").ToEntero() < 1) Then
e.Row.FCCheckBox("Chk").Visible = True
End If
End If
End Sub
#End Region
#Region "V E N T A S"
'/Compras/RepAnt-NC-EXCDetalle.aspx
Protected Sub CargaDatosVentas()
Dim Mov As New ClsMovimientos Dim Mov As New ClsMovimientos
Dim FechaI As String = txtFechaI.Text Dim FechaI As String = txtFechaI.Text
Dim FechaF As String = txtFechaF.Text Dim FechaF As String = txtFechaF.Text
Dim FechaCorte As Date = NowADS().AddYears(1).ToShortDateString.ToString.ToDate
Dim SumDescuentoProntoPago As Double = 0.0
If Mov.GetCxCClienteDetalle(-1, FechaI, FechaF, -1, -1, UsuarioActual.CveEmpresa, -1, FechaCorte:=FechaCorte, Opcion:=2, SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
DtDatosVentas = Mov.DtResultados
'Dim TmpCxCAux As DataTable
'TmpCxCAux = Mov.DtResultados.FiltraParametros($"Saldo > {TxtSaldoMayorA.Text.ToDecimal} AND Saldo < {TxtSaldoMenorA.Text.ToDecimal} ", "Fecha,SerieFolio").AsEnumerable().Take(51).CopyToDataTable()
SumDescuentoProntoPago = DtDatosVentas.SUM("DescuentoProntoPago")
GvCxC.DataSource = DtDatosVentas
If Mov.GetCxPProveedor(-1, FechaI, FechaF, -1, -1, -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", CveSubProyecto:=-1, Opcion:=2, CveEmpresa:=UsuarioActual.CveEmpresa, SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
DtDatosCompras = Mov.DtResultados
GvCxP.DataSource = DtDatosCompras
DtDatosCompras.Columns.Add("Movimiento")
If DtDatosCompras.Rows.Count > 0 Then
DtDatosCompras.Rows(0)("Movimiento") = "FACTURA DE ACREEDOR"
End If
End If End If
Mov.Dispose() Mov.Dispose()
GvCxC.DataBind() GvCxP.DataBind()
UPCompras.Update()
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 End Sub
Protected Sub GvCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCxC.RowDataBound Protected Sub GvCxP_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCxP.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DataKey("CveVenta").ToEntero <= 0 Then
e.Row.BackColor = Drawing.Color.LightGray 'e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo")))
If e.Row.DataKey("CveCompra").ToEntero = 0 Then
e.Row.FCCheckBox("Chk").Visible = False e.Row.FCCheckBox("Chk").Visible = False
e.Row.BackColor = Drawing.Color.LightGray
End If End If
End If End If
End Sub End Sub
Protected Sub SaldarCompras()
Dim ObjConta As New ClsContabilidad
ObjConta.IniciaTransacSQL()
Dim CvePrePoliza As Integer = 0
Dim MsgError As String = ""
Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
Dim EsContabilizable As Boolean = If(UsuarioActual.CveEmpresa.Contiene(13, 83), False, True)
CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ProveedoresAbonar/Saldar", 98, 0, 0, 1, TxtFecha.Text.ToDate, TxtConcepto.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
For Each gr As GridViewRow In GvCxP.Rows
If gr.FCCheckBox("Chk").Checked Then
Dim Saldo As Decimal = gr.DataKey("Saldo").ToDecimal 'gr.DataKey("Saldo").ToDecimal
Dim TCCompra As Decimal = gr.DataKey("TipoCambio").ToDecimal
Dim TCPago As Decimal = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
Dim CveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero
Dim FechaCompra As Date = gr.DataKey("Fecha").ToDate
Dim CveSubProyecto As Integer = gr.DataKey("CveSubProyecto").ToEntero
Dim CveConceptoContablePago As Integer = 17
If gr.DataKey("CveTipoConcepto").ToEntero = 2 Then CveConceptoContablePago = 308 'cuando es acreedor
If CveMoneda <> 1 Then
Select Case CveConceptoContablePago
Case 17
CveConceptoContablePago = 312
Case 308
CveConceptoContablePago = 309
Case Else
End Select
End If
Dim CveConceptoContableComplementaria As Integer = 206
If gr.DataKey("CveTipoConcepto").ToEntero = 2 Then CveConceptoContableComplementaria = 310 'cuando es acreedor
Dim ConceptoPartida As String = String.Format("Saldar compra {0}", gr.DataKey("SerieFolio").ToString)
If CveMoneda > 1 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Saldo, Saldo, CveConceptoContablePago, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, ImporteME:=If(CveMoneda > 1, Saldo, 0), Contabilizable:=EsContabilizable) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, 0.00D, (Saldo * TCCompra - Saldo).RoundSQL, CveConceptoContableComplementaria, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteME:=Saldo, TipoCambio:=TCCompra, Contabilizable:=EsContabilizable) Then
MsgError = "No se pudo insertar la póliza"
End If
Else
TCPago = 1
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Saldo, If(CveMoneda = 1, Saldo, Saldo * TCCompra), CveConceptoContablePago, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteME:=If(CveMoneda > 1, Saldo, 0), TipoCambio:=TCCompra, Contabilizable:=EsContabilizable) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
End If
Dim PorcentajePago As Decimal = Saldo / gr.DataKey("TotalOriginal").ToDecimal
If MsgError = "" AndAlso gr.DataKey("IVA").ToDecimal > 0 Then
Dim PorcentajeImpuesto As Decimal = gr.DataKey("PorcentajeIVA").ToDecimal
Dim IVA As Decimal = PorcentajePago * gr.DataKey("IVA").ToDecimal
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, If(CveMoneda = 1, IVA, IVA * If(FuncionalidadFluctuacionImpuestos, TCPago, TCCompra)), 14, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=EsContabilizable) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
Saldo = Saldo - IVA
End If
If MsgError = "" AndAlso gr.DataKey("IEPS").ToDecimal > 0 Then
Dim IEPS As Decimal = PorcentajePago * gr.DataKey("IEPS").ToDecimal
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, If(CveMoneda = 1, IEPS, IEPS * If(FuncionalidadFluctuacionImpuestos, TCPago, TCCompra)), 25, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, Contabilizable:=EsContabilizable) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
Saldo = Saldo - IEPS
End If
' se manda al ot ingresos, los impuestos por acreditar
If MsgError = "" Then
Dim tcvecon As Integer = 78
Dim tTipoMovto As Boolean = True
If Saldo < 0 Then
tcvecon = 211
tTipoMovto = False
End If
If MsgError = "" AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, tTipoMovto, Saldo, (Saldo * TCPago).RoundSQL, tcvecon, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, TipoCambioPago:=TCPago, CveSubProyecto:=CveSubProyecto, Contabilizable:=EsContabilizable) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
End If
'fluctuación.
If CveMoneda > 1 Then
Dim ImporteFluctuacion As Decimal = 0
ImporteFluctuacion = Saldo * (TCPago - TCCompra)
If CveSubProyecto <= 0 Then MsgError = "No se pudo obtener el sub proyecto o centro de costo"
If TCCompra > TCPago Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), Math.Abs(ImporteFluctuacion), 64, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveSubProyecto:=CveSubProyecto, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, TipoCambioPago:=TCPago, Contabilizable:=EsContabilizable) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
Else
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), Math.Abs(ImporteFluctuacion), 65, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveSubProyecto:=CveSubProyecto, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, TipoCambioPago:=TCPago, Contabilizable:=EsContabilizable) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
End If
End If
End If
Next
If MsgError.Trim.Length = 0 AndAlso CvePrePoliza > 0 Then
If MsgError = "" AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 5) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia
GuardaLogAD($"Bancos/ProveedoresAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
End If
End If
End If
If MsgError = "" Then
ObjConta.Commit()
CargaDatosCompras()
RegistraScript("$('#ModalSaldarCuentaSinPagar').modal('hide')")
Dim Msg As New StringBuilder
Msg.Append("Los movimientos se saldaron correctamente.</br>")
If UsuarioActual.TienePermisoProceso(354) Then 'visualizar la póliza al registros
Msg.AppendFormat("<a Class=""Texto"" target='_blank' href=""/Contabilidad/RegPrePolizaS.aspx?CvePrePoliza={0}"">Ver Póliza</a>&nbsp;&nbsp; ", CvePrePoliza)
End If
Alert(Msg.ToString)
Else
ObjConta.RollBack()
Alert(MsgError, TipoMensaje.MsgError)
End If
ObjConta.Dispose()
End Sub
#End Region #End Region
End Class End Class