Hi,

We like this module very much. We would like to see it with an option where fees (Commerce Fees) and shipping are removed from the order total, since we have some fees which are not interesting from a sales reporting perspective. We are interested in the base price including VAT actually.

We can provide this, any ideas on where to start?

Best Eric

CommentFileSizeAuthor
#8 2284209-8.png40.25 KBvincentdemers

Comments

periksson’s picture

We solved this by creating a custom module which adds a price field to the order (commerce_product_total) including VAT. The field is updated using hook_entity_presave. We then modify the Commerce Reporting view to use this field instead.

Feel free to ask if you want the source code. It's too small to create a module, but we can indeed provide a sandbox.

Best Regards
Eric

mglaman’s picture

Component: Code » Documentation

Thanks for follow up! Sorry I didn't get a chance to reply earlier. I need to get documentation written up that does some "views recipes" and that this module serves as a simplistic blanket approach to reports - not a reporting API (yet/maybe/possibly.)

joecacti22’s picture

Anything new here?

I need to provide a report that shows just the subtotal before shipping and tax. I was able to add a php field in views to show the shipping cost using below. Is there a way to do this and show the subtotal?

$order = commerce_order_load($row->order_number);
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$currency_code = $wrapper->commerce_order_total->currency_code->value();
foreach ($wrapper->commerce_line_items as $line_item_wrapper) {
if ($line_item_wrapper->type->value() == 'shipping') {
// $line_item_wrapper->line_item_label->value();
return commerce_currency_format($line_item_wrapper->commerce_unit_price->amount->value(), $currency_code);
}
}

mglaman’s picture

Component: Documentation » Code

So it seems here that: the price formatter skills have the ability to include our exclude certain components.

Here's what I'm proposing: create a nice price field formatter for Commerce Reports. This formatter will check a configuration stung on what components to include.

I'll make an admin form that lists all price components. If none are checked, it assumes all. If some are checked only those will factor into the reports.

mglaman’s picture

Marking this under the beta2 release plan #2425267: [META] 4.0 Beta2 Release Plan

mglaman’s picture

mglaman’s picture

Status: Active » Closed (won't fix)

There's actually a module that does exactly what I proposed! Please see Commerce price by components. This should allow you to select how the price is formatted (excluding components.)

vincentdemers’s picture

StatusFileSize
new40.25 KB

Actually due to the way that price components for the order total field are stored as a serialized array this is not possible.
https://www.drupal.org/node/2492043

Fact is we cannot use SUM as an aggregation type for a price component such as base_price.

If components were part of the "Group column" maybe that would be feasible.
Group by options for order_total in commerce_reports

thirdender’s picture

I agree that the Commerce price by components isn't a good solution. I think there needs to be a new module that stores calculated subtotal in a field on the order. This would allow for aggregation in Views. I think there should also be a way to configure what is considered the subtotal (options to include or exclude shipping, tax, etc), and a page to recalculate all order subtotals using the batch API.

I know it seems a bit redundant, but the problem is (as pointed out in #8) that the prices are stored in a serialized string that can be operated on by the SQL server.

Do you think this would be a good addition to the Commerce Reporting module, or do you think it would be better as a stand-alone module?

mrpeanut’s picture

Status: Closed (won't fix) » Active

I am having this same issue. You can't SUM with Price by components. Seems like this would fit in Commerce Reporting. How does everyone else show sub-total totals, or discount totals, shipping totals, etc.?