This commit is contained in:
rrene
2020-03-09 19:38:22 -07:00
16 changed files with 2159 additions and 1144 deletions

View File

@@ -815,6 +815,8 @@ Partial Class Ventas_ClientesAbonar
For Each gvr As GridViewRow In GvCxC.Rows
If gvr.FCCheckBox("Chk").Checked Then
Dim ObjFactura As New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos
tipoCambioPago = 1
tipoCambioVenta = 1
@@ -913,6 +915,9 @@ Partial Class Ventas_ClientesAbonar
Case 8 'Ret IVA x Trasladar
If EsAnticipoEspecial Then Exit Select
If ObjFactura.CveTipoRetencion = 4 Then
Exit Select
End If
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
importeMX = ImporteMovimiento
@@ -956,6 +961,44 @@ Partial Class Ventas_ClientesAbonar
End If
End If
End If
Case 313 'Ret Iva Servicios
If EsAnticipoEspecial Then Exit Select
If ObjFactura.CveTipoRetencion = 4 Then
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
importeMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
importeMX = ImporteMovimiento * tipoCambioVenta
ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
importeMX = ImporteMovimiento * tipoCambioVenta
ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
importeMX = ImporteMovimiento * tipoCambioVenta
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
TipoCambioGeneral = tipoCambioVenta
CveSubProyectoContabilizar = CveSubProyecto
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
'OBTENER CUENTAS
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
'Conta ContPAQ
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
'Conta SIG
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero
End If
End If
End If
Case 9 'Ret ISR x Trasladar
If EsAnticipoEspecial Then Exit Select
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
@@ -1037,6 +1080,9 @@ Partial Class Ventas_ClientesAbonar
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
Case 62 'Ret IVA Trasladado
If EsAnticipoEspecial Then Exit Select
If ObjFactura.CveTipoRetencion = 4 Then
Exit Select
End If
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
importeMX = ImporteMovimiento
@@ -1081,6 +1127,44 @@ Partial Class Ventas_ClientesAbonar
End If
End If
End If
Case 314 'Ret Iva Servicios Traslado
If EsAnticipoEspecial Then Exit Select
If ObjFactura.CveTipoRetencion = 4 Then
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
importeMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
importeMX = ImporteMovimiento * tipoCambioVenta
ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
CveSubProyectoContabilizar = CveSubProyecto
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
'OBTENER CUENTAS
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
'Conta ContPAQ
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
'Conta SIG
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero
End If
End If
End If
Case 63 'Ret ISR Trasladado
If EsAnticipoEspecial Then Exit Select
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
@@ -1401,7 +1485,8 @@ Partial Class Ventas_ClientesAbonar
Next
End If
If gvr.FCCheckBox("ChkGenerarNC").Checked Then
ListaFacturasGenerarNC.Add(New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) With {.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()})
ObjFactura.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()
ListaFacturasGenerarNC.Add(ObjFactura)
End If
End If

View File

