-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
+
+
+
diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb
index 4f8101173..28caab902 100644
--- a/Compras/Compras.aspx.vb
+++ b/Compras/Compras.aspx.vb
@@ -1366,7 +1366,15 @@ Partial Class Compras_Compras
Dim ObjPersonal As New ClsRH
ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa)
DdlPersonal.DataSource = ObjPersonal.DtResultados
- DdlPersonalReembolso.DataSource = ObjPersonal.DtResultados.FiltraParametros("CveEstatusPersonal = 1")
+
+ If UsuarioActual.CveEmpresa = 119 Then
+ DdlPersonalReembolso.DataSource = ObjPersonal.DtResultados
+ Else
+ DdlPersonalReembolso.DataSource = ObjPersonal.DtResultados.FiltraParametros("CveEstatusPersonal = 1")
+ End If
+
+
+
ObjPersonal.Dispose()
DdlPersonal.DataBind()
DdlPersonalReembolso.DataBind()
@@ -1829,25 +1837,25 @@ Partial Class Compras_Compras
'TmpDT.Columns.Add("IEPSPSPorcentaje")
'TmpDT.Columns.Add("IEPSPSIVAPorcentaje")
SubTotalConceptos = Math.Round(TmpDT.SUM("Total"), 2).ToDecimal
- AddPS2(False)
+ AddPS2(False)
- 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101
- Dim ProductosCodigoSATNoPermitidos As New StringBuilder("")
- For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows
+ 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101
+ Dim ProductosCodigoSATNoPermitidos As New StringBuilder("")
+ For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows
- ProductosCodigoSATNoPermitidos.AppendFormat("{0}", drr("PS"))
+ ProductosCodigoSATNoPermitidos.AppendFormat("{0}", drr("PS"))
- Next
+ Next
- If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then
- Dim mensajeAdvertencia As String = String.Format("El comprobante contiene productos con código SAT '01010101', revise los productos:{0}", ProductosCodigoSATNoPermitidos.ToString)
- Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia)
-
- End If
+ If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then
+ Dim mensajeAdvertencia As String = String.Format("El comprobante contiene productos con código SAT '01010101', revise los productos:{0}", ProductosCodigoSATNoPermitidos.ToString)
+ Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia)
End If
- Else
+
+ End If
+ Else
CargaConceptosXML(XMLDoc)
End If
@@ -4706,7 +4714,7 @@ Partial Class Compras_Compras
ViewState("CveCompra") = ObjCompras.CveCompra
If ObjCompras.DtResultados.Rows.Count > 0 Then ViewState("CompraFolio") = ObjCompras.DtResultados.Rows(0)("vFolio").ToString
If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
- Devolucion = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate)
+ Devolucion = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDecimal, TxtFecha.Text.Trim.ToDate)
TieneError = Devolucion.TieneError
End If
@@ -6833,20 +6841,20 @@ Partial Class Compras_Compras
End If
End If
Case 6
+ PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal
Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
- For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto"}).Rows
+ For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto", "IVAPorcentaje"}).Rows
If ObjConta.GetRetCuenta(6, RowDetalle("CveClasificacion").ToString().ToEntero()) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero
End If
End If
If importeMN <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual,
- CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=SeContabiliza) Then
+ CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=SeContabiliza, PorcentajeImpuesto:=RowDetalle("IVAPorcentaje").ToString.ToDecimal) Then
ErrorPrepoliza = True
End If
End If
@@ -7135,6 +7143,10 @@ Partial Class Compras_Compras
End If
End If
+ If CveCompraRefacturacion > 0 Then
+ importeMovimiento = 0
+ importeMN = 0
+ End If
Case 59 'Documentos
importeMovimiento = importeCreditos
@@ -8283,6 +8295,16 @@ Partial Class Compras_Compras
End If
End If
Next
+
+ For Each Gvr As GridViewRow In GVNCInvAlmacen.Rows
+ If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
+ If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompra, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then
+ ErrorMovInv = True
+ Exit For
+ End If
+ End If
+ Next
+
End If
@@ -13130,49 +13152,43 @@ Partial Class Compras_Compras
PnlContadoBancos.Visible = True
TxtDocumentoImporte.Text = (TxtTotal.Text.ToDecimal - LblAmortizacion.Text.ToDecimal).FormatoNumero
ChkCreditoMultiple.Visible = False
- DivReembolsoModal.Visible = False
- RfvTxtRembolsoModal.Enabled = False
- TxtRembolsoModal.Text = ""
+ RfvTxtNumeroReembolso.Enabled = False
+ TxtNumeroReembolso.Text = ""
TxtRembolsoNumero.Text = ""
Case "2" ' F y E
PnlContadoFyE.Visible = True
CargaFuncionariosEmpleados()
ChkCreditoMultiple.Visible = False
- DivReembolsoModal.Visible = True
- RfvTxtRembolsoModal.Enabled = True
+ RfvTxtNumeroReembolso.Enabled = True
TxtRembolsoNumero.Text = ""
- TxtRembolsoModal.Text = ""
+ TxtNumeroReembolso.Text = ""
Case "3" ' Creditos
PnlContadoCreditos.Visible = True
ChkCreditoMultiple.Visible = True
CargaCreditos()
- DivReembolsoModal.Visible = False
- RfvTxtRembolsoModal.Enabled = False
- TxtRembolsoModal.Text = ""
+ RfvTxtNumeroReembolso.Enabled = False
+ RfvTxtNumeroReembolso.Text = ""
TxtRembolsoNumero.Text = ""
Case "4" ' Deudores
PnlContadoDeudores.Visible = True
CargaDeudores()
ChkCreditoMultiple.Visible = False
- DivReembolsoModal.Visible = False
- RfvTxtRembolsoModal.Enabled = False
- TxtRembolsoModal.Text = ""
+ RfvTxtNumeroReembolso.Enabled = False
+ TxtNumeroReembolso.Text = ""
TxtRembolsoNumero.Text = ""
Case "5" ' ACREEDORES
PnlContadoAcreedores.Visible = True
ChkCreditoMultiple.Visible = True
CargaAcreedores()
- DivReembolsoModal.Visible = False
- RfvTxtRembolsoModal.Enabled = False
- TxtRembolsoModal.Text = ""
+ RfvTxtNumeroReembolso.Enabled = False
+ TxtNumeroReembolso.Text = ""
TxtRembolsoNumero.Text = ""
Case "6" ' Caja Chica
PnlContadoCajaChica.Visible = True
TxtDocumentoImporteCaja.Text = (TxtTotal.Text.ToDecimal - LblAmortizacion.Text.ToDecimal).FormatoNumero
ChkCreditoMultiple.Visible = False
- DivReembolsoModal.Visible = True
- RfvTxtRembolsoModal.Enabled = True
- TxtRembolsoModal.Text = ""
+ RfvTxtNumeroReembolso.Enabled = True
+ TxtNumeroReembolso.Text = ""
TxtRembolsoNumero.Text = ""
End Select
@@ -13180,7 +13196,7 @@ Partial Class Compras_Compras
End Sub
Protected Sub BtnContado_Click(sender As Object, e As EventArgs)
- TxtRembolsoNumero.Text = TxtRembolsoModal.Text
+ TxtRembolsoNumero.Text = TxtNumeroReembolso.Text
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivContadoModal"))
End Sub
@@ -14256,7 +14272,7 @@ Partial Class Compras_Compras
'*se envia true si hubo un error*'
- Private Function guardardevolucion(ObjInventario As ClsInventarios, CveCompra As Integer, subtotal As Double, Fecha As Date) As MMensajeDevolucion
+ Private Function guardardevolucion(ObjInventario As ClsInventarios, CveCompra As Integer, subtotal As Decimal, Fecha As Date) As MMensajeDevolucion
Dim ErrorMovInv As Boolean = False
Dim CveAlmacen As Integer = DdlAlmacenDevolucion.SelectedValue.ToEntero()
Dim subtotaldevolucion As Double = 0
@@ -14264,6 +14280,7 @@ Partial Class Compras_Compras
Dim CveMovimientoEntrada As Integer = -1
'Calculo los subtotales para comparar con la NC
Dim cantidad As Double = 0.0
+ Dim TotalAlmacen As Decimal = 0
For Each Dr As GridViewRow In GVDevolucion.Rows
'CveAlmacen = Dr.DataKey("CveAlmacen").ToString.ToEntero
@@ -14283,14 +14300,24 @@ Partial Class Compras_Compras
If CveMovimientoEntrada <= 0 Then
ErrorMovInv = True
Else
+ Dim Acumulado As Decimal = 0
+ Dim PU As Decimal = 0
For Each Dr As GridViewRow In GVDevolucion.Rows
If Dr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, Dr.DataKey("PU").ToString.ToDecimal, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then
+ Acumulado += (Dr.FCTextBox("TxtCantidad").Text.ToDecimal * Dr.DataKey("PU").ToString.ToDecimal)
+ PU = Dr.DataKey("PU").ToString.ToDecimal
+ If subtotal < Acumulado Then
+ Dim dif As Decimal = subtotal - Acumulado
+ PU = (((Dr.FCTextBox("TxtCantidad").Text.ToDecimal * Dr.DataKey("PU").ToString.ToDecimal)) + dif) / Dr.FCTextBox("TxtCantidad").Text.ToDecimal
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, PU, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then
ErrorMovInv = True
Exit For
End If
End If
Next
+
End If
Else
ErrorMovInv = True
@@ -14352,18 +14379,18 @@ Partial Class Compras_Compras
'End Sub
Protected Sub BtnVinculaDevolucion_Click(sender As Object, e As EventArgs)
Try
- Dim subtotaldevolucion As Double = 0
+ Dim subtotaldevolucion As Decimal = 0
Dim realizadevolucion As Boolean = False
'Calculo los subtotales para comparar con la NC
- Dim cantidad As Double = 0.0
+ Dim cantidad As Decimal = 0
For Each Dr As GridViewRow In GVDevolucion.Rows
- cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDouble
+ cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDecimal
If cantidad > 0 Then
realizadevolucion = True
- subtotaldevolucion += Dr.DataKey("PU").ToString.ToDouble * cantidad
+ subtotaldevolucion += Dr.DataKey("PU").ToString.ToDecimal * cantidad
End If
Next
@@ -14397,6 +14424,7 @@ Partial Class Compras_Compras
Dim IEPSCompra As Decimal = TxtIEPS.Text.ToDecimal()
Dim RetIVACompra As Decimal = TxtRetIVA.Text.ToDecimal()
Dim RetISRCompra As Decimal = TxtRetISR.Text.ToDecimal()
+ Dim Acumulado As Decimal = 0
'Dim TotalCalculable As Decimal = TotalCompra - IEPSCompra + RetIVACompra + RetISRCompra
@@ -14426,6 +14454,15 @@ Partial Class Compras_Compras
Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2)
Dim Descuento As Decimal = 0
+ Acumulado += (PU * Cantidad)
+
+ If SubTotalCompra < Acumulado Then
+ 'ajusta el valor
+ Dim dif As Decimal = SubTotalCompra - Acumulado
+ PU = ((PU * Cantidad) + dif) / Cantidad
+ Total = Cantidad * PU
+ 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)
End If
@@ -18789,6 +18826,7 @@ Partial Class Compras_Compras
HLAplicaNCFact.Visible = True
LblTotalNC.Text = TxtTotal.Text.FormatoNumero
CargaCuentasXPagar()
+ TabModoNC_ActiveTabChanged(TabModoNC, EventArgs.Empty)
End Sub
Private Sub CargaCuentasXPagar()
@@ -18922,6 +18960,9 @@ Partial Class Compras_Compras
ChkNCInv.Visible = True
GVNCInv.DataSource = DtPendientesAlmacen
GVNCInv.DataBind()
+
+ GVNCInvAlmacen.DataSource = DtPendientesAlmacen
+ GVNCInvAlmacen.DataBind()
End If
End If
@@ -18951,20 +18992,22 @@ Partial Class Compras_Compras
SaldoAnticipo += gvr.FCTextBox("TxtAnticipo").Text.ToDouble
End If
Next
+
+ If SaldoAnticipo <= 0 Then
+ Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
End If
- If SaldoAnticipo <= 0 Then
- Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
LbNCInvSaldo.Text = SaldoAnticipo.FormatoNumero()
+ LbNCInvSaldoAlmacen.Text = SaldoAnticipo.FormatoNumero()
If ChkNCInvNC.Checked Then
Dim ObjInventarios As New ClsInventarios
- If ObjInventarios.RecepcionAlmacenGet(-1, -1, UsuarioActual.CveEmpresa, CveProveedor) AndAlso ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Rows.Count > 0 Then
- DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Copy
+ If ObjInventarios.RecepcionAlmacenGet(-1, -1, UsuarioActual.CveEmpresa, CveProveedor) AndAlso ObjInventarios.DtResultados.FiltraParametros($"CantidadF > 0").Rows.Count > 0 Then
+ DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros($"CantidadF > 0").Copy
End If
ObjInventarios.Dispose()
End If
@@ -18973,10 +19016,12 @@ Partial Class Compras_Compras
If ChkNCInvNC.Checked Then
GVNCInv.DataSource = DtPendientesAlmacen
GVNCInv.DataBind()
- UpNCInv.Update()
- RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC")
+
+ GVNCInvAlmacen.DataSource = DtPendientesAlmacen
+ GVNCInvAlmacen.DataBind()
+
End If
- RegistraScript("$('#ModalNCInv').modal('show');", "ModalNCInv")
+
Else
If ChkNCInvNC.Checked Then
Alert("Niguna de las facturas seleccionadas cuenta con productos pendientes de darles entrada.", TipoMensaje.MsgAdvertencia)
@@ -18989,14 +19034,22 @@ Partial Class Compras_Compras
End If
UpNCInv.Update()
+ UpFacturaNC.Update()
End Sub
+
Protected Sub GVNCInv_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVNCInv.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", "FnCambiaInvNC(this);")
e.Row.FCTextBox("TxtCantidadNCInv").Attributes.Add("onkeyup", $"ValidarCantidad(this,{e.Row.DBCampo("CantidadF")});FnCambiaInvNC(this);")
End If
End Sub
+ Protected Sub GVNCInvAlmacen_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVNCInvAlmacen.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+ 'e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", "FnCambiaInvNC(this);")
+ e.Row.FCTextBox("TxtCantidadNCInv").Attributes.Add("onkeyup", $"ValidarCantidad(this,{e.Row.DBCampo("CantidadF")});FnCambiaInvNC(this);")
+ End If
+ End Sub
Protected Sub BtnNCInv_Click(sender As Object, e As EventArgs)
If ChkNCInvNC.Checked Then
@@ -19054,6 +19107,34 @@ Partial Class Compras_Compras
Protected Sub BtnNCConfirmacion_Click(sender As Object, e As EventArgs)
GuardaAnticipos(Nothing, Nothing)
End Sub
+
+ Protected Sub BtnNCInvAlmacen_Click(sender As Object, e As EventArgs)
+
+ 'Dim ObjCompras As New ClsCompras
+ 'Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL)
+ 'Dim TieneError = False
+
+ 'For Each Gvr As GridViewRow In GVNCInvAlmacen.Rows
+ ' If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
+ ' If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, Gvr.DataKey("CveCompra").ToEntero, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then
+ ' TieneError = True
+ ' Exit For
+ ' End If
+ ' End If
+ 'Next
+
+ 'If Not TieneError Then
+ ' Alert("Se guardo la devolución correctamente", TipoMensaje.MsgInformacion)
+ ' ObjCompras.Commit()
+ 'Else
+ ' Alert("Ocurrió un error al guardar la devolución", TipoMensaje.MsgError)
+ ' ObjCompras.RollBack()
+ 'End If
+
+ 'ObjCompras.Dispose()
+ RegistraScript("$('#FacturaNC').modal('hide');", "ModalNCInv")
+
+ End Sub
#End Region
#Region " INVENTARIO: MOVIMIENTOS DE LA COMPRA "
@@ -19675,8 +19756,8 @@ Partial Class Compras_Compras
Dim Multiplicador = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1)
If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then
- tipoCambioActual = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal
- tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual)
+ 'tipoCambioActual = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal
+ tipoCambioActual = TxtTC.Text.ToDecimal
Else
tipoCambioActual = 1
End If
@@ -20201,6 +20282,10 @@ Partial Class Compras_Compras
Protected Sub BtnFacturaNC_Click(sender As Object, e As EventArgs)
If ChkNCInvNC.Checked Then
CargaNCINV()
+
+ TabModoNC.ActiveTabIndex = 1
+ TabModoNC_ActiveTabChanged(TabModoNC, EventArgs.Empty)
+ UpFacturaNC.Update()
Else
RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC")
End If
@@ -20694,6 +20779,20 @@ Partial Class Compras_Compras
End Sub
+ Protected Sub TabModoNC_ActiveTabChanged(sender As Object, e As EventArgs)
+ Select Case TabModoNC.ActiveTabIndex
+ Case 0
+ BtnFacturaNC.Visible = True
+ BtnNCInvAlmacen.Visible = False
+ TabNCAlmacen.Enabled = False
+ Case 1
+ BtnFacturaNC.Visible = False
+ BtnNCInvAlmacen.Visible = True
+ TabNCAlmacen.Enabled = True
+ End Select
+
+ UpFooterFacturaNC.Update()
+ End Sub
End Class
Public Class MMensajeDevolucion
diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb
index b39460360..99cd97ad1 100644
--- a/Compras/PopUpVerFactura.aspx.vb
+++ b/Compras/PopUpVerFactura.aspx.vb
@@ -1152,6 +1152,29 @@ Partial Class PopUpVerFactura
Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL")
End If
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso (Vta.DtDocumentosRelacionados Is Nothing OrElse Vta.DtDocumentosRelacionados.Rows.Count = 0) Then
+ If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then
+ Vta.DtNCVinculadas = ObjVentas.DtResultados
+ Vta.DtDocumentosRelacionados = ObjVentas.DtResultados '.FiltraParametros("FolioFiscal IS NOT NULL")
+ If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then
+ If Vta.TipoDocto.Contiene("Ing") Then
+ Vta.Timbre.CFDIRelacionados.TipoRelacion = "01"
+ Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso"
+ End If
+
+ If Vta.TipoDocto.Contiene("Egs") Then
+ Vta.Timbre.CFDIRelacionados.TipoRelacion = "01"
+ Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso"
+ End If
+
+ If Vta.TipoDocto.Contiene("Dev") Then
+ Vta.Timbre.CFDIRelacionados.TipoRelacion = "03"
+ Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso"
+ End If
+ End If
+ End If
End If
End If
diff --git a/Compras/RepCxP.aspx.vb b/Compras/RepCxP.aspx.vb
index fdd9bf68e..c3a54da1d 100644
--- a/Compras/RepCxP.aspx.vb
+++ b/Compras/RepCxP.aspx.vb
@@ -763,6 +763,9 @@ Partial Class Compras_RepCxP
End If
If Modalidad = "A" Then
+ If Not ValidarRangosAgregar() Then
+ Exit Sub
+ End If
Dim Dt As DataRow = Nothing
Dt = DtPersonalizarRango.NewRow
Dt("RangoInicial") = TxtRI.Text.ToDouble
@@ -771,6 +774,9 @@ Partial Class Compras_RepCxP
Dt("TipoEscrito") = DdlTipo.SelectedItem.Text
DtPersonalizarRango.Rows.InsertAt(Dt, DtPersonalizarRango.Rows.Count)
ElseIf Modalidad = "U" Then
+ If Not ValidarRangosEditar() Then
+ Exit Sub
+ End If
DtPersonalizarRango.Rows(Index)("RangoInicial") = TxtRI.Text.ToDouble
DtPersonalizarRango.Rows(Index)("RangoFinal") = TxtRF.Text.ToDouble
DtPersonalizarRango.Rows(Index)("Tipo") = DdlTipo.SelectedValue
@@ -783,6 +789,61 @@ Partial Class Compras_RepCxP
RegistraScript("$('#DivPersonalizarRango').modal()", "SDSD")
End Sub
+ Private Function ValidarRangosAgregar() As Boolean
+ Dim UltimoRango As DataTable = DtPersonalizarRango.FiltraParametros(String.Format("Tipo = {0}", DdlTipo.SelectedValue), "RangoInicial")
+ Dim TieneNullRow As DataRow = UltimoRango.Rows(UltimoRango.Rows.Count - 1)
+ Dim aux As String = TieneNullRow.Item("RangoFinal").ToString
+ 'Dim TieneNull As DataTable = UltimoRango.FiltraParametros(String.Format("RangoFinal < 0"))
+ If aux = "" Then
+ Alert("Falta indicar el valor maximo del rango anterior", TipoMensaje.MsgAdvertencia)
+ Return False
+ End If
+ Dim ValorMinimoPosible As Double = UltimoRango.MAX("RangoFinal").ToDouble
+ If Not TxtRI.Text.ToDouble > ValorMinimoPosible Then
+ Alert("El rango inicial no puede ser inferior al rango final anterior", TipoMensaje.MsgAdvertencia)
+ End If
+ Return TxtRI.Text.ToDouble > ValorMinimoPosible
+ End Function
+
+ Private Function ValidarRangosEditar() As Boolean
+ Dim TablaDeDatosAux As DataTable = DtPersonalizarRango.FiltraParametros(String.Format("Tipo = {0}", DdlTipo.SelectedValue))
+
+ 'Valida que hay datos en el row anterior
+ Dim valorMinimo As Double = 0.0
+ If Index > 0 Then
+ 'Validar que el RowAnterior sea del mismo tipo
+ Dim RowAnterior As GridViewRow = GvPersonalizarRango.Rows(Index - 1)
+ If RowAnterior.DataKey("Tipo") = DdlTipo.SelectedValue Then
+ 'Validar que el valor final del row anterior no sea null
+ valorMinimo = If(RowAnterior.DataKey("RangoFinal") IsNot Nothing, RowAnterior.DataKey("RangoFinal").ToDouble, -1.0)
+ End If
+ End If
+
+ 'Valida que datos en e row siguiente
+ Dim valorMaximo As Double = 1000000.0
+ If Index < (GvPersonalizarRango.Rows.Count - 1) Then
+ 'Validamos que el row siguiente sea del mismo tipo
+ Dim RowSiguiente As GridViewRow = GvPersonalizarRango.Rows(Index + 1)
+ If RowSiguiente.DataKey("Tipo") = DdlTipo.SelectedValue Then
+ 'Validamos que el valor inicial del row siguiente no sea NULL
+ valorMaximo = If(RowSiguiente.DataKey("RangoInicial") IsNot Nothing, RowSiguiente.DataKey("RangoInicial").ToDouble, 1000000.0)
+ End If
+ End If
+
+ If Not TxtRI.Text.ToDouble > valorMinimo Then
+ Alert("El rango inicial no puede ser inferior al rango final anterior", TipoMensaje.MsgAdvertencia)
+ Return False
+ End If
+
+ If Not TxtRF.Text.ToDouble < valorMaximo Then
+ Alert("El rango final no puede ser superior al rango inicial siguiente", TipoMensaje.MsgAdvertencia)
+ Return False
+ End If
+
+ Return (TxtRI.Text.ToDouble > valorMinimo And TxtRF.Text.ToDouble < valorMaximo)
+
+ End Function
+
Protected Sub BtnCancelarPersonalizarRangoEditar_Click(sender As Object, e As EventArgs)
RegistraScript("$('#DivPersonalizarRangoEditar').modal('hide')")
RegistraScript("$('#DivPersonalizarRango').modal()", "SDSD")
diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb
index 58e9dd59c..3b39e3541 100644
--- a/Compras/eFacturas.aspx.vb
+++ b/Compras/eFacturas.aspx.vb
@@ -2710,7 +2710,7 @@ Partial Class Compras_eFacturas
Dim PrefijoPagos As String = ""
For Each nodoPrefijo As XmlNode In nodeComp.ChildNodes
- If nodoPrefijo.Prefix <> "tfd" Then
+ If nodoPrefijo.Prefix <> "tfd" And nodoPrefijo.Prefix.ToUpper.Contains("PAGO") Then
PrefijoPagos = nodoPrefijo.Prefix
End If
Next
diff --git a/Contabilidad/PlantillasPolizasDetalle.aspx b/Contabilidad/PlantillasPolizasDetalle.aspx
index 294b70ce4..3db8c7b0a 100644
--- a/Contabilidad/PlantillasPolizasDetalle.aspx
+++ b/Contabilidad/PlantillasPolizasDetalle.aspx
@@ -176,7 +176,7 @@
- >
+ >
@@ -269,6 +269,8 @@
Cuenta Contable:
+
+ Cuenta Contable:
diff --git a/Contabilidad/PlantillasPolizasDetalle.aspx.vb b/Contabilidad/PlantillasPolizasDetalle.aspx.vb
index d97ccd009..7449e664d 100644
--- a/Contabilidad/PlantillasPolizasDetalle.aspx.vb
+++ b/Contabilidad/PlantillasPolizasDetalle.aspx.vb
@@ -138,9 +138,32 @@ Partial Class Contabilidad_PlantillasPolizasDetalle
Private Sub CargaCuenta()
DdlCtaContable.Items.Clear()
- DdlCtaContable.DataSource = DTCuentasContables
- DdlCtaContable.DataBind()
+
DdlCtaContable.Items.Insert(0, New ListItem("Seleccione", "-1"))
+
+ If UsuarioActual.Empresa.TipoContabilizacion = 2 Then
+ Dim Conta As New ClsContabilidad
+ Dim dtt As New DataTable
+
+ If Conta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then
+ dtt = Conta.DtResultados
+ End If
+
+ Conta.Dispose()
+
+ DdlCuentas.Items.Clear()
+ DdlCuentas.DataSource = dtt
+ DdlCuentas.DataBind()
+ DdlCuentas.Visible = True
+ DdlCtaContable.Visible = False
+ Else
+
+ DdlCtaContable.DataSource = DTCuentasContables
+ DdlCtaContable.DataBind()
+ End If
+
+
+ DdlCuentas.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Private Sub CargarConcepto()
@@ -229,7 +252,8 @@ Partial Class Contabilidad_PlantillasPolizasDetalle
If HdnModalidad.Value = "I" Then
If CvePlantillaPoliza > 0 Then
- If ObjPlantillaPolizaDetalle.AddConta_PlantillasPolizasDetalles(CvePlantillaPoliza, DdlConcepto.SelectedValue.ToEntero, DdlTipoMovimiento.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.ToEntero, TxtOrden.Text.Trim.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DDLSubProyecto.SelectedValue.ToEntero, DDLProveedor.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero, DdlPorcentajeImpuesto.SelectedValue.ToDecimal) Then
+ If ObjPlantillaPolizaDetalle.AddConta_PlantillasPolizasDetalles(CvePlantillaPoliza, DdlConcepto.SelectedValue.ToEntero, DdlTipoMovimiento.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.ToEntero, TxtOrden.Text.Trim.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DDLSubProyecto.SelectedValue.ToEntero, DDLProveedor.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero, DdlPorcentajeImpuesto.SelectedValue.ToDecimal,
+CveCuenta:=DdlCuentas.SelectedValue.ToEntero) Then
TxtOrden.Text = ""
If Not ChkSeguirAgregando.Checked Then
updatatos()
diff --git a/Contabilidad/RegPrePoliza.aspx b/Contabilidad/RegPrePoliza.aspx
index c29f117a8..1cb80a307 100644
--- a/Contabilidad/RegPrePoliza.aspx
+++ b/Contabilidad/RegPrePoliza.aspx
@@ -303,7 +303,7 @@
-
+ Cuenta
diff --git a/Contabilidad/RegPrePoliza.aspx.vb b/Contabilidad/RegPrePoliza.aspx.vb
index c5b0c6618..6215cdbce 100644
--- a/Contabilidad/RegPrePoliza.aspx.vb
+++ b/Contabilidad/RegPrePoliza.aspx.vb
@@ -322,6 +322,7 @@ Partial Class ContabilidadC_RegPrePoliza
.Add("ConceptoContable", Type.GetType("System.String"))
.Add("TC", Type.GetType("System.Decimal"))
.Add("PorcentajeImpuesto", Type.GetType("System.Decimal"))
+ .Add("CveCuenta", Type.GetType("System.Int32"))
End With
End Sub
@@ -715,15 +716,20 @@ Partial Class ContabilidadC_RegPrePoliza
If drr IsNot Nothing Then
IdCuenta = drt("IdCtaContable").ToString.ToEntero
CodigoCuenta = drr("CuentaFormato").ToString()
- NombreCuenta = drr("Nombre").ToString()
- 'Cuenta = drr("Nombre").ToString()
+ NombreCuenta = drr("Nombre").ToString()
+ 'Cuenta = drr("Nombre").ToString()
+ NombreCuenta = CodigoCuenta & " " & NombreCuenta
End If
EsComodin = 0
End If
+ If drt("CveCuenta").ToString.ToEntero > 0 Then
+ NombreCuenta = String.Format("{0} {1}", drt("Codigo"), drt("Nombre"))
+ End If
+
Dim dr As DataRow = DtMovimientos.NewRow
dr("IdCuenta") = IdCuenta
- dr("CodigoCuenta") = CodigoCuenta & " " & NombreCuenta
+ dr("CodigoCuenta") = NombreCuenta
dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
dr("Referencia") = If(drt("CveConcepto").ToString.Contiene("29", "130"), drt("Personal"), drt("RazonSocial"))
dr("Concepto") = TxtObservaciones.Text
@@ -737,7 +743,8 @@ Partial Class ContabilidadC_RegPrePoliza
dr("CvePersonal") = drt("CvePersonal")
dr("CveClasificacion") = -1
dr("MultipleSubProyecto") = drt("MultipleSubProyecto")
- dr("PorcentajeImpuesto") = drt("PorcentajeImpuesto")
+ dr("PorcentajeImpuesto") = drt("PorcentajeImpuesto")
+ dr("CveCuenta") = drt("CveCuenta")
DtMovimientos.Rows.Add(dr)
Next
@@ -945,8 +952,8 @@ Partial Class ContabilidadC_RegPrePoliza
CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero,
ImporteMX:=Importe, CveTipoGasto:=gvr.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero,
CveCliente:=gvr.DataKey("CveCliente").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=If(gvr.DataKey("TC").ToString.ToDecimal > 0, gvr.DataKey("TC").ToString.ToDecimal, 1),
- ImporteME:=If(gvr.DataKey("TC").ToString.ToDecimal > 0, (Importe / (gvr.DataKey("TC").ToString.ToDecimal - 1)).RoundSQL, 0),
- PorcentajeImpuesto:=gvr.DataKey("PorcentajeImpuesto").ToDecimal) Then
+ ImporteME:=If(gvr.DataKey("TC").ToString.ToDecimal > 0, (Importe / (gvr.DataKey("TC").ToString.ToDecimal - 1)).RoundSQL, 0),
+ PorcentajeImpuesto:=gvr.DataKey("PorcentajeImpuesto").ToDecimal, CveCuenta:=gvr.DataKey("CveCuenta").ToEntero) Then
Else
MsgError = "No se pudo insertar el detalle de la póliza2"
Exit For
diff --git a/Contratos/Contrato.aspx.vb b/Contratos/Contrato.aspx.vb
index fb51b55b5..1653e71d9 100644
--- a/Contratos/Contrato.aspx.vb
+++ b/Contratos/Contrato.aspx.vb
@@ -1048,7 +1048,7 @@ Partial Class Contratos_Default
TxtPorAnticipo.Text = ObjContratos.PorAmortizacionAnticipo.FormatoNumero
TxtPorAmortizacionAnticipo.Text = ObjContratos.PorAmortizacionAnticipo.FormatoNumero
TxtPorGarantia.Text = ObjContratos.PorGarantia.FormatoNumero
- DdlProyecto.SelectedValue = ObjContratos.CveProyecto.ToString
+ 'DdlProyecto.SelectedValue = ObjContratos.CveProyecto.ToString
CargaSubProyectoContrato(DdlProyecto.SelectedValue.ToEntero)
DdlSubProyectoContrato.SelectedValue = ObjContratos.CveSubProyecto.ToString
TxtPorIVA.Text = ObjContratos.PorIVA.ToString
diff --git a/Contratos/ContratoObra.aspx b/Contratos/ContratoObra.aspx
index ea4c94e5d..6efbb60f6 100644
--- a/Contratos/ContratoObra.aspx
+++ b/Contratos/ContratoObra.aspx
@@ -102,6 +102,10 @@
Agregar Gasto
+
diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb
index 22e3f17ec..51f377cdc 100644
--- a/Inventarios/RecepcionUsados.aspx.vb
+++ b/Inventarios/RecepcionUsados.aspx.vb
@@ -1113,62 +1113,67 @@ Partial Class Inventarios_RecepcionUsados
FolioInv = Resp.FolioUsado
Else
- CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, CveConcepto, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta,
+ Dim tCveConcepto As Integer = CveConcepto
+ If RblUsadosAjuste.SelectedValue = "1" Then 'cuando es garantia, el concepto es de entrada
+ tCveConcepto = 2
+ End If
+
+ CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, tCveConcepto, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta,
CveSubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero,
Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text,
PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor, Modulo:="RU/G")
If CveMovimiento <= 0 Then
- Mensaje = "Error al guardar los movimientos"
- ErrorMovInv = True
- Else
- FolioInv = ObjInventario.Folio.ToString()
+ Mensaje = "Error al guardar los movimientos"
+ ErrorMovInv = True
+ Else
+ FolioInv = ObjInventario.Folio.ToString()
- For Each Dr As DataRow In DtMovimientos.Rows
+ For Each Dr As DataRow In DtMovimientos.Rows
- If CveConcepto = 42 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then
- ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
- Else
- ImporteConcepto = Dr("PU").ToString.ToDecimal
- End If
+ If CveConcepto = 42 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then
+ ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
+ Else
+ ImporteConcepto = Dr("PU").ToString.ToDecimal
+ End If
- If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
- Mensaje = "Error al guardar los movimientos"
- ErrorMovInv = True
- Exit For
- End If
-
- If CveVenta > 0 AndAlso Not ObjVentas.UpdateVentaUsadoRecibido(CveVenta, Dr("CvePS").ToString.ToEntero, True, CveMovimiento) Then
- Mensaje = "Error al actualizar el recibo de los usados"
- ErrorMovInv = True
- Exit For
- End If
-
- 'si es selectedvalue = 42, es entrada ,3 -salida
- Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 42, 1, 2)
-
- If EsDistribuidor AndAlso RBLOpcion.SelectedValue.ToEntero = 42 AndAlso Dr("CveTamaño").ToString.ToEntero > 0 Then
-
- If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, CveVenta, UsuarioActual.CveUsuario,
- UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then
- Mensaje = "Error al guardar Movimientos de distribuidor"
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
+ Mensaje = "Error al guardar los movimientos"
ErrorMovInv = True
Exit For
End If
- End If
- Next
+ If CveVenta > 0 AndAlso Not ObjVentas.UpdateVentaUsadoRecibido(CveVenta, Dr("CvePS").ToString.ToEntero, True, CveMovimiento) Then
+ Mensaje = "Error al actualizar el recibo de los usados"
+ ErrorMovInv = True
+ Exit For
+ End If
- 'GENERA LA PREPOLIZA DE ALMACEN VS EL CONCEPTO DE RNC
- 'If Not ErrorMovInv Then
- ' ErrorMovInv = Not GeneraPrePoliza(CveMovimiento, ObjInventario, ObjConta, True)
- 'End If
+ 'si es selectedvalue = 42, es entrada ,3 -salida
+ Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 42, 1, 2)
+
+ If EsDistribuidor AndAlso RBLOpcion.SelectedValue.ToEntero = 42 AndAlso Dr("CveTamaño").ToString.ToEntero > 0 Then
+
+ If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, CveVenta, UsuarioActual.CveUsuario,
+ UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then
+ Mensaje = "Error al guardar Movimientos de distribuidor"
+ ErrorMovInv = True
+ Exit For
+ End If
+
+ End If
+ Next
+
+ 'GENERA LA PREPOLIZA DE ALMACEN VS EL CONCEPTO DE RNC
+ 'If Not ErrorMovInv Then
+ ' ErrorMovInv = Not GeneraPrePoliza(CveMovimiento, ObjInventario, ObjConta, True)
+ 'End If
+
+ End If
End If
- End If
-
- If Not ErrorMovInv Then
+ If Not ErrorMovInv Then
If Resp IsNot Nothing Then
For Each mensaje2 As String In Resp.Mensajes
Msg.AppendFormat(" {0}", mensaje2)
diff --git a/Inventarios/ResguardoMaterial.aspx.vb b/Inventarios/ResguardoMaterial.aspx.vb
index 320899cee..95743d634 100644
--- a/Inventarios/ResguardoMaterial.aspx.vb
+++ b/Inventarios/ResguardoMaterial.aspx.vb
@@ -802,6 +802,7 @@ Partial Class Inventarios_ResguardoMaterial
Private Sub Guardar(Concepto As Integer)
Dim ObjInventario As New ClsInventarios
Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) 'Inicia la transacción
+ Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
Dim TieneError = False
Dim MensajeError As String = ""
Dim ImporteConcepto = 0.0
@@ -854,6 +855,7 @@ Partial Class Inventarios_ResguardoMaterial
If Not TieneError Then
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestino.SelectedValue.ToEntero, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservaciones.Text, CvePersonal:=CvePersonal, CveMovimientoRelacionado:=CveMovimientoSalida, CveCliente:=CveCliente, CveProveedor:=CveProveedor, Modulo:="ResgMat2")
FolioEntrada = ObjInventario.Folio
+ Dim Importe As Decimal = 0
If CveMovimientoEntrada <= 0 Then
MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
@@ -862,6 +864,7 @@ Partial Class Inventarios_ResguardoMaterial
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
Dim CveSeccionAlmacen As Integer = 0
+ Importe = ObjInventario.DtResultados.SUMD("Total").RoundSQL
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
If CBool(Dr("AplicaSeccion")) Then
CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacenDestino.SelectedValue.ToEntero, Dr("CvePS").ToString.ToEntero).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
@@ -880,6 +883,10 @@ Partial Class Inventarios_ResguardoMaterial
Next
End If
End If
+
+ 'registra la prepoliza
+
+ ContabilizaMovimientoAlmacen(ObjConta, Fecha, "Resguardo", "ResgMat", CveMovimientoSalida, CveMovimientoEntrada, Importe, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False)
End If
Case 24 'LIBERACION
@@ -914,6 +921,7 @@ Partial Class Inventarios_ResguardoMaterial
If Not TieneError Then
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestinoLiberacion.SelectedValue.ToEntero, 23, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservacionesLiberacion.Text, CvePersonal:=CvePersonalLiberacion, CveMovimientoRelacionado:=CveMovimientoSalida, CveProveedor:=CveProveedorLiberacion, CveCliente:=CveClienteLiberacion, MovimientoFijo:=True, Modulo:="ResgMat4")
FolioEntrada = ObjInventario.Folio
+ Dim Importe As Decimal = 0
If CveMovimientoEntrada <= 0 Then
MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
@@ -921,6 +929,7 @@ Partial Class Inventarios_ResguardoMaterial
Else
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
Cont = 0
+ Importe = ObjInventario.DtResultados.SUMD("Total").RoundSQL
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
Dim CveSeccionAlmacen As Integer = DiccionarioSecciones(Dr("CveMovimientoDetalle").ToString.ToEntero).ToString.ToEntero
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString) Then
@@ -932,6 +941,9 @@ Partial Class Inventarios_ResguardoMaterial
Cont += 1
Next
End If
+
+ ContabilizaMovimientoAlmacen(ObjConta, Fecha, "Resguardo", "ResgMat", CveMovimientoSalida, CveMovimientoEntrada, Importe, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False)
+
End If
End If
@@ -981,6 +993,25 @@ Partial Class Inventarios_ResguardoMaterial
ObjInventario.Dispose()
ObjEventos.Dispose()
End Sub
+
+ Public Function ContabilizaMovimientoAlmacen(ByRef ObjConta As ClsContabilidad, Fecha As Date, Concepto As String, Modulo As String, CveMovimientoSalida As Integer, CveMovimientoEntrada As Integer, Importe As Decimal, CveUsuario As Integer, CveEmpresa As Integer, Contabilizable As Boolean) As Integer
+ Dim Retorno As Integer = -1
+ Dim ErrorMovInv As Boolean = False
+
+ Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas(Modulo, 53, 0, 0, 1, Fecha, Concepto, CveUsuario, CveEmpresa)
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Importe, "", 68, Concepto, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=Importe, Contabilizable:=Contabilizable) Then
+ ErrorMovInv = True
+ End If
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Importe, "", 68, Concepto, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=Importe, Contabilizable:=Contabilizable) Then
+ ErrorMovInv = True
+ End If
+
+ If Not ErrorMovInv Then Retorno = CvePrePoliza
+
+ Return Retorno
+ End Function
+
Private Function AgregarAgenda(ByRef ObjEventos As ClsOIEventos, FolioEntrada As Integer, FolioSalida As Integer) As Boolean
Dim TieneError As Boolean = False
Dim RecurrenciaTipo = 0, Frecuencia = -1, DiasSemana = "-1", Dias = -1, Mes = -1, RecurrenciaFin = "-1", CveAgendaTipo = 4, Prioridad = 3, CveTipoEvento = 2, Importe = -1
diff --git a/Inventarios/TrasladoSolicitud.aspx.vb b/Inventarios/TrasladoSolicitud.aspx.vb
index baf983a9c..828eadeda 100644
--- a/Inventarios/TrasladoSolicitud.aspx.vb
+++ b/Inventarios/TrasladoSolicitud.aspx.vb
@@ -214,7 +214,11 @@ Partial Class Inventarios_TrasladoSolicitud
Else
TrGuia.Visible = False
End If
- BtnEliminar.Visible = True
+
+ If UsuarioActual.TienePermisoProceso(313) Then
+ BtnEliminar.Visible = True
+ End If
+
BtnGuardar.Enabled = False
TxtObservaciones.Enabled = False
TxtFecha.Enabled = False
@@ -563,6 +567,8 @@ Partial Class Inventarios_TrasladoSolicitud
Dim CodigoPS As String = ""
+
+ 'Aqui poner permiso para poder evitar permiso de traslado
If ObjInventarios.GetAlmacenes(-1, -1, UsuarioActual.CveEmpresa, -1) Then
If ObjInventarios.DtResultados.Rows.Count > 0 Then
@@ -1037,9 +1043,6 @@ Partial Class Inventarios_TrasladoSolicitud
MandaCorreoRechazo(LbFolio.Text.ToEntero, CveTraspasoSolicitud, CveUsuarioSolicita, TxtMotivoRechazo.Text)
CargaDatos()
RegistraScript("$('#ModalRechazarTraslado').modal('hide');")
-
-
-
End If
End Sub
diff --git a/Inventarios/TraspasoAlmacen.aspx b/Inventarios/TraspasoAlmacen.aspx
index 06766458f..eaf48f3d2 100644
--- a/Inventarios/TraspasoAlmacen.aspx
+++ b/Inventarios/TraspasoAlmacen.aspx
@@ -650,7 +650,7 @@
-
+
<%--
diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb
index 5146a4a86..28c5f2777 100644
--- a/Inventarios/TraspasoAlmacen.aspx.vb
+++ b/Inventarios/TraspasoAlmacen.aspx.vb
@@ -1532,7 +1532,7 @@ Partial Class Inventarios_TraspasoAlmacen
If Dtt IsNot Nothing Then
If TxtFolioRecepcion.Text.Trim <> "" Then
- CveMovimientoSalida = ObjInventarios.DtResultados.FiltroPrimeroValor("CveMovimiento", "").ToEntero
+ CveMovimientoSalida = Dtt.FiltroPrimeroValor("CveMovimiento", "").ToEntero
End If
CveAlmacenDestino = DdlAlmacenRecepcion.SelectedValue.ToEntero
@@ -1810,6 +1810,7 @@ Partial Class Inventarios_TraspasoAlmacen
Dim ObjInventario As New ClsInventarios
Dim Dtt As DataTable = Nothing
Dim CveMovimientoEntrada As Integer = 0
+ Dim CveMovimientoSalidaTransitorio As Integer = 0
Dim Folio = 0
Dim ErrorMovInv As Boolean = False
Dim TextoError = ""
@@ -1845,15 +1846,15 @@ Partial Class Inventarios_TraspasoAlmacen
'AGREGAMOS LA SALIDA
- 'CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenSalida, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
- ' Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, Modulo:="TA/G11")
+ CveMovimientoSalidaTransitorio = ObjInventario.AddMovimiento(CveAlmacenSalida, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
+ Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, Modulo:="TA/G11")
'AGREGAMOS LA ENTRADA
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenEntrada, 27, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="TA/G1")
Folio = ObjInventario.Folio
- If CveMovimientoSalida <= 0 Then
+ If CveMovimientoSalidaTransitorio <= 0 Then
TextoError = "No se pudo generar el movimiento de salida correctamente"
ErrorMovInv = True
Else
@@ -1887,12 +1888,16 @@ Partial Class Inventarios_TraspasoAlmacen
TextoError = "Ocurrió un error al guardar los movimientos de salida"
Exit For
End If
- ''MOV, Alm, Transito
- 'If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, PrecioEntrada, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, Serie:=gvr.DataKey("Serie").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
- ' ErrorMovInv = True
- ' TextoError = "Ocurrió un error al guardar los movimientos de salida"
- ' Exit For
- 'End If
+ 'MOV, Alm, Transito
+ If gvr.DataKey("CveMovimientoDetalleTransitorio").ToString.ToEntero > 0 Then
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaTransitorio, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, PrecioEntrada, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, Serie:=gvr.DataKey("Serie").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=gvr.DataKey("CveMovimientoDetalleTransitorio").ToString.ToEntero) Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al guardar los movimientos de salida"
+ Exit For
+ End If
+ Else
+ CveMovimientoSalidaTransitorio = 0
+ End If
ElseIf cantidadDisponibleValidacion < 0 Then
TextoError = String.Format("Se exceden la cantidad disponibles para {0}", gvr.DataKey("PS").ToString)
@@ -1903,22 +1908,26 @@ Partial Class Inventarios_TraspasoAlmacen
If Not ErrorMovInv Then
Dim Concepto As String = TxtObservacionesRecepcion.Text
If Concepto = "" Then Concepto = "Recepción Traspaso"
- 'Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- 'If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
+ Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
- ' Dim resultado As DataTable = ObjInventario.DtResultados
- ' Dim importe As Decimal = resultado.SUMD("Total").RoundSQL
- ' Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero
+ Dim resultado As DataTable = ObjInventario.DtResultados
+ Dim importe As Decimal = resultado.SUMD("Total").RoundSQL
+ Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero
+ Dim tCveConcepto As Integer = 68
- ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=importe, Contabilizable:=False) Then
- ' ErrorMovInv = True
- ' End If
+ If CveMovimientoSalidaTransitorio = 0 Then
+ tCveConcepto = 289
+ End If
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, tCveConcepto, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalidaTransitorio, ImporteMX:=importe, Contabilizable:=False) Then
+ ErrorMovInv = True
+ End If
- ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=importe, Contabilizable:=False) Then
- ' ErrorMovInv = True
- ' End If
- 'End If
- End If
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=importe, Contabilizable:=False) Then
+ ErrorMovInv = True
+ End If
+ End If
+ End If
End If
diff --git a/OC/OC.aspx b/OC/OC.aspx
index a5c5ecb11..e622ac180 100644
--- a/OC/OC.aspx
+++ b/OC/OC.aspx
@@ -941,7 +941,7 @@
-
+
@@ -1961,7 +1961,7 @@
Cantidad
-
+
diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb
index 440141f5c..3b6988841 100644
--- a/OC/OC.aspx.vb
+++ b/OC/OC.aspx.vb
@@ -2761,7 +2761,7 @@ Partial Class OC
For Each DrInv As DataRow In DtInvOC.FiltraParametros($"CveOrdenCompraDetalle = {dr("CveOrdenCompraDetalle").ToString.ToEntero} AND CveCompraDetalle < 1").Rows
DrInvOCDiferencias = DtInvOCDiferencias.NewRow
DrInvOCDiferencias("TipoCambioAjuste") = DrInv("TipoCambioAjuste").ToString.ToDouble
- DrInvOCDiferencias("Diferencia") = ((dr("Importe").ToString.ToDouble * DrInv("TipoCambioAjuste").ToString.ToDouble) - DrInv("PU").ToString.ToDouble) * DrInv("Cantidad").ToString.ToDouble
+ DrInvOCDiferencias("Diferencia") = ((dr("Importe").ToString.ToDouble * DrInv("TipoCambioAjuste").ToString.ToDouble) - DrInv("PUOriginal").ToString.ToDouble) * DrInv("Cantidad").ToString.ToDouble
DrInvOCDiferencias("CveAlmacen") = DrInv("CveAlmacen").ToString.ToEntero
DrInvOCDiferencias("CveOrdenCompraDetalle") = DrInv("CveOrdenCompraDetalle").ToString.ToEntero
DrInvOCDiferencias("ImporteMovto") = dr("Importe").ToString.ToDouble * DrInv("TipoCambioAjuste").ToString.ToDouble
@@ -2853,14 +2853,11 @@ Partial Class OC
IdCtaContableAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DrDiferencias("CveAlmacen").ToString.ToEntero}").ToEntero
If DiferenciaInvOC.RoundSQL() <> 0 Then
+ Dim tCveSubProyecto As Integer = 0
If CvePrePoliza > 0 Then
- If DdlSubProyecto.SelectedValue <= 0 Then
- Alert("Debe de asignar un sub proyecto o centro de costos.", TipoMensaje.MsgAdvertencia)
- TieneError = True
- Exit For
- End If
+ tCveSubProyecto = DtDetalle.FiltroPrimeroValor("CveSubProyecto", "CveOrdenCompraDetalle =" & CveOCDetalle).ToEntero
If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
ImporteME = (DiferenciaInvOC / TCInvOC).RoundSQL()
@@ -2877,7 +2874,7 @@ Partial Class OC
' Exit For
'End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, 177, SerieFolio, Fecha, IdCtaContableRecepcionOCER, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, 177, SerieFolio, Fecha, IdCtaContableRecepcionOCER, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=tCveSubProyecto) Then
TieneError = True
Exit For
End If
@@ -2895,7 +2892,7 @@ Partial Class OC
'2018.11.24 se cambia concepto 176, de cargo a abono negativo., petición MALL
'2019.03.26 se cambia concepto 177, de abono a cargo., petición MALL
'2019.04.10 se cambia concepto 177, de cargo a abono., petición MALL
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, If(ConceptoSalida = 0, 177, 177), SerieFolio, Fecha, IdCtaContableRecepcionOCER, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero) Then
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, If(ConceptoSalida = 0, 177, 177), SerieFolio, Fecha, IdCtaContableRecepcionOCER, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveOCDetalle:=CveOCDetalle, CveSubProyecto:=tCveSubProyecto) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DiferenciaInvOC, SerieFolio, 176, SerieFolio, Fecha, IdCtaContableRecepcionOC, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=DiferenciaInvOC, CveOCDetalle:=CveOCDetalle) Then
TieneError = True
Exit For
@@ -3551,8 +3548,11 @@ Partial Class OC
If e.Row.RowType = DataControlRowType.DataRow Then
Try
- e.Row.FCLabel("LtlCantidad").Attributes.Add("data-toggle", "tooltip")
- e.Row.FCLabel("LtlCantidad").Attributes.Add("Title", e.Row.DataKey("CveOrdenCompraDetalle"))
+ If e.Row.FCLabel("LtlCantidad") IsNot Nothing Then
+ e.Row.FCLabel("LtlCantidad").Attributes.Add("data-toggle", "tooltip")
+ e.Row.FCLabel("LtlCantidad").Attributes.Add("Title", e.Row.DataKey("CveOrdenCompraDetalle"))
+ End If
+
Catch ex As Exception
End Try
@@ -3749,7 +3749,7 @@ Partial Class OC
- If UsuarioActual.Empresa.Funcionalidad(590).ToString.ToEntero = 1 Then
+ If UsuarioActual.Empresa.Funcionalidad(590).ToString.ToEntero = 1 Then 'empresa agricola
e.Row.FCDropDownList("DdlCultivosCuadroEdit").Visible = True
e.Row.FCDropDownList("DdlCultivosCuadroEdit").DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {e.Row.DBCampo("CveSubProyecto").ToEntero}")
e.Row.FCDropDownList("DdlCultivosCuadroEdit").DataBind()
@@ -3871,7 +3871,11 @@ Partial Class OC
CveCultivoCuadroDetalle = gvr.FCDropDownList("DdlCultivosCuadroEdit").SelectedValue.ToEntero
- Cuadro = gvr.FCDropDownList("DdlCultivosCuadroEdit").SelectedItem.Text
+ Cuadro = ""
+ If CveCultivoCuadroDetalle > 0 Then
+ Cuadro = gvr.FCDropDownList("DdlCultivosCuadroEdit").SelectedItem.Text
+ End If
+
If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Or UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then
diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx
index e64276495..3da1f0d6a 100644
--- a/Ventas/Clientes.aspx
+++ b/Ventas/Clientes.aspx
@@ -577,10 +577,10 @@
Página:
-
+ <%--
Giro:
-
+
--%>
@@ -607,7 +607,7 @@
- Clasificación:
+ Giro:
@@ -4281,7 +4281,7 @@
-
+
diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb
index a01b7bf92..981ee8b46 100644
--- a/Ventas/Clientes.aspx.vb
+++ b/Ventas/Clientes.aspx.vb
@@ -1465,7 +1465,7 @@ Partial Class Clientes
TxtEmailCotizacion.Text = ObjClientes.MailCotizacion
TxtNotificar.Text = ObjClientes.NotificarA
TxtPagina.Text = ObjClientes.Pagina
- TxtGiro.Text = ObjClientes.Giro
+ 'TxtGiro.Text = ObjClientes.Giro
DdlPrecioLista.SelectedValue = ObjClientes.CvePrecioLista.ToString
TxtCC.Text = ObjClientes.NotificarA
ChkMail.Checked = ObjClientes.EnviarFactura
@@ -2520,11 +2520,11 @@ Partial Class Clientes
MetodoPago = 1
End If
-
+ Dim Giro As String = If(DdlClasificacion.SelectedValue.ToEntero() <> -1, DdlClasificacion.SelectedItem.Text, "")
If ObjClientes.AddCliente(TxtNombre.Text.Trim, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtLocalidad.Text.Trim, TxtCiudad.Text.Trim, DdlEstadoSAT.SelectedItem.Text.Trim, DdlSATPais.SelectedItem.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim, TxtTelefono.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""),
- TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text.Trim, TxtGiro.Text.Trim, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble,
+ TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text.Trim, Giro, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble,
TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtNombreCorto.Text.Trim, DdlVendedor.SelectedValue.ToEntero, TxtPlazoCobranza.Text.Trim.ToEntero, TxtPlazoCobranzaRemision.Text.Trim.ToEntero,
DiasPago, DdlTipoPago.SelectedValue, DdlCtaContableClientes.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableAnticipos.SelectedValue.ToEntero,
DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetIVA.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetISR.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableFondoGarantia.SelectedValue.ToEntero,
@@ -2617,9 +2617,9 @@ Partial Class Clientes
Else
NombreCliente = TxtNombre.Text.Trim()
End If
-
+ Dim Giro As String = If(DdlClasificacion.SelectedValue.ToEntero() <> -1, DdlClasificacion.SelectedItem.Text, "")
If ObjClientes.UpdateCliente(NombreCliente, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtLocalidad.Text.Trim, TxtCiudad.Text.Trim, DdlEstadoSAT.SelectedItem.Text.Trim, DdlSATPais.SelectedItem.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim,
- TxtTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text, TxtGiro.Text, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked,
+ TxtTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text, Giro, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked,
ChkEstado.Checked, TxtNombreCorto.Text.Trim, DdlVendedor.SelectedValue.ToEntero, TxtPlazoCobranza.Text.Trim.ToEntero, TxtPlazoCobranzaRemision.Text.Trim.ToEntero, DiasPago, DdlTipoPago.SelectedValue,
DdlCtaContableClientes.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableAnticipos.SelectedValue.ToEntero, DdlCtaContableAnticipos.SelectedItem.Text, DdlCtaContableRetIVA.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetISR.SelectedValue.ToEntero,
DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableFondoGarantia.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableCompClientes.SelectedValue.ToEntero, DdlCtaContableCompClientes.SelectedItem.Text, DdlCtaContableCompAnticipos.SelectedValue.ToEntero, DdlCtaContableCompAnticipos.SelectedItem.Text,
@@ -9143,7 +9143,7 @@ Partial Class Clientes
Dim ImporteBonificacion As Decimal = 0
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) AndAlso ObjAcum.DtResultados.Rows.Count >= 4 Then
GvUsadosResumen.DataSource = ObjAcum.DtResultados
- ImporteBonificacion = ObjAcum.DtResultados.Rows(4)("Valor").ToString().ToDecimal()
+ ImporteBonificacion = ObjAcum.DtResultados.Rows(5)("Valor").ToString().ToDecimal()
End If
GvUsadosResumen.DataBind()
diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb
index 18dbbe908..d6c0cbaf4 100644
--- a/Ventas/ProductosServicios.aspx.vb
+++ b/Ventas/ProductosServicios.aspx.vb
@@ -1146,7 +1146,7 @@ Partial Class ProductosyServicios
End Sub
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
- If DdlSATPS.SelectedValue = "46920" Then
+ If DdlSATPS.SelectedValue.Contiene("46920", "0", "-1") AndAlso UsuarioActual.CveEmpresa.Contiene(119, 158, 72, 80, 145) Then
Alert("El Producto Servicio SAT con clave '01010101' no es valido, por favor seleccione otro", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
@@ -1159,13 +1159,13 @@ Partial Class ProductosyServicios
Dim CveClasificacion2 As Integer = DdlClasificacion2.SelectedValue.ToEntero
If (TxtCodigo.Text = TxtCodigoBarras.Text AndAlso TxtCodigo.Text <> "") Then
- Alert("Los codigos no pueden ser iguales. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ Alert("Los códigos no pueden ser iguales. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
Return
End If
If ddlMetodos.SelectedValue = "5" Or ChkSerie.Checked Then
If Not (ddlMetodos.SelectedValue = "5" And ChkSerie.Checked) Then
- Dim Mensaje As String = If(ddlMetodos.SelectedValue = "5", "Si el método de salida del inventario es 'SerieLote' el producto debe poder aplicar serie", "Si el produco aplica serie el método de inventario debe ser 'SerieLote'")
+ Dim Mensaje As String = If(ddlMetodos.SelectedValue = "5", "Si el método de salida del inventario es 'Serie' el producto debe poder aplicar serie", "Si el produco aplica serie el método de inventario debe ser 'SerieLote'")
Alert(Mensaje)
Exit Sub
End If
@@ -1176,12 +1176,12 @@ Partial Class ProductosyServicios
'End If
If UsuarioActual.Empresa.Funcionalidad(265) = "1" And TxtCodigo.Text = "" Then
- Alert("El codigo es requerido.", TipoMensaje.MsgAdvertencia)
+ Alert("El código es requerido.", TipoMensaje.MsgAdvertencia)
Return
End If
If TxtCodigo.Text <> "" AndAlso Not TxtCodigo.Text.Length >= 3 Then
- Alert("El codigo tiene que que tener una longitud de al menos 3 digitos.", TipoMensaje.MsgAdvertencia)
+ Alert("El código tiene que que tener una longitud de al menos 3 digitos.", TipoMensaje.MsgAdvertencia)
Return
End If
@@ -1450,7 +1450,7 @@ Partial Class ProductosyServicios
Dim ObjAliasDelete As New ClsProductosServicios
Dim TieneError = False
- If ObjAliasDelete.RemovePSAlias(GVAlias.Rows(e.RowIndex).DataKey("CvePS").ToString.ToEntero, GVAlias.Rows(e.RowIndex).DataKey("PSAlias").ToString, -1) Then
+ If ObjAliasDelete.RemovePSAlias(GVAlias.Rows(e.RowIndex).DataKey("CvePS").ToString.ToEntero, GVAlias.Rows(e.RowIndex).DataKey("PSAlias").ToString, UsuarioActual.CveUsuario) Then
GVAlias.EditIndex = -1
CargarAlias()
UPGVAlias.Update()
diff --git a/Ventas/RepCancelacionesPorRespuesta.aspx.cs b/Ventas/RepCancelacionesPorRespuesta.aspx.cs
index df8d7e78a..05451a07f 100644
--- a/Ventas/RepCancelacionesPorRespuesta.aspx.cs
+++ b/Ventas/RepCancelacionesPorRespuesta.aspx.cs
@@ -1,47 +1,47 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.IO;
-using System.Linq;
-using System.ServiceModel;
-using System.Text;
-using System.Web;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using Extensiones;
-using static Extensiones.ModExtensiones;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.ServiceModel;
+using System.Text;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Extensiones;
+using static Extensiones.ModExtensiones;
using Microsoft.Reporting.WebForms;
-public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
-{
- private DataTable DtVentas
- {
- get { return (ViewState["DtVentas"] == null) ? null : (DataTable)ViewState["DtVentas"]; }
- set { ViewState["DtVentas"] = value; }
- }
- private int CveVenta
- {
- get { return (ViewState["CveVenta"] == null) ? -1 : ViewState["CveVenta"].ToString().ToEntero(); }
- set { ViewState["CveVenta"] = value; }
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- CargaDatos();
- }
- }
- private void CargaDatos()
- {
- HdnLigaRefacturar.Value = "";
-
- if (Request["CveVenta"] != null)
- {
- this.CveVenta = Request["CveVenta"].ToString().ToEntero();
- }
-
- var ObjVentas = new ClsVentas();
- if (ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -2, -1, "-1", "-1", "-1", CveUsuarioConsulta: UsuarioActual.CveUsuario))
+public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
+{
+ private DataTable DtVentas
+ {
+ get { return (ViewState["DtVentas"] == null) ? null : (DataTable)ViewState["DtVentas"]; }
+ set { ViewState["DtVentas"] = value; }
+ }
+ private int CveVenta
+ {
+ get { return (ViewState["CveVenta"] == null) ? -1 : ViewState["CveVenta"].ToString().ToEntero(); }
+ set { ViewState["CveVenta"] = value; }
+ }
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!IsPostBack)
+ {
+ CargaDatos();
+ }
+ }
+ private void CargaDatos()
+ {
+ HdnLigaRefacturar.Value = "";
+
+ if (Request["CveVenta"] != null)
+ {
+ this.CveVenta = Request["CveVenta"].ToString().ToEntero();
+ }
+
+ var ObjVentas = new ClsVentas();
+ if (ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -2, -1, "-1", "-1", "-1", CveUsuarioConsulta: UsuarioActual.CveUsuario))
{
if (Request["CveVenta"] != null && Request["CveVenta"].ToString().ToEntero() > 0)
@@ -51,42 +51,42 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
else
{
DtVentas = ObjVentas.DtResultados.Copy();
- }
- }
-
- ObjVentas.Dispose();
- GvDatos.DataSource = DtVentas.FiltraParametros("CveEstatusFactura = 20 AND CveEstatusRefacturacion = 0");
-
- var DtRefacturar = DtVentas.FiltraParametros("CveEstatusRefacturacion IN (1,3)");
- if (DtRefacturar != null && DtRefacturar.Rows.Count > 0)
- {
- DivRefacturar.Visible = true;
- GvRefacturaciones.DataSource = DtRefacturar;
- GvRefacturaciones.DataBind();
- }
-
- GvDatos.DataBind();
- UPDatos.Update();
- }
- protected void BtnValidar_Click(object sender, EventArgs e)
- {
+ }
+ }
+
+ ObjVentas.Dispose();
+ GvDatos.DataSource = DtVentas.FiltraParametros("CveEstatusFactura = 20 AND CveEstatusRefacturacion = 0");
+
+ var DtRefacturar = DtVentas.FiltraParametros("CveEstatusRefacturacion IN (1,3)");
+ if (DtRefacturar != null && DtRefacturar.Rows.Count > 0)
+ {
+ DivRefacturar.Visible = true;
+ GvRefacturaciones.DataSource = DtRefacturar;
+ GvRefacturaciones.DataBind();
+ }
+
+ GvDatos.DataBind();
+ UPDatos.Update();
+ }
+ protected void BtnValidar_Click(object sender, EventArgs e)
+ {
this.HdnLigaRefacturar.Value = "";
- this.CveVenta = -1;
-
- GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
- this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
-
- int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
- string Total = GvRow.DataKey("Total");
- string SubTotal = GvRow.DataKey("SubTotal");
- string Uuid = GvRow.DataKey("FolioFiscal");
- string RFCCliente = GvRow.DataKey("RFCCliente");
- string Folio = GvRow.DataKey("Folio");
- string TipoDocto = GvRow.DataKey("TipoDocto");
- string Nombre = GvRow.DataKey("Nombre");
- if (CveVenta > 0)
- {
- var resp = VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, Total);
+ this.CveVenta = -1;
+
+ GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
+ this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
+
+ int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
+ string Total = GvRow.DataKey("Total");
+ string SubTotal = GvRow.DataKey("SubTotal");
+ string Uuid = GvRow.DataKey("FolioFiscal");
+ string RFCCliente = GvRow.DataKey("RFCCliente");
+ string Folio = GvRow.DataKey("Folio");
+ string TipoDocto = GvRow.DataKey("TipoDocto");
+ string Nombre = GvRow.DataKey("Nombre");
+ if (CveVenta > 0 && Uuid != "")
+ {
+ var resp = VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, Total);
if (resp.EnviarAcuse)
{
Alert(resp.Mensaje,TipoMensaje.MsgConfirmacion,"BtnEnviarMailCancelacion();");
@@ -94,30 +94,31 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
else
{
Alert(resp.Mensaje);
- }
-
- }
- CargaDatos();
+ }
+
+ }
+ CargaDatos();
}
- protected void BtnValidarRefacturacion_Click(object sender, EventArgs e)
- {
+ protected void BtnValidarRefacturacion_Click(object sender, EventArgs e)
+ {
this.HdnLigaRefacturar.Value = "";
- this.CveVenta = -1;
-
- GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
- this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
-
- int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
- string Total = GvRow.DataKey("Total");
- string SubTotal = GvRow.DataKey("SubTotal");
- string Uuid = GvRow.DataKey("FolioFiscal");
- string RFCCliente = GvRow.DataKey("RFCCliente");
- string Folio = GvRow.DataKey("Folio");
- string TipoDocto = GvRow.DataKey("TipoDocto");
- string Nombre = GvRow.DataKey("Nombre");
-
- if (CveVenta > 0)
- {
+ this.CveVenta = -1;
+
+ GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
+ this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
+
+ int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
+ string Total = GvRow.DataKey("Total");
+ string SubTotal = GvRow.DataKey("SubTotal");
+ string Uuid = GvRow.DataKey("FolioFiscal");
+ string RFCCliente = GvRow.DataKey("RFCCliente");
+ string Folio = GvRow.DataKey("Folio");
+ string TipoDocto = GvRow.DataKey("TipoDocto");
+ string Nombre = GvRow.DataKey("Nombre");
+
+
+ if (CveVenta > 0 && Uuid != "")
+ {
var respuesta = VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, Total, true);
CargaDatos();
if (respuesta.CveEstatus.Contiene(4,5))
@@ -129,7 +130,7 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
Alert(respuesta.Mensaje,TipoMensaje.MsgAdvertencia);
}
-
+
//if (respuesta.IrARefacturar)
//{
// Server.Transfer(respuesta.LigaRefacturacion);
@@ -138,46 +139,46 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
//{
// Alert(respuesta.Mensaje);
// CargaDatos();
- //}
- }
- UPDatos.Update();
-
- }
- private MRespuestaSAT VerificarVigenciaSAT(int CveVenta, int CveCliente, string Folio, string TipoDocto, string uuid, string emisor, string receptor, string total, bool EsRefacturacion = false)
- {
- HdnLigaRefacturar.Value = "";
-
+ //}
+ }
+ UPDatos.Update();
+
+ }
+ private MRespuestaSAT VerificarVigenciaSAT(int CveVenta, int CveCliente, string Folio, string TipoDocto, string uuid, string emisor, string receptor, string total, bool EsRefacturacion = false)
+ {
+ HdnLigaRefacturar.Value = "";
+
var retorno = new MRespuestaSAT()
{
Mensaje = "",
EnviarAcuse = false,
LigaRefacturacion = "",
IrARefacturar = false
- };
-
- var sb = new StringBuilder();
-
- string CancelacionAcuse = "";
- DateTime CancelacionFecha = DateTime.Now;
- int CveEstatus = 4;
-
- try
- {
- var resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, true);
- if (resp != null)
+ };
+
+ var sb = new StringBuilder();
+
+ string CancelacionAcuse = "";
+ DateTime CancelacionFecha = DateTime.Now;
+ int CveEstatus = 4;
+
+ try
+ {
+ var resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, true);
+ if (resp != null)
{
-
- if (resp.Estado == null)
- {
- sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible");
- retorno.Mensaje = sb.ToString();
- return retorno;
- }
-
- sb.AppendFormat("Folio Fiscal: {0} ", uuid);
- sb.AppendFormat("Codigo Estado: {0} ", resp.CodigoEstatus);
- sb.AppendFormat("Estado: {0} ", resp.Estado);
- sb.AppendFormat("Es Cancelable: {0} ", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable);
+
+ if (resp.Estado == null)
+ {
+ sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible");
+ retorno.Mensaje = sb.ToString();
+ return retorno;
+ }
+
+ sb.AppendFormat("Folio Fiscal: {0} ", uuid);
+ sb.AppendFormat("Codigo Estado: {0} ", resp.CodigoEstatus);
+ sb.AppendFormat("Estado: {0} ", resp.Estado);
+ sb.AppendFormat("Es Cancelable: {0} ", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable);
sb.AppendFormat("Estatus de Cancelación: {0}
@@ -7790,7 +7802,10 @@
var totalDebito = ToDouble($get("TxtImporteDebito").value);
var totalCheque = ToDouble($get("TxtImporteCheque").value);
var totalTransferencia = ToDouble($get("TxtImporteTransferencia").value);
+
var totalRNC = ToDouble($get("HdnTotalRNC").value);
+ var totalAmortizado = ToDouble($get("HdnAnticipos").value);
+ var totalProntoPago = ToDouble($get("HdnProntoPago").value);
var TotalOtrosContado = 0;
@@ -7800,7 +7815,7 @@
}
} catch (e) { }
- var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado + totalRNC;
+ var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado + totalRNC + totalAmortizado + totalProntoPago;
var totalVenta = ToDouble($get('TxtTotal').value);
if (total > totalVenta) {
@@ -7809,7 +7824,7 @@
$get("TxtCambio").value = "0.00";
}
- $get("TxtImporteContado").value = total - totalRNC;
+ $get("TxtImporteContado").value = total - totalRNC - totalAmortizado - totalProntoPago;
}
// ****************************************************************************************************************************************************************************
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index 52c048cd1..795ac6f44 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -2582,7 +2582,7 @@ Partial Class Ventas
'DdlEstatus.SelectedValueExist("2")
ConfiguraTipoDocto()
- CargaFolios()
+
BtnEmitirImprimir.Text = "Facturar"
BtnEmitirImprimir.Visible = True
@@ -2615,6 +2615,7 @@ Partial Class Ventas
End If
If Not ExFolioFactura Then SetPermisos()
+ If CveVenta < 1 Then CargaFolios()
'SELECCIONA VENDEDOR DEL USUARIO CUANDO SEA VENTA NUEVA Y SIN CLIENTE
If UsuarioActual.CveVendedor > 0 Then
@@ -3980,7 +3981,7 @@ Partial Class Ventas
Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero()
- If UsuarioActual.Empresa.Funcionalidad(135) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso TipoEstatus = 5 Then
+ If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso TipoEstatus = 5 Then
If UsuarioActual.TienePermisoProceso(159) Then
Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto")))
If TienePermiso <> "" Then
@@ -3995,6 +3996,8 @@ Partial Class Ventas
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
+ TmpDT.Columns.Add("TieneProntoPago", GetType(String))
+ TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
@@ -4084,7 +4087,7 @@ Partial Class Ventas
End If
-
+ 'SI LA AUTORIZACION ES POR SUPERVISOR, BUSCA EL SUPERVISOR QUE TIENE EL VENDEDOR
If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then
'Reviso cuales son los supervisores
Dim Objeto As New ClsVtaVendedores
@@ -4101,7 +4104,7 @@ Partial Class Ventas
If TipoEstatus = 2 Then
LkCotizacionAutorizar.Visible = False
- ElseIf TipoEstatus = 2 Then
+ ElseIf TipoEstatus = 5 Then
LkCotizacionAutorizar.Visible = False
End If
End If
@@ -4110,8 +4113,18 @@ Partial Class Ventas
Objeto.Dispose()
End If
- String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())
-
+ 'SI LA AUTORIZACION ES POR PERMISO, BUSCA QUE EL USUARIO TENGA EL PERMISO PARA AUTORIZAR
+ If UsuarioActual.Empresa.Funcionalidad(135) = "2" Then
+ 'Reviso cuales son los supervisores
+ If UsuarioActual.TienePermisoProceso(116) Then
+ LkCotizacionAutorizar.Visible = True
+ If TipoEstatus = 2 Then
+ LkCotizacionAutorizar.Visible = False
+ ElseIf TipoEstatus = 5 Then
+ LkCotizacionAutorizar.Visible = False
+ End If
+ End If
+ End If
Case "Ant"
Trsaldo.Visible = True
@@ -4817,7 +4830,8 @@ Partial Class Ventas
Else
BtnGenerarRemision.Visible = False
End If
- BtnsFacturar.Visible = True
+ If UsuarioActual.TienePermisoProceso(60) Then BtnsFacturar.Visible = True 'puede facturar
+
LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274)
End If
End If
@@ -4868,30 +4882,47 @@ Partial Class Ventas
'Verifico si tiene la funcionalidad (135)
- If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135) = "1" Then
- 'Reviso cuales son los supervisores
- Dim ObjVendedores As New ClsVtaVendedores
+ If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then
- If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then
- Dim DTVendedores As New DataTable
- If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then
- DTVendedores = ObjVendedores.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor))
- End If
+ Select Case UsuarioActual.Empresa.Funcionalidad(135)
+ Case "1" ' POR SUPERVISOR
+ Dim ObjVendedores As New ClsVtaVendedores
- 'Verifico si es su supervisor asignado
- If DTVendedores.Rows.Count > 0 Then
- If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then
- BtnsFacturar.Visible = True
- BtnGenerarRemision.Visible = True
- Else
- BtnsFacturar.Visible = False
- BtnGenerarRemision.Visible = False
+ If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then
+ Dim DTVendedores As New DataTable
+ If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then
+ DTVendedores = ObjVendedores.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor))
+ End If
+
+ 'Verifico si es su supervisor asignado
+ If DTVendedores.Rows.Count > 0 Then
+ If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then
+ BtnsFacturar.Visible = True
+ BtnGenerarRemision.Visible = True
+ Else
+ BtnsFacturar.Visible = False
+ BtnGenerarRemision.Visible = False
+ End If
+ End If
+
+ DTVendedores.Dispose()
End If
- End If
+ ObjVendedores.Dispose()
+
+ Case "2" ' POR PERMISO
+ If UsuarioActual.TienePermisoProceso(116) Then
+ If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then
+ BtnsFacturar.Visible = True
+ BtnGenerarRemision.Visible = True
+ Else
+ BtnsFacturar.Visible = False
+ BtnGenerarRemision.Visible = False
+ End If
+ End If
+
+ End Select
+
- DTVendedores.Dispose()
- End If
- ObjVendedores.Dispose()
End If
If DdlTipoComprobante.SelectedValue = "Cot" Then
@@ -5893,7 +5924,7 @@ Partial Class Ventas
LnkCotizaciones.Visible = False
End If
UPCondicionesPago.Update()
- ElseIf UsuarioActual.CveEmpresa.Contiene(72, 80, 146, 119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta < 1 Then
+ ElseIf UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 146, 158, 140) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta < 1 Then
RBLPago.SelectedValue = "1"
RBLPago_SelectedIndexChanged(Nothing, Nothing)
UPCondicionesPago.Update()
@@ -5967,7 +5998,7 @@ Partial Class Ventas
End If
If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
Else
- If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia)
+ If Alertas AndAlso UsuarioActual.Empresa.Funcionalidad(518) = "1" Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia)
End If
'RBLPago.SelectedValue = "2"
@@ -5988,6 +6019,9 @@ Partial Class Ventas
LnkPedido2SinFacturar.Visible = False
LnkCotizaciones.Visible = False
LnkOCs.Visible = False
+
+ Else
+ If Alertas AndAlso UsuarioActual.Empresa.Funcionalidad(518) = "1" Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia)
End If
End If
UPPCreditoDisponible.Update()
@@ -7837,6 +7871,25 @@ Partial Class Ventas
End If
End If
End If
+ Dim SerieFolioNCProntoPago As String = ""
+ Dim CveVentaNCProntoPago As Integer = -1
+ Dim GeneroDescuentoProntoPago As Boolean = False
+ If ObjFactura.DescuentoProntoPago > 0 Then
+ Dim RespFacturaProntoPago = GenerarNCProntoPago(ObjVentas.IniciaTransacSQL(), ObjClientes, ObjContPaq, ObjFactura)
+ If RespFacturaProntoPago.ObjFacturaProntoPago Is Nothing OrElse RespFacturaProntoPago Is Nothing Then
+ ErrorList.Add("No se pudo generar la nota de crédito de pronto pago")
+ Else
+ If RespFacturaProntoPago.Mensaje.CveVenta <= 0 OrElse RespFacturaProntoPago.Mensaje.TieneError Then
+ ErrorList.Add("No se pudo generar la nota de crédito de pronto pago")
+ Else
+ GeneroDescuentoProntoPago = True
+ CveVentaNCProntoPago = RespFacturaProntoPago.Mensaje.CveVenta
+ SerieFolioNCProntoPago = RespFacturaProntoPago.Mensaje.SerieFolio
+
+ Obj2.Add(RespFacturaProntoPago.ObjFacturaProntoPago)
+ End If
+ End If
+ End If
'MARCA PARA NO SURTIR VENTA DE COTNRATO DE CONSIGNACION DE VENTA | [IPP] : PARCHE
If ErrorList.Count = 0 Then
@@ -7936,7 +7989,7 @@ Partial Class Ventas
'ENVIAR POLIZA VIRTUAL
If ErrorList.Count = 0 Then
- If UsuarioActual.Empresa.Funcionalidad(576) = "1" Then
+ If UsuarioActual.Empresa.Funcionalidad(576) = "1" AndAlso EsProduccion Then
GeneraPolizaVentaWS(ObjFactura)
End If
End If
@@ -8029,7 +8082,7 @@ Partial Class Ventas
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
- If Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro Then
+ If Not GeneroDescuentoProntoPago AndAlso Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro Then
Dim ofa As Modelos.Factura = CType(Obj2(0), Modelos.Factura)
'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC
If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
@@ -8041,9 +8094,25 @@ Partial Class Ventas
GeneraPDFFactura(ChkEnviarFactura.Checked)
End If
+ 'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
+ If GeneroDescuentoProntoPago AndAlso Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro Then
+ Try
+ Dim ofa As Modelos.Factura = CType(Obj2(Obj2.Count - 1), Modelos.Factura)
+ 'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC
+ ofa.Timbre.CFDIRelacionados.UUID.Clear()
+ ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID)
+
+ ObjTimbrado.TimbrarFactura(UsuarioActual, ofa)
+ GeneraPDFFactura(ChkEnviarFactura.Checked)
+ Catch ex As Exception
+ OnError("Ocurrió un error al timbrar la nota de credito", ex)
+ End Try
+ End If
+
If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then
EstatusSMS = EnviarSMSTimbrado(ObjEventos)
End If
+
If Not SeTimbro Then
Alert(ObjTimbrado.MensajeErrorCFDI, TipoMensaje.MsgError)
End If
@@ -8202,6 +8271,10 @@ Partial Class Ventas
MensajeAlert.AppendFormat("
Su cambio es de ${0} ", TxtCambio.Text.ToDecimal.FormatoNumero(2))
End If
+ If CveVentaNCProntoPago > 0 Then
+ MensajeAlert.AppendFormat(String.Format(" La nota de crédito {0} por descuento pronto pago se generó correctamente.
", SerieFolioNCProntoPago))
+ End If
+
'MUESTA ALERT OK
' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-.
Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=2"";"))
@@ -9644,6 +9717,7 @@ Partial Class Ventas
End If
ObjFactura.CveTipoRetencion = DdlTipoRetencion.SelectedValue.ToEntero()
+ ObjFactura.DescuentoProntoPago = HdnProntoPago.Value.ToDecimal()
ObjFactura.NuevaFactura = Me.NuevaFactura
End Sub
@@ -10084,8 +10158,11 @@ Partial Class Ventas
End If
End If
- If tPS.Length > 1000 Then
- tPS = tPS.Remove(999, tPS.Length - 1)
+ tPS = tPS.Replace("|", " ")
+
+ If tPS.Length >= 1000 Then
+ Dim tPSRecortado = tPS.Remove(999, tPS.Length - 999)
+ tPS = tPSRecortado
End If
'condicionante, especial
@@ -10690,8 +10767,14 @@ Partial Class Ventas
factura.Timbre.Comprobante.Serie = ObjVentas.Serie
factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString()
- If Not GuardarUsados(ObjVentas.IniciaTransacSQL, factura) Then
- ErrorList.Add("Error al guardar usados")
+ If ObjFactura.TipoDocto = "Ing" Then
+ If Not GuardarUsados(2, ObjVentas.IniciaTransacSQL, factura) Then
+ ErrorList.Add("Error al guardar usados")
+ End If
+ ElseIf ObjFactura.TipoDocto = "Dev" Then
+ If Not GuardarUsados(1, ObjVentas.IniciaTransacSQL, factura) Then
+ ErrorList.Add("Error al guardar usados")
+ End If
End If
If factura.TipoDocto = "Egs" AndAlso NuevaFactura = 1 Then
@@ -10746,19 +10829,30 @@ Partial Class Ventas
End Try
'SI SE FACTURA UNA RNC SE MUESTRA
- If UsuarioActual.CveEmpresa = 140 AndAlso factura.TipoDocto = "Egs" Then
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso factura.TipoDocto = "Egs" Then
If Row("CveVentaDetalleRNC").ToString().ToEntero() > 0 Then
If Not ObjVentas.AddVentaDetalleRNCFacturada(Row("CveVentaDetalleRNC").ToString().ToEntero(), ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDecimal()) Then
ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.")
End If
+ Dim EsCargo As Boolean = False
+ Dim ListaRNC As List(Of Modelos.Factura) = Nothing
+
+ If NCDescuento Then
+ EsCargo = (Not ListaNCDescuento.Any(Function(RNC) RNC.Num2 = 1))
+ ListaRNC = ListaNCDescuento
+ Else
+ EsCargo = RblRNCTipo.SelectedValue = "1"
+ ListaRNC = ListaRemisionesNC
+ End If
+
'SI SE FACTURAN RNC DE CARGO, SE AGREGA EL CONCEPTO DE ACREDITAMIENTO
- If ClienteEsDistribuidor AndAlso RblRNCTipo.SelectedValue = "1" Then
+ If ListaRNC IsNot Nothing AndAlso ClienteEsDistribuidor AndAlso EsCargo Then
Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL())
Dim CvePSCargo As Integer = -1
- For Each RNC In ListaRemisionesNC
+ For Each RNC In ListaRNC
CvePSCargo = RNC.DtDetalle.FiltroPrimeroValor("CvePS", $"CveVentaDetalle={Row("CveVentaDetalleRNC").ToString()}").ToEntero()
If CvePSCargo > 0 Then
Exit For
@@ -12109,7 +12203,7 @@ Partial Class Ventas
importeMovimiento = 0
Case 103 'Descuento
- If ObjFactura.Descuento <> 0 AndAlso Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "-1" Then
+ If ObjFactura.Descuento <> 0 AndAlso Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso (DdlTipoAmortizacionAnticipo.SelectedValue = "-1" OrElse UsuarioActual.CveEmpresa = 141) Then
importeMovimiento = ObjFactura.Descuento * Multiplicador * ValorMultiplicador
importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador * ValorMultiplicador
@@ -14319,6 +14413,7 @@ Partial Class Ventas
'cuando es amortización por NOTA DE CREDITO
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
LblAntAplicados.Text = String.Format("Amortización por Nota de Crédito: {0:C}", Amortizacion) : LblAntAplicados.Visible = True
+ HdnAnticipos.Value = Amortizacion.RoundSQL(2).ToString()
Amortizacion = 0
HdnTipoDescuento.Value = "-1"
HdnDescuento.Value = "0"
@@ -15015,6 +15110,8 @@ Partial Class Ventas
If ObjVentas.GetVentaDetalle(ObjFacturaDevolucion.CveVenta) Then
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
+ TmpDT.Columns.Add("TieneProntoPago", GetType(String))
+ TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
End If
ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFacturaDevolucion, -1, TmpDT, ObjAC, -1, ObjBancos, ObjVentas)
Else
@@ -15410,7 +15507,7 @@ Partial Class Ventas
TrAlmacenAsignado.Visible = False
TrAlmacenOrigen.Visible = False
- If DdlTipoComprobante.SelectedValue = "Cot" And UsuarioActual.Empresa.Funcionalidad(135) = "1" Then
+ If DdlTipoComprobante.SelectedValue = "Cot" And UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then
Alert("Se ocupa una autorización.", TipoMensaje.MsgAdvertencia)
TrDireccion.Visible = False
TrCiudad.Visible = False
@@ -15818,13 +15915,13 @@ Partial Class Ventas
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 AndAlso (Not CveVenta > 0 Or EsCreaApartirDe Or CveDevolucion > 0) Then RecalculaIVA()
'ViewState("SubProyectoPorcentajeIVA") = dr("IVA")
ViewState("TipoFormato") = dr("TipoFormato")
- ViewState("Serie") = dr("Serie")
+ 'ViewState("Serie") = dr("Serie")
- If UsuarioActual.CveEmpresa = 140 AndAlso Me.CveVenta > 0 AndAlso Not EsCreaApartirDe AndAlso Not String.IsNullOrEmpty(SerieVenta) Then
- LblSerie.Text = SerieVenta
- Else
- LblSerie.Text = dr("Serie").ToString()
- End If
+ 'If UsuarioActual.CveEmpresa = 140 AndAlso Me.CveVenta > 0 AndAlso Not EsCreaApartirDe AndAlso Not String.IsNullOrEmpty(SerieVenta) Then
+ ' LblSerie.Text = SerieVenta
+ 'Else
+ ' LblSerie.Text = dr("Serie").ToString()
+ 'End If
If SerieXML <> "" Then LblSerie.Text = SerieXML
Dim CveSubProyecto As Integer = GetSubProyectoSucursal()
@@ -16221,6 +16318,14 @@ Partial Class Ventas
Descuento += ((Cantidad * PU) - TotalFinal)
End If
+ 'SI TIENE PRONTO PAGO CALCULA EL IMPORTE
+ If DdlTipoComprobante.SelectedValue = "Ing" AndAlso RowPorcentaje("ProntoPago").ToString().ToDecimal() > 0 Then
+ Dim TotalProntoPago As Decimal = (Cantidad * (PU)) - Descuento
+ Dim PorcentajeProntoPago = RowPorcentaje("ProntoPago").ToString().ToDecimal() / 100D
+
+ ObjDescuento.ImporteProntoPago = (TotalProntoPago * PorcentajeProntoPago).RoundSQL(2)
+ End If
+
End If
End If
End If
@@ -16254,6 +16359,7 @@ Partial Class Ventas
Dim Cantidad As Decimal = TxtCantidad.Text.ToDecimal
Dim PU As Decimal = If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal)
+
Dim ObjDescuento As Descuentos = CalcularDescuentos(CvePS, Cantidad, PU)
If ObjDescuento.EsPUModificado Then
PU = ObjDescuento.PU
@@ -16262,7 +16368,8 @@ Partial Class Ventas
AgregarProductoServicio(Cantidad, DdlUnidadMedida.SelectedValue.ToEntero(), DdlUnidadMedida.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero(), DdlClasificacion.SelectedItem.Text,
CvePS, "", TxtObsPS.Text.Trim, PU, ObjDescuento.ImporteDescuento,
DdlProyecto.SelectedValue.ToEntero(), DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedItem.Text,
- Serie:=If(DIVCod.Visible, TxtCodigoSerie.Text.Trim, ""), TiempoEntrega:=TxtTiempoEntrega.Text, CuentaPredial:=TxtCuentaPredial.Text.Trim, RegeneraIEPS:=ClienteDesglosaIEPS, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle)
+ Serie:=If(DIVCod.Visible, TxtCodigoSerie.Text.Trim, ""), TiempoEntrega:=TxtTiempoEntrega.Text, CuentaPredial:=TxtCuentaPredial.Text.Trim, RegeneraIEPS:=ClienteDesglosaIEPS, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle,
+ ImporteProntoPago:=ObjDescuento.ImporteProntoPago)
CalculaUsados()
@@ -16396,7 +16503,8 @@ Partial Class Ventas
PU As Decimal, Descuento As Decimal, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, Optional Serie As String = "", Optional TiempoEntrega As String = "",
Optional EntregaDirecta As Integer = 0, Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, Optional CuentaPredial As String = "",
- Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False) As Boolean
+ Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False,
+ Optional ImporteProntoPago As Decimal = 0) As Boolean
Dim Retorno As Boolean = False
Try
@@ -16425,7 +16533,7 @@ Partial Class Ventas
Dim Row As DataRow = Nothing
Dim TotalCalculableImpuestos As Decimal = 0
Dim TotalCalculableImpuestosIVA As Decimal = 0
- PU = PU.RoundAD(6) ' el precio unitario puede llevar hasta 6 decimales permitidos
+ PU = PU.RoundSQL(6) ' el precio unitario puede llevar hasta 6 decimales permitidos
If Not TmpDT.Columns.Contains("RetIVA") Then
TmpDT.Columns.Add("RetIVA", GetType(Decimal))
@@ -16555,24 +16663,24 @@ Partial Class Ventas
Row("IVA") = Row("PorcentajeIVA")
- Row("ImporteIVA") = (Row("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundAD(NumeroDecimales)
- Row("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
+ Row("ImporteIVA") = (Row("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales)
+ Row("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
- Row("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
+ Row("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
- Row("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
+ Row("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
Row("PorcentajeRetIVA") = ClienteRetIVA
Row("PorcentajeRetISR") = ClienteRetISR
Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
- Row("ImporteIEPS") = (DrPS("IEPSPorcentaje").ToString().ToDecimal * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
+ Row("ImporteIEPS") = (DrPS("IEPSPorcentaje").ToString().ToDecimal * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
Row("IEPS") = Row("ImporteIEPS")
- Row("Descuento") = (Descuento).RoundAD(NumeroDecimales)
+ Row("Descuento") = (Descuento).RoundSQL(NumeroDecimales)
Row("TipoDescuento") = HdnTipoDescuento.Value
Row("CvePromocionDetalle") = CvePromocionDetalle
Row("Total") = (Cantidad * PU)
- Row("TotalImporte") = (Cantidad * PU).RoundAD(NumeroDecimales)
+ Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
'Row("AsientoContableVentas") = DrPS("AsientoContableVentas")
' Row("IdCtaContVentas") = IdCtaContable
@@ -16598,6 +16706,14 @@ Partial Class Ventas
Row("EsOutSourcing") = DrPS("EsOutSourcing")
Row("EsCargo") = EsCargo
+ If ImporteProntoPago > 0 Then
+ Row("ImporteProntoPago") = ImporteProntoPago
+ Row("TieneProntoPago") = "Si"
+ GvPS.Columns(22).Visible = True
+ thProntoPago.Visible = True
+ thProntoPago2.Visible = True
+ End If
+
If UsuarioActual.CveEmpresa = 119 Then
If Not RemisionesLista.Count > 0 Then 'SI VIENE DE REMISION NO SE CONSIDERA
@@ -16817,9 +16933,15 @@ Partial Class Ventas
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
+ TmpDT.Columns.Add("TieneProntoPago", GetType(String))
+ TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
+
TmpDT.Columns("EsOutSourcing").DefaultValue = False
TmpDT.Columns("EsCargo").DefaultValue = False
+ TmpDT.Columns("TieneProntoPago").DefaultValue = "No"
+ TmpDT.Columns("ImporteProntoPago").DefaultValue = 0
+
End Sub
Private Sub CreaDTmpC()
DTmpC = New DataTable
@@ -17242,6 +17364,8 @@ Partial Class Ventas
Dim Total As Decimal = 0
Dim TotalImpuestosLocales As Decimal = 0
+ Dim TotalProntoPago As Decimal = TmpDT.SUM("ImporteProntoPago").ToDecimal
+
If TotalAmortizacion > 0 AndAlso TotalSubTotal = TotalAmortizacion Then ' si se amortizó completa la factura, debe de limpiar los impuestos
If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("3") Then
For Each dr As DataRow In TmpDT.Rows
@@ -17297,6 +17421,11 @@ Partial Class Ventas
TotalAmortizacion = 0
End If
+ Dim TotalRemNCAplicado As Decimal = 0
+
+ If TbDescuentosRNC.Visible AndAlso ListaNCDesc IsNot Nothing Then
+ TotalRemNCAplicado = ListaNCDesc.Sum(Function(RNC) RNC.TotalRemNCAplicado)
+ End If
Total = (TotalSubTotal - TotalDescuentos - TotalAmortizacion + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales)
LblSubTotal1.Text = TotalSubTotal.FormatoNumero(2)
@@ -17309,6 +17438,11 @@ Partial Class Ventas
TxtIEPS.Text = TotalIEPS.FormatoNumero
TxtTotal.Text = Total.FormatoNumero
+ HdnProntoPago.Value = TotalProntoPago.ToString()
+ LblProntoPago.Text = TotalProntoPago.FormatoNumero(2)
+
+ LblTotalAPagar.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado - TotalProntoPago).FormatoNumero
+
LblAmort.Text = TxtSubTotal.Text
If CveVenta <= 0 OrElse (CveDevolucion > 0 And NuevaFactura = 1) Then
HdnVentaSaldo.Value = Total.ToString()
@@ -20029,7 +20163,7 @@ Partial Class Ventas
End If
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
- Dim TotalNC As Decimal = If((ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0) OrElse (ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0), LblTotalNC.Text.Trim().ToDecimal(), 0)
+ Dim TotalNC As Decimal = If((ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0) OrElse (ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0), LblTotalAPagar.Text.Trim().ToDecimal(), 0)
If TotalNC > 0 Then
If (DtPagos.SUM("Importe").ToString().ToDecimal() + AmortizacionNC + Total - TxtCambio.Text.ToDecimal) > TotalNC Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
@@ -21105,8 +21239,14 @@ Partial Class Ventas
ObjVentas.Dispose()
If ActualizoEstatus Then
- 'GeneraPDFCotizacion(True)
- Alert("La cotización ha sido enviada al correo de nuestro cliente:" & Mail)
+
+ If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then
+ GeneraPDFCotizacion(True)
+ Alert("La cotización ha sido enviada al correo de nuestro cliente:" & Mail)
+ ElseIf UsuarioActual.Empresa.Funcionalidad(135) = "2" Then
+ Alert("La cotización ha sido autorizada.")
+ End If
+
Else
Alert("No se pudo autorizar la cotización", TipoMensaje.MsgError)
End If
@@ -24122,7 +24262,8 @@ Partial Class Ventas
Me.TmpDTRNCBonificacionesCliente.Columns.Add("CveVentaRNCCargo", GetType(Integer))
If CargarBonificaciones Then
- Me.TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Copy()
+ 'Me.TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Copy()
+ CargaBonificaciones(-1, True)
End If
If CargarSoloGarantias Then
@@ -24130,10 +24271,10 @@ Partial Class Ventas
Else
GvRemisionesNC.DataSource = DtNC.FiltraParametros("TipoRNC = 1 AND EsGarantia = False")
End If
- GvRemisionesNCBon.DataSource = Me.TmpDTRNCBonificacionesSeleccionadas
-
GvRemisionesNC.DataBind()
- GvRemisionesNCBon.DataBind()
+
+ 'GvRemisionesNCBon.DataSource = Me.TmpDTRNCBonificacionesSeleccionadas
+ 'GvRemisionesNCBon.DataBind()
If CveVentaUsado > 0 Then
DivSMU.Visible = True
@@ -24262,6 +24403,11 @@ Partial Class Ventas
Dim ChkAplicarRNC As CheckBox = DirectCast(sender, CheckBox)
Dim GvRow As GridViewRow = DirectCast(ChkAplicarRNC.NamingContainer, GridViewRow)
+ CargaBonificacionesDesc(GvRow.DataKey("CveVenta").ToEntero(), ChkAplicarRNC.Checked)
+
+ End Sub
+
+ Private Sub CargaBonificacionesDesc(CveVentaRNCCargo As Integer, AplicarRNC As Boolean)
If TmpDTRNCBonificacionesSeleccionadas Is Nothing Then
TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone()
End If
@@ -24271,7 +24417,7 @@ Partial Class Ventas
Dim SbFiltro As New StringBuilder()
SbFiltro.Append("CveVenta IN(")
Using ObjAcum As New ClsAcumuladores
- If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=GvRow.DataKey("CveVenta").ToEntero()) Then
+ If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=CveVentaRNCCargo) Then
DtBon = ObjAcum.DtResultados.Copy()
End If
End Using
@@ -24288,7 +24434,7 @@ Partial Class Ventas
For Each bon In queryBonificacion
SbFiltro.AppendFormat("'{0}',", bon.CveVentaBonificacion)
- ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero(), .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion})
+ ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = CveVentaRNCCargo, .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion})
Next
SbFiltro.Remove(SbFiltro.Length - 1, 1)
SbFiltro.Append(")")
@@ -24302,9 +24448,9 @@ Partial Class Ventas
RowBonificacion("ImporteBonificacion") = RNCBonificacion.Sum(Function(x) x.ImporteBonificacion)
RowBonificacion("IVABonificacion") = RNCBonificacion.Sum(Function(x) x.IVABonificacion)
- RowBonificacion("CveVentaRNCCargo") = GvRow.DataKey("CveVenta").ToEntero()
+ RowBonificacion("CveVentaRNCCargo") = CveVentaRNCCargo
- If ChkAplicarRNC.Checked Then
+ If AplicarRNC Then
TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray)
Else
For Each RowEliminar In Me.TmpDTRNCBonificacionesSeleccionadas.Select(SbFiltro.ToString())
@@ -24328,12 +24474,16 @@ Partial Class Ventas
LblSaldoMaximoBonificacion.Text = String.Format("{0:N2}", Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal() + Me.TmpDTRNCBonificacionesSeleccionadas.SUM("IVABonificacion").ToDecimal())
UpDescNC.Update()
-
End Sub
Protected Sub ChkAplicarNCBon_CheckedChanged(sender As Object, e As EventArgs)
Dim ChkAplicarRNC As CheckBox = DirectCast(sender, CheckBox)
Dim GvRow As GridViewRow = DirectCast(ChkAplicarRNC.NamingContainer, GridViewRow)
+ CargaBonificaciones(GvRow.DataKey("CveVenta").ToEntero(), ChkAplicarRNC.Checked)
+
+ End Sub
+
+ Private Sub CargaBonificaciones(CveVentaRNCCargo As Integer, AplicarRNC As Boolean)
If TmpDTRNCBonificacionesSeleccionadas Is Nothing Then
TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone()
End If
@@ -24343,16 +24493,18 @@ Partial Class Ventas
Dim SbFiltro As New StringBuilder()
SbFiltro.Append("CveVenta IN(")
Using ObjAcum As New ClsAcumuladores
- If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=GvRow.DataKey("CveVenta").ToEntero()) Then
+ If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=CveVentaRNCCargo) Then
DtBon = ObjAcum.DtResultados.Copy()
End If
End Using
If DtBon IsNot Nothing Then
Dim queryBonificacion = From dr In DtBon
- Group By CveVentaBonificacion = dr("CveVentaBonificacion").ToString().ToEntero
+ Where dr("CveVentaBonificacion").ToString().ToEntero > 0
+ Group By CveVentaBonificacion = dr("CveVentaBonificacion").ToString().ToEntero, CveVenta = dr("CveVenta").ToString().ToEntero
Into x = Group
Select New With {
+ .CveVentaRNCCargo = CveVenta,
.CveVentaBonificacion = CveVentaBonificacion,
.ImporteBonificacion = x.Sum(Function(s) s("ImporteBonificacion").ToString().ToDecimal),
.IVABonificacion = x.Sum(Function(s) s("IVABonificacion").ToString().ToDecimal)
@@ -24360,7 +24512,7 @@ Partial Class Ventas
For Each bon In queryBonificacion
SbFiltro.AppendFormat("'{0}',", bon.CveVentaBonificacion)
- ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero(), .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion})
+ ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = bon.CveVentaRNCCargo, .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion})
Next
SbFiltro.Remove(SbFiltro.Length - 1, 1)
SbFiltro.Append(")")
@@ -24374,9 +24526,9 @@ Partial Class Ventas
RowBonificacion("ImporteBonificacion") = RNCBonificacion.Sum(Function(x) x.ImporteBonificacion)
RowBonificacion("IVABonificacion") = RNCBonificacion.Sum(Function(x) x.IVABonificacion)
- RowBonificacion("CveVentaRNCCargo") = GvRow.DataKey("CveVenta").ToEntero()
+ RowBonificacion("CveVentaRNCCargo") = CveVentaRNCCargo
- If ChkAplicarRNC.Checked Then
+ If AplicarRNC Then
TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray)
Else
For Each RowEliminar In Me.TmpDTRNCBonificacionesSeleccionadas.Select(SbFiltro.ToString())
@@ -24400,7 +24552,6 @@ Partial Class Ventas
LtlSMUBon.Text = String.Format("{0:N2}", Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal() + Me.TmpDTRNCBonificacionesSeleccionadas.SUM("IVABonificacion").ToDecimal())
UpModalRemisionesNC.Update()
-
End Sub
Protected Sub GvDescNCCargos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCCargos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
@@ -24436,6 +24587,12 @@ Partial Class Ventas
End If
End If
End Sub
+ Protected Sub GvRemisionesNCBon_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRemisionesNCBon.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+ e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCBonChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);")
+ e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCBonChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});")
+ End If
+ End Sub
Protected Sub DdlNCNivelImporte_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim ImporteReferencia As Double = 0, PorcentajeMaximo As Double = 0
@@ -24823,11 +24980,18 @@ Partial Class Ventas
Dim TotalAcumuladoRNC As Decimal = 0
Dim Terminar As Boolean = False
- For Each RowUsado As DataRow In RNC.DtDetalle.Rows
+ For Each RowUsado As DataRow In RNC.DtDetalle.FiltraParametros("", Orderby:="PU").Rows
Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
- Dim Obs = RowUsado("CodigoPS").ToString()
+ Dim CvePSCargo As Integer = RowUsado("CvePS").ToString().ToEntero()
+ Dim Obs = ""
+ 'SI ES ACUMULADOR LAS OBSERVACIOENS DEBEN SER EL NOMBRE DEL ACUMULADOR
+ If GlobalDTAcumTamaños().FiltroPrimero($"CvePSCargo = {CvePSCargo}") IsNot Nothing Then
+ Obs = RowUsado("CodigoPS").ToString()
+ Else
+ Obs = RowUsado("Obs").ToString()
+ End If
If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then
Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim())
@@ -24900,11 +25064,18 @@ Partial Class Ventas
Dim TotalAcumuladoRNC As Decimal = 0
Dim Terminar As Boolean = False
- For Each RowUsado As DataRow In Me.TmpDTRNCDetalleSelecciondas.FiltraParametros($"CveVenta={RNC.CveVenta}").Rows
+ For Each RowUsado As DataRow In Me.TmpDTRNCDetalleSelecciondas.FiltraParametros($"CveVenta={RNC.CveVenta}", Orderby:="PU").Rows
Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
- Dim Obs = RowUsado("CodigoPS").ToString()
+ Dim CvePSCargo As Integer = RowUsado("CvePS").ToString().ToEntero()
+ Dim Obs = ""
+ 'SI ES ACUMULADOR LAS OBSERVACIOENS DEBEN SER EL NOMBRE DEL ACUMULADOR
+ If GlobalDTAcumTamaños().FiltroPrimero($"CvePSCargo = {CvePSCargo}") IsNot Nothing Then
+ Obs = RowUsado("CodigoPS").ToString()
+ Else
+ Obs = RowUsado("Obs").ToString()
+ End If
If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then
Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim())
@@ -24986,7 +25157,7 @@ Partial Class Ventas
Dim RNCCargo = ListaNC.Where(Function(f) f.CveVenta = RNCBonificacion.CveVentaRNCCargo).FirstOrDefault()
- For Each RowCargo As DataRow In RNCCargo.DtDetalle.Rows
+ For Each RowCargo As DataRow In RNCCargo.DtDetalle.FiltraParametros("", Orderby:="PU").Rows
Dim PorcentajeAplicado = (RNCBonificacion.TotalRemNCAplicado / RNCBonificacion.Total)
@@ -25076,6 +25247,8 @@ Partial Class Ventas
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
+ TmpDT.Columns.Add("TieneProntoPago", GetType(String))
+ TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
End If
If AplicaNCMasiva OrElse AplicaNCUsado Then
@@ -26396,8 +26569,12 @@ Partial Class Ventas
If Not DtCotizaciones.Columns.Contains("Aplicado") Then
DtCotizaciones.Columns.Add("Aplicado", Type.GetType("System.Boolean"))
End If
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ GvCotPS.DataSource = DtCotizaciones.FiltraParametros("Cantidad > 0 AND EsAcumulador = False")
+ Else
+ GvCotPS.DataSource = DtCotizaciones.FiltraParametros("Cantidad > 0")
+ End If
- GvCotPS.DataSource = DtCotizaciones.FiltraParametros("Cantidad > 0")
End If
ObjVentas.Dispose()
GvCotPS.DataBind()
@@ -26465,6 +26642,11 @@ Partial Class Ventas
For Each row As DataRow In DTSeleccionadas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows
CotizacionesLista.Add(row("CveVenta").ToString().ToEntero())
Next
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ CalculaUsadosCotizacion(Cves, DTSeleccionadas, DtCotizaciones)
+ End If
+
Else
For Each row As DataRow In DTSeleccionadas.Rows
If CveMetodoPago <> -1 And row("CveMetodoPago33").ToString().ToEntero() <> CveMetodoPago Then
@@ -26509,6 +26691,74 @@ Partial Class Ventas
UpPS.Update()
UpParametros.Update()
End Sub
+
+ Private Sub CalculaUsadosCotizacion(ByRef SbVentasDetalle As StringBuilder, ByVal DTSeleccionadas As DataTable, ByVal DtCotizaciones As DataTable)
+ If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot", "Dev") Then
+
+ Dim DTTamanios As DataTable = GlobalDTAcumTamaños()
+
+ Dim DTCvePSCostos As DataTable = DTTamanios.FiltraParametros("", "", {"CvePSCargo"})
+
+ Dim TmpDTCalculo As DataRow() = DTSeleccionadas.Rows.Cast(Of DataRow).ToArray()
+
+ Dim DTPSTemp As New DataTable '= TmpDT.Clone
+
+ DTPSTemp.Columns.Add("CveVenta", GetType(Integer))
+ DTPSTemp.Columns.Add("Cantidad", GetType(Integer))
+ DTPSTemp.Columns.Add("CvePS", GetType(Integer))
+ DTPSTemp.Columns.Add("PU", GetType(Decimal))
+
+ For Each DrowPartidas As DataRow In TmpDTCalculo
+ Dim CveTamanioTemp As Integer = DrowPartidas("CveTamaño").ToString().ToEntero()
+ Dim CveVenta As Integer = DrowPartidas("CveVenta").ToString().ToEntero()
+
+ If CveTamanioTemp > 0 Then
+
+ Dim DTTamanioTemp As New DataTable
+ Dim CvePsTemp As Integer = DTTamanios.FiltraParametros($"CveTamaño = { CveTamanioTemp } ").Rows(0)("CvePSCargo").ToString().ToEntero()
+
+ Dim Cargo As Decimal = DTTamanios.FiltroPrimeroValor("Cargo", $" CveTamaño = { CveTamanioTemp }").ToDecimal
+
+ If DTPSTemp.FiltraParametros($"CvePs = { CvePsTemp }").Rows.Count > 0 Then
+
+ For Each dRowUpdate As DataRow In DTPSTemp.Rows
+
+ If (dRowUpdate("CvePS").ToString().ToEntero() = CvePsTemp) Then
+ dRowUpdate("Cantidad") = dRowUpdate("Cantidad").ToString().ToDecimal + DrowPartidas("Cantidad").ToString().ToDecimal
+ dRowUpdate("PU") = Cargo ' dRowUpdate("Total").ToString().ToDecimal + ImporteCargo
+ dRowUpdate("CveVenta") = CveVenta
+ End If
+ Next
+
+ DTPSTemp.AcceptChanges()
+
+ Else
+ Dim dRowNuevo As DataRow = DTPSTemp.NewRow
+
+ dRowNuevo("CvePS") = CvePsTemp
+ dRowNuevo("Cantidad") = DrowPartidas("Cantidad").ToString().ToDecimal
+ dRowNuevo("PU") = Cargo
+ dRowNuevo("CveVenta") = CveVenta
+
+ DTPSTemp.Rows.Add(dRowNuevo)
+ DTPSTemp.AcceptChanges()
+ End If
+
+ End If
+ Next
+
+ For Each drowPsTamaños As DataRow In DTPSTemp.Rows
+
+ If drowPsTamaños("PU").ToString().ToDecimal > 0 Then
+
+ Dim CveVentaDetalleUsado = DtCotizaciones.FiltroPrimeroValor("CveVentaDetalle", $"CveVenta = {drowPsTamaños("CveVenta")} AND CvePS = {drowPsTamaños("CvePS")}").ToEntero()
+ SbVentasDetalle.AppendFormat("{0},", CveVentaDetalleUsado)
+
+ End If
+ Next
+
+ End If
+ End Sub
Private Sub VerificaCotizaciones(ByRef dt As DataTable)
If ChkCotProductos.Checked Then
For Each Gvr As GridViewRow In GvCotPS.Rows
@@ -26545,6 +26795,12 @@ Partial Class Ventas
Return Nothing
End Function
Private Function AgregaPSCotizacion() As Boolean
+ 'Dim ObjFactCotizacion As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa)
+
+ 'Dim TotalCotizacion As Decimal = ObjFactCotizacion.Total 'TmpDT.SUM("TotalImporte").ToDecimal() + TmpDT.SUM("ImporteIVA").ToDecimal() + TmpDT.SUM("ImporteIEPS").ToDecimal() - TmpDT.SUM("ImporteRetIVA").ToDecimal() - TmpDT.SUM("ImporteRetISR").ToDecimal()
+
+ 'ObjFactCotizacion.Dispose()
+
If DtCotizacionesPS IsNot Nothing Then
Dim tCantidad As Decimal = 0
For Each Dr As DataRow In DtCotizacionesPS.Select()
@@ -26554,6 +26810,15 @@ Partial Class Ventas
Dr("CveProyecto").ToString().ToEntero(), Dr("Proyecto").ToString(), Dr("CveSubProyecto").ToString().ToEntero(), Dr("SubProyecto").ToString(),
CveContratoDetalle:=Dr("CveContratoDetalle").ToString().ToEntero(), CveVentaDetalleCotizacion:=Dr("CveVentaDetalle").ToString().ToEntero(), SeActualiza:=True)
Next
+ 'Dim TotalFactura = TmpDT.SUM("TotalImporte").ToDecimal() + TmpDT.SUM("ImporteIVA").ToDecimal() + TmpDT.SUM("ImporteIEPS").ToDecimal() - TmpDT.SUM("ImporteRetIVA").ToDecimal() - TmpDT.SUM("ImporteRetISR").ToDecimal()
+
+ 'Dim Diferencia As Decimal = TotalCotizacion - TotalFactura
+
+ 'If Diferencia <> 0 Then
+ ' Dim LastRow As DataRow = TmpDT.Rows(TmpDT.Rows.Count - 1)
+ ' LastRow("ImporteIVA") = LastRow("ImporteIVA").ToString().ToDecimal() - Diferencia
+ 'End If
+
CalculaTotalesVenta()
Return True
Else
@@ -26566,6 +26831,9 @@ Partial Class Ventas
#Region " COTIZACIONES - FACTURAR "
Private Function PreparaFacturarCotizacion() As Boolean
'LIMPIAMOS
+
+ 'Dim TotalCotizacion As Decimal = TxtTotal.Text.Replace(",", "").ToDecimal()
+
TmpDT.Rows.Clear()
TxtSubTotal.Text = "0.00"
TxtSubTotal2.Text = "0.00"
@@ -26594,6 +26862,18 @@ Partial Class Ventas
Return False
End If
+ 'Dim TotalFactura As Decimal = TmpDT.SUM("TotalImporte").ToDecimal() + TmpDT.SUM("ImporteIVA").ToDecimal() + TmpDT.SUM("ImporteIEPS").ToDecimal() - TmpDT.SUM("ImporteRetIVA").ToDecimal() - TmpDT.SUM("ImporteRetISR").ToDecimal()
+
+ 'Dim Diferencia As Decimal = TotalCotizacion - TotalFactura
+
+ 'If Diferencia <> 0 Then
+ ' Dim LastRow As DataRow = TmpDT.Rows(TmpDT.Rows.Count - 1)
+
+ ' LastRow("ImporteIVA") = LastRow("ImporteIVA").ToString().ToDecimal() + Diferencia
+
+ ' CalculaTotalesVenta()
+ 'End If
+
If TmpDT.Rows.Count = 0 Then
Alert("No hay conceptos por facturar de esta cotización o ha sido cambiada su información. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
Return False
@@ -27985,17 +28265,17 @@ Partial Class Ventas
End If
End Sub
- Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, factura As Modelos.Factura) As Boolean
+ Private Function GuardarUsados(CveConcepto As Integer, SqlTransaccion As SqlClient.SqlTransaction, factura As Modelos.Factura) As Boolean
Dim Resultado As Boolean = True
- If ClienteEsDistribuidor AndAlso factura.TipoDocto.Contiene("Ing") Then
+ If ClienteEsDistribuidor Then
Dim ObjAcum As New ClsAcumuladores(SqlTransaccion)
Dim CvePSPSA As Integer = UsuarioActual.Empresa.Funcionalidad(533).ToEntero
For Each drow As DataRow In factura.DtDetalle.Rows
If drow("CveTamaño").ToString.ToEntero > 0 And (CvePSPSA <> drow("CvePS").ToString.ToEntero) Then
- If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToEntero, drow("CveTamaño").ToString.ToEntero, 2, factura.CveVenta, UsuarioActual.CveUsuario,
+ If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToEntero, drow("CveTamaño").ToString.ToEntero, CveConcepto, factura.CveVenta, UsuarioActual.CveUsuario,
UsuarioActual.CveEmpresa, 0D, "") Then
Resultado = False
Exit For
@@ -28249,13 +28529,15 @@ Partial Class Ventas
End Sub
Protected Sub BtnAplicarDesc_Click(sender As Object, e As EventArgs)
Try
- Dim CveSATNC = "84111506"
- Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
+ Dim DrPS As DataRow = Nothing
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
- If ArrayNC.Length > 0 Then
- Dim CvePSNC As Integer = ArrayNC(0).ToEntero()
+ If ArrayNC.Length >= 4 Then
+ Dim CvePSNC As Integer = ArrayNC(3).ToEntero()
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSNC, AplicaParaVenta:=1).Rows(0)
+ Else
+ Dim CveSATNC = "84111506"
+ DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
End If
If DrPS Is Nothing Then
@@ -28298,7 +28580,7 @@ Partial Class Ventas
'SI TIENE ALGUN AJUSTE O GARANTIA
If ListaNCDesc.Any(Function(RNC) RNC.Num2 = 1) Then
- For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1)
+ For Each RNC In ListaNCDesc.Where(Function(x) x.Num2 = 1)
Dim Salir As Boolean = False
Dim NCAjuste As Integer = -1
@@ -28363,9 +28645,12 @@ Partial Class Ventas
ListaNCDesc.Clear()
Exit Sub
End If
+
+ Dim TotalProntoPago As Decimal = TmpDT.SUM("ImporteProntoPago").ToDecimal
+
HdnTotalRNC.Value = TotalRemNCAplicado.ToString()
LblDescuentosRNC.Text = TotalRemNCAplicado.FormatoNumero
- LblTotalNC.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado).FormatoNumero
+ LblTotalAPagar.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado - TotalProntoPago).FormatoNumero
Dim CvePS = DrPS("CvePS").ToString().ToEntero()
@@ -28774,6 +29059,7 @@ Partial Class Ventas
Public CvePromocionDetalle As Integer = -1
Public PU As Decimal = 0
Public EsPUModificado As Boolean = False
+ Public ImporteProntoPago As Decimal = 0
End Class
Protected Sub btnupEventoBitacora_Click(sender As Object, e As EventArgs)
@@ -29035,4 +29321,468 @@ Partial Class Ventas
+#Region " N O T A - D E - C R E D I T O - P R O N T O - P A G O"
+
+ Private Function GenerarNCProntoPago(SqlTransaccion As SqlClient.SqlTransaction, ByRef ObjCliente As ClsClientes, ByRef ObjConta As ClsContPAQi, ObjFactura As Modelos.Factura) As MensajeProntoPago
+ Dim Retorno As New MensajeProntoPago
+
+ Dim Resp As New Modelos.Factura.MMensajeFactura
+ Dim ObjFacturaProntoPago As Modelos.Factura = Nothing
+
+ Try
+ ObjFacturaProntoPago = New Modelos.Factura(UsuarioActual)
+
+ ObjFacturaProntoPago.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.TextoLimpio
+ ObjFacturaProntoPago.CveUsuario = UsuarioActual.CveUsuario
+ ObjFacturaProntoPago.UsuarioCreo = UsuarioActual.Usuario
+
+ Dim CveSubProyecto As Integer = ObjFactura.CveSubProyecto
+ Dim CveMoneda As Integer = ObjFactura.CveMoneda
+ Dim CveCliente As Integer = ObjFactura.CveCliente
+
+ Dim Folio As Integer = -1
+ Dim Serie As String = "-1"
+
+ ObjFacturaProntoPago.CveEmpresa = UsuarioActual.CveEmpresa
+ ObjFacturaProntoPago.TipoCambio = If(CveMoneda = 1, 1, GlobalTipoCambio(Now).FormatoNumero(4).ToDecimal())
+ ObjFacturaProntoPago.ConvertirPesos = False
+ ObjFacturaProntoPago.CveMoneda = CveMoneda
+ ObjFacturaProntoPago.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda}")
+ ObjFacturaProntoPago.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {CveMoneda}")
+ ObjFacturaProntoPago.Serie = Serie
+ ObjFacturaProntoPago.Folio = Folio
+ ObjFacturaProntoPago.Fecha = Now
+ ObjFacturaProntoPago.CvePrePoliza = -1
+ ObjFacturaProntoPago.CveMetodoPago = 0
+ ObjFacturaProntoPago.CondicionesPago = 0 ' 0 - Contado, 1 - Credito (CHECAR)
+ ObjFacturaProntoPago.FormaPago = 0
+
+ ObjFacturaProntoPago.TipoDocto = "Egs"
+ ObjFacturaProntoPago.Fecha = Now
+
+ ObjFacturaProntoPago.Version = "3.3"
+ ObjFacturaProntoPago.CveMetodoPago33 = 1
+ ObjFacturaProntoPago.MetodoPago33 = "Pago en una sola exhibición"
+ ObjFacturaProntoPago.ClaveMetodoPagoSAT = "PUE"
+
+ ObjFacturaProntoPago.CveFormaPago33 = 21
+ ObjFacturaProntoPago.FormaPago33 = "Aplicación de anticipos"
+ ObjFacturaProntoPago.FormaPagoSAT33 = "30"
+
+ ObjFacturaProntoPago.MetodoPago = ""
+ ObjFacturaProntoPago.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {ObjFacturaProntoPago.CveMetodoPago33}")
+
+ ObjFacturaProntoPago.CveSubProyecto = CveSubProyecto
+ ObjFacturaProntoPago.SetSubProyecto()
+
+ ObjFacturaProntoPago.CveCliente = CveCliente
+ ObjFacturaProntoPago.SetCliente()
+
+
+ If ObjCliente.GetClientes(ObjFacturaProntoPago.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+
+ ObjFacturaProntoPago.CveUsoCFDI = ObjCliente.CveUsoCFDI
+ ObjFacturaProntoPago.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
+ ObjFacturaProntoPago.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
+
+ ObjFacturaProntoPago.DtDetalle = CreaDTDetalleNCProntoPago()
+
+ CargaImpuestosProntoPago(ObjFacturaProntoPago, ObjFactura, ObjCliente.DesglosaIEPS, ObjCliente.RetIVA.ToDecimal, ObjCliente.RetISR.ToDecimal)
+
+ End If
+ End If
+
+ If ObjCliente.GetSucursales(CveCliente) Then
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+ ObjFacturaProntoPago.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero())
+ Else
+ ObjFacturaProntoPago.CveClienteSucursal = -1
+ End If
+ End If
+
+ ObjFacturaProntoPago.CveTipoRelacion = 7
+ ObjFacturaProntoPago.TipoRelacion = "07"
+
+ Dim Fol As New List(Of String)
+ Fol.Add(ObjFactura.FolioFiscal)
+ ObjFacturaProntoPago.UUIDRelacionados = Fol
+
+ Select Case ObjFacturaProntoPago.TipoDocto
+ Case "Ing"
+ ObjFacturaProntoPago.TipoDocumento = "Factura"
+ Case "REM"
+ ObjFacturaProntoPago.TipoDocumento = "Remision"
+ Case "Cot"
+ ObjFacturaProntoPago.TipoDocumento = "Cotizacion"
+ Case "Egs"
+ ObjFacturaProntoPago.TipoDocumento = "Nota de Crédito"
+ Case "Dev"
+ ObjFacturaProntoPago.TipoDocumento = "Nota de Devolución"
+ Case Else
+ ObjFacturaProntoPago.TipoDocumento = ""
+ End Select
+
+ ObjFacturaProntoPago.FechaPago = Now
+
+ ObjFacturaProntoPago.CveCorte = -1
+ ObjFacturaProntoPago.CveMesa = -1
+ ObjFacturaProntoPago.NumeroPersonas = 0
+ ObjFacturaProntoPago.CveContrato = -1
+ ObjFacturaProntoPago.DescripcionContrato = ""
+ ObjFacturaProntoPago.CveClienteSucursal = -1
+ ObjFacturaProntoPago.Entrega = ""
+ ObjFacturaProntoPago.CveAlmacen = -1
+
+ Dim DtVentasNC = InicializaDTVentasNCProntoPago()
+
+ Dim TotalImporte As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("TotalImporte")
+ Dim ImporteIVA As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteIVA")
+ Dim ImporteRetIVA As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteRetIVA")
+ Dim ImporteRetISR As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteRetISR")
+ Dim ImporteIEPS As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteIEPS")
+ Dim Descuento As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("Descuento")
+ Dim Amortizacion As Decimal = 0
+
+ Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
+
+ 'DETALLES
+ ObjFacturaProntoPago.SubTotal = TotalImporte
+ ObjFacturaProntoPago.Descuento = Descuento
+ ObjFacturaProntoPago.Amortizacion = Amortizacion
+ ObjFacturaProntoPago.IVA = ImporteIVA
+ ObjFacturaProntoPago.RetIVA = ImporteRetIVA
+ ObjFacturaProntoPago.RetISR = ImporteRetISR
+ ObjFacturaProntoPago.IEPS = ImporteIEPS
+ ObjFacturaProntoPago.Total = Total
+ ObjFacturaProntoPago.TotalOtrosConceptos = 0
+
+ Dim Drt = DtVentasNC.NewRow
+ Drt("CveVenta") = ObjFactura.CveVenta
+ Drt("Importe") = ObjFactura.DescuentoProntoPago
+ Drt("FolioFiscal") = ObjFactura.FolioFiscal
+
+ DtVentasNC.Rows.Add(Drt)
+ DtVentasNC.AcceptChanges()
+
+ ObjFacturaProntoPago.DtVentasNC = DtVentasNC
+
+ Resp = ObjFacturaProntoPago.EmitirFactura(False, Transac:=SqlTransaccion, ObjContPaqTransac:=ObjConta)
+
+ ObjFacturaProntoPago.Dispose()
+
+ Catch ex As Exception
+ Resp.CveVenta = -1
+ Resp.TieneError = True
+ OnError("Ocurrio un error al generar la nota de credito de pronto pago", ex)
+ End Try
+
+ Retorno.ObjFacturaProntoPago = ObjFacturaProntoPago
+ Retorno.Mensaje = Resp
+
+ Return Retorno
+ End Function
+
+
+ Private Sub AgregaTempDTNCProntoPago(ByRef TmpDT As DataTable, CvePS As Integer, PS As String, Codigo As String, CodigoPS As String, CveTipoPS As Integer, CveTipoInvPS As Integer, CveUM As Integer, UM As String,
+ CveClasificacion As Integer, Clasificacion As String, CveProyecto As Integer, CveSubProyecto As Integer,
+ Obs As String, Cantidad As Double, PU As Double, PorcentajeIVA As Double, ImporteIVA As Double, PorcentajeRetIVA As Double, ImporteRetIVA As Double,
+ PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double,
+ Total As Double, Serie As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String,
+ SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer,
+ CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer)
+
+ Dim Row As DataRow = Nothing
+ Row = TmpDT.NewRow()
+
+ Row("Consec") = TmpDT.Rows.Count + 1
+ Row("Orden") = TmpDT.Rows.Count + 1
+
+ Row("CvePS") = CvePS
+ Row("PS") = PS
+ Row("Codigo") = Codigo
+ Row("CodigoPS") = CodigoPS
+ Row("CveTipoPS") = CveTipoPS
+ Row("CveTipoInvPS") = CveTipoInvPS
+
+ Row("CveUM") = CveUM
+ Row("UM") = UM
+
+ Row("CveClasificacion") = CveClasificacion
+ Row("Clasificacion") = Clasificacion
+ Row("CveProyecto") = CveProyecto
+ Row("Proyecto") = ""
+ Row("CveSubProyecto") = CveSubProyecto
+ Row("SubProyecto") = ""
+
+ Row("Obs") = Obs
+ Row("Cantidad") = Cantidad
+ Row("PU") = Math.Round(PU, 6)
+ Row("PorcentajeIVA") = PorcentajeIVA
+ Row("IVA") = PorcentajeIVA
+ Row("ImporteIVA") = Math.Round(ImporteIVA, 2)
+ Row("PorcentajeRetIVA") = PorcentajeRetIVA
+ Row("ImporteRetIVA") = Math.Round(ImporteRetIVA, 2)
+ Row("PorcentajeRetISR") = PorcentajeRetISR
+ Row("ImporteRetISR") = Math.Round(ImporteRetISR, 2)
+ Row("PorcentajeIEPS") = PorcentajeIEPS
+ Row("ImporteIEPS") = Math.Round(ImporteIEPS, 2)
+ Row("IEPS") = Math.Round(ImporteIEPS, 2)
+ Row("TipoDescuento") = TipoDescuento
+ Row("Descuento") = Math.Round(Descuento, 2)
+ Row("Total") = Math.Round(Total, 2)
+ Row("TotalImporte") = Math.Round(Total, 2)
+
+ Row("Serie") = Serie
+ Row("TiempoEntrega") = TiempoEntrega
+ Row("CvePresupuestoIngreso") = CvePresupuestoIngreso
+ Row("EntregaDirecta") = EntregaDirecta
+ Row("SATClaveProdServ") = SATClaveProdServ
+ Row("SATClaveUM") = SATClaveUM
+
+ 'Contratos
+ Row("CveContratoDetalle") = CveContratoDetalle
+ Row("CveVentaDetalle") = CveVentaDetalle
+ Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
+ Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
+ Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
+ Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
+
+ TmpDT.Rows.Add(Row)
+ End Sub
+
+ Private Sub CargaImpuestosProntoPago(ByRef ObjFacturaDevolucion As Modelos.Factura, ObjFactura As Modelos.Factura, ClienteDesglosaIEPS As Boolean, ClienteRetIVA As Decimal, ClienteRetISR As Decimal)
+ Dim DtImpuestos As New DataTable
+ DtImpuestos.Columns.Add("ImportePU", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteTotal", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteRetIVA", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeRetISR", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteRetISR", GetType(Decimal))
+ DtImpuestos.Columns.Add("PorcentajeIEPS", GetType(Decimal))
+ DtImpuestos.Columns.Add("ImporteIEPS", GetType(Decimal))
+ DtImpuestos.Columns.Add("CveSubProyecto", GetType(Integer))
+ DtImpuestos.AcceptChanges()
+ Dim AcumuladoNC As Decimal = 0
+
+ DtImpuestos.Merge(CargaDtImpuestosNCProntoPago(ObjFactura.CveVenta, ObjFactura.DescuentoProntoPago), True, MissingSchemaAction.Ignore)
+
+ DtImpuestos = CargaTotalesImpuestosProntoPago(DtImpuestos)
+
+ Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, ObjFacturaDevolucion.CveSubProyecto).Rows(0)
+
+ Dim Cantidad As Decimal = 1
+ Dim CveProyecto As Integer = DrSubProyecto("CveProyecto").ToString().ToEntero()
+ Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero
+ Dim SubProyecto = DrSubProyecto("SubProyecto").ToString
+ Dim Proyecto = DrSubProyecto("Proyecto").ToString
+
+ Dim CveSATNC As Integer
+ Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
+ Dim NCBonificacion As Integer = 0
+ If ArrayNC.Length > 6 Then 'CONCEPTO DE PRONTO PAGO
+ CveSATNC = ArrayNC(6).ToEntero()
+ End If
+ Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("")
+
+ For Each Dr As DataRow In DtImpuestos.Rows
+ AgregaTempDTNCProntoPago(ObjFacturaDevolucion.DtDetalle, DrPS("CvePS").ToString.ToEntero, DrPS("PS").ToString, DrPS("Codigo").ToString, DrPS("PSCodigo").ToString, DrPS("CveTipoPS").ToString.ToEntero, DrPS("Inv_CveMetodoInventario").ToString.ToEntero,
+ DrPS("CveUM").ToString.ToEntero, DrPS("UnidadMedida").ToString, DrPS("CveClasificacion").ToString.ToEntero, DrPS("Clasificacion").ToString, CveProyecto, CveSubProyecto,
+ "", Cantidad, Dr("ImportePU").ToString.ToDecimal, Dr("PorcentajeIVA").ToString.ToDecimal, Dr("ImporteIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("ImporteRetIVA").ToString.ToDecimal,
+ Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("ImporteRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("ImporteIEPS").ToString.ToDecimal, -1, 0.0, Dr("ImporteTotal").ToString.ToDecimal, "", "", -1, -1,
+ DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1)
+ Next
+
+ End Sub
+
+ Private Function CargaDtImpuestosNCProntoPago(CveVentaNC As Integer, Importe As Decimal) As DataTable
+ Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
+
+ Dim TmpDT As DataTable = Nothing
+ Dim ObjVentas As New ClsVentas
+
+ If ObjVentas.GetVentaDetalle(CveVentaNC) Then
+ TmpDT = ObjVentas.DtResultados
+ TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
+ TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
+ End If
+
+ If ObjVentas.GetVenta(CveVentaNC, UsuarioActual.CveEmpresa) Then
+ If ObjVentas.DtResultados.Rows.Count > 0 Then
+ Total = ObjVentas.DtResultados()(0)("Total").ToString.ToDecimal
+ SubTotal = ObjVentas.DtResultados()(0)("SubTotal").ToString.ToDecimal
+ End If
+ End If
+ ObjVentas.Dispose()
+
+ Dim DtImpuestosLocal = TmpDT.FiltraParametros("", "", {"PorcentajeIVA", "PorcentajeRetIVA", "PorcentajeRetISR", "PorcentajeIEPS", "CveSubProyecto"}).Copy
+ DtImpuestosLocal.Columns.Add("ImportePU", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteTotal", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteIVA", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteRetIVA", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteRetISR", GetType(Decimal))
+ DtImpuestosLocal.Columns.Add("ImporteIEPS", GetType(Decimal))
+
+ Dim ImporteReferencia As Decimal = Total
+ Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100
+ Dim FiltroStr As String = ""
+ Dim ImporteTotalConcepto As Decimal = 0
+ For Each Dr As DataRow In DtImpuestosLocal.Rows
+ FiltroStr = String.Format("ISNULL(PorcentajeIVA,0) = {0} AND ISNULL(PorcentajeRetIVA,0) = {1} AND ISNULL(PorcentajeRetISR,0) = {2} AND ISNULL(PorcentajeIEPS,0) = {3} AND ISNULL(CveSubProyecto,0) = {4} ", Dr("PorcentajeIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("CveSubProyecto"))
+ ImporteTotalConcepto = Porcentaje * (TmpDT.SUMD("TotalImporte", FiltroStr) - TmpDT.SUMD("Descuento", FiltroStr))
+
+ Dr("ImportePU") = ImporteTotalConcepto.RoundSQL(6)
+ Dr("ImporteTotal") = ImporteTotalConcepto.RoundSQL(2)
+
+ Dr("ImporteIVA") = (ImporteTotalConcepto * Dr("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
+ Dr("ImporteRetIVA") = (ImporteTotalConcepto * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2)
+ Dr("ImporteRetISR") = (ImporteTotalConcepto * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2)
+ Dr("ImporteIEPS") = (ImporteTotalConcepto * Dr("PorcentajeIEPS").ToString().ToDecimal()).RoundSQL(2)
+
+ 'Dr("ImporteIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIVA", FiltroStr), 2)
+ 'Dr("ImporteRetIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetIVA", FiltroStr), 2)
+ 'Dr("ImporteRetISR") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetISR", FiltroStr), 2)
+ 'Dr("ImporteIEPS") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIEPS", FiltroStr), 2)
+
+ '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal)
+ Next
+ 'codigo para ajuste de centavo, si el importe total no cuadra con los totales
+ Dim difTmp As Decimal = Importe - (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR"))
+ If Math.Abs(difTmp) >= 0.01 Then
+ 'asusto la diferencia en el último concepto
+ Dim ImporteAjustado As Decimal = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString.ToDecimal + difTmp
+ DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal") = ImporteAjustado
+ DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImportePU") = ImporteAjustado
+ End If
+ 'CARGA FACTURA A LA CUAL SE APLICA LA NC
+ 'CargaNCDT(CveVentaNC, Importe.ToDecimal)
+ Return DtImpuestosLocal
+ End Function
+
+ Private Function CargaTotalesImpuestosProntoPago(DtImpuestos As DataTable) As DataTable
+ Dim query = From dr In DtImpuestos
+ Group By PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal,
+ PorcentajeRetIVA = dr("PorcentajeRetIVA").ToString.ToDecimal,
+ PorcentajeRetISR = dr("PorcentajeRetISR").ToString.ToDecimal,
+ PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal
+ Into x = Group
+ Select ImportePU = x.Sum(Function(s) s("ImportePU").ToString.ToDecimal),
+ ImporteTotal = x.Sum(Function(s) s("ImporteTotal").ToString.ToDecimal),
+ ImporteIVA = x.Sum(Function(s) Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)), ' Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)) * (1 + PorcentajeIEPS) * PorcentajeIVA,
+ ImporteRetIVA = x.Sum(Function(s) Math.Round(s("ImporteRetIVA").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetIVA,
+ ImporteRetISR = x.Sum(Function(s) Math.Round(s("ImporteRetISR").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetISR,
+ ImporteIEPS = x.Sum(Function(s) Math.Round(s("ImporteIEPS").ToString.ToDecimal, 2)), 'Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeIEPS,
+ PorcentajeIVA = PorcentajeIVA,
+ PorcentajeRetIVA = PorcentajeRetIVA,
+ PorcentajeRetISR = PorcentajeRetISR,
+ PorcentajeIEPS = PorcentajeIEPS
+
+ Return query.QueryToDataTable(False)
+ End Function
+
+ Protected Function CreaDTDetalleNCProntoPago() As DataTable
+ Dim TmpDT = New DataTable
+ TmpDT.Columns.Add("CveVenta", GetType(Integer))
+ TmpDT.Columns.Add("Consec", GetType(Integer))
+ TmpDT.Columns.Add("Cantidad", GetType(Decimal))
+ TmpDT.Columns.Add("Codigo", GetType(String))
+ TmpDT.Columns.Add("CveUM", GetType(Integer))
+ TmpDT.Columns.Add("UM", GetType(String))
+ TmpDT.Columns.Add("SATClaveUM", GetType(String))
+ TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
+ TmpDT.Columns.Add("Clasificacion", GetType(String))
+ TmpDT.Columns.Add("CvePS", GetType(Integer))
+ TmpDT.Columns.Add("PS", GetType(String))
+ TmpDT.Columns.Add("CodigoPS", GetType(String))
+ TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
+ TmpDT.Columns.Add("NoIdentificacion", GetType(String))
+ TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
+ TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
+ TmpDT.Columns.Add("Serie", GetType(String))
+ TmpDT.Columns.Add("CuentaPredial", GetType(String))
+ TmpDT.Columns.Add("Obs", GetType(String))
+ TmpDT.Columns.Add("TiempoEntrega", GetType(String))
+ TmpDT.Columns.Add("PU", GetType(Decimal))
+ TmpDT.Columns.Add("IVA", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
+ TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
+ TmpDT.Columns.Add("IEPS", GetType(Decimal))
+ TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
+ TmpDT.Columns.Add("Descuento", GetType(Decimal))
+ TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
+ TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
+ TmpDT.Columns.Add("Total", GetType(Decimal))
+ 'Para uso del módulo contable
+ TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
+ TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
+ TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
+ TmpDT.Columns.Add("CveProyecto", GetType(Integer))
+ TmpDT.Columns.Add("Proyecto", GetType(String))
+ TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
+ TmpDT.Columns.Add("SubProyecto", GetType(String))
+ TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer))
+ 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
+ TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
+ TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
+ 'Contratos
+ TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
+ 'Remisiones a Facturas
+ TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
+ TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
+ TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
+ 'Pedido2 a Facturas
+ TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
+ TmpDT.Columns.Add("Origen", GetType(Integer))
+ 'Ordenes Servicio
+ TmpDT.Columns.Add("CveOS", GetType(Integer))
+ TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
+ TmpDT.Columns.Add("SeFacturara", GetType(Integer))
+ TmpDT.Columns.Add("Folio", GetType(Integer))
+ TmpDT.Columns.Add("Estatus", GetType(String))
+ 'Ordenamiento
+ TmpDT.Columns.Add("Orden", GetType(Integer))
+ TmpDT.Columns.Add("TipoDocto", GetType(String))
+ 'OC
+ TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
+ TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
+ TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
+ TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
+ TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
+ TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal))
+ TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
+ TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
+ TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
+ TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
+ TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
+ TmpDT.Columns.Add("CveTamaño", GetType(Integer))
+ TmpDT.Columns.Add("EsCargo", GetType(Boolean))
+
+ Return TmpDT
+ End Function
+ Private Function InicializaDTVentasNCProntoPago() As DataTable
+ Dim DtVentasNC = New DataTable
+ DtVentasNC.Columns.Add("CveVenta", GetType(Integer))
+ DtVentasNC.Columns.Add("Importe", GetType(Decimal))
+ DtVentasNC.Columns.Add("FolioFiscal", GetType(String))
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TC", .DataType = GetType(Decimal), .DefaultValue = 1})
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TCCambioValuacion", .DataType = GetType(Decimal), .DefaultValue = 1})
+ DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "CveEstatusFactura", .DataType = GetType(Integer), .DefaultValue = -1})
+
+ Return DtVentasNC
+ End Function
+
+ Public Class MensajeProntoPago
+ Public Property ObjFacturaProntoPago As Modelos.Factura
+ Public Property Mensaje As Modelos.Factura.MMensajeFactura
+ End Class
+
+#End Region
+
End Class
\ No newline at end of file