Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To use calculated field or not?
Message
From
14/01/2012 17:35:05
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01532936
Message ID:
01532951
Views:
65
>Hi,
>
>I am looking for suggestions of better practice when using or not using a Calculated field. Let me describe on an example what I mean by Calculated field (perhaps this is not quite the right term).
>
>Purchase Order and Invoice System. There is a P.O. table (vendor, date, amount, etc.). and P.O. Invoice table. Invoice table is a child table where there could be several records for each P.O. Each P.O. Invoice record has Freight and Sales Tax amount. I need to show on the P.O. Master view the total amount of Freight and Sales tax paid against the P.O. So one approach is to add fields FREIGHT and SALES_TAX to the P.O. Master table and update it on every entry in the Invoice posting. Another approach is to NOT to have these fields in the P.O. Master table but to calculate the total amount on-the-fly. That is, call a method/function that gets all invoices of the P.O. and calculates the total amounts.
>
>Which of the two approaches is better practice, in your opinion. TIA.

Hi,

I would say it depends on. If salestax is a constant I would put it in a separate table and thus calculate if freight is a costfactor meaning it can vary per product (more volume more freight, less weight lesser freight short distance lesser freight etc etc ) I would put it in a fixed field and not calculate. Provided of course that the freight amount itselve you dont have to calculate as when in that case it would require a separate table and a calculation on the fly in that table.

Hope I did not confuse you.

Regards,

Koen
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform