Currently uc_reports_products / uc_reports_customers / uc_reports_sales_summary are monolithic functions that do all of the querying to create a data structure, then call theme functions and return formatted output. These fucntions could be re-usable for other purposes ( eg reporting apis ) if they are re-factored, for example:

function _uc_reports_products() {}

^^ This function does al the heavy-lifting and generates a data structure.

function uc_reports_products() {}

^^ This function is a basic wrapper that just calls _uc_reports_products, then uses the returned data structure and cals the theme functions.

This way, if I want to create a callback that returns a product sales report as JSON data, I can just call _uc_reports_products() directly instead of having to eg copy the entire function over into a custom module.

Comments

rszrama’s picture

Status: Active » Postponed

Tell me about it. That module's SQL is horrible, too. We just need a full replacement of the reports module. : )

I'm going to postpone this due to our place in the release cycle, not because it's a bad idea. Thanks for the feedback!

tr’s picture

Version: 6.x-2.0-rc6 » 7.x-3.x-dev
Status: Postponed » Active

Reopening the issue so it can be addressed for the next major release.

longwave’s picture

Marked #1015056: Sales Report: Show separate line item for recurring monthly as duplicate. It would be good to either build the reports entirely with Views, or at least add some hooks and make that SQL less horrible.

tr’s picture

uc_reports was created because Ubercart needed reports and back then Views didn't support queries on arbitrary tables. Since orders aren't nodes, Views was useless for this purpose. Times have changed though and Views is far more capable. Ubercart gets constant requests for "add this type of report", or "I need another column for this report", or "please add a hook into report generation" etc. So we have a choice of either creating a general-purpose report builder UI, or switching all reports to Views and getting this for free. I vote for the latter :-).

I suggest that Ubercart 3.x should come with a set of pre-built Views replicating the familiar reports from Ubercart 2.x, then we can throw away uc_reports.

tr’s picture

Title: Re-factor report query functions to make them more useful? » Replace uc_reports with Views
tr’s picture

Component: Code » Reports
giorgio79’s picture

So we have a choice of either creating a general-purpose report builder UI, or switching all reports to Views and getting this for free. I vote for the latter :-).

You could also make each order a node, with an order content type :)

tr’s picture

@giorgio79: Orders are already Entities in D7. The only blocker on this issue is someone to devote time to creating the views and integrating them into uc_reports in place of the existing ad hoc solution.

goodeit’s picture

StatusFileSize
new31.67 KB

Here's a view that I put together real fast to emulate the product report in uc_reports. It has sorting by role added, but doesn't have any kind of date filter.

I haven't tested this thoroughly, but wanted to share in case it could help someone.

DanZ’s picture

This still needs to be done.

There may be some steps still required before all the Views can be constructed. For instance, #1876496: Calculate additional Ordered Product fields for Views was needed for per-product sales breakdowns and #1490632: Expose payment receipts and payment balance to Views was needed for some accounting.

Are any other data sources still required? A key point is that normal Views aggregation (SUM(), GROUP BY) does not work on computed fields.

Also, the current reports provide CSV files, which are essential. Views does not do this out of the box, but instead relies on add-on modules such as Views Data Export. How should Ubercart deal with this?

longwave’s picture

I think this really just needs someone to spend the time trying to build the reports in Views and seeing what's not yet possible.

Regarding the CSV files we can just suggest that people install Views Data Export if they don't have it but they would like to export their reports, and add the relevant displays to the views when the module is installed. This is technically a regression but unless we package Data Export with Ubercart (which is a terrible idea) there is no way round it.

tr’s picture

Version: 7.x-3.x-dev » 8.x-4.x-dev
Issue summary: View changes

Will implement in 8.x-4.x first then backport to 7.x-3.x. This will never be backported to 6.x-2.x.

tr’s picture

Marking #1472748: Different csv data in product report <> custom product report as a duplicate, because that won't be an issue anymore when reports are provided through Views.

tr’s picture

Marking #708932: Reports don't show multiple currencies as a duplicate.

We must ensure currency is shown in the new Views reports.

bisonbleu’s picture

Status: Active » Needs work
StatusFileSize
new18.84 KB

Following up on #2877465: Displaying the Customer report stalls for 10,000 customers with multiple orders

Here is a Views version of Ubercart's core Customers Report (User).

It was built using views-7.x-3.14 and Ubercart 7.x-3.9 just because I have such an environment where I could test it. Let me know if this is OK or if I should upgrade to latest releases 7.x or 8.x. I'll wait a little for comments before tackling the next reports.

The only thing missing: Export to CSV file. and Show all records which I guess could be handled by views_data_export

bisonbleu’s picture

Status: Needs work » Active

Changing back to Active.

tr’s picture

Bump.