Exemplo n.º 1
0
void FacturaView::on_mui_veralbaranes_clicked()
{
    BL_FUNC_DEBUG
    AlbaranClienteView *bud = NULL;
    BlDbRecordSet *cur = NULL;
    try {
        QString SQLQuery = "SELECT * FROM albaran WHERE refalbaran = '" + dbValue ( "reffactura" ) + "'";
        cur = mainCompany() ->loadQuery ( SQLQuery );
        if ( !cur->eof() ) {
            while ( !cur->eof() ) {
	      
		/// Como estamos en un plugin buscamos nuevas formas de creacion de objetos.
		int resur = g_plugins->run ( "SNewAlbaranClienteView", mainCompany() );
		if ( !resur ) {
		    blMsgInfo ( _ ( "No se pudo crear instancia de albaran" ) );
		    return;
		} // end if
                bud = ( AlbaranClienteView * ) g_plugParams;
                mainCompany() ->m_pWorkspace->addSubWindow ( bud );
                bud->load ( cur->value( "idalbaran" ) );
                bud->show();
                cur->nextRecord();
            } // end while
        } else {
            blMsgInfo ( _ ( "No hay albaranes con esta referencia" ), this );
        } // end if
        delete cur;
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error inesperado" ), this );
        if ( cur ) delete cur;
        if ( bud ) delete bud;
    } // end try
    
}
Exemplo n.º 2
0
/**
\return
**/
void ArticuloList::remove()
{
    BL_FUNC_DEBUG
    int a = mui_list->currentRow();
    if ( a < 0 ) {
        blMsgInfo ( _ ( "Tiene que seleccionar un articulo" ) );
        return;
    } // end if
    try {
        QString idarticulo = mui_list->dbValue ( "idarticulo" );
        if ( QMessageBox::Yes == QMessageBox::question ( this,
                _ ( "Borrar articulo" ),
                _ ( "Esta a punto de borrar un articulo. Estos datos pueden dar problemas." ),
                QMessageBox::Yes, QMessageBox::No ) ) {
            QString SQLQuery = "DELETE FROM articulo WHERE idarticulo = " + idarticulo;
            int error = mainCompany() ->runQuery ( SQLQuery );
            if ( error )
                throw - 1;
            presentar();
        } // end if
        
    } catch ( ... ) {
	
        blMsgInfo ( _ ( "Error al borrar el articulo" ) );
    } // end try
}
Exemplo n.º 3
0
void BcBloqueaFechaView::on_mui_crear_clicked()
{
    BL_FUNC_DEBUG
    /// Tomamos el anyo pasado como referencia.
    int ejer = QDate::currentDate().year() - 1;

    /// Miramos si ya hay ejercicios introducidos y si es asi cogemos el siguiente como referencia.
    QString consultabd = "SELECT max(ejercicio) AS ej FROM ejercicios";
    BlDbRecordSet *cur = mainCompany()->loadQuery ( consultabd );
    if ( cur ) {
        if ( !cur->eof() ) {
            if ( cur->value( "ej" ).toInt() != 0 )
                ejer = cur->value( "ej" ).toInt();
        } // end if
        delete cur;
    } // end if
    ejer++;

    /// Presentamos el dialogo preguntado que ejercicio crear.
    bool ok = false;
    ejer = QInputDialog::getInt ( this, _ ( "Introduzca Ejercicio a Crear" ),
                                      _ ( "Ponga el anyo:" ), ejer, 0, 10000, 1, &ok );

    /// Comprobamos que el ejercicio introducido sea valido.
    if ( !ok ) return;
    if ( ejer < 1000 ) {
        blMsgInfo ( "Ejercicio invalido" );
        return;
    } // end if
    QString query = "SELECT * FROM ejercicios WHERE ejercicio = " + QString::number ( ejer );
    cur = mainCompany()->loadQuery ( query );
    if ( cur ) {
        if ( cur->numregistros() > 0 ) {
            delete cur;
            blMsgInfo ( _ ( "Ejercicios ya contemplado" ) );
            return;
        } // end if
    } // end if


    /// Creamos el ejercicio.
    for ( int x = 0; x <= 12; x++ ) {
        try {
            QString consultabd = "INSERT INTO ejercicios (ejercicio, periodo, bloqueado) VALUES('" + QString::number ( ejer ) + "', '" + QString::number ( x ) + "', 'f')";
            mainCompany()->begin();
            mainCompany() ->runQuery ( consultabd );
            mainCompany()->commit();
        } catch ( ... ) {
            blMsgInfo ( "Error con la base de datos" );
            mainCompany()->rollback();
        } // end try
    } // end for

    /// Presentamos
    inicializa();

    
}
Exemplo n.º 4
0
/** inicializa todos los componentes de la clase.
    Resetea el sistema de control de cambios para que considere que no hay cambios por parte del usuario.
    Mete la ventana en el workSpace.
*/
Q19View::Q19View ( CarteraCobrosList *fac, BfCompany *comp, QWidget *parent )
        : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setupUi ( this );

        m_carteraCobrosList = fac;

        /// Usurpamos la identidad de mlist y ponemos nuestro propio widget con sus cosillas.
        mui_idbanco->setMainCompany ( comp );
        mui_idbanco->setidbanco ( "0" );

        setDbTableName ( "vencimientoc" );
        setDbFieldId ( "idvencimientoc" );



