BDH: Revision de servicio a domicilio

This commit is contained in:
2021-03-16 11:15:53 -07:00
parent 0c030a16f7
commit 73d59cf01b
6 changed files with 196 additions and 25 deletions

View File

@@ -2203,8 +2203,8 @@ Namespace Modelos
CveCuentaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveCuentaIVATrasladado").ToString.ToEntero
End If
Dim UsaComplementariaClientes As Boolean = False
If UsuarioActual.CveEmpresa.Contiene(1, 119) Then UsaComplementariaClientes = True
Dim UsaComplementariaClientes As Boolean = True
'If UsuarioActual.CveEmpresa.Contiene(1, 119) Then UsaComplementariaClientes = True
If ObjConta.GetPlantillaConceptos(ObjFactura.CveEmpresa, CvePlantilaPoliza) Then
Dim dtt As DataTable = ObjConta.DtResultados
@@ -3798,6 +3798,18 @@ Namespace Modelos
End If
End If
If factura.TipoDocto = "Rem" AndAlso factura.ServicioDomicilio Then
Dim CveMovimientoSalida As Integer = GenerarMovimientoAlmacenServicioDomicilio(ObjInventario, factura, DtInventario, factura.CveAlmacenServicioDomicilio, 8, factura.CveMoneda, factura.CveVenta, "Modelos/SD1")
If CveMovimientoSalida > 0 Then
If Not (GenerarMovimientoAlmacenServicioDomicilio(ObjInventario, factura, DtInventario, factura.CveAlmacenTraspasoDestino, 9, factura.CveMoneda, factura.CveVenta, "Modelos/SD1", CveMovimientoRelacionado:=CveMovimientoSalida) > 0) Then
OcurrioError = True
End If
Else
OcurrioError = True
End If
End If
End If
Return OcurrioError
@@ -4059,6 +4071,129 @@ Namespace Modelos
'Return Not OcurrioError
End Function
Private Function GenerarMovimientoAlmacenServicioDomicilio(ByRef ObjInventario As ClsInventarios, factura As Modelos.Factura, DtInventario As DataTable, CveAlmacen As Integer, CveConcepto As Integer, CveMoneda As Integer, CveVenta As Integer, Modulo As String, Optional MovimientoPrePoliza As Boolean = False, Optional ByRef ObjConta As ClsContabilidad = Nothing, Optional CveMovimientoRelacionado As Integer = -1) As Integer
Dim OcurrioError As Boolean = False
Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, CveConcepto, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:=Modulo, CveMovimientoRelacionado:=CveMovimientoRelacionado)
If CveMovimientoInventario <= 0 Then
OcurrioError = True
ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
Else
Dim Mensaje As String = ""
Dim i As Integer = 0
Dim Cantidad As Double
Dim CveUnidad As Integer
Dim CveProducto As Integer
Dim Existencia As Double
'Dim Pu As Double
'DtInv.Clone()
Dim DtEquivalencias As DataTable
For Each Dr As DataRow In DtInventario.Rows
CveProducto = Dr("CvePS").ToString.ToEntero
CveUnidad = Dr("CveUM").ToString.ToEntero
Cantidad = Dr("Cantidad").ToString.ToDouble
If Dr("CveTipoInvPS").ToString.ToEntero = 5 And Dr("Serie").ToString = "" Then
OcurrioError = True
ErrorList.Add("Se deben especificar las Series de los productos de almacén")
Exit For
End If
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso factura.TipoDocto.Contiene("Rem", "Ing") Then
Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=factura.CveSubProyecto, CveVendedor:=factura.CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1)
If Existencia < Cantidad Then
OcurrioError = True
ErrorList.Add($"No cuenta con la cantidad suficiente en inventario del producto {Dr("CodigoPS")} .Cuenta con {Existencia.FormatoNumero(2)}.")
Exit For
End If
End If
If UsuarioActual.CveEmpresa = 1 Then
DtEquivalencias = New DataTable
DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1, UsuarioActual.CveEmpresa)
Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero
Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'")
'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE)
If CveUnidadBase <> CveUnidad Then
' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA
Cantidad = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble
CveUnidad = CveUnidadBase
End If
End If
If CveProducto > 0 Then
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, 0, CveSeccionAlmacen:=-3, Serie:=Dr("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
OcurrioError = True
ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.<br />")
Exit For
End If
Else
OcurrioError = True
ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.<br />")
Exit For
End If
i = i + 1
Next
'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN
If MovimientoPrePoliza AndAlso Not OcurrioError Then
Dim DtCostos As DataTable = Nothing
Dim ValorInventario As Decimal = 0
Dim TotalCosto As Decimal = 0
If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) Then
DtCostos = ObjInventario.DtResultados
TotalCosto = DtCostos.SUMD("Total").RoundSQL()
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
Dim IdCtaContable As Integer = 0
Dim CveCuenta As Integer = 0
If tmpCostos.Rows.Count > 0 Then
Dim TotalCostoAcumulado As Decimal = 0
Dim cont As Integer = 1
'Se agrega movimiento separado por la cuenta de ventas (ER)
For Each RowInv As DataRow In tmpCostos.Rows
ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL()
TotalCostoAcumulado += ValorInventario
'cuando es el último movimiento y hay diferencias en los importes
If cont = DtCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then
ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado)
End If
'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString)
IdCtaContable = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
CveCuenta = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
If ValorInventario <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then
OcurrioError = True
End If
End If
cont += 1
Next
End If
IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero
If TotalCosto <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then
OcurrioError = True
End If
End If
factura.Inv_CveMovimiento = CveMovimientoInventario
factura.Inv_ValorInventario = ValorInventario
End If
End If
End If
Return CveMovimientoInventario
End Function
Private Sub GuardarVentaEstimaciones(ByRef factura As Modelos.Factura, ObjContr As ClsContratos)
'debe de ser por contrato el movimiento
If factura.CveContratoSecciones.Length > 0 Then
@@ -5786,6 +5921,7 @@ Namespace Modelos
Public Property CvePedido2 As Integer = -1
Public Property CveAlmacenTraspasoOrigen As Integer = -1
Public Property CveAlmacenTraspasoDestino As Integer = -1
Public Property CveAlmacenServicioDomicilio As Integer = -1
Public Property EsDevolucionVenta As Integer = -1
Public Property EsInterno As Integer = -1
Public Property CveEmpresaCRM As Integer = -1

