-- APLICA DEVOLUCIONES DESDE COMRPAS

-- AGREGADO DE APLICASERIE
This commit is contained in:
2025-02-10 11:03:51 -07:00
parent 8b44f91b69
commit 861d1dee37
2 changed files with 347 additions and 362 deletions

View File

@@ -1496,8 +1496,22 @@
</div> </div>
<div class="tools"> <div class="tools">
<table width="325px"> <table width="525px">
<tr> <tr>
<td>
<div id="DivAlmacenDev" runat="server" visible="false" class="row">
<div class="col-md-12">
<table width="175px">
<tr>
<td width="50px">Almacen:</td>
<td width="125px">
<asp:DropDownList ID="DdlAlmacenDevolucion" Style="width: 100%" AutoPostBack="true" runat="server" CssClass="form-control input-sm select2me " DataTextField="Almacen" DataValueField="CveAlmacen"></asp:DropDownList>
</td>
</tr>
</table>
</div>
</div>
</td>
<td width="50px">Compra:</td> <td width="50px">Compra:</td>
<td width="250px"> <td width="250px">
<asp:DropDownList ID="DDLDevolucion" Style="width: 100%" AutoPostBack="true" runat="server" CssClass="form-control input-sm select2me " DataTextField="Compra" DataValueField="CveCompra"></asp:DropDownList> <asp:DropDownList ID="DDLDevolucion" Style="width: 100%" AutoPostBack="true" runat="server" CssClass="form-control input-sm select2me " DataTextField="Compra" DataValueField="CveCompra"></asp:DropDownList>
@@ -1510,30 +1524,16 @@
</div> </div>
</div> </div>
<div class="portlet-body"> <div class="portlet-body">
<div id="DivAlmacenDev" runat="server" visible="false" class="row"> <asp:GridView ID="GVDevolucion" runat="server" DataKeyNames="CveMovimientoDetalle,CveAlmacen,Total,PU,Cantidad,CvePS,CveUM,UM,CveClasificacion,Clasificacion,CodigoPS,CveTipoPS,PUExtranjero" ShowFooter="true" GridLines="None" AutoGenerateColumns="false" EmptyDataText="Aun no hay registros." ShowHeaderWhenEmpty="True" Width="100%" CssClass="table table-striped table-hover Widthall">
<div class="col-md-12">
<table width="325px">
<tr>
<td width="50px">Almacen:</td>
<td width="250px">
<asp:DropDownList ID="DdlAlmacenDevolucion" Style="width: 100%" AutoPostBack="true" runat="server" CssClass="form-control input-sm select2me " DataTextField="Almacen" DataValueField="CveAlmacen"></asp:DropDownList>
</td>
</tr>
</table>
</div>
</div>
<br />
<asp:GridView ID="GVDevolucion" runat="server" DataKeyNames="CveMovimientoDetalle,CveAlmacen,Total,PU,Cantidad,CvePS,CveUM,UM,CveClasificacion,Clasificacion,PS,CveTipoPS,PUExtranjero" ShowFooter="true" GridLines="None" AutoGenerateColumns="false" EmptyDataText="Aun no hay registros." ShowHeaderWhenEmpty="True" Width="100%" CssClass="table table-striped table-hover Widthall">
<Columns> <Columns>
<asp:TemplateField HeaderText="Cantidad" ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Right"> <asp:TemplateField HeaderText="Cantidad" ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Right">
<ItemTemplate> <ItemTemplate>
<asp:Label runat="server" Text='<%# Eval("Cantidad", "{0:#,##0.####}")%>'></asp:Label> <asp:Label runat="server" Text='<%# Eval("Cantidad", "{0:#,##0.####}")%>'></asp:Label>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:BoundField HeaderText="Unidad" DataField="UM" ItemStyle-Width="80px" /> <asp:BoundField HeaderText="Unidad" DataField="UM" ItemStyle-Width="70px" />
<asp:BoundField ItemStyle-Width="400px" HeaderText="Producto o Servicio" DataField="CodigoPS" /> <asp:BoundField HeaderText="Producto" DataField="CodigoPS" />
<asp:TemplateField ItemStyle-Width="80px" HeaderText="P.U." ItemStyle-HorizontalAlign="Right"> <asp:TemplateField ItemStyle-Width="85px" HeaderText="P.U." ItemStyle-HorizontalAlign="Right">
<ItemTemplate> <ItemTemplate>
<asp:Label Text='<%# Eval("PU", "{0:#,##0.####}")%>' runat="server"></asp:Label> <asp:Label Text='<%# Eval("PU", "{0:#,##0.####}")%>' runat="server"></asp:Label>
</ItemTemplate> </ItemTemplate>
@@ -1541,7 +1541,7 @@
<label>Total</label> <label>Total</label>
</FooterTemplate> </FooterTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:TemplateField ItemStyle-Width="80px" HeaderText="Devolución"> <asp:TemplateField ItemStyle-Width="85px" HeaderText="Devolución">
<ItemTemplate> <ItemTemplate>
<asp:TextBox ID="TxtCantidad" Width="50" Mask="999,999.99" min="0" data-max='<%# Eval("Cantidad")%>' data-pu='<%# Eval("PU")%>' type="number" step="any" data-Devolucion="devrow" runat="server"></asp:TextBox> <asp:TextBox ID="TxtCantidad" Width="50" Mask="999,999.99" min="0" data-max='<%# Eval("Cantidad")%>' data-pu='<%# Eval("PU")%>' type="number" step="any" data-Devolucion="devrow" runat="server"></asp:TextBox>
</ItemTemplate> </ItemTemplate>
@@ -1549,7 +1549,7 @@
<asp:TextBox ID="TxtTotal" Width="50" runat="server" Mask="999,999.99" data-Devolucion="devtotal" disabled></asp:TextBox> <asp:TextBox ID="TxtTotal" Width="50" runat="server" Mask="999,999.99" data-Devolucion="devtotal" disabled></asp:TextBox>
</FooterTemplate> </FooterTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:TemplateField ItemStyle-Width="80px" HeaderText=""> <asp:TemplateField ItemStyle-Width="85px" HeaderText="">
<ItemTemplate> <ItemTemplate>
<asp:TextBox ID="TxtTotalDevolucion" CssClass="devTotal TextBoxAsLabel" runat="server" Text="" disabled></asp:TextBox> <asp:TextBox ID="TxtTotalDevolucion" CssClass="devTotal TextBoxAsLabel" runat="server" Text="" disabled></asp:TextBox>
</ItemTemplate> </ItemTemplate>

