VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "C_CIERRE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Function OBTIENERESUMEN_PLAYA_CIERREX(TURNO As Integer, FECHA As Date, PTOVTA As String, RESU As Integer) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " RESU_PLAYA_CIERREX_PROC " & TURNO & ",'" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'," & RESU


rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENERESUMEN_PLAYA_CIERREX = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENERESUMEN_PLAYA_CIERREX", Err.Description
  
End Function

Public Function OBTIENECABECERA_PLAYA_CIERREX(TURNO As Integer, FECHA As Date, PTOVTA As String) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " CABECERA_PLAYA_CIERREX_PROC " & TURNO & ",'" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'"

rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENECABECERA_PLAYA_CIERREX = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENECABECERA_PLAYA_CIERREX", Err.Description

End Function

Public Function OBTIENERESUMEN_PLAYA_CIERREZ(FECHA As Date, PTOVTA As String, RESU As Integer) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " RESU_PLAYA_CIERREZ_PROC '" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'," & RESU

rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENERESUMEN_PLAYA_CIERREZ = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENERESUMEN_PLAYA_CIERREZ", Err.Description
  
End Function

Public Function OBTIENECABECERA_PLAYA_CIERREZ(FECHA As Date, PTOVTA As String) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " CABECERA_PLAYA_CIERREZ_PROC '" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'"

rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENECABECERA_PLAYA_CIERREZ = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENECABECERA_PLAYA_CIERREZ", Err.Description

End Function


Public Function OBTIENERESUMEN_TIENDA_CIERREX(VENDEDOR As String, FECHA As Date, PTOVTA As String, RESU As Integer) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " RESU_TIENDA_CIERREX_PROC '" & VENDEDOR & "','" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'," & RESU

rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENERESUMEN_TIENDA_CIERREX = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENERESUMEN_TIENDA_CIERREX", Err.Description
  
End Function

Public Function OBTIENECABECERA_TIENDA_CIERREX(VENDEDOR As String, FECHA As Date, PTOVTA As String) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " CABECERA_TIENDA_CIERREX_PROC '" & VENDEDOR & "','" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'"

rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENECABECERA_TIENDA_CIERREX = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENECABECERA_TIENDA_CIERREZ", Err.Description

End Function

Public Function OBTIENERESUMEN_TIENDA_CIERREZ(FECHA As Date, PTOVTA As String, RESU As Integer) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " RESU_TIENDA_CIERREZ_PROC '" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'," & RESU

rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENERESUMEN_TIENDA_CIERREZ = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENERESUMEN_TIENDA_CIERREZ", Err.Description
  
End Function

Public Function OBTIENECABECERA_TIENDA_CIERREZ(FECHA As Date, PTOVTA As String) As ADODB.Recordset
Dim StrSql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

On Error GoTo errhandler

StrSql = " CABECERA_TIENDA_CIERREZ_PROC '" & Format(FECHA, "DD/MM/YYYY") & "','" & PTOVTA & "'"

rs.CursorLocation = adUseClient
rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

Set OBTIENECABECERA_TIENDA_CIERREZ = rs

GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "OBTIENECABECERA_TIENDA_CIERREZ", Err.Description

End Function


Public Sub Actualizar_Datos_LuegodeCierreX(StrNroPtoVta As String, IntLugar As Integer, _
                                    IntTurno As Integer, datFechaCierre As Date, StrSalesperId As String)
                                    
Dim cmd As ADODB.Command
Dim StrSql As String
        
On Error GoTo errhandler

    StrSql = "ACTUALIZA_DATOS_LUEGODECIERREX '" & StrNroPtoVta & "'," & IntLugar & "," & IntTurno & ",'" & StrSalesperId & "','" & Format(datFechaCierre, "DD/MM/YYYY") & "'"
        
    Set cmd = New ADODB.Command
        
    cmd.CommandText = StrSql
    cmd.ActiveConnection = "FILEDSN=conexionsies"
    cmd.Execute

    GetObjectContext.SetComplete
    
    Exit Sub
        
errhandler:

    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "CierreX.Actualizar_Datos_LuegodeCierreX", Err.Description
End Sub

Sub Actualizar_Datos_LuegodeCierreZ(StrNroPtoVta As String, datFechaCierre As Date, _
                                    DblGranTotal As Double, IntNroZeta As Integer)
    Dim cmd As ADODB.Command
    Dim StrSql As String
    
