ferid -- I've read the post over several times now that you made, and I must admit, I still don't get it. How is it possible that you subtotal is less than one of your items? Did you use a coupon or something? But...usually coupons happen after the subtotal and are reflected in the total....I just don't get it.
Anyway, regardless, I think I can clear up how taxes work:
Each item is assigned its own tax rate for an order. So, each item is calculated for that tax rate. The subtotal is completely ignored as far as taxes are concerned. Something is causing your subtotal to be less than the cost of the item. Hence, edit orders is calculating the tax based on your item NOT the subtotal. It does this so that you can charge different tax rates for different items. (Of course, the total tax is lumped together as one tax below the subtotal no matter how many tax rates you have. Hence the earlier problem in this thread where someone wanted to separate taxes into two line items instead of one.) I believe that is the problem you are having. This is how the mod was designed to work -- v1 and v2 both do this.
I think this example will help many people who are having tax issues. There is no perfect way to deal with taxes when editing an order -- so sacrifices have to be made. The way Zen Cart was designed orders were not meant to be edited, so edit orders has to take some liberties. Here's an example of how this works:
Item A $100 @ 15% Tax = $15 Tax
Item B $200 @ 20% Tax = $40 Tax
Subtotal: $300
Coupon $15 off
Tax: $10 @ 10% Tax = $1 Tax
Tax VAT 1: $56
Tax VAT 2: $56
Notice that the two taxes take the same value -- the total tax for the order. Also notice that the coupon and subtotal have no effect on taxes. If you want this scenario to work, you'd need to do the following:
Item A $85 @ 15% Tax = $12.75 Tax (Instead of coupon, subtract $15 from item. Then, it applies taxes based on that tax rate!)
Item B $200 @ 20% Tax = $40 Tax
Subtotal: $285 (Subtotal changes because price of item changed.)
Coupon NONE
Tax: $10 @ 10% Tax = $1 Tax
Tax All VAT Combined: $53.75 (Only one tax type is defined that combines all taxes, no matter what rate, together.)
Notice, this works much better because the coupon is folded into an item, and then takes that items tax rate. Plus, only one tax is defined that acts as a catch all for ALL taxes.
You can easily see the dilemmas with edit orders --- which items fall under what tax rates? Where do these taxes go, the first or second tax type? What tax rate do coupons take? Etc.... Much of this data is not stored in the database once an order is placed -- Zen Cart is really not designed to edit orders. Hence, there is no perfect solution. Edit orders strives to do its best, but it will not work correctly in all situations. The more conventional and simple you situation is, the more likely everything will work fine with tax calculations. If not, you may have to figure workarounds out like I did here if you want to use edit orders. If you have more than one tax line for an order -- it simply won't work at all. Edit orders was designed for one tax line per order. Hope this explanation helps!



