dmitry-merzlyakov / nledger

.Net Ledger: Double-Entry Accounting System
Other
182 stars 51 forks source link

Fix inverted conditions in DateSpecifier #38

Closed aaubry closed 8 months ago

aaubry commented 9 months ago

The conditions in the DateSpecifier constructor are inverted, causing queries such as --begin 'since 7 days ago' reg to be filtered incorrectly. When the traits are null (or omitted), the intention is to include every component of the date, but currently no components are used. In the original source, the conditions are different:

  date_specifier_t(const date_t& date,
                   const optional<date_traits_t>& traits = none) {
    if (! traits || traits->has_year)
      year = date.year();
    if (! traits || traits->has_month)
      month = date.month();
    if (! traits || traits->has_day)
      day = date.day();

    TRACE_CTOR(date_specifier_t, "date_t, date_traits_t");
  }

This fix inverts the logic to match the original source code, and makes the above query work as intended.

dmitry-merzlyakov commented 9 months ago

Hi @aaubry Thank you for a good catch - the matter of the request and changes are absolutely clear.

Could you, please, make some small adjustments before completing the PR:

Let me know if you need any assistance. Thank you!

aaubry commented 9 months ago

Sure, no problem. I'll try to do that still today. Thanks!

aaubry commented 8 months ago

I'm closing this because I don't think I can change the target branch. I've opened https://github.com/dmitry-merzlyakov/nledger/pull/39 instead.