In situations where three values are stored in the database, so that knowledge of any two can calculate the third, I sometimes prefer to store all three values together with an indicator, of which two are "real" and which is calculated. Three values must always be equal; if this is not the case, you should study what happens and find out why.
For example, it may be useful to store timestamps as a time zone, UTC, and local time along with an “what is known” indicator. For example, if it is found that some timestamps were recorded using the wrong time zone, the “what is known” indicator can be used to determine if UTC or local time should be adjusted.
Regarding potential rather than historical pricing information, I would think that it would be useful to store the value of exclusive VAT, the expected VAT and the price including VAT, as well as a mode flag indicating various scenarios, such as
- Price including VAT (VIP) must accurately track the VEP + VAT, to the nearest pence
- Price including VAT (VIP) must accurately track VEP + VAT to the nearest 5p
- VAT Price (VIP) must accurately track VEP + VAT to the nearest 20p-1
- Price including VAT (VIP) must accurately track VEP + VAT to the nearest 50p-1
- Price including VAT (VIP) must accurately track VEP + VAT to the nearest 100p-1
- The price including VAT should remain fixed if the VAT changes, but the IP-update of the VAT leads to the fact that the VEP + VAT exceeds the VIP, the record should be marked to suggest that someone will think about increasing the VIP.
In principle, find out what should happen if the VAT changes and is adjusted accordingly.
supercat
source share