/// Calculamos el TOTAL y el numero de operaciones
        BlSubForm *sub = m_carteraCobrosList->mui_list;

	BlFixed a("0.00");
	int numop = 0;
        /// Reseteamos los valores
        for ( int i = 0; i < sub->rowCount(); i++ ) {
            BlDbSubFormRecord *rec = sub->lineaat ( i );
            rec->refresh();
            QString val = rec->dbValue ( "selector" );
            if ( val == "TRUE" ) {
		if (rec->dbValue("descforma_pago") != "Transferencia") 
			blMsgInfo("Hay vencimientos que no pueden ser Remesados");
		if (rec->dbValue("estadovencimientoc") != "Pendiente") 
			blMsgInfo("Hay vencimientos con estado no Pendiente");
                a = a + BlFixed ( rec->dbValue ( "cantvencimientoc" ) );
		numop++;
            } // end if
        } // end for

	mui_total->setText(a.toQString());
	mui_numop->setText(QString::number(numop));

        insertWindow ( windowTitle(), this, FALSE );
        dialogChanges_readValues();
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( tr ( "Error al crear el archivo" ) );
    } // end try
    
}
Exemplo n.º 5
0
/** inicializa todos los componentes de la clase.
    Resetea el sistema de control de cambios para que considere que no hay cambios por parte del usuario.
    Mete la ventana en el workSpace.
*/
ReciboView::ReciboView ( BfCompany *comp, QWidget *parent ) : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG

    setAttribute ( Qt::WA_DeleteOnClose );

    try {
        setupUi ( this );
        blCenterOnScreen ( this );

        setTitleName ( _ ( "Recibo" ) );
        setDbTableName ( "recibo" );
        setDbFieldId ( "idrecibo" );
        addDbField ( "idrecibo", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "ID recibo" ) );
        addDbField ( "cantrecibo", BlDbField::DbNumeric, BlDbField::DbNothing, _ ( "Cantidad" ) );
        addDbField ( "idcliente", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "ID cliente" ) );
        addDbField ( "idforma_pago", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "ID Forma Pago" ) );
        addDbField ( "descrecibo", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Descripcion" ) );
        addDbField ( "fecharecibo", BlDbField::DbDate, BlDbField::DbNothing, _ ( "Fecha de creacion" ) );
        addDbField ( "pagadorecibo", BlDbField::DbBoolean, BlDbField::DbNothing, _ ( "Pagado" ) );
        addDbField ( "devueltorecibo", BlDbField::DbBoolean, BlDbField::DbNothing, _ ( "Devuelto" ) );

        insertWindow ( windowTitle(), this, false );

        mui_idforma_pago->setMainCompany ( comp );

        /// Establecemos los parametros de busqueda de Profesor
        mui_idcliente->setMainCompany ( comp );
        mui_idcliente->setLabel ( _ ( "Tutor/Socio:" ) );
        mui_idcliente->setTableName ( "cliente" );
	mui_idcliente->setFieldId( "idcliente" );
	mui_idcliente->m_valores["cifcliente"] = "";
        mui_idcliente->m_valores["nomcliente"] = "";
	mui_idcliente->m_valores["apellido1cliente"] = "";
	mui_idcliente->m_valores["apellido2cliente"] = "";
	mui_idcliente->setMask("[cifcliente] .- [apellido1cliente] [apellido2cliente], [nomcliente]");

        /// Activamos el listado de lineas de recibo
        mui_list->setMainCompany( comp );
        mui_list->setDbTableName ( "lrecibo" );
        mui_list->setDbFieldId ( "idlrecibo" );
        mui_list->addSubFormHeader ( "idlrecibo", BlDbField::DbInt, BlDbField::DbPrimaryKey , BlSubFormHeader::DbHideView, _ ( "Identificador" ) );
        mui_list->addSubFormHeader ( "idrecibo", BlDbField::DbInt, BlDbField::DbNothing , BlSubFormHeader::DbHideView, _ ( "ID recibo" ) );
        mui_list->addSubFormHeader ( "cantlrecibo", BlDbField::DbNumeric, BlDbField::DbNotNull, BlSubFormHeader::DbNone, _ ( "Cantidad Linea Recibo" ) );
        mui_list->addSubFormHeader ( "conceptolrecibo", BlDbField::DbVarChar, BlDbField::DbNotNull, BlSubFormHeader::DbNone, _ ( "Concepto" ) );

        mui_list->setInsert ( true );
        mui_list->setOrdenEnabled ( true );

        mui_list->load("SELECT * from lrecibo WHERE 1=2");

        pintar();
        dialogChanges_readValues();
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear el recibo" ), this );
    } // end try

    
}
Exemplo n.º 6
0
/** inicializa todos los componentes de la clase.
    Resetea el sistema de control de cambios para que considere que no hay cambios por parte del usuario.
    Mete la ventana en el workSpace.
*/
ConvocatoriaView::ConvocatoriaView ( BfCompany *comp, QWidget *parent )
        : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setupUi ( this );
        blCenterOnScreen ( this );

        setTitleName ( _ ( "Convocatoria" ) );
        setDbTableName ( "actividad" );
        setDbFieldId ( "idactividad" );
        addDbField ( "idactividad", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "ID actividad" ) );
        addDbField ( "nombreactividad", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Nombre del actividad" ) );
        addDbField ( "idprofesor", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Id profesor" ) );

        insertWindow ( windowTitle(), this, false );

        /// Establecemos los parametros de busqueda de Profesor
        mui_idprofesor->setMainCompany ( comp );
        mui_idprofesor->setLabel ( _ ( "Profesor:" ) );
        mui_idprofesor->setTableName ( "profesor" );
        mui_idprofesor->m_valores["nombreprofesor"] = "";


        pintar();
        dialogChanges_readValues();
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear el actividad" ), this );
    } // end try
    
}
Exemplo n.º 7
0
/** inicializa todos los componentes de la clase.
    Resetea el sistema de control de cambios para que considere que no hay cambios por parte del usuario.
    Mete la ventana en el workSpace.
*/
Sepa20022View::Sepa20022View ( FacturasList *fac, BfCompany *comp, QWidget *parent )
        : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setupUi ( this );

        m_facturasList = fac;
        idsFacturas();
        /// Usurpamos la identidad de mlist y ponemos nuestro propio widget con sus cosillas.
        mui_idbanco->setMainCompany ( comp );
        mui_idbanco->setidbanco ( "0" );

        m_q19 = new Sepa20022Writer ( comp );

        setDbTableName ( "factura" );
        setDbFieldId ( "idfactura" );

        mui_fecha->setDate(QDate::currentDate());
        mui_fecha->calendarWidget()->setFirstDayOfWeek(Qt::Monday);

        insertWindow ( windowTitle(), this, false );
        dialogChanges_readValues();
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear el archivo" ) );
    } // end try
    
}
Exemplo n.º 8
0
void TipoArticuloList::pintar()
{
    BL_FUNC_DEBUG
    m_semaforoPintar = TRUE;
    BlDbRecordSet *cursoraux1 = NULL;
    try {
        QTreeWidgetItem * it;


        /// Vaciamos el arbol.
        while ( m_listTipos->topLevelItemCount() > 0 ) {
            it = m_listTipos->takeTopLevelItem ( 0 );
            delete it;
        } // end while

        cursoraux1 = mainCompany()->loadQuery ( "SELECT * FROM tipo_articulo ORDER BY codtipo_articulo" );
        while ( !cursoraux1->eof() ) {
            it = new QTreeWidgetItem ( m_listTipos );
            it->setText ( COL_IDTIPOARTICULO, cursoraux1->value( "idtipo_articulo" ) );
            it->setText ( COL_CODTIPOARTICULO, cursoraux1->value( "codtipo_articulo" ) );
            it->setText ( COL_DESCTIPOARTICULO, cursoraux1->value( "desctipo_articulo" ) );
            //it->setOpen(true);
            cursoraux1->nextRecord();
        } // end while
        delete cursoraux1;
        m_idtipo = "";
        /// Comprobamos cual es la cadena inicial.
        dialogChanges_readValues();
        m_semaforoPintar = FALSE;
        
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error en la carga" ) );
        if ( cursoraux1 ) delete cursoraux1;
    } // end try
}
Exemplo n.º 9
0
/**
\param comp
\param parent
\return
**/
AlbaranProveedorView::AlbaranProveedorView ( BfCompany *comp, QWidget *parent )
        : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setupUi ( this );
        setTitleName ( _ ( "Albaran de proveedor" ) );
        setDbTableName ( "albaranp" );
        setDbFieldId ( "idalbaranp" );
        addDbField ( "idalbaranp", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "Id albaran proveedor" ) );
        addDbField ( "numalbaranp", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Numero albaran proveedor" ) );
        addDbField ( "fechaalbaranp", BlDbField::DbDate, BlDbField::DbNothing, _ ( "Fecha albaran proveedor" ) );
        addDbField ( "comentalbaranp", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Comentario albaran proveedor" ) );
        addDbField ( "idproveedor", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Id proveedor" ) );
        addDbField ( "idforma_pago", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Id forma de pago" ) );
        addDbField ( "idalmacen", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Id almacen" ) );
        addDbField ( "procesadoalbaranp", BlDbField::DbBoolean, BlDbField::DbNothing, _ ( "Albaran procesado" ) );
        addDbField ( "refalbaranp", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Referencia albaran proveedor" ) );
        addDbField ( "descalbaranp", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Descripcion albaran proveedor" ) );

        /// Disparamos los plugins.
        int res = g_plugins->run ( "AlbaranProveedorView_AlbaranProveedorView", this );
        if ( res != 0 ) {
            return;
        } // end if
        subform2->setMainCompany ( comp );
        mui_idalmacen->setMainCompany ( comp );
        mui_idforma_pago->setMainCompany ( comp );
        mui_idproveedor->setMainCompany ( comp );
        m_descuentos->setMainCompany ( comp );
        mui_refalbaranp->setMainCompany ( comp );

        /// Inicializamos BfForm.
        setListaLineas ( subform2 );
        setListaDescuentos ( m_descuentos );

        /// Establecemos los parametros de busqueda del Cliente
        mui_idproveedor->setLabel ( _ ( "Proveedor:" ) );
        mui_idproveedor->setTableName ( "proveedor" );
        mui_idproveedor->m_valores["cifproveedor"] = "";
        mui_idproveedor->m_valores["nomproveedor"] = "";

        m_totalBases->setReadOnly ( true );
        m_totalBases->setAlignment ( Qt::AlignRight );
        m_totalTaxes->setReadOnly ( true );
        m_totalTaxes->setAlignment ( Qt::AlignRight );
        m_totalDiscounts->setReadOnly ( true );
        m_totalDiscounts->setAlignment ( Qt::AlignRight );
        m_totalalbaranp->setReadOnly ( true );
        m_totalalbaranp->setAlignment ( Qt::AlignRight );
        mui_idforma_pago->setId ( "0" );
        mui_idalmacen->setId ( "0" );
        insertWindow ( windowTitle(), this, false );
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear el albaran proveedor" ), this );
    } // end try
    
}
Exemplo n.º 10
0
/**  procedimiento de QtScript
Importa el objeto que se pasa como referencia al engine de script
Busca el archivo en el directorio de openreports que tenga el mismo nombre que la clase
Importa el script y lo lanza.

*/
void BlFormList::blScript(QObject * obj) {
    
    if (g_confpr->value(CONF_USE_QSCRIPT) == "TRUE" || g_confpr->value(CONF_USE_QSCRIPT) == "T" || g_confpr->value(CONF_USE_QSCRIPT) == "1" ) {
  
	  /// Lanzamos los scripts de QScript
	  QString fileName = g_confpr->value( CONF_DIR_OPENREPORTS ) + "blformlist_"+metaObject()->className()+".qs";
	  QFile scriptFile1(fileName);
	  if (scriptFile1.open(QIODevice::ReadOnly)) {
		QTextStream stream(&scriptFile1);
		QString contents = stream.readAll();
		QScriptValue objectValue = m_myEngine.newQObject(this);
		m_myEngine.globalObject().setProperty(metaObject()->className(), objectValue);
		QScriptValue objectValue1 = m_myEngine.newQObject(mainCompany());
		m_myEngine.globalObject().setProperty("MainCompany", objectValue1);
		m_myEngine.importExtension("qt.core");
		m_myEngine.importExtension("qt.gui"); 
		m_myEngine.evaluate(contents);
		scriptFile1.close();
		if (m_myEngine.hasUncaughtException()) {
		  blMsgInfo(m_myEngine.uncaughtException().toString());
		} // end if
	  } // end if
	  
	  
	  fileName = g_confpr->value( CONF_DIR_OPENREPORTS ) + "blformlist"+".qs";
	  scriptFile1.setFileName(fileName);
	  if (scriptFile1.open(QIODevice::ReadOnly)) {
		QTextStream stream(&scriptFile1);
		QString contents = stream.readAll();
		QScriptValue objectValue = m_myEngine.newQObject(this);
		m_myEngine.globalObject().setProperty("BlForm", objectValue);
		QScriptValue objectValue1 = m_myEngine.newQObject(mainCompany());
		m_myEngine.globalObject().setProperty("MainCompany", objectValue1);
		m_myEngine.importExtension("qt.core");
		m_myEngine.importExtension("qt.gui"); 
		m_myEngine.evaluate(contents);
		scriptFile1.close();
		if (m_myEngine.hasUncaughtException()) {
		  blMsgInfo(m_myEngine.uncaughtException().toString());
		} // end if
	  } // end if
    
    } // end if
    
}
Exemplo n.º 11
0
/**
\param comp
\param parent
**/
PagoView::PagoView ( BfCompany *comp, QWidget *parent )
        :  BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    try {
        setAttribute ( Qt::WA_DeleteOnClose );
        setupUi ( this );
        blCenterOnScreen ( this );
        /// Usurpamos la identidad de mlist y ponemos nuestro propio widget con sus cosillas.
        mui_idproveedor->setMainCompany ( comp );
        mui_refpago->setMainCompany ( comp );
        mui_idbanco->setMainCompany ( comp );

        setTitleName ( _ ( "Pago" ) );
        setDbTableName ( "pago" );
        setDbFieldId ( "idpago" );
        addDbField ( "idpago", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "Id pago" ) );
        addDbField ( "idproveedor", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Id proveedor" ) );
        addDbField ( "previsionpago", BlDbField::DbBoolean, BlDbField::DbNothing, _ ( "Previcion de pago" ) );
        addDbField ( "fechapago", BlDbField::DbDate, BlDbField::DbNothing, _ ( "Fecha de pago" ) );
        addDbField ( "refpago", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Referencia de pago" ) );
        addDbField ( "cantpago", BlDbField::DbNumeric, BlDbField::DbNotNull, _ ( "Cantidad" ) );
        addDbField ( "comentpago", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Comentario del pago" ) );
        addDbField ( "idbanco", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Banco" ) );
        addDbField ( "idforma_pago", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Forma de pago" ) );
	
        /// Disparamos los plugins.
        int res = g_plugins->run ( "PagoView_PagoView", this );
        if ( res != 0 ) {
            return;
        } // end if
	
        /// Establecemos los parametros de busqueda del Cliente
        mui_idproveedor->setLabel ( _ ( "Proveedor:" ) );
        mui_idproveedor->setTableName ( "proveedor" );
        mui_idproveedor->m_valores["cifproveedor"] = "";
        mui_idproveedor->m_valores["nomproveedor"] = "";

	mui_idforma_pago->setMainCompany( comp );
        mui_idforma_pago->setQuery ( "SELECT * FROM forma_pago ORDER BY descforma_pago" );
        mui_idforma_pago->setTableName ( "forma_pago" );
        mui_idforma_pago->setFieldId ( "idforma_pago" );
        mui_idforma_pago->m_valores["descforma_pago"] = "";
        mui_idforma_pago->setAllowNull ( false );
        mui_idforma_pago->setId ( "" );
	
	
        insertWindow ( windowTitle(), this, false );
        pintar();
        dialogChanges_readValues();
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear el pago" ), this );
    } // end try

    
}
Exemplo n.º 12
0
void ProveedorView::on_mui_cifproveedor_editingFinished()
{
    BL_FUNC_DEBUG
    QChar digito;
    if ( !blValidateSpainCIFNIFCode ( mui_cifproveedor->text(), digito ) ) {
        blMsgInfo ( _("El CIF del proveedor no parece ser valido. Digito:") + " " + QString ( digito ) );
    } // end if
    
}
Exemplo n.º 13
0
/**
\return
**/
void AlbaranProveedorView::on_mui_duplicar_released()
{
    BL_FUNC_DEBUG
    AlbaranProveedorView *fpv = this ;


    AlbaranProveedorView *bud = NULL;
    BlDbRecordSet *cur = NULL;

    try {
        /// Comprueba si disponemos de los datos m&iacute;nimos. Si no se hace esta
        /// comprobaci&oacute;n la consulta a la base de datos ser&aacute; erronea y al hacer
        /// el siguiente cur->eof() el programa fallar&aacute;.
        /// Comprobamos que existe una albaran con esos datos, y en caso afirmativo lo mostramos.

        /// Creamos la albaran.
        AlbaranProveedorView *bud = new AlbaranProveedorView ( ( BfCompany * ) fpv->mainCompany(), 0 );
        fpv->mainCompany() ->m_pWorkspace->addSubWindow ( bud );
	bud->inicializar();

        bud->setDbValue ( "comentalbaranp", fpv->dbValue ( "comentalbaranp" ) );
        bud->setDbValue ( "idforma_pago", fpv->dbValue ( "idforma_pago" ) );
        bud->setDbValue ( "refalbaranp", fpv->dbValue ( "refalbaranp" ) );
        bud->setDbValue ( "idproveedor", fpv->dbValue ( "idproveedor" ) );
        bud->pintar();
        bud->show();

        /// Traspasamos las lineas de albaran
        QString l;
        BlDbSubFormRecord *linea, *linea1;
        for ( int i = 0; i < fpv->m_listalineas->rowCount(); ++i ) {
            linea = fpv->m_listalineas->lineaat ( i );
            if ( linea->dbValue ( "idarticulo" ) != "" ) {
                linea1 = bud->getlistalineas() ->lineaat ( bud->getlistalineas() ->rowCount() - 1 );
                bud->getlistalineas() ->newRecord();
                bud->getlistalineas() ->setProcesarCambios ( false );
                linea1->setDbValue ( "desclalbaranp", linea->dbValue ( "desclalbaranp" ) );
                linea1->setDbValue ( "cantlalbaranp", linea->dbValue ( "cantlalbaranp" ) );
                linea1->setDbValue ( "pvplalbaranp", linea->dbValue ( "pvplalbaranp" ) );
                linea1->setDbValue ( "descuentolalbaranp", linea->dbValue ( "descuentolalbaranp" ) );
                linea1->setDbValue ( "idarticulo", linea->dbValue ( "idarticulo" ) );
                linea1->setDbValue ( "codigocompletoarticulo", linea->dbValue ( "codigocompletoarticulo" ) );
                linea1->setDbValue ( "nomarticulo", linea->dbValue ( "nomarticulo" ) );
                linea1->setDbValue ( "ivalalbaranp", linea->dbValue ( "ivalalbaranp" ) );
                linea1->setDbValue ( "reqeqlalbaranp", linea->dbValue ( "reqeqlalbaranp" ) );
            } // end if
        } // end for
        bud->calculaypintatotales();

    } catch ( ... ) {
        blMsgInfo ( _ ( "Error inesperado" ), this );
        if ( cur ) delete cur;
        if ( bud ) delete bud;
    } // end try

}
Exemplo n.º 14
0
void ListTiposTrabajoView::on_mui_aceptar_clicked()
{
    try {
        mui_listado->save();
        g_theApp->emitDbTableChanged ( "tipotrabajo" );
        close();
    } catch ( ... ) {
        blMsgInfo ( "Error al guardar los tipos de trabajo" );
    } // end try
}
Exemplo n.º 15
0
/**
\param comp
\param parent
**/
ZView::ZView ( BfCompany *comp, QWidget *parent )
        : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setupUi ( this );

        /// Lanzamos los plugins.
        if ( g_plugins->run ( "ZView_ZView", this ) ) return;

        setTitleName ( _ ( "Cuadre de caja" ) );
        setDbTableName ( "z" );
        setDbFieldId ( "idz" );
        addDbField ( "idz", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "Id" ) );
        addDbField ( "fechaz", BlDbField::DbDate, BlDbField::DbNotNull, _ ( "Fecha" ) );
        addDbField ( "horaz", BlDbField::DbVarChar, BlDbField::DbNotNull, _ ( "Hora" ) );
        addDbField ( "totalz", BlDbField::DbNumeric, BlDbField::DbNotNull, _ ( "Total" ) );
        addDbField ( "numtickets", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Num. tickets" ) );
        addDbField ( "idalmacen", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Id. almacen" ) );
        addDbField ( "nomalmacen", BlDbField::DbVarChar, BlDbField::DbNoSave, _ ( "Almacen" ) );

        mui_idalmacen->setMainCompany ( comp );


        mui_list->setMainCompany ( comp );
        mui_list->setDbTableName ( "albaran" );
        mui_list->setDbFieldId ( "idalbaran" );
        mui_list->addSubFormHeader ( "idalbaran",  BlDbField::DbInt, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Id albaran" ) );
        mui_list->addSubFormHeader ( "numalbaran",  BlDbField::DbVarChar, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Numero" ) );
        mui_list->addSubFormHeader ( "descalbaran",  BlDbField::DbVarChar, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Descripcion" ) );
        mui_list->addSubFormHeader ( "refalbaran",  BlDbField::DbVarChar, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Referencia" ) );
        mui_list->addSubFormHeader ( "fechaalbaran",  BlDbField::DbDate, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Fecha" ) );
        mui_list->addSubFormHeader ( "procesadoalbaran",  BlDbField::DbBoolean, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Procesado" ) );
        mui_list->addSubFormHeader ( "idforma_pago",  BlDbField::DbInt, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Id forma de pago" ) );
        mui_list->addSubFormHeader ( "descforma_pago",  BlDbField::DbVarChar, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite,  _ ( "Forma de pago" ) );
        mui_list->addSubFormHeader ( "anuladoalbaran",  BlDbField::DbBoolean, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Anulado" ) );
        mui_list->addSubFormHeader ( "horaalbaran",  BlDbField::DbVarChar, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Hora" ) );
        mui_list->addSubFormHeader ( "totalalbaran",  BlDbField::DbNumeric, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Total" ) );
        mui_list->addSubFormHeader ( "bimpalbaran",  BlDbField::DbNumeric, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Base Imponible" ) );
        mui_list->addSubFormHeader ( "impalbaran",  BlDbField::DbNumeric, BlDbField::DbNoSave, BlSubFormHeader::DbNoWrite, _ ( "Impuestos" ) );

        mui_list->setInsert ( false );
        mui_list->setDelete ( false );
        mui_list->setSortingEnabled ( true );

        dialogChanges_readValues();
        insertWindow ( windowTitle(), this, false );
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear el almacen" ) );
    } // end try
    
}
Exemplo n.º 16
0
/** inicializa todos los componentes de la clase.
    Resetea el sistema de control de cambios para que considere que no hay cambios por parte del usuario.
    Mete la ventana en el workSpace.
*/
Alarma::Alarma ( BlMainCompany *comp, QWidget *parent )
        : BlWidget ( comp, parent )
{
    BL_FUNC_DEBUG
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setupUi ( this );

    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear la ventana de importacion" ) );
    } // end try
    
}
Exemplo n.º 17
0
ServerLight::ServerLight ( BtCompany *emp ) : BlWidget (emp, 0)
{
    BL_FUNC_DEBUG

    m_tcpServer = new QTcpServer(this);
    if (!m_tcpServer->listen(QHostAddress::Any, 11637)) {
         blMsgInfo(m_tcpServer->errorString());
         return;
    }

    connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(conection()));

    g_plugins->run ( "ServerLight_ServerLight_Post", this );
    
}
Exemplo n.º 18
0
/**
\return
**/
void PedidosProveedorList::remove()
{
    BL_FUNC_DEBUG
    int a = mui_list->currentRow();
    if ( a < 0 ) {
        blMsgInfo ( _ ( "Debe seleccionar una linea" ), this );
        return;
    } // end if
    try {
        mdb_idpedidoproveedor = mui_list->dbValue ( QString ( "idpedidoproveedor" ) );
        if ( editMode() ) {
            PedidoProveedorView * ppv = new PedidoProveedorView ( ( BfCompany * ) mainCompany(), 0 );
            if ( ppv->load ( mdb_idpedidoproveedor ) ) {
                throw - 1;
            } // end if
            ppv->on_mui_borrar_clicked();
            ppv->close();
        } // end if
        presentar();
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al borrar el pedido a proveedor" ), this );
    } // end try
    
}
Exemplo n.º 19
0
/**
\param as
\return
**/
int BcAsientoSubForm_boton_iva ( BcAsientoSubForm *asientoSubForm )
{
    BL_FUNC_DEBUG
    
    asientoSubForm->save();
    try {
        int idborrador = asientoSubForm->dbValue ( "idborrador" ).toInt();
        RegistroIvaView *nuevae = new RegistroIvaView ( ( BcCompany * ) asientoSubForm->mainCompany(), 0 );
        nuevae->inicializa1 ( idborrador );
        ( ( BcCompany * ) asientoSubForm->mainCompany() ) ->pWorkspace() ->addSubWindow ( nuevae );
        nuevae->show();
    } catch ( ... ) {
        blMsgInfo ( _ ( "Debe seleccionar un apunte" ) );
        return 0;
    } // end try
    
    return 0;
}
Exemplo n.º 20
0
void BcExtractoView::openAsiento()
{
    BL_FUNC_DEBUG
    
    QString idasiento = mui_list->dbValue ( "idasiento" );

    int resur = g_plugins->run ( "SNewBcAsientoView", (BfCompany *) mainCompany() );
    
    if ( ! resur) {
        blMsgInfo(_("No se pudo crear instancia de asientos."));
        return;
    } // end if
    
    BcAsientoView *asiento = (BcAsientoView *) g_plugParams;

    asiento ->muestraAsiento ( idasiento );
    asiento ->show();
    asiento ->setFocus();
}
Exemplo n.º 21
0
void RegIVAQToolButton::click()
{
    BL_FUNC_DEBUG

    BlSubForm *las = m_asiento1View->findChild<BlSubForm *> ("mui_list");
//    BcAsientoSubForm *las = m_asiento1View->mui_list;
    las->save();
    try {
        int idborrador = las->dbValue ( "idborrador" ).toInt();
        RegistroIvaView *nuevae = new RegistroIvaView ( ( BcCompany * ) las->mainCompany(), 0 );
        nuevae->inicializa1 ( idborrador );
        ( ( BcCompany * ) las->mainCompany() ) ->pWorkspace() ->addSubWindow ( nuevae );
        nuevae->show();
    } catch ( ... ) {
        blMsgInfo ( _("Debe seleccionar un apunte" ));
    } // end try

    
}
Exemplo n.º 22
0
void ConvocatoriaView::imprimir()
{
    BL_FUNC_DEBUG
    /// Comprobamos que se disponen de los datos minimos para imprimir el recibo.
    QString SQLQuery = "";

    if ( dbValue ( "idcliente" ).isEmpty() ) {
        /// El documento no se ha guardado y no se dispone en la base de datos de estos datos.
        blMsgInfo ( _ ( "Tiene que guardar el documento antes de poder imprimirlo." ), this );
        return;
    }
    /// Disparamos los plugins
    int res = g_plugins->run ( "CoboView_on_mui_imprimir_clicked", this );
    if ( res != 0 ) {
        return;
    } // end if
    BfForm::imprimir();

    
}
Exemplo n.º 23
0
/**
\param comp
\param parent
**/
VencimientoCView::VencimientoCView ( BfCompany *comp, QWidget *parent )
        :  BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    try {
        setAttribute ( Qt::WA_DeleteOnClose );
        setupUi ( this );
        blCenterOnScreen ( this );

        /// Usurpamos la identidad de mlist y ponemos nuestro propio widget con sus cosillas.
        mui_refvencimientoc->setMainCompany ( comp );


        /// Establecemos los parametros de busqueda del Cliente
        mui_idcliente->setMainCompany ( comp );
        mui_idcliente->setLabel ( _ ( "Cliente:" ) );
        mui_idcliente->setTableName ( "cliente" );
        mui_idcliente->m_valores["cifcliente"] = "";
        mui_idcliente->m_valores["nomcliente"] = "";
 
        setTitleName ( tr ( "Vencimiento" ) );
        setDbTableName ( "vencimientoc" );
        setDbFieldId ( "idvencimientoc" );
        addDbField ( "idvencimientoc", BlDbField::DbInt, BlDbField::DbPrimaryKey, QApplication::translate ( "Cobro", "Id cobro" ) );
        addDbField ( "refvencimientoc", BlDbField::DbVarChar, BlDbField::DbNothing, QApplication::translate ( "Cobro", "Referencia de vencimiento" ) );
        addDbField ( "descvencimientoc", BlDbField::DbVarChar, BlDbField::DbNothing, QApplication::translate ( "Cobro", "Descripcion" ) );
        addDbField ( "comentvencimientoc", BlDbField::DbVarChar, BlDbField::DbNothing, QApplication::translate ( "Cobro", "Comentarios" ) );
        addDbField ( "fechavencimientoc", BlDbField::DbVarChar, BlDbField::DbNothing, QApplication::translate ( "Cobro", "Fecha de vencimiento" ) );
        addDbField ( "fechaefvencimientoc", BlDbField::DbVarChar, BlDbField::DbNothing, QApplication::translate ( "Cobro", "Fecha efectiva" ) );
        addDbField ( "estadovencimientoc", BlDbField::DbVarChar, BlDbField::DbNothing, QApplication::translate ( "Vencimiento", "Estado de vencimiento" ) );
        addDbField ( "cantvencimientoc", BlDbField::DbNumeric, BlDbField::DbNothing, QApplication::translate ( "Vencimiento", "Cantidad de vencimiento" ) );
        addDbField ( "idcliente", BlDbField::DbInt, BlDbField::DbNothing, QApplication::translate ( "Vencimiento", "idcliente de Vencimiento" ) );
        insertWindow ( windowTitle(), this, false );
        pintar();
        dialogChanges_readValues();
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( tr ( "Error al crear el pago" ), this );
    } // end try
    
}
Exemplo n.º 24
0
void AlbaranProveedorView::on_mui_verpedidosproveedor_clicked()
{
    BL_FUNC_DEBUG
    QString query = "SELECT * FROM pedidoproveedor WHERE refpedidoproveedor = '" + dbValue ( "refalbaranp" ) + "'";
    BlDbRecordSet *cur = mainCompany() ->loadQuery ( query );
    while ( !cur->eof() ) {
	/// Como estamos en un plugin buscamos nuevas formas de creacion de objetos.
	int resur = g_plugins->run ( "SNewPedidoProveedorView", ( BfCompany * ) mainCompany() );
	if ( !resur ) {
	      blMsgInfo (_( "no se pudo crear instancia de pedido proveedor" ));
	      return;
	} // end if
	PedidoProveedorView * pedpro = ( PedidoProveedorView * ) g_plugParams;
        pedpro->load ( cur->value( "idpedidoproveedor" ) );
        mainCompany() ->m_pWorkspace->addSubWindow ( pedpro );
        pedpro->show();
        cur->nextRecord();
    } // end while
    delete cur;
    
}
Exemplo n.º 25
0
void generarVencimientos (FacturaView *art) {
			BlDbRecordSet *cur1 = art->mainCompany()->loadQuery("SELECT totalfactura FROM factura WHERE idfactura = " + art->dbValue("idfactura"));
			blMsgInfo( _("El total de la factura es :") + cur1->value("totalfactura"));
			BlFixed contado("0.00");

			BlDbRecordSet *cur = art->mainCompany()->loadQuery("SELECT * FROM vencimientocliente WHERE idcliente = " + art->dbValue("idcliente"));
			while (!cur->eof())  {
				QString query = "SELECT ffactura + " + cur->value("diasvencimientocliente") + " AS fechav, totalfactura / 100 * "+cur->value("porcentajevencimientocliente")+" AS porcent FROM factura WHERE idfactura = " + art->dbValue("idfactura");
				if (cur->isLastRecord()) {
					query = "SELECT ffactura + " + cur->value("diasvencimientocliente") + " AS fechav, totalfactura - "+ contado.toQString('.') +" AS porcent FROM factura WHERE idfactura = " + art->dbValue("idfactura");
				} //end if
				BlDbRecordSet *cur2 = art->mainCompany()->loadQuery(query);
				/// REALIZAMOS EL QUERY
				query = "INSERT INTO vencimientoc (idfactura, fechavencimientoc, cantvencimientoc, idforma_pago, refvencimientoc, idcliente) VALUES ("+art->dbValue("idfactura")+",'"+cur2->value("fechav")+"',"+cur2->value("porcent")+","+cur->value("idforma_pago")+",'"+art->dbValue("reffactura")+"',"+art->dbValue("idcliente")+")";
				contado = contado + BlFixed(cur2->value("porcent"));
				art->mainCompany()->runQuery(query);
				delete cur2;
				cur->nextRecord();
			} // end while
			delete cur;
			delete cur1;
}
Exemplo n.º 26
0
/** Cuando hacemos un cobro y el valor del cobro es igual por referencia que todas las facturas
     con la misma referencia se procesan dichas facturas **/
int PagoView::afterSave()
{
    BL_FUNC_DEBUG

    QString query1 = "SELECT COALESCE(sum (cantpago), 0) AS totalp FROM pago WHERE refpago='" + dbValue ( "refpago" ) + "'";
    BlDbRecordSet *cur1 = mainCompany()->loadQuery ( query1 );

    QString query = "SELECT COALESCE(sum(totalfacturap), 0) AS total FROM facturap WHERE reffacturap='" + dbValue ( "refpago" ) + "'";
    BlDbRecordSet *cur = mainCompany()->loadQuery ( query );

    if ( cur->value( "total" ) == cur1->value( "totalp" ) ) {
        blMsgInfo ( _("Toda la referencia esta pagada. Se procesaran todos los documentos con esta referencia") );
        QString query2 = "UPDATE facturap set procesadafacturap = true WHERE reffacturap='" + dbValue ( "refpago" ) + "'";
        mainCompany()->runQuery ( query2 );
    } // end if
    delete cur;
    delete cur1;

    /// Disparamos los plugins.
    g_plugins->run ( "PagoView_afterSave_Post", this );  
    
    return 0;
}
Exemplo n.º 27
0
/** inicializa todos los componentes de la clase.
    Resetea el sistema de control de cambios para que considere que no hay cambios por parte del usuario.
    Mete la ventana en el workSpace.
*/
ConvReunionView::ConvReunionView ( BfCompany *comp, QWidget *parent ) : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    
    setAttribute ( Qt::WA_DeleteOnClose );
    
    try {
    
        setupUi ( this );
        blCenterOnScreen ( this );

        setTitleName ( _ ( "Convocatoria de reunion" ) );
        setDbTableName ( "reunion" );
        setDbFieldId ( "idreunion" );
        addDbField ( "idreunion", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "ID reunion" ) );
        addDbField ( "fecha1convocatoriareunion", BlDbField::DbDate, BlDbField::DbNotNull, _ ( "Fecha 1a Convocatoria" ) );
        addDbField ( "fecha2convocatoriareunion", BlDbField::DbDate, BlDbField::DbNothing, _ ( "Fecha 2a Convocatoria" ) );
        addDbField ( "hora1convocatoriareunion", BlDbField::DbVarChar, BlDbField::DbNotNull, _ ( "Hora 1a Convocatoria" ) );
        addDbField ( "hora2convocatoriareunion", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Hora 2a Convocatoria" ) );
        addDbField ( "tiporeunion", BlDbField::DbVarChar, BlDbField::DbNotNull, _ ( "Tipo" ) );
        addDbField ( "conceptoreunion", BlDbField::DbVarChar, BlDbField::DbNotNull, _ ( "Concepto" ) );
        addDbField ( "resolucionreunion", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Resolucion" ) );

        mui_list->setMainCompany( comp );
        mui_list->setDbTableName ( "asistentereunion" );
        mui_list->setDbFieldId ( "idasistentereunion" );
        mui_list->addSubFormHeader ( "idasistentereunion", BlDbField::DbInt, BlDbField::DbPrimaryKey, BlSubFormHeader::DbHideView | BlSubFormHeader::DbNoWrite, _ ( "ID asistentereunion" ) );
        mui_list->addSubFormHeader ( "idreunion", BlDbField::DbInt, BlDbField::DbNothing, BlSubFormHeader::DbHideView | BlSubFormHeader::DbNoWrite, _ ( "ID Reunion" ) );
        mui_list->addSubFormHeader ( "idcliente", BlDbField::DbInt, BlDbField::DbNotNull | BlDbField::DbRequired, BlSubFormHeader::DbHideView | BlSubFormHeader::DbNoWrite, _ ( "ID Socio" ) );
        mui_list->addSubFormHeader ( "nomcliente", BlDbField::DbVarChar, BlDbField::DbNoSave, BlSubFormHeader::DbNone, _ ( "Nombre Socio" ) );

        mui_list->setInsert ( TRUE );
        mui_list->setDelete ( TRUE );
        mui_list->setSortingEnabled ( FALSE );

	 /// Hacemos una carga vacia para que se inicie bien el subformulario
         mui_list->load("SELECT * from asistentereunion NATURAL LEFT JOIN cliente WHERE 1 = 2");

        mui_ordendia->setMainCompany( comp );
        mui_ordendia->setDbTableName ( "ordendiareunion" );
        mui_ordendia->setDbFieldId ( "idordendiareunion" );
        mui_ordendia->addSubFormHeader ( "idordendiareunion", BlDbField::DbInt, BlDbField::DbPrimaryKey, BlSubFormHeader::DbHideView | BlSubFormHeader::DbNoWrite, _ ( "ID Orden del dia" ) );
        mui_ordendia->addSubFormHeader ( "idreunion", BlDbField::DbInt, BlDbField::DbNothing, BlSubFormHeader::DbHideView | BlSubFormHeader::DbNoWrite, _ ( "ID Reunion" ) );
        mui_ordendia->addSubFormHeader ( "conceptoordendiareunion", BlDbField::DbVarChar, BlDbField::DbRequired, BlSubFormHeader::DbNone, _ ( "Concepto" ) );
        mui_ordendia->addSubFormHeader ( "textoordendiareunion", BlDbField::DbVarChar, BlDbField::DbNothing, BlSubFormHeader::DbNone, _ ( "Texto" ) );
        mui_ordendia->addSubFormHeader ( "resolucionordendiareunion", BlDbField::DbVarChar, BlDbField::DbNothing, BlSubFormHeader::DbNone, _ ( "Resolucion" ) );

        mui_ordendia->setInsert ( TRUE );
        mui_ordendia->setDelete ( TRUE );
        mui_ordendia->setSortingEnabled ( FALSE );
        
	 /// Hacemos una carga vacia para que se inicie bien el subformulario
         mui_ordendia->load("SELECT * from ordendiareunion WHERE 1 = 2");

        insertWindow ( windowTitle(), this, FALSE );
        pintar();
        dialogChanges_readValues();
        blScript(this);
    } catch ( ... ) {
    
        blMsgInfo ( _ ( "Error al crear la reunion" ), this );
        
    } // end try
    
    
}
bool PluginBc_CuentasAnuales2ODS::Arboles()
{
    BL_FUNC_DEBUG

    /// Para no acceder constantemete a la BD cada vez que se quiere averiguar el saldo
    /// de una cuenta, vamos a crear una estructura tipo arbol (usando la clase Arbol) donde,
    /// con un par consultas a BD, se averigüen todos los saldos y puedan estar disponibles en la RAM.

    /// Primero, averiguaremos la cantidad de ramas iniciales (tantos como
    /// numero de cuentas de nivel 2) y las vamos creando.
    dbConnection->begin();
    QString query = "SELECT *, nivel(codigo) AS nivel FROM cuenta ORDER BY codigo";
    BlDbRecordSet *ramas;
    ramas = dbConnection->loadQuery ( query, "Ramas" );
    dbConnection->commit();
    if ( ramas == NULL ) {
        blMsgInfo ( _ ( "Error con la base de datos" ) );
        return 0;
    }

    arbolEjercicioActual = new BcPlanContableArbol;
    arbolEjercicioAnterior = new BcPlanContableArbol;
    while ( !ramas->eof() ) {
        if ( ramas->value( "nivel" ).toInt() == 2 ) { /// Cuenta raiz.
            arbolEjercicioActual->nuevaRama ( ramas );
            arbolEjercicioAnterior->nuevaRama ( ramas );
        } // end if
        ramas->nextRecord();
    } // end while

    /// Inicializamos el arbol desde sus raices (desde sus cuentas de nivel 2)
    /// con el resto de cuentas (las hojas del arbol)
    arbolEjercicioActual->inicializa ( ramas );
    arbolEjercicioAnterior->inicializa ( ramas );

    /// Seguidamente, recopilamos todos los apuntes agrupados por cuenta para poder
    /// establecer asi los valores de cada cuenta para el Ejercicio N.
    dbConnection->begin();
    query = "SELECT cuenta.idcuenta, numapuntes, cuenta.codigo, saldoant, debe, haber,(COALESCE(saldoant,0) + COALESCE(saldop,0)) AS saldo, debeej, haberej, (COALESCE(saldoejp,0) + COALESCE(saldoant,0))AS saldoej  FROM (SELECT idcuenta, codigo FROM cuenta) AS cuenta NATURAL JOIN (SELECT idcuenta, count(idcuenta) AS numapuntes, COALESCE(sum(debe),0) AS debeej, COALESCE(sum(haber),0) AS haberej, (COALESCE(sum(debe),0)-COALESCE(sum(haber),0)) AS saldoejp FROM apunte WHERE EXTRACT(year FROM fecha) = '" + ejercicioActual_fechaBalance.right ( 4 ) + "' GROUP BY idcuenta) AS ejercicio LEFT OUTER JOIN (SELECT idcuenta, COALESCE(sum(debe),0) AS debe, COALESCE(sum(haber),0) AS haber, (COALESCE(sum(debe),0)-COALESCE(sum(haber),0)) AS saldop FROM apunte WHERE fecha >= '01/01/" + ejercicioActual_fechaBalance.right ( 4 ) + "' AND fecha <= '" + ejercicioActual_fechaBalance + "' AND conceptocontable !~* '.*asiento.*(cierre|regularizaci).*' GROUP BY idcuenta) AS periodo ON periodo.idcuenta=ejercicio.idcuenta LEFT OUTER JOIN (SELECT idcuenta, (COALESCE(sum(debe),0)-COALESCE(sum(haber),0)) AS saldoant FROM apunte WHERE fecha < '01/01/" + ejercicioActual_fechaBalance.right ( 4 ) + "' GROUP BY idcuenta) AS anterior ON cuenta.idcuenta=anterior.idcuenta ORDER BY codigo";


    BlDbRecordSet *hojas;
    hojas = dbConnection->loadQuery ( query, "Ejercicio N" );
    dbConnection->commit();
    if ( hojas == NULL ) {
        blMsgInfo ( _ ( "Error con la base de datos" ) );
        return 0;
    }

    /// Para cada cuenta con sus saldos ya calculados hay que actualizar las hojas del �rbol.
    while ( !hojas->eof() ) {
        arbolEjercicioActual->actualizaHojas ( hojas );
        hojas->nextRecord();
    } // end while

    /// Finalmente, recopilamos todos los apuntes agrupados por cuenta para poder
    /// establecer asi los valores de cada cuenta para el Ejercicio N-1.
    dbConnection->begin();
    query = "SELECT cuenta.idcuenta, numapuntes, cuenta.codigo, saldoant, debe, haber, (saldoant + saldop) AS saldo, debeej, haberej, (saldoant + saldoejp) AS saldoej FROM (SELECT idcuenta, codigo FROM cuenta) AS cuenta NATURAL JOIN (SELECT idcuenta, count(idcuenta) AS numapuntes, COALESCE(sum(debe),0) AS debeej, COALESCE (sum(haber),0) AS haberej, (COALESCE(sum(debe),0)-COALESCE(sum(haber),0)) AS saldoejp FROM apunte WHERE EXTRACT(year FROM fecha) = '" + ejercicioAnterior_fechaBalance.right ( 4 ) + "' GROUP BY idcuenta) AS ejercicio LEFT OUTER JOIN (SELECT idcuenta, COALESCE(sum(debe),0) AS debe, COALESCE(sum(haber),0) AS haber, (COALESCE(sum(debe),0)-COALESCE(sum(haber),0)) AS saldop FROM apunte WHERE fecha >= '01/01/" + ejercicioAnterior_fechaBalance.right ( 4 ) + "' AND fecha <= '" + ejercicioAnterior_fechaBalance + "' AND conceptocontable !~* '.*asiento.*(cierre|regularizaci).*' GROUP BY idcuenta) AS periodo ON periodo.idcuenta=ejercicio.idcuenta LEFT OUTER JOIN (SELECT idcuenta, (COALESCE(sum(debe),0)- COALESCE(sum(haber),0)) AS saldoant FROM apunte WHERE fecha < '01/01/" + ejercicioAnterior_fechaBalance.right ( 4 ) + "' GROUP BY idcuenta) AS anterior ON cuenta.idcuenta=anterior.idcuenta ORDER BY codigo";
    hojas = dbConnection->loadQuery ( query, "Ejercicio N-1" );
    dbConnection->commit();
    if ( hojas == NULL ) {
        blMsgInfo ( _ ( "Error con la base de datos" ) );
        return 0;
    }

    /// De nuevo, para cada cuenta con sus saldos ya calculados hay que actualizar las hojas del arbol.
    while ( !hojas->eof() ) {
        arbolEjercicioAnterior->actualizaHojas ( hojas );
        hojas->nextRecord();
    } // end while

    
    return 1;
}
Exemplo n.º 29
0
/**
\param comp
\param parent
**/
PedidoProveedorView::PedidoProveedorView ( BfCompany *comp, QWidget *parent )
        : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setupUi ( this );

        setTitleName ( _ ( "Pedido Proveedor" ) );
        setDbTableName ( "pedidoproveedor" );
        setDbFieldId ( "idpedidoproveedor" );
        addDbField ( "idpedidoproveedor", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "Id pedido proveedor" ) );
        addDbField ( "idproveedor", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Id proveedor" ) );
        addDbField ( "idalmacen", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Id almacen" ) );
        addDbField ( "numpedidoproveedor", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Numero pedido proveedor" ) );
        addDbField ( "fechapedidoproveedor", BlDbField::DbDate, BlDbField::DbNothing, _ ( "Fecha pedido proveedor" ) );
        addDbField ( "comentpedidoproveedor", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Comentario pedido" ) );
        addDbField ( "procesadopedidoproveedor", BlDbField::DbBoolean, BlDbField::DbNothing, _ ( "Pedido procesado" ) );
        addDbField ( "descpedidoproveedor", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Descripcion pedido" ) );
        addDbField ( "refpedidoproveedor", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Referencia pedido" ) );
        addDbField ( "idforma_pago", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Id forma de pago" ) );
        addDbField ( "idtrabajador", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Id trabajador" ) );
        addDbField ( "contactpedidoproveedor", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Persona de contacto proveedor" ) );
        addDbField ( "telpedidoproveedor", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Telefono proveedor" ) );

        /// Disparamos los plugins.
        int res = g_plugins->run ( "PedidoProveedorView_PedidoProveedorView", this );
        if ( res != 0 ) {
            return;
        } // end if

        /// Usurpamos la identidad de mlist y ponemos nuestro propio widget con sus cosillas.
        mui_lineasDetalle->setMainCompany ( comp );
        mui_lineasDetalle->inicializar();
        mui_idproveedor->setMainCompany ( comp );
        mui_idforma_pago->setMainCompany ( comp );
        mui_idforma_pago->setId ( "0" );
        mui_descuentos->setMainCompany ( comp );
        mui_descuentos->inicializar();
        mui_idalmacen->setMainCompany ( comp );
        mui_idalmacen->setId ( "0" );
        mui_idtrabajador->setMainCompany ( comp );
        mui_idtrabajador->setId ( "0" );
        mui_refpedidoproveedor->setMainCompany ( comp );

        /// Establecemos los parametros de busqueda del Cliente
        mui_idproveedor->setLabel ( _ ( "Proveedor:" ) );
        mui_idproveedor->setTableName ( "proveedor" );
        mui_idproveedor->m_valores["cifproveedor"] = "";
        mui_idproveedor->m_valores["nomproveedor"] = "";

        setListaLineas ( mui_lineasDetalle );
        setListaDescuentos ( mui_descuentos );

        dialogChanges_readValues();
        insertWindow ( windowTitle(), this, FALSE );
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear el pedido a proveedor" ), this );
    } // end try
    
}
Exemplo n.º 30
0
/**
\param comp
\param parent
**/
FacturaView::FacturaView ( BfCompany *comp, QWidget *parent )
        : BfForm ( comp, parent )
{
    BL_FUNC_DEBUG
    setupUi ( this );
    setAttribute ( Qt::WA_DeleteOnClose );
    try {
        setTitleName ( _ ( "Factura" ) );
        setDbTableName ( "factura" );
        setDbFieldId ( "idfactura" );
        addDbField ( "idfactura", BlDbField::DbInt, BlDbField::DbPrimaryKey, _ ( "Id factura" ) );
        addDbField ( "idcliente", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Cliente" ) );
        addDbField ( "idalmacen", BlDbField::DbInt, BlDbField::DbNotNull, _ ( "Almacen" ) );
        addDbField ( "numfactura", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Numero factura" ) );
        addDbField ( "ffactura", BlDbField::DbDate, BlDbField::DbNothing, _ ( "Ffactura" ) );
        addDbField ( "procesadafactura", BlDbField::DbBoolean, BlDbField::DbNothing, _ ( "Procesada factura" ) );
        addDbField ( "codigoserie_factura", BlDbField::DbVarChar, BlDbField::DbNotNull, _ ( "Serie" ) );
        addDbField ( "comentfactura", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Comentario" ) );
        addDbField ( "reffactura", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Referencia" ) );
        addDbField ( "descfactura", BlDbField::DbVarChar, BlDbField::DbNothing, _ ( "Descripcion" ) );
        addDbField ( "idtrabajador", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Trabajador" ) );
        addDbField ( "idforma_pago", BlDbField::DbInt, BlDbField::DbNothing, _ ( "Forma de pago" ) );

        /// Establecemos algunos Buddies.
        mui_labelAlmacen->setText ( _ ( "Al&macen" ) );
        mui_labelAlmacen->setBuddy ( mui_idalmacen );

        /// Disparamos los plugins.
        int res = g_plugins->run ( "FacturaView_FacturaView", this );
        if ( res != 0 ) {
            return;
        } // end if
        subform2->setMainCompany ( comp );
        mui_idalmacen->setMainCompany ( comp );
        mui_idforma_pago->setMainCompany ( comp );
        mui_idcliente->setMainCompany ( comp );
        m_descuentos->setMainCompany ( comp );
        mui_codigoserie_factura->setMainCompany ( comp );
        mui_reffactura->setMainCompany ( comp );
        mui_idtrabajador->setMainCompany ( comp );
      
        /// Inicializamos BfForm.
        setListaLineas ( subform2 );
        setListaDescuentos ( m_descuentos );

        /// Establecemos los parametros de busqueda del Cliente
        mui_idcliente->setLabel ( _ ( "Cliente:" ) );
        mui_idcliente->setTableName ( "cliente" );
        mui_idcliente->m_valores["cifcliente"] = "";
        mui_idcliente->m_valores["nomcliente"] = "";

        /// Establecemos valores por defecto en los combo boxes para que no se queden sin inicializar.
        mui_idalmacen->setId ( "" );
        mui_codigoserie_factura->setId ( "" );
        mui_idforma_pago->setId ( "" );
        mui_idtrabajador->setId ( "0" );

        m_totalBases->setReadOnly ( true );
        m_totalBases->setAlignment ( Qt::AlignRight );
        m_totalTaxes->setReadOnly ( true );
        m_totalTaxes->setAlignment ( Qt::AlignRight );
        m_totalDiscounts->setReadOnly ( true );
        m_totalDiscounts->setAlignment ( Qt::AlignRight );
        m_totalfactura->setReadOnly ( true );
        m_totalfactura->setAlignment ( Qt::AlignRight );
        insertWindow ( windowTitle(), this, false );
	blScript(this);
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error al crear la factura" ), this );
    }
    
}