Dumped on 2005-03-22

Index of database - koumbit


Table: acc_trans

acc_trans Structure
F-Key Name Type Description
trans_id integer
chart_id integer
amount double precision
transdate date DEFAULT ('now'::text)::date
source text
cleared boolean DEFAULT false
fx_transaction boolean DEFAULT false
project_id integer
memo text

Index - Schema public


Table: ap

ap Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
invnumber text
transdate date DEFAULT ('now'::text)::date
vendor_id integer
taxincluded boolean DEFAULT false
amount double precision
netamount double precision
paid double precision
datepaid date
duedate date
invoice boolean DEFAULT false
ordnumber text
curr character(3)
notes text
employee_id integer
till character varying(20)
quonumber text
intnotes text
department_id integer
shipvia text
language_code character varying(6)

Index - Schema public


Table: ar

ar Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
invnumber text
transdate date DEFAULT ('now'::text)::date
customer_id integer
taxincluded boolean
amount double precision
netamount double precision
paid double precision
datepaid date
duedate date
invoice boolean DEFAULT false
shippingpoint text
terms smallint
notes text
curr character(3)
ordnumber text
employee_id integer
till character varying(20)
quonumber text
intnotes text
department_id integer
shipvia text
language_code character varying(6)

Index - Schema public


Table: assembly

assembly Structure
F-Key Name Type Description
id integer
parts_id integer
qty double precision
bom boolean
adj boolean

Index - Schema public


Table: audittrail

audittrail Structure
F-Key Name Type Description
trans_id integer
tablename text
reference text
formname text
action text
transdate timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone
employee_id integer

Index - Schema public


Table: business

business Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
description text
discount real

Index - Schema public


Table: chart

chart Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
accno text NOT NULL
description text
charttype character(1) DEFAULT 'A'::bpchar
category character(1)
link text
gifi_accno text

Index - Schema public


Table: customer

customer Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
name character varying(64)
address1 character varying(32)
address2 character varying(32)
city character varying(32)
state character varying(32)
zipcode character varying(10)
country character varying(32)
contact character varying(64)
phone character varying(20)
fax character varying(20)
email text
notes text
discount real
taxincluded boolean DEFAULT false
creditlimit double precision
terms smallint
customernumber character varying(32)
cc text
bcc text
business_id integer
taxnumber character varying(32)
sic_code character varying(6)
iban character varying(34)
bic character varying(11)
employee_id integer
language_code character varying(6)
pricegroup_id integer
curr character(3)
startdate date
enddate date

Index - Schema public


Table: customertax

customertax Structure
F-Key Name Type Description
customer_id integer
chart_id integer

Index - Schema public


Table: defaults

defaults Structure
F-Key Name Type Description
inventory_accno_id integer
income_accno_id integer
expense_accno_id integer
fxgain_accno_id integer
fxloss_accno_id integer
sinumber text
sonumber text
yearend character varying(5)
weightunit character varying(5)
businessnumber text
version character varying(8)
curr text
closedto date
revtrans boolean DEFAULT false
ponumber text
sqnumber text
rfqnumber text
audittrail boolean DEFAULT false
vinumber text
employeenumber text
partnumber text
customernumber text
vendornumber text

Index - Schema public


Table: department

department Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
description text
role character(1) DEFAULT 'P'::bpchar

Index - Schema public


Table: dpt_trans

dpt_trans Structure
F-Key Name Type Description
trans_id integer
department_id integer

Index - Schema public


Table: employee

employee Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
login text
name character varying(64)
address1 character varying(32)
address2 character varying(32)
city character varying(32)
state character varying(32)
zipcode character varying(10)
country character varying(32)
workphone character varying(20)
homephone character varying(20)
startdate date DEFAULT ('now'::text)::date
enddate date
notes text
role character varying(20)
sales boolean DEFAULT false
email text
ssn character varying(20)
iban character varying(34)
bic character varying(11)
managerid integer
employeenumber character varying(32)
dob date

Index - Schema public


Table: exchangerate

exchangerate Structure
F-Key Name Type Description
curr character(3)
transdate date
buy double precision
sell double precision

Index - Schema public


Table: gifi

gifi Structure
F-Key Name Type Description
accno text
description text

Index - Schema public


Table: gl

