The option --permissive now quiets balance assertions
This commit is contained in:
parent
a98ced34dd
commit
634aa589cd
4 changed files with 20 additions and 14 deletions
|
|
@ -95,7 +95,7 @@ void journal_t::initialize()
|
||||||
force_checking = false;
|
force_checking = false;
|
||||||
check_payees = false;
|
check_payees = false;
|
||||||
day_break = false;
|
day_break = false;
|
||||||
checking_style = CHECK_PERMISSIVE;
|
checking_style = CHECK_NORMAL;
|
||||||
recursive_aliases = false;
|
recursive_aliases = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ public:
|
||||||
|
|
||||||
enum checking_style_t {
|
enum checking_style_t {
|
||||||
CHECK_PERMISSIVE,
|
CHECK_PERMISSIVE,
|
||||||
|
CHECK_NORMAL,
|
||||||
CHECK_WARNING,
|
CHECK_WARNING,
|
||||||
CHECK_ERROR
|
CHECK_ERROR
|
||||||
} checking_style;
|
} checking_style;
|
||||||
|
|
|
||||||
|
|
@ -106,10 +106,6 @@ std::size_t session_t::read_data(const string& master_account)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HANDLED(explicit))
|
|
||||||
journal->force_checking = true;
|
|
||||||
if (HANDLED(check_payees))
|
|
||||||
journal->check_payees = true;
|
|
||||||
if (HANDLED(day_break))
|
if (HANDLED(day_break))
|
||||||
journal->day_break = true;
|
journal->day_break = true;
|
||||||
|
|
||||||
|
|
@ -118,13 +114,19 @@ std::size_t session_t::read_data(const string& master_account)
|
||||||
if (HANDLED(no_aliases))
|
if (HANDLED(no_aliases))
|
||||||
journal->no_aliases = true;
|
journal->no_aliases = true;
|
||||||
|
|
||||||
|
if (HANDLED(explicit))
|
||||||
|
journal->force_checking = true;
|
||||||
|
if (HANDLED(check_payees))
|
||||||
|
journal->check_payees = true;
|
||||||
|
|
||||||
if (HANDLED(permissive))
|
if (HANDLED(permissive))
|
||||||
journal->checking_style = journal_t::CHECK_PERMISSIVE;
|
journal->checking_style = journal_t::CHECK_PERMISSIVE;
|
||||||
else if (HANDLED(pedantic))
|
else if (HANDLED(pedantic))
|
||||||
journal->checking_style = journal_t::CHECK_ERROR;
|
journal->checking_style = journal_t::CHECK_ERROR;
|
||||||
else if (HANDLED(strict))
|
else if (HANDLED(strict))
|
||||||
journal->checking_style = journal_t::CHECK_WARNING;
|
journal->checking_style = journal_t::CHECK_WARNING;
|
||||||
else if (HANDLED(value_expr_))
|
|
||||||
|
if (HANDLED(value_expr_))
|
||||||
journal->value_expr = HANDLER(value_expr_).str();
|
journal->value_expr = HANDLER(value_expr_).str();
|
||||||
|
|
||||||
#if HAVE_BOOST_SERIALIZATION
|
#if HAVE_BOOST_SERIALIZATION
|
||||||
|
|
|
||||||
|
|
@ -77,16 +77,18 @@ namespace {
|
||||||
std::istream& in;
|
std::istream& in;
|
||||||
instance_t * parent;
|
instance_t * parent;
|
||||||
std::list<application_t> apply_stack;
|
std::list<application_t> apply_stack;
|
||||||
|
bool no_assertions;
|
||||||
#if defined(TIMELOG_SUPPORT)
|
#if defined(TIMELOG_SUPPORT)
|
||||||
time_log_t timelog;
|
time_log_t timelog;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
instance_t(parse_context_stack_t& _context_stack,
|
instance_t(parse_context_stack_t& _context_stack,
|
||||||
parse_context_t& _context,
|
parse_context_t& _context,
|
||||||
instance_t * _parent = NULL)
|
instance_t * _parent = NULL,
|
||||||
|
const bool _no_assertions = false)
|
||||||
: context_stack(_context_stack), context(_context),
|
: context_stack(_context_stack), context(_context),
|
||||||
in(*context.stream.get()), parent(_parent),
|
in(*context.stream.get()), parent(_parent),
|
||||||
timelog(context) {}
|
no_assertions(_no_assertions), timelog(context) {}
|
||||||
|
|
||||||
virtual string description() {
|
virtual string description() {
|
||||||
return _("textual parser");
|
return _("textual parser");
|
||||||
|
|
@ -779,8 +781,8 @@ void instance_t::include_directive(char * line)
|
||||||
context_stack.get_current().master = master;
|
context_stack.get_current().master = master;
|
||||||
context_stack.get_current().scope = scope;
|
context_stack.get_current().scope = scope;
|
||||||
try {
|
try {
|
||||||
instance_t instance(context_stack,
|
instance_t instance(context_stack, context_stack.get_current(),
|
||||||
context_stack.get_current(), this);
|
this, no_assertions);
|
||||||
instance.apply_stack.push_front(application_t("account", master));
|
instance.apply_stack.push_front(application_t("account", master));
|
||||||
instance.parse();
|
instance.parse();
|
||||||
}
|
}
|
||||||
|
|
@ -1625,7 +1627,7 @@ post_t * instance_t::parse_post(char * line,
|
||||||
if (! diff.is_zero()) {
|
if (! diff.is_zero()) {
|
||||||
if (! post->amount.is_null()) {
|
if (! post->amount.is_null()) {
|
||||||
diff -= post->amount;
|
diff -= post->amount;
|
||||||
if (! diff.is_zero())
|
if (! no_assertions && ! diff.is_zero())
|
||||||
throw_(parse_error, _f("Balance assertion off by %1%") % diff);
|
throw_(parse_error, _f("Balance assertion off by %1%") % diff);
|
||||||
} else {
|
} else {
|
||||||
post->amount = diff;
|
post->amount = diff;
|
||||||
|
|
@ -1909,7 +1911,8 @@ std::size_t journal_t::read_textual(parse_context_stack_t& context_stack)
|
||||||
{
|
{
|
||||||
TRACE_START(parsing_total, 1, "Total time spent parsing text:");
|
TRACE_START(parsing_total, 1, "Total time spent parsing text:");
|
||||||
{
|
{
|
||||||
instance_t instance(context_stack, context_stack.get_current());
|
instance_t instance(context_stack, context_stack.get_current(), NULL,
|
||||||
|
checking_style == journal_t::CHECK_PERMISSIVE);
|
||||||
instance.apply_stack.push_front
|
instance.apply_stack.push_front
|
||||||
(application_t("account", context_stack.get_current().master));
|
(application_t("account", context_stack.get_current().master));
|
||||||
instance.parse();
|
instance.parse();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue