Product price calculation event is only being fired for orders in a shopping cart statuses (which include Checkout statuses).

As it should be possible to have a cartless, and checkout system, taxes need to be calculated so they can be viewed in full on the View Order page without moving into the cart and checkout declared stauses.

Comments

essbee’s picture

For anyone interested right now the work around for this is to flick every order into the Checkout: Checkout status. This causes taxes to be calculated for the order.

Damien Tournoud’s picture

The "cart" status means "an order that is not final yet". Even if you implement a cart-less system, you should still put your order in cart status as long as it is not final. You can alter set the 'cart' flag to any status using hook_commerce_order_status_info() and hook_commerce_order_status_info_alter().

essbee’s picture

Hi Damien,

The issue here is that orders created through admin don't receive tax application because the calculate price routine is not fired. I can create a perfectly functional system without installing cart or checkout modules but taxes are not calculated. So when the order is viewed, there are no taxes present.

An example use case for this would be an invoicing based system.

essbee’s picture

Hmmm ok this issue is actually a bit wider than just the cart part of it.

When editing any order, taxes should be recalculated upon any changes to line items. This is not currently the case for all order statuses.

So as it stands right now it is possible to create a scenario where taxes are not calculated at all, or a scenario where taxes have been calculated, but then items on the order changed but taxes not recalculated to demonstrate.

Is it possible to just have the tax calculation routine firing on all line item changes/additions/deletions?

essbee’s picture

Title: Taxes not calculated for non-shopping cart orders » Sell Price calculation doesn't trigger for non shopping cart statuses

Have renamed this as this is more than just a tax issue.

Not sure whether this should be a separate issue, but noticed the "Unit Price" field on the admin order edit screen is an editable field for non-Price Calculation triggering order statuses, but is disabled for statuses that trigger price calculation.

Price calculating statuses: [Shopping cart: Shopping cart], [Checkout: Checkout] & [Checkout: Review]

This means that an order in [Checkout: Complete] status can have its price updated and the order not total correctly. Given that when the Calculate Sell price routine runs it overrides the price held in Unit Price regardless of whether it has been modified admin, it raises the question as to when one would actually need the field editable.

rszrama’s picture

The fact that sell price calculation isn't happening for non-cart statuses is intentional. You wouldn't want your completed orders suddenly changing product prices and taxes after they've been paid for and shipped. : ) This is why "cart refreshing" (which in turn triggers the recalculation) is only automated through the cart module for orders in a cart status.

However, I'm pretty sure we had another issue open to make this a manual option for non-cart orders. In other words, I still think you should be able to recalculate prices for non-cart orders, but we shouldn't automate it at all. It should be a specific submit button on the order edit form that refreshes the items on the order... in fact, I'd almost want to put a confirmation form on it to make sure it didn't get clicked / submitted accidentally.

If anyone digs up the other issue, we can close this one as duplicate and link it from the other issue... otherwise, maybe I was just imagining having posted an issue for it. Quite possible... : P

pcambra’s picture

rszrama I don't find the issue neither... maybe we discussed it only via IRC because I remember talking with you about it :)

essbee’s picture

Agree having the ability to trigger manually for non cart statuses would be a good thing and would resolve issues raised here.

rszrama’s picture

Title: Sell Price calculation doesn't trigger for non shopping cart statuses » Add the ability for administrators to manually recalculate non-cart order line item prices
Component: Product pricing » User experience
Category: bug » feature
essbee’s picture

What needs to be called in order to recalculate the order totals?

I can manipulate prices in non-cart state orders, and the line totals update, but the order totals, taxes etc do not.

Is this as simple as making a call to a price calc routine?

From a UX perspective, wouldnt it make sense when the Unit price field is edited, and the order is a non-cart status, to apply an "edit-changed" state to the form, with the typical yellow highlighted box advising that changes will be saved and order totals will be updated once the order is saved.

This way the administrator is aware that manipulating the price will change the order total (although I struggle to picture a use case where one would want to manipulate the price of an order line item without updating the order totals).

essbee’s picture

Status: Active » Closed (duplicate)

I'm marking this a duplicate of http://drupal.org/node/1124414 as I think that issue more succinctly explains the issue of totals/taxes not being recalculated

essbee’s picture

Component: User experience » Tax
Status: Closed (duplicate) » Active

Reopening as not fixed by the fix for http://drupal.org/node/1124414

essbee’s picture

Why can't I simply change the trigger for the rule: "Calculate taxes: Sales tax".

the "Calculating the sell price of a product" event only occurs through cart statuses, and further will reset any manual price overrides. What is preventing me from moving this routine say to the "After an Order is Saved/After an order is updated event. This would ensure that taxes were always calculated on orders, even if they did not go through the cart system.

This would certainly provide a far more flexible system - allowing administrators to place tax routines wherever was appropriate for their use case.

Ideas greatly appreciated.

Sam

rszrama’s picture

Status: Active » Closed (duplicate)

Looks like someone else came in with some code for this feature, so let's close this one as duplicate.

See: #1645252: Allow administrators to trigger "checkout completed"