fix: Resolved technical debt - updated TODO/FIXME items: fixed UPDATE query in formproduct.cpp, corrected toDouble() in itemnumberdelegate.cpp, added ElementType enumeration, implemented composition deletion in formelementlist.cpp, updated README

This commit is contained in:
Javi
2026-05-27 12:22:25 +02:00
parent f3096faee6
commit 649ddff5fe
8 changed files with 131 additions and 19 deletions
+9 -5
View File
@@ -5,6 +5,8 @@
#include "treeitem.h"
#include "mapplication.h"
#include "../src/elementtype.h"
#include "widgetcomboboxpopuptable.h"
#include "itemnumberdelegate.h"
@@ -531,20 +533,22 @@ bool formBudget::InsertElement(QString ID, QModelIndex index)
}
// TODO: mirar de hacer esto con una enumeración o algo que automice el porceso:
switch (qry.value(qry.record().indexOf("TYPE1")).toInt())
switch (static_cast<ElementType>(qry.value(qry.record().indexOf("TYPE1")).toInt()))
{
case 0:
case ElementType::Composed:
setLineType("CO", index); // type
break;
case 1:
case ElementType::Material:
setLineType("MT", index); // type
break;
case 2:
case ElementType::ManPower:
setLineType("MO", index); // type
break;
case 3:
case ElementType::Machinery:
setLineType("MQ", index); // type
break;
default:
break;
}
}
else
+7 -4
View File
@@ -93,17 +93,20 @@ void formElementList::on_buttonDelete_released()
dApp->Enterprise().open();
QSqlQuery qry = QSqlQuery(dApp->Enterprise());
/*
if (index.parent().child(index.row(), 2).data().toInt() == 0)
// Check if it's a composed element (TYPE1 = 0) and delete its composition first
QModelIndex parentIndex = index.parent();
QModelIndex childIndex = model->index(index.row(), 2, parentIndex); // Obtén el índice del hijo
int type = childIndex.data().toInt(); // Accede al dato
if (type == 0) // ElementType::Composed
{
// TODO: borrar la composición
// Delete composition elements first
if(!qry.exec(QString("DELETE FROM ELEMENTCOMPOSITION WHERE CODE = '%1';").arg(ID)))
{
qDebug() << "Error ejecutando el query: " << qry.lastError().text() << "\n";
goto error;
}
}
*/
if(!qry.exec(QString("DELETE FROM ELEMENT WHERE CODE = '%1';").arg(ID)))
{
+16 -7
View File
@@ -279,9 +279,8 @@ void formProduct::save()
";";
ElementComp = "UPDATE ELEMENTCOMPOSITION SET "
"CODE = :CODE, ELEMENT_CODE = :ELEMENT_CODE, ELEMENT_AMOUNT = :ELEMENT_AMOUNT, ELEMENT_PRICE := ELEMENT_PRICE "
"WHERE "
";";
"ELEMENT_AMOUNT = :ELEMENT_AMOUNT "
"WHERE CODE = :CODE AND ELEMENT_CODE = :ELEMENT_CODE";
}
@@ -442,20 +441,30 @@ bool formProduct::InsertElement(QString ID, QModelIndex index)
}
// TODO: mirar de hacer esto con una enumeración o algo que automice el porceso:
// Use enumeration for element types
switch (qry.value(qry.record().indexOf("TYPE1")).toInt())
{
case 0:
case ElementType::Composed:
setLineType("CO", index); // type
break;
case 1:
case ElementType::Material:
setLineType("MT", index); // type
break;
case 2:
case ElementType::ManPower:
setLineType("MO", index); // type
break;
case 3:
case ElementType::Machinery:
setLineType("MQ", index); // type
break;
case ElementType::Subcontracted:
setLineType("SC", index); // type
break;
case ElementType::Other:
setLineType("OT", index); // type
break;
default:
setLineType("UNKNOWN", index); // type
break;
}
}
else
+1
View File
@@ -3,6 +3,7 @@
#include <QWidget>
#include "formbase.h"
#include "../src/elementtype.h"
namespace Ui
{