diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 25548fcf6..662753b41 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -2728,6 +2728,7 @@ Partial Class Bancos_IE Dim TipoMovtoAplicar = False For Each Dr As DataRow In ObjMov.DtResultados.FiltraParametros("CveConceptoContable IN (13,8,9,38)").Rows + Dim PorcentajeImpuesto As Decimal = Dr("PorcentajeImpuesto").ToString.ToDecimal() CveConceptoContableAplciar = Dr("CveConceptoContable").ToString.ToEntero TipoMovtoAplicar = Not CBool(Dr("TipoMovto").ToString) ImporteAplicar = (Dr("Importe").ToString.ToDecimal * PorcentajePagoDevDin).RoundSQL() @@ -2735,7 +2736,7 @@ Partial Class Bancos_IE ImporteAplicarME = (Dr("ImporteME").ToString.ToDecimal * PorcentajePagoDevDin).RoundSQL() IdCtaContableAplicar = Dr("IdCtaContable").ToString.ToEntero - If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, ImporteAplicar, ReferenciaAplicar, CveConceptoContableAplciar, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME) Then + If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, ImporteAplicar, ReferenciaAplicar, CveConceptoContableAplciar, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME, PorcentajeImpuesto:=PorcentajeImpuesto) Then Select Case CveConceptoContableAplciar Case 13 CveConceptoContableAplciar = 61 @@ -2747,7 +2748,7 @@ Partial Class Bancos_IE CveConceptoContableAplciar = 39 End Select TipoMovtoAplicar = Not TipoMovtoAplicar - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, ImporteAplicar, ReferenciaAplicar, CveConceptoContableAplciar, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, ImporteAplicar, ReferenciaAplicar, CveConceptoContableAplciar, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución" Exit Select End If diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 3355cd25b..07149a6ab 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -1927,7 +1927,7 @@ Partial Class PV Else ObjVentas.Commit() If ObjAC IsNot Nothing Then ObjAC.Commit() - Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:="BtnRefrescarPagina();") + Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:="document.location.href=""/Ventas/PV.aspx"";") End If ObjVentas.Dispose() diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index d6ae66541..0132a3566 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -21903,12 +21903,19 @@ Partial Class Ventas End If ObjCliente.Dispose() - AplicarNC(DdlNCPS.SelectedValue.ToEntero(), EsNCAmortizacion:=ChkAplicaNCAnticipo.Checked, AplicaImpuestosLocales:=AplicaImpuestosLocales) + Dim AplicaNuevoDocumento As Boolean = False + + 'SOLO APLICA SI NO HAY DOCUMENTOS QUE SELECCIONAR + If UsuarioActual.CveEmpresa = 140 AndAlso GvCxC.Rows.Count = 0 Then + AplicaNuevoDocumento = True + End If + + AplicarNC(DdlNCPS.SelectedValue.ToEntero(), EsNCAmortizacion:=ChkAplicaNCAnticipo.Checked, AplicaImpuestosLocales:=AplicaImpuestosLocales, AplicaNuevoDocumento:=AplicaNuevoDocumento) RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC") End Sub - Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True) + Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional AplicaNuevoDocumento As Boolean = False) Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") If DrPS Is Nothing Then Alert("Ocurrió un error al cargar la información del producto. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) @@ -21951,41 +21958,48 @@ Partial Class Ventas DtImpuestos.AcceptChanges() Dim AcumuladoNC As Decimal = 0 - If AplicaNCMasiva Then - If NCDescuento Then - For Each RNC In ListaNCDesc - DtImpuestos.Merge(CargaDtImpuestosNC(RNC.CveVenta, RNC.TotalRemNCAplicado, NCDescuento:=True, AplicaImpuestosLocales:=AplicaImpuestosLocales), True, MissingSchemaAction.Ignore) - Next - Else + If Not AplicaNuevoDocumento Then + If AplicaNCMasiva Then + If NCDescuento Then + For Each RNC In ListaNCDesc + DtImpuestos.Merge(CargaDtImpuestosNC(RNC.CveVenta, RNC.TotalRemNCAplicado, NCDescuento:=True, AplicaImpuestosLocales:=AplicaImpuestosLocales), True, MissingSchemaAction.Ignore) + Next + Else - For Each Gvr As GridViewRow In GvCxC.Rows - If Gvr.FCCheckBox("ChkCxC").Checked Then - DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString().ToEntero(), Gvr.FCTextBox("TxtImporte").Text.ToString().ToDecimal, AplicaImpuestosLocales:=AplicaImpuestosLocales), True, MissingSchemaAction.Ignore) - 'CARGA FACTURA A LA CUAL SE APLICA LA NC - AcumuladoNC += Gvr.FCTextBox("TxtImporte").Text.ToString().ToDecimal - CargaNCDT(Gvr.DataKey("CveVenta").ToString().ToEntero(), Gvr.FCTextBox("TxtImporte").Text.ToString().ToDecimal) + For Each Gvr As GridViewRow In GvCxC.Rows + If Gvr.FCCheckBox("ChkCxC").Checked Then + DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString().ToEntero(), Gvr.FCTextBox("TxtImporte").Text.ToString().ToDecimal, AplicaImpuestosLocales:=AplicaImpuestosLocales), True, MissingSchemaAction.Ignore) + 'CARGA FACTURA A LA CUAL SE APLICA LA NC + AcumuladoNC += Gvr.FCTextBox("TxtImporte").Text.ToString().ToDecimal + CargaNCDT(Gvr.DataKey("CveVenta").ToString().ToEntero(), Gvr.FCTextBox("TxtImporte").Text.ToString().ToDecimal) + End If + Next + End If + Else + DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal, AplicaImpuestosLocales:=AplicaImpuestosLocales) + + If EsNCAmortizacion Then + If DtAnticipoAmortizacion Is Nothing Then + InicializaDTAnticiposAmortizacion() End If - Next + Dim PorcentajeAplicado As Decimal = (TxtNCPorcentaje.Text.ToDecimal / 100D) + + Dim RowAnticipo As DataRow = DtAnticipoAmortizacion.NewRow + RowAnticipo("CveVenta") = Me.CveVenta + RowAnticipo("Importe") = TxtNCImporte.Text.Trim.ToDecimal + RowAnticipo("SaldoAnticipo") = SaldoAnticipo * PorcentajeAplicado + + DtAnticipoAmortizacion.Rows.Add(RowAnticipo) + End If + End If Else - DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal, AplicaImpuestosLocales:=AplicaImpuestosLocales) - - If EsNCAmortizacion Then - If DtAnticipoAmortizacion Is Nothing Then - InicializaDTAnticiposAmortizacion() - End If - Dim PorcentajeAplicado As Decimal = (TxtNCPorcentaje.Text.ToDecimal / 100D) - - Dim RowAnticipo As DataRow = DtAnticipoAmortizacion.NewRow - RowAnticipo("CveVenta") = Me.CveVenta - RowAnticipo("Importe") = TxtNCImporte.Text.Trim.ToDecimal - RowAnticipo("SaldoAnticipo") = SaldoAnticipo * PorcentajeAplicado - - DtAnticipoAmortizacion.Rows.Add(RowAnticipo) - End If - + For Each RNC In ListaRemisionesNC + DtImpuestos.Merge(CargaDtImpuestosNC(RNC.CveVenta, RNC.TotalRemNCAplicado, NCDescuento:=True, AplicaImpuestosLocales:=AplicaImpuestosLocales), True, MissingSchemaAction.Ignore) + Next End If + Dim query = From dr In DtImpuestos Group By PorcentajeIVA = dr("PorcentajeIVA").ToString().ToDecimal, PorcentajeRetIVA = dr("PorcentajeRetIVA").ToString().ToDecimal, @@ -22004,7 +22018,10 @@ Partial Class Ventas PorcentajeIEPS = PorcentajeIEPS '(1 + DrPS("IEPSPorcentaje").ToString().ToDecimal) - Dim DrSubProyecto = GlobalDTSubProyectos(-1, TmpDT.FiltroPrimeroValor("CveSubProyecto", "", "ImporteTotal DESC").ToEntero(), UsuarioActual.CveEmpresa, -1).FiltroPrimero("") + 'Dim DrSubProyecto = GlobalDTSubProyectos(-1, TmpDT.FiltroPrimeroValor("CveSubProyecto", "", "ImporteTotal DESC").ToEntero(), UsuarioActual.CveEmpresa, -1).FiltroPrimero("") + + Dim DrSubProyecto = GlobalDTSubProyectos(-1, DdlSubProyectoDatos.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, -1).FiltroPrimero("") + If DrSubProyecto Is Nothing Then Alert("Ocurrió un error al cargar la información de centro de costos. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) Exit Sub @@ -22100,8 +22117,8 @@ Partial Class Ventas Dim TmpDT As DataTable = Nothing Dim TmpDTImpuestos As DataTable = Nothing - Dim ObjVentas As New ClsVentas + Dim ObjVentas As New ClsVentas If ObjVentas.GetVentaImpuestosLocales(CveVentaNC) Then If ObjVentas.DtResultados.Rows.Count > 0 Then TmpDTImpuestos = ObjVentas.DtResultados.Copy() @@ -22127,7 +22144,8 @@ Partial Class Ventas End If ObjVentas.Dispose() - Dim DtImpuestosLocal = TmpDT.FiltraParametros("", "", {"PorcentajeIVA", "PorcentajeRetIVA", "PorcentajeRetISR", "PorcentajeIEPS", "CveSubProyecto"}).Copy + + 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))