Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard-widget): make "this year" display correct count of donations #2847

Closed
Benunc opened this issue Feb 27, 2018 · 1 comment
Closed
Assignees
Milestone

Comments

@Benunc
Copy link
Member

Benunc commented Feb 27, 2018

Issue Overview

"This Year" is currently showing all donations for all time. It should show just the current calendar year.

Expected Behavior

It should show just this year, or even better would be to allow the admin to set a fiscal year somewhere in the settings, and just show the fiscal year here.

Current Behavior

SHows all time donations.

Possible Solution

from super user Scott Lewis:

I think the "This year" part of the dashboard widget is just coded wrong. It says:

give_currency_filter( give_format_amount( give_get_total_earnings(), array( 'sanitize' => false ) ) )

which looks like total all time earnings to me. If you look at the code for give_get_total_earnings() in give/includes/payments/functions.php you will see there is no date bounds in this calculation at all. It is what it says: total earnings but that isn't "last year" which is where it is being used in the dashboard widget.

The other dashboard numbers use:
give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) )

where 'last_month', 'this_week' or 'this_month' are specified.

Changing the widget to use:

give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_year' ), array( 'sanitize' => false ) ) )

produces the correct total for the past year and is probably what the dashboard widget should be using.

Steps to Reproduce (for bugs)

  1. In an install with lots of donations spanning multiple years, check the "This year on the dashboard widget
  2. It will not correctly display this year.
@slewisma
Copy link

Slight clarification: for "this year", it should use "this_year" in get_earnings(), not "last_year" as my email to Ben stated.

The reason for consideration of letting the admin specify their fiscal year is that this_year and last_year refer to calendar years but that may not be what the admin wants to see on the dashboard if they do all their tracking and reporting by fiscal year. Also, this_year should really be labelled "Year to date" if corrected to use this_year since it isn't a whole year unless it is 23:59:59 on 12/31 when the dashboard is viewed.

@DevinWalker DevinWalker added this to the 2.0.5 milestone Feb 28, 2018
@DevinWalker DevinWalker self-assigned this Feb 28, 2018
DevinWalker pushed a commit that referenced this issue Feb 28, 2018
fix(dashboard-widget): incorrect stat for this year #2847
DevinWalker added a commit that referenced this issue Feb 28, 2018
* release/2.0.5:
  fix(dashboard-widget): incorrect stat for this year #2847
  fix(cache): typo in text domain
  fix(cache): typo in function name
DevinWalker added a commit that referenced this issue Feb 28, 2018
* release/2.1: (38 commits)
  fix(dashboard-widget): incorrect stat for this year #2847
  fix(cache): typo in text domain
  fix(cache): typo in function name
  fix(compat): resolve caching conflict with W3TC
  fix(form): #2838
  fix(compat): Change hook that load give text domain #2784
  style(code): improve formatting
  fix(form): sanitize default minimum amount
  fix(donation): Change Minimum Amount to 1.0 if empty  #2819
  fix(phpcs): Fix phpcs error #2819
  refactor(donation): Remove unwanted condition check #2819
  fix(donation): Fix amount format #2819
  fix(donation): Fix minimum donation amount check #2819
  refactor(import-settings): use core functions and sanitize $_POST
  feat(export): Make checkbox fields for export checked by default
  feat(export): Add feature to selectively export fields
  fix(media-uploads): upload file to correct folder
  fix(cache): prevent possible cache  conflict on multisite
  fix(db): use get_offset fn instead of repeatable logic
  style(db):improve code formatting
  ...
DevinWalker added a commit that referenced this issue Feb 28, 2018
* release/2.1: (39 commits)
  fix(dashboard-widget): incorrect stat for this year #2847
  fix(cache): typo in text domain
  fix(cache): typo in function name
  feat(admin-plugin): Add Give menu in plugin menu section #2278
  fix(compat): resolve caching conflict with W3TC
  fix(form): #2838
  fix(compat): Change hook that load give text domain #2784
  style(code): improve formatting
  fix(form): sanitize default minimum amount
  fix(donation): Change Minimum Amount to 1.0 if empty  #2819
  fix(phpcs): Fix phpcs error #2819
  refactor(donation): Remove unwanted condition check #2819
  fix(donation): Fix amount format #2819
  fix(donation): Fix minimum donation amount check #2819
  refactor(import-settings): use core functions and sanitize $_POST
  feat(export): Make checkbox fields for export checked by default
  feat(export): Add feature to selectively export fields
  fix(media-uploads): upload file to correct folder
  fix(cache): prevent possible cache  conflict on multisite
  fix(db): use get_offset fn instead of repeatable logic
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants