diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 8e1a04e7f..d7e65134c 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1406,6 +1406,29 @@
+ + + + + + + + + + + + + + + + +
Descuento Adicional Por Pago: +   +
Total Original: +   +
Total a Pagar: +   +
@@ -2449,127 +2472,127 @@
- - - -
- -
- -
- -
- -
-
-
-
- -
-
- - -
-
-
- -
- -
- -
- -
-
-
-
- - -
-
Nombre:
-
- -
-
-
-
Calle:
-
- -
-
Núm.
-
- -
-
CP.
-
- -
-
-
-
Pais:
-
- - -
-
Estado:
-
- - -
-
-
-
Municipio:
-
- - -
-
Colonia:
-
- - -
-
-
-
+ + +
+ +
+ +
+ +
+ +
-
-
-
- Convertir a unidad Aduana +
+
+ +
+
+ + +
+
+
+ <%-- +
+ +
--%> + +
+ +
+
+
+
+ + +
+
Nombre:
+
+ +
+
+
+
Calle:
+
+ +
+
Núm.
+
+ +
+
CP.
+
+ +
+
+
+
Pais:
+
+ + +
+
Estado:
+
+ + +
+
+
+
Municipio:
+
+ + +
+
Colonia:
+
+ + +
+
+
+
+ +
+
+
+
+ Convertir a unidad Aduana - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-
- - + +
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 2580050e6..51f0e67e0 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5993,6 +5993,21 @@ Partial Class Ventas DdlFormaCliente.DataBind() DdlMetodoCliente.DataSource = GlobalDTVtaMetodoPago DdlMetodoCliente.DataBind() + + If CveMetodoPago = 1 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso TbDescuentosAdicionales.Visible Then + If TmpDT.SUMD("Descuento") > 0 Then + Dim TotalDescuento As Decimal = TmpDT.SUMD("Total", "Descuento > 0") * 0.05D + Dim RowDescuentos = TmpDT.Select("Descuento > 0") + + If RowDescuentos IsNot Nothing Then + LblDescuentoAdicional.Text = TotalDescuento.FormatoNumero(2) + CalculaTotalesVenta() + End If + Else + LblDescuentoAdicional.Text = "0.00" + End If + UpPS.Update() + End If 'End If End Sub Private Sub CargaUsoCFDI() @@ -6423,9 +6438,9 @@ Partial Class Ventas End If If ObjCliente.AplicaComercioExterior Then - DdlSATMotivoTraslado.DataSource = GlobalDTSATMotivoTraslado - DdlSATMotivoTraslado.DataBind() - DdlSATMotivoTraslado.SelectedValueExist(ObjCliente.CveMotivoTraslado) + 'DdlSATMotivoTraslado.DataSource = GlobalDTSATMotivoTraslado + 'DdlSATMotivoTraslado.DataBind() + 'DdlSATMotivoTraslado.SelectedValueExist(ObjCliente.CveMotivoTraslado) DdlIncoterm.Items.Clear() DdlIncoterm.DataSource = GlobalDTIncoterm() DdlIncoterm.DataBind() @@ -7298,7 +7313,9 @@ Partial Class Ventas LblEstado.Text = ObjCliente.DtResultados.Rows(0)("Estado").ToString() 'TxtNumCtaPago.Text = ObjCliente.DtResultados.Rows(0)("NumCtaPago").ToString() LblTelefono.Text = ObjCliente.DtResultados.Rows(0)("Telefono").ToString() - LblCP.Text = ObjCliente.DtResultados.Rows(0)("CP").ToString() + If Not UsuarioActual.Empresa.Funcionalidad(350) = "1" Then + LblCP.Text = ObjCliente.DtResultados.Rows(0)("CP").ToString() + End If ViewState("CliLocalidad") = ObjCliente.DtResultados.Rows(0)("Localidad").ToString() ViewState("CliPais") = ObjCliente.DtResultados.Rows(0)("Pais").ToString() ViewState("CliNoExt") = ObjCliente.DtResultados.Rows(0)("NoExt").ToString() @@ -8557,7 +8574,6 @@ Partial Class Ventas #End Region #Region " EMITIR IMPRIMIR - GUARDAR " - Protected Sub BtnEmitirImprimir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEmitirImprimir.Click Try EmitirImprimir() @@ -9184,11 +9200,12 @@ Partial Class Ventas Dim ArchivoSti As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta)) Dim ArchivoSti2 As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.mrt", UsuarioActual.Empresa.Ruta)) + Dim ArchivoSti3 As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.mrt", UsuarioActual.Empresa.Ruta)) LnkImprimir.Visible = False 'If (UsuarioActual.CveEmpresa.Contiene(1, 4, 5, 7, 11, 12, 72, 80, 81, 83) And UsuarioActual.CveUsuario = 100) Or UsuarioActual.CveEmpresa.Contiene(80, 83) Or UsuarioActual.CveUsuario = 100 Then - If (Archivo.Exists Or Archivo2.Exists Or ArchivoSti.Exists Or ArchivoSti2.Exists) And IfNull(CveVenta, 0).ToString().ToEntero() > 0 Then + If (Archivo.Exists Or Archivo2.Exists Or ArchivoSti.Exists Or ArchivoSti2.Exists Or ArchivoSti3.Exists) And IfNull(CveVenta, 0).ToString().ToEntero() > 0 Then HplDownPDF.Visible = True HplDownPDF.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta))) If UsuarioActual.CveRol = 1 Then @@ -9218,10 +9235,8 @@ Partial Class Ventas Exit Sub End If - CreaObjetosVenta(TipoDoctoViejo:=TipoDoctoViejo) - 'Verifica versión 3.3.() - If ObjFactura.Version = "3.3" AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then + If (Not UsuarioActual.Empresa.Funcionalidad(350) = "1") AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then Dim dttsat As DataTable = TmpDT.FiltraParametros("ISNULL(SATClaveProdServ,'') = '' OR ISNULL(SATClaveUM,'') = '' ") If dttsat IsNot Nothing AndAlso dttsat.Rows.Count > 0 Then Dim str As New StringBuilder @@ -9253,6 +9268,40 @@ Partial Class Ventas End If End If + 'CREA UNA COPIA DE SEGURIDAD PARA LOS DATOS DEL TMPDT + If TmpDTError Is Nothing OrElse TmpDTError.Rows.Count = 0 Then + TmpDTError = TmpDT.Copy() + End If + + If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso TbDescuentosAdicionales.Visible Then + If LblDescuentoAdicional.Text.ToDecimal() > 0 Then + Dim TotalDescuento As Decimal = LblDescuentoAdicional.Text.ToDecimal() / (1D + TmpDT.MAX("PorcentajeIVA").ToString().ToDecimal()) + Dim RowDescuentos = TmpDT.Select("Descuento > 0") + + If RowDescuentos IsNot Nothing Then + + Dim Row As DataRow = RowDescuentos(0) + Row("Descuento") = Row("Descuento").ToString().ToDecimal() + TotalDescuento + + Dim TotalCalculableImpuestos As Decimal = (Row("Cantidad").ToString().ToDecimal() * Row("PU").ToString().ToDecimal()) - Row("Descuento").ToString().ToDecimal() + Row("ImporteIVA") = (TotalCalculableImpuestos * Row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2) + + CalculaTotalesVenta(RecalcularTotalOriginal:=False) + + 'UpPS.Update() + 'VALIDA EL CALCULO DE LOS DESCUENTOS + If (LblTotalOriginal.Text.ToDecimal() - LblDescuentoAdicional.Text.ToDecimal()) <> TxtTotal.Text.ToDecimal() Then + TmpDT = TmpDTError.Copy() + CalculaTotalesVenta(RecalcularTotalOriginal:=False) + Alert("Ocurrió un error al procesar los datos de la Venta. Los descuentos no coinciden con el importe final", TipoMensaje.MsgError) + Exit Sub + End If + End If + End If + End If + + CreaObjetosVenta(TipoDoctoViejo:=TipoDoctoViejo) + If ObjFactura Is Nothing Or (ObjFactura.Cliente Is Nothing And Not CveEmpresaCRM > 0) Then Alert("Ocurrió un error al procesar los datos de la Venta.", TipoMensaje.MsgError) ObjFactura = Nothing @@ -10138,6 +10187,7 @@ Partial Class Ventas MensajeAlert = Nothing If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose() TmpDT = TmpDTError.Copy + CalculaTotalesVenta(RecalcularTotalOriginal:=False) Else ObjVentas.RollBack() @@ -10161,7 +10211,7 @@ Partial Class Ventas MensajeAlert = Nothing If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose() TmpDT = TmpDTError.Copy - + CalculaTotalesVenta(RecalcularTotalOriginal:=False) End If ObjFactura = Nothing ListaNotasCreditoGeneradas = Nothing @@ -12197,115 +12247,116 @@ Partial Class Ventas i += 1 Next - Dim AplicaComercioExteriorSubProyecto As Boolean + Dim AplicaComercioExteriorSubProyecto As Boolean = True If ChkEmitirComercioExterior.Checked Then - AplicaComercioExteriorSubProyecto = If(GlobalDTSubProyectos(-1, Obj.CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa)(0)("AplicaComercioExterior").ToString() = "True", True, False) + 'AplicaComercioExteriorSubProyecto = If(GlobalDTSubProyectos(-1, Obj.CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa)(0)("AplicaComercioExterior").ToString() = "True", True, False) Timbre.Complementos.ComercioExterior11.AplicaComercioExteriorSubProyecto = AplicaComercioExteriorSubProyecto - If Obj.Cliente.AplicaComercioExterior And AplicaComercioExteriorSubProyecto Then - 'DATOS GENERALES + 'DATOS GENERALES - Timbre.Comprobante.Exportacion = "02" - Timbre.Complementos.ComercioExterior11.TipoOperacion = GlobalDTTipoOperacion().FiltraParametros($"CveTipoOperacion={CveTipoOperacion}")(0)("ClaveSATTipoOperacion").ToString() - Timbre.Complementos.ComercioExterior11.ClavedePedimento = GlobalDTClavePedimento().FiltraParametros($"CvePedimento={CvePedimento}")(0)("ClaveSATPedimento").ToString() - Timbre.Complementos.ComercioExterior11.CertificadoOrigen = "0" - Timbre.Complementos.ComercioExterior11.Incoterm = GlobalDTIncoterm.FiltroPrimeroValor("ClaveSATIncoterm", $"CveIncoterm={DdlIncoterm.SelectedValue}") - Timbre.Complementos.ComercioExterior11.Subdivision = "0" + Timbre.Comprobante.Exportacion = "02" + Timbre.Complementos.ComercioExterior11.TipoOperacion = GlobalDTTipoOperacion().FiltraParametros($"CveTipoOperacion={CveTipoOperacion}")(0)("ClaveSATTipoOperacion").ToString() + Timbre.Complementos.ComercioExterior11.ClavedePedimento = GlobalDTClavePedimento().FiltraParametros($"CvePedimento={CvePedimento}")(0)("ClaveSATPedimento").ToString() + Timbre.Complementos.ComercioExterior11.CertificadoOrigen = "0" + Timbre.Complementos.ComercioExterior11.Incoterm = GlobalDTIncoterm.FiltroPrimeroValor("ClaveSATIncoterm", $"CveIncoterm={DdlIncoterm.SelectedValue}") + Timbre.Complementos.ComercioExterior11.Subdivision = "0" - Timbre.Complementos.ComercioExterior11.TipoCambioUSD = If(Obj.CveMoneda = 1, 1, Obj.TipoCambio) - If Timbre.Comprobante.TipoComprobante = "T" Then - Timbre.Complementos.ComercioExterior11.MotivoTraslado = GlobalDTSATMotivoTraslado.FiltroPrimeroValor("ClaveSATMotivoTraslado", $"CveMotivoTraslado={DdlSATMotivoTraslado.SelectedValue}") - Else - Timbre.Complementos.ComercioExterior11.MotivoTraslado = "" - End If + Timbre.Complementos.ComercioExterior11.TipoCambioUSD = If(Obj.CveMoneda = 1, 1, Obj.TipoCambio) - 'EMISOR - Dim Dr As DataRow - Dr = Nothing - If GlobalDTSubProyectos(-1, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).Rows.Count > 0 Then - Dr = GlobalDTSubProyectos(-1, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa)(0) - End If - Timbre.Complementos.ComercioExterior11.Emisor.CURP = UsuarioActual.Empresa.CURP - Timbre.Complementos.ComercioExterior11.Emisor.Calle = Dr("Calle").ToString() - Timbre.Complementos.ComercioExterior11.Emisor.NumeroExterior = Dr("NoExt").ToString() - Timbre.Complementos.ComercioExterior11.Emisor.NumeroInterior = Dr("NoInt").ToString() - Timbre.Complementos.ComercioExterior11.Emisor.Colonia = Dr("ClaveSATColonia").ToString() - Timbre.Complementos.ComercioExterior11.Emisor.Localidad = "" - Timbre.Complementos.ComercioExterior11.Emisor.Municipio = Dr("ClaveSATMunicipio").ToString() - Timbre.Complementos.ComercioExterior11.Emisor.Estado = Dr("ClaveSATEstado").ToString() - Timbre.Complementos.ComercioExterior11.Emisor.Pais = Dr("ClaveSATPais").ToString() - Timbre.Complementos.ComercioExterior11.Emisor.CP = Dr("ClaveSATCP").ToString() + Timbre.Complementos.ComercioExterior11.MotivoTraslado = "" - Dim ComExtPais, ComExtEstado, ComExtMunicipio, ComExtColonia, ComExtCalle, ComExtNumero, ComExtCP As String - ComExtColonia = "" : ComExtMunicipio = "" - ComExtPais = GlobalDTGralPaises.FiltroPrimeroValor("ClaveSATPais", $"CvePais={DdlComExtPais.SelectedValue}") - ComExtCalle = TxtComExtCalle.Text.Trim - ComExtNumero = TxtComExtNumero.Text.Trim - ComExtCP = TxtComExtCP.Text.Trim + 'If Timbre.Comprobante.TipoComprobante = "T" Then + ' Timbre.Complementos.ComercioExterior11.MotivoTraslado = GlobalDTSATMotivoTraslado.FiltroPrimeroValor("ClaveSATMotivoTraslado", $"CveMotivoTraslado={DdlSATMotivoTraslado.SelectedValue}") + 'Else + ' Timbre.Complementos.ComercioExterior11.MotivoTraslado = "" + 'End If - If ComExtPais = "MEX" Then + 'EMISOR + Dim Dr As DataRow + Dr = Nothing + If GlobalDTSubProyectos(-1, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).Rows.Count > 0 Then + Dr = GlobalDTSubProyectos(-1, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa)(0) + End If + Timbre.Complementos.ComercioExterior11.Emisor.CURP = UsuarioActual.Empresa.CURP + Timbre.Complementos.ComercioExterior11.Emisor.Calle = Dr("Calle").ToString() + Timbre.Complementos.ComercioExterior11.Emisor.NumeroExterior = Dr("NoExt").ToString() + Timbre.Complementos.ComercioExterior11.Emisor.NumeroInterior = Dr("NoInt").ToString() + Timbre.Complementos.ComercioExterior11.Emisor.Colonia = Dr("ClaveSATColonia").ToString() + Timbre.Complementos.ComercioExterior11.Emisor.Localidad = "" + Timbre.Complementos.ComercioExterior11.Emisor.Municipio = Dr("ClaveSATMunicipio").ToString() + Timbre.Complementos.ComercioExterior11.Emisor.Estado = Dr("ClaveSATEstado").ToString() + Timbre.Complementos.ComercioExterior11.Emisor.Pais = Dr("ClaveSATPais").ToString() + Timbre.Complementos.ComercioExterior11.Emisor.CP = Dr("ClaveSATCP").ToString() + + Dim ComExtPais, ComExtEstado, ComExtMunicipio, ComExtColonia, ComExtCalle, ComExtNumero, ComExtCP As String + ComExtColonia = "" : ComExtMunicipio = "" + ComExtPais = GlobalDTGralPaises.FiltroPrimeroValor("ClaveSATPais", $"CvePais={DdlComExtPais.SelectedValue}") + ComExtCalle = TxtComExtCalle.Text.Trim + ComExtNumero = TxtComExtNumero.Text.Trim + ComExtCP = TxtComExtCP.Text.Trim + + If ComExtPais = "MEX" Then + ComExtEstado = GlobalDTGralEstados(ComExtPais).FiltroPrimeroValor("ClaveSATEstado", $"CveEstado={DdlComExtEstado.SelectedValue}") + ComExtMunicipio = GlobalDTGralMunicipios(ComExtEstado).FiltroPrimeroValor("ClaveSATMunicipio", $"CveMunicipio={DdlComExtMunicipio.SelectedValue}") + ComExtColonia = GlobalDTGralColonias("-1", "-1", "-1", CveColonia:=DdlComExtColonia.SelectedValue.ToEntero).FiltroPrimeroValor("ClaveSATColonia", "") + Else + If ComExtPais.Contiene("USA", "CAN") Then ComExtEstado = GlobalDTGralEstados(ComExtPais).FiltroPrimeroValor("ClaveSATEstado", $"CveEstado={DdlComExtEstado.SelectedValue}") - ComExtMunicipio = GlobalDTGralMunicipios(ComExtEstado).FiltroPrimeroValor("ClaveSATMunicipio", $"CveMunicipio={DdlComExtMunicipio.SelectedValue}") - ComExtColonia = GlobalDTGralColonias("-1", "-1", "-1", CveColonia:=DdlComExtColonia.SelectedValue.ToEntero).FiltroPrimeroValor("ClaveSATColonia", "") Else - If ComExtPais.Contiene("USA", "CAN") Then - ComExtEstado = GlobalDTGralEstados(ComExtPais).FiltroPrimeroValor("ClaveSATEstado", $"CveEstado={DdlComExtEstado.SelectedValue}") - Else - ComExtEstado = TxtComExtEstado.Text.Trim - End If - ComExtMunicipio = TxtComExtMunicipio.Text.Trim - ComExtColonia = TxtComExtColonia.Text.Trim + ComExtEstado = TxtComExtEstado.Text.Trim End If + ComExtMunicipio = TxtComExtMunicipio.Text.Trim + ComExtColonia = TxtComExtColonia.Text.Trim + End If - 'RECEPTOR - Timbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib = If(Timbre.Comprobante.Version = "4.0", Obj.Cliente.NumRegIdTrib, "") ' EN LA VERSION 3.3 NO DEBE DE REGISTRARSE ESTE VALOR - Timbre.Complementos.ComercioExterior11.Receptor.Calle = ComExtCalle - Timbre.Complementos.ComercioExterior11.Receptor.NumeroExterior = ComExtNumero - Timbre.Complementos.ComercioExterior11.Receptor.NumeroInterior = "" - Timbre.Complementos.ComercioExterior11.Receptor.Colonia = ComExtColonia - Timbre.Complementos.ComercioExterior11.Receptor.Localidad = "" - Timbre.Complementos.ComercioExterior11.Receptor.Referencia = Obj.Cliente.ReferenciaFiscal - Timbre.Complementos.ComercioExterior11.Receptor.Municipio = ComExtMunicipio - Timbre.Complementos.ComercioExterior11.Receptor.CP = ComExtCP - Timbre.Complementos.ComercioExterior11.Receptor.Estado = ComExtEstado - Timbre.Complementos.ComercioExterior11.Receptor.Pais = ComExtPais - Timbre.Receptor.ResidenciaFiscal = Obj.Cliente.ClaveSATPais - Timbre.Receptor.NumeroRegistroTributario = Obj.Cliente.NumRegIdTrib + 'RECEPTOR + Timbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib = If(Timbre.Comprobante.Version = "4.0", Obj.Cliente.NumRegIdTrib, "") ' EN LA VERSION 3.3 NO DEBE DE REGISTRARSE ESTE VALOR + Timbre.Complementos.ComercioExterior11.Receptor.Calle = ComExtCalle + Timbre.Complementos.ComercioExterior11.Receptor.NumeroExterior = ComExtNumero + Timbre.Complementos.ComercioExterior11.Receptor.NumeroInterior = "" + Timbre.Complementos.ComercioExterior11.Receptor.Colonia = ComExtColonia + Timbre.Complementos.ComercioExterior11.Receptor.Localidad = "" + Timbre.Complementos.ComercioExterior11.Receptor.Referencia = Obj.Cliente.ReferenciaFiscal + Timbre.Complementos.ComercioExterior11.Receptor.Municipio = ComExtMunicipio + Timbre.Complementos.ComercioExterior11.Receptor.CP = ComExtCP + Timbre.Complementos.ComercioExterior11.Receptor.Estado = ComExtEstado + Timbre.Complementos.ComercioExterior11.Receptor.Pais = ComExtPais + Timbre.Receptor.ResidenciaFiscal = Obj.Cliente.ClaveSATPais + Timbre.Receptor.NumeroRegistroTributario = Obj.Cliente.NumRegIdTrib - 'DESTINATARIO - Timbre.Complementos.ComercioExterior11.Destinatario = Nothing + 'DESTINATARIO + Timbre.Complementos.ComercioExterior11.Destinatario = Nothing - 'Timbre.Complementos.ComercioExterior11.Destinatario.Nombre = TxtDestinatarioNombre.Text.Trim - 'Timbre.Complementos.ComercioExterior11.Destinatario.Calle = ComExtCalle - 'Timbre.Complementos.ComercioExterior11.Destinatario.NumeroExterior = ComExtNumero - 'Timbre.Complementos.ComercioExterior11.Destinatario.NumeroInterior = "" - 'Timbre.Complementos.ComercioExterior11.Destinatario.Colonia = ComExtColonia - 'Timbre.Complementos.ComercioExterior11.Destinatario.Localidad = "" - 'Timbre.Complementos.ComercioExterior11.Destinatario.Referencia = Obj.Cliente.ReferenciaFiscal - 'Timbre.Complementos.ComercioExterior11.Destinatario.Municipio = ComExtMunicipio - 'Timbre.Complementos.ComercioExterior11.Destinatario.CP = ComExtCP - 'Timbre.Complementos.ComercioExterior11.Destinatario.Estado = ComExtEstado - 'Timbre.Complementos.ComercioExterior11.Destinatario.Pais = ComExtPais - 'Timbre.Complementos.ComercioExterior11.Destinatario.NumRegIdTrib = TxtNumRegIdTrib.Text.Trim + 'Timbre.Complementos.ComercioExterior11.Destinatario.Nombre = TxtDestinatarioNombre.Text.Trim + 'Timbre.Complementos.ComercioExterior11.Destinatario.Calle = ComExtCalle + 'Timbre.Complementos.ComercioExterior11.Destinatario.NumeroExterior = ComExtNumero + 'Timbre.Complementos.ComercioExterior11.Destinatario.NumeroInterior = "" + 'Timbre.Complementos.ComercioExterior11.Destinatario.Colonia = ComExtColonia + 'Timbre.Complementos.ComercioExterior11.Destinatario.Localidad = "" + 'Timbre.Complementos.ComercioExterior11.Destinatario.Referencia = Obj.Cliente.ReferenciaFiscal + 'Timbre.Complementos.ComercioExterior11.Destinatario.Municipio = ComExtMunicipio + 'Timbre.Complementos.ComercioExterior11.Destinatario.CP = ComExtCP + 'Timbre.Complementos.ComercioExterior11.Destinatario.Estado = ComExtEstado + 'Timbre.Complementos.ComercioExterior11.Destinatario.Pais = ComExtPais + 'Timbre.Complementos.ComercioExterior11.Destinatario.NumRegIdTrib = TxtNumRegIdTrib.Text.Trim - 'MERCANCIAS - For Each Gvr As GridViewRow In GvComercioExterior.Rows - Dim mercancia As New CFDIComercioExterior11Mercancias With {.CantidadAduana = Gvr.FCTextBox("TxtCantidad").Text.ToDecimal, + 'MERCANCIAS + For Each Gvr As GridViewRow In GvComercioExterior.Rows + Dim mercancia As New CFDIComercioExterior11Mercancias With {.CantidadAduana = Gvr.FCTextBox("TxtCantidad").Text.ToDecimal, .FraccionArancelaria = Gvr.DataKey("ClaveSATFraccionArancelaria").ToString(), .UnidadAduana = Gvr.DataKey("ClaveSATUnidadAduana").ToString(), .ValorDolares = Math.Round(Gvr.FCTextBox("TxtCantidad").Text.ToDecimal * Gvr.FCTextBox("TxtValorUnitario").Text.ToDecimal, 2), .ValorUnitarioAduana = Gvr.FCTextBox("TxtValorUnitario").Text.ToDecimal, .NoIdentificacion = Gvr.DataKey("Codigo")} - If Gvr.FCTextBox("TxtMarca").Text <> "" Then - mercancia.DescripcionesEspecificas.Marca = Gvr.FCTextBox("TxtMarca").Text - End If + If Gvr.FCTextBox("TxtMarca").Text <> "" Then + mercancia.DescripcionesEspecificas.Marca = Gvr.FCTextBox("TxtMarca").Text + End If - Timbre.Complementos.ComercioExterior11.Mercancias.Add(mercancia) - i += 1 - Next - End If + Timbre.Complementos.ComercioExterior11.Mercancias.Add(mercancia) + i += 1 + Next Else @@ -17969,6 +18020,12 @@ Partial Class Ventas ObjDescuento.ImporteDescuento = 0 Return ObjDescuento End If + + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Cot") AndAlso CveRinTamañoPS > 0 Then + If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso Not TbDescuentosAdicionales.Visible Then + TbDescuentosAdicionales.Visible = True + End If + End If End If Dim dr As DataRow = Nothing @@ -19241,7 +19298,7 @@ Partial Class Ventas ConfiguraTipoDocto() End If End Sub - Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True, Optional NCDescuento As Boolean = False, Optional ValidarDescuentos As Boolean = False) + Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True, Optional NCDescuento As Boolean = False, Optional ValidarDescuentos As Boolean = False, Optional RecalcularTotalOriginal As Boolean = True) Dim TotalSubTotal As Decimal = TmpDT.SUMD("TotalImporte") Dim TotalSubTotalRef As Decimal = TotalSubTotal @@ -19346,6 +19403,12 @@ Partial Class Ventas LblTotalAPagar.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado - TotalProntoPago).FormatoNumero + If RecalcularTotalOriginal Then + LblTotalOriginal.Text = (TxtTotal.Text.ToDecimal()).FormatoNumero + End If + + LblTotalAPagarAdicional.Text = (LblTotalOriginal.Text.ToDecimal() - LblDescuentoAdicional.Text.ToDecimal()).FormatoNumero + LblAmort.Text = TxtSubTotal.Text If CveVenta <= 0 OrElse (CveDevolucion > 0 And NuevaFactura = 1) Then HdnVentaSaldo.Value = Total.ToString() @@ -22071,6 +22134,9 @@ Partial Class Ventas Dim saldo = TxtTotal.Text.Replace(",", "").ToDouble - abonado 'CVImporteContado.ValueToCompare = (saldo.FormatoNumero(2).ToDouble).ToString() + LblDescuentoAdicional.Text = "0.00" + CalculaTotalesVenta() + CargaGridContado() UpContado.Update() End Sub @@ -22322,6 +22388,40 @@ Partial Class Ventas End If End If + Dim VieneDeCotizacion As Boolean = False + If DtCotizacionesPS IsNot Nothing AndAlso DtCotizacionesPS.Rows.Count > 0 Then + VieneDeCotizacion = True + End If + + If DdlTipoComprobante.SelectedValue = "Ing" AndAlso (Not VieneDeCotizacion) AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso DtPagos IsNot Nothing AndAlso TbDescuentosAdicionales.Visible Then + If TmpDT.SUMD("Descuento") > 0 AndAlso DtPagos.SUMD("Importe", "MesesSinIntereses <=0") = TxtTotal.Text.ToDecimal() Then + Dim TotalDescuento As Decimal = TmpDT.SUMD("Total", "Descuento > 0") * 0.05D + Dim RowDescuentos = TmpDT.Select("Descuento > 0") + + If RowDescuentos IsNot Nothing Then + LblDescuentoAdicional.Text = TotalDescuento.FormatoNumero(2) + + 'Dim Row As DataRow = RowDescuentos(0) + 'Row("Descuento") = Row("Descuento").ToString().ToDecimal() + TotalDescuento + + 'Dim TotalCalculableImpuestos As Decimal = (Row("Cantidad").ToString().ToDecimal() * Row("PU").ToString().ToDecimal()) - Row("Descuento").ToString().ToDecimal() + 'Row("ImporteIVA") = (TotalCalculableImpuestos * Row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2) + + 'BtnAgregarPago.Enabled = False + + CalculaTotalesVenta() + + Dim RowPago = DtPagos.Rows(0) + RowPago("Importe") = LblTotalAPagarAdicional.Text.ToDecimal() + + + End If + Else + LblDescuentoAdicional.Text = "0.00" + End If + UpPS.Update() + End If + CargaGridContado() UpContado.Update() @@ -22360,7 +22460,7 @@ Partial Class Ventas If (Not PermiteCredito OrElse RBLPago.SelectedValue = "2") AndAlso TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() + AmortizacionNC - If TotalPago <> TxtTotal.Text.ToDecimal Then + If TotalPago <> (TxtTotal.Text.ToDecimal - LblDescuentoAdicional.Text.ToDecimal()) Then If MostrarAlertas Then Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia) End If @@ -29481,7 +29581,8 @@ Partial Class Ventas Dim PU As Decimal = If(AplicaPUEditado, Gv.FCTextBox("TxtPrecioEditado").Text.ToDecimal, Gv.DataKey("PU").ToDecimal) Dim Total As Decimal = (Cantidad * PU) Dim TotalImpuestos As Decimal = (Cantidad * PU) - Descuento - Dim ImporteIVA As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeIVA").ToString().ToDecimal + Dim TotalCalculableImpuestosIVA = TotalImpuestos * (1 + Gv.DataKey("PorcentajeIEPS").ToString().ToDecimal) + Dim ImporteIVA As Decimal = TotalCalculableImpuestosIVA * Gv.DataKey("PorcentajeIVA").ToString().ToDecimal Dim ImporteRetIVA As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeRetIVA").ToString().ToDecimal Dim ImporteRetISR As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeRetISR").ToString().ToDecimal Dim ImporteIEPS As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeIEPS").ToString().ToDecimal @@ -35535,6 +35636,9 @@ Partial Class Ventas Protected Sub ChkEmitirComercioExterior_CheckedChanged(sender As Object, e As EventArgs) If CveVenta <= 0 OrElse EsCreaApartirDe Then + + ViewState("AplicaComercioExterior") = ChkEmitirComercioExterior.Checked + If ChkEmitirComercioExterior.Checked Then DdlMoneda.SelectedValueExist("2") CambiaMoneda()
Descuentos RNC: