This commit is contained in:
2025-01-03 19:00:38 -07:00
5 changed files with 648 additions and 301 deletions

View File

@@ -1631,7 +1631,7 @@ Public Class ClsVentas
Return Retorno Return Retorno
End Function End Function
Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, IEPS As Decimal, PorcentajeIEPS As Decimal, IVA As Decimal, PorcentajeIVA As Decimal, Descuento As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, IEPS As Decimal, PorcentajeIEPS As Decimal, IVA As Decimal, PorcentajeIVA As Decimal, Descuento As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1, Optional CvePromocionDetalle As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_VentasDetalleRemisionUpdate") DataAdapter("PA_VentasDetalleRemisionUpdate")
@@ -1647,6 +1647,7 @@ Public Class ClsVentas
.Add("@Descuento", SqlDbType.Decimal).Value = Descuento .Add("@Descuento", SqlDbType.Decimal).Value = Descuento
.Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones
.Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico
.Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle
End With End With
Try Try

View File

@@ -2,6 +2,7 @@
Option Explicit On Option Explicit On
Imports System.Data Imports System.Data
Imports System.Math Imports System.Math
Imports ADSNetLibrary.SIGAPI.Models.OC.Response
Imports ClosedXML.Excel Imports ClosedXML.Excel
Imports DocumentFormat.OpenXml.Drawing.Diagrams Imports DocumentFormat.OpenXml.Drawing.Diagrams
Imports Extensiones Imports Extensiones
@@ -2444,6 +2445,8 @@ Partial Class General_SaldosIniciales
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Total - Saldo, 95, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Total - Saldo, 95, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If End If
Else Else
'ANTICIPOS 'ANTICIPOS
Dim CveIE As Integer = ObjIE.AddBancos_IE(1, 1, Fecha, Folio.ToString(), "", Total, 1, Dim CveIE As Integer = ObjIE.AddBancos_IE(1, 1, Fecha, Folio.ToString(), "", Total, 1,
@@ -2479,6 +2482,7 @@ Partial Class General_SaldosIniciales
ElseIf RblFormato.SelectedValue = "17" Then ElseIf RblFormato.SelectedValue = "17" Then
Dim NoEncontrados As Integer = 0 Dim NoEncontrados As Integer = 0
Dim VentasAgregadas As Integer = 0
Dim Encontrados As Integer = 0 Dim Encontrados As Integer = 0
Dim StrRFCNoencontrados As New StringBuilder Dim StrRFCNoencontrados As New StringBuilder
Dim drr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero("AplicaParaVenta = 1") Dim drr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero("AplicaParaVenta = 1")
@@ -2519,343 +2523,640 @@ Partial Class General_SaldosIniciales
Dim CountRow As Integer = 1 Dim CountRow As Integer = 1
Dim LastSerieFolioTipoDoc As String = String.Empty Dim LastSerieFolioTipoDoc As String = String.Empty
Dim EsDetalle As Boolean = False Dim EsDetalle As Boolean = False
For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{Row("Sucursal").ToString()}'")
Dim TipoDocto As String = Row("Tipo Documento").ToString().Trim
Dim RFC As String = Row("RFC").ToString().Trim.Replace("-", "").Replace(" ", "")
Dim Serie As String = Row("Serie").ToString().Trim
Dim Folio As Integer = Row("Folio").ToString().ToEntero()
Dim Fecha As Date = Row("Fecha").ToString().ToDate
Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString().ToDate
Dim ImpuestoLocal As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString().ToDecimal, 0D)
Dim Amortizacion As Decimal = If(dt.Columns.Contains("Amort.Ant"), Row("Amort.Ant").ToString().ToDecimal, 0)
Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString().ToEntero()
If LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}" AndAlso UsuarioActual.CveEmpresa = 189 Then If UsuarioActual.CveEmpresa = 189 Then
EsDetalle = True
Else Dim DTFoliosFiscales As DataTable = dt.FiltraParametros("", "", {"Folio Fiscal"})
LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}"
EsDetalle = False For Each drFolioFiscal As DataRow In DTFoliosFiscales.Rows
End If Dim FolioFiscalActual As String = drFolioFiscal("Folio Fiscal").ToString
Dim DRVentaActual As DataRow = dt.FiltroPrimero($"[Folio Fiscal] = '{FolioFiscalActual}'")
Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{DRVentaActual("Sucursal").ToString()}'")
Dim TipoDocto As String = DRVentaActual("Tipo Documento").ToString().Trim
Dim RFC As String = DRVentaActual("RFC").ToString().Trim.Replace("-", "").Replace(" ", "")
Dim Serie As String = DRVentaActual("Serie").ToString().Trim
Dim Folio As Integer = DRVentaActual("Folio").ToString().ToEntero()
Dim Fecha As Date = DRVentaActual("Fecha").ToString().ToDate
Dim FechaVencimiento As Date = DRVentaActual("Fecha Vencimiento").ToString().ToDate
Dim ImpuestoLocal As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), DRVentaActual("ImpuestoLocal").ToString().ToDecimal, 0D)
Dim Amortizacion As Decimal = If(dt.Columns.Contains("Amort.Ant"), DRVentaActual("Amort.Ant").ToString().ToDecimal, 0)
Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString().ToEntero()
If LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}" AndAlso UsuarioActual.CveEmpresa = 189 Then
EsDetalle = True
Else
LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}"
EsDetalle = False
End If
Dim SubTotal As Decimal = 0
Dim IVA As Decimal = 0
Dim Total As Decimal = 0
Dim Saldo As Decimal = 0
Dim RetIVA As Decimal = 0
Dim RetISR As Decimal = 0
Dim IEPS As Decimal = 0
SubTotal = DRVentaActual("SubTotal").ToString().ToDecimal
IVA = DRVentaActual("IVA").ToString().ToDecimal
Total = DRVentaActual("Total").ToString().ToDecimal
Saldo = DRVentaActual("Saldo").ToString().ToDecimal
RetIVA = DRVentaActual("Ret IVA").ToString().ToDecimal
RetISR = DRVentaActual("Ret ISR").ToString().ToDecimal
IEPS = DRVentaActual("IEPS").ToString().ToDecimal
Dim Moneda As String = DRVentaActual("Moneda").ToString()
Dim TipoCambio As String = DRVentaActual("Tipo Cambio").ToString()
Dim CveMoneda As Integer = 1
Dim Vendedor As String = If(dt.Columns.Contains("Vendedor"), DRVentaActual("Vendedor").ToString(), "")
Dim CveVendedor As Integer = 0
Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString().ToEntero()
'Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), DRVentaActual("Folio Fiscal").ToString(), "")
Dim PorcentajeIVA As Decimal = If(dt.Columns.Contains("PorcentajeIVA"), Round(DRVentaActual("PorcentajeIVA").ToString().ToDecimal, 2), 0)
Dim PorcentajeRetIVA As Decimal = If(dt.Columns.Contains("PorcentajeRetIVA"), Round(DRVentaActual("PorcentajeRetIVA").ToString().ToDecimal, 4), 0)
Dim PorcentajeRetISR As Decimal = If(dt.Columns.Contains("PorcentajeRetISR"), Round(DRVentaActual("PorcentajeRetISR").ToString().ToDecimal, 4), 0)
Dim PedidoContrato As String = If(dt.Columns.Contains("Pedido"), DRVentaActual("Pedido").ToString(), "")
GuardaLog(Sucursal + "-" + DRVentaActual("Folio").ToString())
'Temporalmente SE BORRARA
Dim Transaccion As String = "" ' Row("Transaccion2").ToString()
Dim Folio2 As String = "" ' Row("Folio2").ToString()
Dim CodCliente As String = "" 'Row("CodCliente2").ToString()
TipoDocto = IIf(TipoDocto.ToUpper.Contiene("INGRESO", "INGRESOS", "ING", "FACTURA", "FACTURAS"), "Ing", IIf(TipoDocto.ToUpper.Contiene("EGRESO", "EGRESOS", "EGS"), "Egs", "Rem")).ToString()
'Dim CantidadDetalle As Decimal = 0
'Dim PUDetalle As Decimal = 0
'Dim IVADetalle As Decimal = 0
Dim PorcentajeIEPS As Decimal = 0
Dim SubTotal As Decimal = 0 Dim TotalDetalles As Decimal = 0
Dim IVA As Decimal = 0 For Each dRowDetalle As DataRow In dt.FiltraParametros($"[Folio Fiscal]='{FolioFiscalActual}'").Rows
Dim Total As Decimal = 0 Dim CantidadDetalle As Decimal = dRowDetalle("Cantidad").ToString.ToDecimal 'digo PU IVADetalle
Dim Saldo As Decimal = 0 Dim PuDetalle As Decimal = dRowDetalle("PU").ToString.ToDecimal
Dim RetIVA As Decimal = 0 Dim IVADetalle As Decimal = dRowDetalle("IVADetalle").ToString.ToDecimal
Dim RetISR As Decimal = 0 Dim IEPSDetalle As Decimal = dRowDetalle("IEPS").ToString.ToDecimal
Dim IEPS As Decimal = 0 TotalDetalles += (CantidadDetalle * PuDetalle) + IVADetalle + IEPSDetalle
If UsuarioActual.CveEmpresa = 189 AndAlso Not EsDetalle Then
For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
SubTotal += item("SubTotal").ToString().ToDecimal
IVA += item("IVA").ToString().ToDecimal
Total += item("Total").ToString().ToDecimal
Saldo += item("Saldo").ToString().ToDecimal
RetIVA += item("Ret IVA").ToString().ToDecimal
RetISR += item("Ret ISR").ToString().ToDecimal
IEPS += item("IEPS").ToString().ToDecimal
Next Next
Else
SubTotal = Row("SubTotal").ToString().ToDecimal
IVA = Row("IVA").ToString().ToDecimal
Total = Row("Total").ToString().ToDecimal
Saldo = Row("Saldo").ToString().ToDecimal
RetIVA = Row("Ret IVA").ToString().ToDecimal
RetISR = Row("Ret ISR").ToString().ToDecimal
IEPS = Row("IEPS").ToString().ToDecimal
End If
Dim Moneda As String = Row("Moneda").ToString()
Dim TipoCambio As String = Row("Tipo Cambio").ToString()
Dim CveMoneda As Integer = 1
Dim Vendedor As String = If(dt.Columns.Contains("Vendedor"), Row("Vendedor").ToString(), "")
Dim CveVendedor As Integer = 0
Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString().ToEntero() If IEPS > 0 Then
Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), Row("Folio Fiscal").ToString(), "") PorcentajeIEPS = If(dt.Columns.Contains("PorcentajeIEPS"), Round(DRVentaActual("PorcentajeIEPS").ToString().ToDecimal, 4), 0)
Dim PorcentajeIVA As Decimal = If(dt.Columns.Contains("PorcentajeIVA"), Round(Row("PorcentajeIVA").ToString().ToDecimal, 2), 0) End If
Dim PorcentajeRetIVA As Decimal = If(dt.Columns.Contains("PorcentajeRetIVA"), Round(Row("PorcentajeRetIVA").ToString().ToDecimal, 4), 0)
Dim PorcentajeRetISR As Decimal = If(dt.Columns.Contains("PorcentajeRetISR"), Round(Row("PorcentajeRetISR").ToString().ToDecimal, 4), 0)
Dim PedidoContrato As String = If(dt.Columns.Contains("Pedido"), Row("Pedido").ToString(), "")
GuardaLog(Sucursal + "-" + Row("Folio").ToString()) If Math.Abs(TotalDetalles - Total) > 0.01 Then
'Temporalmente SE BORRARA ErrorVentas = True
Dim Transaccion As String = "" ' Row("Transaccion2").ToString() Alert($"Registro {CountRow} El total no coincide con el acumulado de los detalles, total: {Total.ToString("###,###,###.00")} detatalle: {TotalDetalles.ToString("###,###,###.00")}", TipoMensaje.MsgAdvertencia)
Dim Folio2 As String = "" ' Row("Folio2").ToString() Exit For
Dim CodCliente As String = "" 'Row("CodCliente2").ToString() End If
Dim IEPSDetalle As Decimal = 0
Dim CantidadDetalle As Decimal = 0
Dim PUDetalle As Decimal = 0
Dim IVADetalle As Decimal = 0
Dim PorcentajeIEPS As Decimal = 0
If IEPS > 0 Then If Vendedor <> "" Then
PorcentajeIEPS = If(dt.Columns.Contains("PorcentajeIEPS"), Round(Row("PorcentajeIEPS").ToString().ToDecimal, 4), 0) CveVendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltroPrimeroValor("CveVendedor", $"Vendedor = '{Vendedor}'").ToString().ToEntero()
End If If Not CveVendedor > 0 Then CveVendedor = 0
Else
CveVendedor = 0
End If
If RblFormato.SelectedValue = "17" Then If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN") Then
CveMoneda = 1
TipoCambio = "1"
ElseIf Moneda.ToUpper.Contiene("DÓLAR", "DÓLARES", "DOLARES", "USD") Then
CveMoneda = 2
Dim CodigoDetalle As String = Row("Codigo").ToString If TipoCambio.Trim.ToDecimal < 10 Then
If CodigoDetalle.Trim.Length > 0 Then
Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = '{CodigoDetalle}'")
If DrDetalles IsNot Nothing Then If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
CvePS = DrDetalles("CvePS").ToString().ToEntero() TipoCambio = GlobalTipoCambio(Fecha.AddDays(-1)).ToString()
CveUnidadMedida = DrDetalles("CveUnidadMedida").ToString().ToEntero() Else
CveClasificacion = DrDetalles("CveClasificacion").ToString().ToEntero() TipoCambio = GlobalTipoCambio(Fecha).ToString()
Else End If
Alert($"El código del producto no se encontro, error en registro {CountRow}")
End If
End If
If TipoCambio = "" Then TipoCambio = "1"
If Not CveClienteSucursal > 0 Then CveClienteSucursal = -1
If FechaVencimiento = "".ToDate Or FechaVencimiento < "1900/01/01".ToDate Then
FechaVencimiento = Fecha
End If
If Not ErrorVentas Then
CvePrePoliza = ObjConta.AddPrePolizas("Venta/SaldoInicial", 1, Total, Total, CveMoneda, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If Not CvePrePoliza > 0 Then
ErrorVentas = True ErrorVentas = True
End If End If
Else
Alert($"El código es requerido, error en registro {CountRow}")
ErrorVentas = True
End If End If
IEPSDetalle = Row("IEPS").ToString.ToDecimal If Not ErrorVentas Then
CantidadDetalle = Row("Cantidad").ToString.ToDecimal 'Venta
PUDetalle = Row("PU").ToString.ToDecimal If CveCliente > 0 Then
IVADetalle = Row("IVA").ToString.ToDecimal
If CantidadDetalle = 0 Then
Alert($"No se especifico la cantidad, error en registro {CountRow}")
ErrorVentas = True
End If
End If
If dt.Columns.Contains("Cliente Sucursal") AndAlso Row("Cliente Sucursal").ToString() <> "" Then
Dim ObjCliente As New ClsClientes
If ObjCliente.GetSucursales(CveCliente) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
CveClienteSucursal = ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "SucursalCliente = '" & Row("Cliente Sucursal").ToString().Trim & "'").ToEntero
End If
End If
ObjCliente.Dispose()
End If
'If Not CveCliente > 0 Then Alert(String.Format("No se encontró el cliente con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorVentas = True : RFC.GuardaLog : Exit For If TipoDocto.Contiene("Ing", "Egs", "Rem") Then
TipoDocto = IIf(TipoDocto.ToUpper.Contiene("INGRESO", "INGRESOS", "ING", "FACTURA", "FACTURAS"), "Ing", IIf(TipoDocto.ToUpper.Contiene("EGRESO", "EGRESOS", "EGS"), "Egs", "Rem")).ToString() GuardaLog(Serie & "-" & Folio)
'PrePóliza If Not EsDetalle Then
If Not EsDetalle Then If Not ObjVentas.AddVenta(TipoDocto, Folio, CveCliente.ToEntero(), CveClienteSucursal, SubTotal, 0, Amortizacion, IVA, RetIVA, RetISR, Total, CveMoneda, TipoCambio.ToDecimal,
CvePrePoliza = ObjConta.AddPrePolizas("Venta/SaldoInicial", 1, Total, Total, 1, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) 0, 0, 0, FechaVencimiento, Fecha, "", "", Fecha, CveVendedor, Folio2, "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, 0, CvePrePoliza,
End If UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=Sucursal.ToEntero(), CveSubProyectoEjecucion:=Sucursal.ToEntero(),
CveSubProyectoCobranza:=Sucursal.ToEntero(), IEPS:=IEPS, ObservacionesAlmacen:=Transaccion, Entrega:=CodCliente, ImpuestoLocal:=ImpuestoLocal,
PedidoContrato:=PedidoContrato, CveMetodoPago33:=3) Then
ErrorVentas = True
Exit For
Else
VentasAgregadas += 1
End If
CveVenta = ObjVentas.CveVenta
End If
If Vendedor <> "" Then
CveVendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltroPrimeroValor("CveVendedor", $"Vendedor = '{Vendedor}'").ToString().ToEntero()
If Not CveVendedor > 0 Then CveVendedor = 0
Else
CveVendedor = 0
End If
'Moneda For Each dRowDetalle As DataRow In dt.FiltraParametros($"[Folio Fiscal]='{FolioFiscalActual}'").Rows
If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN") Then
CveMoneda = 1
TipoCambio = "1"
ElseIf Moneda.ToUpper.Contiene("DÓLAR", "DÓLARES", "DOLARES", "USD") Then
CveMoneda = 2
If TipoCambio.Trim.ToDecimal < 10 Then
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then Dim CantidadDetalle As Decimal = dRowDetalle("Cantidad").ToString.ToDecimal 'digo PU IVADetalle
TipoCambio = GlobalTipoCambio(Fecha.AddDays(-1)).ToString() Dim PuDetalle As Decimal = dRowDetalle("PU").ToString.ToDecimal
Dim IVADetalle As Decimal = dRowDetalle("IVADetalle").ToString.ToDecimal
Dim IEPSDetalle As Decimal = dRowDetalle("IEPS").ToString.ToDecimal
Dim PorcentajeIEPSDetalle = dRowDetalle("PorcentajeIEPS").ToString.ToDecimal
Dim CodigoDetalle As String = dRowDetalle("Codigo").ToString
If CodigoDetalle.Trim.Length > 0 Then
Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = '{CodigoDetalle}'")
If DrDetalles IsNot Nothing Then
CvePS = DrDetalles("CvePS").ToString().ToEntero()
CveUnidadMedida = DrDetalles("CveUnidadMedida").ToString().ToEntero()
CveClasificacion = DrDetalles("CveClasificacion").ToString().ToEntero()
Else
Alert($"El código del producto no se encontro, error en registro {CountRow}")
ErrorVentas = True
End If
Else
Alert($"El código es requerido, error en registro {CountRow}")
ErrorVentas = True
End If
If Not ErrorVentas Then
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, CantidadDetalle, CveUnidadMedida, PuDetalle, IVADetalle, TotalDetalles, "Saldo Inicial", 0, 0, Sucursal.ToEntero(), 0,
PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, ImporteRetIVA:=0, IEPS:=IEPSDetalle, PorcentajeRetISR:=0, PorcentajeIEPS:=PorcentajeIEPSDetalle) Then
ErrorVentas = True
Exit For
End If
End If
Next
Dim ConceptoContable As Integer = 1
Dim ConceptoContablePago As Integer = 2
If TipoDocto = "Egs" Then
ConceptoContable = 12
ConceptoContablePago = 91
End If
If FolioFiscalActual <> "" Then
If Not ObjVentas.UpdateVentaFolioFiscal(FolioFiscalActual, CveVenta, UsuarioActual.CveEmpresa) Then
ErrorVentas = True
Exit For
End If
End If
Dim UsaComplementaria As Boolean = False
If UsuarioActual.CveEmpresa.Contiene(119, 158) Then UsaComplementaria = True
'PrePólizaDetalle
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, SubTotal, 4, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, CveSubProyecto:=Sucursal.ToEntero(), PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, ConceptoContable, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
If IVA > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, IVA, 13, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If IEPS > 0 Then
'AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, Folio, 38, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IEPS)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, IEPS, 38, Folio.ToString, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If RetIVA > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 8, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If RetISR > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 9, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If ImpuestoLocal > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImpuestoLocal, ImpuestoLocal, 27, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If UsaComplementaria Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total * TipoCambio.ToDecimal - Total, Total * TipoCambio.ToDecimal - Total, 203, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteME:=Total, TipoCambio:=TipoCambio.ToDecimal, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
'Saldo
If Saldo < Total Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Total - Saldo, ConceptoContablePago, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, CveVentaAmortizacion:=CveVenta, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Total - Saldo, 95, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If Not ErrorVentas Then
VentasAgregadas += VentasAgregadas
End If
Else
'ANTICIPOS
Dim CveIE As Integer = ObjIE.AddBancos_IE(1, 1, Fecha, Folio.ToString(), "", Total, 1, 1, "Anticipo Cliente", "", False, False, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, 30, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, 66, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
'_______________________________________________________________
Else Else
TipoCambio = GlobalTipoCambio(Fecha).ToString() NoEncontrados = NoEncontrados + 1
StrRFCNoencontrados.AppendFormat("{0}<br/>", RFC)
'ErrorVentas = True
'Exit For
End If
End If
Next
Else
For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{Row("Sucursal").ToString()}'")
Dim TipoDocto As String = Row("Tipo Documento").ToString().Trim
Dim RFC As String = Row("RFC").ToString().Trim.Replace("-", "").Replace(" ", "")
Dim Serie As String = Row("Serie").ToString().Trim
Dim Folio As Integer = Row("Folio").ToString().ToEntero()
Dim Fecha As Date = Row("Fecha").ToString().ToDate
Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString().ToDate
Dim ImpuestoLocal As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString().ToDecimal, 0D)
Dim Amortizacion As Decimal = If(dt.Columns.Contains("Amort.Ant"), Row("Amort.Ant").ToString().ToDecimal, 0)
Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString().ToEntero()
If LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}" AndAlso UsuarioActual.CveEmpresa = 189 Then
EsDetalle = True
Else
LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}"
EsDetalle = False
End If
Dim SubTotal As Decimal = 0
Dim IVA As Decimal = 0
Dim Total As Decimal = 0
Dim Saldo As Decimal = 0
Dim RetIVA As Decimal = 0
Dim RetISR As Decimal = 0
Dim IEPS As Decimal = 0
If UsuarioActual.CveEmpresa = 189 AndAlso Not EsDetalle Then
For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
SubTotal += item("SubTotal").ToString().ToDecimal
IVA += item("IVA").ToString().ToDecimal
Total += item("Total").ToString().ToDecimal
Saldo += item("Saldo").ToString().ToDecimal
RetIVA += item("Ret IVA").ToString().ToDecimal
RetISR += item("Ret ISR").ToString().ToDecimal
IEPS += item("IEPS").ToString().ToDecimal
Next
Else
SubTotal = Row("SubTotal").ToString().ToDecimal
IVA = Row("IVA").ToString().ToDecimal
Total = Row("Total").ToString().ToDecimal
Saldo = Row("Saldo").ToString().ToDecimal
RetIVA = Row("Ret IVA").ToString().ToDecimal
RetISR = Row("Ret ISR").ToString().ToDecimal
IEPS = Row("IEPS").ToString().ToDecimal
End If
Dim Moneda As String = Row("Moneda").ToString()
Dim TipoCambio As String = Row("Tipo Cambio").ToString()
Dim CveMoneda As Integer = 1
Dim Vendedor As String = If(dt.Columns.Contains("Vendedor"), Row("Vendedor").ToString(), "")
Dim CveVendedor As Integer = 0
Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString().ToEntero()
Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), Row("Folio Fiscal").ToString(), "")
Dim PorcentajeIVA As Decimal = If(dt.Columns.Contains("PorcentajeIVA"), Round(Row("PorcentajeIVA").ToString().ToDecimal, 2), 0)
Dim PorcentajeRetIVA As Decimal = If(dt.Columns.Contains("PorcentajeRetIVA"), Round(Row("PorcentajeRetIVA").ToString().ToDecimal, 4), 0)
Dim PorcentajeRetISR As Decimal = If(dt.Columns.Contains("PorcentajeRetISR"), Round(Row("PorcentajeRetISR").ToString().ToDecimal, 4), 0)
Dim PedidoContrato As String = If(dt.Columns.Contains("Pedido"), Row("Pedido").ToString(), "")
GuardaLog(Sucursal + "-" + Row("Folio").ToString())
'Temporalmente SE BORRARA
Dim Transaccion As String = "" ' Row("Transaccion2").ToString()
Dim Folio2 As String = "" ' Row("Folio2").ToString()
Dim CodCliente As String = "" 'Row("CodCliente2").ToString()
Dim IEPSDetalle As Decimal = 0
Dim CantidadDetalle As Decimal = 0
Dim PUDetalle As Decimal = 0
Dim IVADetalle As Decimal = 0
Dim PorcentajeIEPS As Decimal = 0
If IEPS > 0 Then
PorcentajeIEPS = If(dt.Columns.Contains("PorcentajeIEPS"), Round(Row("PorcentajeIEPS").ToString().ToDecimal, 4), 0)
End If
If RblFormato.SelectedValue = "17" Then
Dim CodigoDetalle As String = Row("Codigo").ToString
If CodigoDetalle.Trim.Length > 0 Then
Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = '{CodigoDetalle}'")
If DrDetalles IsNot Nothing Then
CvePS = DrDetalles("CvePS").ToString().ToEntero()
CveUnidadMedida = DrDetalles("CveUnidadMedida").ToString().ToEntero()
CveClasificacion = DrDetalles("CveClasificacion").ToString().ToEntero()
Else
Alert($"El código del producto no se encontro, error en registro {CountRow}")
ErrorVentas = True
End If
Else
Alert($"El código es requerido, error en registro {CountRow}")
ErrorVentas = True
End If
IEPSDetalle = Row("IEPS").ToString.ToDecimal
CantidadDetalle = Row("Cantidad").ToString.ToDecimal
PUDetalle = Row("PU").ToString.ToDecimal
IVADetalle = Row("IVA").ToString.ToDecimal
If CantidadDetalle = 0 Then
Alert($"No se especifico la cantidad, error en registro {CountRow}")
ErrorVentas = True
End If End If
End If End If
End If If dt.Columns.Contains("Cliente Sucursal") AndAlso Row("Cliente Sucursal").ToString() <> "" Then
'Si no se especifica TC, se manda como pesos. Dim ObjCliente As New ClsClientes
If TipoCambio = "" Then TipoCambio = "1" If ObjCliente.GetSucursales(CveCliente) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
If Not CveClienteSucursal > 0 Then CveClienteSucursal = -1 CveClienteSucursal = ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "SucursalCliente = '" & Row("Cliente Sucursal").ToString().Trim & "'").ToEntero
If FechaVencimiento = "".ToDate Or FechaVencimiento < "1900/01/01".ToDate Then
FechaVencimiento = Fecha
End If
'Venta
If CveCliente > 0 Then
If TipoDocto.Contiene("Ing", "Egs", "Rem") Then
GuardaLog(Serie & "-" & Folio)
If Not EsDetalle Then
If Not ObjVentas.AddVenta(TipoDocto, Folio, CveCliente.ToEntero(), CveClienteSucursal, SubTotal, 0, Amortizacion, IVA, RetIVA, RetISR, Total, CveMoneda, TipoCambio.ToDecimal,
0, 0, 0, FechaVencimiento, Fecha, "", "", Fecha, CveVendedor, Folio2, "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, 0, CvePrePoliza,
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=Sucursal.ToEntero(), CveSubProyectoEjecucion:=Sucursal.ToEntero(),
CveSubProyectoCobranza:=Sucursal.ToEntero(), IEPS:=IEPS, ObservacionesAlmacen:=Transaccion, Entrega:=CodCliente, ImpuestoLocal:=ImpuestoLocal,
PedidoContrato:=PedidoContrato, CveMetodoPago33:=3) Then
ErrorVentas = True
Exit For
End If End If
CveVenta = ObjVentas.CveVenta
End If End If
If Not EsDetalle Then ObjCliente.Dispose()
SubTotal = Row("SubTotal").ToString().ToDecimal End If
IVA = Row("IVA").ToString().ToDecimal
Total = Row("Total").ToString().ToDecimal
Saldo = Row("Saldo").ToString().ToDecimal 'If Not CveCliente > 0 Then Alert(String.Format("No se encontró el cliente con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorVentas = True : RFC.GuardaLog : Exit For
RetIVA = Row("Ret IVA").ToString().ToDecimal TipoDocto = IIf(TipoDocto.ToUpper.Contiene("INGRESO", "INGRESOS", "ING", "FACTURA", "FACTURAS"), "Ing", IIf(TipoDocto.ToUpper.Contiene("EGRESO", "EGRESOS", "EGS"), "Egs", "Rem")).ToString()
RetISR = Row("Ret ISR").ToString().ToDecimal 'PrePóliza
IEPS = Row("IEPS").ToString().ToDecimal If Not EsDetalle Then
CvePrePoliza = ObjConta.AddPrePolizas("Venta/SaldoInicial", 1, Total, Total, 1, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
End If
If Vendedor <> "" Then
CveVendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltroPrimeroValor("CveVendedor", $"Vendedor = '{Vendedor}'").ToString().ToEntero()
If Not CveVendedor > 0 Then CveVendedor = 0
Else
CveVendedor = 0
End If
'Moneda
If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN") Then
CveMoneda = 1
TipoCambio = "1"
ElseIf Moneda.ToUpper.Contiene("DÓLAR", "DÓLARES", "DOLARES", "USD") Then
CveMoneda = 2
If TipoCambio.Trim.ToDecimal < 10 Then
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
TipoCambio = GlobalTipoCambio(Fecha.AddDays(-1)).ToString()
Else
TipoCambio = GlobalTipoCambio(Fecha).ToString()
End If
End If End If
If RblFormato.SelectedValue = "17" Then End If
Dim TotalDetalles As Decimal = SubTotal 'Si no se especifica TC, se manda como pesos.
If PUDetalle > 0 Then If TipoCambio = "" Then TipoCambio = "1"
TotalDetalles = (CantidadDetalle * PUDetalle) + IVA - RetIVA - RetISR + IEPSDetalle
If Not CveClienteSucursal > 0 Then CveClienteSucursal = -1
If FechaVencimiento = "".ToDate Or FechaVencimiento < "1900/01/01".ToDate Then
FechaVencimiento = Fecha
End If
'Venta
If CveCliente > 0 Then
If TipoDocto.Contiene("Ing", "Egs", "Rem") Then
GuardaLog(Serie & "-" & Folio)
If Not EsDetalle Then
If Not ObjVentas.AddVenta(TipoDocto, Folio, CveCliente.ToEntero(), CveClienteSucursal, SubTotal, 0, Amortizacion, IVA, RetIVA, RetISR, Total, CveMoneda, TipoCambio.ToDecimal,
0, 0, 0, FechaVencimiento, Fecha, "", "", Fecha, CveVendedor, Folio2, "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, 0, CvePrePoliza,
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=Sucursal.ToEntero(), CveSubProyectoEjecucion:=Sucursal.ToEntero(),
CveSubProyectoCobranza:=Sucursal.ToEntero(), IEPS:=IEPS, ObservacionesAlmacen:=Transaccion, Entrega:=CodCliente, ImpuestoLocal:=ImpuestoLocal,
PedidoContrato:=PedidoContrato, CveMetodoPago33:=3) Then
ErrorVentas = True
Exit For
Else
VentasAgregadas += 1
End If
CveVenta = ObjVentas.CveVenta
End If End If
If Math.Abs(TotalDetalles - Total) > 0.01 Then If Not EsDetalle Then
ErrorVentas = True SubTotal = Row("SubTotal").ToString().ToDecimal
Alert($"Registro {CountRow} El total no councide con el calculo de los detalles, total: {Total.ToString("###,###,###.00")} calculo detatalles: {TotalDetalles.ToString("###,###,###.00")}", TipoMensaje.MsgAdvertencia) IVA = Row("IVA").ToString().ToDecimal
Exit For Total = Row("Total").ToString().ToDecimal
Saldo = Row("Saldo").ToString().ToDecimal
RetIVA = Row("Ret IVA").ToString().ToDecimal
RetISR = Row("Ret ISR").ToString().ToDecimal
IEPS = Row("IEPS").ToString().ToDecimal
End If End If
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, CantidadDetalle, CveUnidadMedida, PUDetalle, IVADetalle, TotalDetalles, "Saldo Inicial", 0, 0, Sucursal.ToEntero(), 0, If RblFormato.SelectedValue = "17" Then
PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, ImporteRetIVA:=RetIVA, IEPS:=IEPSDetalle, PorcentajeRetISR:=PorcentajeRetISR, PorcentajeIEPS:=PorcentajeIEPS) Then
ErrorVentas = True Dim TotalDetalles As Decimal = SubTotal
Exit For If PUDetalle > 0 Then
TotalDetalles = (CantidadDetalle * PUDetalle) + IVA - RetIVA - RetISR + IEPSDetalle
End If
If Math.Abs(TotalDetalles - Total) > 0.01 Then
ErrorVentas = True
Alert($"Registro {CountRow} El total no coincide con el acumulado de los detalles, total: {Total.ToString("###,###,###.00")} detatalle: {TotalDetalles.ToString("###,###,###.00")}", TipoMensaje.MsgAdvertencia)
Exit For
End If
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, CantidadDetalle, CveUnidadMedida, PUDetalle, IVADetalle, TotalDetalles, "Saldo Inicial", 0, 0, Sucursal.ToEntero(), 0,
PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, ImporteRetIVA:=RetIVA, IEPS:=IEPSDetalle, PorcentajeRetISR:=PorcentajeRetISR, PorcentajeIEPS:=PorcentajeIEPS) Then
ErrorVentas = True
Exit For
End If
Else
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, IVA, SubTotal * PorcentajeIVA, "Saldo Inicial", 0, 0, Sucursal.ToEntero(), 0, PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, ImporteRetIVA:=RetIVA, IEPS:=0) Then
ErrorVentas = True
Exit For
End If
End If
Dim ConceptoContable As Integer = 1
Dim ConceptoContablePago As Integer = 2
If TipoDocto = "Egs" Then
ConceptoContable = 12
ConceptoContablePago = 91
End If
If FolioFiscal <> "" Then
If Not ObjVentas.UpdateVentaFolioFiscal(FolioFiscal, CveVenta, UsuarioActual.CveEmpresa) Then
ErrorVentas = True
Exit For
End If
End If
Dim UsaComplementaria As Boolean = False
If UsuarioActual.CveEmpresa.Contiene(119, 158) Then UsaComplementaria = True
If Not EsDetalle Then
SubTotal = 0
IVA = 0
Total = 0
Saldo = 0
RetIVA = 0
RetISR = 0
For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
SubTotal += item("SubTotal").ToString().ToDecimal
IVA += item("IVA").ToString().ToDecimal
Total += item("Total").ToString().ToDecimal
Saldo += item("Saldo").ToString().ToDecimal
RetIVA += item("Ret IVA").ToString().ToDecimal
RetISR += item("Ret ISR").ToString().ToDecimal
IEPS += item("IEPS").ToString().ToDecimal
Next
'PrePólizaDetalle
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, SubTotal, 4, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, CveSubProyecto:=Sucursal.ToEntero(), PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, ConceptoContable, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
If IVA > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, IVA, 13, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If IEPS > 0 Then
'AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, Folio, 38, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IEPS)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, IEPS, 38, Folio.ToString, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If RetIVA > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 8, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If RetISR > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 9, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If ImpuestoLocal > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImpuestoLocal, ImpuestoLocal, 27, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If UsaComplementaria Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total * TipoCambio.ToDecimal - Total, Total * TipoCambio.ToDecimal - Total, 203, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteME:=Total, TipoCambio:=TipoCambio.ToDecimal, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
'Saldo
If Saldo < Total Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Total - Saldo, ConceptoContablePago, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, CveVentaAmortizacion:=CveVenta, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Total - Saldo, 95, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
End If End If
Else Else
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, IVA, SubTotal * PorcentajeIVA, "Saldo Inicial", 0, 0, Sucursal.ToEntero(), 0, PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, ImporteRetIVA:=RetIVA, IEPS:=0) Then
ErrorVentas = True
Exit For
End If
End If
If Not EsDetalle Then
Dim ConceptoContable As Integer = 1 SubTotal = 0
Dim ConceptoContablePago As Integer = 2 IVA = 0
If TipoDocto = "Egs" Then Total = 0
ConceptoContable = 12 Saldo = 0
ConceptoContablePago = 91 RetIVA = 0
End If RetISR = 0
For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
If FolioFiscal <> "" Then SubTotal += item("SubTotal").ToString().ToDecimal
If Not ObjVentas.UpdateVentaFolioFiscal(FolioFiscal, CveVenta, UsuarioActual.CveEmpresa) Then IVA += item("IVA").ToString().ToDecimal
ErrorVentas = True Total += item("Total").ToString().ToDecimal
Exit For Saldo += item("Saldo").ToString().ToDecimal
End If RetIVA += item("Ret IVA").ToString().ToDecimal
End If RetISR += item("Ret ISR").ToString().ToDecimal
IEPS += item("IEPS").ToString().ToDecimal
Dim UsaComplementaria As Boolean = False Next
If UsuarioActual.CveEmpresa.Contiene(119, 158) Then UsaComplementaria = True 'ANTICIPOS
Dim CveIE As Integer = ObjIE.AddBancos_IE(1, 1, Fecha, Folio.ToString(), "", Total, 1,
If Not EsDetalle Then 1, "Anticipo Cliente", "", False, False, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
SubTotal = 0 If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, 30, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
IVA = 0 If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, 66, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
Total = 0
Saldo = 0
RetIVA = 0
RetISR = 0
For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
SubTotal += item("SubTotal").ToString().ToDecimal
IVA += item("IVA").ToString().ToDecimal
Total += item("Total").ToString().ToDecimal
Saldo += item("Saldo").ToString().ToDecimal
RetIVA += item("Ret IVA").ToString().ToDecimal
RetISR += item("Ret ISR").ToString().ToDecimal
IEPS += item("IEPS").ToString().ToDecimal
Next
'PrePólizaDetalle
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, SubTotal, 4, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, CveSubProyecto:=Sucursal.ToEntero(), PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, ConceptoContable, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
If IVA > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, IVA, 13, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If IEPS > 0 Then
'AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, Folio, 38, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IEPS)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, IEPS, 38, Folio.ToString, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If RetIVA > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 8, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If RetISR > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 9, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If ImpuestoLocal > 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImpuestoLocal, ImpuestoLocal, 27, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
If UsaComplementaria Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total * TipoCambio.ToDecimal - Total, Total * TipoCambio.ToDecimal - Total, 203, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteME:=Total, TipoCambio:=TipoCambio.ToDecimal, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
'Saldo
If Saldo < Total Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Total - Saldo, ConceptoContablePago, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, CveVentaAmortizacion:=CveVenta, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Total - Saldo, 95, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If End If
End If End If
Encontrados = Encontrados + 1
Else Else
NoEncontrados = NoEncontrados + 1
If Not EsDetalle Then StrRFCNoencontrados.AppendFormat("{0}<br/>", RFC)
'ErrorVentas = True
SubTotal = 0 'Exit For
IVA = 0
Total = 0
Saldo = 0
RetIVA = 0
RetISR = 0
For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
SubTotal += item("SubTotal").ToString().ToDecimal
IVA += item("IVA").ToString().ToDecimal
Total += item("Total").ToString().ToDecimal
Saldo += item("Saldo").ToString().ToDecimal
RetIVA += item("Ret IVA").ToString().ToDecimal
RetISR += item("Ret ISR").ToString().ToDecimal
IEPS += item("IEPS").ToString().ToDecimal
Next
'ANTICIPOS
Dim CveIE As Integer = ObjIE.AddBancos_IE(1, 1, Fecha, Folio.ToString(), "", Total, 1,
1, "Anticipo Cliente", "", False, False, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, 30, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, 66, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
End If
End If End If
Encontrados = Encontrados + 1
Else CountRow = CountRow + 1
NoEncontrados = NoEncontrados + 1 Next
StrRFCNoencontrados.AppendFormat("{0}<br/>", RFC) End If
'ErrorVentas = True
'Exit For
End If
'**********************************************************************************************************************************************************************************
CountRow = CountRow + 1
Next
If Not ErrorVentas Then If Not ErrorVentas Then
Alert(String.Format("Se agregaron: <b>{0}</b> Ventas correctamente. <b>{1} no encontrados</b><br/>{2} ", Encontrados, NoEncontrados, StrRFCNoencontrados), TipoMensaje.MsgInformacion)
If UsuarioActual.CveEmpresa = 189 Then
Alert(String.Format("Se agregaron: <b>{0}</b> Ventas correctamente. <b>{1} no encontrados</b><br/>{2} ", VentasAgregadas, NoEncontrados, StrRFCNoencontrados), TipoMensaje.MsgInformacion)
Else
Alert(String.Format("Se agregaron: <b>{0}</b> Ventas correctamente. <b>{1} no encontrados</b><br/>{2} ", Encontrados, NoEncontrados, StrRFCNoencontrados), TipoMensaje.MsgInformacion)
End If
ObjVentas.Commit() ObjVentas.Commit()
TxtExcel.Text = "" TxtExcel.Text = ""
UpDatos.Update() UpDatos.Update()

View File

@@ -629,15 +629,15 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
var CancelacionPagos = Modelos.OpcionesCancelacionPagos.SinPagos; var CancelacionPagos = Modelos.OpcionesCancelacionPagos.SinPagos;
if (UsuarioActual.Empresa.Funcionalidad(109) == "1") if (UsuarioActual.Empresa.Funcionalidad(109) == "1" || UsuarioActual.Empresa.Funcionalidad(382) == "1")
{ {
CancelacionPagos = Modelos.OpcionesCancelacionPagos.ConPagos_CancelarIE; CancelacionPagos = Modelos.OpcionesCancelacionPagos.ConPagos_CancelarIE;
} }
if (UsuarioActual.Empresa.Funcionalidad(382) == "1") //if (UsuarioActual.Empresa.Funcionalidad(382) == "1")
{ //{
CancelacionPagos = Modelos.OpcionesCancelacionPagos.ConPagos_GenerarIxC; // CancelacionPagos = Modelos.OpcionesCancelacionPagos.ConPagos_GenerarIxC;
} //}
retorno = factura.EjecutarCancelacionPendiente(CveEstatus, CancelacionFecha, CancelacionAcuse, CancelacionPagos: CancelacionPagos); retorno = factura.EjecutarCancelacionPendiente(CveEstatus, CancelacionFecha, CancelacionAcuse, CancelacionPagos: CancelacionPagos);

View File

@@ -407,6 +407,10 @@
<li> <li>
<asp:HyperLink ID="HLFAgregarOS" Target="_blank" runat="server" Visible="false"> <i class="fa fa-plus"></i> Agregar Orden de Servicio</asp:HyperLink> <asp:HyperLink ID="HLFAgregarOS" Target="_blank" runat="server" Visible="false"> <i class="fa fa-plus"></i> Agregar Orden de Servicio</asp:HyperLink>
</li> </li>
<li id="LiCalcularPromociones" runat="server" visible="false">
<asp:LinkButton ID="LnkCalcularPromociones" runat="server" CausesValidation="False" Text="<i class='fa fa-tag'></i> Aplicar promociones" OnClick="LnkCalcularPromociones_Click"
data-toggle="confirmation" data-popout="true" data-original-title="¿Aplicar Promociones?" data-btn-ok-label="si" />
</li>
</ContentTemplate> </ContentTemplate>
<Triggers> <Triggers>
<asp:AsyncPostBackTrigger ControlID="LnkImprimir" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="LnkImprimir" EventName="Click" />
@@ -8343,7 +8347,7 @@
<div id="DivCorreoCuentaCliente" runat="server" visible="false" class="row" style="padding-left: 16px;"> <div id="DivCorreoCuentaCliente" runat="server" visible="false" class="row" style="padding-left: 16px;">
<div class="form-group form-md-line-input input-iconright col-xs-6"> <div class="form-group form-md-line-input input-iconright col-xs-6">
<asp:TextBox ID="TxtCorreoCliente" CssClass="form-control" runat="server" MaxLength="300" CausesValidation="true"></asp:TextBox> <asp:TextBox ID="TxtCorreoCliente" CssClass="form-control" runat="server" MaxLength="300" CausesValidation="true"></asp:TextBox>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" CssClass="help-block errorimput" ValidationExpression="(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*" ControlToValidate="TxtCorreoCliente" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Email''</b> no es válido, por favor ingrése uno correcto." ValidationGroup="GrpGuardarCliente"></asp:RegularExpressionValidator>--%> <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" CssClass="help-block errorimput" ValidationExpression="(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*" ControlToValidate="TxtCorreoCliente" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Email''</b> no es válido, por favor ingrése uno correcto." ValidationGroup="GrpGuardarCliente"></asp:RegularExpressionValidator>--%>
<label for="<%= TxtCorreoCliente.ClientID.ToString()%>">Email: </label> <label for="<%= TxtCorreoCliente.ClientID.ToString()%>">Email: </label>
<i></i> <i></i>
</div> </div>

View File

@@ -23821,6 +23821,11 @@ Partial Class Ventas
End If End If
End If End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = True
End If
TxtAtencionA.Enabled = True TxtAtencionA.Enabled = True
UpCliente.Update() UpCliente.Update()
@@ -23828,6 +23833,7 @@ Partial Class Ventas
UpPS.Update() UpPS.Update()
UpCliente.Update() UpCliente.Update()
UPObservaciones.Update() UPObservaciones.Update()
UpnTools.Update()
End Sub End Sub
Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click
@@ -23954,7 +23960,7 @@ Partial Class Ventas
For Each Row As DataRow In TmpDT.Rows For Each Row As DataRow In TmpDT.Rows
Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero() Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero()
If CveVentaDetalle > 0 Then If CveVentaDetalle > 0 Then
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Descuento").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario) Then If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Descuento").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario, CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero()) Then
OcurrioError = True OcurrioError = True
Exit For Exit For
End If End If
@@ -23962,7 +23968,7 @@ Partial Class Ventas
If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("CveUM").ToString().ToEntero(), If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("CveUM").ToString().ToEntero(),
Row("PU").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), Row("PU").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6),
Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(), Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(),
CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString()}").ToEntero(), -1), CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(),
ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDecimal, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDecimal, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal()) Then ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDecimal, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDecimal, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal()) Then
OcurrioError = True OcurrioError = True
Exit For Exit For
@@ -24897,7 +24903,7 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then EjecutaRecalculaPrecios = True If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then EjecutaRecalculaPrecios = True
If UsuarioActual.CveEmpresa = 189 Then EjecutaRecalculaPrecios = False If UsuarioActual.CveEmpresa = 189 Then EjecutaRecalculaPrecios = False
If EjecutaRecalculaPrecios Then RecalculaPrecios() If EjecutaRecalculaPrecios Then RecalculaPrecios(False)
End Sub End Sub
Private Function ValidaPagosContado(Optional MostrarAlertas As Boolean = True, Optional TipoDoctoViejo As String = "") As Boolean Private Function ValidaPagosContado(Optional MostrarAlertas As Boolean = True, Optional TipoDoctoViejo As String = "") As Boolean
@@ -31899,6 +31905,9 @@ Partial Class Ventas
BtnCrearApartirDe.Visible = False BtnCrearApartirDe.Visible = False
BtnGenerarRemision.Visible = False BtnGenerarRemision.Visible = False
BtnPermisoEditarCotizacion.Visible = False BtnPermisoEditarCotizacion.Visible = False
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = False
End If
BtnEditarCotizacion.Visible = False BtnEditarCotizacion.Visible = False
BtnGenerarOS.Visible = False BtnGenerarOS.Visible = False
@@ -32967,12 +32976,16 @@ Partial Class Ventas
End If End If
End If End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = True
End If
UpPS.Update() UpPS.Update()
UPPDescuento.Update() UPPDescuento.Update()
UPObservaciones.Update() UPObservaciones.Update()
UPCondicionesPago.Update() UPCondicionesPago.Update()
UpCliente.Update() UpCliente.Update()
UpnTools.Update()
End Sub End Sub
Private Sub BtnEditarCotizacion_Click(sender As Object, e As EventArgs) Handles BtnEditarCotizacion.Click Private Sub BtnEditarCotizacion_Click(sender As Object, e As EventArgs) Handles BtnEditarCotizacion.Click
@@ -33107,7 +33120,7 @@ Partial Class Ventas
Row("PU").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal() * (1 + Row("PorcentajeIVA").ToString().ToDecimal())), 6), Row("PU").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal() * (1 + Row("PorcentajeIVA").ToString().ToDecimal())), 6),
Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(),
PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDecimal, TiempoEntrega:=Row("TiempoEntrega").ToString(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDecimal, TiempoEntrega:=Row("TiempoEntrega").ToString(),
PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero()) Then
MensajeError = "Ocurrió un error al guardar las partidas de la cotización" MensajeError = "Ocurrió un error al guardar las partidas de la cotización"
OcurrioError = True OcurrioError = True
Exit For Exit For
@@ -34591,6 +34604,9 @@ Partial Class Ventas
'CUANDO ES CREAR APARTIR DE SE LIMPIAN FUNCIONALIDADES DE DOCUMENTOS YA REGISTRADOS 'CUANDO ES CREAR APARTIR DE SE LIMPIAN FUNCIONALIDADES DE DOCUMENTOS YA REGISTRADOS
BtnGenerarRemision.Visible = False BtnGenerarRemision.Visible = False
BtnEditarRemision.Visible = False BtnEditarRemision.Visible = False
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = False
End If
BtnPermisoEditarRemision.Visible = False BtnPermisoEditarRemision.Visible = False
BtnPermisoEditarCotizacion.Visible = False BtnPermisoEditarCotizacion.Visible = False
BtnEditarCotizacion.Visible = False BtnEditarCotizacion.Visible = False
@@ -39807,7 +39823,7 @@ Partial Class Ventas
RegistraScript("MuestraAnticipos();", "AE") RegistraScript("MuestraAnticipos();", "AE")
End Sub End Sub
Private Sub RecalculaPrecios() Private Sub RecalculaPrecios(ByRef RecalculoPromociones As Boolean, Optional ForzarRecalculo As Boolean = False)
Dim PuedeRecalcular As Boolean = False Dim PuedeRecalcular As Boolean = False
If CveVenta <= 0 OrElse EsCreaApartirDe OrElse (ModalidadEdicion AndAlso Not DdlTipoComprobante.SelectedValue = "Cot") Then If CveVenta <= 0 OrElse EsCreaApartirDe OrElse (ModalidadEdicion AndAlso Not DdlTipoComprobante.SelectedValue = "Cot") Then
@@ -39819,6 +39835,10 @@ Partial Class Ventas
PuedeRecalcular = False PuedeRecalcular = False
End If End If
If ForzarRecalculo Then
PuedeRecalcular = True
End If
If TmpDT IsNot Nothing AndAlso PuedeRecalcular Then If TmpDT IsNot Nothing AndAlso PuedeRecalcular Then
For Each Row As DataRow In TmpDT.Rows For Each Row As DataRow In TmpDT.Rows
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal() Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
@@ -39846,6 +39866,13 @@ Partial Class Ventas
Row("Total") = (Cantidad * PU) Row("Total") = (Cantidad * PU)
Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales) Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
Row("TotalConImpuestos") = (Row("Total").ToString().ToDecimal() - Row("Descuento").ToString().ToDecimal() + Row("ImporteIVA").ToString().ToDecimal()).RoundSQL(2) Row("TotalConImpuestos") = (Row("Total").ToString().ToDecimal() - Row("Descuento").ToString().ToDecimal() + Row("ImporteIVA").ToString().ToDecimal()).RoundSQL(2)
Row("CvePromocionDetalle") = ObjDescuento.CvePromocionDetalle
If ObjDescuento.CvePromocionDetalle > 0 Then
RecalculoPromociones = True
End If
End If End If
Next Next
@@ -39917,7 +39944,9 @@ Partial Class Ventas
BtnsFacturar.Visible = False BtnsFacturar.Visible = False
BtnEditarRemision.Visible = False BtnEditarRemision.Visible = False
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
LiCalcularPromociones.Visible = False
End If
LimpiaDocumentoDEV() LimpiaDocumentoDEV()
CambiaTipoDocto() CambiaTipoDocto()
@@ -40288,5 +40317,17 @@ Partial Class Ventas
Protected Sub BtnRegresarBusqueda_Click(sender As Object, e As EventArgs) Protected Sub BtnRegresarBusqueda_Click(sender As Object, e As EventArgs)
LimpiarAgregarCliente() LimpiarAgregarCliente()
End Sub End Sub
Protected Sub LnkCalcularPromociones_Click(sender As Object, e As EventArgs)
Dim Recalculo As Boolean = False
RecalculaPrecios(Recalculo, ForzarRecalculo:=True)
If Recalculo Then
Alert("Se han recalculado los precios y promociones en base a las condiciones actuales")
Else
Alert("No se han encontrado cambios para los precios y promociones")
End If
End Sub
End Class End Class