gl Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
reference text
description text
transdate date DEFAULT ('now'::text)::date
employee_id integer
notes text
department_id integer

Index - Schema public


Table: inventory

inventory Structure
F-Key Name Type Description
warehouse_id integer
parts_id integer
oe_id integer
orderitems_id integer
qty real
shippingdate date
employee_id integer

Index - Schema public


Table: invoice

invoice Structure
F-Key Name Type Description
id integer DEFAULT nextval('invoiceid'::text)
trans_id integer
parts_id integer
description text
qty real
allocated real
sellprice double precision
fxsellprice double precision
discount real
assemblyitem boolean DEFAULT false
unit character varying(5)
project_id integer
deliverydate date
serialnumber text

Index - Schema public


Table: language

language Structure
F-Key Name Type Description
code character varying(6)
description text

Index - Schema public


Table: makemodel

makemodel Structure
F-Key Name Type Description
parts_id integer
make text
model text

Index - Schema public


Table: oe

oe Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
ordnumber text
transdate date DEFAULT ('now'::text)::date
vendor_id integer
customer_id integer
amount double precision
netamount double precision
reqdate date
taxincluded boolean
shippingpoint text
notes text
curr character(3)
employee_id integer
closed boolean DEFAULT false
quotation boolean DEFAULT false
quonumber text
intnotes text
department_id integer
shipvia text
language_code character varying(6)

Index - Schema public


Table: orderitems

orderitems Structure
F-Key Name Type Description
trans_id integer
parts_id integer
description text
qty real
sellprice double precision
discount real
unit character varying(5)
project_id integer
reqdate date
ship real
serialnumber text
id integer DEFAULT nextval('orderitemsid'::text)

Index - Schema public


Table: parts

parts Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
partnumber text
description text
unit character varying(5)
listprice double precision
sellprice double precision
lastcost double precision
priceupdate date DEFAULT ('now'::text)::date
weight real
onhand real
notes text
makemodel boolean DEFAULT false
assembly boolean DEFAULT false
alternate boolean DEFAULT false
rop real
inventory_accno_id integer
income_accno_id integer
expense_accno_id integer
bin text
obsolete boolean DEFAULT false
bom boolean DEFAULT false
image text
drawing text
microfiche text
partsgroup_id integer

Index - Schema public


Table: partscustomer

partscustomer Structure
F-Key Name Type Description
parts_id integer
customer_id integer
pricegroup_id integer
pricebreak real
sellprice double precision
validfrom date
validto date
curr character(3)

Index - Schema public


Table: partsgroup

partsgroup Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
partsgroup text

Index - Schema public


Table: partstax

partstax Structure
F-Key Name Type Description
parts_id integer
chart_id integer

Index - Schema public


Table: partsvendor

partsvendor Structure
F-Key Name Type Description
vendor_id integer
parts_id integer
partnumber text
leadtime smallint
lastcost double precision
curr character(3)

Index - Schema public


Table: pricegroup

pricegroup Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
pricegroup text

Index - Schema public


Table: project

project Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
projectnumber text
description text

Index - Schema public


Table: shipto

shipto Structure
F-Key Name Type Description
trans_id integer
shiptoname character varying(64)
shiptoaddress1 character varying(32)
shiptoaddress2 character varying(32)
shiptocity character varying(32)
shiptostate character varying(32)
shiptozipcode character varying(10)
shiptocountry character varying(32)
shiptocontact character varying(64)
shiptophone character varying(20)
shiptofax character varying(20)
shiptoemail text

Index - Schema public


Table: sic

sic Structure
F-Key Name Type Description
code character varying(6)
sictype character(1)
description text

Index - Schema public


Table: status

status Structure
F-Key Name Type Description
trans_id integer
formname text
printed boolean DEFAULT false
emailed boolean DEFAULT false
spoolfile text
chart_id integer

Index - Schema public


Table: tax

tax Structure
F-Key Name Type Description
chart_id integer
rate double precision
taxnumber text

Index - Schema public


Table: translation

translation Structure
F-Key Name Type Description
trans_id integer
language_code character varying(6)
description text

Index - Schema public


Table: vendor