@@ -56,6 +56,114 @@
</li>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel runat="server" ID="UpFiltros">
<ContentTemplate>
<div class="portlet solid grey-cascade portlet-filter" style="">
<div class="portlet-title portlet-filterT smalltitle" style="min-height: 122px; position: relative;">
<div class="tools">
<asp:Button ID="btConsultar" CssClass="btn btn-primary" runat="server" ValidationGroup="GrpConsultar" Text="Consultar" /></td>
<a href="javascript:;" data-idchekbox="<%= chkexpand.ClientID%>" class=" <%= IIf(chkexpand.Checked = True, "collapse", "expand")%>"></a>
<asp:CheckBox ID="chkexpand" CssClass="hidden" runat="server" />
</div>
<div class="titlefiltros caption magindate">
<div class="row">
<div class="col-md-1 truncate text-right">Fecha del mes: </div>
<div class="col-md-2 col-sm-2">
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 95px !important; padding: 0px;">
<asp:TextBox Style="width: 80px !important;" ID="TxtFechaMes" runat="server" CssClass="form-control" CausesValidation="true" MaxLength="10"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="ImgFechaMes" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
</div>
<ajax:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TxtFechaMes" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CalendarExtender1" TargetControlID="TxtFechaMes" PopupButtonID="ImgFechaMes" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
</div>
<div class="col-md-1 truncate text-right">Sucursal: </div>
<div class="col-md-2">
<asp:DropDownList ID="DdlSubProyectoFiltro" runat="server" CssClass="form-control input-sm select2me" Width="50%" DataValueField="CveSubProyecto" DataTextField="SubProyecto"></asp:DropDownList>
</div>
</div>
<div class="row" style="margin-top: 10px">
<label class="col-md-1 text-right">Marca: </label>
<div class="col-md-3">
<asp:DropDownList ID="DdlMarcaFiltro" runat="server" DataTextField="Marca" DataValueField="CveMarca" CssClass="form-control input-sm select2me"></asp:DropDownList>
</div>
<label class="col-md-1 text-right">Vendedor: </label>
<div class="col-md-3">
<asp:DropDownList ID="DdlVendedorFiltro" runat="server" Class="table-group-action-input form-control input-inline input-sm select2me" Width="50%" DataValueField="CveVendedor" DataTextField="Vendedor"></asp:DropDownList>
</div>
<label class="col-md-1 text-right">Categoria: </label>
<div class="col-md-3">
<asp:DropDownList ID="DdlCategoria" runat="server" Class="table-group-action-input form-control input-inline input-sm select2me" Width="50%" DataValueField="CveCategoria" DataTextField="Categoria"></asp:DropDownList>
</div>
</div>
<div class="row" style="margin-top: 10px">
<label class="col-md-1 text-right">Clasificaciones: </label>
<div class="col-md-3">
<asp:DropDownList ID="DdlClasificaciones" runat="server" Class="table-group-action-input form-control input-inline input-sm select2me" Width="50%" DataValueField="CveClasificacion" DataTextField="Clasificacion"></asp:DropDownList>
</div>
<label class="col-md-1 text-right">Sub Clasificaciones: </label>
<div class="col-md-3">
<asp:DropDownList ID="DdlClasificacion2" runat="server" Class="table-group-action-input form-control input-inline input-sm select2me" Width="50%" DataValueField="CveClasificacion" DataTextField="Clasificacion"></asp:DropDownList>
</div>
</div>
</div>
</div>
<div class="portlet-body magindate" <%= IIf(chkexpand.Checked = True, "", "style=""display:none;""")%>>
<div class="row">
</div>
<div class="row">
</div>
<div id="DivFamiliaSubFamilia" class="row" runat="server" visible="false">
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div id="dvCuerpo" style="width: 100%">
<asp:UpdatePanel ID="UPDatos" runat="server" RenderMode="Inline" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GV" runat="server" GridLines="None" BorderWidth="0" UseAccessibleHeader="true" DataKeyNames="Titulo,Etiqueta,RealMes,VtaMesAA,RealAcumulado,RealMesPorcentaje"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD" data-sort="true" ShowHeader="True" EmptyDataText="No se encontraron resultados." ShowHeaderWhenEmpty="true"
AutoGenerateColumns="False" AllowPaging="False" ShowFooter="False">
<Columns>
<asp:TemplateField HeaderText="Grupo" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="HlkGrupo" runat="server" Target="_blank" Text='<%# Eval("Titulo").ToString() %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Real Mes" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblRealMes" runat="server" Target="_blank" Text='<%# Eval("RealMes").ToString() %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Ventata Mes Año Anterior" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblVtaMesAA" runat="server" Target="_blank" Text='<%# Eval("VtaMesAA").ToString() %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Real Acumulado" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblRealAcumulado" runat="server" Target="_blank" Text='<%# Eval("RealAcumulado").ToString() %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Real Mes Porcentaje" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblRealMesPorcentaje" runat="server" Target="_blank" Text='<%# Eval("RealMesPorcentaje").ToString() %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="DivAgregarTiposD" class="modal ADS fade" role="dialog">
<div class="modal-dialog" style="width: 450px;">
<asp:UpdatePanel runat="server" class="modal-content" ID="UpModalTiposD" UpdateMode="Conditional">

View File

