object srvComisiones: TsrvComisiones
  OldCreateOrder = True
  OnCreate = DARemoteServiceCreate
  RequiresSession = True
  SessionManager = dmServer.SessionManager
  AcquireConnection = True
  ConnectionName = 'IBX'
  ServiceSchema = schComisiones
  ServiceAdapter = DABINAdapter
  OnBeforeAcquireConnection = DARemoteServiceBeforeAcquireConnection
  Height = 249
  Width = 343
  object Diagrams: TDADiagrams
    Left = 150
    Top = 74
    DiagramData = '<Diagrams>'#13#10'</Diagrams>'#13#10
  end
  object DataDictionary: TDADataDictionary
    Fields = <
      item
        Name = 'Comisiones_ID'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_DESCRIPCION'
        DataType = datString
        Size = 255
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'DESCRIPCION'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_FECHA'
        DataType = datDateTime
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'FECHA'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_USUARIO'
        DataType = datString
        Size = 20
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'USUARIO'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_ID_EMPRESA'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_EMPRESA'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_REFERENCIA'
        DataType = datString
        Size = 255
        BlobType = dabtUnknown
        DisplayWidth = 0
        Alignment = taLeftJustify
        ServerAutoRefresh = True
      end
      item
        Name = 'Facturas_Comision_ID_CLIENTE'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        Alignment = taLeftJustify
      end
      item
        Name = 'Facturas_Comision_CLIENTE'
        DataType = datString
        Size = 255
        BlobType = dabtUnknown
        DisplayWidth = 0
        Alignment = taLeftJustify
      end
      item
        Name = 'Facturas_Comision_IMPORTE_COMISIONABLE'
        DataType = datCurrency
        BlobType = dabtUnknown
        DisplayWidth = 0
        Alignment = taRightJustify
      end
      item
        Name = 'Facturas_Comision_IMPORTE_COMISION'
        DataType = datCurrency
        BlobType = dabtUnknown
        DisplayWidth = 0
        Alignment = taRightJustify
      end
      item
        Name = 'Comisiones_Detalles_ID_EMPRESA'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_EMPRESA'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_ID_AGENTE'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_AGENTE'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_AGENTE'
        DataType = datString
        Size = 255
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'AGENTE'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_ID_FACTURA'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_FACTURA'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_FECHA'
        DataType = datDateTime
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'FECHA'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_REFERENCIA'
        DataType = datString
        Size = 255
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'REFERENCIA'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_SITUACION'
        DataType = datString
        Size = 19
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'SITUACION'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_ID_PROVEEDOR'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_PROVEEDOR'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_PROVEEDOR'
        DataType = datString
        Size = 255
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'PROVEEDOR'
        Alignment = taLeftJustify
      end
      item
        Name = 'Comisiones_Detalles_COMISION'
        DataType = datFloat
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'COMISION'
        Alignment = taLeftJustify
      end
      item
        Name = 'V_Detalles_Facturas_Comision_ID_COMISION_LIQUIDADA'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_COMISION_LIQUIDADA'
        Alignment = taLeftJustify
      end
      item
        Name = 'V_Detalles_Facturas_Comision_IMPORTE_COMISIONABLE'
        DataType = datCurrency
        BlobType = dabtUnknown
        DisplayWidth = 0
        Alignment = taRightJustify
      end
      item
        Name = 'V_Detalles_Facturas_Comision_IMPORTE_COMISION'
        DataType = datCurrency
        BlobType = dabtUnknown
        DisplayWidth = 0
        Alignment = taRightJustify
      end
      item
        Name = 'Facturas_Comision_ID_COMISION_LIQUIDADA'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_COMISION_LIQUIDADA'
        Alignment = taLeftJustify
      end
      item
        Name = 'Facturas_Comision_ID'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID'
        Alignment = taLeftJustify
      end
      item
        Name = 'V_Detalles_Facturas_Comision_ID'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID'
        Alignment = taLeftJustify
      end
      item
        Name = 'Facturas_Comision_ID_FACTURA'
        DataType = datInteger
        BlobType = dabtUnknown
        DisplayWidth = 0
        DisplayLabel = 'ID_FACTURA'
        Alignment = taLeftJustify
      end>
    Left = 150
    Top = 22
  end
  object schComisiones: TDASchema
    ConnectionManager = dmServer.ConnectionManager
    DataDictionary = DataDictionary
    Diagrams = Diagrams
    Datasets = <
      item
        Params = <
          item
            Name = 'ID_COMISION'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'V_AGENTES_COMISIONES_DET_FAC'
            SQL = 
              'select V_AGENTES_COMISIONES_DET_FAC.ID_EMPRESA,'#10'       V_AGENTES' +
              '_COMISIONES_DET_FAC.ID_AGENTE, CONTACTOS1.NOMBRE as AGENTE,'#10'    ' +
              '   V_AGENTES_COMISIONES_DET_FAC.ID_FACTURA,'#10'       V_AGENTES_COM' +
              'ISIONES_DET_FAC.ID_COMISION_LIQUIDADA,'#10'       V_AGENTES_COMISION' +
              'ES_DET_FAC.FECHA,'#10'       V_AGENTES_COMISIONES_DET_FAC.REFERENCIA' +
              ','#10'       V_AGENTES_COMISIONES_DET_FAC.SITUACION,'#10'       V_AGENTE' +
              'S_COMISIONES_DET_FAC.ID_CLIENTE,'#10'       CONTACTOS2.NOMBRE as CLI' +
              'ENTE,'#10'       V_AGENTES_COMISIONES_DET_FAC.ID_PROVEEDOR,'#10'       C' +
              'ONTACTOS3.NOMBRE as PROVEEDOR,'#10'       V_AGENTES_COMISIONES_DET_F' +
              'AC.COMISION,'#10'       SUM(V_AGENTES_COMISIONES_DET_FAC.IMPORTE_TOT' +
              'AL)as IMPORTE_COMISIONABLE,'#10'       SUM(V_AGENTES_COMISIONES_DET_' +
              'FAC.IMPORTE_COMISION) as IMPORTE_COMISION'#10#10'from V_AGENTES_COMISI' +
              'ONES_DET_FAC'#10'LEFT JOIN CONTACTOS CONTACTOS1 ON (CONTACTOS1.ID = ' +
              'V_AGENTES_COMISIONES_DET_FAC.ID_AGENTE)'#10'LEFT JOIN CONTACTOS CONT' +
              'ACTOS2 ON (CONTACTOS2.ID = V_AGENTES_COMISIONES_DET_FAC.ID_CLIEN' +
              'TE)'#10'LEFT JOIN CONTACTOS CONTACTOS3 ON (CONTACTOS3.ID = V_AGENTES' +
              '_COMISIONES_DET_FAC.ID_PROVEEDOR)'#10'WHERE V_AGENTES_COMISIONES_DET' +
              '_FAC.ID_COMISION_LIQUIDADA = :ID_COMISION'#10'GROUP BY 1, 2, 3, 4, 5' +
              ', 6, 7, 8, 9, 10, 11, 12, 13'
            StatementType = stSQL
            ColumnMappings = <
              item
                DatasetField = 'ID_EMPRESA'
                TableField = 'ID_EMPRESA'
              end
              item
                DatasetField = 'ID_AGENTE'
                TableField = 'ID_AGENTE'
              end
              item
                DatasetField = 'AGENTE'
                TableField = 'AGENTE'
              end
              item
                DatasetField = 'FECHA'
                TableField = 'FECHA'
              end
              item
                DatasetField = 'REFERENCIA'
                TableField = 'REFERENCIA'
              end
              item
                DatasetField = 'SITUACION'
                TableField = 'SITUACION'
              end
              item
                DatasetField = 'ID_PROVEEDOR'
                TableField = 'ID_PROVEEDOR'
              end
              item
                DatasetField = 'PROVEEDOR'
                TableField = 'PROVEEDOR'
              end
              item
                DatasetField = 'COMISION'
                TableField = 'COMISION'
              end
              item
                DatasetField = 'ID_CLIENTE'
                TableField = 'ID_CLIENTE'
              end
              item
                DatasetField = 'CLIENTE'
                TableField = 'CLIENTE'
              end
              item
                DatasetField = 'ID_COMISION_LIQUIDADA'
                TableField = 'ID_COMISION_LIQUIDADA'
              end
              item
                DatasetField = 'IMPORTE_COMISIONABLE'
                TableField = 'IMPORTE_COMISIONABLE'
              end
              item
                DatasetField = 'IMPORTE_COMISION'
                TableField = 'IMPORTE_COMISION'
              end
              item
                DatasetField = 'ID_FACTURA'
                TableField = 'ID_FACTURA'
              end>
          end>
        Name = 'Facturas_Comision'
        Fields = <
          item
            Name = 'ID_EMPRESA'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_ID_EMPRESA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_AGENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_ID_AGENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'AGENTE'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_AGENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_FACTURA'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_ID_FACTURA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_COMISION_LIQUIDADA'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_ID_COMISION_LIQUIDADA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'FECHA'
            DataType = datDateTime
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_FECHA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'REFERENCIA'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_REFERENCIA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'SITUACION'
            DataType = datString
            Size = 19
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_SITUACION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_CLIENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_ID_CLIENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'CLIENTE'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_CLIENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_PROVEEDOR'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_ID_PROVEEDOR'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'PROVEEDOR'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_PROVEEDOR'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'COMISION'
            DataType = datFloat
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_COMISION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'IMPORTE_COMISIONABLE'
            DataType = datCurrency
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_IMPORTE_COMISIONABLE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'IMPORTE_COMISION'
            DataType = datCurrency
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_IMPORTE_COMISION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end>
        BusinessRulesClient.ScriptLanguage = rslPascalScript
        BusinessRulesServer.ScriptLanguage = rslPascalScript
      end
      item
        Params = <
          item
            Name = 'CODIGO'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'EMPRESA'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end>
        Statements = <
          item
            Connection = 'IBX'
            SQL = 
              'SELECT VALOR'#10'FROM REFERENCIAS'#10'WHERE CODIGO = :CODIGO'#10'AND ID_EMPR' +
              'ESA = :EMPRESA'
            StatementType = stSQL
            ColumnMappings = <
              item
                DatasetField = 'VALOR'
                TableField = 'VALOR'
              end>
          end>
        Name = 'DarReferencia'
        Fields = <
          item
            Name = 'VALOR'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end>
        BusinessRulesClient.ScriptLanguage = rslPascalScript
        BusinessRulesServer.ScriptLanguage = rslPascalScript
      end
      item
        Params = <>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'COMISIONES_LIQUIDADAS'
            SQL = 
              'SELECT '#10'    COMISIONES_LIQUIDADAS.ID, COMISIONES_LIQUIDADAS.ID_E' +
              'MPRESA,'#10'    COMISIONES_LIQUIDADAS.REFERENCIA, COMISIONES_LIQUIDA' +
              'DAS.ID_AGENTE,'#10'    COMISIONES_LIQUIDADAS.DESCRIPCION, COMISIONES' +
              '_LIQUIDADAS.FECHA,'#10'    COMISIONES_LIQUIDADAS.IMPORTE_TOTAL, COMI' +
              'SIONES_LIQUIDADAS.USUARIO,'#10'    CONTACTOS.NOMBRE'#10'FROM COMISIONES_' +
              'LIQUIDADAS'#10'LEFT JOIN CONTACTOS ON (CONTACTOS.ID = COMISIONES_LIQ' +
              'UIDADAS.ID_AGENTE)'
            StatementType = stSQL
            ColumnMappings = <
              item
                DatasetField = 'ID'
                TableField = 'ID'
              end
              item
                DatasetField = 'DESCRIPCION'
                TableField = 'DESCRIPCION'
              end
              item
                DatasetField = 'FECHA'
                TableField = 'FECHA'
              end
              item
                DatasetField = 'USUARIO'
                TableField = 'USUARIO'
              end
              item
                DatasetField = 'ID_EMPRESA'
                TableField = 'ID_EMPRESA'
              end
              item
                DatasetField = 'REFERENCIA'
                TableField = 'REFERENCIA'
              end
              item
                DatasetField = 'ID_AGENTE'
                TableField = 'ID_AGENTE'
              end
              item
                DatasetField = 'IMPORTE_TOTAL'
                TableField = 'IMPORTE_TOTAL'
              end
              item
                DatasetField = 'NOMBRE'
                TableField = 'NOMBRE'
              end>
          end>
        Name = 'Comisiones'
        Fields = <
          item
            Name = 'ID'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_ID'
            InPrimaryKey = True
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_EMPRESA'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_ID_EMPRESA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'REFERENCIA'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_REFERENCIA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_AGENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'DESCRIPCION'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_DESCRIPCION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'FECHA'
            DataType = datDateTime
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_FECHA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'IMPORTE_TOTAL'
            DataType = datFloat
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'USUARIO'
            DataType = datString
            Size = 20
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_USUARIO'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'NOMBRE'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end>
        BusinessRulesClient.ScriptLanguage = rslPascalScript
        BusinessRulesServer.ScriptLanguage = rslPascalScript
      end
      item
        Params = <
          item
            Name = 'ID'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'COMISIONES_LIQUIDADAS'
            SQL = 
              'SELECT'#10'    COMISIONES_LIQUIDADAS.ID, COMISIONES_LIQUIDADAS.ID_EM' +
              'PRESA,'#10'    COMISIONES_LIQUIDADAS.REFERENCIA, COMISIONES_LIQUIDAD' +
              'AS.ID_AGENTE,'#10'    COMISIONES_LIQUIDADAS.DESCRIPCION, COMISIONES_' +
              'LIQUIDADAS.FECHA,'#10'    COMISIONES_LIQUIDADAS.IMPORTE_TOTAL, COMIS' +
              'IONES_LIQUIDADAS.USUARIO,'#10'    CONTACTOS.NOMBRE'#10'FROM COMISIONES_L' +
              'IQUIDADAS'#10'LEFT JOIN CONTACTOS ON (CONTACTOS.ID = COMISIONES_LIQU' +
              'IDADAS.ID_AGENTE)'#10'WHERE COMISIONES_LIQUIDADAS.ID = :ID'
            StatementType = stSQL
            ColumnMappings = <
              item
                DatasetField = 'ID'
                TableField = 'ID'
              end
              item
                DatasetField = 'DESCRIPCION'
                TableField = 'DESCRIPCION'
              end
              item
                DatasetField = 'FECHA'
                TableField = 'FECHA'
              end
              item
                DatasetField = 'USUARIO'
                TableField = 'USUARIO'
              end
              item
                DatasetField = 'ID_EMPRESA'
                TableField = 'ID_EMPRESA'
              end
              item
                DatasetField = 'REFERENCIA'
                TableField = 'REFERENCIA'
              end
              item
                DatasetField = 'ID_AGENTE'
                TableField = 'ID_AGENTE'
              end
              item
                DatasetField = 'IMPORTE_TOTAL'
                TableField = 'IMPORTE_TOTAL'
              end
              item
                DatasetField = 'NOMBRE'
                TableField = 'NOMBRE'
              end>
          end>
        Name = 'Comisiones_Refresh'
        Fields = <
          item
            Name = 'ID'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_ID'
            InPrimaryKey = True
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_EMPRESA'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_ID_EMPRESA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'REFERENCIA'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_REFERENCIA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_AGENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'DESCRIPCION'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_DESCRIPCION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'FECHA'
            DataType = datDateTime
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_FECHA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'IMPORTE_TOTAL'
            DataType = datFloat
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'USUARIO'
            DataType = datString
            Size = 20
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_USUARIO'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'NOMBRE'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end>
        BusinessRulesClient.ScriptLanguage = rslPascalScript
        BusinessRulesServer.ScriptLanguage = rslPascalScript
      end
      item
        Params = <>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'V_AGENTES_COMISIONES_DET_FAC'
            SQL = 
              'select V_AGENTES_COMISIONES_DET_FAC.ID_EMPRESA,'#10'       V_AGENTES' +
              '_COMISIONES_DET_FAC.ID_AGENTE, CONTACTOS1.NOMBRE as AGENTE,'#10'    ' +
              '   V_AGENTES_COMISIONES_DET_FAC.ID_FACTURA,'#10'       V_AGENTES_COM' +
              'ISIONES_DET_FAC.ID_COMISION_LIQUIDADA,'#10'       V_AGENTES_COMISION' +
              'ES_DET_FAC.FECHA,'#10'       V_AGENTES_COMISIONES_DET_FAC.REFERENCIA' +
              ','#10'       V_AGENTES_COMISIONES_DET_FAC.SITUACION,'#10'       V_AGENTE' +
              'S_COMISIONES_DET_FAC.ID_CLIENTE,'#10'       CONTACTOS2.NOMBRE as CLI' +
              'ENTE,'#10'       V_AGENTES_COMISIONES_DET_FAC.ID_PROVEEDOR,'#10'       C' +
              'ONTACTOS3.NOMBRE as PROVEEDOR,'#10'       V_AGENTES_COMISIONES_DET_F' +
              'AC.COMISION,'#10'       SUM(V_AGENTES_COMISIONES_DET_FAC.IMPORTE_TOT' +
              'AL) as IMPORTE_COMISIONABLE,'#10'       SUM(V_AGENTES_COMISIONES_DET' +
              '_FAC.IMPORTE_COMISION) as IMPORTE_COMISION'#10#10'from V_AGENTES_COMIS' +
              'IONES_DET_FAC'#10'LEFT JOIN CONTACTOS CONTACTOS1 ON (CONTACTOS1.ID =' +
              ' V_AGENTES_COMISIONES_DET_FAC.ID_AGENTE)'#10'LEFT JOIN CONTACTOS CON' +
              'TACTOS2 ON (CONTACTOS2.ID = V_AGENTES_COMISIONES_DET_FAC.ID_CLIE' +
              'NTE)'#10'LEFT JOIN CONTACTOS CONTACTOS3 ON (CONTACTOS3.ID = V_AGENTE' +
              'S_COMISIONES_DET_FAC.ID_PROVEEDOR)'#10'GROUP BY 1, 2, 3, 4, 5, 6, 7,' +
              ' 8, 9, 10, 11, 12, 13'
            StatementType = stSQL
            ColumnMappings = <
              item
                DatasetField = 'ID_EMPRESA'
                TableField = 'ID_EMPRESA'
              end
              item
                DatasetField = 'ID_AGENTE'
                TableField = 'ID_AGENTE'
              end
              item
                DatasetField = 'AGENTE'
                TableField = 'AGENTE'
              end
              item
                DatasetField = 'FECHA'
                TableField = 'FECHA'
              end
              item
                DatasetField = 'REFERENCIA'
                TableField = 'REFERENCIA'
              end
              item
                DatasetField = 'SITUACION'
                TableField = 'SITUACION'
              end
              item
                DatasetField = 'ID_PROVEEDOR'
                TableField = 'ID_PROVEEDOR'
              end
              item
                DatasetField = 'PROVEEDOR'
                TableField = 'PROVEEDOR'
              end
              item
                DatasetField = 'COMISION'
                TableField = 'COMISION'
              end
              item
                DatasetField = 'ID_CLIENTE'
                TableField = 'ID_CLIENTE'
              end
              item
                DatasetField = 'CLIENTE'
                TableField = 'CLIENTE'
              end
              item
                DatasetField = 'ID_COMISION_LIQUIDADA'
                TableField = 'ID_COMISION_LIQUIDADA'
              end
              item
                DatasetField = 'IMPORTE_COMISIONABLE'
                TableField = 'IMPORTE_COMISIONABLE'
              end
              item
                DatasetField = 'IMPORTE_COMISION'
                TableField = 'IMPORTE_COMISION'
              end
              item
                DatasetField = 'ID_FACTURA'
                TableField = 'ID_FACTURA'
              end>
          end>
        Name = 'V_Detalles_Facturas_Comision'
        Fields = <
          item
            Name = 'ID_EMPRESA'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_ID_EMPRESA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_AGENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_ID_AGENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'AGENTE'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_AGENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_FACTURA'
            DataType = datInteger
            BlobType = dabtUnknown
            DisplayWidth = 0
            Alignment = taLeftJustify
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_COMISION_LIQUIDADA'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'V_Detalles_Facturas_Comision_ID_COMISION_LIQUIDADA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'FECHA'
            DataType = datDateTime
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_FECHA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'REFERENCIA'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_REFERENCIA'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'SITUACION'
            DataType = datString
            Size = 19
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_SITUACION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_CLIENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_ID_CLIENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'CLIENTE'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Facturas_Comision_CLIENTE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'ID_PROVEEDOR'
            DataType = datInteger
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_ID_PROVEEDOR'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'PROVEEDOR'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_PROVEEDOR'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'COMISION'
            DataType = datFloat
            BlobType = dabtUnknown
            DictionaryEntry = 'Comisiones_Detalles_COMISION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'IMPORTE_COMISIONABLE'
            DataType = datCurrency
            BlobType = dabtUnknown
            DictionaryEntry = 'V_Detalles_Facturas_Comision_IMPORTE_COMISIONABLE'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end
          item
            Name = 'IMPORTE_COMISION'
            DataType = datCurrency
            BlobType = dabtUnknown
            DictionaryEntry = 'V_Detalles_Facturas_Comision_IMPORTE_COMISION'
            InPrimaryKey = False
            Calculated = False
            Lookup = False
            LookupCache = False
          end>
        BusinessRulesClient.ScriptLanguage = rslPascalScript
        BusinessRulesServer.ScriptLanguage = rslPascalScript
      end>
    Commands = <
      item
        Params = <
          item
            Name = 'VALOR'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptUnknown
          end
          item
            Name = 'CODIGO'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptUnknown
          end
          item
            Name = 'ID_EMPRESA'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptUnknown
          end>
        Statements = <
          item
            Connection = 'IBX'
            SQL = 
              'UPDATE REFERENCIAS SET'#10'       VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
              'IGO AND'#10'      ID_EMPRESA = :ID_EMPRESA'
            StatementType = stSQL
            ColumnMappings = <>
          end>
        Name = 'ModificarReferencia'
      end
      item
        Params = <
          item
            Name = 'ID_COMISION_LIQUIDADA'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'ID_FACTURA'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptUnknown
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'FACTURAS_CLIENTE'
            SQL = 
              'UPDATE FACTURAS_CLIENTE'#10'SET ID_COMISION_LIQUIDADA = :ID_COMISION' +
              '_LIQUIDADA'#10'WHERE (ID = :ID_FACTURA)'
            StatementType = stSQL
            ColumnMappings = <>
          end>
        Name = 'Insert_Facturas_Comisiones'
      end
      item
        Params = <
          item
            Name = 'OLD_ID_FACTURA'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptUnknown
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'FACTURAS_CLIENTE'
            SQL = 
              'UPDATE FACTURAS_CLIENTE'#10'SET ID_COMISION_LIQUIDADA = Null'#10'WHERE (' +
              'ID = :OLD_ID_FACTURA)'
            StatementType = stSQL
            ColumnMappings = <>
          end>
        Name = 'Delete_Facturas_Comision'
      end
      item
        Params = <
          item
            Name = 'ID_COMISION_LIQUIDADA'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'OLD_ID_FACTURA'
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptUnknown
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'FACTURAS_CLIENTE'
            SQL = 
              'UPDATE FACTURAS_CLIENTE'#10'SET ID_COMISION_LIQUIDADA = :ID_COMISION' +
              '_LIQUIDADA'#10'WHERE (ID = :OLD_ID_FACTURA)'
            StatementType = stSQL
            ColumnMappings = <>
          end>
        Name = 'Update_Facturas_Comision'
      end
      item
        Params = <
          item
            Name = 'ID'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'ID_EMPRESA'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'REFERENCIA'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'ID_AGENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'DESCRIPCION'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'FECHA'
            DataType = datDateTime
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'IMPORTE_TOTAL'
            DataType = datFloat
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'USUARIO'
            DataType = datString
            Size = 20
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'COMISIONES_LIQUIDADAS'
            SQL = 
              'INSERT'#10'  INTO COMISIONES_LIQUIDADAS'#10'    (ID, ID_EMPRESA, REFEREN' +
              'CIA, ID_AGENTE, DESCRIPCION, FECHA, IMPORTE_TOTAL, USUARIO)'#10'  VA' +
              'LUES'#10'    (:ID, :ID_EMPRESA, :REFERENCIA, :ID_AGENTE, :DESCRIPCIO' +
              'N, :FECHA, :IMPORTE_TOTAL, :USUARIO)'
            StatementType = stSQL
            ColumnMappings = <>
          end>
        Name = 'Insert_Comisiones'
      end
      item
        Params = <
          item
            Name = 'OLD_ID'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'COMISIONES_LIQUIDADAS'
            SQL = 
              'DELETE '#10'  FROM'#10'    COMISIONES_LIQUIDADAS'#10'  WHERE'#10'    (ID = :OLD_' +
              'ID)'
            StatementType = stSQL
            ColumnMappings = <>
          end>
        Name = 'Delete_Comisiones'
      end
      item
        Params = <
          item
            Name = 'ID'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'ID_EMPRESA'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'REFERENCIA'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'ID_AGENTE'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'DESCRIPCION'
            DataType = datString
            Size = 255
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'FECHA'
            DataType = datDateTime
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'IMPORTE_TOTAL'
            DataType = datFloat
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'USUARIO'
            DataType = datString
            Size = 20
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end
          item
            Name = 'OLD_ID'
            DataType = datInteger
            BlobType = dabtUnknown
            Value = ''
            ParamType = daptInput
          end>
        Statements = <
          item
            Connection = 'IBX'
            TargetTable = 'COMISIONES_LIQUIDADAS'
            SQL = 
              'UPDATE COMISIONES_LIQUIDADAS'#10'  SET '#10'    ID = :ID, '#10'    ID_EMPRES' +
              'A = :ID_EMPRESA,'#10'    REFERENCIA = :REFERENCIA,'#10'    ID_AGENTE = :' +
              'ID_AGENTE,'#10'    DESCRIPCION = :DESCRIPCION, '#10'    FECHA = :FECHA, ' +
              #10'    IMPORTE_TOTAL = :IMPORTE_TOTAL,'#10'    USUARIO = :USUARIO'#10'  WH' +
              'ERE'#10'    (ID = :OLD_ID)'
            StatementType = stSQL
            ColumnMappings = <>
          end>
        Name = 'Update_Comisiones'
      end>
    RelationShips = <>
    UpdateRules = <
      item
        Name = 'Insert Comisiones'
        DoUpdate = False
        DoInsert = True
        DoDelete = False
        DatasetName = 'Comisiones'
        FailureBehaviour = fbRaiseException
      end
      item
        Name = 'Insert Facturas_Comision'
        DoUpdate = False
        DoInsert = True
        DoDelete = False
        DatasetName = 'Facturas_Comision'
        FailureBehaviour = fbRaiseException
      end
      item
        Name = 'Update Comisiones'
        DoUpdate = True
        DoInsert = False
        DoDelete = False
        DatasetName = 'Comisiones'
        FailureBehaviour = fbRaiseException
      end
      item
        Name = 'Update Facturas_Comision'
        DoUpdate = True
        DoInsert = False
        DoDelete = False
        DatasetName = 'Facturas_Comision'
        FailureBehaviour = fbRaiseException
      end
      item
        Name = 'Delete Facturas_Comision'
        DoUpdate = False
        DoInsert = False
        DoDelete = True
        DatasetName = 'Facturas_Comision'
        FailureBehaviour = fbRaiseException
      end
      item
        Name = 'Delete Comisiones'
        DoUpdate = False
        DoInsert = False
        DoDelete = True
        DatasetName = 'Comisiones'
        FailureBehaviour = fbRaiseException
      end>
    Left = 48
    Top = 24
  end
  object DABINAdapter: TDABINAdapter
    Left = 48
    Top = 72
  end
  object bpComisiones: TDABusinessProcessor
    Schema = schComisiones
    InsertCommandName = 'Insert_Comisiones'
    DeleteCommandName = 'Delete_Comisiones'
    UpdateCommandName = 'Update_Comisiones'
    RefreshDatasetName = 'Comisiones_Refresh'
    ReferencedDataset = 'Comisiones'
    ProcessorOptions = [poPrepareCommands]
    UpdateMode = updWhereKeyOnly
    Left = 248
    Top = 24
  end
  object bpFacturas_Comision: TDABusinessProcessor
    Schema = schComisiones
    InsertCommandName = 'Insert_Facturas_Comisiones'
    DeleteCommandName = 'Delete_Facturas_Comision'
    UpdateCommandName = 'Update_Facturas_Comision'
    ReferencedDataset = 'Facturas_Comision'
    ProcessorOptions = [poAutoGenerateRefreshDataset, poPrepareCommands]
    UpdateMode = updWhereKeyOnly
    Left = 248
    Top = 80
  end
end