vendor Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
name character varying(64)
address1 character varying(32)
address2 character varying(32)
city character varying(32)
state character varying(32)
zipcode character varying(10)
country character varying(32)
contact character varying(64)
phone character varying(20)
fax character varying(20)
email text
notes text
terms smallint
taxincluded boolean DEFAULT false
vendornumber character varying(32)
cc text
bcc text
gifi_accno character varying(30)
business_id integer
taxnumber character varying(32)
sic_code character varying(6)
discount real
creditlimit double precision
iban character varying(34)
bic character varying(11)
employee_id integer
language_code character varying(6)
pricegroup_id integer
curr character(3)
startdate date
enddate date

Index - Schema public


Table: vendortax

vendortax Structure
F-Key Name Type Description
vendor_id integer
chart_id integer

Index - Schema public


Table: warehouse

warehouse Structure
F-Key Name Type Description
id integer DEFAULT nextval('id'::text)
description text

Index - Schema public


Table: yearend

yearend Structure
F-Key Name Type Description
trans_id integer
transdate date

Index - Schema public


Function: check_department( )

Returns: "trigger"

Language: PLPGSQL

declare
  dpt_id int;
begin
  if new.department_id = 0 then
    delete from dpt_trans where trans_id = new.id;
    return NULL;
  end if;
  select into dpt_id trans_id from dpt_trans where trans_id = new.id;
  if dpt_id > 0 then
    update dpt_trans set department_id = new.department_id where trans_id = dpt_id;
  else
    insert into dpt_trans (trans_id, department_id) values (new.id, new.department_id);
  end if;
return NULL;
end;

Function: check_inventory( )

Returns: "trigger"

Language: PLPGSQL

declare
  itemid int;
  row_data inventory%rowtype;
begin
  if not old.quotation then
    for row_data in select * from inventory where oe_id = old.id loop
      select into itemid id from orderitems where trans_id = old.id and id = row_data.orderitems_id;
      if itemid is null then
	delete from inventory where oe_id = old.id and orderitems_id = row_data.orderitems_id;
      end if;
    end loop;
  end if;
  return old;
end;

Function: del_customer( )

Returns: "trigger"

Language: PLPGSQL

begin
  delete from shipto where trans_id = old.id;
  delete from customertax where customer_id = old.id;
  delete from partscustomer where customer_id = old.id;
  return NULL;
end;

Function: del_department( )

Returns: "trigger"

Language: PLPGSQL

begin
  delete from dpt_trans where trans_id = old.id;
  return NULL;
end;

Function: del_exchangerate( )

Returns: "trigger"

Language: PLPGSQL

declare
  t_transdate date;
  t_curr char(3);
  t_id int;
  d_curr text;
begin
  select into d_curr substr(curr,1,3) from defaults;
  if TG_RELNAME = 'ar' then
    select into t_curr, t_transdate curr, transdate from ar where id = old.id;
  end if;
  if TG_RELNAME = 'ap' then
    select into t_curr, t_transdate curr, transdate from ap where id = old.id;
  end if;
  if TG_RELNAME = 'oe' then
    select into t_curr, t_transdate curr, transdate from oe where id = old.id;
  end if;
  if d_curr != t_curr then
    select into t_id a.id from acc_trans ac
    join ar a on (a.id = ac.trans_id)
    where a.curr = t_curr
    and ac.transdate = t_transdate
    except select a.id from ar a where a.id = old.id
    union
    select a.id from acc_trans ac
    join ap a on (a.id = ac.trans_id)
    where a.curr = t_curr
    and ac.transdate = t_transdate
    except select a.id from ap a where a.id = old.id
    union
    select o.id from oe o
    where o.curr = t_curr
    and o.transdate = t_transdate
    except select o.id from oe o where o.id = old.id;
    if not found then
      delete from exchangerate where curr = t_curr and transdate = t_transdate;
    end if;
  end if;
return old;
end;

Function: del_vendor( )

Returns: "trigger"

Language: PLPGSQL

begin
  delete from shipto where trans_id = old.id;
  delete from vendortax where vendor_id = old.id;
  delete from partsvendor where vendor_id = old.id;
  return NULL;
end;

Function: del_yearend( )

Returns: "trigger"

Language: PLPGSQL

begin
  delete from yearend where trans_id = old.id;
  return NULL;
end;

Generated by PostgreSQL Autodoc

W3C HTML 4.01 Strict