--BDH, generar bonificaciones en base al subproyecto
This commit is contained in:
@@ -7,6 +7,7 @@ Imports System.Globalization
|
|||||||
Imports System.IO
|
Imports System.IO
|
||||||
Imports System.Net
|
Imports System.Net
|
||||||
Imports System.Net.Http
|
Imports System.Net.Http
|
||||||
|
Imports System.Security.Policy
|
||||||
Imports Extensiones
|
Imports Extensiones
|
||||||
Imports Microsoft.Reporting.WebForms
|
Imports Microsoft.Reporting.WebForms
|
||||||
Imports Newtonsoft.Json
|
Imports Newtonsoft.Json
|
||||||
@@ -209,14 +210,14 @@ Partial Class Clientes
|
|||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
Private Property ObjFactura As Modelos.Factura
|
'Private Property ObjFactura As Modelos.Factura
|
||||||
Get
|
' Get
|
||||||
Return CType(ViewState("ObjFactura"), Modelos.Factura)
|
' Return CType(ViewState("ObjFactura"), Modelos.Factura)
|
||||||
End Get
|
' End Get
|
||||||
Set(value As Modelos.Factura)
|
' Set(value As Modelos.Factura)
|
||||||
ViewState("ObjFactura") = value
|
' ViewState("ObjFactura") = value
|
||||||
End Set
|
' End Set
|
||||||
End Property
|
'End Property
|
||||||
|
|
||||||
Private Property CobranzaTelefono As String
|
Private Property CobranzaTelefono As String
|
||||||
Get
|
Get
|
||||||
@@ -309,14 +310,14 @@ Partial Class Clientes
|
|||||||
ViewState("DTPorcentajePrecios") = value
|
ViewState("DTPorcentajePrecios") = value
|
||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
Private Property TmpDT As DataTable
|
'Private Property TmpDT As DataTable
|
||||||
Get
|
' Get
|
||||||
Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable))
|
' Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable))
|
||||||
End Get
|
' End Get
|
||||||
Set(value As DataTable)
|
' Set(value As DataTable)
|
||||||
ViewState("TmpDT") = value
|
' ViewState("TmpDT") = value
|
||||||
End Set
|
' End Set
|
||||||
End Property
|
'End Property
|
||||||
Private Property DtPromociones As DataTable
|
Private Property DtPromociones As DataTable
|
||||||
Get
|
Get
|
||||||
Return If(IsNothing(ViewState("DtPromociones")), Nothing, CType(ViewState("DtPromociones"), DataTable))
|
Return If(IsNothing(ViewState("DtPromociones")), Nothing, CType(ViewState("DtPromociones"), DataTable))
|
||||||
@@ -664,7 +665,7 @@ Partial Class Clientes
|
|||||||
Actualizar = False
|
Actualizar = False
|
||||||
SetValues()
|
SetValues()
|
||||||
CargaCombos()
|
CargaCombos()
|
||||||
CreaDTVentas()
|
'CreaDTVentas()
|
||||||
CreaDtPago()
|
CreaDtPago()
|
||||||
RegistraScript("CargaHeader();")
|
RegistraScript("CargaHeader();")
|
||||||
CargaCombosDirecionesClientesSAT()
|
CargaCombosDirecionesClientesSAT()
|
||||||
@@ -9197,102 +9198,52 @@ Partial Class Clientes
|
|||||||
|
|
||||||
#Region " A C U M U L A D O R E S"
|
#Region " A C U M U L A D O R E S"
|
||||||
|
|
||||||
Protected Sub LnkFacturaUsadosCargos_Click(sender As Object, e As EventArgs)
|
|
||||||
'CveVentaNota = 0
|
|
||||||
|
|
||||||
'Dim Cargos As Decimal = 0D
|
|
||||||
'Dim Iva As Decimal = 0D
|
|
||||||
|
|
||||||
'For Each GvRow As GridViewRow In GvAcum.Rows
|
|
||||||
|
|
||||||
' If GvRow.DataKey("CveConcepto").Toentero() = 1 And GvRow.FCCheckBox("ChkCargo").Checked Then
|
|
||||||
' Cargos = Cargos + GvRow.DataKey("ImporteCargo").ToDecimal()
|
|
||||||
' End If
|
|
||||||
'Next
|
|
||||||
|
|
||||||
'Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).Toentero() 'CvePS Distruibuidor Cargo Nota
|
|
||||||
'Dim CveUnidadMedida As Integer
|
|
||||||
'Dim CveClasificacion As Integer
|
|
||||||
|
|
||||||
'If CvePS > 0 Then
|
|
||||||
|
|
||||||
' If Cargos > 0 Then
|
|
||||||
|
|
||||||
' CveUnidadMedida = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveUnidadMedida").ToString().Toentero()
|
|
||||||
' CveClasificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveClasificacion").ToString().Toentero()
|
|
||||||
' Iva = Cargos * 0.16D
|
|
||||||
|
|
||||||
' If GenerarNotaCredito(CvePS, 1, CveUnidadMedida, Cargos, Iva, "Clientes/Usados", CveClasificacion) Then
|
|
||||||
' Alert($"LA nota de crédito fue generada correctamente {SerieNotaAcumulador}-{FolioNotaAcumulador}")
|
|
||||||
' Else
|
|
||||||
' Alert("Se presento un error al generar la nota de creédito", TipoMensaje.MsgError)
|
|
||||||
' End If
|
|
||||||
' End If
|
|
||||||
|
|
||||||
'Else
|
|
||||||
' Alert("No esta asignada la funcionalidad CvePS Distruibuidor Cargo Nota")
|
|
||||||
'End If
|
|
||||||
|
|
||||||
CreaObjetosVenta(1)
|
|
||||||
|
|
||||||
'If ObjFactura.CveCliente > 0 Then
|
|
||||||
' If TmpDT.Rows.Count > 0 Then
|
|
||||||
' Dim Retorno = ObjFactura.EmitirFactura(false)
|
|
||||||
' For Each Mensaje In Retorno.Mensajes
|
|
||||||
' Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion))
|
|
||||||
' Next
|
|
||||||
' End If
|
|
||||||
'End If
|
|
||||||
|
|
||||||
CargaUsados()
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
Protected Sub LnkFacturaUsadosBonificacion_Click(sender As Object, e As EventArgs)
|
Protected Sub LnkFacturaUsadosBonificacion_Click(sender As Object, e As EventArgs)
|
||||||
|
|
||||||
'CveVentaNota = 0
|
Dim DtSubProyectos As DataTable = New DataTable()
|
||||||
'Dim Bonificacion As Decimal = 0D
|
DtSubProyectos.Columns.Add(New DataColumn("CveSubProyecto", GetType(Integer)))
|
||||||
'Dim Iva As Decimal = 0D
|
|
||||||
|
|
||||||
'For Each GvRow As GridViewRow In GvAcum.Rows
|
For Each GvRow As GridViewRow In GvAcum.Rows
|
||||||
' If GvRow.DataKey("CveConcepto").Toentero() = 1 And GvRow.FCCheckBox("ChkBonificacion").Checked Then
|
If GvRow.FCCheckBox("ChkBonificacion").Checked Then
|
||||||
' Bonificacion = Bonificacion + GvRow.DataKey("ImporteBonificacion").ToDecimal()
|
DtSubProyectos.Rows.Add(GvRow.DataKey("CveSubProyecto").ToEntero())
|
||||||
' End If
|
|
||||||
'Next
|
|
||||||
|
|
||||||
|
|
||||||
'Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).Toentero() 'CvePS Distruibuidor Bonificación Nota
|
|
||||||
'Dim CveUnidadMedida As Integer
|
|
||||||
'Dim CveClasificacion As Integer
|
|
||||||
'If CvePS > 0 Then
|
|
||||||
' If Bonificacion > 0 Then
|
|
||||||
|
|
||||||
' CveUnidadMedida = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveUnidadMedida").ToString().Toentero()
|
|
||||||
' CveClasificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveClasificacion").ToString().Toentero()
|
|
||||||
' Iva = Bonificacion * 0.16D
|
|
||||||
|
|
||||||
' If GenerarNotaCredito(CvePS, 2, CveUnidadMedida, Bonificacion, Iva, "Clientes/Usados", CveClasificacion) Then
|
|
||||||
' Alert($"LA nota de crédito fue generada correctamente {SerieNotaAcumulador}-{FolioNotaAcumulador}")
|
|
||||||
' Else
|
|
||||||
' Alert("Se presento un error al generar la nota de creédito", TipoMensaje.MsgError)
|
|
||||||
' End If
|
|
||||||
|
|
||||||
' End If
|
|
||||||
|
|
||||||
'Else
|
|
||||||
' Alert("No esta asignada la funcionalidad CvePS Distruibuidor Bonificación Nota")
|
|
||||||
'End If
|
|
||||||
|
|
||||||
CreaObjetosVenta(2)
|
|
||||||
|
|
||||||
If ObjFactura.CveCliente > 0 Then
|
|
||||||
If TmpDT.Rows.Count > 0 Then
|
|
||||||
Dim Retorno As Modelos.Factura.MMensajeFactura = ObjFactura.EmitirFactura(False)
|
|
||||||
For Each Mensaje As String In Retorno.Mensajes
|
|
||||||
Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion))
|
|
||||||
Next
|
|
||||||
End If
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
Dim StringFolios As New StringBuilder
|
||||||
|
Dim StringMsg As New StringBuilder
|
||||||
|
|
||||||
|
Dim ObjVentas As New ClsVentas
|
||||||
|
ObjVentas.IniciaTransacSQL()
|
||||||
|
|
||||||
|
Dim TieneError As Boolean = False
|
||||||
|
Try
|
||||||
|
For Each Row As DataRow In DtSubProyectos.FiltraParametros("", DistinctColumns:={"CveSubProyecto"}).Rows
|
||||||
|
Dim Resp = CreaObjetosVenta(2, Row("CveSubProyecto").ToString().ToEntero(), ObjVentas)
|
||||||
|
If Resp.TieneError Then
|
||||||
|
TieneError = True
|
||||||
|
StringMsg.Append("Ocurrió un error al generar la RNC de bonificación")
|
||||||
|
Exit For
|
||||||
|
Else
|
||||||
|
StringFolios.AppendFormat("<br/><b>{0}<b/>", Resp.SerieFolio)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
Catch ex As Exception
|
||||||
|
TieneError = True
|
||||||
|
StringMsg.Append("Ocurrió un error al generar la RNC de bonificación")
|
||||||
|
End Try
|
||||||
|
|
||||||
|
If TieneError Then
|
||||||
|
ObjVentas.RollBack()
|
||||||
|
Else
|
||||||
|
ObjVentas.Commit()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If Not TieneError AndAlso StringFolios.Length > 0 Then
|
||||||
|
StringMsg.AppendFormat("Se generaron las siguientes remisiones de nota de crédito de bonificación: {0}", StringFolios)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Alert(StringMsg.ToString(), If(TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion))
|
||||||
|
|
||||||
Alert("Listo")
|
Alert("Listo")
|
||||||
CargaUsados()
|
CargaUsados()
|
||||||
End Sub
|
End Sub
|
||||||
@@ -9420,8 +9371,8 @@ Partial Class Clientes
|
|||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub CreaDTVentas()
|
Private Function CreaDTVentas() As DataTable
|
||||||
TmpDT = New DataTable
|
Dim TmpDT = New DataTable
|
||||||
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Consec", GetType(Integer))
|
TmpDT.Columns.Add("Consec", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
||||||
@@ -9507,8 +9458,9 @@ Partial Class Clientes
|
|||||||
TmpDT.Columns.Add("CveTamaño", GetType(Integer))
|
TmpDT.Columns.Add("CveTamaño", GetType(Integer))
|
||||||
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
|
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
|
||||||
|
|
||||||
End Sub
|
Return TmpDT
|
||||||
Private Function AgregarProductoServicio(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
|
End Function
|
||||||
|
Private Function AgregarProductoServicio(ByRef TmpDT As DataTable, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
|
||||||
PU As Decimal, Descuento As Decimal,
|
PU As Decimal, Descuento As Decimal,
|
||||||
CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String,
|
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 Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0,
|
||||||
@@ -9630,16 +9582,15 @@ Partial Class Clientes
|
|||||||
Return Retorno
|
Return Retorno
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
Private Sub CreaObjetosVenta(Tipo As Integer)
|
Private Function CreaObjetosVenta(Tipo As Integer, CveSubProyecto As Integer, ByRef ObjVentas As ClsVentas) As Modelos.Factura.MMensajeFactura
|
||||||
|
Dim TmpDT As DataTable = CreaDTVentas()
|
||||||
Dim CveSubProyecto As Integer = -1
|
Dim UsadosBonificacion As List(Of Integer) = New List(Of Integer)
|
||||||
|
|
||||||
TmpDT.Rows.Clear()
|
TmpDT.Rows.Clear()
|
||||||
TmpDT.AcceptChanges()
|
TmpDT.AcceptChanges()
|
||||||
|
|
||||||
For Each GvRow As GridViewRow In GvAcum.Rows
|
For Each GvRow As GridViewRow In GvAcum.Rows
|
||||||
If GvRow.FCCheckBox("ChkBonificacion").Checked OrElse GvRow.FCCheckBox("ChkCargo").Checked Then
|
If GvRow.FCCheckBox("ChkBonificacion").Checked AndAlso GvRow.DataKey("CveSubProyecto").ToEntero() = CveSubProyecto Then
|
||||||
CveSubProyecto = GvRow.DataKey("CveSubProyecto").ToEntero()
|
|
||||||
|
|
||||||
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal
|
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal
|
||||||
Dim PU As Decimal = 0
|
Dim PU As Decimal = 0
|
||||||
@@ -9662,6 +9613,8 @@ Partial Class Clientes
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
If CvePSCargo > 0 AndAlso PU > 0 Then
|
If CvePSCargo > 0 AndAlso PU > 0 Then
|
||||||
|
Dim CveMovto As Integer = GvRow.DataKey("CveMovto").ToEntero()
|
||||||
|
|
||||||
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePSCargo).Rows(0)
|
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePSCargo).Rows(0)
|
||||||
If Dr IsNot Nothing Then
|
If Dr IsNot Nothing Then
|
||||||
CveUnidadMedida = Dr("CveUnidadMedida").ToString().ToEntero()
|
CveUnidadMedida = Dr("CveUnidadMedida").ToString().ToEntero()
|
||||||
@@ -9671,8 +9624,10 @@ Partial Class Clientes
|
|||||||
Clasificacion = Dr("Clasificacion").ToString()
|
Clasificacion = Dr("Clasificacion").ToString()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
AgregarProductoServicio(Cantidad, CveUnidadMedida, UnidadMedida, CveClasificacion, Clasificacion, CvePSCargo, PS, "Clientes/Usados", PU, 0, -1, "", DdlSubProyecto.SelectedValue.ToEntero(),
|
AgregarProductoServicio(TmpDT, Cantidad, CveUnidadMedida, UnidadMedida, CveClasificacion, Clasificacion, CvePSCargo, PS, "Clientes/Usados", PU, 0, -1, "", DdlSubProyecto.SelectedValue.ToEntero(),
|
||||||
DdlSubProyecto.SelectedItem.Text, PorcentajeIVA:=PorcentajeIVA)
|
DdlSubProyecto.SelectedItem.Text, PorcentajeIVA:=PorcentajeIVA)
|
||||||
|
|
||||||
|
UsadosBonificacion.Add(CveMovto)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@@ -9696,18 +9651,7 @@ Partial Class Clientes
|
|||||||
ObjFolios.Dispose()
|
ObjFolios.Dispose()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Dim ObjFactura = New Modelos.Factura(UsuarioActual)
|
||||||
'If FolioNotaCredito(Tipo) Then
|
|
||||||
' Folio = FolioNotaAcumulador
|
|
||||||
' Serie = SerieNotaAcumulador
|
|
||||||
'End If
|
|
||||||
|
|
||||||
If ObjFactura IsNot Nothing Then
|
|
||||||
ObjFactura.Dispose()
|
|
||||||
ObjFactura = Nothing
|
|
||||||
End If
|
|
||||||
|
|
||||||
ObjFactura = New Modelos.Factura(UsuarioActual)
|
|
||||||
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
||||||
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
||||||
ObjFactura.CveVenta = -1
|
ObjFactura.CveVenta = -1
|
||||||
@@ -9828,20 +9772,12 @@ Partial Class Clientes
|
|||||||
ObjFactura.CveTipoRelacion = -1
|
ObjFactura.CveTipoRelacion = -1
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim UsadosBonificacion As List(Of Integer) = New List(Of Integer)
|
|
||||||
For Each GvRow As GridViewRow In GvAcum.Rows
|
|
||||||
Dim CveMovto As Integer = GvRow.DataKey("CveMovto").ToEntero()
|
|
||||||
If (Tipo = 1 And GvRow.FCCheckBox("ChkCargo").Checked) Or (Tipo = 2 And GvRow.FCCheckBox("ChkBonificacion").Checked) Then
|
|
||||||
UsadosBonificacion.Add(CveMovto)
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
ObjFactura.UsadosBonificacion = UsadosBonificacion
|
ObjFactura.UsadosBonificacion = UsadosBonificacion
|
||||||
ObjFactura.TipoBonificacion = Tipo
|
ObjFactura.TipoBonificacion = Tipo
|
||||||
|
|
||||||
' ObjFactura.Timbre = PreParaTimbre(ObjFactura)
|
Return ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Clientes/Bonificacion", MostrarURL:=True)
|
||||||
|
|
||||||
End Sub
|
End Function
|
||||||
|
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|||||||
Reference in New Issue
Block a user