View File

@@ -326,6 +326,7 @@ Partial Class Inventarios_RecepcionUsados
End Sub
Private Sub CargaInicial()
ConsecutivoVenta = 0
CveMovimiento = -1
CveMovimientoRelacionado = -1
TieneRelacionado = -1
@@ -2255,7 +2256,7 @@ Partial Class Inventarios_RecepcionUsados
'VALIDA PROMOCIONES Y EXISTENCIAS
Dim ObjVentas As New ClsVentas
If ObjVentas.GetPromocionesPS(-1, Now, CveSubProyecto, Me.ObjRemisionNC.CveCliente, Me.ObjRemisionNC.CveVendedor, UsuarioActual.CveEmpresa) Then
If ObjVentas.GetPromocionesPS(-1, Now, CveSubProyecto, Me.ObjRemisionNC.CveCliente, Me.ObjRemisionNC.CveVendedor, 1, UsuarioActual.CveEmpresa) Then
Me.ObjRemisionNC.DtPromociones = ObjVentas.DtResultados.Copy()
End If
ObjVentas.Dispose()
@@ -2573,8 +2574,11 @@ Partial Class Inventarios_RecepcionUsados
Dim Obs As String = SbBCI.ToString()
AddPSRNC(ObjRemisionNC.DtDetalle, 1, CveUnidadMedida, "", CveClasificacion, "", CvePS, "", Obs, PU, 0, -1, "",
ObjRemisionNC.CveSubProyecto, ObjRemisionNC.SubProyecto.SubProyecto, PorcentajeIVA:=PorcentajeIVA)
If AddPSRNC(ObjRemisionNC.DtDetalle, 1, CveUnidadMedida, "", CveClasificacion, "", CvePS, "", Obs, PU, 0, -1, "",
ObjRemisionNC.CveSubProyecto, ObjRemisionNC.SubProyecto.SubProyecto, PorcentajeIVA:=PorcentajeIVA) Then
ConsecutivoVenta += 1
End If
Else
End If
@@ -2966,6 +2970,9 @@ Partial Class Inventarios_RecepcionUsados
Dim CargoActual As Double = 0
Dim Row As DataRow = Nothing
ConsecutivoVenta += 1
Row = TmpDTAjustes.NewRow
Row("CveFolioGarantia") = DdlFolioGarantia.SelectedValue.ToEntero
Row("CveTipoUso") = DdlTipoUso.SelectedValue.ToEntero
@@ -2981,7 +2988,7 @@ Partial Class Inventarios_RecepcionUsados
Row("TipoComprobante") = 1
Row("Comprobante") = TxtPoliza.Text
Row("Importe") = TxtImporteAjuste.Text.ToDouble
Row("ConsecutivoVenta") = TxtConsecutivoAjuste.Text.ToEntero()
Row("ConsecutivoVenta") = ConsecutivoVenta
Row("CvePS") = DdlPSAjuste.SelectedValue
Row("PS") = DdlPSAjuste.SelectedText
Row("CveVenta") = -1

