In the original Commerce Reports there was a "Sales" report that allowed viewing the breakdown by daily, weekly, monthly, and yearly. To dogfood the Views integration, this should be recreated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs work
FileSize
12.52 KB

Here is the first go.

mglaman’s picture

FileSize
24.41 KB

Yearly added. Can't get menu links and tabs to cooperate.

lisastreeter’s picture

Made a little progress. I recently had the same tabs/menu issue while working on another project. Ended up just creating the menu link separately from the view. So I added that to links.menu.yml. I also added a tab for daily but couldn't add weekly:

Drupal\views\Plugin\views\sort\Data.php lacks an option for 'week' granularity. Looks like it would be a pretty simple patch. I just wasn't sure about the format.

mglaman’s picture

I just looked, in 7.x-4.x I added a custom handler: http://cgit.drupalcode.org/commerce_reports/tree/includes/views/handlers...

      case 'week':
        $formula = views_date_sql_format('YW', "$this->table_alias.$this->real_field");

And here we make it the default sort handler in a views data alter. So just like I provided a work around for the ReportDateField we'll need a sort version.

//Changed created to use our date sort handler which adds weekly granularity.
  $data['commerce_order']['created']['sort']['handler'] = 'commerce_reports_handler_sort_date';
mglaman’s picture

FYI we can make that its own issue, then mark it as a blocker from here. Get that in, then re-roll the patch.

lisastreeter’s picture

mglaman’s picture

Status: Needs work » Needs review
FileSize
46.82 KB
510.27 KB

Here is the updated view, with weekly thanks to the fix in #2976401: Create a custom sort handler to provide 'weekly' aggregation option. embedded gif goodness.

Status: Needs review » Needs work

The last submitted patch, 8: 2976147-8.patch, failed testing. View results

mglaman’s picture

Status: Needs work » Needs review
FileSize
47.29 KB

Try to fix schema error. Forgot to mark Views in info.yml, too.

Status: Needs review » Needs work

The last submitted patch, 10: 2976147-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mglaman’s picture

Status: Needs work » Needs review
FileSize
48.02 KB

Try to fix the schema issues.

mglaman’s picture

For

Schema errors for views.view.sales_report with the following errors: views.view.sales_report:display.default.display_options.fields.report_id.set_precision missing schema

the `report_id` is an entity field, but COUNT() aggregated. So it’s been flipped to a `numeric` handler. But the handler is overridden at run time, not in a schema level.

mglaman’s picture

There's a core bug. I'll just tell the test to not validate schema. See #2976616: Aggregated entity fields cause SchemaIncompleteException

Status: Needs review » Needs work

The last submitted patch, 12: 2976147-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mglaman’s picture

Status: Needs work » Needs review
FileSize
48.26 KB

Skip checking the schema.

  • mglaman committed af34d4c on 8.x-1.x
    Issue #2976147 by mglaman, lisastreeter: Create a sales report...
mglaman’s picture

Status: Needs review » Fixed

Comitted!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.