EMD - OC Autorizadas, registrar prepóliza 154 Cargo, 152 Abono
This commit is contained in:
117
OC/OC.aspx.vb
117
OC/OC.aspx.vb
@@ -6,6 +6,7 @@ Imports System.Data.SqlClient
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
Imports Microsoft.Owin.Security.Provider
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Partial Class OC_OC
|
||||
@@ -2852,6 +2853,14 @@ Partial Class OC_OC
|
||||
End If
|
||||
|
||||
|
||||
If Not TieneError AndAlso TipoOC = "OC" Then
|
||||
|
||||
If Not GeneraPrePolizaPresupuesto(CveOrdenCompra, OC.IniciaTransacSQL) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
If Conta IsNot Nothing Then Conta.Commit()
|
||||
OC.Commit()
|
||||
@@ -3304,6 +3313,7 @@ Partial Class OC_OC
|
||||
|
||||
'TERMINA TODO POR SI OCURRIÓ ALGO RARO
|
||||
If TieneError Then
|
||||
|
||||
If OC IsNot Nothing Then OC.RollBack()
|
||||
If UsuarioActual.Empresa.UsaAC AndAlso VerificaPresupuesto Then
|
||||
If Conta IsNot Nothing Then Conta.RollBack()
|
||||
@@ -3505,6 +3515,16 @@ Partial Class OC_OC
|
||||
|
||||
End If
|
||||
|
||||
|
||||
If Not HuboError AndAlso UsuarioActual.Empresa.Funcionalidad(532) = "1" Then
|
||||
|
||||
If Not GeneraPrePolizaPresupuesto(objOrdenCompra.CveOrdenCompra, objOrdenCompra.IniciaTransacSQL) Then
|
||||
HuboError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
HuboError = True
|
||||
End Try
|
||||
@@ -9027,22 +9047,6 @@ Partial Class OC_OC
|
||||
|
||||
If resultadosFiltrados.Count > 0 Then
|
||||
|
||||
Dim EnumAgrupado = (From row In DtDetalle.AsEnumerable()
|
||||
Group row By
|
||||
SubProyecto = row.Field(Of String)("SubProyecto"),
|
||||
CveSubProyecto = row.Field(Of Integer)("CveSubProyecto"),
|
||||
Clasificacion = row.Field(Of String)("Clasificacion"),
|
||||
CveClasificacion = row.Field(Of Integer)("CveClasificacion")
|
||||
Into Group
|
||||
Select New With {
|
||||
.SubProyecto = SubProyecto,
|
||||
.CveSubProyecto = CveSubProyecto,
|
||||
.Clasificacion = Clasificacion,
|
||||
.CveClasificacion = CveClasificacion,
|
||||
.TotalSum = Group.Sum(Function(r) If(IsDBNull(r("Total")), 0D, Convert.ToDecimal(r("Total"))))
|
||||
}).ToList()
|
||||
|
||||
|
||||
If Opcion = 1 Then
|
||||
|
||||
|
||||
@@ -9075,6 +9079,22 @@ Partial Class OC_OC
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
Dim EnumAgrupado = (From row In DtDetalle.AsEnumerable()
|
||||
Group row By
|
||||
SubProyecto = row.Field(Of String)("SubProyecto"),
|
||||
CveSubProyecto = row.Field(Of Integer)("CveSubProyecto"),
|
||||
Clasificacion = row.Field(Of String)("Clasificacion"),
|
||||
CveClasificacion = row.Field(Of Integer)("CveClasificacion")
|
||||
Into Group
|
||||
Select New With {
|
||||
.SubProyecto = SubProyecto,
|
||||
.CveSubProyecto = CveSubProyecto,
|
||||
.Clasificacion = Clasificacion,
|
||||
.CveClasificacion = CveClasificacion,
|
||||
.TotalSum = Group.Sum(Function(r) If(IsDBNull(r("Total")), 0D, Convert.ToDecimal(r("Total"))))
|
||||
}).ToList()
|
||||
|
||||
For Each item In EnumAgrupado
|
||||
|
||||
Dim tieneRegistrosConCveSubProyecto As Boolean = resultadosFiltrados.Any(Function(row) CType(row("CveSubProyecto"), Integer) = item.CveSubProyecto)
|
||||
@@ -9105,6 +9125,7 @@ Partial Class OC_OC
|
||||
respuesta = True
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
@@ -9130,6 +9151,70 @@ Partial Class OC_OC
|
||||
End Function
|
||||
|
||||
|
||||
Private Function GeneraPrePolizaPresupuesto(CveOrdenCompraPrePoliza As Integer, Optional ByRef transaccion As SqlTransaction = Nothing) As Boolean
|
||||
|
||||
Dim Respuesta As Boolean = True
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then
|
||||
|
||||
Dim ObjConta As New ClsContabilidad()
|
||||
|
||||
If transaccion Is Nothing Then
|
||||
ObjConta = New ClsContabilidad(Nothing)
|
||||
Else
|
||||
ObjConta = New ClsContabilidad(transaccion)
|
||||
End If
|
||||
|
||||
|
||||
Dim CvePrePolizaPreSuPuesto = ObjConta.AddPrePolizas("OC/OC-(Presupuesto)", 53, LblTotal.Text.ToDecimal, LblTotal.Text.ToDecimal, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, DdlProveedores.SelectedText, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
If CvePrePolizaPreSuPuesto > 0 Then
|
||||
|
||||
Dim EnumAgrupado = (From row In DtDetalle.AsEnumerable()
|
||||
Group row By
|
||||
SubProyecto = row.Field(Of String)("SubProyecto"),
|
||||
CveSubProyecto = row.Field(Of Integer)("CveSubProyecto"),
|
||||
Clasificacion = row.Field(Of String)("Clasificacion"),
|
||||
CveClasificacion = row.Field(Of Integer)("CveClasificacion")
|
||||
Into Group
|
||||
Select New With {
|
||||
.SubProyecto = SubProyecto,
|
||||
.CveSubProyecto = CveSubProyecto,
|
||||
.Clasificacion = Clasificacion,
|
||||
.CveClasificacion = CveClasificacion,
|
||||
.TotalSum = Group.Sum(Function(r) If(IsDBNull(r("Total")), 0D, Convert.ToDecimal(r("Total"))) + If(IsDBNull(r("IVA")), 0D, Convert.ToDecimal(r("IVA"))) + If(IsDBNull(r("IEPSPSIVA")), 0D, Convert.ToDecimal(r("IEPSPSIVA"))) - If(IsDBNull(r("RetIVA")), 0D, Convert.ToDecimal(r("RetIVA"))) - If(IsDBNull(r("RetISR")), 0D, Convert.ToDecimal(r("RetISR"))))
|
||||
}).ToList()
|
||||
|
||||
For Each item In EnumAgrupado
|
||||
|
||||
Dim SerieFolio = $"OC: {Folio}, Clasificación: {item.Clasificacion}"
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaPreSuPuesto, False, item.TotalSum, item.TotalSum, 154, SerieFolio, SerieFolio, CveProveedor:=DdlProveedores.SelectedValue.ToEntero, CveOC:=CveOrdenCompraPrePoliza, CveClasificacion:=item.CveClasificacion, CveSubProyecto:=item.CveSubProyecto, Contabilizable:=True) Then
|
||||
Respuesta = False
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaPreSuPuesto, True, item.TotalSum, item.TotalSum, 152, SerieFolio, SerieFolio, CveProveedor:=DdlProveedores.SelectedValue.ToEntero, CveOC:=CveOrdenCompraPrePoliza, CveClasificacion:=item.CveClasificacion, CveSubProyecto:=item.CveSubProyecto, Contabilizable:=True) Then
|
||||
Respuesta = False
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
Else
|
||||
Respuesta = False
|
||||
End If
|
||||
|
||||
|
||||
|
||||
End If
|
||||
|
||||
Return Respuesta
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user