/**
\param formula
\param return
\return
**/
bool BcCuentasAnualesImprimirView::procesaFormula ( const QDomNode &formula )
{
    BL_FUNC_DEBUG
    QDomElement valor = formula.firstChildElement ( "VALORACT" );
    //
    QString valors = valor.toElement().text();
    QString codigo = formula.parentNode().firstChildElement ( "CONCEPTO" ).toElement().text();
    //
    if ( !valor.isNull() ) {
        return true;
    } // end if
    BlFixed tvaloract = BlFixed ( "0.0" );
    BlFixed tvalorant = BlFixed ( "0.0" );
    QDomElement formula3 = formula.toElement();
    QDomNodeList litems = formula3.elementsByTagName ( "OPERADOR" );
    for ( int i = 0; i < litems.count(); i++ ) {
        QDomNode item = litems.item ( i );
        QDomElement e1 = item.toElement(); /// Try to convert the node to an element.
        if ( !e1.isNull() ) { /// The node was really an element.
            if ( !procesaOperador ( item ) )
                return false;
            QString valoract, valorant;
            if ( valorItem ( item, valoract, valorant ) ) {
                tvaloract = tvaloract + BlFixed ( valoract );
                tvalorant = tvalorant + BlFixed ( valorant );
            } else
                return false;
        } // end if
    } // end for
    QString tvaloracts = tvaloract.toQString();
    QString tvalorants = tvalorant.toQString();
    agregaValores ( formula, tvaloracts, tvalorants );
    
    return true;
}
/**
\param cuentaNegativa
\return
**/
BlFixed PluginBc_CuentasAnuales2ODS::cuentaNegativa ( BlFixed valor )
{
    BL_FUNC_DEBUG
    /// Comprueba que sea un numero negativo
    BlFixed resultado;
    if ( valor < BlFixed ( "0.00" ) )
        resultado = valor;
    else
        resultado = BlFixed ( "0.00" );
    return resultado;
}
int BtTicket_insertarArticuloCodigoNL_Post ( BtTicket *tick )
{
    BL_FUNC_DEBUG
    int valor = -1;
    static int semaforo = 0;
    if ( semaforo == 0 ) {
        valor = 0;
        semaforo = 1;
        QString query = "SELECT * FROM tc_articulo_alias LEFT JOIN tc_talla AS t1 ON tc_articulo_alias.idtc_talla = t1.idtc_talla LEFT JOIN tc_color AS t2 ON tc_articulo_alias.idtc_color = t2.idtc_color WHERE aliastc_articulo_tallacolor = '" + ( ( BtCompany * ) tick->mainCompany() )->valorBtInput() + "'";
        BlDbRecordSet *cur = tick->mainCompany() ->loadQuery ( query );
        if ( !cur->eof() ) {
            BlDbRecord * rec = tick->insertarArticulo ( cur->value( "idarticulo" ), BlFixed ( "1" ), true );
            rec->setDbValue ( "idtc_talla", cur->value( "idtc_talla" ) );
            rec->setDbValue ( "idtc_color", cur->value( "idtc_color" ) );
            rec->setDbValue ( "nomtc_talla", cur->value( "nomtc_talla" ) );
            rec->setDbValue ( "nomtc_color", cur->value( "nomtc_color" ) );
        } else {
	    valor = -1;
	} // end if
        delete cur;
        tick->pintar();
        semaforo = 0;
    } // end if
    
    return valor;
}
Esempio n. 4
0
/**
\param cuenta
**/
void BcPlanContableArbol::actualizaHojas ( BlDbRecordSet *cuenta )
{
    BL_FUNC_DEBUG

    int i = 0;
    bool actualizado = false;
    tipohoja *hojaraiz;
    QString cuentapadre = cuenta->value( "codigo" ).left ( 2 );

    /// Buscamos la rama del arbol que es la padre la cuenta pasada.
    for ( ; i < raiz.size(); ++i ) {
        hojaraiz = raiz.at ( i );
        if ( cuentapadre == hojaraiz->codigo )
            break;
    } // end for

    /// Si la rama principal se ha encontrado y tiene hijos, se actualiza
    if ( i < raiz.size() && hojaraiz->ramas ) {
        ActualizarHoja ( & ( hojaraiz->ramas ), cuenta, &actualizado );
        if ( actualizado ) {
            hojaraiz->saldoant = hojaraiz->saldoant + BlFixed ( cuenta->value( "saldoant" ) );
            hojaraiz->debe = hojaraiz->debe + BlFixed ( cuenta->value( "debe" ) );
            hojaraiz->haber = hojaraiz->haber + BlFixed ( cuenta->value( "haber" ) );
            hojaraiz->saldo = hojaraiz->saldo + BlFixed ( cuenta->value( "saldo" ) );
            hojaraiz->debeej = hojaraiz->debeej + BlFixed ( cuenta->value( "debeej" ) );
            hojaraiz->haberej = hojaraiz->haberej + BlFixed ( cuenta->value( "haberej" ) );
            hojaraiz->saldoej = hojaraiz->saldoej + BlFixed ( cuenta->value( "saldoej" ) );
            hojaraiz->numapuntes += cuenta->value( "numapuntes" ).toInt();
        } // end if
    } // end if

    
}
Esempio n. 5
0
void TicketClienteView::calculaypintatotales() {
  
  if (!m_listalineas) return;
  //blMsgInfo("Calculo y pinto los totales");
  /*
 *     m_totalBases->setText ( base.toQString() );
    m_totalTaxes->setText ( iva.toQString() );
    m_totalalbaran->setText ( total.toQString() );
    m_totalDiscounts->setText ( desc.toQString() );
    m_totalIRPF->setText ( QString ( irpf.toQString() ) );
    m_totalReqEq->setText ( QString ( reqeq.toQString() ) );
    */
  BlFixed total("0.00");
  BlFixed impuestos("0.00");
  BlFixed bimp("0.00");
  BlDbSubFormRecord *linea;
    
  
   for ( int i = 0; i < m_listalineas->rowCount(); ++i ) {
        linea = m_listalineas->lineaat ( i );
        BlFixed cant ( linea->dbValue ( "cantlalbaran" ));
        BlFixed pvpund ( linea->dbValue ( "pvpivainclalbaran"));
	BlFixed ivalin ( linea->dbValue ( "ivalalbaran"));
	
	BlFixed totallinea = cant * pvpund;
	totallinea.setPrecision(2);
	total = total + totallinea;
	
	BlFixed ivalinea = totallinea - totallinea / (BlFixed("1.00") + (ivalin / BlFixed("100.00")));
	ivalinea.setPrecision(2);
	impuestos = impuestos + ivalinea;
		
    } // end for
    // Calculamos la base imponible
    bimp = total - impuestos;

  m_totalalbaran->setText( total.toQString());
  m_totalTaxes-> setText( impuestos.toQString());
  m_totalBases -> setText (bimp.toQString());
  
}
int BtTicket_insertarArticuloNL_Post ( BtTicket *tick )
{
    BL_FUNC_DEBUG
    QString query = "SELECT * FROM tc_articulo_alias WHERE aliastc_articulo_tallacolor = '" + ( ( BtCompany * ) tick->mainCompany() )->valorBtInput() + "'";
    BlDbRecordSet *cur = tick->mainCompany() ->loadQuery ( query );
    if ( !cur->eof() ) {
        tick->insertarArticulo ( cur->value( "idarticulo" ), BlFixed ( "1" ) );
    } // end if
    delete cur;
    
    return 0;
}
Esempio 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.
*/
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
    
}
Esempio n. 8
0
void ArtGraficos::on_mui_list_cellClicked ( int row, int column )
{
    BL_FUNC_DEBUG

    QString artvarios = g_confpr->value( CONF_ARTICULOS_VARIOS );
    QString codigo = m_articulos[row][column];
    QString idArticulo = m_nodarticulos[row][column].firstChildElement("IDARTICULO").toElement().text();
    BtTicket *tick = (( BtCompany * ) mainCompany() ) ->ticketActual();


    /// Buscamos si ya hay una linea con el articulo que buscamos
    BlDbRecord *m_lineaActual = NULL;
    BlDbRecord *item;
    bool nuevaLinea = artvarios.contains ( codigo );


    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        item = tick->listaLineas() ->at ( i );
        if ( item->dbValue ( "idarticulo" ) == idArticulo )
            m_lineaActual = item;
    }// end for

    if ( m_lineaActual && nuevaLinea == false ) {
        /// Ya hay una linea con este articulo (es un agregado)
        BlFixed cantidadib ( m_lineaActual->dbValue ( "cantlalbaran" ) );
        BlFixed cant1 = cantidadib + BlFixed("1");
        m_lineaActual->setDbValue ( "cantlalbaran", cant1.toQString() );
    } else {
        /// No hay ningun item con este articulo (es una insercion)
        m_lineaActual = tick->agregarLinea();
        m_lineaActual->setDbValue ( "idarticulo", idArticulo );
	    QString a("1.00");
        m_lineaActual->setDbValue ( "cantlalbaran", "1.00" );
	m_lineaActual->setDbValue ( "pvpivainclalbaran", m_nodarticulos[row][column].firstChildElement("PVPIVAINCARTICULO").toElement().text());
	m_lineaActual->setDbValue ( "pvplalbaran", m_nodarticulos[row][column].firstChildElement("PVPARTICULO").toElement().text());
	m_lineaActual->setDbValue ( "codigocompletoarticulo", m_nodarticulos[row][column].firstChildElement("PVPIVAINCARTICULO").toElement().text());
	m_lineaActual->setDbValue ( "nomarticulo", m_nodarticulos[row][column].firstChildElement("NOMARTICULO").toElement().text());
	m_lineaActual->setDbValue ( "desclalbaran", m_nodarticulos[row][column].firstChildElement("NOMARTICULO").toElement().text());
	m_lineaActual->setDbValue ( "ivalalbaran", m_nodarticulos[row][column].firstChildElement("IVAARTICULO").toElement().text());

    } // end if

    /// Pintamos el ticket ya que se ha modificado.
    tick->pintar();

    BlDebug::blDebug("END ArtGraficos::on_mui_list_cellClicked");
}
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;
}
Esempio n. 10
0
void MTicketDesglose::pintar()
{
    BL_FUNC_DEBUG
    BtTicket *tick =     ( ( BtCompany * ) mainCompany() ) ->ticketActual();
    //QString html = "<font size=\"1\">";
    QString html = "<p style=\"font-family:monospace; font-size: 12pt;\">";
    QString html1 = "<font size=\"1\">";

    html1 += "Ticket: " + tick->dbValue ( "nomticket" ) + "<BR>";

    QString querytrab = "SELECT * FROM trabajador WHERE idtrabajador = " + tick->dbValue ( "idtrabajador" );
    BlDbRecordSet *curtrab = mainCompany() ->loadQuery ( querytrab );
    html1 += "Trabajador: " + tick->dbValue ( "idtrabajador" ) + " " + curtrab->value( "nomtrabajador" ) + "<BR>";
    delete curtrab;
    QString query = "SELECT * FROM cliente WHERE idcliente = " + tick->dbValue ( "idcliente" );
    BlDbRecordSet *cur1 = mainCompany() ->loadQuery ( query );
    html1 += "Cliente: " + tick->dbValue ( "idcliente" ) + " " + cur1->value( "nomcliente" ) + "<BR>";
    delete cur1;

    html += "<TABLE border=\"0\">";
    BlDbRecord *item;
    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        item = tick->listaLineas() ->at ( i );
        QString bgcolor = "#FFFFFF";
        if ( item == tick->lineaActBtTicket() ) bgcolor = "#CCCCFF";
        html += "<TR>";
        html += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + item->dbValue ( "cantlalbaran" ) + "</TD>";
        html += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomarticulo" ) + "</TD>";
        BlFixed totalLinea ( "0.00" );
        totalLinea = BlFixed ( item->dbValue ( "cantlalbaran" ) ) * BlFixed ( item->dbValue ( "pvplalbaran" ) );
        html += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + totalLinea.toQString() + "</TD>";
        html += "</TR>";
    }// end for
    html += "</TABLE>";

