This commit is contained in:
2025-04-22 14:29:55 -07:00
7 changed files with 272 additions and 30 deletions

View File

@@ -372,7 +372,7 @@
<ContentTemplate>
<br />
<div style="height: 250px; overflow-x: scroll">
<asp:GridView ID="GvFacturas" runat="server" AutoGenerateColumns="False" DataKeyNames="CveVenta, CvePrePoliza, CveIE, TipoCambio, CveMoneda, CveCliente, Importe, SerieFolio,CveCuenta,CveSubProyecto" CssClass="table table-striped table-advance table-hover" Style="text-align: center; float: right; width: 100%;" GridLines="None">
<asp:GridView ID="GvFacturas" runat="server" AutoGenerateColumns="False" DataKeyNames="CveVenta, CvePrePoliza, CveIE, TipoCambio, CveMoneda, CveCliente, Importe, SerieFolio,CveCuenta,CveSubProyecto,SobranteFaltante" CssClass="table table-striped table-advance table-hover" Style="text-align: center; float: right; width: 100%;" GridLines="None">
<Columns>
<asp:TemplateField>
<HeaderTemplate>

View File

@@ -324,8 +324,17 @@ Partial Class Bancos_DepositosCaja
End If
End If
NuevaCvePrePoliza = ObjConta.AddPrePolizas("DepCaja", 13, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, $"Depósito Bancario - {DdlTipoDeposito.SelectedItem.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=1)
Dim ImporteSobFaltante As Decimal = 0
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
For Each Gvr As GridViewRow In GvFacturas.Rows
If Gvr.FCCheckBox("ChkFactura").Checked Then
ImporteSobFaltante += Gvr.DataKey("SobranteFaltante").ToDecimal()
End If
Next
End If
NuevaCvePrePoliza = ObjConta.AddPrePolizas("DepCaja", 13, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, $"Depósito Bancario - {DdlTipoDeposito.SelectedItem.Text} {If(ImporteSobFaltante <> 0, $"- Sobrante/faltante: ${ImporteSobFaltante:N2}", "")}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=1)
Dim CveTransaccionBanco As Integer = DdlTipoDeposito.SelectedValue.ToEntero

View File

@@ -776,6 +776,16 @@
</div>
</div>
<div class="row mt-4">
<div class="col-md-12 d-flex justify-content-end">
<asp:Button ID="BtnCancelarOP" runat="server" Text="Cancelar OP"
CssClass="btn btn-danger" Visible="false"
OnClick="BtnCancelarOP_Click" />
</div>
</div>
<div id="DVModalFinalizarOP" class="modal ADS fade" role="dialog" data-backdrop="static">
<div class="modal-dialog" style="width: 750px;">
<asp:UpdatePanel runat="server" class="modal-content" ID="UpModalFinalizar" UpdateMode="Conditional">
@@ -877,6 +887,73 @@
<!-- Modal de Cancelación -->
<div id="DVModalCancelarOP" class="modal ADS fade" role="dialog" data-backdrop="static">
<div class="modal-dialog" style="width: 750px;">
<asp:UpdatePanel runat="server" class="modal-content" ID="UpModalCancelar" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Cancelar Orden de Producción #<%= LblFolio.Text %></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-4 form-group">
<label>Almacén Salida MP:</label>
<asp:DropDownList ID="DdlAlmacenSalidaMP" runat="server"
DataTextField="Almacen" DataValueField="CveAlmacen"
CssClass="form-control select2me" />
</div>
<div class="col-md-4 form-group">
<label>Almacén Devoluciones:</label>
<asp:DropDownList ID="DdlAlmacenDevolucionCancel" runat="server"
DataTextField="Almacen" DataValueField="CveAlmacen"
CssClass="form-control select2me" />
</div>
<div class="col-md-4 form-group">
<label>Almacén Mermas:</label>
<asp:DropDownList ID="DdlAlmacenMermas" runat="server"
DataTextField="Almacen" DataValueField="CveAlmacen"
CssClass="form-control select2me" />
</div>
</div>
<div class="section-title">Materia Prima</div>
<asp:GridView ID="GvMPCancelacion" runat="server" AutoGenerateColumns="False"
CssClass="table table-striped table-hover" GridLines="None" Width="100%"
DataKeyNames="CvePSMateriaPrima,CveUMMateriaPrima">
<Columns>
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
<asp:BoundField DataField="UnidadMedida" HeaderText="UM" />
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
<asp:TemplateField HeaderText="Merma">
<ItemTemplate>
<asp:TextBox ID="TxtMerma" runat="server" Text="0"
CssClass="form-control" TextMode="Number" step="0.01" min="0" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Devolución">
<ItemTemplate>
<asp:TextBox ID="TxtDevolucionCancel" runat="server" Text="0"
CssClass="form-control" TextMode="Number" step="0.01" min="0" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div class="modal-footer">
<asp:Button ID="BtnAceptarCancelacion" runat="server"
Text="Aceptar Cancelación" CssClass="btn btn-primary"
OnClick="BtnAceptarCancelacion_Click" />
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</asp:Content>
@@ -892,7 +969,7 @@
}
}
</script>
</asp:Content>

