Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: To auto-calc or not auto-calc

by jhourcle (Prior)
on Jul 21, 2005 at 13:35 UTC ( #476822=note: print w/replies, xml ) Need Help??

in reply to To auto-calc or not auto-calc

It's actually a deeper question as to data normalization--

Some stuff seems redundant, as it can be calculated, but that assumes that the data never gets modified once it's been created, and that there are no special exceptions.

For someone who just wants something quick to sell something online, and doesn't care about historical trends and such, calculating on the fly is probably just fine ... But you have to understand that you can never look back up an old invoice in the system.

The auto-calculating situation you've described also doesn't allow for item bulk discounts (especially for the complex ones, where it's not just a total percentage off, but the first 1-20 items are full price, but there's a reduction on the 21-100 items, and a further discount on 101+)

Even the order total may not just be a straight sum -- maybe there's a discount if you order more than $100 (or whatever currency you're dealing in).

I'm all for the calculating it at the time the order, and writing out all of the values, rather than attempting to re-calculate the invoice on what may be different info (price changes, even item description changes, etc.). It's not efficient in terms of size, but it is efficient for speed, and I find it to be more useful in the long term.

As for 'correct' -- no one way is more 'correct' than the other other. You have to decide what your requirements and constraints are for the project, and make the decisions based on that. One way is easier to code, and takes much less space to store; the other way will take you longer to write, but gives extra functionality that may (or may not) be useful in the situations your program is going to be used.

Replies are listed 'Best First'.
Re^2: To auto-calc or not auto-calc
by jk2addict (Chaplain) on Jul 21, 2005 at 18:47 UTC

    And therein lays the problem. I can't come to grips with either side of that fence.

    It makes sencs to autocal subtotal and items total if I'm creating an order from a cart. From there on out I guess it's safe to just let people change price/quantity and leave the calculation for subtotal and total up to them instead of doing it for them like we would in the cart.

    It's more work, but more flexibility because as you point out, all bets are off in the order when it comes to totals and possible "new math" involved in discounts.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://476822]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2022-05-26 18:08 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (93 votes). Check out past polls.