@@ -4,12 +4,54 @@ Imports Microsoft.Reporting.WebForms
Partial Class MetasVendedores
Inherits ClsPaginas
Private Property DtDatos As DataTable
Get
DtDatos = DirectCast(ViewState("DtDatos"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtDatos") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CargaDatosModal()
CargaDatosFiltros()
CargarDatosReporte()
End If
End Sub
Private Sub CargaDatosFiltros()
Dim dNow As Date = Now
TxtFechaMes.Text = dNow.ToString("dd/MM/yyyy")
DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa)
DdlSubProyectoFiltro.DataBind()
DdlSubProyectoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
Dim ObjPS As New ClsProductosServicios
If ObjPS.GetMarcas(UsuarioActual.CveEmpresa) Then
DdlMarcaFiltro.DataSource = ObjPS.DtResultados
End If
ObjPS.Dispose()
DdlMarcaFiltro.DataBind()
DdlMarcaFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
DdlVendedorFiltro.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedorFiltro.DataBind()
DdlVendedorFiltro.Items.Insert(0, New ListItem("Seleccionar", "-1"))
DdlCategoria.DataSource = GlobalDTGralCategorias(UsuarioActual.CveEmpresa)
DdlCategoria.DataBind()
DdlCategoria.Items.Insert(0, New ListItem("Seleccionar", "-1"))
DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
DdlClasificaciones.DataBind()
DdlClasificaciones.Items.Insert(0, New ListItem("Todos", "-1"))
DdlClasificacion2.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
DdlClasificacion2.DataBind()
DdlClasificacion2.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Private Sub CargaDatosModal()
DdlVendedores.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
@@ -25,6 +67,17 @@ Partial Class MetasVendedores
DdlMarcas.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Private Sub CargarDatosReporte()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetRepMetasVendedores(TxtFechaMes.Text, UsuarioActual.CveEmpresa, DdlVendedorFiltro.SelectedValue.ToEntero, DdlCategoria.SelectedValue.ToEntero,
DdlClasificaciones.SelectedValue.ToEntero, DdlClasificacion2.SelectedValue.ToEntero, DdlMarcaFiltro.SelectedValue.ToEntero,
DdlSubProyectoFiltro.SelectedValue.ToEntero) Then
GV.DataSource = ObjVentas.DtResultados
DtDatos = ObjVentas.DtResultados
End If
ObjVentas.Dispose()
GV.DataBind()
End Sub
Private Sub ResetDatosSeleccionadosModal()
DdlVendedores.SelectedValue = "-1"
TxtFechaI.Text = ""
@@ -53,4 +106,45 @@ Partial Class MetasVendedores
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"))
ResetDatosSeleccionadosModal()
End Sub
Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click
CargarDatosReporte()
UPDatos.Update()
End Sub
Protected Sub GV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GV.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Select Case e.Row.DataKey("Etiqueta")
Case "Categoria"
e.Row.CssClass = "Totales"
Case "Clasificacion"
e.Row.CssClass = "SubTotales2"
Case "Clasificacion2"
e.Row.CssClass = "SubTotales"
End Select
If e.Row.DataKey("Titulo") = "" Then
e.Row.Cells(0).Text = "OTRO"
End If
End If
End Sub
Protected Sub LnkPDF_RowDataBound(sender As Object, e As EventArgs) Handles LnkPDF.Click
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
If Imagen.Exists Then
params.Add(New ReportParameter("pImg", logouri))
Else
params.Add(New ReportParameter("pImg", ""))
End If
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
params.Add(New ReportParameter("FechaImpresion", Today))
params.Add(New ReportParameter("SubProyecto", DdlSubProyectoFiltro.SelectedItem.ToString))
params.Add(New ReportParameter("Agente", DdlVendedorFiltro.SelectedItem.ToString))
ImprimirPDF("Empresas/Grales/Formatos/MetasVendedores.rdlc", DtDatos, params, "Rep. Metas por vendedores", "PDF", RDSName:="DataSet1")
End Sub
End Class

View File

@@ -2590,6 +2590,19 @@ Partial Class Ventas
CargaPorcentajeMarcas()
BloqueaCondiconesPago()
BloqueaClasificaciones()
'NO PERMITIR AGREGAR PS DESDE VENTAS EN ECONOLLANTAS
If UsuarioActual.CveEmpresa = 141 Then
BtnModalAddPS.Enabled = False
End If
End Sub
Private Sub BloqueaClasificaciones()
If UsuarioActual.CveEmpresa = 141 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
DdlClasificacion.Enabled = False
DdlUnidadMedida.Enabled = False
End If
End Sub
Private Sub BloqueaCondiconesPago()
@@ -4376,6 +4389,8 @@ Partial Class Ventas
End If
End If
DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString)
UpPS.Update()
UpContado.Update()
UpEstatus.Update()
@@ -4794,10 +4809,10 @@ Partial Class Ventas
ViewState("ClienteRetIVA") = ObjCliente.RetIVA / 100
ViewState("ClienteRetISR") = ObjCliente.RetISR / 100
DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString)
DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty)
If CveVenta <= 0 Then
DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString)
DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty)
ViewState("RetIVAFletes") = ObjCliente.RetieneIVAFletes
If ObjCliente.RetieneIVAFletes Then
TrRetIVA.Style.Add("display", "")
@@ -4806,9 +4821,6 @@ Partial Class Ventas
End If
ViewState("Vendedor") = ObjCliente.Vendedor
ViewState("CtaContable") = ObjCliente.CuentaContable
ViewState("IdCtaContClientes") = ObjCliente.IdCtaContClientes
@@ -5819,6 +5831,10 @@ Partial Class Ventas
GvPS.DataSource = TmpDT
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
GvPS.DataBind()
If UsuarioActual.CveEmpresa = 141 Then
GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlUnidadMedida").Enabled = False
GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlClasificacion").Enabled = False
End If
End Sub
Protected Sub GvPS_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvPS.RowCancelingEdit
GvPS.EditIndex = -1
@@ -6053,6 +6069,7 @@ Partial Class Ventas
End If
End If
' LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero
TrRetIVA.Style.Add("display", "")
DdlTipoRetencion.Visible = True
End If
@@ -8392,6 +8409,9 @@ Partial Class Ventas
End Select
ObjFactura.ComplementoINE = INE
End If
If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then
ObjFactura.CveTipoRetencion = DdlTipoRetencion.SelectedValue.ToEntero()
End If
End Sub
Private Sub CreaObjetosVentaDevolucion()
@@ -8791,7 +8811,7 @@ Partial Class Ventas
.Descripcion = tPS,
.ValorUnitario = drr("PU").ToString.ToDecimal,
.Importe = drr("TotalImporte").ToString.ToDecimal,
.Descuento = drr("Descuento").ToString.ToDecimal,
.Descuento = drr("Descuento").ToString.ToDecimal.RoundSQL(2),
.Unidad = drr("UM").ToString,
.ClaveUnidad = drr("SATClaveUM").ToString,
.ClaveProdServ = drr("SATClaveProdServ").ToString,
@@ -9300,6 +9320,10 @@ Partial Class Ventas
Next
End If
Dim CveTipoRetencion As Integer = -1
If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then
CveTipoRetencion = DdlTipoRetencion.SelectedValue.ToEntero()
End If
factura.CvePrePoliza = ObjConta.AddPrePolizas("Ventas/GuardarVenta", factura.CvePlantillaPoliza, factura.Total, factura.Total, factura.CveMoneda, factura.Fecha, If(CveEmpresaCRM > 0, LblEmpresaCRM.Text, factura.Cliente.Nombre), factura.CveUsuario, factura.CveEmpresa)
If Not ObjVentas.AddVenta(factura.TipoDocto, factura.Folio, factura.CveCliente, factura.CveClienteSucursal, factura.SubTotalTC, factura.DescuentoTC,
@@ -9316,7 +9340,7 @@ Partial Class Ventas
CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)),
CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM,
DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False),
Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion) Then
Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion, CveTipoRetencion:=CveTipoRetencion) Then
ErrorList.Add("Ocurrió un error al Generar la Venta.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
Else
If factura.TipoDocto.Contiene("Dev", "Egs") Or DtVentasNC IsNot Nothing Then
@@ -10564,7 +10588,7 @@ Partial Class Ventas
End If
Case 8 'Ret IVA por Trasladar
If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then
If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso ObjFactura.CveTipoRetencion <> 4 Then 'SI NO ES RETENCION DE IVA DE SERVICIOS
importeMovimiento = ObjFactura.RetIVA * ValorMultiplicador
importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
@@ -10572,17 +10596,12 @@ Partial Class Ventas
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
'CONTABILIDAD CONTPAQ
'SI LA RETENCION ES AL 6% DEBE USAR ESTA CUENTA
If UsuarioActual.Empresa.Funcionalidad(580).ToEntero() > 0 AndAlso (DdlTipoRetencion.SelectedValue = "4") Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(580).ToEntero()
If IdCtaContRetIVA > 0 Then
IdCtaContable = IdCtaContRetIVA
Else
If IdCtaContRetIVA > 0 Then
IdCtaContable = IdCtaContRetIVA
Else
If ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
If ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
@@ -10599,6 +10618,25 @@ Partial Class Ventas
End If
End If
Case 313 'Ret Iva Servicios
If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso ObjFactura.CveTipoRetencion = 4 Then 'SI TIENE RETENCION DE IVA DE SERVICIOS
importeMovimiento = ObjFactura.RetIVA * ValorMultiplicador
importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
CveSubProyectoContabilizar = CveSubProyectoVenta
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
'OBTENER CUENTAS
If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
'Conta ContPAQ
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
'Conta SIG
CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero
End If
End If
End If
Case 9 'Ret ISR por Trasladar
@@ -12367,14 +12405,20 @@ Partial Class Ventas
' Exit Sub
'End If
Dim TotalCalculableImpuestos As Decimal = 0
Dim Cantidad, PU, Descuento As Decimal
Dim TotalDescuentosRound As Decimal = 0
Dim Cantidad, PU, Descuento, DescuentoRound As Decimal
For Each dr As DataRow In TmpDT.Rows
Cantidad = dr("Cantidad").ToString.ToDecimal
PU = dr("PU").ToString.ToDecimal
'proporcional la mortización al concepto
Descuento = PU * Cantidad / LblSubTotal1.Text.ToDecimal * Amortizacion
Descuento = (PU * Cantidad / LblSubTotal1.Text.ToDecimal * Amortizacion)
DescuentoRound = Descuento.RoundSQL(NumeroDecimales)
TotalDescuentosRound += DescuentoRound
TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
dr("Descuento") = Descuento
dr("Descuento") = DescuentoRound
dr("TotalImporte") = Math.Round(Cantidad * PU, NumeroDecimales)
dr("ImporteIVA") = Math.Round(dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
dr("ImporteIEPS") = Math.Round(dr("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
@@ -12383,6 +12427,19 @@ Partial Class Ventas
dr("PorcentajeRetIVA") = ClienteRetIVA
dr("PorcentajeRetISR") = ClienteRetISR
Next
'REVISA SI EXISTEN DIFERENCIAS ENTRE EL DESCUENTO Y LO AMORTIZADO PARA REALIZAR UN AJUSTE EN EL ULTIMO CONCEPTO AGREGADO
Dim diff As Decimal = Math.Abs(TotalDescuentosRound - Amortizacion)
Dim DrUltimo As DataRow = TmpDT.Rows(TmpDT.Rows.Count - 1)
'SI EL DESCUENTO SUPERA LO AMORTIZADO RESTA LA DIFERENCIA AL ULTIMO DESCUENTO
If TotalDescuentosRound > Amortizacion Then
DrUltimo("Descuento") = DrUltimo("Descuento").ToString().ToDecimal() - diff
End If
'SI EL DESCUENTO ES MENOR A LO AMORTIZADO SUMA LA DIFERENCIA AL ULTIMO DESCUENTO
If TotalDescuentosRound < Amortizacion Then
DrUltimo("Descuento") = DrUltimo("Descuento").ToString().ToDecimal() + diff
End If
GvPS.DataSource = TmpDT
GvPS.DataBind()
@@ -14209,6 +14266,7 @@ Partial Class Ventas
CargaGvComercioExterior()
End If
End If
UpPS.Update()
End Sub
@@ -14461,6 +14519,7 @@ Partial Class Ventas
End If
' LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero
TrRetIVA.Style.Add("display", "")
DdlTipoRetencion.Visible = True
End If
@@ -17052,6 +17111,9 @@ Partial Class Ventas
Else
Alert("El producto no fue encontrado.", TipoMensaje.MsgAdvertencia)
End If
UpPS.Update()
End Sub
Private Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlMoneda.SelectedIndexChanged
CambiaMoneda()
@@ -17473,6 +17535,28 @@ Partial Class Ventas
End Sub
Private Function ValidaPagosContado() As Boolean
Dim Retorno = False
'SI LA VENTA ES NUEVA VALIDAR TAMBIEN LOS PAGOS DE CONTADO
If UsuarioActual.CveEmpresa = 141 AndAlso CveVenta <= 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then
If Not PermiteCredito AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) Then
Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia)
Retorno = True
Return Retorno
End If
If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then
Dim Total As Decimal = TxtTotal.Text.ToDecimal()
Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal()
If TotalPago < Total Then
Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia)
Retorno = True
Return Retorno
End If
End If
End If
'SI TIENE SALDO PENDIENTE VALIDA SI TIENE PAGOS
If Me.SaldoVenta > 0 Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso (UsuarioActual.Empresa.Funcionalidad(531) = "1") AndAlso (Not PermiteCredito) AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) And TxtTotal.Text.ToDecimal > 0 Then
@@ -17480,6 +17564,21 @@ Partial Class Ventas
Retorno = True
End If
If UsuarioActual.CveEmpresa = 141 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then
If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then
Dim Total As Decimal = TxtTotal.Text.ToDecimal()
Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal()
If TotalPago < Total Then
Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia)
Retorno = True
Return Retorno
End If
End If
End If
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
Dim TotalNC As Decimal = If(ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0, LblTotalNC.Text.Trim().ToDecimal(), 0)
If TotalNC > 0 Then
@@ -23914,6 +24013,20 @@ Partial Class Ventas
Retorno = False
Return Retorno
End If
If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then
Dim Total As Decimal = TxtTotal.Text.ToDecimal()
Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal()
If TotalPago < Total Then
Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia)
Retorno = False
Return Retorno
End If
End If
End If
Return Retorno