Hey, thanks for this great module at first.

Currently I'm working on reports for ERPAL Platform distributive.
We are using Commerce reports tax module to calculate taxes for our orders, because it great module and Commerce and ERPAL Platform work together very well.

In our system we are using several order types and each order type may have custom statuses. But in Tax reports we have hardcoded statuses: 'pending', 'processing', 'completed'. So tax doesn't calculate for my orders because some of them don't have such statuses at all.

It would be really nice to have these statuses configurable.

Comments

skdrupal88’s picture

Status: Active » Needs review
StatusFileSize
new4.35 KB

I implemented it in my patch, but check please titles and descriptions for status settings fields, maybe you could define better titles.

mglaman’s picture

Thanks for the patch! You think it'd be more effective to selectively rekey based in status versus state? What state are your statuses attached to?

I can't rember where 'processsing' status gets made (which contrib) but I know I see it often. Would like to see it still in there by default. Pending and processing use the same state, which identifies checkout has been completed - or that actions have been completed, ready to be closed out and marked 'completed'

skdrupal88’s picture

StatusFileSize
new57.24 KB
new4.26 KB

I tried to don't change previous module structure, thats why I used such default statuses, from patch:

-    $order_previous_status = in_array($original->status, array('pending', 'processing', 'completed'));
+    $order_previous_status = in_array($original->status, variable_get('commerce_reports_tax_order_statuses', array('pending', 'processing', 'completed')));
-  return array('pending', 'completed');
+  return variable_get('commerce_reports_tax_order_generate_statuses', array('pending', 'completed'));

I changed foreach to get statuses, patch in attachments.
States/statuses I use:
Only local images are allowed.

torgospizza’s picture

Why don't we just use "post-checkout" states rather than having to configure statuses every time? e.g.,

$post_checkout_states = array_keys(commerce_order_statuses(array('state' => 'completed')));

$order_previous_status = in_array($post_checkout_states);

I would also recommend replacing the function commerce_reports_tax_order_statuses() with a similar $post_checkout_states array-building function.

EDIT: I'm also noticing that it appears "status" and "state" are being confused all over the Commerce Reports module, so this might be part of a larger issue.

mglaman’s picture

Component: Code » Tax Reports

torgosPizza, you're right they are being confused across the module. 7.x-3.x relied on the status of an order. In 7.x-4.x I have tried to move over to state. All of the Views should use state now. The more "codified" submodules may not have been - such as tax and stock. My primary goal for those was to improve code and bring it up to speed and may have missed that.

I would much rather prefer order states versus status.

mglaman’s picture

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

  • mglaman committed ce4ab38 on 7.x-4.x authored by korgik
    Issue #2380219 by korgik: Tax reports - order statuses configuration...
mglaman’s picture

Status: Needs review » Fixed

Committed! Thanks for patch.

+++ b/modules/tax/commerce_reports_tax.admin.inc
@@ -8,19 +8,47 @@
     '#type' => 'submit',
     '#value' => t('Generate all tax information'),
     '#submit' => array('commerce_reports_tax_form_submit_generate'),
   );
...
+  $values = $form_state['values'];
+  variable_set('commerce_reports_tax_order_generate_statuses', $values['commerce_reports_tax_order_generate_statuses']);
+  variable_set('commerce_reports_tax_order_statuses', $values['commerce_reports_tax_order_statuses']);
+

I added the system_settings_form_submit callback to the generate button's submit callbacks. This way we don't need to worry about variable logic in the generation callback.

Also, in reference to #4. Across the module there is discrepancy on status and state. In my opinion the Views should be based on Order State since it comes configured with no (simple) front facing configuration. Tax, however, has a front facing configuration and Order Status is much simpler than introducing Order State to user UI. AFAIK Commerce doesn't really make Order State a front facing feature, more so for back end simplification.

Status: Fixed » Closed (fixed)

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

The last submitted patch, 1: commerce_reports-configurable_statuses-2380219-1.patch, failed testing.

Status: Closed (fixed) » Needs work

The last submitted patch, 3: commerce_reports-configurable_statuses-2380219-3.patch, failed testing.

mglaman’s picture

Status: Needs work » Fixed

Moving on.

Status: Fixed » Closed (fixed)

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