diff options
-rw-r--r-- | doc/ledger.1 | 6 | ||||
-rw-r--r-- | src/csv.cc | 8 | ||||
-rw-r--r-- | src/csv.h | 6 | ||||
-rw-r--r-- | src/generate.cc | 10 | ||||
-rw-r--r-- | src/generate.h | 2 | ||||
-rw-r--r-- | src/item.cc | 22 | ||||
-rw-r--r-- | src/item.h | 20 | ||||
-rw-r--r-- | src/post.cc | 24 | ||||
-rw-r--r-- | src/post.h | 6 | ||||
-rw-r--r-- | src/print.cc | 8 | ||||
-rw-r--r-- | src/py_item.cc | 10 | ||||
-rw-r--r-- | src/py_post.cc | 2 | ||||
-rw-r--r-- | src/report.cc | 9 | ||||
-rw-r--r-- | src/report.h | 10 | ||||
-rw-r--r-- | src/textual.cc | 2 | ||||
-rw-r--r-- | src/xact.cc | 6 | ||||
-rw-r--r-- | test/baseline/opt-aux-date.test (renamed from test/baseline/opt-effective.test) | 0 | ||||
-rw-r--r-- | test/baseline/opt-primary-date.test (renamed from test/baseline/opt-actual-dates.test) | 0 |
18 files changed, 77 insertions, 74 deletions
diff --git a/doc/ledger.1 b/doc/ledger.1 index 656a3866..4829034f 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -1,4 +1,4 @@ -.Dd February 27, 2012 +.Dd February 28, 2012 .Dt ledger 1 .Sh NAME .Nm ledger @@ -263,7 +263,6 @@ transactions they are contained in. See the manual for more information. .It Fl \-account Ar STR .It Fl \-account-width Ar INT .It Fl \-actual Pq Fl L -.It Fl \-actual-dates .It Fl \-add-budget .It Fl \-amount Ar EXPR Pq Fl t .It Fl \-amount-data Pq Fl j @@ -271,6 +270,7 @@ transactions they are contained in. See the manual for more information. .It Fl \-anon .It Fl \-args-only .It Fl \-auto-match +.It Fl \-aux-date .It Fl \-average Pq Fl A .It Fl \-balance-format Ar FMT .It Fl \-base @@ -308,7 +308,6 @@ See .It Fl \-display-total Ar EXPR .It Fl \-dow .It Fl \-download -.It Fl \-effective .It Fl \-empty Pq Fl E .It Fl \-end Pq Fl e .It Fl \-equity @@ -387,6 +386,7 @@ See .Fl \-leeway . .It Fl \-prices-format Ar FMT .It Fl \-pricedb-format Ar FMT +.It Fl \-primary-date .It Fl \-quantity Pq Fl O .It Fl \-quarterly .It Fl \-raw @@ -109,8 +109,8 @@ void csv_reader::read_index(std::istream& sin) if (date_mask.match(field)) index.push_back(FIELD_DATE); - else if (date_eff_mask.match(field)) - index.push_back(FIELD_DATE_EFF); + else if (date_aux_mask.match(field)) + index.push_back(FIELD_DATE_AUX); else if (code_mask.match(field)) index.push_back(FIELD_CODE); else if (payee_mask.match(field)) @@ -175,8 +175,8 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket, xact->_date = parse_date(field); break; - case FIELD_DATE_EFF: - xact->_date_eff = parse_date(field); + case FIELD_DATE_AUX: + xact->_date_aux = parse_date(field); break; case FIELD_CODE: @@ -62,7 +62,7 @@ class csv_reader enum headers_t { FIELD_DATE = 0, - FIELD_DATE_EFF, + FIELD_DATE_AUX, FIELD_CODE, FIELD_PAYEE, FIELD_AMOUNT, @@ -74,7 +74,7 @@ class csv_reader }; mask_t date_mask; - mask_t date_eff_mask; + mask_t date_aux_mask; mask_t code_mask; mask_t payee_mask; mask_t amount_mask; @@ -90,7 +90,7 @@ public: : in(_in), pathname(_pathname), linenum(0), sequence(0), date_mask("date"), - date_eff_mask("posted( ?date)?"), + date_aux_mask("posted( ?date)?"), code_mask("code"), payee_mask("(payee|desc(ription)?|title)"), amount_mask("amount"), diff --git a/src/generate.cc b/src/generate.cc index 185e23e7..963cd845 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -69,9 +69,9 @@ generate_posts_iterator::generate_posts_iterator generate_date(next_date_buf); next_date = parse_date(next_date_buf.str()); - std::ostringstream next_eff_date_buf; - generate_date(next_eff_date_buf); - next_eff_date = parse_date(next_eff_date_buf.str()); + std::ostringstream next_aux_date_buf; + generate_date(next_aux_date_buf); + next_aux_date = parse_date(next_aux_date_buf.str()); } @@ -326,8 +326,8 @@ void generate_posts_iterator::generate_xact(std::ostream& out) next_date += gregorian::days(six_gen()); if (truth_gen()) { out << '='; - out << format_date(next_eff_date, FMT_WRITTEN); - next_eff_date += gregorian::days(six_gen()); + out << format_date(next_aux_date, FMT_WRITTEN); + next_aux_date += gregorian::days(six_gen()); } out << ' '; diff --git a/src/generate.h b/src/generate.h index 47abcd94..abf719d4 100644 --- a/src/generate.h +++ b/src/generate.h @@ -57,7 +57,7 @@ class generate_posts_iterator std::size_t quantity; bool allow_invalid; date_t next_date; - date_t next_eff_date; + date_t next_aux_date; mt19937 rnd_gen; diff --git a/src/item.cc b/src/item.cc index 97411512..653013ea 100644 --- a/src/item.cc +++ b/src/item.cc @@ -35,7 +35,7 @@ namespace ledger { -bool item_t::use_effective_date = false; +bool item_t::use_aux_date = false; bool item_t::has_tag(const string& tag, bool) const { @@ -150,7 +150,7 @@ void item_t::parse_tags(const char * p, if (char * pp = std::strchr(buf, '=')) { *pp++ = '\0'; - _date_eff = parse_date(pp); + _date_aux = parse_date(pp); } if (buf[0]) _date = parse_date(buf); @@ -239,12 +239,12 @@ namespace { value_t get_date(item_t& item) { return item.date(); } - value_t get_actual_date(item_t& item) { - return item.actual_date(); + value_t get_primary_date(item_t& item) { + return item.primary_date(); } - value_t get_effective_date(item_t& item) { - if (optional<date_t> effective = item.effective_date()) - return *effective; + value_t get_aux_date(item_t& item) { + if (optional<date_t> aux_date = item.aux_date()) + return *aux_date; return NULL_VALUE; } value_t get_note(item_t& item) { @@ -403,9 +403,11 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind, if (name == "actual") return WRAP_FUNCTOR(get_wrapper<&get_actual>); else if (name == "actual_date") - return WRAP_FUNCTOR(get_wrapper<&get_actual_date>); + return WRAP_FUNCTOR(get_wrapper<&get_primary_date>); else if (name == "addr") return WRAP_FUNCTOR(get_wrapper<&get_addr>); + else if (name == "auxiliary_date") + return WRAP_FUNCTOR(get_wrapper<&get_aux_date>); break; case 'b': @@ -435,7 +437,7 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind, else if (name == "end_pos") return WRAP_FUNCTOR(get_wrapper<&get_end_pos>); else if (name == "effective_date") - return WRAP_FUNCTOR(get_wrapper<&get_effective_date>); + return WRAP_FUNCTOR(get_wrapper<&get_aux_date>); break; case 'f': @@ -472,6 +474,8 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind, return WRAP_FUNCTOR(get_wrapper<&get_pending>); else if (name == "parent") return WRAP_FUNCTOR(get_wrapper<&ignore>); + else if (name == "primary_date") + return WRAP_FUNCTOR(get_wrapper<&get_primary_date>); break; case 's': @@ -112,7 +112,7 @@ public: state_t _state; optional<date_t> _date; - optional<date_t> _date_eff; + optional<date_t> _date_aux; optional<string> note; optional<position_t> pos; optional<string_map> metadata; @@ -138,7 +138,7 @@ public: set_state(item.state()); _date = item._date; - _date_eff = item._date_eff; + _date_aux = item._date_aux; note = item.note; pos = item.pos; metadata = item.metadata; @@ -175,7 +175,7 @@ public: scope_t& scope, bool overwrite_existing = true); - static bool use_effective_date; + static bool use_aux_date; virtual bool has_date() const { return _date; @@ -183,17 +183,17 @@ public: virtual date_t date() const { assert(_date); - if (use_effective_date) - if (optional<date_t> effective = effective_date()) - return *effective; + if (use_aux_date) + if (optional<date_t> aux = aux_date()) + return *aux; return *_date; } - virtual date_t actual_date() const { + virtual date_t primary_date() const { assert(_date); return *_date; } - virtual optional<date_t> effective_date() const { - return _date_eff; + virtual optional<date_t> aux_date() const { + return _date_aux; } void set_state(state_t new_state) { @@ -220,7 +220,7 @@ private: ar & boost::serialization::base_object<scope_t>(*this); ar & _state; ar & _date; - ar & _date_eff; + ar & _date_aux; ar & note; ar & pos; ar & metadata; diff --git a/src/post.cc b/src/post.cc index d88dd869..125947e4 100644 --- a/src/post.cc +++ b/src/post.cc @@ -91,11 +91,11 @@ date_t post_t::date() const if (xdata_ && is_valid(xdata_->date)) return xdata_->date; - if (item_t::use_effective_date) { - if (_date_eff) - return *_date_eff; - else if (xact && xact->_date_eff) - return *xact->_date_eff; + if (item_t::use_aux_date) { + if (_date_aux) + return *_date_aux; + else if (xact && xact->_date_aux) + return *xact->_date_aux; } if (! _date) { @@ -105,7 +105,7 @@ date_t post_t::date() const return *_date; } -date_t post_t::actual_date() const +date_t post_t::primary_date() const { if (xdata_ && is_valid(xdata_->date)) return xdata_->date; @@ -117,11 +117,11 @@ date_t post_t::actual_date() const return *_date; } -optional<date_t> post_t::effective_date() const +optional<date_t> post_t::aux_date() const { - optional<date_t> date = item_t::effective_date(); + optional<date_t> date = item_t::aux_date(); if (! date && xact) - return xact->effective_date(); + return xact->aux_date(); return date; } @@ -657,9 +657,9 @@ void to_xml(std::ostream& out, const post_t& post) push_xml y(out, "date"); to_xml(out, *post._date, false); } - if (post._date_eff) { - push_xml y(out, "effective-date"); - to_xml(out, *post._date_eff, false); + if (post._date_aux) { + push_xml y(out, "aux-date"); + to_xml(out, *post._date_aux, false); } if (post.account) { @@ -123,8 +123,8 @@ public: virtual date_t value_date() const; virtual date_t date() const; - virtual date_t actual_date() const; - virtual optional<date_t> effective_date() const; + virtual date_t primary_date() const; + virtual optional<date_t> aux_date() const; string payee() const; @@ -230,7 +230,7 @@ public: { bool operator()(const post_t * left, const post_t * right) const { gregorian::date_duration duration = - left->actual_date() - right->actual_date(); + left->primary_date() - right->primary_date(); if (duration.days() == 0) { return ((left->pos ? left->pos->sequence : 0) < (right->pos ? right->pos->sequence : 0)); diff --git a/src/print.cc b/src/print.cc index 56a2ec7b..63f38d80 100644 --- a/src/print.cc +++ b/src/print.cc @@ -112,11 +112,11 @@ namespace { std::ostringstream buf; - buf << format_date(item_t::use_effective_date ? - xact.date() : xact.actual_date(), + buf << format_date(item_t::use_aux_date ? + xact.date() : xact.primary_date(), format_type, format); - if (! item_t::use_effective_date && xact.effective_date()) - buf << '=' << format_date(*xact.effective_date(), + if (! item_t::use_aux_date && xact.aux_date()) + buf << '=' << format_date(*xact.aux_date(), format_type, format); buf << ' '; diff --git a/src/py_item.cc b/src/py_item.cc index 51d9e50c..361de914 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -149,13 +149,13 @@ void export_item() .def("parse_tags", &item_t::parse_tags) .def("append_note", &item_t::append_note) - .add_static_property("use_effective_date", - make_getter(&item_t::use_effective_date), - make_setter(&item_t::use_effective_date)) + .add_static_property("use_auxiliary_date", + make_getter(&item_t::use_aux_date), + make_setter(&item_t::use_aux_date)) .add_property("date", &item_t::date, make_setter(&item_t::_date)) - .add_property("effective_date", &item_t::effective_date, - make_setter(&item_t::_date_eff)) + .add_property("auxiliary_date", &item_t::aux_date, + make_setter(&item_t::_date_aux)) .add_property("state", &item_t::state, &item_t::set_state) diff --git a/src/py_post.cc b/src/py_post.cc index 62323eb1..cb6ebce7 100644 --- a/src/py_post.cc +++ b/src/py_post.cc @@ -160,7 +160,7 @@ void export_post() .def("get_tag", py_get_tag_2m) .def("date", &post_t::date) - .def("effective_date", &post_t::effective_date) + .def("auxiliary_date", &post_t::aux_date) .def("must_balance", &post_t::must_balance) diff --git a/src/report.cc b/src/report.cc index c562ab38..530e7727 100644 --- a/src/report.cc +++ b/src/report.cc @@ -76,8 +76,7 @@ void report_t::normalize_options(const string& verb) HANDLER(pager_).off(); } - item_t::use_effective_date = (HANDLED(effective) && - ! HANDLED(actual_dates)); + item_t::use_aux_date = (HANDLED(aux_date) && ! HANDLED(primary_date)); commodity_pool_t::current_pool->keep_base = HANDLED(base); commodity_pool_t::current_pool->get_quotes = session.HANDLED(download); @@ -960,10 +959,10 @@ option_t<report_t> * report_t::lookup_option(const char * p) OPT(abbrev_len_); else OPT_(account_); else OPT(actual); - else OPT(actual_dates); else OPT(add_budget); else OPT(amount_); else OPT(amount_data); + else OPT_ALT(primary_date, actual_dates); else OPT(anon); else OPT_ALT(color, ansi); else OPT(auto_match); @@ -1005,12 +1004,12 @@ option_t<report_t> * report_t::lookup_option(const char * p) else OPT(date_width_); break; case 'e': - OPT(effective); - else OPT(empty); + OPT(empty); else OPT_(end_); else OPT(equity); else OPT(exact); else OPT(exchange_); + else OPT_ALT(aux_date, effective); break; case 'f': OPT(flat); diff --git a/src/report.h b/src/report.h index 565728df..2b521aae 100644 --- a/src/report.h +++ b/src/report.h @@ -224,12 +224,12 @@ public: HANDLER(abbrev_len_).report(out); HANDLER(account_).report(out); HANDLER(actual).report(out); - HANDLER(actual_dates).report(out); HANDLER(add_budget).report(out); HANDLER(amount_).report(out); HANDLER(amount_data).report(out); HANDLER(anon).report(out); HANDLER(auto_match).report(out); + HANDLER(aux_date).report(out); HANDLER(average).report(out); HANDLER(balance_format_).report(out); HANDLER(base).report(out); @@ -256,7 +256,6 @@ public: HANDLER(display_amount_).report(out); HANDLER(display_total_).report(out); HANDLER(dow).report(out); - HANDLER(effective).report(out); HANDLER(empty).report(out); HANDLER(end_).report(out); HANDLER(equity).report(out); @@ -303,6 +302,7 @@ public: HANDLER(price).report(out); HANDLER(prices_format_).report(out); HANDLER(pricedb_format_).report(out); + HANDLER(primary_date).report(out); HANDLER(quantity).report(out); HANDLER(quarterly).report(out); HANDLER(raw).report(out); @@ -361,8 +361,6 @@ public: parent->HANDLER(limit_).on(string("--actual"), "actual"); }); - OPTION(report_t, actual_dates); - OPTION_(report_t, add_budget, DO() { parent->budget_flags |= BUDGET_BUDGETED | BUDGET_UNBUDGETED; }); @@ -571,7 +569,7 @@ public: }); OPTION(report_t, dow); - OPTION(report_t, effective); + OPTION(report_t, aux_date); OPTION(report_t, empty); // -E OPTION_(report_t, end_, DO_(args) { // -e @@ -822,6 +820,8 @@ public: "P %(datetime) %(display_account) %(scrub(display_amount))\n"); }); + OPTION(report_t, primary_date); + OPTION_(report_t, quantity, DO() { // -O parent->HANDLER(revalued).off(); parent->HANDLER(amount_).set_expr(string("--quantity"), "amount"); diff --git a/src/textual.cc b/src/textual.cc index 739b63f0..4de8d461 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1603,7 +1603,7 @@ xact_t * instance_t::parse_xact(char * line, if (char * p = std::strchr(line, '=')) { *p++ = '\0'; - xact->_date_eff = parse_date(p); + xact->_date_aux = parse_date(p); } xact->_date = parse_date(line); diff --git a/src/xact.cc b/src/xact.cc index 6c07c862..8e1951a5 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -794,9 +794,9 @@ void to_xml(std::ostream& out, const xact_t& xact) push_xml y(out, "date"); to_xml(out, *xact._date, false); } - if (xact._date_eff) { - push_xml y(out, "effective-date"); - to_xml(out, *xact._date_eff, false); + if (xact._date_aux) { + push_xml y(out, "aux-date"); + to_xml(out, *xact._date_aux, false); } if (xact.code) { diff --git a/test/baseline/opt-effective.test b/test/baseline/opt-aux-date.test index 9d1e73d0..9d1e73d0 100644 --- a/test/baseline/opt-effective.test +++ b/test/baseline/opt-aux-date.test diff --git a/test/baseline/opt-actual-dates.test b/test/baseline/opt-primary-date.test index e69de29b..e69de29b 100644 --- a/test/baseline/opt-actual-dates.test +++ b/test/baseline/opt-primary-date.test |