/** \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; }
void Cambio::on_mui_pago_textChanged() { BlFixed total ( mui_total->text().replace ( ",", "." ) ); BlFixed pago ( mui_pago->text().replace ( ",", "." ) ); BlFixed cambio = pago - total; mui_cambio->setText ( cambio.toQString() ); }
QString Q19Writer::import ( BlFixed f, int longitud ) { f.setPrecision ( 2 ); QString res = QString::number ( f.value ); if ( f.value < 0 ) { throw _ ( "Datos incorrectos" ) +"\n" + _ ( "Importe negativo (%1) ! " ).arg ( f.toQString() ); } if ( res.length() >longitud ) { throw _ ( "Datos incorrectos" ) +"\n" + _ ( "Importe excesivo (%1) !. El limite son %2 digitos, incluyendo los 2 decimales " ).arg ( f.toQString() ).arg ( abs ( longitud ) ); } return res.rightJustified ( longitud,'0',true ); }
void cobropagoview::s_recalculaSaldo() { BL_FUNC_DEBUG BlFixed totalcobro ( "0" ); BlFixed totalpago ( "0" ); for ( int i = 0; i < mui_listado->rowCount(); i++ ) { BlDbSubFormRecord *rec = mui_listado->lineaat ( i ); if ( rec ) { if ( rec->dbValue ( "tipoprevcobro" ) == "f" ) { totalcobro = totalcobro + BlFixed ( rec->dbValue ( "cantidadprevcobro" ) ); } else { totalpago = totalpago + BlFixed ( rec->dbValue ( "cantidadprevcobro" ) ); } // end if } // end if } // end for m_totalCobros->setText ( totalcobro.toQString() ); m_totalPagos->setText ( totalpago.toQString() ); }
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()); }
/** \param iva \param base \param desc \param irpf \param reqeq **/ void AlbaranProveedorView::pintatotales ( BlFixed iva, BlFixed base, BlFixed total, BlFixed desc, BlFixed irpf, BlFixed reqeq ) { BL_FUNC_DEBUG m_totalBases->setText ( QString ( base.toQString() ) ); m_totalTaxes->setText ( QString ( iva.toQString() ) ); m_totalDiscounts->setText ( QString ( desc.toQString() ) ); m_totalIRPF->setText ( QString ( irpf.toQString() ) ); m_totalReqEq->setText ( QString ( reqeq.toQString() ) ); m_totalalbaranp->setText ( QString ( total.toQString() ) ); }
/** \param iva \param base \param total \param desc \param irpf \param reqeq **/ void PedidoProveedorView::pintatotales ( BlFixed iva, BlFixed base, BlFixed total, BlFixed desc, BlFixed irpf, BlFixed reqeq ) { BL_FUNC_DEBUG mui_totalBaseImponible->setText ( base.toQString() ); mui_totalImpuestos->setText ( iva.toQString() ); mui_totalPedido->setText ( total.toQString() ); mui_totalDescuentos->setText ( desc.toQString() ); mui_totalIRPF->setText ( QString ( irpf.toQString() ) ); mui_totalRecargo->setText ( QString ( reqeq.toQString() ) ); }
/** \param iva \param base \param total \param desc \param irpf \param reqeq **/ void FacturaView::pintatotales ( BlFixed iva, BlFixed base, BlFixed total, BlFixed desc, BlFixed irpf, BlFixed reqeq ) { BL_FUNC_DEBUG m_totalBases->setText ( base.toQString() ); m_totalTaxes->setText ( iva.toQString() ); m_totalfactura->setText ( total.toQString() ); m_totalDiscounts->setText ( desc.toQString() ); m_totalIRPF->setText ( QString ( irpf.toQString() ) ); m_totalReqEq->setText ( QString ( reqeq.toQString() ) ); }
/** \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(); } } } }
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á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í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í 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 á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í 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 á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 árbol y cerramos la conexió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 ); }
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() ); }
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 ); }
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; }
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; }
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; }
} /** Hace la carga del listado. Para ello genera los SELECTS con ayuda de generaFiltro y los pasa al SubFormulario para que los presente. Tambien hace un select de calculo de totales y lo presenta en el textEdit correspondiente. */ void CobrosList::presentar() { BL_FUNC_DEBUG if ( mainCompany() != NULL ) { QString query = "SELECT * FROM cobro LEFT JOIN cliente ON cliente.idcliente = cobro.idcliente LEFT JOIN forma_pago ON cobro.idforma_pago = forma_pago.idforma_pago LEFT JOIN trabajador ON trabajador.idtrabajador = cobro.idtrabajador WHERE 1 = 1 " + generaFiltro(); mui_list->load ( query ); /// Hacemos el calculo del total. BlFixed total = mui_list->sumarCampo ( "cantcobro" ); m_total->setText ( total.toQString() ); } // end if } /** Metodo auxiliar que genera la clausula WHERE del listado con las opciones de filtrado especificadas. */ const QString CobrosList::generaFiltro() { BL_FUNC_DEBUG QString filtro = ""; /// Hacemos el filtrado like del campo m_filtro filtro += mui_list->likeFilterSQL(m_filtro->text());
/** \param nodo \param valoract \param valorant **/ void BcCuentasAnualesImprimirView::agregaValores ( const QDomNode &nodo, const QString &valoract, const QString &valorant ) { BL_FUNC_DEBUG QDomElement enodo = nodo.toElement(); BlFixed fvaloract ( valoract ); BlFixed fvalorant ( valorant ); /// Miramos las opciones pasadas if ( nodo.nodeName() == QString ( "OPERADOR" ) ) { QDomNodeList opcs = enodo.elementsByTagName ( "OPCIONES" ); for ( int i = 0; i < opcs.count(); i++ ) { QDomElement op = opcs.item ( i ).toElement(); QString opciones = op.text(); if ( opciones == "POSITIVO" ) { if ( fvaloract < 0 ) fvaloract = fvaloract * -1; if ( fvalorant < 0 ) fvalorant = fvalorant * -1; } // end if if ( opciones == "NEGATIVO" ) { if ( fvaloract > 0 ) fvaloract = fvaloract * -1; if ( fvalorant > 0 ) fvalorant = fvalorant * -1; } // end if if ( opciones == "RESTAR" ) { fvaloract = fvaloract * -1; fvalorant = fvalorant * -1; } // end if } // end for } else { QDomNodeList opcs = nodo.parentNode().toElement().elementsByTagName ( "OPCIONES" ); for ( int i = 0; i < opcs.count(); i++ ) { QDomElement op = opcs.item ( i ).toElement(); QString opciones = op.text(); if ( opciones == "MAYORCERO" ) { if ( fvaloract < 0 ) fvaloract = 0; if ( fvalorant < 0 ) fvalorant = 0; } // end if if ( opciones == "MENORCERO" ) { if ( fvaloract > 0 ) fvaloract = 0; if ( fvalorant > 0 ) fvalorant = 0; } // end if } // end for } // end if QDomElement valoract1 = m_doc.createElement ( "VALORACT" ); valoract1.setTagName ( "VALORACT" ); QDomText etx = m_doc.createTextNode ( fvaloract.toQString() ); valoract1.appendChild ( etx ); QDomElement valorant1 = m_doc.createElement ( "VALORANT" ); valorant1.setTagName ( "VALORANT" ); QDomText etc = m_doc.createTextNode ( fvalorant.toQString() ); valorant1.appendChild ( etc ); QDomNode n = nodo; enodo.appendChild ( valoract1 ); enodo.appendChild ( valorant1 ); }
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 }