// ======================================
    html += "<BR><HR><BR>";
    base basesimp;
    base basesimpreqeq;
    BlDbRecord *linea;
    /// Impresion de los contenidos.
    QString l;
    BlFixed irpf ( "0" );

    BlDbRecordSet *cur = mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre = 'IRPF'" );
    if ( cur ) {
        if ( !cur->eof() ) {
            irpf = BlFixed ( cur->value( "valor" ) );
        } // end if
        delete cur;
    } // end if


    BlFixed descuentolinea ( "0.00" );
    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        linea = tick->listaLineas() ->at ( i );
        BlFixed cant ( linea->dbValue ( "cantlalbaran" ) );
        BlFixed pvpund ( linea->dbValue ( "pvplalbaran" ) );
        BlFixed desc1 ( linea->dbValue ( "descuentolalbaran" ) );
        BlFixed cantpvp = cant * pvpund;
        BlFixed base = cantpvp - cantpvp * desc1 / 100;
        descuentolinea = descuentolinea + ( cantpvp * desc1 / 100 );
        basesimp[linea->dbValue ( "ivalalbaran" ) ] = basesimp[linea->dbValue ( "ivalalbaran" ) ] + base;
        basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] = basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] + base;
    } // end for

    BlFixed basei ( "0.00" );
    base::Iterator it;
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        basei = basei + it.value();
    } // end for

    /// Calculamos el total de los descuentos.
    /// De momento aqui no se usan descuentos generales en venta.
    BlFixed porcentt ( "0.00" );
    /*
        BlDbSubFormRecord *linea1;
        if (m_listadescuentos->rowCount()) {
            for (int i = 0; i < m_listadescuentos->rowCount(); ++i) {
                linea1 = m_listadescuentos->lineaat(i);
                BlFixed propor(linea1->dbValue("proporcion" + m_listadescuentos->tableName()).toAscii().constData());
                porcentt = porcentt + propor;
            } // end for
        } // end if
    */

    /// Calculamos el total de base imponible.
    BlFixed totbaseimp ( "0.00" );
    BlFixed parbaseimp ( "0.00" );
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        if ( porcentt > BlFixed ( "0.00" ) ) {
            parbaseimp = it.value() - it.value() * porcentt / 100;
        } else {
            parbaseimp = it.value();
        } // end if
        html1 += "Base Imp " + it.key() + "% " + parbaseimp.toQString() + "<BR>";
        totbaseimp = totbaseimp + parbaseimp;
    } // end for

    /// Calculamos el total de IVA.
    BlFixed totiva ( "0.00" );
    BlFixed pariva ( "0.00" );
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        BlFixed piva ( it.key().toAscii().constData() );
        if ( porcentt > BlFixed ( "0.00" ) ) {
            pariva = ( it.value() - it.value() * porcentt / 100 ) * piva / 100;
        } else {
            pariva = it.value() * piva / 100;
        } // end if
        html1 += "IVA " + it.key() + "% " + pariva.toQString() + "<BR>";
        totiva = totiva + pariva;
    } // end for

    /// Calculamos el total de recargo de equivalencia.
    BlFixed totreqeq ( "0.00" );
    BlFixed parreqeq ( "0.00" );
    for ( it = basesimpreqeq.begin(); it != basesimpreqeq.end(); ++it ) {
        BlFixed preqeq ( it.key().toAscii().constData() );
        if ( porcentt > BlFixed ( "0.00" ) ) {
            parreqeq = ( it.value() - it.value() * porcentt / 100 ) * preqeq / 100;
        } else {
            parreqeq = it.value() * preqeq / 100;
        } // end if
        html1 += "R.Eq " + it.key() + "% " + parreqeq.toQString() + "<BR>";
        totreqeq = totreqeq + parreqeq;
    } // end for



    BlFixed totirpf = totbaseimp * irpf / 100;

    html1 += "<B>Base Imp. " + totbaseimp.toQString() + "<BR>";
    html1 += "<B>IVA. " + totiva.toQString() + "<BR>";
    html1 += "<B>IRPF. " + totirpf.toQString() + "<BR>";

    BlFixed total = totiva + totbaseimp + totreqeq - totirpf;
    html1 += "<B>Total: " + total.toQString() + "<BR>";



    html += "</p>";
    html1 += "</FONT>";

