-- cambios en carta porte

This commit is contained in:
2021-12-11 16:56:01 -07:00
parent 456b057d31
commit 1e02a1874d
20 changed files with 1678 additions and 2824 deletions

View File

@@ -4380,7 +4380,7 @@ Partial Class Clientes
Private Sub CargaDirClientePais()
DdlDirClientePais.DataSource = GlobalDTPais()
DdlDirClientePais.DataSource = GlobalDTGralPaises()
DdlDirClientePais.DataBind()
DdlDirClientePais.SelectedValueExist("151")
End Sub
@@ -4388,7 +4388,7 @@ Partial Class Clientes
Private Sub CargaDirClienteEstado()
DdlDirClienteEstado.Items.Clear()
If DdlDirClientePais.SelectedValue.ToEntero > 0 Then
DdlDirClienteEstado.DataSource = GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlDirClientePais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString)
DdlDirClienteEstado.DataSource = GlobalDTEstado(GlobalDTGralPaises.FiltraParametros($"CvePais = {DdlDirClientePais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString)
End If
DdlDirClienteEstado.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteEstado.DataBind()
@@ -4397,7 +4397,7 @@ Partial Class Clientes
Private Sub CargaDirClienteMunicipio()
DdlDirClienteMunicipio.Items.Clear()
If DdlDirClienteEstado.SelectedValue.ToEntero > 0 Then
DdlDirClienteMunicipio.DataSource = GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlDirClientePais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlDirClienteEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString)
DdlDirClienteMunicipio.DataSource = GlobalDTMunicipio(GlobalDTEstado(GlobalDTGralPaises.FiltraParametros($"CvePais = {DdlDirClientePais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlDirClienteEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString)
End If
DdlDirClienteMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteMunicipio.DataBind()
@@ -4405,8 +4405,8 @@ Partial Class Clientes
Private Sub CargaDirClienteColonia()
DdlDirClienteColonia.Items.Clear()
If DdlDirClienteMunicipio.SelectedValue.ToEntero > 0 Then
DdlDirClienteColonia.DataSource = GlobalDTColonia(GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlDirClientePais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlDirClienteEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString).FiltraParametros($"CveMunicipio = {DdlDirClienteMunicipio.SelectedValue.ToEntero}")(0)("ClaveSATMunicipio").ToString).FiltraParametros(If(TxtEnvioCP.Text.Trim.Length > 0, $"CP = {TxtEnvioCP.Text}", ""))
If DdlDirClienteMunicipio.SelectedValue.ToEntero > 0 Then
DdlDirClienteColonia.DataSource = GlobalDTGralColonias("-1", "-1", "-1", DdlDirClienteMunicipio.SelectedValue.ToEntero, CodigoPostal:=If(TxtEnvioCP.Text.Trim.Length > 0, TxtEnvioCP.Text.ToEntero, -1))
End If
DdlDirClienteColonia.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteColonia.DataBind()
@@ -4455,16 +4455,14 @@ Partial Class Clientes
Private Sub DirClientevalidaCodigoPostal()
Dim CPTxt As Integer = TxtEnvioCP.Text.ToEntero()
Dim CveColonia As Integer = DdlDirClienteColonia.SelectedValue.ToEntero
If CPTxt > 0 And CveColonia > 0 Then
Dim CP As Integer = GlobalDTColonia("-1").FiltroPrimeroValor("CP", $"CveColonia = {CveColonia}").ToEntero
Dim CP As Integer = GlobalDTGralColonias("-1", "-1", "-1", CveColonia:=CveColonia).FiltroPrimeroValor("CP", "").ToEntero
If CPTxt <> CP Then
Alert("El codigo postal selecionado es diferente del codigo postal de la Colonia.", TipoMensaje.MsgAdvertencia)
Alert("El código postal selecionado es diferente del codigo postal de la Colonia.", TipoMensaje.MsgAdvertencia)
End If
End If
@@ -6930,7 +6928,7 @@ Partial Class Clientes
Private Sub CargaPais()
DdlPais.Items.Clear()
DdlPais.DataSource = GlobalDTPais()
DdlPais.DataSource = GlobalDTGralPaises()
DdlPais.DataBind()
DdlPais.SelectedValueExist("151")
End Sub
@@ -6938,7 +6936,7 @@ Partial Class Clientes
Private Sub CargaEstado()
DdlEstado.Items.Clear()
If DdlPais.SelectedValue.ToEntero() > 0 Then
DdlEstado.DataSource = GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero()}")(0)("ClaveSATPais").ToString())
DdlEstado.DataSource = GlobalDTEstado(GlobalDTGralPaises.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero()}")(0)("ClaveSATPais").ToString())
End If
DdlEstado.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlEstado.DataBind()
@@ -6947,7 +6945,7 @@ Partial Class Clientes
Private Sub CargaMunicipio()
DdlMunicipio.Items.Clear()
If DdlEstado.SelectedValue.ToEntero() > 0 Then
DdlMunicipio.DataSource = GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero()}")(0)("ClaveSATPais").ToString()).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero()}")(0)("ClaveSATEstado").ToString())
DdlMunicipio.DataSource = GlobalDTMunicipio(GlobalDTEstado(GlobalDTGralPaises.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero()}")(0)("ClaveSATPais").ToString()).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero()}")(0)("ClaveSATEstado").ToString())
End If
DdlMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlMunicipio.DataBind()
@@ -6956,10 +6954,11 @@ Partial Class Clientes
Private Sub CargaColonia()
DdlColonia.Items.Clear()
If DdlMunicipio.SelectedValue.ToEntero() > 0 Then
DdlColonia.DataSource = GlobalDTColonia(GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero()}")(0)("ClaveSATPais").ToString()).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero()}")(0)("ClaveSATEstado").ToString()).FiltraParametros($"CveMunicipio = {DdlMunicipio.SelectedValue.ToEntero()}")(0)("ClaveSATMunicipio").ToString())
DdlColonia.DataSource = GlobalDTGralColonias("-1", "-1", "-1", DdlMunicipio.SelectedValue.ToEntero)
End If
DdlColonia.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlColonia.DataBind()
DdlColonia.DataBind()
End Sub
Protected Sub DdlPais_SelectedIndexChanged(sender As Object, e As EventArgs)
@@ -9788,10 +9787,6 @@ Partial Class Clientes
ObjFactura.Serie = Serie
ObjFactura.Fecha = Now
ObjFactura.CvePrePoliza = -1
'ObjFactura.CveMetodoPago = DdlMetodoPago.SelectedValue.Toentero()
'ObjFactura.MetodoPago = DdlMetodoPago.SelectedItem.Text
'ObjFactura.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {DdlMetodoPago.SelectedValue}")
ObjFactura.FechaVencimiento = TxtFechaPago.Text.ToDate()
ObjFactura.CveMetodoPago33 = DdlMetodoPago33.SelectedValue.ToEntero()
@@ -9811,24 +9806,16 @@ Partial Class Clientes
ObjFactura.CondicionEntrega = ""
ObjFactura.CondicionesPago = 0 ' 0 - Contado, 1 - Credito, 2 - termianl
ObjFactura.FormaPago = 0
ObjFactura.AtnA = ""
ObjFactura.FordGSDB = ""
ObjFactura.NumeroContrato = ""
ObjFactura.DescripcionContrato = ""
ObjFactura.NumeroDescripcionContrato = ""
ObjFactura.PedidoContrato = ""
ObjFactura.OrdenCompra = ""
ObjFactura.FormaPago = 0
Select Case ObjFactura.TipoDocto
Case "Ing"
ObjFactura.TipoDocumento = "Factura"
Case "Rem"
ObjFactura.TipoDocumento = "Remision"
Case "Cot"
ObjFactura.TipoDocumento = "Cotizacion"
ObjFactura.TipoDocumento = "Cotización"
Case "Egs"
ObjFactura.TipoDocumento = "Nota de Crédito"
Case "Dev"
@@ -9843,30 +9830,18 @@ Partial Class Clientes
ObjFactura.Fech1 = Now
ObjFactura.Fech2 = Now
ObjFactura.Fech3 = Now
ObjFactura.Alfa1 = ""
ObjFactura.Alfa2 = ""
ObjFactura.Alfa3 = ""
'NUM 1- CARGO 2- BONIFICACION
ObjFactura.Fech3 = Now
'NUM 1- CARGO 2- BONIFICACION
ObjFactura.Num1 = Tipo
ObjFactura.Num2 = 0
ObjFactura.Num3 = 0
ObjFactura.FechaPago = Now
ObjFactura.CveCorte = -1
ObjFactura.CveMesa = -1
ObjFactura.NumeroPersonas = 0
ObjFactura.CveContrato = -1
ObjFactura.CveClienteSucursal = DdlSucursalCliente.SelectedValue.ToEntero()
ObjFactura.Entrega = ""
ObjFactura.Vigencia = Now
ObjFactura.CveVentaPadre = -1
ObjFactura.CveVendedor = DdlVendedor.SelectedValue.ToEntero()
If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then
DdlVendedor.Enabled = False
@@ -9875,14 +9850,9 @@ Partial Class Clientes
ObjFactura.FechaEjecucion = Now
ObjFactura.CveSubProyecto = UsuarioActual.CveSubProyecto
ObjFactura.CveSubProyectoCobranza = UsuarioActual.CveSubProyecto
ObjFactura.CveSubProyectoEjecucion = UsuarioActual.CveSubProyecto
ObjFactura.AtencionA = "-1"
ObjFactura.MotivoDescuento = ""
ObjFactura.Observaciones = ""
ObjFactura.Det_OrdenCompra = ""
ObjFactura.Det_FechaOrdenCompra = ""
ObjFactura.MonedaAbreviatura = ""
ObjFactura.CveSubProyectoEjecucion = UsuarioActual.CveSubProyecto
ObjFactura.SubTotal = SubTotalFactura
ObjFactura.Descuento = 0
ObjFactura.Amortizacion = 0
@@ -9930,505 +9900,12 @@ Partial Class Clientes
Next
ObjFactura.UsadosBonificacion = UsadosBonificacion
ObjFactura.TipoBonificacion = Tipo
Dim FM As New Modelos.FemsaFactura
Dim TmpDT7Eleven As New DataTable
Dim TmpDTComplementosTimbrado As New DataTable
'PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
ObjFactura.FemsaFactura = FM
' ObjFactura.Timbre = PreParaTimbre(ObjFactura)
ObjFactura.TipoBonificacion = Tipo
' ObjFactura.Timbre = PreParaTimbre(ObjFactura)
End Sub
'Private Sub PrepararTimbrado(ByRef FM As Modelos.FemsaFactura, ByRef TmpDT7Eleven As DataTable, ByRef TmpDTComplementosTimbrado As DataTable)
' FM.AplicaFEMSA = ChkAplicaFEMSA.Checked
' FM.FEMSA_NumSociedad = ""
' FM.FEMSA_NumProveedor = ""
' FM.FEMSA_Mail = ""
' FM.FEMSA_Version = "".Toentero()
' FM.FEMSA_NumPedido = "".Toentero()
' FM.FEMSA_NumEntrada = ""
' FM.FEMSA_NumRemision = ""
' FM.FEMSA_NumSocio = ""
' FM.FEMSA_CentroCosto = ""
' FM.FEMSA_IPeriodoLiquidacion = ""
' FM.FEMSA_FPeriodoLiquidacion = ""
' FM.FEMSA_CodRetencion1 = ""
' FM.FEMSA_CodRetencion2 = ""
' TmpDT7Eleven.Columns.Add("sevenElevenNumProveedor")
' TmpDT7Eleven.Columns.Add("sevenElevenFolio")
' TmpDT7Eleven.Columns.Add("sevenElevenTienda")
' TmpDT7Eleven.Columns.Add("sevenElevenFecha")
' Dim Row As DataRow = TmpDT7Eleven.NewRow
' Row("sevenElevenNumProveedor") = ""
' Row("sevenElevenFolio") = ""
' Row("sevenElevenTienda") = ""
' Row("sevenElevenFecha") = ""
' TmpDT7Eleven.Rows.Add(Row)
' TmpDTComplementosTimbrado.Columns.Add("CveComplemento")
' TmpDTComplementosTimbrado.Columns.Add("IdContabilidad")
' TmpDTComplementosTimbrado.Columns.Add("TipoProceso")
' TmpDTComplementosTimbrado.Columns.Add("TipoAmbito")
' TmpDTComplementosTimbrado.Columns.Add("Entidad")
' Dim Row2 As DataRow = TmpDTComplementosTimbrado.NewRow
' Row2("CveComplemento") = -1
' Row2("IdContabilidad") = -1
' Row2("TipoProceso") = -1
' Row2("TipoAmbito") = -1
' Row2("Entidad") = -1
' TmpDTComplementosTimbrado.Rows.Add(Row2)
'End Sub
'Private Function PreParaTimbre(Obj As 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
' Try
' Obj.SetSubProyecto(Me)
' Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
' Catch ex As Exception
' End Try
' Timbre.Comprobante.Confirmacion = ""
' Timbre.Receptor.RFC = Obj.Cliente.RFC
' Timbre.Receptor.Nombre = Obj.Cliente.Nombre
' Timbre.Receptor.ResidenciaFiscal = ""
' Timbre.Receptor.NumeroRegistroTributario = ""
' Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI
' If Obj.CveTipoRelacion > 0 Then
' Select Case Obj.CveTipoRelacion
' Case 1
' Timbre.CFDIRelacionados.TipoRelacion = "01"
' Timbre.CFDIRelacionados.TipoRelacionTexto = "01-Nota de Crédito aplicada a Ingreso"
' Case 2
' Timbre.CFDIRelacionados.TipoRelacion = "02"
' Timbre.CFDIRelacionados.TipoRelacionTexto = "02-Nota de débito de los documentos relacionados"
' Case 3
' Timbre.CFDIRelacionados.TipoRelacion = "03"
' Timbre.CFDIRelacionados.TipoRelacionTexto = "03-Devolución aplicada a Ingreso"
' Case 4
' Timbre.CFDIRelacionados.TipoRelacion = "04"
' Timbre.CFDIRelacionados.TipoRelacionTexto = "04-Refacturación de Ingreso"
' Case 7
' Timbre.CFDIRelacionados.TipoRelacion = "07"
' Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
' Case 8
' Timbre.CFDIRelacionados.TipoRelacion = "08"
' Timbre.CFDIRelacionados.TipoRelacionTexto = "08-Factura generada por pagos en parcialidades "
' Case 9
' Timbre.CFDIRelacionados.TipoRelacion = "09"
' Timbre.CFDIRelacionados.TipoRelacionTexto = "09-Factura generada por pagos diferidos"
' End Select
' End If
' Dim totSubTotal As Decimal = Obj.SubTotal
' Dim totIVA As Decimal = Obj.IVA
' Dim totRetIVA As Decimal = Obj.RetIVA
' Dim totRetISR As Decimal = Obj.RetISR
' Dim TasaRetIVA As Decimal = 0
' Dim TasaRetISR As Decimal = 0
' 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
' '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 = drr("TotalImporte").ToString().ToDecimal(),
' .Descuento = drr("Descuento").ToString().ToDecimal(),
' .Unidad = drr("UM").ToString(),
' .ClaveUnidad = drr("SATClaveUM").ToString(),
' .ClaveProdServ = drr("SATClaveProdServ").ToString(),
' .Noidentificacion = drr("Noidentificacion").ToString(),
' .CuentaPredial = drr("CuentaPredial").ToString()}
' 'verifica suma subtotales
' If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe 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
' If Timbre.Comprobante.Total > 0 Then
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .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, .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, .TasaOCuota = TasaRetIVA, .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, .TasaOCuota = TasaRetISR, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString().ToDecimal()})
' End If
' Timbre.Conceptos.Add(concepto)
' i += 1
' Next
' Return Timbre
'End Function
'Private Function GenerarNotaCredito(CvePS As Integer, Tipo As Integer, CveUnidadMedida As Integer, Importe As Decimal, Iva As Decimal, Descripcion As String, CveClasificacion As Integer) As Boolean
' Dim Respuesta As Boolean = False
' Dim ObjVentas As New ClsVentas
' Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
' Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL())
' Dim ErrorVentas As Boolean = False
' Dim SubTotal As Decimal = Importe
' Dim Total As Decimal = Importe + Iva
' Dim RetIVA As Decimal = 0
' Dim RetISR As Decimal = 0
' Dim TipoCambio As Decimal = 0
' Dim FechaVencimiento As Date = Now
' Dim fecha As Date = Now
' Dim Folio As Integer = 0
' Dim Serie As String = ""
' If FolioNotaCredito() Then
' Folio = FolioNotaAcumulador
' Serie = SerieNotaAcumulador
' End If
' Dim CveSubProyecto As Integer = DdlSubProyecto.SelectedValue.Toentero()
' Dim CveVenta As Integer
' If Folio > 0 Then
' Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas($"Clientes/{Descripcion}", 1, Total, Total, 1, fecha, "Nota de crédito por Cargo", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
' If ObjVentas.AddVenta("Egs", Folio, CveCliente.Toentero(), -1, SubTotal, 0, 0, Iva, RetIVA, RetISR, Total, 1, TipoCambio,
' 0, 0, 0, FechaVencimiento, fecha, "", "", fecha, -1, "", "", "", 0, 0, 0, "-1".ToDate(), "-1".ToDate(), "-1".ToDate(), -1, -1, 0, CvePrePoliza,
' UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=CveSubProyecto, CveSubProyectoEjecucion:=CveSubProyecto) Then
' CveVenta = ObjVentas.CveVenta
' If CveVenta > 0 Then
' If ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, 0.16, SubTotal * 0.16, Descripcion, 0, 0, -1, 0) Then
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, SubTotal, Folio.ToString(), 150, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, ImporteMX:=SubTotal, CveSubProyecto:=CveSubProyecto) Then
' ErrorVentas = True
' End If
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio.ToString(), 12, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Total) Then
' ErrorVentas = True
' End If
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Iva, Folio.ToString(), 13, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Iva) Then
' ErrorVentas = True
' End If
' If Not ErrorVentas Then
' For Each GvRow As GridViewRow In GvAcum.Rows
' Dim CveMovto As Integer = GvRow.DataKey("CveMovto").Toentero()
' If (Tipo = 1 And GvRow.FCCheckBox("ChkCargo").Checked) Or (Tipo = 2 And GvRow.FCCheckBox("ChkBonificacion").Checked) Then
' If ObjAcum.DistribuidorActualizarFacturados(CveMovto, UsuarioActual.CveEmpresa, Tipo, CveVenta) Then
' Respuesta = True
' ErrorVentas = False
' CveVentaNota = CveVenta
' Else
' Respuesta = False
' ErrorVentas = True
' CveVentaNota = 0
' Exit For
' End If
' End If
' Next
' End If
' If Not ErrorVentas Then
' Alert($"Nota de crédito generada correctamente <a href='./Ventas.aspx?CveVenta={CveVenta}' >{Serie}-{Folio}</a>")
' End If
' Else
' ErrorVentas = True
' End If
' Else
' ErrorVentas = True
' End If
' Else
' ErrorVentas = True
' End If
' Else
' Alert("No se pudo obtener el Folio.", TipoMensaje.MsgError)
' End If
' If ErrorVentas Then
' ObjVentas.RollBack()
' Else
' ObjVentas.Commit()
' CargaUsados()
' 'Dim DtDetallesVenta As New DataTable
' 'If ObjVentas.GetVentaDetalle(CveVenta) Then
' ' DtDetallesVenta = ObjVentas.DtResultados
' ' 'CreaObjetosVenta(CveVenta, Serie, Folio, SubTotal, Iva, DtDetallesVenta)
' ' ObjFactura.Timbre = PreParaTimbre(ObjFactura, ObjFactura.CveSubProyecto)
' ' Dim ObjTimbrado As New Timbrado
' ' Dim SeTimbro As Boolean = False
' ' SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
' ' If SeTimbro Then
' ' Alert("Se timbro correctamente")
' ' Else
' ' Alert("No se pudo timbrar, intente mas tarde.", TipoMensaje.MsgError)
' ' End If
' 'Else
' ' Alert("No se pudo timbrar, no se pudieron obtener los detalles de la venta.", TipoMensaje.MsgError)
' 'End If
' End If
' ObjVentas.Dispose()
' Return Respuesta
'End Function
'Private Function generaNC(CveVenta As Integer, ByRef ObjVentas As ClsVentas, ByVal factura As Modelos.Factura) As List(Of Object)
' Dim Obj As New List(Of Object)
' Dim CveVentaNueva As Integer = ObjVentas.CveVenta
' Dim BanderaGeneraNC As Boolean = False
' If UsuarioActual.CveEmpresa.Contiene(1, 119) Then BanderaGeneraNC = True
' If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
' If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
' Dim drv As DataRow = ObjVentas.DtResultados.Rows(0)
' Dim TmpDTconceptos As DataTable = Nothing
' ''CargaCliente
' Dim CveCliente As Integer = drv("CveCliente").ToString().Toentero()
' If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not CveCliente.Contiene(10450, 10460, 10458) Then
' Return Nothing
' ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not CveCliente.Contiene(27448) Then
' Return Nothing
' End If
' factura.TipoDocto = drv("TipoDocto").ToString()
' factura.Serie = drv("Serie").ToString()
' factura.FechaEjecucion = drv("FechaEjecucion").ToString().ToDate()Time
' factura.Fecha = drv("Fecha").ToString().ToDate()Time
' factura.CveSubProyectoEjecucion = drv("CveSubProyectoEjecucion").ToString().Toentero()
' factura.CveSubProyectoCobranza = drv("CveSubProyectoCobranza").ToString().Toentero()
' factura.CveClienteSucursal = drv("CveClienteSucursal").ToString().Toentero()
' factura.CveSubProyecto = drv("CveSubProyecto").ToString().Toentero()
' ''CargaDetalle
' If ObjVentas.GetVentaDetalle(CveVenta) Then
' TmpDTconceptos = ObjVentas.DtResultados
' TmpDTconceptos.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
' GvPS.DataSource = TmpDTconceptos
' GvPS.DataBind()
' End If
' '' Carga Totales
' factura.SubTotal = drv("SubTotal").ToString().ToDecimal()
' factura.Descuento = drv("Descuento").ToString().ToDecimal()
' factura.Amortizacion = drv("Amortizacion").ToString().ToDecimal()
' factura.IVA = drv("IVA").ToString().ToDecimal()
' factura.RetIVA = drv("RetIVA").ToString().ToDecimal()
' factura.RetISR = drv("RetISR").ToString().ToDecimal()
' factura.Total = drv("Total").ToString().ToDecimal()
' factura.MotivoDescuento = drv("MotivoDescuento").ToString()
' factura.Observaciones = drv("Observaciones").ToString()
' factura.CveMoneda = drv("CveMoneda").ToString().Toentero()
' factura.TipoCambio = drv("TipoCambio").ToString().ToDecimal()
' factura.CveVendedor = drv("CveVendedor").ToString().Toentero()
' factura.RefDocto = drv("Ref").ToString()
' If factura.CveCliente > 0 Then
' If Not IsNothing(TmpDTconceptos) AndAlso TmpDTconceptos.Rows.Count > 0 Then
' If Not drv("Total").ToString().ToDecimal() = factura.Total Then
' Return Nothing
' End If
' End If
' End If
' End If
' End If
' If Obj.Count > 0 Then
' Return Obj
' Else
' Return Nothing
' End If
'End Function
'Private Function PreParaTimbre(Obj As Modelos.Factura, CveSubProyecto As Integer) 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.Fecha
' 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
' Try
' Obj.SetSubProyecto(Me)
' Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
' Catch ex As Exception
' End Try
' Timbre.Comprobante.Confirmacion = ""
' Timbre.Receptor.RFC = TxtRFC.Text
' Timbre.Receptor.Nombre = TxtNombre.Text
' Timbre.Receptor.ResidenciaFiscal = ""
' Timbre.Receptor.NumeroRegistroTributario = ""
' Timbre.Receptor.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}")
' Dim totSubTotal As Decimal = Obj.SubTotal
' Dim totIVA As Decimal = Obj.IVA
' Dim totRetIVA As Decimal = Obj.RetIVA
' Dim totRetISR As Decimal = Obj.RetISR
' Dim TasaRetIVA As Decimal = 0
' Dim TasaRetISR As Decimal = 0
' 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
' '' 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 = drr("TotalImporte").ToString().ToDecimal(),
' .Descuento = drr("Descuento").ToString().ToDecimal(),
' .Unidad = drr("UM").ToString(),
' .ClaveUnidad = drr("SATClaveUM").ToString(),
' .ClaveProdServ = drr("SATClaveProdServ").ToString(),
' .Noidentificacion = drr("Noidentificacion").ToString(),
' .CuentaPredial = drr("CuentaPredial").ToString()}
' '' verifica suma subtotales
' If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe 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
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .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, .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, .TasaOCuota = TasaRetIVA, .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, .TasaOCuota = TasaRetISR, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString().ToDecimal()})
' End If
' Timbre.Conceptos.Add(concepto)
' i += 1
' Next
' Dim AplicaComercioExteriorSubProyecto As Boolean = If(GlobalDTSubProyectos(-1, Obj.CveSubProyecto)(0)("AplicaComercioExterior").ToString() = "True", True, False)
' Timbre.Complementos.ComercioExterior11.AplicaComercioExteriorSubProyecto = AplicaComercioExteriorSubProyecto
' If Obj.Cliente.AplicaComercioExterior And AplicaComercioExteriorSubProyecto Then
' Timbre.Receptor.ResidenciaFiscal = Obj.Cliente.ClaveSATPais
' Timbre.Receptor.NumeroRegistroTributario = Obj.Cliente.NumRegIdTrib
' End If
' Return Timbre
'End Function
#End Region