Taxes per order not stored in database

Project: 
Ubercart
Category: 
bug report
Priority: 
critical
Status: 
active

The only way to calculate taxes collected for remittances to the government is to go through every order in a month and run the function that calculates the taxes on it.

Additionally, if the tax rate is changed then the invoice will not be historically correct anymore?

Taxes need to be added as line items perhaps once the order is completed?

Or do we add more tax rules that are date based, so each time a tax changes the appropriate rule for the date of the order is used?

Perhaps the tax rules need to have their own table that is associated to an order?

Gord.

+1 It's really critical for

+1

It's really critical for accounting that the actual amounts received for each order are stored with the order. I haven't checked the tables, but other things that are vital for accounting are the actual ship date and the actual receipt date for the payment(s) - not just the order date! This is true whether you use cash or accrual accounting. Even if there is no Ubercart accounting module and accounting is supported just by export to QuickBooks etc., it is absolutely essential that the needed information is stored! Also, a field for actual shipping amount paid by the business to ship the order and the actual date shipped, because these will be needed for accounting too when shipping (not just shipping quotes) is fully integrated. (maybe this is added by the shipping module)

Generally, every cent (or should that be uc_currency_format('cent')? Smiling) that is received or paid via Ubercart needs to be recorded with its associated transaction.

re: Taxes

Gord, I agree...this could lead to some rather large problems when dealing with adding, removing, or altering taxes in any way. Any adjustments to state or local taxes, or even something like the tax free holidays that some states offer could require you to make these changes.

I'd rather see these values stored per order during the checkout process as opposed to being date based rules. The date based rules would still leave you with the problem of needing to re-calculate each time and would leave more room for inconsistencies between what was actually paid and what is later reported.

Would there be large problems trying to tie taxes in with line items?

Re: Taxes per order not stored in database

Why doesn't the tax amount for an order get stored in the uc_order_line_items table with a type of 'tax' and the title of the tax method used?

Re: Re: Taxes per order not stored in database

I think it's due to the line items API having to differentiate between calculated line items (like a tax which has to be calculated each time in case a country, zone, product type, etc. changes) and a stored line item like a shipping fee. I'm open to discussion on how to improve the line item API, but basically we're looking at either leaving it like it is or making sure sales people remember to recalculate taxes when they make a change to an order.

Re: Re: Re: Taxes per order not stored in database

Can't there be a trigger to recalculate the tax when a change to an order is made?

Re: Re: Re: Re: Taxes per order not stored in database

I was thinking the same thing as I was typing it. Similarly, it could check the order status before recalculating the tax and not do it if the order status is in the completed state.

Re: Re: Re: Re: Re: Taxes per order not stored in database

That would be ideal, then it would be a simple group by statement and sum to calculate taxes.
Keep in mind though that it would be quite useful to store what the tax was at the time of calculation.
Eg: Order is placed when the tax was 6%, the next day the store owner processes it after adding/removing an item from the order. The new tax rate of 7% would apply even though the customer ordered before then.

It is an edge case issue, being able to manually set the tax after calculation would be a potential work around...

Gord.

Re: Re: Re: Re: Re: Re: Taxes per order not stored in database

I've made it so that the amount of tax that is charged to an order is recorded in the order log. Any changes that affect the tax amount will be reflected there as well, so everything should be traceable now.

Re: Re: Re: Re: Re: Re: Re: Taxes per order not stored in databa