For a semi-offtopic question, I hope I don't get burned. This is written in mod_perl though so maybe it counts. Anyway, I work for a company that provides hosted online store software for a niche market. Each retailer is in charge of setting up their store through our web interface. One of the things they do is input tax rates for various states they are required to collect taxes for. They also get to input products and specify whether the product is taxable (there is no way to differentiate whether the product is taxable in some states but not others).
This is an old system written by someone with no sense of logic, so please bear with me.
Now, the problem is coming when I am trying to calculate tax in conjunction with promotions. Retailers can set up promotions such as, "Spend $50.00 and get $5.00 off your order," "Spend $50.00 and get 10% off your order," or "Spend $50.00 and shipping is free."
($50.00 is arbitrary, it can be anything)
The problem comes when trying to calculate tax for this. If the customer orders 3 items for a total of $50.00, and only two of them are taxable, taking a percentage is certainly possible (take 10% off the taxable subtotal and 10% off the non-taxable subtotal, add them together, and you get your promotion amount). Now what if they get $5.00 off their order? Should I calculate a ratio and divide the $5.00 between the taxable and non-taxable? Should I apply it to taxable so they get a better deal? What if the amount is over the taxable, then just apply the rest to the non-taxable portion? The logic gets convoluted.
Currently, the system works like this (written by the old programmer):
- Calculate the subtotal (all items, taxable + nontaxable).
- Calculate only the taxable subtotal.
- Calculate tax to the taxable subtotal.
- Calculate shipping.
- Add subotal + tax + shipping to get "grand total"
- Calculate the discount amount (using the grand total - so if they had $48.00 worth of items and $2.00 tax they would receive the "spend $50.00 and get XX promotion" deal)
- Subtract the discount amount from the grand total, and now you have the "real" grand total
This seems wrong to me. It seems like we are charging more tax than we should and we are also giving people discounts who don't "really" qualify. Anyone else have any experience with this?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.