Fix a bug in Database.cpp : operation forced to non virtual in LinkOrUnlinkOperation
This commit is contained in:
parent
02b204d408
commit
61e2a7505c
|
@ -495,15 +495,17 @@ void Database::LinkOrUnlinkOperation(User* user, Operation& op)
|
|||
bool _virtual;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
account = user->GetAccount(op.account);
|
||||
|
||||
if (op.transfert)
|
||||
{
|
||||
// No one or not linked
|
||||
if (!GetOperation(op.transfert, &linked) || op.description != linked.description || op.amount != -linked.amount || op.account == linked.account)
|
||||
{
|
||||
req = QString("UPDATE operation SET transfert='', virtual='0' WHERE id='%1'").arg(op.id);
|
||||
op._virtual = account._virtual;
|
||||
req = QString("UPDATE operation SET transfert='', virtual='%1' WHERE id='%2'").arg(op._virtual?"1":"0", op.id);
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
op.transfert = 0;
|
||||
op._virtual = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -516,8 +518,9 @@ void Database::LinkOrUnlinkOperation(User* user, Operation& op)
|
|||
|
||||
if (query.next())
|
||||
{
|
||||
op._virtual = account._virtual;
|
||||
set = query.record();
|
||||
req = QString("UPDATE operation SET transfert='', virtual='0' WHERE id='%1'").arg(set.value("id").toString());
|
||||
req = QString("UPDATE operation SET transfert='', virtual='%1' WHERE id='%2'").arg(op._virtual?"1":"0", set.value("id").toString());
|
||||
query.clear();
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
|
@ -529,8 +532,6 @@ void Database::LinkOrUnlinkOperation(User* user, Operation& op)
|
|||
|
||||
EXECUTE_SQL_QUERY(req, );
|
||||
|
||||
op._virtual = false;
|
||||
|
||||
// Don't need to link
|
||||
if (!query.next()) return ;
|
||||
|
||||
|
@ -541,7 +542,6 @@ void Database::LinkOrUnlinkOperation(User* user, Operation& op)
|
|||
|
||||
op.transfert = linked.id;
|
||||
|
||||
account = user->GetAccount(op.account);
|
||||
account2 = user->GetAccount(set.value("account").toInt());
|
||||
|
||||
_virtual = account._virtual || account2._virtual;
|
||||
|
|
Loading…
Reference in New Issue
Block a user