Skip to content

Commit

Permalink
Merge pull request #5336 from n-stein/fix(#5296)
Browse files Browse the repository at this point in the history
fix(#5296): fix for DELETEDTIME = NULL
  • Loading branch information
whalley committed Nov 16, 2022
2 parents 671b8d4 + ed1293d commit 793a8bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
22 changes: 17 additions & 5 deletions src/model/Model_Category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ bool Model_Category::is_hidden(int catID, int subcatID)

bool Model_Category::is_used(int id, int sub_id)
{
const auto &trans = Model_Checking::instance().find(Model_Checking::CATEGID(id), Model_Checking::SUBCATEGID(sub_id), Model_Checking::DELETEDTIME(wxEmptyString));
if (!trans.empty()) return true;
const auto &trans = Model_Checking::instance().find(Model_Checking::CATEGID(id), Model_Checking::SUBCATEGID(sub_id));
if (!trans.empty())
{
for (const auto& txn : trans)
if (txn.DELETEDTIME.IsEmpty())
return true;
}
const auto &split = Model_Splittransaction::instance().find(Model_Checking::CATEGID(id), Model_Checking::SUBCATEGID(sub_id));
if (!split.empty())
{
Expand All @@ -176,8 +181,13 @@ bool Model_Category::is_used(int id, int sub_id)

bool Model_Category::is_used(int id)
{
const auto& trans = Model_Checking::instance().find(Model_Checking::CATEGID(id), Model_Checking::DELETEDTIME(wxEmptyString));
if (!trans.empty()) return true;
const auto& trans = Model_Checking::instance().find(Model_Checking::CATEGID(id));
if (!trans.empty())
{
for (const auto& txn : trans)
if (txn.DELETEDTIME.IsEmpty())
return true;
}
const auto& split = Model_Splittransaction::instance().find(Model_Checking::CATEGID(id));
if (!split.empty())
{
Expand All @@ -196,8 +206,10 @@ bool Model_Category::has_income(int id, int sub_id)
{
double sum = 0.0;
auto splits = Model_Splittransaction::instance().get_all();
for (const auto& tran: Model_Checking::instance().find(Model_Checking::CATEGID(id), Model_Checking::SUBCATEGID(sub_id), Model_Checking::DELETEDTIME(wxEmptyString)))
for (const auto& tran: Model_Checking::instance().find(Model_Checking::CATEGID(id), Model_Checking::SUBCATEGID(sub_id)))
{
if (!tran.DELETEDTIME.IsEmpty()) continue;

switch (Model_Checking::type(tran))
{
case Model_Checking::WITHDRAWAL:
Expand Down
9 changes: 7 additions & 2 deletions src/model/Model_Payee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,13 @@ bool Model_Payee::is_hidden(const Data& record)

bool Model_Payee::is_used(int id)
{
const auto &trans = Model_Checking::instance().find(Model_Checking::PAYEEID(id), Model_Checking::DELETEDTIME(wxEmptyString));
if (!trans.empty()) return true;
const auto &trans = Model_Checking::instance().find(Model_Checking::PAYEEID(id));
if (!trans.empty())
{
for (const auto& txn : trans)
if (txn.DELETEDTIME.IsEmpty())
return true;
}
const auto &bills = Model_Billsdeposits::instance().find(Model_Billsdeposits::PAYEEID(id));
if (!bills.empty()) return true;

Expand Down

0 comments on commit 793a8bb

Please sign in to comment.