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"); }
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() ); }
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; }