[gnc-autoclear.cpp] restore abort explanation message

pull/2153/head
Christopher Lam 6 months ago
parent 722a455593
commit 2e3fd090ff

@ -79,7 +79,7 @@ using SplitVec = std::vector<Split*>;
struct Solution
{
bool abort = false;
std::optional<const char*> abort;
SplitVec splits;
};
@ -124,7 +124,7 @@ subset_sum (SplitInfoVec::const_iterator iter,
DEBUG ("SOLUTION FOUND: %s%s", path_to_str (path),
solution.splits.empty() ? "" : " ABORT: AMBIGUOUS");
if (!solution.splits.empty())
solution.abort = true;
solution.abort = "Cannot uniquely clear splits. Found multiple possibilities.";
else
{
solution.splits.resize (path.size());
@ -140,7 +140,7 @@ subset_sum (SplitInfoVec::const_iterator iter,
if (monitor.should_abort())
{
DEBUG ("ABORT: timeout");
solution.abort = true;
solution.abort = "Auto-clear exceeds allocated time";
return;
}
@ -227,12 +227,17 @@ gnc_account_get_autoclear_splits (Account *account, gnc_numeric toclear_value,
DEBUG ("finished subset_sum in %f seconds", monitor.get_elapsed());
if (solution.splits.empty() || solution.abort)
if (solution.splits.empty())
{
g_set_error (error, autoclear_quark, 1, "%s",
"The selected amount cannot be cleared.");
return nullptr;
}
else if (solution.abort)
{
g_set_error (error, autoclear_quark, 1, "%s", *solution.abort);
return nullptr;
}
return std::accumulate
(solution.splits.begin(), solution.splits.end(),

@ -102,8 +102,8 @@ TestCase ambiguousTestCase = {
{ "Memo 03", -10, false },
},
.tests = {
{ -10, "The selected amount cannot be cleared." },
{ -20, "The selected amount cannot be cleared." },
{ -10, "Cannot uniquely clear splits. Found multiple possibilities." },
{ -20, "Cannot uniquely clear splits. Found multiple possibilities." },
// -30 can be cleared by returning all three -10 splits
{ -30, nullptr },
@ -121,7 +121,7 @@ TestCase sequentialTestCase1 =
.tests = {
{ 1, "The selected amount cannot be cleared." },
{ 4, "The selected amount cannot be cleared." },
{ 5, "The selected amount cannot be cleared." },
{ 5, "Cannot uniquely clear splits. Found multiple possibilities." },
{ 6, "The selected amount cannot be cleared." },
{ 9, "The selected amount cannot be cleared." },
{ 11, "The selected amount cannot be cleared." },
@ -156,9 +156,9 @@ TestCase sequentialTestCase3 =
{ "Memo 04", 5, false },
},
.tests = {
{ 5, "The selected amount cannot be cleared." },
{ 7, "The selected amount cannot be cleared." },
{ 10, "The selected amount cannot be cleared." },
{ 5, "Cannot uniquely clear splits. Found multiple possibilities." },
{ 7, "Cannot uniquely clear splits. Found multiple possibilities." },
{ 10, "Cannot uniquely clear splits. Found multiple possibilities." },
{ 2, nullptr },
{ 12, nullptr },
{ 15, nullptr },

Loading…
Cancel
Save