View File

@@ -107,6 +107,8 @@ Partial Class OP_OP
CreaPS()
SetValues()
End If
BtnCancelarOP.Visible = (CveOP > 0 AndAlso TipoEstatus <> 3 AndAlso TipoEstatus <> 4)
End Sub
Private Sub CreaPS()
@@ -900,6 +902,133 @@ Partial Class OP_OP
End If
End Sub
#Region "Cancelar"
Protected Sub BtnCancelarOP_Click(sender As Object, e As EventArgs)
' Cargar almacenes
DdlAlmacenSalidaMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1")
DdlAlmacenSalidaMP.DataBind()
DdlAlmacenDevolucionCancel.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1")
DdlAlmacenDevolucionCancel.DataBind()
DdlAlmacenMermas.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1")
DdlAlmacenMermas.DataBind()
' Cargar MP
GvMPCancelacion.DataSource = DtMP.FiltraParametros("Tipo = 'MP'")
GvMPCancelacion.DataBind()
RegistraScript("$('#DVModalCancelarOP').modal('show');")
UpModalCancelar.Update()
End Sub
Protected Sub BtnAceptarCancelacion_Click(sender As Object, e As EventArgs)
Dim ObjInventario As New ClsInventarios()
Dim TieneError As Boolean = False
Dim MensajeError As String = ""
ObjInventario.IniciaTransacSQL()
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
Dim ObjOP As New ClsOP(ObjInventario.IniciaTransacSQL())
Try
' Validaciones
If DdlAlmacenSalidaMP.SelectedValue = "-1" OrElse
DdlAlmacenDevolucionCancel.SelectedValue = "-1" Then
Throw New Exception("Seleccione todos los almacenes requeridos")
End If
' 1. Movimiento de Salida MP
Dim CveMovSalida As Integer = ObjInventario.AddMovimiento(
DdlAlmacenSalidaMP.SelectedValue.ToEntero(), 26, 1, NowADS, -1,
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
Observaciones:="Cancelación OP #" & LblFolio.Text)
' 2. Movimiento de Entrada Devoluciones
Dim CveMovEntradaDev As Integer = ObjInventario.AddMovimiento(
DdlAlmacenDevolucionCancel.SelectedValue.ToEntero(), 27, 1, NowADS, -1,
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
' 3. Procesar cada material
For Each row As GridViewRow In GvMPCancelacion.Rows
Dim Cantidad As Decimal = CDec(row.Cells(2).Text)
Dim Merma As Decimal = row.FCTextBox("TxtMerma").Text.ToDecimal()
Dim Devolucion As Decimal = row.FCTextBox("TxtDevolucionCancel").Text.ToDecimal()
If (Merma + Devolucion) > Cantidad Then
Throw New Exception("La suma de merma y devolución no puede exceder la cantidad")
End If
Dim CvePS As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(0)
Dim CveUM As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(1)
' Registrar salida
ObjInventario.AddMovimientoDetalle(CveMovSalida, Cantidad, CveUM, CvePS, 0)
' Registrar devolución
If Devolucion > 0 Then
ObjInventario.AddMovimientoDetalle(CveMovEntradaDev, Devolucion, CveUM, CvePS, 0)
End If
Next
' 4. Registrar mermas si existen
Dim TotalMermas As Decimal = 0
If DdlAlmacenMermas.SelectedValue <> "-1" Then
Dim CveMovMerma As Integer = ObjInventario.AddMovimiento(
DdlAlmacenMermas.SelectedValue.ToEntero(), 26, 1, NowADS, -1,
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
For Each row As GridViewRow In GvMPCancelacion.Rows
Dim Merma As Decimal = row.FCTextBox("TxtMerma").Text.ToDecimal()
If Merma > 0 Then
Dim CvePS As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(0)
Dim CveUM As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(1)
ObjInventario.AddMovimientoDetalle(CveMovMerma, Merma, CveUM, CvePS, 0)
TotalMermas += Merma
End If
Next
End If
' 5. Generar pólizas contables
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("OP/Cancelacion", 53, 0, 0, 1, NowADS,
"Cancelación OP #" & LblFolio.Text,
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
' Salida MP (Abono 68)
ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMP, TotalMP, 68, "Salida MP Cancelación")
' Entrada Devoluciones (Cargo 68)
ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalDevoluciones, TotalDevoluciones, 68, "Devoluciones Cancelación")
If TotalMermas > 0 Then
' Salida Mermas (Abono 68)
ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMermas, TotalMermas, 68, "Mermas Cancelación")
' Cargo Mermas (95)
ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalMermas, TotalMermas, 95, "Ajuste por Mermas")
End If
' 6. Actualizar estatus OP
If ObjOP.UpdateEstatusOP(CveOP, 4, UsuarioActual.CveEmpresa) Then
ObjInventario.Commit()
TxtEstatus.Text = "Cancelado"
BtnCancelarOP.Visible = False
UpOP.Update()
RegistraScript("$('#DVModalCancelarOP').modal('hide');")
Alert("OP cancelada correctamente", TipoMensaje.MsgInformacion)
Else
Throw New Exception("Error al actualizar el estatus de la OP")
End If
Catch ex As Exception
ObjInventario.RollBack()
Alert($"Error: {ex.Message}", TipoMensaje.MsgError)
Finally
ObjInventario.Dispose()
ObjConta.Dispose()
End Try
End Sub
#End Region
#Region "Finalizar"