View File

@@ -1938,8 +1938,9 @@
<asp:Panel ID="PanelBloqueo" runat="server" CssClass="modalPopup" align="center" Style="display: none">
<table border="0" width="250px" cellspacing="1" style="background-color: White; padding-left: 10px;">
<tr style="background-color: #3598dc; color: #FFFFFF; font-size: 14px; text-align:center">
<td colspan="2"><asp:Label runat="server" Text="<i class='fa fa-lock fa-2 icontxt'></i>&nbsp;Acceso Restringido"/></td>
<tr style="background-color: #3598dc; color: #FFFFFF; font-size: 14px; text-align: center">
<td colspan="2">
<asp:Label runat="server" Text="<i class='fa fa-lock fa-2 icontxt'></i>&nbsp;Acceso Restringido" /></td>
</tr>
<tr>
<td colspan="1">&nbsp;</td>
@@ -1950,7 +1951,7 @@
<asp:Label runat="server" Text="Código de Acceso:" Font-Bold="true" Width="120px" />
</td>
<td colspan="1">
<asp:TextBox ID="TxtCodigoAcceso" runat="server" type="password" ></asp:TextBox>
<asp:TextBox ID="TxtCodigoAcceso" runat="server" type="password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVCodigoAcceso" runat="server" ControlToValidate="TxtCodigoAcceso" Display="None" ErrorMessage="<span class='has-error'><span id='username-error' class='help-block'>El campo <b>''Código de Acceso''</b> es necesario.</span></span>" ValidationGroup="GrpValidarCodigo"></asp:RequiredFieldValidator>
</td>
</tr>
@@ -2896,17 +2897,17 @@
</div>
<br />
<div class="row">
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<div class="form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlMarcaPSAjuste" CssClass="form-control input-sm select2me" runat="server" DataTextField="Marca" DataValueField="CveMarca" Width="100%" OnSelectedIndexChanged="DdlMarcaPS_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Selected="True" Text="Seleccione la Marca (Todas)" Value="-1"></asp:ListItem>
</asp:DropDownList>
<label for="<%= DdlMarcaPSAjuste.ClientID.ToString()%>">Marca:</label>
</div>
</div>
<div class="col-md-12">
<div class="form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlMarcaPSAjuste" CssClass="form-control input-sm select2me" runat="server" DataTextField="Marca" DataValueField="CveMarca" Width="100%" OnSelectedIndexChanged="DdlMarcaPS_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Selected="True" Text="Seleccione la Marca (Todas)" Value="-1"></asp:ListItem>
</asp:DropDownList>
<label for="<%= DdlMarcaPSAjuste.ClientID.ToString()%>">Marca:</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-9">
<div class="form-group form-md-line-input input-iconright">
<ADS:Dropdownlost ID="DdlPSAjuste" CssStyle="width: 100%;" CssClass=" form-control input-sm DdlPS" IncluyeTodos="false" CssClassDdl="select2me form-control" runat="server" CausesValidation="true" DataTextField="PSCodigo" DataValueField="CvePS" Onselectedindexchange="DdlPSAjuste_selectedindexchange"></ADS:Dropdownlost>
<asp:HiddenField ID="HdnPSAjusteMarca" ClientIDMode="Static" runat="server" Value="-1" />