On Error GoTo errhandler
    
    StrSql = "ACTUALIZA_DATOS_LUEGODECIERREZ " & _
    "'" & StrNroPtoVta & "','" & Format(datFechaCierre, "DD/MM/YYYY") & "'," & DblGranTotal & "," & IntNroZeta
        
    Set cmd = New ADODB.Command
        
    cmd.CommandText = StrSql
    cmd.ActiveConnection = "FILEDSN=conexionsies"
    cmd.Execute
    
    GetObjectContext.SetComplete
    Exit Sub
errhandler:
    
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "CierreZ.Actualiza_Datos_Zeta", Err.Description
End Sub

' Esta funcion verifica si existen transacciones no facturadas en OP_TRAN
' recibe un recordset con los registros no cancelados de los tran de GASBOY
Function Tran_Facturado(ByVal rstran As ADODB.Recordset) As Boolean
    Dim rs As ADODB.Recordset
    Dim StrSql As String
    
    Set rs = New ADODB.Recordset
    
    Tran_Facturado = True
    
    Do While Not rstran.EOF
        StrSql = "Select * from OP_TRAN " & _
        "where " & _
        " numero='" & Trim(rstran!numero) & "' and " & _
        " soles='" & Trim(rstran!soles) & "' and " & _
        " producto='" & Trim(rstran!producto) & "' and " & _
        " precio='" & Trim(rstran!precio) & "' and " & _
        " galones='" & Trim(rstran!galones) & "' and " & _
        " cara='" & Trim(rstran!cara) & "' and " & _
        " fecha='" & Trim(rstran!FECHA) & "' and " & _
        " hora='" & Trim(rstran!hora) & "' and " & _
        " turno='" & Trim(rstran!hora) & "' and " & _
        " estado='" & Trim(rstran!estado) & "'"
        
        rs.Open StrSql, "FILEDSN=conexionsies", adOpenStatic
        
        If Not rs.EOF Then
            If Not IsNull(rs!numero) And Not IsNull(rs!TURNO) Then
                Tran_Facturado = False ' SE ENCONTRRO UN TRANSACCION NO FACTURADA
                Exit Function
            End If
        End If
        
        rstran.MoveNext
        rs.Close
     Loop
    
    GetObjectContext.SetComplete
    Exit Function
erryhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "Tran_Facturado", Err.Description
End Function


Function ObtenerCarasdePtovta(ByVal StrNroPtoVta As String) As ADODB.Recordset
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim StrSql As String

    
On Error GoTo errhandler
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    StrSql = "select side from OP_SalesPointVSSide where SalesPoint='" & StrNroPtoVta & "'"
        
    rs.Open StrSql, con, adOpenStatic
                
    Set ObtenerCarasdePtovta = rs
    
        
    GetObjectContext.SetComplete
    Exit Function
    
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    If Not con Is Nothing Then
        Set con = Nothing
    End If
    
    GetObjectContext.SetAbort

    Err.Raise Err.Number, "ObtenerCarasdePtovta", Err.Description
End Function


Public Function Auxiliar1(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim StrSql As String

    
On Error GoTo errhandler
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    StrSql = "OP_SECUENCIA_CIERREX_PROC '" & VarAux1 & "'"
        
    rs.Open StrSql, con, adOpenStatic
                
    Set Auxiliar1 = rs
    
        
    GetObjectContext.SetComplete
    Exit Function
    
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    If Not con Is Nothing Then
        Set con = Nothing
    End If
    
    GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar1", Err.Description
End Function

Public Function Auxiliar2(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    
    Dim StrSql As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    
    On Error GoTo errhandler
    
    StrSql = " PLAYA_CIERREX_VEND_PROC " & VarAux1(1, 1) & ",'" & Format(VarAux1(1, 2), "DD/MM/YYYY") & "','" & VarAux1(1, 3) & "'," & VarAux1(1, 4) & ",'" & VarAux1(1, 5) & "'"
    
    
    rs.CursorLocation = adUseClient
    rs.Open StrSql, "FILEDSN=Conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    Set Auxiliar2 = rs

    GetObjectContext.SetComplete
    
Exit Function
        
errhandler:

    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "C_CIERRE.Auxiliar2", Err.Description
    
End Function

Public Function Auxiliar3(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar3", Err.Description
End Function

Public Function Auxiliar4(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar4", Err.Description
End Function

Public Function Auxiliar5(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar5", Err.Description
End Function


Public Function Auxiliar6(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar6", Err.Description
End Function

Public Function Auxiliar7(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar7", Err.Description
End Function

Public Function Auxiliar8(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar8", Err.Description
End Function

Public Function Auxiliar9(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar9", Err.Description
End Function

Public Function Auxiliar10(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_OP_FACTURACION.C_CIERRE.Auxiliar10", Err.Description
End Function







