diff options
author | John Wiegley <johnw@newartisans.com> | 2012-02-27 11:52:23 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-02-27 11:52:23 -0600 |
commit | 5532a1a8b756f0f7499570afccb1d4fc3e9bc76d (patch) | |
tree | 0231741233df49ddfd221faa2c115f7c55829559 /src | |
parent | 2ec35ea6e98dcfb03fb8c2e90b85991aaa7be2fa (diff) | |
download | fork-ledger-5532a1a8b756f0f7499570afccb1d4fc3e9bc76d.tar.gz fork-ledger-5532a1a8b756f0f7499570afccb1d4fc3e9bc76d.tar.bz2 fork-ledger-5532a1a8b756f0f7499570afccb1d4fc3e9bc76d.zip |
Added --check-payees option
Diffstat (limited to 'src')
-rw-r--r-- | src/journal.cc | 36 | ||||
-rw-r--r-- | src/journal.h | 1 | ||||
-rw-r--r-- | src/session.cc | 3 | ||||
-rw-r--r-- | src/session.h | 2 |
4 files changed, 25 insertions, 17 deletions
diff --git a/src/journal.cc b/src/journal.cc index 8f382125..355f3ee6 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -89,6 +89,7 @@ void journal_t::initialize() fixed_metadata = false; was_loaded = false; force_checking = false; + check_payees = false; checking_style = CHECK_PERMISSIVE; } @@ -160,26 +161,27 @@ string journal_t::register_payee(const string& name, xact_t *, const string&) { string payee; -#if 0 - std::set<string>::iterator i = known_payees.find(name); + if (check_payees && + (checking_style == CHECK_WARNING || checking_style == CHECK_ERROR)) { + std::set<string>::iterator i = known_payees.find(name); - if (i == known_payees.end()) { - if (! xact) { - if (force_checking) - fixed_payees = true; - known_payees.insert(name); - } - else if (! fixed_payees && xact->_state != item_t::UNCLEARED) { - known_payees.insert(name); - } - else if (checking_style == CHECK_WARNING) { - warning_(_("%1Unknown payee '%2'") << location << name); - } - else if (checking_style == CHECK_ERROR) { - throw_(parse_error, _("Unknown payee '%1'") << name); + if (i == known_payees.end()) { + if (! xact) { + if (force_checking) + fixed_payees = true; + known_payees.insert(name); + } + else if (! fixed_payees && xact->_state != item_t::UNCLEARED) { + known_payees.insert(name); + } + else if (checking_style == CHECK_WARNING) { + warning_(_("%1Unknown payee '%2'") << location << name); + } + else if (checking_style == CHECK_ERROR) { + throw_(parse_error, _("Unknown payee '%1'") << name); + } } } -#endif foreach (payee_mapping_t& value, payee_mappings) { if (value.first.match(name)) { diff --git a/src/journal.h b/src/journal.h index 9c42ec6a..d7cf94da 100644 --- a/src/journal.h +++ b/src/journal.h @@ -134,6 +134,7 @@ public: tag_check_exprs_map tag_check_exprs; bool was_loaded; bool force_checking; + bool check_payees; enum checking_style_t { CHECK_PERMISSIVE, diff --git a/src/session.cc b/src/session.cc index cc069efe..797ee3e5 100644 --- a/src/session.cc +++ b/src/session.cc @@ -99,6 +99,8 @@ 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(permissive)) journal->checking_style = journal_t::CHECK_PERMISSIVE; @@ -248,6 +250,7 @@ option_t<session_t> * session_t::lookup_option(const char * p) break; case 'c': OPT(cache_); + else OPT(check_payees); break; case 'd': OPT(download); // -Q diff --git a/src/session.h b/src/session.h index 5d6d4bed..680b8a0e 100644 --- a/src/session.h +++ b/src/session.h @@ -87,6 +87,7 @@ public: void report_options(std::ostream& out) { HANDLER(cache_).report(out); + HANDLER(check_payees).report(out); HANDLER(download).report(out); HANDLER(decimal_comma).report(out); HANDLER(file_).report(out); @@ -110,6 +111,7 @@ public: */ OPTION(session_t, cache_); + OPTION(session_t, check_payees); OPTION(session_t, download); // -Q OPTION_(session_t, decimal_comma, DO() { |