View File

@@ -1689,9 +1689,7 @@ Partial Class Compras_Compras
End If End If
'SE OCUPAN AFUERA DEL POSTBACK ?? 'SE OCUPAN AFUERA DEL POSTBACK ??
cargaddlVinculacionServcios()
If UsuarioActual.TienePermisoProceso(117) Then If UsuarioActual.TienePermisoProceso(117) Then
HplAddClasificacion.Visible = False HplAddClasificacion.Visible = False
ImgClasificacion.Visible = False ImgClasificacion.Visible = False
End If End If
@@ -2011,6 +2009,8 @@ Partial Class Compras_Compras
SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL
If Not TmpDT.Columns.Contains("Amortizacion") Then TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) If Not TmpDT.Columns.Contains("Amortizacion") Then TmpDT.Columns.Add("Amortizacion", GetType(Decimal))
If Not TmpDT.Columns.Contains("AplicaSerie") Then TmpDT.Columns.Add(New DataColumn("AplicaSerie", GetType(Boolean)) With {.DefaultValue = False})
If Not TmpDT.Columns.Contains("AplicaLote") Then TmpDT.Columns.Add(New DataColumn("AplicaLote", GetType(Boolean)) With {.DefaultValue = False}) If Not TmpDT.Columns.Contains("AplicaLote") Then TmpDT.Columns.Add(New DataColumn("AplicaLote", GetType(Boolean)) With {.DefaultValue = False})
If Not TmpDT.Columns.Contains("AplicaCaducidad") Then TmpDT.Columns.Add(New DataColumn("AplicaCaducidad", GetType(Boolean)) With {.DefaultValue = False}) If Not TmpDT.Columns.Contains("AplicaCaducidad") Then TmpDT.Columns.Add(New DataColumn("AplicaCaducidad", GetType(Boolean)) With {.DefaultValue = False})
If Not TmpDT.Columns.Contains("Lote") Then TmpDT.Columns.Add("Lote", GetType(String)) If Not TmpDT.Columns.Contains("Lote") Then TmpDT.Columns.Add("Lote", GetType(String))
@@ -3081,19 +3081,15 @@ Partial Class Compras_Compras
If Not TmpDT.Columns.Contains("ImporteSinImpuestos") Then If Not TmpDT.Columns.Contains("ImporteSinImpuestos") Then
TmpDT.Columns.Add("ImporteSinImpuestos", GetType(Decimal)) TmpDT.Columns.Add("ImporteSinImpuestos", GetType(Decimal))
End If End If
If Not TmpDT.Columns.Contains("AplicaLote") Then If Not TmpDT.Columns.Contains("AplicaSerie") Then TmpDT.Columns.Add("AplicaSerie", GetType(Boolean))
TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
End If
If Not TmpDT.Columns.Contains("AplicaCaducidad") Then
TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
End If
If Not TmpDT.Columns.Contains("Lote") Then If Not TmpDT.Columns.Contains("AplicaLote") Then TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
TmpDT.Columns.Add("Lote", GetType(String))
End If If Not TmpDT.Columns.Contains("AplicaCaducidad") Then TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
If Not TmpDT.Columns.Contains("FechaCaducidad") Then
TmpDT.Columns.Add("FechaCaducidad", GetType(Date)) If Not TmpDT.Columns.Contains("Lote") Then TmpDT.Columns.Add("Lote", GetType(String))
End If
If Not TmpDT.Columns.Contains("FechaCaducidad") Then TmpDT.Columns.Add("FechaCaducidad", GetType(Date))
GvPS.DataSource = TmpDT GvPS.DataSource = TmpDT
GvPS.DataBind() GvPS.DataBind()
@@ -4272,22 +4268,8 @@ Partial Class Compras_Compras
#End Region #End Region
#Region "Vinculacion De Servcios" #Region "Vinculacion De Servicios"
Private Function isAdminObraGluyas() As Boolean
Return (UsuarioActual.CveRol = 1047 And UsuarioActual.CveEmpresa = 66)
End Function
Private Sub cargaddlVinculacionServcios()
If isAdminObraGluyas() Then
TabVinculacionServicios.Visible = True
'Dim productos As New ClsProductosServicios
'If productos.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then
' PSDTRemplazo = productos.DtResultados.FiltraParametros("CveTipoPS=2", "PS")
'End If
'productos.Dispose()
GVVinculacionServicios.DataSource = TmpDT
GVVinculacionServicios.DataBind()
End If
End Sub
Protected Sub GVVinculacionServicios_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVVinculacionServicios.RowDataBound Protected Sub GVVinculacionServicios_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVVinculacionServicios.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowType = DataControlRowType.DataRow Then
Dim dt As DataTable = Nothing Dim dt As DataTable = Nothing
@@ -4447,7 +4429,7 @@ Partial Class Compras_Compras
Dim CapitalMiltiple As Decimal = GvRow.FCTextBox("TxtCapital").Text.ToDecimal Dim CapitalMiltiple As Decimal = GvRow.FCTextBox("TxtCapital").Text.ToDecimal
Dim InteresMiltiple As Decimal = GvRow.FCTextBox("TxtInteres").Text.ToDecimal Dim InteresMiltiple As Decimal = GvRow.FCTextBox("TxtInteres").Text.ToDecimal
Dim AmbosMiltiple As Decimal = GvRow.FCTextBox("TxtAmbos").Text.ToDecimal Dim AmbosMultiple As Decimal = GvRow.FCTextBox("TxtAmbos").Text.ToDecimal
Dim MensualidadMultiple As Decimal = GvRow.DataKey("Mensualidad").ToDecimal Dim MensualidadMultiple As Decimal = GvRow.DataKey("Mensualidad").ToDecimal
If CapitalMiltiple > 0 Or InteresMiltiple > 0 Then If CapitalMiltiple > 0 Or InteresMiltiple > 0 Then
@@ -4456,9 +4438,9 @@ Partial Class Compras_Compras
MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple
'CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero 'CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero
ElseIf AmbosMiltiple > 0 Then ElseIf AmbosMultiple > 0 Then
TotalCreditos = TotalCreditos + AmbosMiltiple TotalCreditos = TotalCreditos + AmbosMultiple
MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple
'CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero 'CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero
EstatusCredito = GvRow.DataKey("Estatus").ToEntero EstatusCredito = GvRow.DataKey("Estatus").ToEntero
@@ -5623,6 +5605,8 @@ Partial Class Compras_Compras
' If DdlMoneda.SelectedValue.ToEntero = 1 Or (DdlMoneda.SelectedValue.ToEntero > 1 AndAlso GlobalTipoCambio(TxtFecha.Text.ToDate) > 0) Then ' If DdlMoneda.SelectedValue.ToEntero = 1 Or (DdlMoneda.SelectedValue.ToEntero > 1 AndAlso GlobalTipoCambio(TxtFecha.Text.ToDate) > 0) Then
''ALMACEN CONSIGNACION ''ALMACEN CONSIGNACION
If DdlTipoComprobante.SelectedValue = "Fac" Then
If CveConsignacion > 0 AndAlso CveCompraRefacturacion <= 0 Then If CveConsignacion > 0 AndAlso CveCompraRefacturacion <= 0 Then
'actualizamos cvecompraconsignacion 'actualizamos cvecompraconsignacion
@@ -5893,6 +5877,7 @@ Partial Class Compras_Compras
End If End If
End If End If
End If
'*************************************************** P R I M E R A P A R T E C O M P R A S ************************************************************************************************************************************************************************************************************************************************************************************************** '*************************************************** P R I M E R A P A R T E C O M P R A S **************************************************************************************************************************************************************************************************************************************************************************************************
'P R E P O L I Z A S 'P R E P O L I Z A S
@@ -6816,7 +6801,7 @@ Partial Class Compras_Compras
Dim RegistroCuentaPuente As Boolean = False Dim RegistroCuentaPuente As Boolean = False
'NC CON PRODUCTOS - CUENTA PUENTE 'NC CON PRODUCTOS - CUENTA PUENTE
If DdlTipoComprobante.SelectedValue = "NC" And DdlTipoCompra.SelectedValue.Contiene("9", "12") Then If DdlTipoComprobante.SelectedValue = "NC" AndAlso DdlTipoCompra.SelectedValue.Contiene("9", "12") Then
RegistraConcepto225 = True RegistraConcepto225 = True
End If End If
@@ -6835,15 +6820,14 @@ Partial Class Compras_Compras
If Devolucion IsNot Nothing AndAlso Devolucion.DebeRealizarDevolucion AndAlso Devolucion.CveMovimiento > 0 Then If Devolucion IsNot Nothing AndAlso Devolucion.DebeRealizarDevolucion AndAlso Devolucion.CveMovimiento > 0 Then
ConceptoContabilizacionNC = 68 ConceptoContabilizacionNC = 68
CveMovimientoDevolucion = Devolucion.CveMovimiento CveMovimientoDevolucion = Devolucion.CveMovimiento
importeMovimiento = TmpDT.SUM("Total")
importeMN = importeMovimiento * tipoCambioActual * Multiplicador
End If End If
'cuando es garantía. 'cuando es garantía.
If DdlTipoCompra.SelectedValue.Contiene("12", "14") Then If DdlTipoCompra.SelectedValue.Contiene("12", "14") Then ConceptoContabilizacionNC = 259
ConceptoContabilizacionNC = 259
End If
Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
If importeMovimiento > 0 Or TxtTotal.Text.ToDecimal = 0 Then If importeMovimiento > 0 Or TxtTotal.Text.ToDecimal = 0 Then
RegistroCuentaPuente = True RegistroCuentaPuente = True
Dim ImporteTransito As Decimal = 0 Dim ImporteTransito As Decimal = 0
@@ -6861,8 +6845,6 @@ Partial Class Compras_Compras
End If End If
End If End If
Next Next
Dim importeMNTemp As Decimal = 0 Dim importeMNTemp As Decimal = 0
Dim CveCompraAmortizacion As Integer = -1 Dim CveCompraAmortizacion As Integer = -1
@@ -6881,19 +6863,15 @@ Partial Class Compras_Compras
ImporteTransito += importeMNTemp ImporteTransito += importeMNTemp
CveCompraAmortizacion = Gvr.DataKey("CveCompra").ToEntero CveCompraAmortizacion = Gvr.DataKey("CveCompra").ToEntero
'se registra por cada compra relacionada 'se registra por cada compra relacionada
End If End If
Next Next
If importeMNTemp > 0 Then If importeMNTemp > 0 Then
'importeMNTemp = importeMNTemp - TxtDescuento.Text.ToDecimal
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMNTemp, importeMNTemp, ConceptoContabilizacionNC, Referencia, Concepto, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraAmortizacion, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, Contabilizable:=SeContabiliza) Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMNTemp, importeMNTemp, ConceptoContabilizacionNC, Referencia, Concepto, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraAmortizacion, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True ErrorPrepoliza = True
End If End If
End If End If
'si se marca que no se va a recibir, falta validación 'si se marca que no se va a recibir, falta validación
If Not ErrorMovInv AndAlso Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 1, UsuarioActual.CveUsuario) Then If Not ErrorMovInv AndAlso Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 1, UsuarioActual.CveUsuario) Then
ErrorMovInv = True ErrorMovInv = True
@@ -6914,8 +6892,6 @@ Partial Class Compras_Compras
End If End If
End If End If
Else Else
Dim DiferenciaDevolucion As Decimal = If(DdlMoneda.SelectedValue.ToEntero <> 1, (importeMovimiento * TxtTC.Text.ToDecimal), importeMovimiento) - TotalRealDevolucion Dim DiferenciaDevolucion As Decimal = If(DdlMoneda.SelectedValue.ToEntero <> 1, (importeMovimiento * TxtTC.Text.ToDecimal), importeMovimiento) - TotalRealDevolucion
If TotalRealDevolucion <> 0 Then If TotalRealDevolucion <> 0 Then
@@ -10896,12 +10872,13 @@ Partial Class Compras_Compras
TmpDT.Columns.Add("CveCultivoCuadroDetalle", GetType(Integer)) TmpDT.Columns.Add("CveCultivoCuadroDetalle", GetType(Integer))
TmpDT.Columns.Add("TemporadaCuadro", GetType(String)) TmpDT.Columns.Add("TemporadaCuadro", GetType(String))
TmpDT.Columns.Add("AplicaSerie", GetType(Boolean))
TmpDT.Columns.Add("AplicaLote", GetType(Boolean)) TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean)) TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
TmpDT.Columns.Add("Serie", GetType(String))
TmpDT.Columns.Add("Lote", GetType(String)) TmpDT.Columns.Add("Lote", GetType(String))
TmpDT.Columns.Add("FechaCaducidad", GetType(Date)) TmpDT.Columns.Add("FechaCaducidad", GetType(Date))
TmpDTOriginal = New DataTable TmpDTOriginal = New DataTable
TmpDTOriginal.Columns.Add("Consec", GetType(Integer)) TmpDTOriginal.Columns.Add("Consec", GetType(Integer))
TmpDTOriginal.Columns.Add("Cantidad", GetType(Decimal)) TmpDTOriginal.Columns.Add("Cantidad", GetType(Decimal))
@@ -11011,8 +10988,10 @@ Partial Class Compras_Compras
TmpDTOriginal.Columns.Add("CveCultivoCuadroDetalle", GetType(Double)) TmpDTOriginal.Columns.Add("CveCultivoCuadroDetalle", GetType(Double))
TmpDTOriginal.Columns.Add("TemporadaCuadro", GetType(String)) TmpDTOriginal.Columns.Add("TemporadaCuadro", GetType(String))
TmpDTOriginal.Columns.Add("AplicaSerie", GetType(Boolean))
TmpDTOriginal.Columns.Add("AplicaLote", GetType(Boolean)) TmpDTOriginal.Columns.Add("AplicaLote", GetType(Boolean))
TmpDTOriginal.Columns.Add("AplicaCaducidad", GetType(Boolean)) TmpDTOriginal.Columns.Add("AplicaCaducidad", GetType(Boolean))
TmpDTOriginal.Columns.Add("Serie", GetType(String))
TmpDTOriginal.Columns.Add("Lote", GetType(String)) TmpDTOriginal.Columns.Add("Lote", GetType(String))
TmpDTOriginal.Columns.Add("FechaCaducidad", GetType(Date)) TmpDTOriginal.Columns.Add("FechaCaducidad", GetType(Date))
@@ -12164,8 +12143,6 @@ Partial Class Compras_Compras
#Region " AJUSTA IMPORTES " #Region " AJUSTA IMPORTES "
Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False) Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False)
If ImporteAjuste = 0 Then Exit Sub If ImporteAjuste = 0 Then Exit Sub
Dim Amortizacion As Decimal = 0 Dim Amortizacion As Decimal = 0
@@ -13849,8 +13826,14 @@ Partial Class Compras_Compras
'si no esta vinculado a nc simplemente me lo brinco 'si no esta vinculado a nc simplemente me lo brinco
If realizadevolucion Then If realizadevolucion Then
'si el subtotal es iwal a la nc lo guardo si no marco error 'si el subtotal es igual a la nc lo guardo si no marco error
If subtotal > subtotaldevolucion - 1 AndAlso subtotal < subtotaldevolucion + 1 Then Dim tTolerancia As Decimal = 0
Dim tAjustaUltimo As Boolean = True
If UsuarioActual.Empresa.Funcionalidad(574) = "1" Then
tTolerancia = Math.Abs(TxtSubTotal2.Text.ToDecimal - subtotaldevolucion)
tAjustaUltimo = False
End If
If Math.Abs(subtotal - subtotaldevolucion) <= tTolerancia Then
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 13, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G1") CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 13, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G1")
If CveMovimientoEntrada <= 0 Then If CveMovimientoEntrada <= 0 Then
@@ -13867,17 +13850,17 @@ Partial Class Compras_Compras
PU = Dr.DataKey("PU").ToString.ToDecimal PU = Dr.DataKey("PU").ToString.ToDecimal
PUExtranjero = Dr.DataKey("PUExtranjero").ToString.ToDecimal PUExtranjero = Dr.DataKey("PUExtranjero").ToString.ToDecimal
ii += 1 ii += 1
If CantidadRenglones = ii Then If CantidadRenglones = ii AndAlso tAjustaUltimo Then
Dim dif As Decimal = subtotal - Acumulado Dim dif As Decimal = subtotal - Acumulado
PU = (((Dr.FCTextBox("TxtCantidad").Text.ToDecimal * Dr.DataKey("PU").ToString.ToDecimal)) + dif) / Dr.FCTextBox("TxtCantidad").Text.ToDecimal PU = (((Dr.FCTextBox("TxtCantidad").Text.ToDecimal * Dr.DataKey("PU").ToDecimal)) + dif) / Dr.FCTextBox("TxtCantidad").Text.ToDecimal
End If End If
If ObjInventario.GetExistenciasProducto(Dr.DataKey("CvePS").ToString.ToEntero, Dr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, CveAlmacen, Dim tFechaExistencia As DateTime = TxtFecha.Text.ToDateTime.AddHours(NowADS().Hour).AddMinutes(NowADS().Minute).AddSeconds(NowADS().Second)
FechaMovto:=TxtFecha.Text.ToDateTime.AddHours(NowADS().Hour).AddMinutes(NowADS().Minute).AddSeconds(NowADS().Second).ToString("yyyy/MM/dd HH:mm")) Then If ObjInventario.GetExistenciasProducto(Dr.DataKey("CvePS").ToEntero, Dr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, CveAlmacen,
FechaMovto:=tFechaExistencia.ToString("yyyy/MM/dd HH:mm")) Then
Dim Existencia As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", CveAlmacen)).ToDecimal Dim Existencia As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", CveAlmacen)).ToDecimal
If Dr.FCTextBox("TxtCantidad").Text.ToDouble > Existencia Then If Dr.FCTextBox("TxtCantidad").Text.ToDouble > Existencia Then
Alert($"No hay existencia suficiente del producto {Dr.DataKey("PS").ToString} en la fecha:{TxtFecha.Text}", TipoMensaje.MsgAdvertencia) Alert($"No hay existencia suficiente del producto: <br/> - {Dr.DataKey("CodigoPS")} en la fecha: {tFechaExistencia.ToString("yyyy/MM/dd HH:mm")}", TipoMensaje.MsgAdvertencia)
ErrorMovInv = True ErrorMovInv = True
Exit For Exit For
End If End If
@@ -13966,8 +13949,6 @@ Partial Class Compras_Compras
Try Try
Dim subtotaldevolucion As Decimal = 0 Dim subtotaldevolucion As Decimal = 0
Dim realizadevolucion As Boolean = False Dim realizadevolucion As Boolean = False
'Calculo los subtotales para comparar con la NC 'Calculo los subtotales para comparar con la NC
Dim cantidad As Decimal = 0D Dim cantidad As Decimal = 0D
@@ -13982,11 +13963,13 @@ Partial Class Compras_Compras
'si no esta vinculado a nc simplemente me lo brinco 'si no esta vinculado a nc simplemente me lo brinco
If realizadevolucion Then If realizadevolucion Then
'si el subtotal es iwal a la nc lo guardo si no marco error 'si el subtotal es igual a la nc lo guardo si no marco error
If TxtSubTotal2.Text.ToDouble > subtotaldevolucion - 1 AndAlso TxtSubTotal2.Text.ToDouble < subtotaldevolucion + 1 Then 'si tiene FNC574, se ajustará la diferencia a un concepto como RNC
Dim tTolerancia As Decimal = 1
'si tiene la funcionalidad ajustará en un producto la diferencia
If UsuarioActual.Empresa.Funcionalidad(574) = "1" Then tTolerancia = Math.Abs(TxtSubTotal2.Text.ToDecimal - subtotaldevolucion)
If Math.Abs(TxtSubTotal2.Text.ToDecimal - subtotaldevolucion) <= tTolerancia Then
VinculaDevolucion() VinculaDevolucion()
Else Else
Alert("El Total de la NC debe ser igual al total de la devolucion", TipoMensaje.MsgAdvertencia) Alert("El Total de la NC debe ser igual al total de la devolucion", TipoMensaje.MsgAdvertencia)
End If End If
@@ -14011,48 +13994,42 @@ Partial Class Compras_Compras
Dim RetIVACompra As Decimal = TxtRetIVA.Text.ToDecimal() Dim RetIVACompra As Decimal = TxtRetIVA.Text.ToDecimal()
Dim RetISRCompra As Decimal = TxtRetISR.Text.ToDecimal() Dim RetISRCompra As Decimal = TxtRetISR.Text.ToDecimal()
Dim Acumulado As Decimal = 0 Dim Acumulado As Decimal = 0
'Dim TotalCalculable As Decimal = TotalCompra - IEPSCompra + RetIVACompra + RetISRCompra
Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2) Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2)
Dim Contador As Integer = 0 Dim Contador As Integer = 0
Dim Consec As Integer = 0 Dim Consec As Integer = 0
Dim tAjusteUltimo As Boolean = True
For Each gvr As GridViewRow In GVDevolucion.Rows For Each gvr As GridViewRow In GVDevolucion.Rows
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
Contador += 1 Contador += 1
End If End If
Next Next
Dim CveSubProyectoContrato As String = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenDevolucion.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto") Dim Total As Decimal = 0
Dim SubProyecto As String = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyectoContrato.ToEntero).FiltroPrimeroValor("SubProyecto") Dim CveSubProyectoDev As String = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenDevolucion.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto")
Dim SubProyecto As String = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyectoDev.ToEntero).FiltroPrimeroValor("SubProyecto")
'Iteramos el GridView de la OC 'Iteramos el GridView de la OC
If UsuarioActual.Empresa.Funcionalidad(574) = "1" Then tAjusteUltimo = False
For Each gvr As GridViewRow In GVDevolucion.Rows For Each gvr As GridViewRow In GVDevolucion.Rows
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero
'Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal
Dim CveUM As Integer = gvr.DataKey("CveUM").ToString.ToEntero Dim CveUM As Integer = gvr.DataKey("CveUM").ToString.ToEntero
Dim UM As String = gvr.DataKey("UM").ToString Dim UM As String = gvr.DataKey("UM").ToString
Dim CveClasificacion As Integer = gvr.DataKey("CveClasificacion").ToString.ToEntero Dim CveClasificacion As Integer = gvr.DataKey("CveClasificacion").ToString.ToEntero
Dim Clasificacion As String = gvr.DataKey("Clasificacion").ToString Dim Clasificacion As String = gvr.DataKey("Clasificacion").ToString
Dim PS As String = gvr.DataKey("PS").ToString Dim PS As String = gvr.DataKey("CodigoPS").ToString
Dim CveTipoPS As Integer = gvr.DataKey("CveTipoPS").ToString.ToEntero Dim CveTipoPS As Integer = gvr.DataKey("CveTipoPS").ToString.ToEntero
Dim CveProyecto As String = "-1" Dim CveProyecto As String = "-1"
Dim Proyecto As String = "Seleccione" Dim Proyecto As String = "Seleccione"
Dim Obs As String = "" Dim Obs As String = ""
Dim PU As Decimal = gvr.DataKey("PU").ToString.ToDecimal Dim PU As Decimal = gvr.DataKey("PU").ToString.ToDecimal
Dim Total As Decimal = gvr.FCTextBox("TxtTotalDevolucion").Text.ToDecimal Total = gvr.FCTextBox("TxtTotalDevolucion").Text.ToDecimal
Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2)
Dim Descuento As Decimal = 0 Dim Descuento As Decimal = 0
Acumulado += (PU * Cantidad) Acumulado += (PU * Cantidad)
Consec += 1 Consec += 1
If Consec = Contador Then 'SubTotalCompra < Acumulado Then If Consec = Contador AndAlso tAjusteUltimo Then 'SubTotalCompra < Acumulado Then
'ajusta el valor 'ajusta el valor
Dim dif As Decimal = SubTotalCompra - Acumulado Dim dif As Decimal = SubTotalCompra - Acumulado
If dif <> 0 Then If dif <> 0 Then
@@ -14060,10 +14037,25 @@ Partial Class Compras_Compras
Total = Cantidad * PU Total = Cantidad * PU
End If End If
End If End If
AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, -1, False) AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoDev, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVAPorcentajeCompra, 0, 0, 0, 0, Descuento, -1, False, CveAlmacen:=DdlAlmacenDevolucion.SelectedValue.ToEntero)
End If End If
Next Next
If UsuarioActual.Empresa.Funcionalidad(574) = "1" Then
Dim CvePS_RNC As Integer = UsuarioActual.Empresa.Funcionalidad(580).ToEntero
If CvePS_RNC = 0 Then
Alert("producto utilizado para diferencia no definido.")
Exit Sub
End If
Dim PSRow As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS_RNC).FiltroPrimero("")
Dim PS As String = PSRow("PSCodigo").ToString
Dim tDif As Decimal = TxtSubTotal2.Text.ToDecimal - Total
AddPS(1, PSRow("CveUnidadMedida").ToString.ToEntero, PSRow("UnidadMedida").ToString,
PSRow("CveClasificacion").ToString.ToEntero, PSRow("Clasificacion").ToString, CvePS_RNC, PS, 1, CveSubProyectoDev.ToString, SubProyecto, "", "-1", "", tDif, tDif, IVAPorcentajeCompra, 0, 0, 0, 0, 0)
End If
AddPS2() AddPS2()
BtnGuardar.Enabled = True BtnGuardar.Enabled = True
@@ -14079,7 +14071,7 @@ Partial Class Compras_Compras
ImgClasificacion.Visible = False ImgClasificacion.Visible = False
LbAgregar.Visible = False LbAgregar.Visible = False
UpPSS.Update()
'CargaGvInv() 'CargaGvInv()
@@ -14101,7 +14093,6 @@ Partial Class Compras_Compras
End If End If
GvOC1.DataBind() GvOC1.DataBind()
' TmpDT = OrdenarTablas("CvePS", DTOCTemp, TmpDT)
GvOC2.DataSource = TmpDT GvOC2.DataSource = TmpDT
GvOC2.DataBind() GvOC2.DataBind()
@@ -14455,19 +14446,13 @@ Partial Class Compras_Compras
End If End If
End If End If
If Not TmpDT.Columns.Contains("AplicaLote") Then If Not TmpDT.Columns.Contains("AplicaLote") Then TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
End If
If Not TmpDT.Columns.Contains("AplicaCaducidad") Then
TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
End If
If Not TmpDT.Columns.Contains("Lote") Then
TmpDT.Columns.Add("Lote", GetType(String))
End If
If Not TmpDT.Columns.Contains("FechaCaducidad") Then
TmpDT.Columns.Add("FechaCaducidad", GetType(Date))
End If
If Not TmpDT.Columns.Contains("AplicaCaducidad") Then TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
If Not TmpDT.Columns.Contains("Lote") Then TmpDT.Columns.Add("Lote", GetType(String))
If Not TmpDT.Columns.Contains("FechaCaducidad") Then TmpDT.Columns.Add("FechaCaducidad", GetType(Date))
If ObjInventario.GetInv_ComprasMov(CveCompra, UsuarioActual.CveEmpresa) Then If ObjInventario.GetInv_ComprasMov(CveCompra, UsuarioActual.CveEmpresa) Then
If ObjInventario.DtResultados.Rows.Count > 0 Then If ObjInventario.DtResultados.Rows.Count > 0 Then
@@ -18124,7 +18109,7 @@ Partial Class Compras_Compras
Case "A" 'ADD Case "A" 'ADD
Dim SATClavePS As Integer = -1 Dim SATClavePS As Integer = -1
Dim PSRow As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") Dim PSRow As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("")
If PSRow IsNot Nothing Then If PSRow IsNot Nothing Then
SATClavePS = PSRow("SATClavePS").ToString.ToEntero SATClavePS = PSRow("SATClavePS").ToString.ToEntero
End If End If
@@ -18213,13 +18198,10 @@ Partial Class Compras_Compras
Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Decimal = 0, Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Decimal = 0,
Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Decimal = 0, Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Decimal = 0,
Optional PorcentajeIEPS As Decimal = 0, Optional PorcentajeRetIVA As Decimal = 0, Optional PorcentajeRetISR As Decimal = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1, Optional CveCultivoCuadroDetalle As Integer = -1, Optional PorcentajeIEPS As Decimal = 0, Optional PorcentajeRetIVA As Decimal = 0, Optional PorcentajeRetISR As Decimal = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1, Optional CveCultivoCuadroDetalle As Integer = -1,
Optional CveSATPSActualizado As Boolean = False, Optional TemporadaCuadro As String = "", Optional CodigoPS As String = "") As Integer Optional CveSATPSActualizado As Boolean = False, Optional TemporadaCuadro As String = "", Optional CodigoPS As String = "", Optional CveAlmacen As Integer = -1) As Integer
Dim Row As DataRow = Nothing Dim Row As DataRow = Nothing
If Not TmpDT.Columns.Contains("CodigoPS") Then TmpDT.Columns.Add("CodigoPS")
If Not TmpDT.Columns.Contains("CodigoPS") Then
TmpDT.Columns.Add("CodigoPS")
End If
Row = TmpDT.NewRow() Row = TmpDT.NewRow()
Dim Retorno As Integer = 0 Dim Retorno As Integer = 0
@@ -18377,11 +18359,14 @@ Partial Class Compras_Compras
Row("CveTipoGasto") = CveTipoGasto Row("CveTipoGasto") = CveTipoGasto
Row("TipoGasto") = If(CveTipoGasto > 0, TipoGasto, "") Row("TipoGasto") = If(CveTipoGasto > 0, TipoGasto, "")
Row("CveContratoDetalle") = CveContratoDetalle Row("CveContratoDetalle") = CveContratoDetalle
Row("AplicaSerie") = DrPS("AplicaSerie")
Row("AplicaLote") = DrPS("AplicaLote")
Row("AplicaCaducidad") = DrPS("AplicaCaducidad")
Row("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle Row("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle
Row("TemporadaCuadro") = TemporadaCuadro Row("TemporadaCuadro") = TemporadaCuadro
If CveAlmacen > 0 Then Row("CveAlmacen") = CveAlmacen
If UsuarioActual.Empresa.UsaAC Then If UsuarioActual.Empresa.UsaAC Then
Row("CveProgramaOperativo") = DdlACGeneral1.SelectedValue.ToEntero Row("CveProgramaOperativo") = DdlACGeneral1.SelectedValue.ToEntero
@@ -18391,7 +18376,6 @@ Partial Class Compras_Compras
Row("CveClasificacionOG") = DdlACGeneral5.SelectedValue.ToEntero Row("CveClasificacionOG") = DdlACGeneral5.SelectedValue.ToEntero
End If End If
'Esta parte es para validar cuando la factura tenga ieps en o se asignara el ieps como una partida ya no se considere 'Esta parte es para validar cuando la factura tenga ieps en o se asignara el ieps como una partida ya no se considere
If (CveFactura > 0 Or CveCompra > 0) And TxtIEPS.Text.ToDecimal = 0 Then If (CveFactura > 0 Or CveCompra > 0) And TxtIEPS.Text.ToDecimal = 0 Then
Row("IEPSPS") = 0 Row("IEPSPS") = 0
@@ -23176,6 +23160,7 @@ Public Class ClsCompraManagerCompras
If Not TmpDT.Columns.Contains("AplicaLote") Then TmpDT.Columns.Add("AplicaLote", GetType(Boolean)) If Not TmpDT.Columns.Contains("AplicaLote") Then TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
If Not TmpDT.Columns.Contains("AplicaCaducidad") Then TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean)) If Not TmpDT.Columns.Contains("AplicaCaducidad") Then TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
If Not TmpDT.Columns.Contains("AplicaSerie") Then TmpDT.Columns.Add("AplicaSerie", GetType(Boolean))
If Not TmpDT.Columns.Contains("Lote") Then TmpDT.Columns.Add("Lote", GetType(String)) If Not TmpDT.Columns.Contains("Lote") Then TmpDT.Columns.Add("Lote", GetType(String))
@@ -23426,7 +23411,7 @@ Public Class ClsCompraManagerCompras
TmpDT.Columns.Add("TemporadaCuadro", GetType(String)) TmpDT.Columns.Add("TemporadaCuadro", GetType(String))
TmpDT.Columns.Add("NoIdentificacion", GetType(String)) TmpDT.Columns.Add("NoIdentificacion", GetType(String))
TmpDT.Columns.Add("AplicaSerie", GetType(Boolean))
TmpDT.Columns.Add("AplicaLote", GetType(Boolean)) TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean)) TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))