00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022
00023 #include <QAction>
00024 #include <QMessageBox>
00025 #include <QStringList>
00026 #include <QWidget>
00027 #include <QIcon>
00028 #include <QApplication>
00029 #include <QObject>
00030
00031 #include "pluginregistroiva.h"
00032 #include "empresa.h"
00033 #include "registroivaview.h"
00034 #include "cobropagoview.h"
00035 #include "asiento1.h"
00036 #include "listlinasiento1view.h"
00037 #include "listregistroivaview.h"
00038 #include "registroivaview.h"
00039 #include "regivaqtoolbutton.h"
00040
00041
00042
00044
00046 myRegIVA::myRegIVA() {
00047 _depura("myRegIVA::myRegIVA", 0);
00048 _depura("END myRegIVA::myRegIVA", 0);
00049 }
00050
00051
00053
00055 myRegIVA::~myRegIVA() {
00056 _depura("myRegIVA::~myRegIVA", 0);
00057 _depura("END myRegIVA::~myRegIVA", 0);
00058 }
00059
00060
00062
00064 void myRegIVA::elslot() {
00065 _depura("myRegIVA::elslot", 0);
00066 ListRegistroIvaView *perd = new ListRegistroIvaView(m_bulmacont->empresaactual(), "0");
00067 perd->inicializa();
00068 m_bulmacont->empresaactual()->pWorkspace()->addWindow(perd);
00069 perd->show();
00070 _depura("END empresa_registroiva", 0);
00071 _depura("END myRegIVA::elslot", 0);
00072 }
00073
00074
00076
00078 void myRegIVA::elslot1() {
00079 _depura("myRegIVA::elslot1", 0);
00080 cobropagoview *adoc = new cobropagoview(m_bulmacont->empresaactual(), 0);
00081 m_bulmacont->empresaactual()->pWorkspace()->addWindow(adoc);
00082 adoc->show();
00083 _depura("END myRegIVA::elslot1", 0);
00084 }
00085
00086
00088
00091 void myRegIVA::inicializa(Bulmacont *bges) {
00093 m_bulmacont = bges;
00094 QAction *accion = new QAction("&Registro de IVA", 0);
00095 accion->setStatusTip("Registro de IVA");
00096 accion->setWhatsThis("Registro de IVA");
00097
00098 QAction *accion1 = new QAction("&Cobros y Pagos", 0);
00099 accion1->setStatusTip("Cobros y Pagos");
00100 accion1->setWhatsThis("Cobros y Pagos");
00101
00102 connect(accion, SIGNAL(activated()), this, SLOT(elslot()));
00103 connect(accion1, SIGNAL(activated()), this, SLOT(elslot1()));
00105 bges->menuListados->insertAction(bges->actionCuentas_Anuales, accion);
00106 bges->menuListados->insertAction(bges->actionCuentas_Anuales, accion1);
00107 bges->menuListados->insertSeparator(bges->actionCuentas_Anuales);
00108 }
00109
00110
00112
00115 int entryPoint(Bulmacont *bcont) {
00116 _depura("Punto de entrada del plugin registroIVA", 0);
00117 myRegIVA *my = new myRegIVA();
00118 my->inicializa(bcont);
00119 return 0;
00120 }
00121
00122
00124
00128 int Asiento1View_Asiento1View(Asiento1View *l) {
00129 _depura("Asiento1View_Asiento1View", 0);
00130
00131 RegIVAQToolButton *mui_exporta_efactura2 = new RegIVAQToolButton(l, l->mui_plugbotones);
00132
00133 QHBoxLayout *m_hboxLayout1 = l->mui_plugbotones->findChild<QHBoxLayout *>("hboxLayout1");
00134 if (!m_hboxLayout1) {
00135 m_hboxLayout1 = new QHBoxLayout(l->mui_plugbotones);
00136 m_hboxLayout1->setSpacing(5);
00137 m_hboxLayout1->setMargin(5);
00138 m_hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
00139 }
00140 m_hboxLayout1->addWidget(mui_exporta_efactura2);
00141
00142 _depura("END Asiento1View_Asiento1View", 0);
00143 return 0;
00144 }
00145
00146
00148
00152 int Asiento1_guardaAsiento1_post(Asiento1 *as) {
00153 _depura("Asiento1_guardaAsiento1_post", 0);
00154 Empresa *companyact = as->companyact();
00155 QString cuentas = "";
00156 QString query = "SELECT valor FROM configuracion WHERE nombre = 'RegistroEmitida' OR nombre = 'RegistroSoportada'";
00157 cursor2 *curvalor = companyact->cargacursor(query);
00158 while (!curvalor->eof()) {
00160 cuentas += curvalor->valor("valor") + "%|";
00161 curvalor->siguienteregistro();
00162 }
00163 delete curvalor;
00165 cuentas.truncate(cuentas.length() - 1);
00166
00169 QString SQLQuery = "SELECT bcontrapartidaborr(idborrador) AS contra FROM borrador LEFT JOIN cuenta ON borrador.idcuenta = cuenta.idcuenta WHERE idasiento = " + as->DBvalue("idasiento") + " AND codigo SIMILAR TO '" + companyact->sanearCadena(cuentas.toAscii().constData()) + "' GROUP BY contra";
00170
00171 cursor2 *cursborr= companyact->cargacursor(SQLQuery);
00172 while (!cursborr->eof()) {
00173 int idborrador = cursborr->valor("contra").toInt();
00174 RegistroIvaView *reg = new RegistroIvaView(companyact, 0);
00175 reg->inicializa1(idborrador);
00176 companyact->pWorkspace()->addWindow(reg);
00177 reg->show();
00178 cursborr->siguienteregistro();
00179 }
00180 delete cursborr;
00181 _depura("END Asiento1_guardaAsiento1_post", 0);
00182 return 0;
00183 }
00184
00185
00186
00188
00192 int ListLinAsiento1View_boton_iva(ListLinAsiento1View *as) {
00193 _depura("ListLinAsiento1View_boton_iva", 0);
00194 as->guardar();
00195 try {
00196 int idborrador = as->DBvalue("idborrador").toInt();
00197 RegistroIvaView *nuevae = new RegistroIvaView((Empresa *) as->empresaBase(), 0);
00198 nuevae->inicializa1(idborrador);
00199 ((Empresa *)as->empresaBase())->pWorkspace()->addWindow(nuevae);
00200 nuevae->show();
00201 } catch (...) {
00202 mensajeInfo("Debe seleccionar un apunte");
00203 return 0;
00204 }
00205 _depura("END ListLinAsiento1View_boton_iva", 0);
00206 return 0;
00207 }
00208