Added --check-payees option
This commit is contained in:
parent
2ec35ea6e9
commit
5532a1a8b7
6 changed files with 26 additions and 17 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
0
test/baseline/opt-check-payees.test
Normal file
0
test/baseline/opt-check-payees.test
Normal file
Loading…
Add table
Reference in a new issue