summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ledger.11
-rw-r--r--src/journal.cc36
-rw-r--r--src/journal.h1
-rw-r--r--src/session.cc3
-rw-r--r--src/session.h2
-rw-r--r--test/baseline/opt-check-payees.test0
6 files changed, 26 insertions, 17 deletions
diff --git a/doc/ledger.1 b/doc/ledger.1
index 5e280889..656a3866 100644
--- a/doc/ledger.1
+++ b/doc/ledger.1
@@ -281,6 +281,7 @@ transactions they are contained in. See the manual for more information.
.It Fl \-budget-format Ar FMT
.It Fl \-by-payee Pq Fl P
.It Fl \-cache Ar FILE
+.It Fl \-check-payees
.It Fl \-cleared Pq Fl C
.It Fl \-cleared-format Ar FMT
.It Fl \-collapse Pq Fl n
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() {
diff --git a/test/baseline/opt-check-payees.test b/test/baseline/opt-check-payees.test
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/baseline/opt-check-payees.test