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_VENTASCSTORE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Function ObtenerDatosTMPSCTORE(ByVal DblCorrelativo As Double, ByVal IntRedondeo As Integer, Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
   Dim cmd As ADODB.Recordset
    
   On Error GoTo errhandler
   
   StrSql = " OP_MostrarDetalleVentasCSTOREProc " & DblCorrelativo & "," & IntRedondeo
                
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies", adOpenStatic
                
   Set ObtenerDatosTMPSCTORE = rs
      
   GetObjectContext.SetComplete
   Exit Function
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

   GetObjectContext.SetAbort
   Err.Raise Err.Number, "DB_OP_FACTURACION.ObtenerDatosTemporal", Err.Description
End Function
Public Function GrabarcstoreTmp(ByVal dou_CORRNBR As Double, ByVal str_DOCTYPEID As String, ByVal dou_NBRDOCUMENT As Double, _
                                ByVal str_SITEID As String, ByVal str_INVTIDSKU As String, _
                                ByVal str_CURYID As String, ByVal str_DATEDOC As String, _
                                ByVal str_DATEPROCESALES As String, ByVal dou_NBRTURN As Double, _
                                ByVal dou_PORCENTTAXIGV As Double, ByVal dou_PORCENTTAXISC As Double, _
                                ByVal dou_TOTALPEN As Double, _
                                ByVal dou_TOTALUSD As Double, ByVal dou_TAXPEN As Double, _
                                ByVal dou_TAXUSD As Double, _
                                ByVal byt_STKITEM As Byte, ByVal byt_STKFISI As Byte, _
                                ByVal dou_SLS_PRICE As Double, _
                                ByVal dou_SLSPRICESALE As Double, ByVal dou_STDCOSTPEN As Double, _
                                ByVal dou_STDCOSTUSD As Double, ByVal str_INVTIDALTER As String, _
                                ByVal dou_QTY As Double, _
                                ByVal STR_DESCR As String, ByVal strunidad As String, Optional VarAux As Variant)
On Error GoTo ErrorHandler
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim ERROR As ADODB.ERROR
Dim LSTR_CADENA As String

LSTR_CADENA = dou_CORRNBR & ",'" & str_DOCTYPEID & "'," & dou_NBRDOCUMENT & ",'" & _
                    str_SITEID & "','" & str_INVTIDSKU & "','" & str_CURYID & "','" & _
                    str_DATEDOC & "','" & str_DATEPROCESALES & "'," & _
                    dou_NBRTURN & "," & dou_PORCENTTAXIGV & "," & dou_PORCENTTAXISC & "," _
                    & dou_TOTALPEN & "," & dou_TOTALUSD & "," & dou_TAXPEN & "," & _
                    dou_TAXUSD & "," & byt_STKITEM & "," & byt_STKFISI & "," & _
                    dou_SLS_PRICE & "," & dou_SLSPRICESALE & "," & dou_STDCOSTPEN & "," & _
                    dou_STDCOSTUSD & ",'" & str_INVTIDALTER & "'," & dou_QTY & ",'" & _
                    STR_DESCR & "','" & strunidad & "'"

Set cmd = New ADODB.Command
cmd.CommandText = " Op_GrabarcstoreTmpProc " & LSTR_CADENA
Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"
Set cmd.ActiveConnection = con
cmd.Execute

GetObjectContext.SetComplete
Exit Function

ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_OP_FACTURACION.GrabarRegistroenDetalleTemporal", LStrMensajeError
End Function

Public Function ActualizaNCreditoDetalle(ByVal dou_CORRNBR As Double, ByVal int_nlin As Integer, _
                                         ByVal str_SITEID As String, ByVal str_INVTIDSKU As String, _
                                         ByVal dou_TOTALPEN As Double, ByVal dou_TOTALUSD As Double, _
                                         ByVal dou_TAXPEN As Double, ByVal dou_TAXUSD As Double, _
                                         ByVal DblDevuelto As Double, Optional VarAux As Variant)
                                
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim ERROR As ADODB.ERROR
Dim LSTR_CADENA As String

LSTR_CADENA = dou_CORRNBR & "," & int_nlin & ",'" & str_SITEID & "','" & str_INVTIDSKU & "'," & _
              dou_TOTALPEN & "," & dou_TOTALUSD & "," & _
              dou_TAXPEN & "," & dou_TAXUSD & "," & DblDevuelto

On Error GoTo ErrorHandler
Set cmd = New ADODB.Command
cmd.CommandText = " Op_actualizaNcreditoTmpProc   " & LSTR_CADENA
Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"
Set cmd.ActiveConnection = con
cmd.Execute

GetObjectContext.SetComplete
Exit Function

ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_OP_FACTURACION.Op_actualizaNcreditoTmpProc ", LStrMensajeError
                                
End Function



Public Function actualizarcstoreDetalle(ByVal dou_CORRNBR As Double, ByVal str_DOCTYPEID As String, _
                                ByVal dou_NBRDOCUMENT As Double, ByVal int_nlin As Integer, _
                                ByVal str_SITEID As String, ByVal str_INVTIDSKU As String, _
                                ByVal str_CURYID As String, ByVal str_DATEDOC As String, _
                                ByVal str_DATEPROCESALES As String, ByVal dou_NBRTURN As Double, _
                                ByVal dou_PORCENTTAXIGV As Double, ByVal dou_PORCENTTAXISC As Double, _
                                ByVal dou_TOTALPEN As Double, ByVal dou_TOTALUSD As Double, _
                                ByVal dou_TAXPEN As Double, ByVal dou_TAXUSD As Double, _
                                ByVal byt_STKITEM As Byte, ByVal byt_STKFISI As Byte, ByVal dou_SLS_PRICE As Double, _
                                ByVal dou_SLSPRICESALE As Double, ByVal dou_STDCOSTPEN As Double, _
                                ByVal dou_STDCOSTUSD As Double, ByVal str_INVTIDALTER As String, _
                                ByVal dou_QTY As Double, ByVal STR_DESCR As String, ByVal strunidad As String, Optional VarAux As Variant)

Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim ERROR As ADODB.ERROR
Dim LSTR_CADENA As String

LSTR_CADENA = dou_CORRNBR & ",'" & str_DOCTYPEID & "'," & dou_NBRDOCUMENT & "," & _
                    int_nlin & ",'" & str_SITEID & "','" & str_INVTIDSKU & "','" & _
                    str_CURYID & "','" & str_DATEDOC & "','" & str_DATEPROCESALES & "'," & _
                    dou_NBRTURN & "," & dou_PORCENTTAXIGV & "," & _
                    dou_PORCENTTAXISC & "," & dou_TOTALPEN & "," & dou_TOTALUSD & "," & _
                    dou_TAXPEN & "," & dou_TAXUSD & "," & byt_STKITEM & "," & byt_STKFISI & "," & _
                    dou_SLS_PRICE & "," & dou_SLSPRICESALE & "," & dou_STDCOSTPEN & "," & _
                    dou_STDCOSTUSD & ",'" & str_INVTIDALTER & "'," & dou_QTY & ",'" & _
                    STR_DESCR & "','" & strunidad & "'"

On Error GoTo ErrorHandler
Set cmd = New ADODB.Command
cmd.CommandText = " Op_actualizacstoreTmpProc  " & LSTR_CADENA
Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"
Set cmd.ActiveConnection = con
cmd.Execute

GetObjectContext.SetComplete
Exit Function

ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_OP_FACTURACION.actualizarcstoreDetalle", LStrMensajeError
End Function

Public Function eliminarcstoreDetalle(ByVal dou_CORRNBR As Double, ByVal dou_nlinea As Integer, Optional VarAux As Variant)

Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim ERROR As ADODB.ERROR
Dim LSTR_CADENA As String

LSTR_CADENA = dou_CORRNBR & "," & dou_nlinea

On Error GoTo ErrorHandler
Set cmd = New ADODB.Command
cmd.CommandText = " Op_EliminarDetTempcstore_Proc " & LSTR_CADENA
Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"
Set cmd.ActiveConnection = con
cmd.Execute

GetObjectContext.SetComplete
Exit Function

ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_OP_FACTURACION.actualizarcstoreDetalle", LStrMensajeError
End Function
Public Sub borrartransgrabadas(ByVal dou_CORRNBR As Double, Optional VarAux As Variant)

Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim ERROR As ADODB.ERROR

On Error GoTo ErrorHandler
Set cmd = New ADODB.Command
cmd.CommandText = " Op_borrartransgrabadas " & dou_CORRNBR
Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"
Set cmd.ActiveConnection = con
cmd.Execute

GetObjectContext.SetComplete
Exit Sub

ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_OP_FACTURACION.borrartransgrabadas", LStrMensajeError
End Sub
Public Function obtenercabezeratransgrabadas(ByVal DblCorrelativo As Double, Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
   Dim cmd As ADODB.Recordset
    
   On Error GoTo errhandler
   
   StrSql = " op_obtenercabezeratransgrabadas " & DblCorrelativo
                
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies", adOpenStatic
                
   Set obtenercabezeratransgrabadas = rs
      
   GetObjectContext.SetComplete
   Exit Function
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

   GetObjectContext.SetAbort
   Err.Raise Err.Number, "DB_OP_FACTURACION.obtenercabezeratransgrabadas ", Err.Description
End Function
Public Function grabarventa(ByVal CORRNBR As Double, ByVal DOCTYPEID As String, ByVal NBRDOCUMENT As Double, _
            ByVal TYPEPAYMENTID As String, ByVal STKINVENTORY As Byte, ByVal SITEID As String, _
            ByVal CURYID As String, ByVal TERMID As String, ByVal SALESPERID As String, _
            ByVal USERID As String, ByVal DATEDOC As String, ByVal DATEPROCESALES As String, _
            ByVal TAXIGVID As String, ByVal TAXISCID As String, _
            ByVal TOTALPEN As Double, ByVal TOTALUSD As Double, ByVal SUBTOTALPEN As Double, _
            ByVal SUBTOTALUSD As Double, ByVal TAXIGVPEN As Double, ByVal TAXIGVUSD As Double, _
            ByVal TAXISCPEN As Double, ByVal TAXISCUSD As Double, ByVal TOTALNOTAFFECTPEN As Double, _
            ByVal TOTALNOTAFFECTUSD As Double, _
            ByVal PORCENTDISCOUNT1 As Double, ByVal PORCENTDISCOUNT2 As Double, _
            ByVal TOTDISCOUNTPEN As Double, ByVal TOTDISCOUNTUSD As Double, _
            ByVal TOTRETURNEDPEN As Double, ByVal TOTRETURNEDUSD As Double, _
            ByVal TOTCASHPEN As Double, ByVal TOTCASHUSD As Double, _
            ByVal Custidss As String, ByVal taxregnbr As String, ByVal CUSTNAME As String, _
            ByVal PLACA As String, ByVal NBRBONUS As Double, ByVal CURYTYPEID As String, _
            ByVal CURYRATE As Double, ByVal PROMOTIONCARDID As String, _
            ByVal POINTNUMBER As Integer, ByVal SALESPOINT As String, _
            ByVal KILOMETRAJE As Integer, ByVal businesstype As String, _
            ByVal tipoventa As String, Optional ByVal IntAdelanto As Integer = 0, Optional VarAux As Variant) As Integer
   
Dim StrSql As String
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Recordset
    
On Error GoTo errhandler

StrSql = " OP_GRABARVENTACSTORE " & CORRNBR & ",'" & DOCTYPEID & "','" & _
                                   NBRDOCUMENT & "','" & TYPEPAYMENTID & "'," & STKINVENTORY & ",'" & _
                                   SITEID & "','" & CURYID & "','" & TERMID & "','" & SALESPERID & "','" & _
                                   USERID & "','" & DATEDOC & "','" & DATEPROCESALES & "','" & _
                                   TAXIGVID & "','" & TAXISCID & "'," & TOTALPEN & "," & _
                                   TOTALUSD & "," & SUBTOTALPEN & "," & SUBTOTALUSD & "," & _
                                   TAXIGVPEN & "," & TAXIGVUSD & "," & TAXISCPEN & "," & TAXISCUSD & "," & _
                                   TOTALNOTAFFECTPEN & "," & TOTALNOTAFFECTUSD & "," & _
                                   PORCENTDISCOUNT1 & "," & PORCENTDISCOUNT2 & "," & TOTDISCOUNTPEN & "," & _
                                    TOTDISCOUNTUSD & "," & TOTRETURNEDPEN & "," & _
                                   TOTRETURNEDUSD & "," & TOTCASHPEN & "," & TOTCASHUSD & ",'" & _
                                   Custidss & "','" & taxregnbr & "','" & CUSTNAME & "','" & PLACA & "'," & _
                                   NBRBONUS & ",'" & CURYTYPEID & "'," & CURYRATE & ",'" & PROMOTIONCARDID & _
                                   "'," & POINTNUMBER & ",'" & SALESPOINT & "'," & KILOMETRAJE & ",'" & _
                                   businesstype & "','" & tipoventa & "'," & IntAdelanto

   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies", adOpenStatic
    
    If Not IsNull(rs) Then
         grabarventa = IIf(rs.Fields(0) = "OK", 0, 1)
     Else
        grabarventa = 1
      End If
   GetObjectContext.SetComplete
   Exit Function
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

   GetObjectContext.SetAbort
   Err.Raise Err.Number, "DB_OP_FACTURACION.ObtenerDatosTemporal", Err.Description
   
End Function

Public Sub OP_AGREGACLIENTECSTORE(ByVal Custidss As String, ByVal taxregnbr As String, _
                                ByVal CUSTNAME As String, ByVal addr1 As String, _
                                ByVal dateproc As Date, ByVal USERID As String, Optional VarAux As Variant)

Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim ERROR As ADODB.ERROR


On Error GoTo ErrorHandler
Set cmd = New ADODB.Command
cmd.CommandText = " OP_AGREACLIENTECSTORE '" & Custidss & "','" & taxregnbr & "','" & _
                                CUSTNAME & "','" & addr1 & "','" & dateproc & "','" & USERID & "'"
Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"
Set cmd.ActiveConnection = con
cmd.Execute

GetObjectContext.SetComplete
Exit Sub

ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_OP_FACTURACION.borrartransgrabadas", LStrMensajeError
End Sub

Public Function ObtenerDatosTMPnc(ByVal DblCorrelativo As Double, ByVal IntRedondeo As Integer, Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
   Dim cmd As ADODB.Recordset
    
   On Error GoTo errhandler
   
   StrSql = " OP_MostrarDetalleNCProc " & DblCorrelativo & "," & IntRedondeo
   'OP_MostrarDetalleNCProc
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies", adOpenStatic
                
   Set ObtenerDatosTMPnc = rs
      
   GetObjectContext.SetComplete
   Exit Function
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

   GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_OP_FACTURACION.ObtenerDatosTemporal", Err.Description
End Function



Public Function Auxiliar1(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_VENTASCSTORE.Auxiliar1", Err.Description
End Function

Public Function Auxiliar2(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_VENTASCSTORE.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_VENTASCSTORE.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_VENTASCSTORE.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_VENTASCSTORE.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_VENTASCSTORE.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_VENTASCSTORE.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_VENTASCSTORE.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_VENTASCSTORE.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_VENTASCSTORE.Auxiliar10", Err.Description
End Function


