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()); }
void Sepa20022View::idsFacturas ( void ) { BlSubForm *sub = m_facturasList->mui_list; int factures = 0; ids=""; for ( int i = 0; i < sub->rowCount(); i++ ) { BlDbSubFormRecord *rec = sub->lineaat ( i ); rec->refresh(); QString val = rec->dbValue ( "selector" ); if ( val == "true" ) { ids = ids + ( ids.length() >0 ?",":"" ) +rec->dbValue ( "idfactura" ); factures++; } // end if } // end for if ( factures==0 ) { QMessageBox::critical ( parentWidget(), _ ( "Remesa vacia" ),_ ( "No hay facturas seleccionadas. Puede utilizar la columna selector para seleccionar los recibos a incluir en la remesa bancaria." ) ); close(); } }
/** inicializa todos los componentes de la clase. Resetea el sistema de control de cambios para que considere que no hay cambios por parte del usuario. Mete la ventana en el workSpace. */ Q19View::Q19View ( CarteraCobrosList *fac, BfCompany *comp, QWidget *parent ) : BfForm ( comp, parent ) { BL_FUNC_DEBUG setAttribute ( Qt::WA_DeleteOnClose ); try { setupUi ( this ); m_carteraCobrosList = fac; /// Usurpamos la identidad de mlist y ponemos nuestro propio widget con sus cosillas. mui_idbanco->setMainCompany ( comp ); mui_idbanco->setidbanco ( "0" ); setDbTableName ( "vencimientoc" ); setDbFieldId ( "idvencimientoc" ); /// Calculamos el TOTAL y el numero de operaciones BlSubForm *sub = m_carteraCobrosList->mui_list; BlFixed a("0.00"); int numop = 0; /// Reseteamos los valores for ( int i = 0; i < sub->rowCount(); i++ ) { BlDbSubFormRecord *rec = sub->lineaat ( i ); rec->refresh(); QString val = rec->dbValue ( "selector" ); if ( val == "TRUE" ) { if (rec->dbValue("descforma_pago") != "Transferencia") blMsgInfo("Hay vencimientos que no pueden ser Remesados"); if (rec->dbValue("estadovencimientoc") != "Pendiente") blMsgInfo("Hay vencimientos con estado no Pendiente"); a = a + BlFixed ( rec->dbValue ( "cantvencimientoc" ) ); numop++; } // end if } // end for mui_total->setText(a.toQString()); mui_numop->setText(QString::number(numop)); insertWindow ( windowTitle(), this, FALSE ); dialogChanges_readValues(); blScript(this); } catch ( ... ) { blMsgInfo ( tr ( "Error al crear el archivo" ) ); } // end try }
int BfSubForm_on_mui_list_editFinished ( BfSubForm *subform ) { BL_FUNC_DEBUG int err; BlDbRecordSet *cur = NULL; BlDbRecordSet *cur1 = NULL; BlDbRecordSet *cur2 = NULL; if ( subform->tableName() != "lpedidoproveedor" && subform->tableName() != "lalbaranp" && subform->tableName() != "lfacturap" ) { return 0; } // end if BlDbSubFormRecord *rec = subform->lineaat ( subform->m_prevRow ); if ( rec == NULL ) { return -1; } // end if BlDbSubFormField *camp = ( BlDbSubFormField * ) subform->item ( subform->m_prevRow, subform->m_prevCol ); camp->refresh(); if ( camp->fieldName() == "pvplpedidoproveedor" || camp->fieldName() == "pvplalbaranp" || camp->fieldName() == "pvplfacturap" ) { BlDbSubFormRecord * rec = subform->lineaat ( subform->currentRow() ); if ( rec->dbValue ( "idarticulo" ) == "" ) return 0; QString query = "SELECT preciocostearticulo FROM articulo WHERE idarticulo = " + rec->dbValue ( "idarticulo" ); cur = subform->mainCompany() ->loadQuery ( query ); if ( ! cur->eof() ) { if ( "'" + cur->value( "preciocostearticulo" ) + "'" == camp->valorcampoprep ( err ) ) { delete cur; return 0; } // end if } // end if delete cur; int ret = QMessageBox::question ( subform, "Pregunta", "Actualizo precio de coste del articulo..?", QMessageBox::Yes, QMessageBox::No ); if ( ret == QMessageBox::Yes ) { QString query1 = "UPDATE articulo SET preciocostearticulo=" + camp->valorcampoprep ( err ) + " where idarticulo=" + rec->dbValue ( "idarticulo" ); subform->mainCompany() ->begin(); subform->mainCompany() ->runQuery ( query1 ); subform->mainCompany() ->commit(); } // end if return 0; } // end if if ( camp->fieldName() == "codigocompletoarticulo" ) { cur = subform->mainCompany() ->loadQuery ( "SELECT * FROM articulo WHERE codigocompletoarticulo = '" + camp->text() + "'" ); if ( !cur->eof() ) { rec->setDbValue ( "idarticulo", cur->value( "idarticulo" ) ); rec->setDbValue ( "codigocompletoarticulo", cur->value( "codigocompletoarticulo" ) ); rec->setDbValue ( "nomarticulo", cur->value( "nomarticulo" ) ); if ( subform->tableName() == "lpedidoproveedor" || subform->tableName() == "lalbaranp" || subform->tableName() == "lfacturap" ) { rec->setDbValue ( "desc" + subform->tableName(), cur->value( "nomarticulo" ) ); rec->setDbValue ( "cant" + subform->tableName(), "1.00" ); rec->setDbValue ( "descuento" + subform->tableName(), "0.00" ); rec->setDbValue ( "pvp" + subform->tableName(), cur->value( "preciocostearticulo" ) ); } // end if } else { /// No hace falta avisar que el articulo es inexistente porque ya se hace en BlSubForm::editFinished. delete cur; return -1; } // end if cur1 = subform->mainCompany() ->loadQuery ( "SELECT * FROM tasa_iva WHERE idtipo_iva = " + cur->value( "idtipo_iva" ) + " ORDER BY fechatasa_iva DESC LIMIT 1" ); if ( !cur->eof() ) { if ( subform->tableName() == "lpedidoproveedor" || subform->tableName() == "lalbaranp" || subform->tableName() == "lfacturap" ) { rec->setDbValue ( "iva" + subform->tableName(), cur1->value( "porcentasa_iva" ) ); if ( subform->idproveedor() != "" ) { cur2 = subform->mainCompany() ->loadQuery ( "SELECT recargoeqproveedor FROM proveedor WHERE idproveedor = " + subform->idproveedor() ); if ( !cur2->eof() ) { if ( cur2->value( "recargoeqproveedor" ) == "t" ) { rec->setDbValue ( "reqeq" + subform->tableName(), cur1->value( "porcentretasa_iva" ) ); } // end if } // end if delete cur2; } else { rec->setDbValue ( "reqeq" + subform->tableName(), "0" ); } // end if } // end if } // end if if ( cur1 != NULL ) delete cur1; if ( cur != NULL ) delete cur; } // end if return 0; }
void ImpQToolButton::click() { BL_FUNC_DEBUG QString res = ""; if ( m_albaranClienteList != NULL ) { m_companyact = ( BfCompany * ) m_albaranClienteList->mainCompany(); BlSubForm *sub = m_albaranClienteList->mui_list; /// Creamos la factura /// Como estamos en un plugin buscamos nuevas formas de creacion de objetos. int resur = g_plugins->run ( "SNewFacturaView", m_companyact ); if ( !resur ) { blMsgInfo ( "no se pudo crear instancia de factura" ); return; } // end if FacturaView *fac = ( FacturaView * ) g_plugParams; m_companyact->m_pWorkspace->addSubWindow ( fac ); /// Cargamos un elemento que no existe para inicializar bien la clase. fac->load ( "0" ); /// Reseteamos los valores for ( int i = 0; i < sub->rowCount(); i++ ) { BlDbSubFormRecord *rec = sub->lineaat ( i ); rec->refresh(); QString val = rec->dbValue ( "selector" ); if ( val == "TRUE" ) { QString id = rec->dbValue ( "idalbaran" ); /// Como estamos en un plugin buscamos nuevas formas de creacion de objetos. int resur = g_plugins->run ( "SNewAlbaranClienteView", m_companyact ); if ( !resur ) { blMsgInfo ( "no se pudo crear instancia de albaran" ); return; } // end if AlbaranClienteView *pres = ( AlbaranClienteView * ) g_plugParams; pres->load ( id ); if ( pres->mui_procesadoalbaran->isChecked() ) { pres->close(); return; } // end if m_companyact->pWorkspace() ->addSubWindow ( pres ); m_companyact->insertWindow ( pres->windowTitle(), pres, FALSE ); pres->show(); // El calculo de descuentos es complejo BlFixed descgen1 = pres->getlistadescuentos() ->sumarCampo ( "proporciondalbaran" ); BlFixed descgen = BlFixed ( "1.000" ) - descgen1 / BlFixed ( "100" ); /// Agregamos a comentarios que albaran se corresponde. QString comm = fac->dbValue ( "comentfactura" ) + "(" + _ ( "ALBARAN: Num " ) + pres->dbValue ( "numalbaran" ) + _ ( "Ref:" ) + " " + pres->dbValue ( "refalbaran" ) + _ ( "Fecha:" ) + " " + pres->dbValue ( "fechaalbaran" ) + ")\n"; fac->setDbValue ( "comentfactura", comm ); fac->setDbValue ( "idforma_pago", pres->dbValue ( "idforma_pago" ) ); fac->setDbValue ( "reffactura", pres->dbValue ( "refalbaran" ) ); fac->setDbValue ( "idcliente", pres->dbValue ( "idcliente" ) ); fac->setDbValue ( "idalmacen", pres->dbValue ( "idalmacen" ) ); QString l; BlDbSubFormRecord *linea, *linea1; for ( int i = 0; i < pres->getlistalineas() ->rowCount(); ++i ) { linea = pres->getlistalineas() ->lineaat ( i ); if ( linea->dbValue ( "idarticulo" ) != "" ) { linea1 = fac->getlistalineas() ->lineaat ( fac->getlistalineas() ->rowCount() - 1 ); /// Haciendo el nuevo registro antes nos evitamos problemas de foco. fac->getlistalineas() ->newRecord(); fac->getlistalineas() ->setProcesarCambios ( FALSE ); linea1->setDbValue ( "codigocompletoarticulo", linea->dbValue ( "codigocompletoarticulo" ) ); linea1->setDbValue ( "desclfactura", linea->dbValue ( "desclalbaran" ) ); linea1->setDbValue ( "cantlfactura", linea->dbValue ( "cantlalbaran" ) ); linea1->setDbValue ( "pvplfactura", linea->dbValue ( "pvplalbaran" ) ); linea1->setDbValue ( "ivalfactura", linea->dbValue ( "ivalalbaran" ) ); BlFixed descpar1 = BlFixed ( linea->dbValue ( "descuentolalbaran" ) ); BlFixed descpar = BlFixed ( "1.000" ) - descpar1 / BlFixed ( "100" ); BlFixed desc = ( BlFixed ( "1.00" ) - descpar * descgen ) * BlFixed ( "100.00" ); linea1->setDbValue ( "descuentolfactura", desc.toQString ( '.' ) ); linea1->setDbValue ( "idarticulo", linea->dbValue ( "idarticulo" ) ); linea1->setDbValue ( "nomarticulo", linea->dbValue ( "nomarticulo" ) ); fac->getlistalineas() ->setProcesarCambios ( TRUE ); linea1->refresh(); } // end if } // end for pres->mui_procesadoalbaran->setChecked ( TRUE ); } // end if } // end for fac->calculaypintatotales(); fac->pintar(); fac->show(); } // end if }