View File

@@ -1264,6 +1264,9 @@ Partial Class PV
DdlMarcaPS.DataBind()
DdlMarcaPSAjuste.DataBind()
DdlMarcaPS.Items.Insert(0, New ListItem("Todas", "-1"))
DdlMarcaPSAjuste.Items.Insert(0, New ListItem("Todas", "-1"))
UpModalVenta.Update()
UpAjuste.Update()
End Sub
@@ -3519,11 +3522,19 @@ Partial Class PV
ObjFactura.DtInventario = DtInv.FiltraParametros("Seleccionado = 1")
End If
ObjFactura.ServicioDomicilio = ChkServicioDomicilio.Checked
'VALIDA ENTREGA POR ADELANTADO
If UsuarioActual.Empresa.Funcionalidad(145) = "1" Then
'INCRUSTAMOS ALMACEN ENTREGA POR ADELANTADO CUANDO SEA REMISION Y NO TRAIGA ASIGNADO POR EL USUARIO
If ObjFactura.CveAlmacenTraspasoDestino <= 0 And ObjFactura.TipoDocto = "Rem" Then
If ObjFactura.ServicioDomicilio Then
ObjFactura.CveAlmacenServicioDomicilio = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 29 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString.ToEntero
ObjFactura.DtInventario = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
End If
ObjFactura.CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString.ToEntero
End If
'SI LA SUCURSAL NO TIENE ENTREGA POR ADELANTADO
@@ -3532,8 +3543,6 @@ Partial Class PV
End If
End If
ObjFactura.ServicioDomicilio = ChkServicioDomicilio.Checked
End Sub
#End Region

View File

@@ -754,6 +754,12 @@
</asp:UpdatePanel>
</td>
</tr>
<tr align="left" id="TrServicioDomicilio" runat="server" visible="false">
<td><b>Servicio a Domicilio:</b>&nbsp;</td>
<td>
activado
</td>
</tr>
</table>
</div>
</ContentTemplate>

View File

@@ -4012,6 +4012,10 @@ Partial Class Ventas
End If
End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CBool(DbRowVenta("ServicioDomicilio")) Then
TrServicioDomicilio.Visible = True
End If
'CargaDetalle
If ObjVentas.GetVentaDetalle(CveVenta) Then
TmpDT = ObjVentas.DtResultados
@@ -12976,8 +12980,10 @@ Partial Class Ventas
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
Dim IdCtaContable As Integer = 0
Dim CveCuenta As Integer = 0
Dim TotalCostoAcumulado As Decimal = 0
If tmpCostos.Rows.Count > 0 Then
Dim TotalCostoAcumulado As Decimal = 0
Dim cont As Integer = 1
'Se agrega movimiento separado por la cuenta de ventas (ER)
For Each RowInv As DataRow In tmpCostos.Rows
@@ -12995,12 +13001,18 @@ Partial Class Ventas
'If ValorInventario <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, TipoMovto69, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero(), CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then
OcurrioError = True
End If
OcurrioError = True
End If
'End If
cont += 1
Next
End If
'AJUSTA EL TOTAL
If Math.Abs(TotalCostoAcumulado - TotalCosto) = 0.01 Then
TotalCosto = TotalCostoAcumulado
End If
IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero()
'If TotalCosto <> 0 Then
@@ -23186,7 +23198,7 @@ Partial Class Ventas
Dim ObjBancos As New ClsBancos
If UsuarioActual.CveRol = 1 Then
GvComplementoPagos.Columns(8).Visible = True
GvComplementoPagos.Columns(7).Visible = True
End If