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; }
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 Devolucion::on_mui_browser_anchorClicked ( const QUrl &anchor ) { if ( anchor.queryItemValue ( "op" ) == "minus" ) { if ( m_ticket->dbValue ( "idalbaran" ).isEmpty() ) return; int sizein = m_ticket->listaLineas()->size(); for ( int i = 0; i < sizein; ++i ) { BlDbRecord *item = m_ticket->listaLineas() ->at ( i ); if ( item->dbValue ( "numlalbaran" ) == anchor.queryItemValue ( "numlalbaran" ) ) { BlDbRecord *nitem = m_ticket->agregarLinea(); QList<BlDbField *> *lista = item->lista(); for ( int j = 0; j < lista->size(); ++j ) { BlDbField * camp = lista->at ( j ); if ( camp->fieldName() != "numlalbaran" ) { nitem->setDbValue ( camp->fieldName(), camp->fieldValue() ); } // end if if ( camp->fieldName() == "cantlalbaran" && camp->fieldValue().toFloat() > 0 ) { nitem->setDbValue ( camp->fieldName(), "-1" ); }// end if } // end if } // end for }// end for } // end if pintar(); }
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 ServerLight::processTicketDataXML(QString data) { BtCompany *emp = (BtCompany *) mainCompany(); BlDbRecord *rec; BtTicket *ticket; BtTicket *ticketActual; fprintf(stdout, "\n==========MENSAJE COMPLETO ===============\n"); fprintf(stdout, data.toAscii()); fprintf(stdout, "\n=========================\n"); ticketActual = emp->ticketActual(); QString *er = new QString(""); int *erline; int num = 0; erline = # QDomDocument doc ( "mydocument" ); if ( !doc.setContent ( data, true, er, erline ) ) { //fprintf(stderr, er->toAscii()); //fprintf(stderr, QString::number(*erline).toAscii()); fprintf(stderr, "Error en documento XML.\n"); return; } // end if QDomElement docElem = doc.documentElement(); QDomElement principal = docElem.firstChildElement ( "TICKET" ); /// Cogemos la coordenada X QDomNodeList nodos = principal.elementsByTagName ( "LINEATICKET" ); /// Crea un ticket. ticket = emp->newBtTicket(); ticket->setDbValue("nomticket", principal.firstChildElement("NOMTICKET").text() ); ticket->setDbValue("idtrabajador", "1"); int i = 0; while (i < nodos.count() ) { QDomNode ventana = nodos.item ( i++ ); QDomElement e1 = ventana.toElement(); /// try to convert the node to an element. if ( !e1.isNull() ) { /// the node was really an element. QString idarticulo = e1.firstChildElement("IDARTICULO").text(); QString cantarticulo = e1.firstChildElement("CANTARTICULO").text(); QString imagen = ""; QDomElement modificadores = e1.firstChildElement("MODIFICADORES"); if (!modificadores.isNull()) imagen = modificadores.firstChildElement("IMAGEN").text(); /// Inserta lineas. BlDbRecord *linea = ticket->agregarLinea(); linea->setDbValue("idarticulo", idarticulo); linea->setDbValue("cantlalbaran", cantarticulo); if (imagen != "") { QByteArray bytes1 = QByteArray::fromBase64(imagen.toAscii()); QByteArray bytes; QBuffer buffer(&bytes); QImage img; buffer.open(QIODevice::WriteOnly); img.loadFromData(bytes1, "BMP"); img.save("/tmp/imagen.bmp","BMP"); img.save(&buffer, "PNG"); QString text = bytes.toBase64(); linea->setDbValue ( "imglalbaran", text ); } else { linea->setDbValue ( "imglalbaran", "" ); } // end if /// El plugin de IVA incluido tiene que estar instalado. /// Buscamos los parametros en la base de datos. QString query = "SELECT pvparticulo, pvpivaincarticulo, codigocompletoarticulo, nomarticulo, porcentasa_iva FROM articulo LEFT JOIN (SELECT idtipo_iva, porcentasa_iva, fechatasa_iva FROM tasa_iva ) AS t1 ON articulo.idtipo_iva = t1.idtipo_iva WHERE idarticulo = " + idarticulo + " ORDER BY t1.fechatasa_iva LIMIT 1"; BlDbRecordSet *cur = mainCompany() ->loadQuery ( query ); if ( !cur->eof() ) { linea->setDbValue ( "pvplalbaran", cur->value( "pvparticulo" ) ); linea->setDbValue ( "pvpivainclalbaran", cur->value( "pvpivaincarticulo" ) ); linea->setDbValue ( "codigocompletoarticulo", cur->value( "codigocompletoarticulo" ) ); linea->setDbValue ( "nomarticulo", cur->value( "nomarticulo" ) ); linea->setDbValue ( "desclalbaran", cur->value( "nomarticulo" ) ); linea->setDbValue ( "ivalalbaran", cur->value( "porcentasa_iva") ); } // end if delete cur; } // end if } // end while /// Aparca el ticket. emp->listaTickets()->prepend(ticket); /// Hacemos una llamada a plugins para indicar que hay un ticket nuevo y que deben recoger los otros plugins. /// En este caso es una llamada extraña pq no se pasa la clase llamante sino que se pasa el ticket generado. g_plugins->run("ticket_aparcado_remotamente", ticket); }
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 ); }
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; }