View File

@@ -2606,18 +2606,7 @@ Partial Class Clientes
If DdlTipoCliente.SelectedValue = "1" Then
If TxtContacto.Text.Trim() = "" Then InformacionCompleta = False
If TxtRepresentanteLegal.Text.Trim() = "" Then InformacionCompleta = False
'si es el concepto de pagaré
Dim tPagare As Integer = 0
For Each dRow As GridViewRow In GvDocumentosCliente.Rows
Dim CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToEntero()
If CveDocumentacion = 265 Then tPagare = 1
Next
If tPagare = 0 Then InformacionCompleta = False
tPagare = 0 'valida que cuando menos tenga una cuenta
For Each dRow As GridViewRow In GvBancosCuentas.Rows
tPagare = 1
Next
If tPagare = 0 Then InformacionCompleta = False
End If
End If

View File

@@ -1250,7 +1250,7 @@
<asp:GridView ID="GVAnticipos" runat="server" AutoGenerateColumns="False" ClientIDMode="Static" EmptyDataText="No se encontraron Anticipos del Cliente"
ToolTip="Listado de Anticipos" CssClass="GVAnticipos table table-striped table-hover Widthall mysmallbtn" data-height="300" GridLines="None"
DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos">
DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos,CveFormaPago">
<Columns>
<asp:TemplateField>
<ItemTemplate>
@@ -1539,8 +1539,6 @@
}
$("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
// $get('HdnVentaSaldo').value = Total - FnSumaValoresAnt();
}
function FnSumaValoresAnt() {
@@ -1589,7 +1587,12 @@
$get("TxtCambio").value = FormatoNumero(cambio);
} else {
$get("TxtFaltante").value = FormatoNumero(cambio);
if (cambio == 'NaN') {
$get("TxtFaltante").value = "0.00";
} else {
$get("TxtFaltante").value = FormatoNumero(cambio);
}
$get("ChkSobFaltante").checked = true;
$get("TxtCambio").value = "";
}
@@ -1618,8 +1621,15 @@
}
function ValidaSobranteFaltante() {
if (ToDouble($get("TxtFaltante").value) > 1) {
alert("El sobrante/faltante no debe ser mayor a 1");
let sobFaltantePermitido = 1;
if (<%= If(UsuarioActual.Empresa.CveEmpresa = 189, 1, 0)%> == 1) {
sobFaltantePermitido = 10;
}
if (ToDouble($get("TxtFaltante").value) > sobFaltantePermitido) {
alert("El sobrante/faltante no debe ser mayor a " + sobFaltantePermitido);
$get("TxtFaltante").value = "";
$get("ChkSobFaltante").checked = false;
} else {
@@ -1630,11 +1640,20 @@
function CargaSobranteFaltante() {
$('#ChkSobFaltante').change(function () {
if (this.checked == true) {
if (ToDouble($get("TxtCambio").value) > 1) {
alert("El sobrante/faltante no debe ser mayor a 1")
let sobFaltantePermitido = 1;
if (<%= If(UsuarioActual.Empresa.CveEmpresa = 189, 1, 0)%> == 1) {
sobFaltantePermitido = 10;
}
if (ToDouble($get("TxtCambio").value) > sobFaltantePermitido) {
alert("El sobrante/faltante no debe ser mayor a " + sobFaltantePermitido)
$get("ChkSobFaltante").checked = false;
} else {
$get("TxtFaltante").value = $get("TxtCambio").value;
if ($get("TxtCambio").value == 'NaN') {
$get("TxtFaltante").value = "0.00";
} else {
$get("TxtFaltante").value = $get("TxtCambio").value;
}
}
}

View File

@@ -593,13 +593,19 @@ Partial Class Ventas_PVCobranza
Faltante = Math.Abs(TxtFaltante.Text.ToDecimal())
End If
If Faltante > 1 Then
Alert("El faltante no puede ser mayor a 1.00", TipoMensaje.MsgAdvertencia)
Dim sobFaltantePermitido = 1
If UsuarioActual.CveEmpresa = 189 Then
sobFaltantePermitido = 10
End If
If Faltante > sobFaltantePermitido Then
Alert($"El faltante no puede ser mayor a {sobFaltantePermitido}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If Sobrante > 1 Then
Alert("El sobrante no puede ser mayor a 1.00", TipoMensaje.MsgAdvertencia)
If Sobrante > sobFaltantePermitido Then
Alert($"El sobrante no puede ser mayor a {sobFaltantePermitido}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
@@ -956,7 +962,7 @@ Partial Class Ventas_PVCobranza
GuardaLog(ex.ToString())
End Try
If MsgError = "" AndAlso Not ChkSobFaltante.Checked Then
If MsgError = "" Then
If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=5, CveVenta:=CveVenta) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
GuardaLogAD($"Ventas/Ventas-NCGeneradas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
@@ -1310,6 +1316,7 @@ Partial Class Ventas_PVCobranza
Dim DtPagos As DataTable = New DataTable("DtPagosFactura")
DtPagos.Columns.Add(New DataColumn("CveFormaPago", GetType(Integer)))
DtPagos.Columns.Add(New DataColumn("Importe", GetType(Decimal)))
Dim PagadoSinEfectivo As Decimal = 0
If VentaConta Then
If TxtImporteCredito.Text.ToDecimal > 0 Then DtPagos.Rows.Add({4, TxtImporteCredito.Text.ToDecimal}) : PagadoSinEfectivo += TxtImporteCredito.Text.ToDecimal
@@ -1320,7 +1327,19 @@ Partial Class Ventas_PVCobranza
If TxtImporteTransferencia.Text.ToDecimal > 0 Then DtPagos.Rows.Add({3, TxtImporteTransferencia.Text.ToDecimal}) : PagadoSinEfectivo += TxtImporteTransferencia.Text.ToDecimal
If TxtNCDev.Text.ToDecimal > 0 Then DtPagos.Rows.Add({21, TxtNCDev.Text.ToDecimal}) : PagadoSinEfectivo += TxtNCDev.Text.ToDecimal
'If TxtNCDev.Text.ToDecimal > 0 Then DtPagos.Rows.Add({21, TxtNCDev.Text.ToDecimal}) : PagadoSinEfectivo += TxtNCDev.Text.ToDecimal
If TxtNCDev.Text.ToDecimal > 0 Then
For Each GvRow As GridViewRow In GVAnticipos.Rows
If GvRow.DataKey("Tipo").Contiene("NC", "IxC", "Ant") AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then
Dim CveFormaPagoAnt = GvRow.DataKey("CveFormaPago").ToEntero()
Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal()
DtPagos.Rows.Add({CveFormaPagoAnt, Importe})
End If
Next
End If
If TxtImporteOtrosContado.Text.ToDecimal() > 0 Then
PagadoSinEfectivo += TxtImporteOtrosContado.Text.ToDecimal