// ======================================
    /// Pintamos el HTML en el textBrowser
    setText ( html1 );
    
}
/**
\return
**/
void BcCuentasAnualesImprimirView::on_mui_aceptar_clicked()
{
    BL_FUNC_DEBUG
    QString finicial = mui_fechainicial->text();
    QString ffinal = mui_fechafinal->text();
    QString finicial1 = mui_fechainicial1->text();
    QString ffinal1 = mui_fechafinal1->text();
    if ( finicial1 == "" ) {
        finicial1 = finicial;
    } // end if
    if ( ffinal1 == "" ) {
        ffinal1 = ffinal;
    }
    if ( finicial == "" || ffinal == "" ) {
        return;
    } // end if


    /** Version sin ARBOL

        /// Ponemos todos los valores de las cuentas. Hacemos la carga.
        QDomNodeList lcuentas = m_doc.elementsByTagName("CUENTA");
        for (int i = 0; i < lcuentas.count(); i++) {
            QDomNode cuenta = lcuentas.item(i);
            QDomElement e1 = cuenta.toElement(); /// try to convert the node to an element.
            if( !e1.isNull() ) { /// the node was really an element.
                /// Este es el c&aacute;lculo de los saldos para la cuenta.
                QString query = "SELECT saldototal('" + e1.text() + "','" + finicial + "','" + ffinal + "') AS valoract, saldototal('" + e1.text() + "','" + finicial1 + "','" + ffinal1 + "') AS valorant";
                BlDbRecordSet *cur = mainCompany()->loadQuery(query);
                if (!cur->eof()) {
                    QString valoract = cur->value("valoract");
                    QString valorant = cur->value("valorant");
                    QDomNode c = e1.parentNode();
                    agregaValores(c, valoract, valorant);
                } // end if
                delete cur;
            } // end if
        } // end for

    **/

    /** Version con ARBOL: mas rollo de codigo pero muuuucho mas eficiente **/
    /// Vamos a crear un arbol en la memoria dinamica con
    /// los distintos niveles de cuentas.


    /// Primero, averiguaremos la cantidad de ramas iniciales (tantos como
    /// numero de cuentas de nivel 2) y las vamos creando.
    mainCompany() ->begin();
    QString query = "SELECT *, nivel(codigo) AS nivel FROM cuenta ORDER BY codigo";
    BlDbRecordSet *ramas;
    ramas = mainCompany() ->loadQuery ( query, "Ramas" );
    BcPlanContableArbol *arbolP1, *arbolP2; /// un arbol por cada periodo
    arbolP1 = new BcPlanContableArbol;
    arbolP2 = new BcPlanContableArbol;
    while ( !ramas->eof() ) {
        if ( atoi ( ramas->value( "nivel" ).toLatin1().constData() ) == 2 ) { /// Cuenta ra&iacute;z.
            arbolP1->nuevaRama ( ramas );
            arbolP2->nuevaRama ( ramas );
        } // end if
        ramas->nextRecord();
    } // end while
    arbolP1->inicializa ( ramas );
    arbolP2->inicializa ( ramas );
    delete ramas;
    mainCompany() ->commit();

    QRegExp rx ( "^.*perdidas y ganancias.*$" ); /// filtro para saber si es el de perdidas y ganancias
    rx.setCaseSensitivity ( Qt::CaseInsensitive );
    QString asiento;
    /// Discernimos entre Balances y Cuenta de Resultados
    if ( rx.exactMatch ( m_doc.elementsByTagName ( "TITULO" ).item ( 0 ).toElement().text() ) )
        /// Hay que excluir el asiento de Regularizacion para el calculo de beneficios o perdidas si existe ya en el periodo
        asiento = "%Asiento de Regularizaci%";
    else
        asiento = "%Asiento de Cierre%"; /// No hay que tener en cuenta el asiento de cierre para obtener los saldos

    /// OJO!! Antes de nada, hay que calcular el asiento de REGULARIZACION que nos guarda el resultado en la 129
    BcAsientoView *asientoReg;

        int resur = g_plugins->run ( "SNewBcAsientoView", (BcCompany *) mainCompany() );
        if ( ! resur) {
            blMsgInfo("No se pudo crear instancia de asientos");
            return;
        } // end if
        asientoReg = (BcAsientoView *) g_plugParams;
//    ( ( BcCompany * ) mainCompany() ) ->regularizaempresa ( finicial, ffinal );
    asientoReg ->asientoRegularizacion ( finicial, ffinal );

    /// Ahora, recopilamos todos los apuntes agrupados por cuenta para poder
    /// establecer as&iacute; los valores de cada cuenta para el periodo 1.
    mainCompany() ->begin();
    query = "SELECT cuenta.idcuenta, numapuntes, cuenta.codigo, saldoant, debe, haber, saldo, debeej, haberej, saldoej FROM (SELECT idcuenta, codigo FROM cuenta) AS cuenta NATURAL JOIN (SELECT idcuenta, count(idcuenta) AS numapuntes,sum(debe) AS debeej, sum(haber) AS haberej, (sum(debe)-sum(haber)) AS saldoej FROM apunte WHERE EXTRACT(year FROM fecha) = EXTRACT(year FROM timestamp '" + finicial + "') GROUP BY idcuenta) AS ejercicio LEFT OUTER JOIN (SELECT idcuenta,sum(debe) AS debe, sum(haber) AS haber, (sum(debe)-sum(haber)) AS saldo FROM apunte WHERE fecha >= '" + finicial + "' AND fecha <= '" + ffinal + "' AND conceptocontable NOT SIMILAR TO '" + asiento + "' GROUP BY idcuenta) AS periodo ON periodo.idcuenta=ejercicio.idcuenta LEFT OUTER JOIN (SELECT idcuenta, (sum(debe)-sum(haber)) AS saldoant FROM apunte WHERE fecha < '" + finicial + "' GROUP BY idcuenta) AS anterior ON cuenta.idcuenta=anterior.idcuenta ORDER BY codigo";
    BlDbRecordSet *hojas;
    hojas = mainCompany() ->loadQuery ( query, "Periodo1" );
    /// Para cada cuenta con sus saldos calculados hay que actualizar hojas del &aacute;rbol.
    while ( !hojas->eof() ) {
        arbolP1->actualizaHojas ( hojas );
        hojas->nextRecord();
    } // end while
    mainCompany() ->commit();
    asientoReg->on_mui_borrar_clicked ( false ); /// borramos el asiento temporal creado indicando que no queremos confirmacion

    /// Para el segundo periodo, calculamos el asiento de REGULARIZACION que nos guarda el resultado en la 129
//    ( ( BcCompany * ) mainCompany() ) ->regularizaempresa ( finicial1, ffinal1 );
    asientoReg ->asientoRegularizacion ( finicial1, ffinal1 );
//    asientoReg = ( ( BcCompany * ) mainCompany() ) ->intapuntsempresa2();

    /// Ahora, recopilamos todos los apuntes agrupados por cuenta para poder
    /// establecer as&iacute; los valores de cada cuenta para el periodo 2.
    mainCompany() ->begin();
    query = "SELECT cuenta.idcuenta, numapuntes, cuenta.codigo, saldoant, debe, haber, saldo, debeej, haberej, saldoej FROM (SELECT idcuenta, codigo FROM cuenta) AS cuenta NATURAL JOIN (SELECT idcuenta, count(idcuenta) AS numapuntes,sum(debe) AS debeej, sum(haber) AS haberej, (sum(debe)-sum(haber)) AS saldoej FROM apunte WHERE EXTRACT(year FROM fecha) = EXTRACT(year FROM timestamp '" + finicial1 + "') GROUP BY idcuenta) AS ejercicio LEFT OUTER JOIN (SELECT idcuenta,sum(debe) AS debe, sum(haber) AS haber, (sum(debe)-sum(haber)) AS saldo FROM apunte WHERE fecha >= '" + finicial1 + "' AND fecha <= '" + ffinal1 + "' AND conceptocontable NOT SIMILAR TO '" + asiento + "' GROUP BY idcuenta) AS periodo ON periodo.idcuenta=ejercicio.idcuenta LEFT OUTER JOIN (SELECT idcuenta, (sum(debe)-sum(haber)) AS saldoant FROM apunte WHERE fecha < '" + finicial1 + "' GROUP BY idcuenta) AS anterior ON cuenta.idcuenta=anterior.idcuenta ORDER BY codigo";
    hojas = mainCompany() ->loadQuery ( query, "Periodo2" );
    /// Para cada cuenta con sus saldos calculados hay que actualizar hojas del &aacute;rbol.
    while ( !hojas->eof() ) {
        arbolP2->actualizaHojas ( hojas );
        hojas->nextRecord();
    } // end while
    delete hojas;
    mainCompany() ->commit();
    asientoReg->on_mui_borrar_clicked ( false ); /// borramos indicando que no queremos confirmacion

    QDomNodeList lcuentas = m_doc.elementsByTagName ( "CUENTA" );
    for ( int i = 0; i < lcuentas.count(); i++ ) {
        QDomNode cuenta = lcuentas.item ( i );
        QDomElement e1 = cuenta.toElement();
        QString valorP1, valorP2;
        BlFixed valor = BlFixed ( "0.00" );
        if ( !e1.isNull() ) {
            if ( arbolP1->irHoja ( e1.text() ) )
                valor = BlFixed ( arbolP1->hojaActual ( "saldo" ) );
            else
                valor = BlFixed ( "0.00" );
            valorP1 = valor.toQString();
            if ( arbolP2->irHoja ( e1.text() ) )
                valor = BlFixed ( arbolP2->hojaActual ( "saldo" ) );
            else
                valor = BlFixed ( "0.00" );
            valorP2 = valor.toQString();
            QDomNode c = e1.parentNode();
            agregaValores ( c, valorP1, valorP2 );
        } // end if
    } // end for

    /// Eliminamos el &aacute;rbol y cerramos la conexi&oacute;n con la BD.
    delete arbolP1;
    delete arbolP2;

    /** Fin de la version con ARBOL **/

    /// Hacemos el calculo recursivo del balance.
    bool terminado = false;
    while ( !terminado ) {
        terminado = true;
        /// Recogemos los valores de cuenta.
        QDomNodeList litems = m_doc.elementsByTagName ( "FORMULA" );
        for ( int i = 0; i < litems.count(); i++ ) {
            QDomNode item = litems.item ( i );
            QDomElement e1 = item.toElement(); /// Try to convert the node to an element.
            if ( !e1.isNull() ) { /// The node was really an element.
                terminado &= procesaFormula ( item );
            } // end if
        } // end for
    } // end while

    /// Una vez que tenemos el objeto bien generado y a punto pasamos a la generacion del PDF.
    imprimir ( finicial, ffinal, finicial1, ffinal1 );
    
}
int MTicketIVAInc_pintar ( MTicketIVAInc *mtick )
{
  BL_FUNC_DEBUG
  
  QString query;
  QString buscar;
  
  BtTicket *tick = ( ( BtCompany * ) mtick->mainCompany() )->ticketActual();
  QString plainTextContent = "";
  QString htmlContent = "<font size=\"4\", font-family:monospace>";
  
  htmlContent += "Ticket: " + tick->dbValue ( "nomticket" ) + "<BR>";
  plainTextContent += "Ticket: " + tick->dbValue ( "nomticket" ) + "\n";
  
  query = "SELECT idtrabajador, nomtrabajador FROM trabajador WHERE idtrabajador = " + tick->dbValue ( "idtrabajador" );
  BlDbRecordSet *rsTrabajador = mtick->mainCompany()->loadQuery ( query );
  plainTextContent += "Trabajador: " + rsTrabajador->value( "nomtrabajador" ) + "\n";
  htmlContent += "Trabajador: " + rsTrabajador->value( "nomtrabajador" ) + "<br>";
  delete rsTrabajador;
 
  query = "SELECT idcliente, nomcliente FROM cliente WHERE idcliente = " + tick->dbValue ( "idcliente" );
  BlDbRecordSet *rsCliente = mtick->mainCompany()->loadQuery ( query );
  plainTextContent += "Cliente: " + rsCliente->value( "nomcliente" ) + "\n";
  htmlContent += "Cliente: " + rsCliente->value( "nomcliente" ) + "<br>";
  delete rsCliente;
  
  htmlContent += "<br>";
  htmlContent += "<TABLE border=\"0\" width=\"100%\">";
  htmlContent += "<tr><td>" + QString(_("CANT:")) + "</td><td width=\"30%\">" + QString(_("ARTI:")) + "</td><td>" + QString(_("TALLA:")) + "</td><td>" + QString(_("COLOR:")) + "</td><td>" + QString(_("PREC:")) + "</td></tr>";
  htmlContent += "<tr><td colspan=\"5\" width=\"100%\" ><hr></td></tr>";
  plainTextContent += "\n";
  plainTextContent += "  " + QString(_("CANT:").rightJustified( 7, ' ', true )) + "  " + QString(_("ARTI:").leftJustified ( 15, ' ', true )) + "  " + QString(_("TALLA:").leftJustified( 7, ' ', true ))+ "  " + QString(_("COLOR:").leftJustified( 7, ' ', true ))+ "  " + QString(_("PRECIO:").leftJustified( 9, ' ', true )) + "\n";
  plainTextContent += "-----------------------------------------------------------\n";
  
//   if (tick->dbValue("nomticket") != "") {
//     htmlContent += "<TR><TD colspan=\"5\" align=\"center\"><B>" + tick->dbValue ( "nomticket" ) + "</B></td></tr>";
//   } // end if

  BlDbRecord *item;
  for ( int i = 0; i < tick->listaLineas()->size(); ++i ) {
      item = tick->listaLineas()->at ( i );
      QString bgcolor = "#FFFFFF";
      if ( item == tick->lineaActBtTicket() ) {
	    buscar = item->dbValue ( "nomarticulo" );
            bgcolor = "#CCCCFF";
            plainTextContent += "> ";
        } else {
            plainTextContent += "  ";
        } // end if
      htmlContent += "<TR>";
      htmlContent += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + item->dbValue ( "cantlalbaran" ) + "</TD>";
      htmlContent += "<TD bgcolor=\"" + bgcolor + "\" whidth>" + item->dbValue ( "nomarticulo" ) + "</TD>";
      htmlContent += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_talla" ) + "</TD>";
      htmlContent += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_color" ) + "</TD>";
      BlFixed totalLinea ( "0.00" );
      totalLinea = BlFixed ( item->dbValue ( "cantlalbaran" ) ) * BlFixed ( item->dbValue ( "pvpivainclalbaran" ) );
      htmlContent += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + totalLinea.toQString() + "</TD>";
      htmlContent += "</TR>";
      
      plainTextContent += item->dbValue("cantlalbaran").rightJustified ( 7, ' ', true ) + " ";
      plainTextContent += item->dbValue("nomarticulo").leftJustified ( 20, ' ', true ) + " ";
      plainTextContent += item->dbValue("nomtc_talla").leftJustified ( 7, ' ', true ) + " ";
      plainTextContent += item->dbValue("nomtc_color").leftJustified ( 7, ' ', true ) + " ";
      plainTextContent += totalLinea.toQString().leftJustified ( 9, ' ', true ) + "\n";
      
  } // end for
  
  htmlContent+= "</TABLE>";
  htmlContent += "<HR>";
  base basesimp;
  base basesimpreqeq;
  BlDbRecord *linea;
  
  QString l;
  BlFixed irpf ( "0" );

  BlDbRecordSet *cur = mtick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre = 'IRPF'" );
  
  if ( cur ) {
      if ( !cur->eof() ) {
	  irpf = BlFixed ( cur->value( "valor" ) );
      } // end if
      delete cur;
  } // end if

  BlFixed descuentolinea ( "0.00" );
  
  for ( int i = 0; i < tick->listaLineas()->size(); ++i ) {
      linea = tick->listaLineas()->at ( i );
      BlFixed cant ( linea->dbValue ( "cantlalbaran" ) );
      BlFixed pvpund ( linea->dbValue ( "pvpivainclalbaran" ) );
      BlFixed desc1 ( linea->dbValue ( "descuentolalbaran" ) );
      BlFixed cantpvp = cant * pvpund;
      BlFixed iva ( linea->dbValue ( "ivalalbaran" ) );
      BlFixed base = cantpvp - cantpvp * desc1 / 100;
      base = base / ( BlFixed ( "1" ) + ( iva / BlFixed ( "100" ) ) );
      descuentolinea = descuentolinea + ( cantpvp * desc1 / 100 );
      basesimp[linea->dbValue ( "ivalalbaran" ) ] = basesimp[linea->dbValue ( "ivalalbaran" ) ] + base;
      basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] = basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] + base;
  } // end for

  BlFixed basei ( "0.00" );
  base::Iterator it;
  
  for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
      basei = basei + it.value();
  } // end for
  mtick->mui_browser->setText ( htmlContent );
  mtick->mui_plainText->setPlainText ( plainTextContent );
  
  mtick->mui_browser->find ( buscar );
  QTextCursor cursor = mtick->mui_browser->textCursor();
  cursor.clearSelection();
  mtick->mui_browser->setTextCursor( cursor );
  
  
  
  return -1;
  
  
 
