VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: bpos on May 28, 2020, 23:48:52 PM

Title: Edit Order Taxes?
Post by: bpos on May 28, 2020, 23:48:52 PM
 I am using joomla 3.9.18 and VM 3.8.2.  Up to date as of this posting. I have read numerous posts on something similar to this but not exactly?

When a customer puts in an order everything on the front end works great. Taxes calculated and Grand total works as it should. Then submits the order all is ok at this point. But if the customer wants to add an additional product after the order is submitted the admin can do this on the backend?

Well so I thought.  If I (admin) put in the additional items and try to re calculate the total things dont go as planned. The item gets added but the tax row does not work at all. In fact now that the order has changed the tax is eliminated from the entire order. Is there a way or a hack that can be used to get the tax row working in the backend?

Its like the original order is a snapshot and the backend is just a way to add product but not calculate a new total with tax? Invoice creation and print version do update but with no tax as well.
Pics attached show original order and after adding additional items.

Please advise
Thanks
Title: Re: Edit Order Taxes?
Post by: jenkinhill on May 29, 2020, 11:17:36 AM
In my view you should create a new order for the extra product, not modify an existing contract (order).
Title: Re: Edit Order Taxes?
Post by: bpos on May 29, 2020, 11:53:42 AM
Whats the point of being able to add or edit the invoice if you cant get the total with tax correct?
Title: Re: Edit Order Taxes?
Post by: pinochico on May 29, 2020, 12:50:57 PM
What's the point of editing an order?

