diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index cacb9655c..f6e935237 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -716,7 +716,7 @@ Partial Class Ventas_PVCobranza End If 'GENERAR NC PARA AMORTIZACION - If ListaAnticiposAplicados IsNot Nothing AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then + If ListaAnticiposAplicados IsNot Nothing AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() AndAlso TxtNCDev.Text.ToDecimal() > 0 Then For Each gvr As GridViewRow In GVAnticipos.Rows If gvr.DataKey("Tipo") = "Ant" AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then @@ -1187,6 +1187,14 @@ Partial Class Ventas_PVCobranza ListaAnticiposAplicados = Nothing End If + If GVAnticipos IsNot Nothing Then + For Each GvRow As GridViewRow In GVAnticipos.Rows + If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing Then + GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked = False + End If + Next + End If + ImgAntiPend.Visible = False DivAnticipo.Visible = False @@ -1314,28 +1322,31 @@ Partial Class Ventas_PVCobranza DtAnticipos.Columns.Add("Folio", GetType(String)) DtAnticipos.Columns.Add("Tipo", GetType(String)) - For Each GvRow As GridViewRow In GVAnticipos.Rows - If GvRow.DataKey("Tipo").Contiene("NC", "IxC") AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then + If TxtNCDev.Text.ToDecimal() > 0 Then + For Each GvRow As GridViewRow In GVAnticipos.Rows + If GvRow.DataKey("Tipo").Contiene("NC", "IxC") AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then - Dim CveVenta = GvRow.DataKey("CveVenta").ToEntero() - Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal() - Dim CveConceptoContable = GvRow.DataKey("CveConceptoContable").ToEntero() - Dim CveIE = GvRow.DataKey("CveIE").ToEntero() + Dim CveVenta = GvRow.DataKey("CveVenta").ToEntero() + Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal() + Dim CveConceptoContable = GvRow.DataKey("CveConceptoContable").ToEntero() + Dim CveIE = GvRow.DataKey("CveIE").ToEntero() - Dim FolioFiscal = GvRow.DataKey("FolioFiscal") - Dim Descuentos As Decimal = GvRow.DataKey("Descuentos").ToDecimal() - Dim TotalAnticipo As Decimal = GvRow.DataKey("TotalAnticipo").ToDecimal() - Dim SubTotalAnticipo As Decimal = GvRow.DataKey("SubTotalAnticipo").ToDecimal() - Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero() - Dim Fecha As DateTime = GvRow.DataKey("Fecha").ToDateTime() - Dim TipoCambioPago As Decimal = GvRow.DataKey("TipoCambioPago").ToDecimal() - Dim Folio = GvRow.DataKey("Folio") - Dim Tipo = GvRow.DataKey("Tipo") + Dim FolioFiscal = GvRow.DataKey("FolioFiscal") + Dim Descuentos As Decimal = GvRow.DataKey("Descuentos").ToDecimal() + Dim TotalAnticipo As Decimal = GvRow.DataKey("TotalAnticipo").ToDecimal() + Dim SubTotalAnticipo As Decimal = GvRow.DataKey("SubTotalAnticipo").ToDecimal() + Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero() + Dim Fecha As DateTime = GvRow.DataKey("Fecha").ToDateTime() + Dim TipoCambioPago As Decimal = GvRow.DataKey("TipoCambioPago").ToDecimal() + Dim Folio = GvRow.DataKey("Folio") + Dim Tipo = GvRow.DataKey("Tipo") - DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo) + DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo) + + End If + Next + End If - End If - Next If DtAnticipos.Rows.Count > 0 Then ObjFactura.EsNCAmortizacion = True @@ -1481,16 +1492,22 @@ Partial Class Ventas_PVCobranza ObjNC.AgregarPS(CvePSAnticipo, Cantidad, PU, Descuento, Obs, CveSubProyecto:=Venta.CveSubProyecto, PorcentajeIVA:=Venta.PorcentajeIVA) ObjNC.CalculaTotales() + Dim CveIE As Integer = -1 + If GvRowAnticipo IsNot Nothing Then + CveIE = GvRowAnticipo.DataKey("CveIE").ToEntero() + End If + 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("CveIE", GetType(Integer)) 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}) DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "Folio", .DataType = GetType(String), .DefaultValue = ""}) - DtVentasNC.Rows.Add(Venta.CveVenta, Total, "") + 'DtVentasNC.Rows.Add(Venta.CveVenta, CveIE, Total, "") ObjNC.DtVentasNC = DtVentasNC @@ -1519,7 +1536,7 @@ Partial Class Ventas_PVCobranza Dim CveVenta = GvRowAnticipo.DataKey("CveVenta").ToEntero() Dim Importe = GvRowAnticipo.FCTextBox(String.Format("TxtAnticipo{0}", GvRowAnticipo.RowIndex)).Text.ToDecimal() Dim CveConceptoContable = GvRowAnticipo.DataKey("CveConceptoContable").ToEntero() - Dim CveIE = GvRowAnticipo.DataKey("CveIE").ToEntero() + Dim FolioFiscal = GvRowAnticipo.DataKey("FolioFiscal") Dim Descuentos As Decimal = GvRowAnticipo.DataKey("Descuentos").ToDecimal() @@ -1546,7 +1563,6 @@ Partial Class Ventas_PVCobranza ObjNC.CveTipoRelacion = 7 ObjNC.PreparaTimbre() - 'AjustarTimbreNC(ObjNC) Retorno = ObjNC.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True) Retorno.Factura = ObjNC