Renamed actual/effective dates to primary/auxiliary
This commit is contained in:
parent
7a55c7ffc1
commit
656e46e182
18 changed files with 77 additions and 74 deletions
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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 << ' ';
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
22
src/item.cc
22
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':
|
||||
|
|
|
|||
20
src/item.h
20
src/item.h
|
|
@ -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;
|
||||
|
|
|
|||
24
src/post.cc
24
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));
|
||||
|
|
|
|||
|
|
@ -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 << ' ';
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
10
src/report.h
10
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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue