text: -- /packages/intranet-cost/sql/postgresql/intranet-price-list-create.sql
  --
  -- ]project-open[ "Costs" Financial Base Module
  -- Copyright (C) 2004 - 2009 ]project-open[
  --
  -- All rights including reserved. To inquire license terms please 
  -- refer to http://www.project-open.com/modules/<module-key>
  
  
  -------------------------------------------------------------
  -- Price List
  --
  -- Several objects expose a changing price over time,
  -- such as employees (salary), rent, aDSL line etc.
  -- However, we don't want to modify the price for
  -- every month when generating monthly costs,
  -- so it may be better to record the changing price
  -- over time.
  -- This object determines the price for an object
  -- based on a start_date - end_date range.
  -- End_date is kind of redundant, because it could
  -- be deduced from the start_date of the next cost,
  -- but that way we would need a max(...) query to
  -- determine a current price which might be very slow.
  --
  create table im_prices (
  	object_id		integer
  				constraint im_prices_object_fk
  				references acs_objects,
  	attribute		text
  				constraint im_prices_attribute_nn
  				not null,
  	start_date		timestamptz,
  	end_date		timestamptz default '2099-12-31',
  	amount			numeric(12,3),
  	currency		char(3)
  				constraint im_prices_currency_fk
  				references currency_codes(iso),
  		primary key (object_id, attribute, currency)
  );
  
  alter table im_prices
  add constraint im_prices_start_end_ck
  check(start_date < end_date);
  