I don't see any sense and I don't use this function (I don't like it), precisely because of the problems of correct calculation.

I inform customers that we do not edit the order and create a new one.
Then everything works.
Title: Re: Edit Order Taxes?
Post by: jenkinhill on May 29, 2020, 16:06:52 PM
In some countries it is illegal to change an invoice once an order is confirmed, and against the rules of some payment providers.
Title: Re: Edit Order Taxes?
Post by: AH on May 29, 2020, 18:26:58 PM
Of course you should be able to edit an order in ADMIN

If no invoice exists or payment has not been made

If you cannot think of any scenarios where this is a valid business process - I suggest you go and spend more time with clients
Title: Re: Edit Order Taxes?
Post by: bpos on May 29, 2020, 19:15:17 PM
I use this invoice system to merely make invoices. Not to run a detailed cost analysis report for the tax lawyer. I do not do transactions online. Its illegal in our area.
I use a POS system (store front) that is designed for this. Even the POS system has a way to add/edit orders to get the correct pricing at a later time.

Secondly whats the point of having "shopper confirmed" and "confirmed?"  If a invoice is "shopper confirmed" its not admin approved "confirmed" until the shop owner says its confirmed? All orders are just shopper confirmed so at that point no transaction has occurred so why wouldn`t you want to get an order correct before finishing a transaction?

For instance in my case. The customer orders 35 items and has looked around on my site for 30 minutes to compose this list of items. They want a total. "shopper confirmed".  Then email me and say can you add something I forgot. I have a choice. Either say " Can you go back and add what you want to another invoice?"  Or perhaps say "Can you just start over and get your order right?"  It might make someone frustrated and say "you know what" forget it. Too much trouble...   They still have the choice of saying I dont want what you added and say cancel or void the order.

Honestly if you are worried about keeping the taxes (books) correct then I would rely on something other than this system. For instance pay pal has all the details for any transactions made if your customer used VM to make the purchase?

Going back to the original question. Is it really that big of a deal to be able to calculate the order correctly (taxes) on the backend of an unfinished order?
After all there is a spot to add additional product?

No one is changing an order after its been processed by a payment provider.  Why would you?
Title: Re: Edit Order Taxes?
Post by: pinochico on May 29, 2020, 22:50:46 PM
QuoteNo one is changing an order after its been processed by a payment provider.  Why would you?

It's just a wish.

If there is an option to edit an order in the administration, none of the administrators will distinguish whether it is paid or not and will edit it because the customer will call.

Why?

Because it works (in VirtueMart or using additional applications).

And after the e-shop (VirtueMart), he will then request the correction of his mistake so that he is not penalized by the payment gateway.

Who decides when another paid order can be edited and when not?
Until when is it possible to edit an order and from when not?
Administrator?
E-shop creator?
VirtueMart?

I don't know if there will ever be the right way.
Title: Re: Edit Order Taxes?
Post by: bpos on May 30, 2020, 00:31:14 AM
I can understand why it is set up the way it is.

I just think VM can be more versatile than that.  If one never uses this with a payment gateway then there is no need to worry about what gets edited? (crazy idea I know)

As I mention I am just using it as a invoicing system only. There are plenty of times where I receive an invoice from places only to tell the vendor to add to it before I say ok lets pay for it? Then they call to take payment.

Just seems odd that there is an edit button to add a product but no way of calculating correctly? While I am complaining about the invoice section.. the invoice deletion could be helpful in the midst of this. If you want the customer to put in another order (add to the order) then why not just delete the invoice and let them create a new one? It is very difficult to figure out how all this invoicing system should be setup and how it looks and such in the beginning. I must have made 20 invoices that are stuck in limbo on my orders section doing nothing all because I cant delete them?
Again I understand the reasoning why it is the way it is. But perhaps just the superadmin can edit these things?

If anyone is editing there is obviously a invoice status that lets you know if you should do any editing? How about shopper confirmed means we can still talk about it. And confirmed means its to late to do anything?

I can see how this would be difficult if your were using this as a full on shop with payment gateway since the shopper would complete the transaction at the time of ordering. But I am speaking of those who might not set up a transaction (payment gateway) ?

Just some thoughts..

Title: Re: Edit Order Taxes?
Post by: AH on May 30, 2020, 10:58:48 AM
Bpos

VM allows orders to be edited, when you do it is completely irrelevant to the functionality that is supported.  The WHEN becomes a business decision with all the associated risks and responsibilities.

There is some control in VM now to stop invoiced orders being edited - that is NOT the issue here and is a moot point.

Pinocchio - the right way,  that is what the business decides meets their needs - let the business decide what is legal for the country within which their operations are based.

So back to the real problem.

The tax should be correct, it looks to be a fault

To provide input to the team - could you create 2 orders exactly the same - then use the edit function WITHOUT MAKING CHANGES  and just save the first order

Then compare the database table entries for the 2 orders
orders
order item details

Then if both the order table entries are the same (ie saving after changing nothing is fine) you can go to the next part of the test.

Add an order item and compare again

Please can you do this and provide a result??
Title: Re: Edit Order Taxes?
Post by: bpos on May 30, 2020, 12:25:48 PM
 You are correct that the tax is the fault. 

I didnt have to check the database to see what happened but its the same in the database.

The tax on the edited version skips the calculation.  The subtotal is the same as the grand total.

The order subtotal is changed in the orders table.

So for some reason in the cart I am adding the final price to get the subtotal and in the orders BE it looks like it wants to try and calculate the cost column instead?

Now that I look at this let me explain some things.

In a normal "simple" order invoice we use 4 basic rows.
 
Final price
Subtotal
tax
Total

Thats it.

There is no need for VAT or Discount or any other muddled numbers that dont come to the exact conclusion of price.

I would like to add a few things that seem confusing to me. Which might contribute to why this thing is not calculating correctly?
In my world "cost" means cost of goods (which would NEVER be shown to customer) I would say it should be lower than the sales or final price???
                   "base price" ? I Have no idea why this is needed. I understand its used as currency conversion but has no use to me.
                    "final price" Well normally this is the sales price of an item where I come from.
                    "override"? ??? No idea why you need this. maybe for discounts?
                     overwrite final ? and overwrite final to be taxed? OK..

So on the front end in products I have this set where it shows for some odd reason the base price slashed out then gives the final price under that with a nice little message saying "you save x amount"
In the backend I have my products set up with a fictitious cost price (which should be cheaper than the sales price but is not in this case) and a final price that is overwritten to be taxed?
It looks good I suppose for the customer shopping thinking that they are saving with all this showing. I am aware all of this can be hidden.
Moving on to the actual cart. I have removed all of the garble... discount heading, tax heading, slashed price (cost price) and instead have the 4 simple rows that are the real sales prices and taxes and totals

Billing/Shipping and payment method not used for me. So its gone in the cart.

In the backend I have no idea why there would be a cost price and a base price with tax, total discount then another column with tax then show the cost price slashed in the total? I assume all this is needed across the pond?

Anywho Im guessing this system does not configure simple tax on to a final price then come up with the total in this manner?

I have attached a before and after edit order and the cart setup.

Honestly at the end of the day I am just looking for a solution that works for me.

Thanks
Title: Re: Edit Order Taxes?
Post by: AH on May 30, 2020, 13:23:32 PM
Ok - I have given you a possible fix and also tried to suggest other things relating to general VM setup.

QuoteThere is no need for VAT or Discount or any other muddled numbers that dont come to the exact conclusion of price.

These are base VM data elements they may or may not be populated - but they always show in admin.  You can do invoice and cart overrides to prevent them from showing (I certainly do for discount etc)


QuoteI would like to add a few things that seem confusing to me. Which might contribute to why this thing is not calculating correctly?

I think I have a "fix" for you - even with this fix I would still consider my observations below the fix.

So to try a fix:

in admin/models/orders.php
see this line:
`order_subtotal`=(SELECT sum(ROUND(product_item_price, '. $rounding .')*product_quantity) /*+ product_subtotal_discount*/ FROM #__virtuemart_order_items where `virtuemart_order_id`='.$ordid.'), ';

change it to

`order_subtotal`=(SELECT sum(ROUND(product_item_price, '. $rounding .')*product_quantity)+product_subtotal_discount FROM #__virtuemart_order_items where `virtuemart_order_id`='.$ordid.'), ';

Then do the order test again.



QuoteIn my world "cost" means cost of goods (which would NEVER be shown to customer) I would say it should be lower than the sales or final price???
                   "base price" ? I Have no idea why this is needed. I understand its used as currency conversion but has no use to me.
                    "final price" Well normally this is the sales price of an item where I come from.
                    "override"? ??? No idea why you need this. maybe for discounts?
                     overwrite final ? and overwrite final to be taxed? OK..


If you are tax per bill - I would suggest you just put your retail price as the "Cost price" leave everything else alone.  You will not then have all that discount stuff (if you do, then config of taxes may need looking at)

Some stores put in the cost of goods price from the supplier in this field and use VM's capability to uplift these cost prices with a "margin" to automatically calculate a Final price.

For me I never put the supplier cost of the goods in VM - the value i put in the cost price is the "net sales price" in the store (vm then calculates the final price as we use VAT tax in Europe - which is line item based and not bill total.)
I think you use tax per bill so can ignore that.


QuoteSo on the front end in products I have this set where it shows for some odd reason the base price slashed out then gives the final price under that with a nice little message saying "you save x amount"
In the backend I have my products set up with a fictitious cost price (which should be cheaper than the sales price but is not in this case) and a final price that is overwritten to be taxed?
It looks good I suppose for the customer shopping thinking that they are saving with all this showing. I am aware all of this can be hidden.

And that is not what you should be achieving - because every item looks discounted - which it is not.I would need to see a product price page and tax setup in your site to determine exactly your config, but that is my best guess so far.

QuoteMoving on to the actual cart. I have removed all of the garble... discount heading, tax heading, slashed price (cost price) and instead have the 4 simple rows that are the real sales prices and taxes and totals

Yes - you can show what is required for your country

The problem you are having currently with order edit is that (for me and not for the VM team I see a bug in the order save calculation relating to order_subtotal when there are discount items in the order)

Title: Re: Edit Order Taxes?
Post by: bpos on May 31, 2020, 02:03:39 AM
AH Thank you.

You are pretty much spot on with all of this.

The code didnt make any difference for me. BUT

I did however try another template that had pre-configured examples of products with "VAT tax per product" configured for all its items. ( I presume the correct way to configure product pricing?) I noticed that there was no row for tax per bill in the edit order.
VAT tax per product has no real function in the calculation of the final total so there is no extra calculation needed. It simply drops the subtotal down to the total.
Once I switched to "tax per bill" I then got the same tax row that I use now. I tried to "edit the order" and just re saved and the same result happened that I am currently having. It skipped right over the VAT tax per bill and used the subtotal once again.

So perhaps you are right. There is a bug in the arithmetic operation for "tax per bill"

My guess is it doesnt exist.

Pic 1 shows vat per product. There no row used for this from what I can tell?
Pic 2 show vat per bill and the row for this appears. But does nothing.

Thoughts?
Title: Re: Edit Order Taxes?
Post by: AH on May 31, 2020, 11:08:51 AM
Quote
You are pretty much spot on with all of this.

I have my moments (few and far between)

I am not sure what you mean by template and preconfigured

Unfortunately - I have never used tax per bill so am not familiar with the nuances (VAT tax per product is all I know)
Consequently I am not able to debug your issue or provide a possible solution - as this area of the system is way too complicated for me to unpick for another tax method.

Firstly - you might configure the items as I suggested -
put your net price in the cost price and let that flow through to the final price (which in your country, I believe, will be the same - as tax per bill is applied only at checkout as a bill total only and not by line item?)

I sort of remember this kind of discussion in other threads regarding tax per bill - you may be able to find some thoughts in one of the more recent ones.

Because of my lack of knowledge with tax per bill I may be sending you down a dead end - so please consider looking at other posts - you will not bet the only person using tax per bill
Title: Re: Edit Order Taxes?
Post by: bpos on May 31, 2020, 21:42:55 PM
Yep I have seen a few posts with somewhat similar issues which I did not see any solution to.

My point about the template was that I have a few joomla templates that are done by someone else and have VM added in them. The one I tried has products and pricing set as a few examples. I figure its safe to assume that me and whoever created another template couldnt both have the same problem and product pricing configured in 2 different ways?

Maybe Milbo or one of the other experts can take a peek into the calculation method on the order sheet and see if "tax per bill" is configured correctly?

Thanks
Title: Re: Edit Order Taxes?
Post by: AH on June 01, 2020, 10:47:35 AM
HI

As I think you know Templates do not create configurations - but they do often contain some "dubious" calculations to "mask" base stuff or create new stuff that may not be correct thinking

Just post the configuration of you taxes and an example product front page showing prices

Title: Re: Edit Order Taxes?
Post by: bpos on June 01, 2020, 12:18:49 PM
The only point I was making about another joomla template that had VM installed with a few product samples is that they are 2 arbitrary sites with the same problem. So a problem (or bug) exist.

So I have shown you the edit order section (pic) a few times so here is the tax setup along with the config in product BE plus product FE.

Setting up pricing with just a cost or base price doesnt solve or change anything. It still does not work for tax per bill on the orders edit page.

I did find another VM topic talking about the exact same problem but with no answer.  http://forum.virtuemart.net/index.php?topic=136852.msg497109#msg497109

The cart set up as I have it works perfectly. Its only the order edit page.

I feel pretty certain there is no tax per bill row set up on order page to actaully do calculation. 

VAT tax falls in a completely different location on the orders page and seems to calculate completely different pricing variables.(perhaps discount totals?) Not sure how VAT works....

Title: Re: Edit Order Taxes?
Post by: AH on June 01, 2020, 13:36:35 PM
Bpos

thanks for putting up the configs

I decided to do a bit more digging and actually configure tax per bill.  I found some anomalies in the database data even without touching order edit and I also noted that when doing order edit tax per bill was cleared to 0 - even though it showed in the edit view as the correct value!

Generally in configuration - what I noted:

1. In your config you have a product showing tax: 0%
2. I see the rules applied doing a 50%

I did not consider this an optimal setting, so my config was a single tax per bill - (I set mine to 10% to make my calculations simpler for my simple brain)

No other rules or taxes were configured

Due to upload restrictions the order edit images will be in the next post

Title: Re: Edit Order Taxes?
Post by: AH on June 01, 2020, 13:39:27 PM
On order reviewing a Front end order an invoice all is fine

Without touching anything (a look at the database)

orders Table
data looks fine

order items table
product_basePriceWithTax is set to 0.00 (wonder why that is not just the same as the base_price in my case as there is no tax to add at item level)


Ok now for an edit - open and save no changes
orders Table
order_billTaxAmount is get set to 0.00 from 10.00
order_Total is therefore "wrong" was 11.00 now 10.00

order items table
product_basePriceWithTax gets set to 10.00 was 0.00 (not sure if this is wrong or when the order was initially created the value was wrong)


Images below show some anomalies and the final save BUG - unsure as to whether the initial data store is also bugged and is the actual problem - but I will leave the team to sort that out

At least I have detailed what I see in a tax per bill scenario

Title: Re: Edit Order Taxes?
Post by: bpos on June 01, 2020, 21:52:39 PM
This is secondary to whats been pointed out. Probably another clue toward the problem?

I notice that once an order has been placed it does not seem that the order can be altered in any way? The only thing possible is to add another product which it will add to the total without tax.

On the order edit page open edit pic 31
Before any changes are made the order is calculated from the cart correctly

Trying to change any variable. pic32
Made a few changes to the input fields (in product price) and (taxes)

Changes to input fields not applying. pic33
Hit edit and save and all fields are returned to initial numbers before the edit? No edits worked.

Does it pick up its subtotal from the cost or base price?  Notice that once the order has been opened and saved that the subtotal has changed.
Title: Re: Edit Order Taxes?
Post by: AH on June 02, 2020, 10:28:22 AM
The ability to change an order can be linked to invoiced or not settings

The order edit with tax per bill is (to use an English term) buggered!
Title: Re: Edit Order Taxes?
Post by: bpos on June 03, 2020, 23:18:26 PM
Milbo Help!   :)
Title: Re: Edit Order Taxes?
Post by: bpos on June 08, 2020, 06:31:09 AM
So is this something that needs to be reported as a bug fix or not?

Perhaps it needs to go into another topic section?

Please advise.
I would really like to use this.
Thanks
Title: Re: Edit Order Taxes?
Post by: bpos on June 12, 2021, 21:55:11 PM
Hello. Its been quite some time since this post.

I wonder if anyone found a fix for this yet? There have been several updates but I don`t see any changes to the tax edit problem?

Thanks