//     BtTicket *tick = ( ( BtCompany * ) mtick->mainCompany() )->ticketActual();
//     QString html = "<p style=\"font-family:monospace; font-size: 12pt;\">";
//     QString html1 = "<font size=\"1\">";
// 
//     html1 += "Ticket: " + tick->dbValue ( "nomticket" ) + "<BR>";
// 
//     QString querytrab = "SELECT * FROM trabajador WHERE idtrabajador = " + tick->dbValue ( "idtrabajador" );
//     BlDbRecordSet *curtrab = mtick->mainCompany()->loadQuery ( querytrab );
//     html1 += "Trabajador: " + tick->dbValue ( "idtrabajador" ) + " " + curtrab->value( "nomtrabajador" ) + "<BR>";
//     delete curtrab;
//     
//     QString query = "SELECT * FROM cliente WHERE idcliente = " + tick->dbValue ( "idcliente" );
//     BlDbRecordSet *cur1 = mtick->mainCompany()->loadQuery ( query );
//     html1 += "Cliente: " + tick->dbValue ( "idcliente" ) + " " + cur1->value( "nomcliente" ) + "<BR>";
//     delete cur1;
// 
//     html += "<TABLE border=\"0\" width=\"100%\">";
//     if (tick->dbValue("nomticket") != "") {
//       html += "<TR><TD colspan=\"5\" align=\"center\"><B>" + tick->dbValue ( "nomticket" ) + "</B></td></tr>";
//     } // end if
// 
//     BlDbRecord *item;
//     for ( int i = 0; i < tick->listaLineas()->size(); ++i ) {
//         item = tick->listaLineas()->at ( i );
//         QString bgcolor = "#FFFFFF";
//         if ( item == tick->lineaActBtTicket() ) bgcolor = "#CCCCFF";
//         html += "<TR>";
//         html += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + item->dbValue ( "cantlalbaran" ) + "</TD>";
//         html += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomarticulo" ) + "</TD>";
//         html += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_talla" ) + "</TD>";
//         html += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_color" ) + "</TD>";
//         BlFixed totalLinea ( "0.00" );
//         totalLinea = BlFixed ( item->dbValue ( "cantlalbaran" ) ) * BlFixed ( item->dbValue ( "pvpivainclalbaran" ) );
//         html += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + totalLinea.toQString() + "</TD>";
//         html += "</TR>";
//     } // end for
//     
//     html += "</TABLE>";    
//     html += "<BR><HR><BR>";
//     base basesimp;
//     base basesimpreqeq;
//     BlDbRecord *linea;
//     
//     /// Impresion de los contenidos.
//     QString l;
//     BlFixed irpf ( "0" );
// 
//     BlDbRecordSet *cur = mtick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre = 'IRPF'" );
//     
//     if ( cur ) {
//         if ( !cur->eof() ) {
//             irpf = BlFixed ( cur->value( "valor" ) );
//         } // end if
//         delete cur;
//     } // end if
// 
//     BlFixed descuentolinea ( "0.00" );
//     
//     for ( int i = 0; i < tick->listaLineas()->size(); ++i ) {
//         linea = tick->listaLineas()->at ( i );
//         BlFixed cant ( linea->dbValue ( "cantlalbaran" ) );
//         BlFixed pvpund ( linea->dbValue ( "pvpivainclalbaran" ) );
//         BlFixed desc1 ( linea->dbValue ( "descuentolalbaran" ) );
//         BlFixed cantpvp = cant * pvpund;
//         BlFixed iva ( linea->dbValue ( "ivalalbaran" ) );
//         BlFixed base = cantpvp - cantpvp * desc1 / 100;
//         base = base / ( BlFixed ( "1" ) + ( iva / BlFixed ( "100" ) ) );
//         descuentolinea = descuentolinea + ( cantpvp * desc1 / 100 );
//         basesimp[linea->dbValue ( "ivalalbaran" ) ] = basesimp[linea->dbValue ( "ivalalbaran" ) ] + base;
//         basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] = basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] + base;
//     } // end for
// 
//     BlFixed basei ( "0.00" );
//     base::Iterator it;
//     
//     for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
//         basei = basei + it.value();
//     } // end for
// 
//     /// Calculamos el total de los descuentos.
//     /// De momento aqui no se usan descuentos generales en venta.
//     BlFixed porcentt ( "0.00" );
// 
//     /// Calculamos el total de base imponible.
//     BlFixed totbaseimp ( "0.00" );
//     BlFixed parbaseimp ( "0.00" );
//     
//     for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
//         if ( porcentt > BlFixed ( "0.00" ) ) {
//             parbaseimp = it.value() - it.value() * porcentt / 100;
//         } else {
//             parbaseimp = it.value();
//         } // end if
//         html1 += "Base Imp " + it.key() + "% " + parbaseimp.toQString() + "<BR>";
//         totbaseimp = totbaseimp + parbaseimp;
//     } // end for
// 
//     /// Calculamos el total de IVA.
//     BlFixed totiva ( "0.00" );
//     BlFixed pariva ( "0.00" );
//     
//     for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
//         BlFixed piva ( it.key().toLatin1().constData() );
//         if ( porcentt > BlFixed ( "0.00" ) ) {
//             pariva = ( it.value() - it.value() * porcentt / 100 ) * piva / 100;
//         } else {
//             pariva = it.value() * piva / 100;
//         } // end if
//         html1 += "IVA " + it.key() + "% " + pariva.toQString() + "<BR>";
//         totiva = totiva + pariva;
//     } // end for
// 
//     /// Calculamos el total de recargo de equivalencia.
//     BlFixed totreqeq ( "0.00" );
//     BlFixed parreqeq ( "0.00" );
//     
//     for ( it = basesimpreqeq.begin(); it != basesimpreqeq.end(); ++it ) {
//         BlFixed preqeq ( it.key().toLatin1().constData() );
//         if ( porcentt > BlFixed ( "0.00" ) ) {
//             parreqeq = ( it.value() - it.value() * porcentt / 100 ) * preqeq / 100;
//         } else {
//             parreqeq = it.value() * preqeq / 100;
//         } // end if
//         html1 += "R.Eq " + it.key() + "% " + parreqeq.toQString() + "<BR>";
//         totreqeq = totreqeq + parreqeq;
//     } // end for
// 
//     BlFixed totirpf = totbaseimp * irpf / 100;
// 
//     html1 += "<B>Base Imp. " + totbaseimp.toQString() + "<BR>";
//     html1 += "<B>IVA. " + totiva.toQString() + "<BR>";
//     html1 += "<B>IRPF. " + totirpf.toQString() + "<BR>";
// 
//     BlFixed total = totiva + totbaseimp + totreqeq - totirpf;
//     html1 += "<B>Total: " + total.toQString() + "<BR>";
// 
//     html += "</p>";
//     html1 += "</FONT>";
// 
//     /// Pintamos el HTML en el textBrowser
//     mtick->mui_browser->setText ( html );
//     
//     return -1;
}
int BtTicket_imprimir(BtTicket *tick)
{
    BlDebug::blDebug("pluginbt_aliastallasycolores::BtTicket_imprimir",0);

    if ( tick->listaLineas()->size() ) {
        if( tick->listaLineas()->at ( 0 )->exists ( "pvpivainclalbaran" ) ) {
	    BtTicket_imprimirIVAInc(tick);
	    BlDebug::blDebug("END pluginbt_aliastallasycolores::BtTicket_imprimir",0);
	    return -1;
	} // end if
    } else {
        BlDebug::blDebug("END pluginbt_aliastallasycolores::BtTicket_imprimir",0);
        return -1;
    } // end if
    
    struct empresastr {
        QString nombre;
        QString direccionCompleta;
        QString codigoPostal;
        QString ciudad;
        QString provincia;
        QString telefono;
    } empresa;

    struct clientestr {
        QString cif;
        QString nombre;
    } cliente;

    struct trabajadorstr {
        QString nombre;
        QString id;
    } trabajador;

    struct almacenstr {
        QString nombre;
    } almacen;

    struct fechastr {
        QString dia;
        QString hora;
    } fecha;

    struct totalstr {
        BlFixed iva;
        BlFixed baseImponible;
        BlFixed totalIva;
    } total;

    BlDbRecordSet *cur = tick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre='NombreEmpresa'" );
    if ( !cur->eof() )
        empresa.nombre = cur->value( "valor" );
    delete cur;
    
    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre='CIF'" );
    if ( !cur->eof() )
        empresa.nombre += "\n" + cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre='DireccionCompleta'" );
    if ( !cur->eof() )
        empresa.direccionCompleta = cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre='CodPostal'" );
    if ( !cur->eof() )
        empresa.codigoPostal = cur->value( "valor" ).toLatin1();
    delete cur;

    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre='Ciudad'" );
    if ( !cur->eof() )
        empresa.ciudad = cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre='Telefono'" );
    if ( !cur->eof() )
        empresa.telefono = cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre='Provincia'" );
    if ( !cur->eof() )
        empresa.provincia = cur->value( "valor" );
    delete cur;

    fecha.dia = QDate::currentDate().toString ( "d-M-yyyy" );
    fecha.hora = QTime::currentTime().toString ( "HH:mm" );

    trabajador.id = tick->dbValue ( "idtrabajador" );
    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM trabajador WHERE idtrabajador=" + tick->dbValue ( "idtrabajador" ) );
    if ( !cur->eof() )
        trabajador.nombre = cur->value( "nomtrabajador" );
    
    delete cur;
    
    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM cliente WHERE idcliente=" + tick->dbValue ( "idcliente" ) );
    if ( !cur->eof() ) {
        cliente.cif = cur->value( "cifcliente" ).toLatin1();
        cliente.nombre = cur->value( "nomcliente" ).toLatin1();
    } // end if
    delete cur;

    cur = tick->mainCompany()->loadQuery ( "SELECT * FROM almacen WHERE idalmacen=" + tick->dbValue ( "idalmacen" ) );
    if ( !cur->eof() )
        almacen.nombre = cur->value( "nomalmacen" ).toLatin1() ;
    delete cur;

    BlDbRecord *linea;
    
    if ( tick->listaLineas()->size() ) {
        total.iva = BlFixed ( tick->listaLineas()->at ( 0 )->dbValue ( "ivalalbaran" ) );
    }
        
    for ( int i = 0; i < tick->listaLineas()->size(); ++i ) {
        linea = tick->listaLineas()->at ( i );
        BlFixed cantidad = BlFixed ( linea->dbValue ( "cantlalbaran" ) );
        total.baseImponible = total.baseImponible + cantidad * BlFixed ( linea->dbValue ( "pvplalbaran" ) );
    } // end for
    
    total.totalIva = total.baseImponible + total.baseImponible * total.iva / BlFixed ( "100" );

    BlEscPrinter pr ( g_confpr->value(CONF_DIR_USER) + "bulmatpv_ticket_tc.esc" );
    pr.initializePrinter();
    pr.setCharacterCodeTable ( page19 );
    pr.setJustification ( BlEscPrinter::center );

    if ( g_confpr->value( CONF_TPV_PRINTER_LOGO ) != "" ) {
        pr.printImage ( g_confpr->value( CONF_TPV_PRINTER_LOGO ) );
    } // end if
    
    pr.printText ( empresa.nombre + "\n" );
    pr.setCharacterPrintMode ( CHARACTER_FONTB_SELECTED );
    pr.setCharacterSize ( CHAR_WIDTH_1 | CHAR_HEIGHT_1 );
    pr.setColor ( red );
    pr.printText ( empresa.direccionCompleta + "\n" );
    pr.initializePrinter();
    pr.setCharacterCodeTable ( page19 );

    pr.printText ( "\n" );
    pr.printText ( fecha.dia + " " + fecha.hora + "\n" );
    pr.printText ( "Cliente, " + cliente.cif + " " + cliente.nombre + "\n" );
    pr.printText ( "\n" );

    pr.turnWhiteBlack ( 1 );
    pr.printText ( " Uds. PRODUCTO � � � � � �    P.U. IMPORTE\n" );

    pr.turnWhiteBlack ( 0 );
    pr.setCharacterPrintMode ( CHARACTER_FONTB_SELECTED );
    pr.setCharacterSize ( CHAR_WIDTH_1 | CHAR_HEIGHT_1 );

    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        if ( i == tick->listaLineas()->size() - 1 )
            pr.setUnderlineMode ( 1 );
            
        linea = tick->listaLineas() ->at ( i );
        BlFixed iva = BlFixed ( linea->dbValue ( "ivalalbaran" ) );
        BlFixed pvp = BlFixed ( linea->dbValue ( "pvplalbaran" ) );
        pvp = pvp + pvp * iva / BlFixed ( "100" );
        BlFixed pvptotal = BlFixed ( linea->dbValue ( "cantlalbaran" ) ) * pvp;
        pr.printText ( linea->dbValue ( "cantlalbaran" ).rightJustified ( 5, ' ', true ) + "  " );
        pr.printText ( linea->dbValue ( "desclalbaran" ).leftJustified ( 27, ' ', true ) + " " );
        QString pvpstr = pvp.toQString();
        QString pvptotalstr = pvptotal.toQString();
        pr.printText ( QString ( pvpstr + "�" ).rightJustified ( 10, ' ', true ) + " " );
        pr.printText ( QString ( pvptotalstr + "�" ).rightJustified ( 10, ' ', true ) );
        pr.printText ( "\n" );
    } // end for
    
    pr.setUnderlineMode ( 0 );
    pr.setJustification ( BlEscPrinter::right );
    pr.setCharacterPrintMode ( CHARACTER_FONTA_SELECTED );
    pr.printText ( "Base Imponible: " + total.baseImponible.toQString() + "�\n" );
    pr.printText ( "IVA " + total.iva.toQString() + "%:" + ( total.totalIva - total.baseImponible ).toQString() + "�\n" );
    pr.setCharacterPrintMode ( CHARACTER_FONTA_SELECTED | EMPHASIZED_MODE | DOUBLE_HEIGHT | DOUBLE_WIDTH );
    pr.printText ( "TOTAL: " + total.totalIva.toQString() + "�\n" );
    pr.printText ( "\n\n" );
    pr.setJustification ( BlEscPrinter::left );
    pr.setCharacterPrintMode ( CHARACTER_FONTA_SELECTED );
    pr.printText ( "Le ha atendido " + trabajador.nombre + "\n" );
    pr.printText ( "\n" );
    pr.printText ( "Tel. " + empresa.telefono + "\n" );
    pr.printText ( "\n" );
    pr.setJustification ( BlEscPrinter::center );
    pr.setColor ( red );
    pr.printText ( "*** GRACIAS POR SU VISITA ***\n" );
    QByteArray qba = tick->dbValue ( "refalbaran" ).toLatin1();
    char* barcode = qba.data();
    pr.setJustification ( BlEscPrinter::center );
    pr.setBarcodeFormat ( 2, 50, both, fontB );
    pr.printBarCode ( code39, qba.size(), barcode );
    pr.cutPaperAndFeed ( true, 10 );
    pr.print();
    
    /// Si queremos imprimir con CUPS lo hacemos de esta otra forma
    if (!g_confpr->value( CONF_TICKET_PRINTER_FILE).isEmpty() && g_confpr->value( CONF_TICKET_PRINTER_FILE) != "/dev/null") {
        QString comando = "cat " + g_confpr->value(CONF_DIR_USER) + "bulmatpv_ticket_tc.esc" + "  > " + g_confpr->value( CONF_TICKET_PRINTER_FILE );
        system ( comando.toLatin1().data() );
    } else if (g_confpr->value(CONF_CUPS_DEFAULT_PRINTER).isEmpty() || g_confpr->value(CONF_CUPS_DEFAULT_PRINTER).toLower() == "none") {
        BlDebug::blDebug("Debe establecer el parametro CONF_CUPS_DEFAULT_PRINTER o CONF_TICKET_PRINTER_FILE para imprimir el ticket " , 2);
    } else {
		blRawPrint ("bulmatpv_ticket_tc.esc");
    } // end if
    
    BlDebug::blDebug("END pluginbt_aliastallasycolores::BtTicket_imprimir",0);
    return -1;
}
Esempio n. 14
0
void Devolucion::pintar()
{
    if ( !m_ticket ) return;

// ====================== PINTAMOS ========================
    QString html = "<p style=\"font-family:monospace; font-size: 8pt;\">";
    QString html1 = "<font size=\"1\">";

    html1 += "Ticket: " + m_ticket->dbValue ( "nomticket" ) + "<BR>";

    QString querytrab = "SELECT * FROM trabajador WHERE idtrabajador = " + m_ticket->dbValue ( "idtrabajador" );
    BlDbRecordSet *curtrab = mainCompany() ->loadQuery ( querytrab );
    html1 += "Trabajador: " + m_ticket->dbValue ( "idtrabajador" ) + " " + curtrab->value( "nomtrabajador" ) + "<BR>";
    delete curtrab;
    QString query = "SELECT * FROM cliente WHERE idcliente = " + m_ticket->dbValue ( "idcliente" );
    BlDbRecordSet *cur1 = mainCompany() ->loadQuery ( query );
    html1 += "Cliente: " + m_ticket->dbValue ( "idcliente" ) + " " + cur1->value( "nomcliente" ) + "<BR>";
    delete cur1;

    if ( m_ticket->listaLineas()->size() > 0 ) {

        html += "<TABLE border=\"0\">";

        html += "<TR bgcolor = \"#CCCCCC\">";
        html += "<TD>SEL</TD>";
        for ( int z = 0; z < m_ticket->listaLineas()->at ( 0 )->lista()->size(); ++z ) {
            BlDbField *head = m_ticket->listaLineas()->at ( 0 )->lista()->at ( z );
            if ( head->fieldName().left ( 2 ) != "id" && head->fieldName().left ( 3 ) != "num" )
                html += "<TD>" + head->fieldName().left ( 4 ) + "</TD>";
        } // end for
        html += "</TR>";

        BlDbRecord *item;
        for ( int i = 0; i < m_ticket->listaLineas() ->size(); ++i ) {
            item = m_ticket->listaLineas() ->at ( i );

            html += "<TR>";
            html += "<TD><A NAME=\"plus\" HREF=\"?op=plus&numlalbaran=" + item->dbValue ( "numlalbaran" ) + "\">+</A>  <A HREF=\"?op=minus&numlalbaran=" + item->dbValue ( "numlalbaran" ) + "\">-</A></td>";
            for ( int j = 0; j < item->lista()->size(); ++j ) {
                BlDbField *camp = item->lista()->at ( j );
                if ( camp->fieldName().left ( 2 ) != "id" && camp->fieldName().left ( 3 ) != "num" )
                    html += "<TD>" + camp->fieldValue() + "</TD>";
            } // end for

            html += "</TR>";
        }// end for
        html += "</TABLE>";

    } // end if
// ======================================
    html += "<BR><HR><BR>";
    base basesimp;
    base basesimpreqeq;
    BlDbRecord *linea;
    /// Impresion de los contenidos.
    QString l;
    BlFixed irpf ( "0" );

    BlDbRecordSet *cur = mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre = 'IRPF'" );
    if ( cur ) {
        if ( !cur->eof() ) {
            irpf = BlFixed ( cur->value( "valor" ) );
        } // end if
        delete cur;
    } // end if


    BlFixed descuentolinea ( "0.00" );
    for ( int i = 0; i < m_ticket->listaLineas() ->size(); ++i ) {
        linea = m_ticket->listaLineas() ->at ( i );
        BlFixed cant ( linea->dbValue ( "cantlalbaran" ) );
        BlFixed pvpund ( linea->dbValue ( "pvplalbaran" ) );
        BlFixed desc1 ( linea->dbValue ( "descuentolalbaran" ) );
        BlFixed cantpvp = cant * pvpund;
        BlFixed base = cantpvp - cantpvp * desc1 / 100;
        descuentolinea = descuentolinea + ( cantpvp * desc1 / 100 );
        basesimp[linea->dbValue ( "ivalalbaran" ) ] = basesimp[linea->dbValue ( "ivalalbaran" ) ] + base;
        basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] = basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] + base;
    } // end for

    BlFixed basei ( "0.00" );
    base::Iterator it;
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        basei = basei + it.value();
    } // end for

    /// Calculamos el total de los descuentos.
    /// De momento aqui no se usan descuentos generales en venta.
    BlFixed porcentt ( "0.00" );

    /// Calculamos el total de base imponible.
    BlFixed totbaseimp ( "0.00" );
    BlFixed parbaseimp ( "0.00" );
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        if ( porcentt > BlFixed ( "0.00" ) ) {
            parbaseimp = it.value() - it.value() * porcentt / 100;
        } else {
            parbaseimp = it.value();
        } // end if
        html1 += "Base Imp " + it.key() + "% " + parbaseimp.toQString() + "<BR>";
        totbaseimp = totbaseimp + parbaseimp;
    } // end for

    /// Calculamos el total de IVA.
    BlFixed totiva ( "0.00" );
    BlFixed pariva ( "0.00" );
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        BlFixed piva ( it.key().toLatin1().constData() );
        if ( porcentt > BlFixed ( "0.00" ) ) {
            pariva = ( it.value() - it.value() * porcentt / 100 ) * piva / 100;
        } else {
            pariva = it.value() * piva / 100;
        } // end if
        html1 += "IVA " + it.key() + "% " + pariva.toQString() + "<BR>";
        totiva = totiva + pariva;
    } // end for

    /// Calculamos el total de recargo de equivalencia.
    BlFixed totreqeq ( "0.00" );
    BlFixed parreqeq ( "0.00" );
    for ( it = basesimpreqeq.begin(); it != basesimpreqeq.end(); ++it ) {
        BlFixed preqeq ( it.key().toLatin1().constData() );
        if ( porcentt > BlFixed ( "0.00" ) ) {
            parreqeq = ( it.value() - it.value() * porcentt / 100 ) * preqeq / 100;
        } else {
            parreqeq = it.value() * preqeq / 100;
        } // end if
        html1 += "R.Eq " + it.key() + "% " + parreqeq.toQString() + "<BR>";
        totreqeq = totreqeq + parreqeq;
    } // end for



    BlFixed totirpf = totbaseimp * irpf / 100;

    html1 += "<B>Base Imp. " + totbaseimp.toQString() + "<BR>";
    html1 += "<B>IVA. " + totiva.toQString() + "<BR>";
    html1 += "<B>IRPF. " + totirpf.toQString() + "<BR>";

    BlFixed total = totiva + totbaseimp + totreqeq - totirpf;
    html1 += "<B>Total: " + total.toQString() + "<BR>";

    html += "</p>";
    html1 += "</FONT>";

    if ( m_totalin == "" ) {
        mui_total->setText ( total.toQString() );
        m_totalin = total.toQString();
    }
    mui_newtotal->setText ( total.toQString() );
    BlFixed diff ( m_totalin );
    diff = diff - total;
    mui_difprice->setText ( diff.toQString() );


// ======================================
    /// Pintamos el HTML en el textBrowser
    mui_browser->setText ( html );
}
Esempio n. 15
0
QString Q19Writer::import ( BlDbRecordSet *cur, QString nomcamp, int longitud )
{

	return import ( BlFixed ( cur->value( nomcamp ) ),longitud ) ;
}
int BtTicket_imprimirIVAInc(BtTicket *tick)
{
    BL_FUNC_DEBUG
    
    struct empresastr {
        QString nombre;
        QString direccionCompleta;
        QString codigoPostal;
        QString ciudad;
        QString provincia;
        QString telefono;
    } empresa;

    struct clientestr {
        QString cif;
        QString nombre;
    } cliente;

    struct trabajadorstr {
        QString nombre;
        QString id;
    } trabajador;

    struct almacenstr {
        QString nombre;
    } almacen;

    struct fechastr {
        QString dia;
        QString hora;
    } fecha;

    struct totalstr {
        BlFixed iva;
        BlFixed baseImponible;
        BlFixed totalIva;
    } total;

    BlDbRecordSet *cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre='NombreEmpresa'" );
    if ( !cur->eof() )
        empresa.nombre = cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre='CIF'" );
    if ( !cur->eof() )
        empresa.nombre += "\n" + cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre='DireccionCompleta'" );
    if ( !cur->eof() )
        empresa.direccionCompleta = cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre='CodPostal'" );
    if ( !cur->eof() )
        empresa.codigoPostal = cur->value( "valor" ).toLatin1();
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre='Ciudad'" );
    if ( !cur->eof() )
        empresa.ciudad = cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre='Telefono'" );
    if ( !cur->eof() )
        empresa.telefono = cur->value( "valor" );
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM configuracion WHERE nombre='Provincia'" );
    if ( !cur->eof() )
        empresa.provincia = cur->value( "valor" );
    delete cur;

    fecha.dia = QDate::currentDate().toString ( "d-M-yyyy" );
    fecha.hora = QTime::currentTime().toString ( "HH:mm" );

    trabajador.id = tick->dbValue ( "idtrabajador" );
    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM trabajador WHERE idtrabajador=" + tick->dbValue ( "idtrabajador" ) );
    if ( !cur->eof() )
        trabajador.nombre = cur->value( "nomtrabajador" );
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM cliente WHERE idcliente=" + tick->dbValue ( "idcliente" ) );
    if ( !cur->eof() ) {
	if (cur->value("idcliente") != g_confpr->value(CONF_IDCLIENTE_DEFECTO)) {
        cliente.cif = cur->value( "cifcliente" ).toLatin1();
        cliente.nombre = cur->value( "nomcliente" ).toLatin1();
	} else {
	cliente.cif = "";
        cliente.nombre = "";
	} // end if
    } // end if
    delete cur;

    cur = tick->mainCompany() ->loadQuery ( "SELECT * FROM almacen WHERE idalmacen=" + tick->dbValue ( "idalmacen" ) );
    if ( !cur->eof() )
        almacen.nombre = cur->value( "nomalmacen" ).toLatin1() ;
    delete cur;

    BlDbRecord *linea;
    base totales;

    /// Inicializamos los componentes.
    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        linea = tick->listaLineas() ->at ( i );
	    BlFixed init("0.00");
        totales[linea->dbValue ( "ivalalbaran" ) ] = init;
    } // end for

    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        linea = tick->listaLineas() ->at ( i );
        BlFixed cantidad = BlFixed ( linea->dbValue ( "cantlalbaran" ) );
	    BlFixed totlinea = cantidad * BlFixed( linea->dbValue("pvpivainclalbaran"));
        total.totalIva = total.totalIva + cantidad * BlFixed ( linea->dbValue ( "pvpivainclalbaran" ) );
        totales[linea->dbValue ( "ivalalbaran" ) ] = totales[linea->dbValue ( "ivalalbaran" ) ] + totlinea;
    } // end for

    BlEscPrinter pr ( g_confpr->value(CONF_DIR_USER) + "bulmatpv_ticket_tc_ivainc.esc" );
    pr.initializePrinter();
    pr.setCharacterCodeTable ( page19 );
    pr.setJustification ( BlEscPrinter::center );

    if ( g_confpr->value( CONF_TPV_PRINTER_LOGO ) != "" ) {
        pr.printImage ( g_confpr->value( CONF_TPV_PRINTER_LOGO ) );
    } // end if
    
    pr.printText ( empresa.nombre + "\n" );
    pr.setCharacterPrintMode ( CHARACTER_FONTB_SELECTED );
    pr.setCharacterSize ( CHAR_WIDTH_1 | CHAR_HEIGHT_1 );
    pr.setColor ( red );
    pr.printText ( empresa.direccionCompleta + "\n" );
    pr.initializePrinter();
    pr.setCharacterCodeTable ( page19 );
    pr.printText ( "\n" );
    pr.printText ( fecha.dia + " " + fecha.hora + "\n" );
    if (cliente.cif != "") 
	pr.printText ( "Cliente: " + cliente.cif + " " + cliente.nombre + "\n" );
    pr.printText ( "Num. Ticket:  " + tick->dbValue("numalbaran") + "\n" );
    pr.printText ( "\n" );
    pr.turnWhiteBlack ( 1 );
    pr.printText ( "Uds PRODUCTO � � � � � � � P.U. � IMPORTE \n" );
    pr.turnWhiteBlack ( 0 );
    pr.setCharacterPrintMode ( CHARACTER_FONTB_SELECTED );
    pr.setCharacterSize ( CHAR_WIDTH_1 | CHAR_HEIGHT_1 );

    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        if ( i == tick->listaLineas()->size() - 1 )
            pr.setUnderlineMode ( 1 );
        
        linea = tick->listaLineas()->at ( i );
        BlFixed pvp = BlFixed ( linea->dbValue ( "pvpivainclalbaran" ) );	
        BlFixed pvptotal = BlFixed ( linea->dbValue ( "cantlalbaran" ) ) * pvp;
        pr.printText ( linea->dbValue ( "cantlalbaran" ).rightJustified ( 3, ' ', true ) + " " );
        pr.printText ( linea->dbValue ( "desclalbaran" ).leftJustified ( 21, ' ', true ) + " " );
        pr.printText ( linea->dbValue ( "nomtc_talla" ).leftJustified ( 3, ' ', true ) + " " );
        pr.printText ( linea->dbValue ( "nomtc_color" ).leftJustified ( 3, ' ', true ) + " " );	
		
        QString pvpstr = pvp.toQString();
        QString pvptotalstr = pvptotal.toQString();
        pr.printText ( QString ( pvpstr + "�" ).rightJustified ( 10, ' ', true ) + " " );
        pr.printText ( QString ( pvptotalstr + "�" ).rightJustified ( 10, ' ', true ) );
        pr.printText ( "\n" );
    } // end for
    pr.setUnderlineMode ( 0 );
    pr.setJustification ( BlEscPrinter::right );
    pr.setCharacterPrintMode ( CHARACTER_FONTA_SELECTED );    
    base::Iterator it;
    for ( it = totales.begin(); it != totales.end(); ++it ) {
      QString tipoIva = it.key();	
      QString sqlquery = "SELECT (" +it.value().toQString('.') + "/ ( 1 + " + tipoIva.replace(",",".") + "/100 ))::NUMERIC(12,2) AS base, " + it.value().toQString('.') + "- ("+it.value().toQString('.') + "/ ( 1 + " + tipoIva.replace(",",".") + "/100 ))::NUMERIC(12,2) AS iva";
      BlDbRecordSet *cur = tick->mainCompany()->loadQuery(sqlquery);
      pr.printText ( "Base Imponible: " + cur->value("base") + "�\n" );
      pr.printText ( "IVA " +it.key() + "%  " + cur->value("iva") + "�\n" );
      delete cur;
    } // end for
    pr.setCharacterPrintMode ( CHARACTER_FONTA_SELECTED | EMPHASIZED_MODE | DOUBLE_HEIGHT | DOUBLE_WIDTH );
    pr.printText ( "TOTAL: " + total.totalIva.toQString() + "�\n" );
    pr.printText ( "\n\n" );
    pr.setJustification ( BlEscPrinter::left );
    pr.setCharacterPrintMode ( CHARACTER_FONTA_SELECTED );
    pr.printText ( "Le ha atendido " + trabajador.nombre + "\n" );
    pr.printText ( "\n" );
    pr.printText ( "\n" );
    pr.setJustification ( BlEscPrinter::center );
    pr.setColor ( red );
    pr.printText ( "*** GRACIAS POR SU VISITA ***\n" );
    QByteArray qba = tick->dbValue ( "refalbaran" ).toLatin1();
    char* barcode = qba.data();
    pr.setJustification ( BlEscPrinter::center );
    pr.setBarcodeFormat ( 2, 50, both, fontB );
    pr.printBarCode ( code39, qba.size(), barcode );
    pr.cutPaperAndFeed ( true, 10 );
    pr.print();

    /// Si queremos imprimir con CUPS lo hacemos de esta otra forma
    if (!g_confpr->value( CONF_TICKET_PRINTER_FILE).isEmpty() && g_confpr->value( CONF_TICKET_PRINTER_FILE) != "/dev/null") {
        QString comando = "cat " + g_confpr->value(CONF_DIR_USER) + "bulmatpv_ticket_tc_ivainc.esc" + "  > " + g_confpr->value( CONF_TICKET_PRINTER_FILE );
        system ( comando.toLatin1().data() );
    } else if (g_confpr->value(CONF_CUPS_DEFAULT_PRINTER).isEmpty() || g_confpr->value(CONF_CUPS_DEFAULT_PRINTER).toLower() == "none") {
        BlDebug::blDebug("Debe establecer el parametro CONF_CUPS_DEFAULT_PRINTER o CONF_TICKET_PRINTER_FILE para imprimir el ticket " , 2);
    } else {
        QString comando = "lp -d" + g_confpr->value(CONF_CUPS_DEFAULT_PRINTER) + " " + g_confpr->value(CONF_DIR_USER) + "bulmatpv_ticket_tc_ivainc.esc";
        system ( comando.toLatin1().data() );
    } // end if
    
    return 1;
}
Esempio n. 17
0
/**
\param cuentas
\param ramas
**/
void BcPlanContableArbol::SintetizarRamas ( BlDbRecordSet **cuentas, tiporama **ramas )
{
    BL_FUNC_DEBUG

    tiporama *guia, *rama;
    tipohoja *hoja;
    int nivel;
    BlDbRecordSet *ptrcuentas = *cuentas;
    nivel = atoi ( ptrcuentas->value( "nivel" ).toAscii().constData() );
    ptrcuentas->nextRecord();
    guia = NULL;
    while ( !ptrcuentas->eof() && ( atoi ( ptrcuentas->value( "nivel" ).toAscii().constData() ) > nivel ) ) {
        /// Reservamos un huequecito de memoria para almacenar los datos de la rama.
        rama = new tiporama;
        if ( !guia ) {
            *ramas = guia = rama;
        } else {
            guia->sgte = rama;
            guia = guia->sgte;
        } // end if
        hoja = new tipohoja; /// Idem para una hojita.
        hoja->idcuenta = atoi ( ptrcuentas->value( "idcuenta" ).toAscii().constData() );
        hoja->codigo = ptrcuentas->value( "codigo" );
        hoja->descripcion = ptrcuentas->value( "descripcion" );
        hoja->saldoant = hoja->debe = hoja->haber = hoja->saldo = hoja->debeej = hoja->haberej = hoja->saldoej = BlFixed ( "0.00" );
        hoja->numapuntes = 0;
        hoja->ramas = NULL;
        guia->hoja = hoja;
        guia->sgte = NULL;
        /// Pero a&uacute;n puede haber m&aacute;s ramas que crezcan, en tal caso habr&aacute;
        /// que sintetizarlas
        SintetizarRamas ( &ptrcuentas, & ( hoja->ramas ) );
    } // end while

    
}
Esempio n. 18
0
/**
\param ramaraiz
\param cuenta
\param actualizado
**/
void BcPlanContableArbol::ActualizarHoja ( tiporama** ramaraiz, BlDbRecordSet* cuenta, bool* actualizado )
{
    BL_FUNC_DEBUG

    tiporama* rama = *ramaraiz;
    int idcuenta = cuenta->value( "idcuenta" ).toInt();

    /// Buscamos por cada una de las ramas.
    while ( rama && ! ( *actualizado ) ) {
        if ( rama->hoja->idcuenta == idcuenta ) {
            /// Ponemos los valores obtenidos de la BD.
            rama->hoja->saldoant = BlFixed ( cuenta->value( "saldoant" ) );
            rama->hoja->debe = BlFixed ( cuenta->value( "debe" ) );
            rama->hoja->haber = BlFixed ( cuenta->value( "haber" ) );
            rama->hoja->saldo = BlFixed ( cuenta->value( "saldo" ) );
            rama->hoja->debeej = BlFixed ( cuenta->value( "debeej" ) );
            rama->hoja->haberej = BlFixed ( cuenta->value( "haberej" ) );
            rama->hoja->saldoej = BlFixed ( cuenta->value( "saldoej" ) );
            rama->hoja->numapuntes = cuenta->value( "numapuntes" ).toInt();
	    BlDebug::blDebug ( Q_FUNC_INFO, 0, QString(_("Codigo = '%1', Numero de apunte = '%2'")).arg(cuenta->value( "codigo" )).arg(QString::number(rama->hoja->numapuntes)) );
            *actualizado = true;
        } else {
            if ( rama->hoja->ramas ) {
                ActualizarHoja ( & ( rama->hoja->ramas ), cuenta, & ( *actualizado ) );
                /// A la vuelta, actualizamos los valores si alguna hoja fue actualizada.
                if ( *actualizado ) {
                    rama->hoja->saldoant = rama->hoja->saldoant + BlFixed ( cuenta->value( "saldoant" ) );
                    rama->hoja->debe = rama->hoja->debe + BlFixed ( cuenta->value( "debe" ) );
                    rama->hoja->haber = rama->hoja->haber + BlFixed ( cuenta->value( "haber" ) );
                    rama->hoja->saldo = rama->hoja->saldo + BlFixed ( cuenta->value( "saldo" ) );
                    rama->hoja->debeej = rama->hoja->debeej + BlFixed ( cuenta->value( "debeej" ) );
                    rama->hoja->haberej = rama->hoja->haberej + BlFixed ( cuenta->value( "haberej" ) );
                    rama->hoja->saldoej = rama->hoja->saldoej + BlFixed ( cuenta->value( "saldoej" ) );
                    rama->hoja->numapuntes += cuenta->value( "numapuntes" ).toInt();
                } // end if
            } // end if
        } // end if
        rama = rama->sgte;
    } // end while

    
}
Esempio n. 19
0
/**
\param ramas
**/
void BcPlanContableArbol::nuevaRama ( BlDbRecordSet *ramas )
{
    BL_FUNC_DEBUG

    /// Rellenamos los valores de inicializacion para una hoja.
    hoja = new tipohoja;
    hoja->idcuenta = atoi ( ramas->value( "idcuenta" ).toAscii().constData() );
    hoja->codigo = QString ( ramas->value( "codigo" ) );
    hoja->descripcion = QString ( ramas->value( "descripcion" ) );
    hoja->saldoant = hoja->debe = hoja->haber = hoja->saldo = hoja->debeej = hoja->haberej = hoja->saldoej = BlFixed ( "0.00" );
    hoja->numapuntes = 0;
    hoja->ramas = NULL;
    raiz << hoja;

    
}
Esempio n. 20
0
/**
\return
**/
void Q19Writer::genera ( BlDbRecordSet  *curcobro, QString fileName , QStringList *idsGenerats)
{
      BL_FUNC_DEBUG
      QString refActual ( "cap rebut" );
      if (fileName.length()==0) {
          fileName = QFileDialog::getSaveFileName ( parentWidget(), _ ( "Fichero de remesa bancaria (Cuaderno 19)" ),
                       "",
                       _ ( "*.q19;;*" ) );
      }

      BlDebug::blDebug ( Q_FUNC_INFO, 0, QString(_("Nombre del fichero: '%1'")).arg(fileName) );

      if (fileName.length()>0) { // else ha apretat cancel?lar
       
	try
	{
		int cobraments=curcobro->numregistros();
		BlDbRecordSet  *curbanc;
		/*
		http://www.cam.es/1/empresas/servicios/pdf/c19.pdf
		"    Dentro de cada Cliente Ordenante, todos los registros individuales debera'n
		figurar en el soporte clasificados ascendentemente por el nu'mero de Entidad-
		Oficina de adeudo, Referencia y Co'digo de dato, terminando con un registro de
		<<Total Ordenante>>. Al final llevara' un registro de <<Total General>>.
		"
		Per'o cada idbanco (de fet cada entitat, per'o no filem tan prim) requereix un
		fitxer, perqu'e no portar'as a un banc els rebuts que vols cobrar per un altre.
		I la data de c'arrec va a la capc,alera d'ordenant, per tant hem d'ordenar primer
		per banc i data i despre's pel que demana als rebuts d'un ordenant. Farem tantes capc,aleres
		d'ordenant com dates encara que sempre sigui el mateix ordenant.

		*/
		bool bancUnic = ( curcobro->value( "idbanco",0 ) == curcobro->value( "idbanco",curcobro->numregistros()-1 ) );
		BlDebug::blDebug ( "bancUnic=",0,bancUnic?"si":"no" );
		QString idbanc ( "" );
		QFile file;
		QTextStream out ( &file );
		/*
		   http://www.cam.es/1/empresas/servicios/pdf/c19.pdf
		   - Codigo ASCII ( en mayusculas) (caracter 165= enye).
		   - Registros de longitud fija (162 bytes).
		   - Formato MS-DOS secuencial tipo texto.
		   En canvi un fitxer de mostra generat amb un programa que do'na el banc
		   te' 162 car'acters + \x0a , que no e's un salt de li'nia MSDOS. Ni se' si
		   un fitxer de registres de longitud fixa necessita  salts de li'nia per a res.
		*/
		out.setCodec ( "Q19" );
		QString sufijo;
		QDate fechaCargo = ( curcobro->eof() ?
		                     QDate()
		                     : QDate::fromString ( curcobro->value( "fechavenccobro" ),"dd/MM/yyyy" ) ) ;
		BlFixed impOrdenante ( 0,2 );
		BlFixed impPresentador ( 0,2 );
		QString resultats ( "" );
		int registrosOrdenante=0;
		int registrosPresentador=0;
		int cobramentsOrdenante=0;
		int cobramentsPresentador=0;
		int ordenants=0;
		int sensebanc=0;
		int sensevenc=0;
		while ( !curcobro->eof() )
		{
			if ( QDate::fromString ( curcobro->value( "fechavenccobro" ),"dd/MM/yyyy" ).isValid() )
			{
				if ( ( !curcobro->value( "idbanco" ).isNull() ) && ( curcobro->value( "idbanco" ).length() >0 ) )
				{

					if ( QDate::fromString ( curcobro->value( "fechavenccobro" ),"dd/MM/yyyy" ) != fechaCargo )
					{
						registrosPresentador++;
						registrosOrdenante++;
						totalOrdenante ( out, sufijo , curbanc, impOrdenante,
						                 cobramentsOrdenante, registrosOrdenante );
						ordenants++;
					}
					if ( curcobro->value( "idbanco" ) != idbanc )
					{
						// canvi de banc on cobrem els rebuts, canvi de fitxer
						idbanc=curcobro->value( "idbanco" );
						if ( file.handle() !=-1 )
						{
							registrosPresentador++;
							totalPresentador ( out, sufijo, curbanc, impPresentador, cobramentsPresentador, registrosPresentador , ordenants );
							resultats += _ ( "\n%3 : %1 recibos, %2 EUR. " ).arg ( cobramentsPresentador ).arg ( impPresentador.toQString() ).arg ( file.fileName() );
							file.close();
							delete curbanc;

						}
						curbanc = m_empresa->loadQuery ( "SELECT * FROM banco WHERE idbanco = $1",1,&idbanc );
                                                sufijo = curbanc->value("sufijobanco");
						if ( bancUnic )
						{
							file.setFileName ( fileName );
							BlDebug::blDebug ( "creare' ",0,fileName );
						}
						else
						{
							QString nomNou = fileName;
							QRegExp ext ( "(\\..*)$" );
							QString extensio ( "" );
							if ( ext.indexIn ( nomNou ) >=0 )
							{
								extensio = ext.cap ( 1 );
							}
							nomNou.replace ( ext,"" );
							nomNou+="_"+curbanc->value( "nombanco" ).replace ( QRegExp ( "[^a-zA-Z0-9_]" ),"-" )
							        +extensio;
							file.setFileName ( nomNou );
							BlDebug::blDebug ( "creare' el nom que m'he muntat: ",0,fileName );
						}
						if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
							return;
						cabeceraPresentador ( out, sufijo , curbanc );
						cobramentsPresentador=0;
						registrosPresentador=1;
						impPresentador=0;
						ordenants=0;
						fechaCargo=QDate::fromString ( curcobro->value( "fechavenccobro" ),"dd/MM/yyyy" ) ;
					}
					if ( ( QDate::fromString ( curcobro->value( "fechavenccobro" ),"dd/MM/yyyy" ) != fechaCargo ) || ( registrosPresentador==1 ) )
					{
						fechaCargo = QDate::fromString ( curcobro->value( "fechavenccobro" ),"dd/MM/yyyy" );
						registrosPresentador++;
						cabeceraOrdenante ( out, sufijo , curbanc, fechaCargo );
						cobramentsOrdenante=0;
						registrosOrdenante=1;
						impOrdenante=0;
					}

					refActual=curcobro->value( "refcobro" );
					int registres = cobroQ19 ( out, sufijo, curcobro );
                                        if (idsGenerats) 
                                        { 
                                           idsGenerats->append(curcobro->value("idcobro"));
                                        }
					registrosOrdenante+=registres;
					registrosPresentador+=registres;
					cobramentsOrdenante++;
					cobramentsPresentador++;
					impOrdenante=impOrdenante+BlFixed ( curcobro->value( "cantcobro" ) );
					impPresentador=impPresentador+BlFixed ( curcobro->value( "cantcobro" ) );
				}
				else
				{
					sensebanc++;
				}
			}
			else
			{
				sensevenc++;
			}
			curcobro->nextRecord();
		}
		if ( file.handle() !=-1 )
		{
			registrosPresentador++;
			registrosOrdenante++;
			totalOrdenante ( out, sufijo , curbanc, impOrdenante, cobramentsOrdenante, registrosOrdenante );
			ordenants++;
						
			registrosPresentador++;
                        totalPresentador ( out, sufijo, curbanc, impPresentador, cobramentsPresentador, registrosPresentador , ordenants );
			resultats += _ ( "\n%3 : %1 recibos, %2 EUR. " ).arg ( cobramentsPresentador ).arg ( impPresentador.toQString() ).arg ( file.fileName() );
			file.close();
			delete curbanc;

		}
		if ( ( sensevenc>0 ) || ( sensebanc>0 ) )
		{
			QMessageBox::warning ( parentWidget(),_ ( "Remesa parcialmente generada" ),
			                       _ ( "Excluidos %3 de %2 recibos por falta de fecha de vencimiento y otros %1 por falta de banco" ).arg ( sensebanc ).arg ( cobraments ).arg ( sensevenc ) );
		}
		QMessageBox::information ( parentWidget(),_ ( "Fichero(s) generado(s)" ),_ ( "Tiene los siguientes ficheros de recibos para los bancos:\n%1" ).arg ( resultats ) );
	}
	catch ( QString e )
	{
		BlDebug::blDebug ( "Error ",0,refActual+":"+e );
		QMessageBox::critical ( parentWidget(),_ ( "Remesa mal generada" ),_( "%2\n.El fichero de remesa bancaria generado no es aprovechable. Ha fallado la generacion en el recibo con referencia %1" ).arg ( refActual ).arg ( e ) );
                if (idsGenerats) 
                {
                     idsGenerats->clear();
                }
	}
      }
	
}
Esempio n. 21
0
/**
\param ramas
**/
void BcPlanContableArbol::inicializa ( BlDbRecordSet *ramas )
{
    BL_FUNC_DEBUG

    QString padre;
    tiporama* guia = NULL;
    ramas->firstRecord();
    /// Hay que construir el arbol con todas sus hojitas (cuentas).
    for (int i = 0; i < raiz.size(); ++i ) {
        padre = raiz.at ( i )->codigo;
        /// Creamos las primeras hojas en la ra&iacute;z y sintetizamos el resto
        /// recursivamente (si es que existen aun m&aacute;s hojas hijas).
        while ( !ramas->eof() && ramas->value( "codigo" ).startsWith ( padre ) ) {
            if ( ramas->value( "nivel" ).toInt() > 2 ) {
                /// Creamos una hoja.
                hoja = new tipohoja;
                hoja->idcuenta = ramas->value( "idcuenta" ).toInt();
                hoja->codigo = ramas->value( "codigo" );
                hoja->descripcion = ramas->value( "descripcion" );
                hoja->saldoant = hoja->debe = hoja->haber = hoja->saldo = hoja->debeej = hoja->haberej = hoja->saldoej = BlFixed ( "0.00" );
                hoja->numapuntes = 0;
                hoja->ramas = NULL;
                rama = new tiporama;
                rama->hoja = hoja;
                rama->sgte = NULL;
                /// Creamos la uni&oacute;n con la ra&iacute;z.
                if ( !raiz.at ( i )->ramas ) {
                    raiz.at ( i )->ramas = guia = rama;
                } else { /// Avanzamos el puntero a la siguiente supuesta rama.
                    guia->sgte = rama;
                    guia = guia->sgte;
                } // end if
                /// Buscamos si adem&aacute;s de esta hoja hay m&aacute;s ramas que
                /// crezcan, en tal caso habr&aacute; que sintetizarlas.
                SintetizarRamas ( &ramas, & ( hoja->ramas ) );
            } else {
                ramas->nextRecord();
            } // end if
        } // end while
    } // end for

    
}
Esempio n. 22
0
Cambio::Cambio ( BtCompany *emp, QWidget *parent ) : BlWidget ( emp, parent )
{
    setupUi ( this );

    m_value = 0;
    base basesimp;
    base basesimpreqeq;
    BlDbRecord *linea;

    BtTicket *tick = emp->ticketActual();


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


    /// Impresion de los contenidos.
    QString l;
    BlFixed irpf ( "0" );

    BlDbRecordSet *cur = emp->loadQuery ( "SELECT * FROM configuracion WHERE nombre = 'IRPF'" );
    if ( cur ) {
        if ( !cur->eof() ) {
            irpf = BlFixed ( cur->value( "valor" ) );
        } // end if
        delete cur;
    } // end if


    BlFixed descuentolinea ( "0.00" );
    for ( int i = 0; i < tick->listaLineas() ->size(); ++i ) {
        linea = tick->listaLineas() ->at ( i );
        BlFixed cant ( linea->dbValue ( "cantlalbaran" ) );
        cant.setPrecision(emp->decimalesCantidad());
        BlFixed pvpund ( linea->dbValue ( "pvpivainclalbaran" ) );
        pvpund.setPrecision(emp->decimalesCantidad());
        BlFixed desc1 ( linea->dbValue ( "descuentolalbaran" ) );
        BlFixed cantpvp = cant * pvpund;
        cantpvp.setPrecision(emp->decimalesCantidad());
        BlFixed base = cantpvp - cantpvp * desc1 / 100;
        descuentolinea = descuentolinea + ( cantpvp * desc1 / 100 );
        basesimp[linea->dbValue ( "ivalalbaran" ) ] = basesimp[linea->dbValue ( "ivalalbaran" ) ] + base;
        basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] = basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] + base;
    } // end for

    BlFixed basei ( "0.00" );
    base::Iterator it;
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        basei = basei + it.value();
    } // end for

    /// Calculamos el total de los descuentos.
    /// De momento aqui no se usan descuentos generales en venta.
    BlFixed porcentt ( "0.00" );

    /// Calculamos el total de base imponible.
    BlFixed totbaseimp ( "0.00" );
    BlFixed parbaseimp ( "0.00" );
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        if ( porcentt > BlFixed ( "0.00" ) ) {
            parbaseimp = it.value() - it.value() * porcentt / 100;
        } else {
            parbaseimp = it.value();
        } // end if
        totbaseimp = totbaseimp + parbaseimp;
    } // end for

    /// Calculamos el total de IVA.
    BlFixed totiva ( "0.00" );
    BlFixed pariva ( "0.00" );
    for ( it = basesimp.begin(); it != basesimp.end(); ++it ) {
        BlFixed piva ( it.key().toAscii().constData() );
        if ( porcentt > BlFixed ( "0.00" ) ) {
            pariva = ( it.value() - it.value() * porcentt / 100 ) * piva / 100;
        } else {
            pariva = it.value() * piva / 100;
        } // end if
        totiva = totiva + pariva;
    } // end for

    /// Calculamos el total de recargo de equivalencia.
    BlFixed totreqeq ( "0.00" );
    BlFixed parreqeq ( "0.00" );
    for ( it = basesimpreqeq.begin(); it != basesimpreqeq.end(); ++it ) {
        BlFixed preqeq ( it.key().toAscii().constData() );
        if ( porcentt > BlFixed ( "0.00" ) ) {
            parreqeq = ( it.value() - it.value() * porcentt / 100 ) * preqeq / 100;
        } else {
            parreqeq = it.value() * preqeq / 100;
        } // end if
        totreqeq = totreqeq + parreqeq;
    } // end for

    BlFixed totirpf = totbaseimp * irpf / 100;

    BlFixed total =  totbaseimp;

    mui_total->setText ( total.toQString() );

}
Esempio n. 23
0
void ImpQToolButton::click()
{
    BL_FUNC_DEBUG

    QString res = "";

    if ( m_albaranClienteList != NULL ) {
        m_companyact = ( BfCompany * ) m_albaranClienteList->mainCompany();
        BlSubForm *sub = m_albaranClienteList->mui_list;

        /// Creamos la factura
        /// Como estamos en un plugin buscamos nuevas formas de creacion de objetos.
        int resur = g_plugins->run ( "SNewFacturaView", m_companyact );
        if ( !resur ) {
            blMsgInfo ( "no se pudo crear instancia de factura" );
            return;
        } // end if
        FacturaView *fac = ( FacturaView * ) g_plugParams;
        m_companyact->m_pWorkspace->addSubWindow ( fac );

        /// Cargamos un elemento que no existe para inicializar bien la clase.
        fac->load ( "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" ) {
                QString id = rec->dbValue ( "idalbaran" );

                /// Como estamos en un plugin buscamos nuevas formas de creacion de objetos.
                int resur = g_plugins->run ( "SNewAlbaranClienteView", m_companyact );
                if ( !resur ) {
                    blMsgInfo ( "no se pudo crear instancia de albaran" );
                    return;
                } // end if
                AlbaranClienteView *pres = ( AlbaranClienteView * ) g_plugParams;
                pres->load ( id );
                if ( pres->mui_procesadoalbaran->isChecked() ) {
                    pres->close();
                    return;
                } // end if
                m_companyact->pWorkspace() ->addSubWindow ( pres );
                m_companyact->insertWindow ( pres->windowTitle(), pres, FALSE );
                pres->show();

                // El calculo de descuentos es complejo
                BlFixed descgen1 = pres->getlistadescuentos() ->sumarCampo ( "proporciondalbaran" );
                BlFixed descgen = BlFixed ( "1.000" ) - descgen1 / BlFixed ( "100" );

                /// Agregamos a comentarios que albaran se corresponde.
                QString comm = fac->dbValue ( "comentfactura" ) + "(" + _ ( "ALBARAN: Num " ) + pres->dbValue ( "numalbaran" ) + _ ( "Ref:" ) + " " + pres->dbValue ( "refalbaran" ) + _ ( "Fecha:" ) + " " + pres->dbValue ( "fechaalbaran" ) + ")\n";
                fac->setDbValue ( "comentfactura", comm );
                fac->setDbValue ( "idforma_pago", pres->dbValue ( "idforma_pago" ) );
                fac->setDbValue ( "reffactura", pres->dbValue ( "refalbaran" ) );
                fac->setDbValue ( "idcliente", pres->dbValue ( "idcliente" ) );
                fac->setDbValue ( "idalmacen", pres->dbValue ( "idalmacen" ) );

                QString l;
                BlDbSubFormRecord *linea, *linea1;
                for ( int i = 0; i < pres->getlistalineas() ->rowCount(); ++i ) {
                    linea = pres->getlistalineas() ->lineaat ( i );
                    if ( linea->dbValue ( "idarticulo" ) != "" ) {
                        linea1 = fac->getlistalineas() ->lineaat ( fac->getlistalineas() ->rowCount() - 1 );
                        /// Haciendo el nuevo registro antes nos evitamos problemas de foco.
                        fac->getlistalineas() ->newRecord();
                        fac->getlistalineas() ->setProcesarCambios ( FALSE );
                        linea1->setDbValue ( "codigocompletoarticulo", linea->dbValue ( "codigocompletoarticulo" ) );
                        linea1->setDbValue ( "desclfactura", linea->dbValue ( "desclalbaran" ) );
                        linea1->setDbValue ( "cantlfactura", linea->dbValue ( "cantlalbaran" ) );
                        linea1->setDbValue ( "pvplfactura", linea->dbValue ( "pvplalbaran" ) );
                        linea1->setDbValue ( "ivalfactura", linea->dbValue ( "ivalalbaran" ) );
                        BlFixed descpar1 = BlFixed ( linea->dbValue ( "descuentolalbaran" ) );
                        BlFixed descpar = BlFixed ( "1.000" ) - descpar1 / BlFixed ( "100" );
                        BlFixed desc = ( BlFixed ( "1.00" ) - descpar * descgen ) * BlFixed ( "100.00" );
                        linea1->setDbValue ( "descuentolfactura", desc.toQString ( '.' ) );
                        linea1->setDbValue ( "idarticulo", linea->dbValue ( "idarticulo" ) );
                        linea1->setDbValue ( "nomarticulo", linea->dbValue ( "nomarticulo" ) );
                        fac->getlistalineas() ->setProcesarCambios ( TRUE );
                        linea1->refresh();
                    } // end if
                } // end for

                pres->mui_procesadoalbaran->setChecked ( TRUE );
            } // end if
        } // end for

        fac->calculaypintatotales();
        fac->pintar();
        fac->show();

    } // end if

    
}