summaryrefslogtreecommitdiff
path: root/sql/Pg-database.sql
blob: e9b295df2f18b119d60482a4b64a3eff3a30fd78 (plain)
  1. begin;
  2. --
  3. CREATE TABLE transactions (
  4. id int PRIMARY KEY,
  5. table_name text
  6. );
  7. -- BEGIN new entity management
  8. CREATE TABLE entity (
  9. id serial PRIMARY KEY,
  10. name text check (name ~ '[[:alnum:]_]'),
  11. entity_class integer not null,
  12. created date not null default current_date);
  13. CREATE UNIQUE INDEX entity_class_name_class_idx ON entity(name,entity_class);
  14. COMMENT ON TABLE entity IS $$ The primary entity table to map to all contacts $$;
  15. COMMENT ON COLUMN entity.name IS $$ This is the common name of an entity. If it was a person it may be Joshua Drake, a company Acme Corp. You may also choose to use a domain such as commandprompt.com $$;
  16. CREATE TABLE entity_class (
  17. id serial primary key,
  18. class text check (class ~ '[[:alnum:]_]') NOT NULL,
  19. active boolean not null default TRUE);
  20. COMMENT ON TABLE entity_class IS $$ Defines the class type such as vendor, customer, contact, employee $$;
  21. COMMENT ON COLUMN entity_class.id IS $$ The first 7 values are reserved and permanent $$;
  22. CREATE index entity_class_idx ON entity_class(lower(class));
  23. ALTER TABLE entity ADD FOREIGN KEY (entity_class) REFERENCES entity_class(id);
  24. INSERT INTO entity_class (id,class) VALUES (1,'Vendor');
  25. INSERT INTO entity_class (id,class) VALUES (2,'Customer');
  26. INSERT INTO entity_class (id,class) VALUES (3,'Employee');
  27. INSERT INTO entity_class (id,class) VALUES (4,'Contact');
  28. INSERT INTO entity_class (id,class) VALUES (5,'Lead');
  29. INSERT INTO entity_class (id,class) VALUES (6,'Referral');
  30. SELECT setval('entity_class_id_seq',7);
  31. CREATE TABLE entity_class_to_entity (
  32. entity_class_id integer not null references entity_class(id),
  33. entity_id integer not null references entity(id),
  34. PRIMARY KEY(entity_class_id,entity_id)
  35. );
  36. COMMENT ON TABLE entity_class_to_entity IS $$ Relation builder for classes to entity $$;
  37. CREATE TABLE country (
  38. id serial PRIMARY KEY,
  39. name text check (name ~ '[[:alnum:]_]') NOT NULL,
  40. short_name text check (short_name ~ '[[:alnum:]_]') NOT NULL,
  41. itu text);
  42. COMMENT ON COLUMN country.itu IS $$ The ITU Telecommunication Standardization Sector code for calling internationally. For example, the US is 1, Great Britain is 44 $$;
  43. CREATE UNIQUE INDEX country_name_idx on country(lower(name));
  44. CREATE TABLE location_class (
  45. id serial UNIQUE,
  46. class text check (class ~ '[[:alnum:]_]') not null,
  47. authoritative boolean not null,
  48. PRIMARY KEY (class,authoritative));
  49. CREATE UNIQUE INDEX lower_class_unique ON location_class(lower(class));
  50. INSERT INTO location_class(id,class,authoritative) VALUES ('1','Billing',TRUE);
  51. INSERT INTO location_class(id,class,authoritative) VALUES ('2','Sales',TRUE);
  52. INSERT INTO location_class(id,class,authoritative) VALUES ('3','Shipping',TRUE);
  53. SELECT SETVAL('location_class_id_seq',4);
  54. CREATE TABLE location (
  55. id serial PRIMARY KEY,
  56. location_class integer not null references location(id),
  57. line_one text check (line_one ~ '[[:alnum:]_]') NOT NULL,
  58. line_two text,
  59. line_three text,
  60. city_province text check (city_province ~ '[[:alnum:]_]') NOT NULL,
  61. country_id integer not null REFERENCES country(id),
  62. mail_code text not null check (mail_code ~ '[[:alnum:]_]'),
  63. created date not null,
  64. inactive_date timestamp default null,
  65. active boolean not null default TRUE
  66. );
  67. CREATE INDEX location_unique_class_idx ON location (id,location_class);
  68. CREATE TABLE company (
  69. id serial UNIQUE,
  70. entity_id integer not null references entity(id),
  71. legal_name text check (legal_name ~ '[[:alnum:]_]'),
  72. tax_id text,
  73. created date default current_date not null,
  74. PRIMARY KEY (entity_id,legal_name));
  75. COMMENT ON COLUMN company.tax_id IS $$ In the US this would be a EIN. $$;
  76. CREATE TABLE company_to_location (
  77. location_id integer references location(id) not null,
  78. company_id integer references company(id) not null,
  79. PRIMARY KEY(location_id,company_id));
  80. CREATE TABLE salutation (
  81. id serial unique,
  82. salutation text primary key);
  83. INSERT INTO salutation (id,salutation) VALUES ('1','Dr.');
  84. INSERT INTO salutation (id,salutation) VALUES ('2','Miss.');
  85. INSERT INTO salutation (id,salutation) VALUES ('3','Mr.');
  86. INSERT INTO salutation (id,salutation) VALUES ('4','Mrs.');
  87. INSERT INTO salutation (id,salutation) VALUES ('5','Ms.');
  88. INSERT INTO salutation (id,salutation) VALUES ('6','Sir.');
  89. SELECT SETVAL('salutation_id_seq',7);
  90. CREATE TABLE person (
  91. id serial PRIMARY KEY,
  92. entity_id integer references entity(id) not null,
  93. salutation_id integer references salutation(id),
  94. first_name text check (first_name ~ '[[:alnum:]_]') NOT NULL,
  95. middle_name text,
  96. last_name text check (last_name ~ '[[:alnum:]_]') NOT NULL,
  97. created date not null default current_date
  98. );
  99. COMMENT ON TABLE person IS $$ Every person, must have an entity to derive a common or display name. The correct way to get class information on a person would be person.entity_id->entity_class_to_entity.entity_id. $$;
  100. CREATE TABLE person_to_location (
  101. location_id integer not null references location(id),
  102. person_id integer not null references person(id),
  103. PRIMARY KEY (location_id,person_id));
  104. CREATE TABLE person_to_company (
  105. location_id integer references location(id) not null,
  106. person_id integer references person(id) not null,
  107. PRIMARY KEY (location_id,person_id));
  108. CREATE TABLE entity_other_name (
  109. entity_id integer not null references entity(id),
  110. other_name text check (other_name ~ '[[:alnum:]_]'),
  111. PRIMARY KEY (other_name, entity_id));
  112. COMMENT ON TABLE entity_other_name IS $$ Similar to company_other_name, a person may be jd, Joshua Drake, linuxpoet... all are the same person. $$;
  113. CREATE TABLE person_to_entity (
  114. person_id integer not null references person(id),
  115. entity_id integer not null references entity(id) check (entity_id != person_id),
  116. related_how text,
  117. created date not null default current_date,
  118. PRIMARY KEY (person_id,entity_id));
  119. CREATE TABLE company_to_entity (
  120. company_id integer not null references company(id),
  121. entity_id integer not null references entity(id) check (entity_id != company_id),
  122. related_how text,
  123. created date not null default current_date,
  124. PRIMARY KEY (company_id,entity_id));
  125. CREATE TABLE contact_class (
  126. id serial UNIQUE,
  127. class text check (class ~ '[[:alnum:]_]') NOT NULL,
  128. PRIMARY KEY (class));
  129. CREATE UNIQUE INDEX contact_class_class_idx ON contact_class(lower(class));
  130. INSERT INTO contact_class (id,class) values (1,'Primary Phone');
  131. INSERT INTO contact_class (id,class) values (2,'Secondary Phone');
  132. INSERT INTO contact_class (id,class) values (3,'Cell Phone');
  133. INSERT INTO contact_class (id,class) values (4,'AIM');
  134. INSERT INTO contact_class (id,class) values (5,'Yahoo');
  135. INSERT INTO contact_class (id,class) values (6,'Gtalk');
  136. INSERT INTO contact_class (id,class) values (7,'MSN');
  137. INSERT INTO contact_class (id,class) values (8,'IRC');
  138. INSERT INTO contact_class (id,class) values (9,'Fax');
  139. INSERT INTO contact_class (id,class) values (10,'Generic Jabber');
  140. INSERT INTO contact_class (id,class) values (11,'Home Phone');
  141. SELECT SETVAL('contact_class_id_seq',12);
  142. CREATE TABLE person_to_contact (
  143. person_id integer references person(id) not null,
  144. contact_class_id integer references contact_class(id) not null,
  145. contact text check(contact ~ '[[:alnum:]_]') not null,
  146. PRIMARY KEY (person_id,contact_class_id,contact));
  147. COMMENT ON TABLE person_to_contact IS $$ To keep track of the relationship between multiple contact methods and a single individual $$;
  148. CREATE TABLE company_to_contact (
  149. company_id integer references company(id) not null,
  150. contact_class_id integer references contact_class(id) not null,
  151. contact text check(contact ~ '[[:alnum:]_]') not null,
  152. PRIMARY KEY (company_id,contact_class_id,contact));
  153. COMMENT ON TABLE company_to_contact IS $$ To keep track of the relationship between multiple contact methods and a single company $$;
  154. -- Begin rocking notes interface
  155. CREATE TABLE note_class(id serial primary key, class text not null check (class ~ '[[:alnum:]_]'));
  156. INSERT INTO note_class(id,class) VALUES (1,'Entity');
  157. INSERT INTO note_class(id,class) VALUES (2,'Invoice');
  158. CREATE UNIQUE INDEX note_class_idx ON note_class(lower(class));
  159. CREATE TABLE note (id serial primary key, note_class integer not null references note_class(id),
  160. note text not null, vector tsvector not null,
  161. created timestamp not null default now(),
  162. ref_key integer not null);
  163. CREATE TABLE entity_note() INHERITS (note);
  164. ALTER TABLE entity_note ADD CHECK (id = 1);
  165. ALTER TABLE entity_note ADD FOREIGN KEY (ref_key) REFERENCES entity(id);
  166. CREATE INDEX entity_note_id_idx ON entity_note(id);
  167. CREATE UNIQUE INDEX entity_note_class_idx ON note_class(lower(class));
  168. CREATE INDEX entity_note_vectors_idx ON entity_note USING gist(vector);
  169. CREATE TABLE invoice_note() INHERITS (note);
  170. CREATE INDEX invoice_note_id_idx ON invoice_note(id);
  171. CREATE UNIQUE INDEX invoice_note_class_idx ON note_class(lower(class));
  172. CREATE INDEX invoice_note_vectors_idx ON invoice_note USING gist(vector);
  173. ALTER TABLE invoice_note ADD CHECK (id = 2);
  174. -- END entity
  175. --
  176. CREATE TABLE makemodel (
  177. parts_id int PRIMARY KEY,
  178. make text,
  179. model text
  180. );
  181. --
  182. CREATE TABLE gl (
  183. id serial PRIMARY KEY,
  184. reference text,
  185. description text,
  186. transdate date DEFAULT current_date,
  187. person_id integer references person(id),
  188. notes text,
  189. approved bool default true,
  190. department_id int default 0
  191. );
  192. --
  193. CREATE TABLE chart (
  194. id serial PRIMARY KEY,
  195. accno text NOT NULL,
  196. description text,
  197. charttype char(1) DEFAULT 'A',
  198. category char(1),
  199. link text,
  200. gifi_accno text,
  201. contra bool DEFAULT 'f'
  202. );
  203. --
  204. CREATE TABLE gifi (
  205. accno text PRIMARY KEY,
  206. description text
  207. );
  208. --
  209. CREATE TABLE defaults (
  210. setting_key text primary key,
  211. value text
  212. );
  213. /*
  214. inventory_accno_id int,
  215. income_accno_id int,
  216. expense_accno_id int,
  217. fxgain_accno_id int,
  218. fxloss_accno_id int,
  219. */
  220. \COPY defaults FROM stdin WITH DELIMITER |
  221. sinumber|1
  222. sonumber|1
  223. yearend|1
  224. businessnumber|1
  225. version|1.2.0
  226. closedto|\N
  227. revtrans|1
  228. ponumber|1
  229. sqnumber|1
  230. rfqnumber|1
  231. audittrail|0
  232. vinumber|1
  233. employeenumber|1
  234. partnumber|1
  235. customernumber|1
  236. vendornumber|1
  237. glnumber|1
  238. projectnumber|1
  239. \.
  240. -- */
  241. CREATE TABLE acc_trans (
  242. trans_id int,
  243. chart_id int NOT NULL REFERENCES chart (id),
  244. amount NUMERIC,
  245. transdate date DEFAULT current_date,
  246. source text,
  247. cleared bool DEFAULT 'f',
  248. fx_transaction bool DEFAULT 'f',
  249. project_id int,
  250. memo text,
  251. invoice_id int,
  252. approved bool default true,
  253. entry_id SERIAL PRIMARY KEY
  254. );
  255. --
  256. CREATE TABLE invoice (
  257. id serial PRIMARY KEY,
  258. trans_id int,
  259. parts_id int,
  260. description text,
  261. qty integer,
  262. allocated integer,
  263. sellprice NUMERIC,
  264. fxsellprice NUMERIC,
  265. discount float4, -- jd: check into this
  266. assemblyitem bool DEFAULT 'f',
  267. unit varchar(5),
  268. project_id int,
  269. deliverydate date,
  270. serialnumber text,
  271. notes text
  272. );
  273. -- Added for Entity but can't be added due to order
  274. ALTER TABLE invoice_note ADD FOREIGN KEY (ref_key) REFERENCES invoice(id);
  275. --
  276. --
  277. CREATE TABLE customer (
  278. id serial PRIMARY KEY,
  279. entity_id int references entity(id),
  280. discount numeric,
  281. taxincluded bool default 'f',
  282. creditlimit NUMERIC default 0,
  283. terms int2 default 0,
  284. customernumber varchar(32),
  285. cc text,
  286. bcc text,
  287. business_id int,
  288. invoice_notes text,
  289. sic_code varchar(6),
  290. iban varchar(34),
  291. bic varchar(11),
  292. language_code varchar(6),
  293. pricegroup_id int,
  294. curr char(3),
  295. startdate date DEFAULT CURRENT_DATE,
  296. enddate date
  297. );
  298. COMMENT ON TABLE customer IS $$ This is now a metadata table that holds information specific to customers. Source info is not part of the entity management $$;
  299. COMMENT ON COLUMN customer.entity_id IS $$ This is the relationship between entities and customers $$;
  300. --
  301. --
  302. CREATE TABLE parts (
  303. id serial PRIMARY KEY,
  304. partnumber text,
  305. description text,
  306. unit varchar(5),
  307. listprice NUMERIC,
  308. sellprice NUMERIC,
  309. lastcost NUMERIC,
  310. priceupdate date DEFAULT current_date,
  311. weight numeric,
  312. onhand numeric DEFAULT 0,
  313. notes text,
  314. makemodel bool DEFAULT 'f',
  315. assembly bool DEFAULT 'f',
  316. alternate bool DEFAULT 'f',
  317. rop float4, -- jd: what is this
  318. inventory_accno_id int,
  319. income_accno_id int,
  320. expense_accno_id int,
  321. bin text,
  322. obsolete bool DEFAULT 'f',
  323. bom bool DEFAULT 'f',
  324. image text,
  325. drawing text,
  326. microfiche text,
  327. partsgroup_id int,
  328. project_id int,
  329. avgcost NUMERIC
  330. );
  331. --
  332. CREATE TABLE assembly (
  333. id int,
  334. parts_id int,
  335. qty numeric,
  336. bom bool,
  337. adj bool,
  338. PRIMARY KEY (id, parts_id)
  339. );
  340. --
  341. CREATE TABLE ar (
  342. id serial PRIMARY KEY,
  343. invnumber text,
  344. transdate date DEFAULT current_date,
  345. entity_id int REFERENCES entity(id),
  346. taxincluded bool,
  347. amount NUMERIC,
  348. netamount NUMERIC,
  349. paid NUMERIC,
  350. datepaid date,
  351. duedate date,
  352. invoice bool DEFAULT 'f',
  353. shippingpoint text,
  354. terms int2 DEFAULT 0,
  355. notes text,
  356. curr char(3),
  357. ordnumber text,
  358. person_id integer references person(id) not null,
  359. till varchar(20),
  360. quonumber text,
  361. intnotes text,
  362. department_id int default 0,
  363. shipvia text,
  364. language_code varchar(6),
  365. ponumber text,
  366. on_hold bool default false,
  367. approved bool default true
  368. );
  369. COMMENT ON COLUMN ar.entity_id IS $$ Used to be customer_id, but customer is now metadata. You need to push to entity $$;
  370. --
  371. CREATE TABLE ap (
  372. id serial PRIMARY KEY,
  373. invnumber text,
  374. transdate date DEFAULT current_date,
  375. entity_id int REFERENCES entity(id),
  376. taxincluded bool DEFAULT 'f',
  377. amount NUMERIC,
  378. netamount NUMERIC,
  379. paid NUMERIC,
  380. datepaid date,
  381. duedate date,
  382. invoice bool DEFAULT 'f',
  383. ordnumber text,
  384. curr char(3),
  385. notes text,
  386. person_id integer references person(id) not null,
  387. till varchar(20),
  388. quonumber text,
  389. intnotes text,
  390. department_id int DEFAULT 0,
  391. shipvia text,
  392. language_code varchar(6),
  393. ponumber text,
  394. shippingpoint text,
  395. on_hold bool default false,
  396. approved bool default true,
  397. terms int2 DEFAULT 0
  398. );
  399. COMMENT ON COLUMN ap.entity_id IS $$ Used to be customer_id, but customer is now metadata. You need to push to entity $$;
  400. --
  401. CREATE TABLE taxmodule (
  402. taxmodule_id serial PRIMARY KEY,
  403. taxmodulename text NOT NULL
  404. );
  405. --
  406. CREATE TABLE taxcategory (
  407. taxcategory_id serial PRIMARY KEY,
  408. taxcategoryname text NOT NULL,
  409. taxmodule_id int NOT NULL,
  410. FOREIGN KEY (taxmodule_id) REFERENCES taxmodule (taxmodule_id)
  411. );
  412. --
  413. CREATE TABLE partstax (
  414. parts_id int,
  415. chart_id int,
  416. taxcategory_id int,
  417. PRIMARY KEY (parts_id, chart_id),
  418. FOREIGN KEY (parts_id) REFERENCES parts (id),
  419. FOREIGN KEY (chart_id) REFERENCES chart (id),
  420. FOREIGN KEY (taxcategory_id) REFERENCES taxcategory (taxcategory_id)
  421. );
  422. --
  423. CREATE TABLE tax (
  424. chart_id int PRIMARY KEY,
  425. rate numeric,
  426. taxnumber text,
  427. validto date,
  428. pass integer DEFAULT 0 NOT NULL,
  429. taxmodule_id int DEFAULT 1 NOT NULL,
  430. FOREIGN KEY (chart_id) REFERENCES chart (id),
  431. FOREIGN KEY (taxmodule_id) REFERENCES taxmodule (taxmodule_id)
  432. );
  433. --
  434. CREATE TABLE customertax (
  435. customer_id int,
  436. chart_id int,
  437. PRIMARY KEY (customer_id, chart_id)
  438. );
  439. --
  440. CREATE TABLE vendortax (
  441. vendor_id int,
  442. chart_id int,
  443. PRIMARY KEY (vendor_id, chart_id)
  444. );
  445. --
  446. CREATE TABLE oe_class (
  447. id smallint unique check(id IN (1,2)),
  448. oe_class text primary key);
  449. INSERT INTO oe_class(id,oe_class) values (1,'Sales Order');
  450. INSERT INTO oe_class(id,oe_class) values (2,'Purchase Order');
  451. COMMENT ON TABLE oe_class IS $$ This could probably be done better. But I need to remove the customer_id/vendor_id relationship and instead rely on a classification $$;
  452. CREATE TABLE oe (
  453. id serial PRIMARY KEY,
  454. ordnumber text,
  455. transdate date default current_date,
  456. entity_id integer references entity(id) NOT NULL,
  457. amount NUMERIC,
  458. netamount NUMERIC,
  459. reqdate date,
  460. taxincluded bool,
  461. shippingpoint text,
  462. notes text,
  463. curr char(3),
  464. person_id integer references person(id) not null,
  465. closed bool default 'f',
  466. quotation bool default 'f',
  467. quonumber text,
  468. intnotes text,
  469. department_id int default 0,
  470. shipvia text,
  471. language_code varchar(6),
  472. ponumber text,
  473. terms int2 DEFAULT 0,
  474. oe_class_id int references oe_class(id) NOT NULL
  475. );
  476. --
  477. CREATE TABLE orderitems (
  478. id serial PRIMARY KEY,
  479. trans_id int,
  480. parts_id int,
  481. description text,
  482. qty numeric,
  483. sellprice NUMERIC,
  484. discount numeric,
  485. unit varchar(5),
  486. project_id int,
  487. reqdate date,
  488. ship numeric,
  489. serialnumber text,
  490. notes text
  491. );
  492. --
  493. CREATE TABLE exchangerate (
  494. curr char(3),
  495. transdate date,
  496. buy numeric,
  497. sell numeric,
  498. PRIMARY KEY (curr, transdate)
  499. );
  500. --
  501. create table employee (
  502. entity_id integer references entity(id) not null PRIMARY KEY,
  503. entity_class_id integer references entity_class(id) not null check (entity_class_id = 3),
  504. login text,
  505. startdate date default current_date,
  506. enddate date,
  507. notes text,
  508. role varchar(20),
  509. sales bool default 'f',
  510. ssn varchar(20),
  511. iban varchar(34),
  512. bic varchar(11),
  513. managerid int,
  514. employeenumber varchar(32),
  515. dob date
  516. );
  517. COMMENT ON TABLE employee IS $$ Is a metadata table specific to employees $$;
  518. -- batch stuff
  519. CREATE TABLE batch_class (
  520. id serial unique,
  521. class varchar primary key
  522. );
  523. insert into batch_class (id,class) values (1,'ap');
  524. insert into batch_class (id,class) values (2,'ar');
  525. insert into batch_class (id,class) values (3,'payment');
  526. insert into batch_class (id,class) values (4,'payment_reversal');
  527. insert into batch_class (id,class) values (5,'gl');
  528. SELECT SETVAL('batch_class_id_seq',6);
  529. CREATE TABLE batch (
  530. id serial primary key,
  531. batch_class_id integer references batch_class(id) not null,
  532. description text,
  533. approved_on date default null,
  534. approved_by int references employee(entity_id),
  535. created_by int references employee(entity_id),
  536. locked_by int references session(session_id),
  537. created_on date default now()
  538. );
  539. CREATE TABLE voucher (
  540. trans_id int,
  541. batch_id int references batch(id) not null,
  542. id serial primary key
  543. );
  544. --
  545. create table shipto (
  546. trans_id int,
  547. shiptoname varchar(64),
  548. shiptoaddress1 varchar(32),
  549. shiptoaddress2 varchar(32),
  550. shiptocity varchar(32),
  551. shiptostate varchar(32),
  552. shiptozipcode varchar(10),
  553. shiptocountry varchar(32),
  554. shiptocontact varchar(64),
  555. shiptophone varchar(20),
  556. shiptofax varchar(20),
  557. shiptoemail text,
  558. entry_id SERIAL PRIMARY KEY
  559. );
  560. -- SHIPTO really needs to be pushed into entities too
  561. --
  562. CREATE TABLE vendor (
  563. entity_id int references entity(id) not null PRIMARY KEY,
  564. entity_class_id int references entity(entity_class) not null check (entity_class_id = 1),
  565. terms int2 default 0,
  566. taxincluded bool default 'f',
  567. vendornumber varchar(32),
  568. cc text,
  569. bcc text,
  570. gifi_accno varchar(30),
  571. business_id int,
  572. taxnumber varchar(32),
  573. sic_code varchar(6),
  574. discount numeric,
  575. creditlimit numeric default 0,
  576. iban varchar(34),
  577. bic varchar(11),
  578. language_code varchar(6),
  579. pricegroup_id int,
  580. curr char(3),
  581. startdate date,
  582. enddate date
  583. );
  584. COMMENT ON TABLE vendor IS $$ Now a meta data table $$;
  585. --
  586. CREATE TABLE project (
  587. id serial PRIMARY KEY,
  588. projectnumber text,
  589. description text,
  590. startdate date,
  591. enddate date,
  592. parts_id int,
  593. production numeric default 0,
  594. completed numeric default 0,
  595. customer_id int
  596. );
  597. --
  598. CREATE TABLE partsgroup (
  599. id serial PRIMARY KEY,
  600. partsgroup text
  601. );
  602. --
  603. CREATE TABLE status (
  604. trans_id int PRIMARY KEY,
  605. formname text,
  606. printed bool default 'f',
  607. emailed bool default 'f',
  608. spoolfile text
  609. );
  610. --
  611. CREATE TABLE department (
  612. id serial PRIMARY KEY,
  613. description text,
  614. role char(1) default 'P'
  615. );
  616. --
  617. -- department transaction table
  618. CREATE TABLE dpt_trans (
  619. trans_id int PRIMARY KEY,
  620. department_id int
  621. );
  622. --
  623. -- business table
  624. CREATE TABLE business (
  625. id serial PRIMARY KEY,
  626. description text,
  627. discount numeric
  628. );
  629. --
  630. -- SIC
  631. CREATE TABLE sic (
  632. code varchar(6) PRIMARY KEY,
  633. sictype char(1),
  634. description text
  635. );
  636. --
  637. CREATE TABLE warehouse (
  638. id serial PRIMARY KEY,
  639. description text
  640. );
  641. --
  642. CREATE TABLE inventory (
  643. entity_id integer references employee(entity_id) not null,
  644. warehouse_id int,
  645. parts_id int,
  646. trans_id int,
  647. orderitems_id int,
  648. qty numeric,
  649. shippingdate date,
  650. entry_id SERIAL PRIMARY KEY
  651. );
  652. --
  653. CREATE TABLE yearend (
  654. trans_id int PRIMARY KEY,
  655. transdate date
  656. );
  657. --
  658. CREATE TABLE partsvendor (
  659. entity_id int references entity(id) not null,
  660. parts_id int,
  661. partnumber text,
  662. leadtime int2,
  663. lastcost NUMERIC,
  664. curr char(3),
  665. entry_id SERIAL PRIMARY KEY
  666. );
  667. --
  668. CREATE TABLE pricegroup (
  669. id serial PRIMARY KEY,
  670. pricegroup text
  671. );
  672. --
  673. CREATE TABLE partscustomer (
  674. parts_id int,
  675. customer_id int,
  676. pricegroup_id int,
  677. pricebreak numeric,
  678. sellprice NUMERIC,
  679. validfrom date,
  680. validto date,
  681. curr char(3),
  682. entry_id SERIAL PRIMARY KEY
  683. );
  684. -- How does partscustomer.customer_id relate here?
  685. --
  686. CREATE TABLE language (
  687. code varchar(6) PRIMARY KEY,
  688. description text
  689. );
  690. --
  691. CREATE TABLE audittrail (
  692. trans_id int,
  693. tablename text,
  694. reference text,
  695. formname text,
  696. action text,
  697. transdate timestamp default current_timestamp,
  698. person_id integer references person(id) not null,
  699. entry_id BIGSERIAL PRIMARY KEY
  700. );
  701. --
  702. CREATE TABLE translation (
  703. trans_id int,
  704. language_code varchar(6),
  705. description text,
  706. PRIMARY KEY (trans_id, language_code)
  707. );
  708. --
  709. CREATE TABLE recurring (
  710. id int PRIMARY KEY,
  711. reference text,
  712. startdate date,
  713. nextdate date,
  714. enddate date,
  715. repeat int2,
  716. unit varchar(6),
  717. howmany int,
  718. payment bool default 'f'
  719. );
  720. --
  721. CREATE TABLE recurringemail (
  722. id int PRIMARY KEY,
  723. formname text,
  724. format text,
  725. message text
  726. );
  727. --
  728. CREATE TABLE recurringprint (
  729. id int PRIMARY KEY,
  730. formname text,
  731. format text,
  732. printer text
  733. );
  734. --
  735. CREATE TABLE jcitems (
  736. id serial PRIMARY KEY,
  737. project_id int,
  738. parts_id int,
  739. description text,
  740. qty numeric,
  741. allocated numeric,
  742. sellprice NUMERIC,
  743. fxsellprice NUMERIC,
  744. serialnumber text,
  745. checkedin timestamp with time zone,
  746. checkedout timestamp with time zone,
  747. person_id integer references person(id) not null,
  748. notes text
  749. );
  750. insert into transactions (id, table_name) SELECT id, 'ap' FROM ap;
  751. CREATE RULE ap_id_track_i AS ON insert TO ap
  752. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'ap');
  753. CREATE RULE ap_id_track_u AS ON update TO ap
  754. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  755. insert into transactions (id, table_name) SELECT id, 'ar' FROM ap;
  756. CREATE RULE ar_id_track_i AS ON insert TO ar
  757. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'ar');
  758. CREATE RULE ar_id_track_u AS ON update TO ar
  759. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  760. INSERT INTO transactions (id, table_name) SELECT id, 'business' FROM business;
  761. CREATE RULE business_id_track_i AS ON insert TO business
  762. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'business');
  763. CREATE RULE business_id_track_u AS ON update TO business
  764. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  765. INSERT INTO transactions (id, table_name) SELECT id, 'chart' FROM chart;
  766. CREATE RULE chart_id_track_i AS ON insert TO chart
  767. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'chart');
  768. CREATE RULE chart_id_track_u AS ON update TO chart
  769. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  770. INSERT INTO transactions (id, table_name) SELECT id, 'customer' FROM customer;
  771. CREATE RULE customer_id_track_i AS ON insert TO customer
  772. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'customer');
  773. CREATE RULE customer_id_track_u AS ON update TO customer
  774. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  775. INSERT INTO transactions (id, table_name) SELECT id, 'department' FROM department;
  776. CREATE RULE department_id_track_i AS ON insert TO department
  777. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'department');
  778. CREATE RULE department_id_track_u AS ON update TO department
  779. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  780. INSERT INTO transactions (id, table_name) SELECT entity_id, 'employee' FROM employee;
  781. INSERT INTO transactions (id, table_name) SELECT id, 'gl' FROM gl;
  782. CREATE RULE gl_id_track_i AS ON insert TO gl
  783. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'gl');
  784. CREATE RULE gl_id_track_u AS ON update TO gl
  785. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  786. INSERT INTO transactions (id, table_name) SELECT id, 'oe' FROM oe;
  787. CREATE RULE oe_id_track_i AS ON insert TO oe
  788. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'oe');
  789. CREATE RULE oe_id_track_u AS ON update TO oe
  790. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  791. INSERT INTO transactions (id, table_name) SELECT id, 'parts' FROM parts;
  792. CREATE RULE parts_id_track_i AS ON insert TO parts
  793. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'parts');
  794. CREATE RULE parts_id_track_u AS ON update TO parts
  795. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  796. INSERT INTO transactions (id, table_name) SELECT id, 'partsgroup' FROM partsgroup;
  797. CREATE RULE partsgroup_id_track_i AS ON insert TO partsgroup
  798. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'partsgroup');
  799. CREATE RULE partsgroup_id_track_u AS ON update TO partsgroup
  800. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  801. INSERT INTO transactions (id, table_name) SELECT id, 'pricegroup' FROM pricegroup;
  802. CREATE RULE pricegroup_id_track_i AS ON insert TO pricegroup
  803. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'pricegroup');
  804. CREATE RULE pricegroup_id_track_u AS ON update TO pricegroup
  805. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  806. INSERT INTO transactions (id, table_name) SELECT id, 'project' FROM project;
  807. CREATE RULE project_id_track_i AS ON insert TO project
  808. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'project');
  809. CREATE RULE project_id_track_u AS ON update TO project
  810. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  811. INSERT INTO transactions (id, table_name) SELECT entity_id, 'vendor' FROM vendor;
  812. CREATE RULE vendor_id_track_i AS ON insert TO vendor
  813. DO INSERT INTO transactions (id, table_name) VALUES (new.entity_id, 'vendor');
  814. INSERT INTO transactions (id, table_name) SELECT id, 'warehouse' FROM warehouse;
  815. CREATE RULE warehouse_id_track_i AS ON insert TO warehouse
  816. DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'employee');
  817. CREATE RULE warehouse_id_track_u AS ON update TO warehouse
  818. DO UPDATE transactions SET id = new.id WHERE id = old.id;
  819. CREATE TABLE custom_table_catalog (
  820. table_id SERIAL PRIMARY KEY,
  821. extends TEXT,
  822. table_name TEXT
  823. );
  824. CREATE TABLE custom_field_catalog (
  825. field_id SERIAL PRIMARY KEY,
  826. table_id INT REFERENCES custom_table_catalog,
  827. field_name TEXT
  828. );
  829. INSERT INTO taxmodule (
  830. taxmodule_id, taxmodulename
  831. ) VALUES (
  832. 1, 'Simple'
  833. );
  834. create index acc_trans_trans_id_key on acc_trans (trans_id);
  835. create index acc_trans_chart_id_key on acc_trans (chart_id);
  836. create index acc_trans_transdate_key on acc_trans (transdate);
  837. create index acc_trans_source_key on acc_trans (lower(source));
  838. --
  839. create index ap_id_key on ap (id);
  840. create index ap_transdate_key on ap (transdate);
  841. create index ap_invnumber_key on ap (invnumber);
  842. create index ap_ordnumber_key on ap (ordnumber);
  843. create index ap_quonumber_key on ap (quonumber);
  844. --
  845. create index ar_id_key on ar (id);
  846. create index ar_transdate_key on ar (transdate);
  847. create index ar_invnumber_key on ar (invnumber);
  848. create index ar_ordnumber_key on ar (ordnumber);
  849. create index ar_quonumber_key on ar (quonumber);
  850. --
  851. create index assembly_id_key on assembly (id);
  852. --
  853. create index chart_id_key on chart (id);
  854. create unique index chart_accno_key on chart (accno);
  855. create index chart_category_key on chart (category);
  856. create index chart_link_key on chart (link);
  857. create index chart_gifi_accno_key on chart (gifi_accno);
  858. --
  859. create index customer_id_key on customer (id);
  860. create index customer_customernumber_key on customer (customernumber);
  861. create index customer_customer_id_key on customertax (customer_id);
  862. --
  863. create unique index employee_login_key on employee (login);
  864. --
  865. create index exchangerate_ct_key on exchangerate (curr, transdate);
  866. --
  867. create unique index gifi_accno_key on gifi (accno);
  868. --
  869. create index gl_id_key on gl (id);
  870. create index gl_transdate_key on gl (transdate);
  871. create index gl_reference_key on gl (reference);
  872. create index gl_description_key on gl (lower(description));
  873. --
  874. create index invoice_id_key on invoice (id);
  875. create index invoice_trans_id_key on invoice (trans_id);
  876. --
  877. create index makemodel_parts_id_key on makemodel (parts_id);
  878. create index makemodel_make_key on makemodel (lower(make));
  879. create index makemodel_model_key on makemodel (lower(model));
  880. --
  881. create index oe_id_key on oe (id);
  882. create index oe_transdate_key on oe (transdate);
  883. create index oe_ordnumber_key on oe (ordnumber);
  884. create index orderitems_trans_id_key on orderitems (trans_id);
  885. create index orderitems_id_key on orderitems (id);
  886. --
  887. create index parts_id_key on parts (id);
  888. create index parts_partnumber_key on parts (lower(partnumber));
  889. create index parts_description_key on parts (lower(description));
  890. create index partstax_parts_id_key on partstax (parts_id);
  891. --
  892. create index vendor_entity_id_key on vendor (entity_id);
  893. create index vendor_vendornumber_key on vendor (vendornumber);
  894. --
  895. create index shipto_trans_id_key on shipto (trans_id);
  896. --
  897. create index project_id_key on project (id);
  898. create unique index projectnumber_key on project (projectnumber);
  899. --
  900. create index partsgroup_id_key on partsgroup (id);
  901. create unique index partsgroup_key on partsgroup (partsgroup);
  902. --
  903. create index status_trans_id_key on status (trans_id);
  904. --
  905. create index department_id_key on department (id);
  906. --
  907. create index partsvendor_parts_id_key on partsvendor (parts_id);
  908. --
  909. create index pricegroup_pricegroup_key on pricegroup (pricegroup);
  910. create index pricegroup_id_key on pricegroup (id);
  911. --
  912. create index audittrail_trans_id_key on audittrail (trans_id);
  913. --
  914. create index translation_trans_id_key on translation (trans_id);
  915. --
  916. create unique index language_code_key on language (code);
  917. --
  918. create index jcitems_id_key on jcitems (id);
  919. -- Popular some entity data
  920. INSERT INTO country(short_name,name) VALUES ('AC','Ascension Island');
  921. INSERT INTO country(short_name,name) VALUES ('AD','Andorra');
  922. INSERT INTO country(short_name,name) VALUES ('AE','United Arab Emirates');
  923. INSERT INTO country(short_name,name) VALUES ('AF','Afghanistan');
  924. INSERT INTO country(short_name,name) VALUES ('AG','Antigua and Barbuda');
  925. INSERT INTO country(short_name,name) VALUES ('AI','Anguilla');
  926. INSERT INTO country(short_name,name) VALUES ('AL','Albania');
  927. INSERT INTO country(short_name,name) VALUES ('AM','Armenia');
  928. INSERT INTO country(short_name,name) VALUES ('AN','Netherlands Antilles');
  929. INSERT INTO country(short_name,name) VALUES ('AO','Angola');
  930. INSERT INTO country(short_name,name) VALUES ('AQ','Antarctica');
  931. INSERT INTO country(short_name,name) VALUES ('AR','Argentina');
  932. INSERT INTO country(short_name,name) VALUES ('AS','American Samoa');
  933. INSERT INTO country(short_name,name) VALUES ('AT','Austria');
  934. INSERT INTO country(short_name,name) VALUES ('AU','Australia');
  935. INSERT INTO country(short_name,name) VALUES ('AW','Aruba');
  936. INSERT INTO country(short_name,name) VALUES ('AX','Aland Islands');
  937. INSERT INTO country(short_name,name) VALUES ('AZ','Azerbaijan');
  938. INSERT INTO country(short_name,name) VALUES ('BA','Bosnia and Herzegovina');
  939. INSERT INTO country(short_name,name) VALUES ('BB','Barbados');
  940. INSERT INTO country(short_name,name) VALUES ('BD','Bangladesh');
  941. INSERT INTO country(short_name,name) VALUES ('BE','Belgium');
  942. INSERT INTO country(short_name,name) VALUES ('BF','Burkina Faso');
  943. INSERT INTO country(short_name,name) VALUES ('BG','Bulgaria');
  944. INSERT INTO country(short_name,name) VALUES ('BH','Bahrain');
  945. INSERT INTO country(short_name,name) VALUES ('BI','Burundi');
  946. INSERT INTO country(short_name,name) VALUES ('BJ','Benin');
  947. INSERT INTO country(short_name,name) VALUES ('BM','Bermuda');
  948. INSERT INTO country(short_name,name) VALUES ('BN','Brunei Darussalam');
  949. INSERT INTO country(short_name,name) VALUES ('BO','Bolivia');
  950. INSERT INTO country(short_name,name) VALUES ('BR','Brazil');
  951. INSERT INTO country(short_name,name) VALUES ('BS','Bahamas');
  952. INSERT INTO country(short_name,name) VALUES ('BT','Bhutan');
  953. INSERT INTO country(short_name,name) VALUES ('BV','Bouvet Island');
  954. INSERT INTO country(short_name,name) VALUES ('BW','Botswana');
  955. INSERT INTO country(short_name,name) VALUES ('BY','Belarus');
  956. INSERT INTO country(short_name,name) VALUES ('BZ','Belize');
  957. INSERT INTO country(short_name,name) VALUES ('CA','Canada');
  958. INSERT INTO country(short_name,name) VALUES ('CC','Cocos (Keeling) Islands');
  959. INSERT INTO country(short_name,name) VALUES ('CD','Congo, Democratic Republic');
  960. INSERT INTO country(short_name,name) VALUES ('CF','Central African Republic');
  961. INSERT INTO country(short_name,name) VALUES ('CG','Congo');
  962. INSERT INTO country(short_name,name) VALUES ('CH','Switzerland');
  963. INSERT INTO country(short_name,name) VALUES ('CI','Cote D\'Ivoire (Ivory Coast)');
  964. INSERT INTO country(short_name,name) VALUES ('CK','Cook Islands');
  965. INSERT INTO country(short_name,name) VALUES ('CL','Chile');
  966. INSERT INTO country(short_name,name) VALUES ('CM','Cameroon');
  967. INSERT INTO country(short_name,name) VALUES ('CN','China');
  968. INSERT INTO country(short_name,name) VALUES ('CO','Colombia');
  969. INSERT INTO country(short_name,name) VALUES ('CR','Costa Rica');
  970. INSERT INTO country(short_name,name) VALUES ('CS','Czechoslovakia (former)');
  971. INSERT INTO country(short_name,name) VALUES ('CU','Cuba');
  972. INSERT INTO country(short_name,name) VALUES ('CV','Cape Verde');
  973. INSERT INTO country(short_name,name) VALUES ('CX','Christmas Island');
  974. INSERT INTO country(short_name,name) VALUES ('CY','Cyprus');
  975. INSERT INTO country(short_name,name) VALUES ('CZ','Czech Republic');
  976. INSERT INTO country(short_name,name) VALUES ('DE','Germany');
  977. INSERT INTO country(short_name,name) VALUES ('DJ','Djibouti');
  978. INSERT INTO country(short_name,name) VALUES ('DK','Denmark');
  979. INSERT INTO country(short_name,name) VALUES ('DM','Dominica');
  980. INSERT INTO country(short_name,name) VALUES ('DO','Dominican Republic');
  981. INSERT INTO country(short_name,name) VALUES ('DZ','Algeria');
  982. INSERT INTO country(short_name,name) VALUES ('EC','Ecuador');
  983. INSERT INTO country(short_name,name) VALUES ('EE','Estonia');
  984. INSERT INTO country(short_name,name) VALUES ('EG','Egypt');
  985. INSERT INTO country(short_name,name) VALUES ('EH','Western Sahara');
  986. INSERT INTO country(short_name,name) VALUES ('ER','Eritrea');
  987. INSERT INTO country(short_name,name) VALUES ('ES','Spain');
  988. INSERT INTO country(short_name,name) VALUES ('ET','Ethiopia');
  989. INSERT INTO country(short_name,name) VALUES ('FI','Finland');
  990. INSERT INTO country(short_name,name) VALUES ('FJ','Fiji');
  991. INSERT INTO country(short_name,name) VALUES ('FK','Falkland Islands (Malvinas)');
  992. INSERT INTO country(short_name,name) VALUES ('FM','Micronesia');
  993. INSERT INTO country(short_name,name) VALUES ('FO','Faroe Islands');
  994. INSERT INTO country(short_name,name) VALUES ('FR','France');
  995. INSERT INTO country(short_name,name) VALUES ('FX','France, Metropolitan');
  996. INSERT INTO country(short_name,name) VALUES ('GA','Gabon');
  997. INSERT INTO country(short_name,name) VALUES ('GB','Great Britain (UK)');
  998. INSERT INTO country(short_name,name) VALUES ('GD','Grenada');
  999. INSERT INTO country(short_name,name) VALUES ('GE','Georgia');
  1000. INSERT INTO country(short_name,name) VALUES ('GF','French Guiana');
  1001. INSERT INTO country(short_name,name) VALUES ('GH','Ghana');
  1002. INSERT INTO country(short_name,name) VALUES ('GI','Gibraltar');
  1003. INSERT INTO country(short_name,name) VALUES ('GL','Greenland');
  1004. INSERT INTO country(short_name,name) VALUES ('GM','Gambia');
  1005. INSERT INTO country(short_name,name) VALUES ('GN','Guinea');
  1006. INSERT INTO country(short_name,name) VALUES ('GP','Guadeloupe');
  1007. INSERT INTO country(short_name,name) VALUES ('GQ','Equatorial Guinea');
  1008. INSERT INTO country(short_name,name) VALUES ('GR','Greece');
  1009. INSERT INTO country(short_name,name) VALUES ('GS','S. Georgia and S. Sandwich Isls.');
  1010. INSERT INTO country(short_name,name) VALUES ('GT','Guatemala');
  1011. INSERT INTO country(short_name,name) VALUES ('GU','Guam');
  1012. INSERT INTO country(short_name,name) VALUES ('GW','Guinea-Bissau');
  1013. INSERT INTO country(short_name,name) VALUES ('GY','Guyana');
  1014. INSERT INTO country(short_name,name) VALUES ('HK','Hong Kong');
  1015. INSERT INTO country(short_name,name) VALUES ('HM','Heard and McDonald Islands');
  1016. INSERT INTO country(short_name,name) VALUES ('HN','Honduras');
  1017. INSERT INTO country(short_name,name) VALUES ('HR','Croatia (Hrvatska)');
  1018. INSERT INTO country(short_name,name) VALUES ('HT','Haiti');
  1019. INSERT INTO country(short_name,name) VALUES ('HU','Hungary');
  1020. INSERT INTO country(short_name,name) VALUES ('ID','Indonesia');
  1021. INSERT INTO country(short_name,name) VALUES ('IE','Ireland');
  1022. INSERT INTO country(short_name,name) VALUES ('IL','Israel');
  1023. INSERT INTO country(short_name,name) VALUES ('IM','Isle of Man');
  1024. INSERT INTO country(short_name,name) VALUES ('IN','India');
  1025. INSERT INTO country(short_name,name) VALUES ('IO','British Indian Ocean Territory');
  1026. INSERT INTO country(short_name,name) VALUES ('IQ','Iraq');
  1027. INSERT INTO country(short_name,name) VALUES ('IR','Iran');
  1028. INSERT INTO country(short_name,name) VALUES ('IS','Iceland');
  1029. INSERT INTO country(short_name,name) VALUES ('IT','Italy');
  1030. INSERT INTO country(short_name,name) VALUES ('JE','Jersey');
  1031. INSERT INTO country(short_name,name) VALUES ('JM','Jamaica');
  1032. INSERT INTO country(short_name,name) VALUES ('JO','Jordan');
  1033. INSERT INTO country(short_name,name) VALUES ('JP','Japan');
  1034. INSERT INTO country(short_name,name) VALUES ('KE','Kenya');
  1035. INSERT INTO country(short_name,name) VALUES ('KG','Kyrgyzstan');
  1036. INSERT INTO country(short_name,name) VALUES ('KH','Cambodia');
  1037. INSERT INTO country(short_name,name) VALUES ('KI','Kiribati');
  1038. INSERT INTO country(short_name,name) VALUES ('KM','Comoros');
  1039. INSERT INTO country(short_name,name) VALUES ('KN','Saint Kitts and Nevis');
  1040. INSERT INTO country(short_name,name) VALUES ('KP','Korea (North)');
  1041. INSERT INTO country(short_name,name) VALUES ('KR','Korea (South)');
  1042. INSERT INTO country(short_name,name) VALUES ('KW','Kuwait');
  1043. INSERT INTO country(short_name,name) VALUES ('KY','Cayman Islands');
  1044. INSERT INTO country(short_name,name) VALUES ('KZ','Kazakhstan');
  1045. INSERT INTO country(short_name,name) VALUES ('LA','Laos');
  1046. INSERT INTO country(short_name,name) VALUES ('LB','Lebanon');
  1047. INSERT INTO country(short_name,name) VALUES ('LC','Saint Lucia');
  1048. INSERT INTO country(short_name,name) VALUES ('LI','Liechtenstein');
  1049. INSERT INTO country(short_name,name) VALUES ('LK','Sri Lanka');
  1050. INSERT INTO country(short_name,name) VALUES ('LR','Liberia');
  1051. INSERT INTO country(short_name,name) VALUES ('LS','Lesotho');
  1052. INSERT INTO country(short_name,name) VALUES ('LT','Lithuania');
  1053. INSERT INTO country(short_name,name) VALUES ('LU','Luxembourg');
  1054. INSERT INTO country(short_name,name) VALUES ('LV','Latvia');
  1055. INSERT INTO country(short_name,name) VALUES ('LY','Libya');
  1056. INSERT INTO country(short_name,name) VALUES ('MA','Morocco');
  1057. INSERT INTO country(short_name,name) VALUES ('MC','Monaco');
  1058. INSERT INTO country(short_name,name) VALUES ('MD','Moldova');
  1059. INSERT INTO country(short_name,name) VALUES ('MG','Madagascar');
  1060. INSERT INTO country(short_name,name) VALUES ('MH','Marshall Islands');
  1061. INSERT INTO country(short_name,name) VALUES ('MK','F.Y.R.O.M. (Macedonia)');
  1062. INSERT INTO country(short_name,name) VALUES ('ML','Mali');
  1063. INSERT INTO country(short_name,name) VALUES ('MM','Myanmar');
  1064. INSERT INTO country(short_name,name) VALUES ('MN','Mongolia');
  1065. INSERT INTO country(short_name,name) VALUES ('MO','Macau');
  1066. INSERT INTO country(short_name,name) VALUES ('MP','Northern Mariana Islands');
  1067. INSERT INTO country(short_name,name) VALUES ('MQ','Martinique');
  1068. INSERT INTO country(short_name,name) VALUES ('MR','Mauritania');
  1069. INSERT INTO country(short_name,name) VALUES ('MS','Montserrat');
  1070. INSERT INTO country(short_name,name) VALUES ('MT','Malta');
  1071. INSERT INTO country(short_name,name) VALUES ('MU','Mauritius');
  1072. INSERT INTO country(short_name,name) VALUES ('MV','Maldives');
  1073. INSERT INTO country(short_name,name) VALUES ('MW','Malawi');
  1074. INSERT INTO country(short_name,name) VALUES ('MX','Mexico');
  1075. INSERT INTO country(short_name,name) VALUES ('MY','Malaysia');
  1076. INSERT INTO country(short_name,name) VALUES ('MZ','Mozambique');
  1077. INSERT INTO country(short_name,name) VALUES ('NA','Namibia');
  1078. INSERT INTO country(short_name,name) VALUES ('NC','New Caledonia');
  1079. INSERT INTO country(short_name,name) VALUES ('NE','Niger');
  1080. INSERT INTO country(short_name,name) VALUES ('NF','Norfolk Island');
  1081. INSERT INTO country(short_name,name) VALUES ('NG','Nigeria');
  1082. INSERT INTO country(short_name,name) VALUES ('NI','Nicaragua');
  1083. INSERT INTO country(short_name,name) VALUES ('NL','Netherlands');
  1084. INSERT INTO country(short_name,name) VALUES ('NO','Norway');
  1085. INSERT INTO country(short_name,name) VALUES ('NP','Nepal');
  1086. INSERT INTO country(short_name,name) VALUES ('NR','Nauru');
  1087. INSERT INTO country(short_name,name) VALUES ('NT','Neutral Zone');
  1088. INSERT INTO country(short_name,name) VALUES ('NU','Niue');
  1089. INSERT INTO country(short_name,name) VALUES ('NZ','New Zealand (Aotearoa)');
  1090. INSERT INTO country(short_name,name) VALUES ('OM','Oman');
  1091. INSERT INTO country(short_name,name) VALUES ('PA','Panama');
  1092. INSERT INTO country(short_name,name) VALUES ('PE','Peru');
  1093. INSERT INTO country(short_name,name) VALUES ('PF','French Polynesia');
  1094. INSERT INTO country(short_name,name) VALUES ('PG','Papua New Guinea');
  1095. INSERT INTO country(short_name,name) VALUES ('PH','Philippines');
  1096. INSERT INTO country(short_name,name) VALUES ('PK','Pakistan');
  1097. INSERT INTO country(short_name,name) VALUES ('PL','Poland');
  1098. INSERT INTO country(short_name,name) VALUES ('PM','St. Pierre and Miquelon');
  1099. INSERT INTO country(short_name,name) VALUES ('PN','Pitcairn');
  1100. INSERT INTO country(short_name,name) VALUES ('PR','Puerto Rico');
  1101. INSERT INTO country(short_name,name) VALUES ('PS','Palestinian Territory, Occupied');
  1102. INSERT INTO country(short_name,name) VALUES ('PT','Portugal');
  1103. INSERT INTO country(short_name,name) VALUES ('PW','Palau');
  1104. INSERT INTO country(short_name,name) VALUES ('PY','Paraguay');
  1105. INSERT INTO country(short_name,name) VALUES ('QA','Qatar');
  1106. INSERT INTO country(short_name,name) VALUES ('RE','Reunion');
  1107. INSERT INTO country(short_name,name) VALUES ('RO','Romania');
  1108. INSERT INTO country(short_name,name) VALUES ('RS','Serbia');
  1109. INSERT INTO country(short_name,name) VALUES ('RU','Russian Federation');
  1110. INSERT INTO country(short_name,name) VALUES ('RW','Rwanda');
  1111. INSERT INTO country(short_name,name) VALUES ('SA','Saudi Arabia');
  1112. INSERT INTO country(short_name,name) VALUES ('SB','Solomon Islands');
  1113. INSERT INTO country(short_name,name) VALUES ('SC','Seychelles');
  1114. INSERT INTO country(short_name,name) VALUES ('SD','Sudan');
  1115. INSERT INTO country(short_name,name) VALUES ('SE','Sweden');
  1116. INSERT INTO country(short_name,name) VALUES ('SG','Singapore');
  1117. INSERT INTO country(short_name,name) VALUES ('SH','St. Helena');
  1118. INSERT INTO country(short_name,name) VALUES ('SI','Slovenia');
  1119. INSERT INTO country(short_name,name) VALUES ('SJ','Svalbard & Jan Mayen Islands');
  1120. INSERT INTO country(short_name,name) VALUES ('SK','Slovak Republic');
  1121. INSERT INTO country(short_name,name) VALUES ('SL','Sierra Leone');
  1122. INSERT INTO country(short_name,name) VALUES ('SM','San Marino');
  1123. INSERT INTO country(short_name,name) VALUES ('SN','Senegal');
  1124. INSERT INTO country(short_name,name) VALUES ('SO','Somalia');
  1125. INSERT INTO country(short_name,name) VALUES ('SR','Suriname');
  1126. INSERT INTO country(short_name,name) VALUES ('ST','Sao Tome and Principe');
  1127. INSERT INTO country(short_name,name) VALUES ('SU','USSR (former)');
  1128. INSERT INTO country(short_name,name) VALUES ('SV','El Salvador');
  1129. INSERT INTO country(short_name,name) VALUES ('SY','Syria');
  1130. INSERT INTO country(short_name,name) VALUES ('SZ','Swaziland');
  1131. INSERT INTO country(short_name,name) VALUES ('TC','Turks and Caicos Islands');
  1132. INSERT INTO country(short_name,name) VALUES ('TD','Chad');
  1133. INSERT INTO country(short_name,name) VALUES ('TF','French Southern Territories');
  1134. INSERT INTO country(short_name,name) VALUES ('TG','Togo');
  1135. INSERT INTO country(short_name,name) VALUES ('TH','Thailand');
  1136. INSERT INTO country(short_name,name) VALUES ('TJ','Tajikistan');
  1137. INSERT INTO country(short_name,name) VALUES ('TK','Tokelau');
  1138. INSERT INTO country(short_name,name) VALUES ('TM','Turkmenistan');
  1139. INSERT INTO country(short_name,name) VALUES ('TN','Tunisia');
  1140. INSERT INTO country(short_name,name) VALUES ('TO','Tonga');
  1141. INSERT INTO country(short_name,name) VALUES ('TP','East Timor');
  1142. INSERT INTO country(short_name,name) VALUES ('TR','Turkey');
  1143. INSERT INTO country(short_name,name) VALUES ('TT','Trinidad and Tobago');
  1144. INSERT INTO country(short_name,name) VALUES ('TV','Tuvalu');
  1145. INSERT INTO country(short_name,name) VALUES ('TW','Taiwan');
  1146. INSERT INTO country(short_name,name) VALUES ('TZ','Tanzania');
  1147. INSERT INTO country(short_name,name) VALUES ('UA','Ukraine');
  1148. INSERT INTO country(short_name,name) VALUES ('UG','Uganda');
  1149. INSERT INTO country(short_name,name) VALUES ('UK','United Kingdom');
  1150. INSERT INTO country(short_name,name) VALUES ('UM','US Minor Outlying Islands');
  1151. INSERT INTO country(short_name,name) VALUES ('US','United States');
  1152. INSERT INTO country(short_name,name) VALUES ('UY','Uruguay');
  1153. INSERT INTO country(short_name,name) VALUES ('UZ','Uzbekistan');
  1154. INSERT INTO country(short_name,name) VALUES ('VA','Vatican City State (Holy See)');
  1155. INSERT INTO country(short_name,name) VALUES ('VC','Saint Vincent & the Grenadines');
  1156. INSERT INTO country(short_name,name) VALUES ('VE','Venezuela');
  1157. INSERT INTO country(short_name,name) VALUES ('VG','British Virgin Islands');
  1158. INSERT INTO country(short_name,name) VALUES ('VI','Virgin Islands (U.S.)');
  1159. INSERT INTO country(short_name,name) VALUES ('VN','Viet Nam');
  1160. INSERT INTO country(short_name,name) VALUES ('VU','Vanuatu');
  1161. INSERT INTO country(short_name,name) VALUES ('WF','Wallis and Futuna Islands');
  1162. INSERT INTO country(short_name,name) VALUES ('WS','Samoa');
  1163. INSERT INTO country(short_name,name) VALUES ('YE','Yemen');
  1164. INSERT INTO country(short_name,name) VALUES ('YT','Mayotte');
  1165. INSERT INTO country(short_name,name) VALUES ('YU','Yugoslavia (former)');
  1166. INSERT INTO country(short_name,name) VALUES ('ZA','South Africa');
  1167. INSERT INTO country(short_name,name) VALUES ('ZM','Zambia');
  1168. INSERT INTO country(short_name,name) VALUES ('ZR','Zaire');
  1169. INSERT INTO country(short_name,name) VALUES ('ZW','Zimbabwe');
  1170. --
  1171. CREATE FUNCTION del_yearend() RETURNS TRIGGER AS '
  1172. begin
  1173. delete from yearend where trans_id = old.id;
  1174. return NULL;
  1175. end;
  1176. ' language 'plpgsql';
  1177. -- end function
  1178. --
  1179. CREATE TRIGGER del_yearend AFTER DELETE ON gl FOR EACH ROW EXECUTE PROCEDURE del_yearend();
  1180. -- end trigger
  1181. --
  1182. CREATE FUNCTION del_department() RETURNS TRIGGER AS '
  1183. begin
  1184. delete from dpt_trans where trans_id = old.id;
  1185. return NULL;
  1186. end;
  1187. ' language 'plpgsql';
  1188. -- end function
  1189. --
  1190. CREATE TRIGGER del_department AFTER DELETE ON ar FOR EACH ROW EXECUTE PROCEDURE del_department();
  1191. -- end trigger
  1192. CREATE TRIGGER del_department AFTER DELETE ON ap FOR EACH ROW EXECUTE PROCEDURE del_department();
  1193. -- end trigger
  1194. CREATE TRIGGER del_department AFTER DELETE ON gl FOR EACH ROW EXECUTE PROCEDURE del_department();
  1195. -- end trigger
  1196. CREATE TRIGGER del_department AFTER DELETE ON oe FOR EACH ROW EXECUTE PROCEDURE del_department();
  1197. -- end trigger
  1198. --
  1199. CREATE FUNCTION del_customer() RETURNS TRIGGER AS '
  1200. begin
  1201. delete from shipto where trans_id = old.id;
  1202. delete from customertax where customer_id = old.id;
  1203. delete from partscustomer where customer_id = old.id;
  1204. return NULL;
  1205. end;
  1206. ' language 'plpgsql';
  1207. -- end function
  1208. --
  1209. CREATE TRIGGER del_customer AFTER DELETE ON customer FOR EACH ROW EXECUTE PROCEDURE del_customer();
  1210. -- end trigger
  1211. --
  1212. CREATE FUNCTION del_vendor() RETURNS TRIGGER AS '
  1213. begin
  1214. delete from shipto where trans_id = old.id;
  1215. delete from vendortax where vendor_id = old.id;
  1216. delete from partsvendor where vendor_id = old.id;
  1217. return NULL;
  1218. end;
  1219. ' language 'plpgsql';
  1220. -- end function
  1221. --
  1222. CREATE TRIGGER del_vendor AFTER DELETE ON vendor FOR EACH ROW EXECUTE PROCEDURE del_vendor();
  1223. -- end trigger
  1224. --
  1225. CREATE FUNCTION del_exchangerate() RETURNS TRIGGER AS '
  1226. declare
  1227. t_transdate date;
  1228. t_curr char(3);
  1229. t_id int;
  1230. d_curr text;
  1231. begin
  1232. select into d_curr substr(value,1,3) from defaults where setting_key = ''curr'';
  1233. if TG_RELNAME = ''ar'' then
  1234. select into t_curr, t_transdate curr, transdate from ar where id = old.id;
  1235. end if;
  1236. if TG_RELNAME = ''ap'' then
  1237. select into t_curr, t_transdate curr, transdate from ap where id = old.id;
  1238. end if;
  1239. if TG_RELNAME = ''oe'' then
  1240. select into t_curr, t_transdate curr, transdate from oe where id = old.id;
  1241. end if;
  1242. if d_curr != t_curr then
  1243. select into t_id a.id from acc_trans ac
  1244. join ar a on (a.id = ac.trans_id)
  1245. where a.curr = t_curr
  1246. and ac.transdate = t_transdate
  1247. except select a.id from ar a where a.id = old.id
  1248. union
  1249. select a.id from acc_trans ac
  1250. join ap a on (a.id = ac.trans_id)
  1251. where a.curr = t_curr
  1252. and ac.transdate = t_transdate
  1253. except select a.id from ap a where a.id = old.id
  1254. union
  1255. select o.id from oe o
  1256. where o.curr = t_curr
  1257. and o.transdate = t_transdate
  1258. except select o.id from oe o where o.id = old.id;
  1259. if not found then
  1260. delete from exchangerate where curr = t_curr and transdate = t_transdate;
  1261. end if;
  1262. end if;
  1263. return old;
  1264. end;
  1265. ' language 'plpgsql';
  1266. -- end function
  1267. --
  1268. CREATE TRIGGER del_exchangerate BEFORE DELETE ON ar FOR EACH ROW EXECUTE PROCEDURE del_exchangerate();
  1269. -- end trigger
  1270. --
  1271. CREATE TRIGGER del_exchangerate BEFORE DELETE ON ap FOR EACH ROW EXECUTE PROCEDURE del_exchangerate();
  1272. -- end trigger
  1273. --
  1274. CREATE TRIGGER del_exchangerate BEFORE DELETE ON oe FOR EACH ROW EXECUTE PROCEDURE del_exchangerate();
  1275. -- end trigger
  1276. --
  1277. CREATE FUNCTION check_inventory() RETURNS TRIGGER AS '
  1278. declare
  1279. itemid int;
  1280. row_data inventory%rowtype;
  1281. begin
  1282. if not old.quotation then
  1283. for row_data in select * from inventory where trans_id = old.id loop
  1284. select into itemid id from orderitems where trans_id = old.id and id = row_data.orderitems_id;
  1285. if itemid is null then
  1286. delete from inventory where trans_id = old.id and orderitems_id = row_data.orderitems_id;
  1287. end if;
  1288. end loop;
  1289. end if;
  1290. return old;
  1291. end;
  1292. ' language 'plpgsql';
  1293. -- end function
  1294. --
  1295. CREATE TRIGGER check_inventory AFTER UPDATE ON oe FOR EACH ROW EXECUTE PROCEDURE check_inventory();
  1296. -- end trigger
  1297. --
  1298. --
  1299. CREATE FUNCTION check_department() RETURNS TRIGGER AS '
  1300. declare
  1301. dpt_id int;
  1302. begin
  1303. if new.department_id = 0 then
  1304. delete from dpt_trans where trans_id = new.id;
  1305. return NULL;
  1306. end if;
  1307. select into dpt_id trans_id from dpt_trans where trans_id = new.id;
  1308. if dpt_id > 0 then
  1309. update dpt_trans set department_id = new.department_id where trans_id = dpt_id;
  1310. else
  1311. insert into dpt_trans (trans_id, department_id) values (new.id, new.department_id);
  1312. end if;
  1313. return NULL;
  1314. end;
  1315. ' language 'plpgsql';
  1316. -- end function
  1317. --
  1318. CREATE TRIGGER check_department AFTER INSERT OR UPDATE ON ar FOR EACH ROW EXECUTE PROCEDURE check_department();
  1319. -- end trigger
  1320. CREATE TRIGGER check_department AFTER INSERT OR UPDATE ON ap FOR EACH ROW EXECUTE PROCEDURE check_department();
  1321. -- end trigger
  1322. CREATE TRIGGER check_department AFTER INSERT OR UPDATE ON gl FOR EACH ROW EXECUTE PROCEDURE check_department();
  1323. -- end trigger
  1324. CREATE TRIGGER check_department AFTER INSERT OR UPDATE ON oe FOR EACH ROW EXECUTE PROCEDURE check_department();
  1325. -- end trigger
  1326. --
  1327. CREATE FUNCTION del_recurring() RETURNS TRIGGER AS '
  1328. BEGIN
  1329. DELETE FROM recurring WHERE id = old.id;
  1330. DELETE FROM recurringemail WHERE id = old.id;
  1331. DELETE FROM recurringprint WHERE id = old.id;
  1332. RETURN NULL;
  1333. END;
  1334. ' language 'plpgsql';
  1335. --end function
  1336. CREATE TRIGGER del_recurring AFTER DELETE ON ar FOR EACH ROW EXECUTE PROCEDURE del_recurring();
  1337. -- end trigger
  1338. CREATE TRIGGER del_recurring AFTER DELETE ON ap FOR EACH ROW EXECUTE PROCEDURE del_recurring();
  1339. -- end trigger
  1340. CREATE TRIGGER del_recurring AFTER DELETE ON gl FOR EACH ROW EXECUTE PROCEDURE del_recurring();
  1341. -- end trigger
  1342. --
  1343. CREATE FUNCTION avgcost(int) RETURNS FLOAT AS '
  1344. DECLARE
  1345. v_cost float;
  1346. v_qty float;
  1347. v_parts_id alias for $1;
  1348. BEGIN
  1349. SELECT INTO v_cost, v_qty SUM(i.sellprice * i.qty), SUM(i.qty)
  1350. FROM invoice i
  1351. JOIN ap a ON (a.id = i.trans_id)
  1352. WHERE i.parts_id = v_parts_id;
  1353. IF v_cost IS NULL THEN
  1354. v_cost := 0;
  1355. END IF;
  1356. IF NOT v_qty IS NULL THEN
  1357. IF v_qty = 0 THEN
  1358. v_cost := 0;
  1359. ELSE
  1360. v_cost := v_cost/v_qty;
  1361. END IF;
  1362. END IF;
  1363. RETURN v_cost;
  1364. END;
  1365. ' language 'plpgsql';
  1366. -- end function
  1367. --
  1368. CREATE FUNCTION lastcost(int) RETURNS FLOAT AS '
  1369. DECLARE
  1370. v_cost float;
  1371. v_parts_id alias for $1;
  1372. BEGIN
  1373. SELECT INTO v_cost sellprice FROM invoice i
  1374. JOIN ap a ON (a.id = i.trans_id)
  1375. WHERE i.parts_id = v_parts_id
  1376. ORDER BY a.transdate desc, a.id desc
  1377. LIMIT 1;
  1378. IF v_cost IS NULL THEN
  1379. v_cost := 0;
  1380. END IF;
  1381. RETURN v_cost;
  1382. END;
  1383. ' language plpgsql;
  1384. -- end function
  1385. --
  1386. CREATE OR REPLACE FUNCTION trigger_parts_short() RETURNS TRIGGER
  1387. AS
  1388. '
  1389. BEGIN
  1390. IF NEW.onhand >= NEW.rop THEN
  1391. NOTIFY parts_short;
  1392. END IF;
  1393. RETURN NEW;
  1394. END;
  1395. ' LANGUAGE PLPGSQL;
  1396. -- end function
  1397. CREATE TRIGGER parts_short AFTER UPDATE ON parts
  1398. FOR EACH ROW EXECUTE PROCEDURE trigger_parts_short();
  1399. -- end function
  1400. CREATE OR REPLACE FUNCTION add_custom_field (VARCHAR, VARCHAR, VARCHAR)
  1401. RETURNS BOOL AS
  1402. '
  1403. DECLARE
  1404. table_name ALIAS FOR $1;
  1405. new_field_name ALIAS FOR $2;
  1406. field_datatype ALIAS FOR $3;
  1407. BEGIN
  1408. EXECUTE ''SELECT TABLE_ID FROM custom_table_catalog
  1409. WHERE extends = '''''' || table_name || '''''' '';
  1410. IF NOT FOUND THEN
  1411. BEGIN
  1412. INSERT INTO custom_table_catalog (extends)
  1413. VALUES (table_name);
  1414. EXECUTE ''CREATE TABLE custom_''||table_name ||
  1415. '' (row_id INT PRIMARY KEY)'';
  1416. EXCEPTION WHEN duplicate_table THEN
  1417. -- do nothing
  1418. END;
  1419. END IF;
  1420. EXECUTE ''INSERT INTO custom_field_catalog (field_name, table_id)
  1421. VALUES ( '''''' || new_field_name ||'''''', (SELECT table_id FROM custom_table_catalog
  1422. WHERE extends = ''''''|| table_name || ''''''))'';
  1423. EXECUTE ''ALTER TABLE custom_''||table_name || '' ADD COLUMN ''
  1424. || new_field_name || '' '' || field_datatype;
  1425. RETURN TRUE;
  1426. END;
  1427. ' LANGUAGE PLPGSQL;
  1428. -- end function
  1429. CREATE OR REPLACE FUNCTION drop_custom_field (VARCHAR, VARCHAR)
  1430. RETURNS BOOL AS
  1431. '
  1432. DECLARE
  1433. table_name ALIAS FOR $1;
  1434. custom_field_name ALIAS FOR $2;
  1435. BEGIN
  1436. DELETE FROM custom_field_catalog
  1437. WHERE field_name = custom_field_name AND
  1438. table_id = (SELECT table_id FROM custom_table_catalog
  1439. WHERE extends = table_name);
  1440. EXECUTE ''ALTER TABLE custom_'' || table_name ||
  1441. '' DROP COLUMN '' || custom_field_name;
  1442. RETURN TRUE;
  1443. END;
  1444. ' LANGUAGE PLPGSQL;
  1445. -- end function
  1446. commit;
  1447. CREATE TABLE menu_node (
  1448. id serial NOT NULL,
  1449. label character varying NOT NULL,
  1450. parent integer,
  1451. "position" integer NOT NULL
  1452. );
  1453. ALTER TABLE public.menu_node OWNER TO ledgersmb;
  1454. --
  1455. -- Name: menu_node_id_seq; Type: SEQUENCE SET; Schema: public; Owner: ledgersmb
  1456. --
  1457. SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('menu_node', 'id'), 193, true);
  1458. --
  1459. -- Data for Name: menu_node; Type: TABLE DATA; Schema: public; Owner: ledgersmb
  1460. --
  1461. COPY menu_node (id, label, parent, "position") FROM stdin;
  1462. 0 Top-level \N 0
  1463. 1 AR 0 1
  1464. 2 Add Transaction 1 1
  1465. 3 Sales Invoice 1 2
  1466. 4 Reports 1 3
  1467. 5 Transactions 4 1
  1468. 6 Outstanding 4 2
  1469. 7 AR Aging 4 3
  1470. 9 Taxable Sales 4 4
  1471. 10 Non-Taxable 4 5
  1472. 11 Customers 1 4
  1473. 12 Add Customer 11 1
  1474. 13 Reports 11 2
  1475. 14 Search 13 1
  1476. 15 History 13 2
  1477. 16 Point of Sale 0 2
  1478. 17 Sale 16 1
  1479. 18 Open 16 2
  1480. 19 Receipts 16 3
  1481. 20 Close Till 16 4
  1482. 21 AP 0 3
  1483. 22 Add Transaction 21 1
  1484. 23 Vendor Invoice 21 2
  1485. 24 Reports 21 3
  1486. 25 Transactions 24 1
  1487. 26 Outstanding 24 2
  1488. 27 AP Aging 24 3
  1489. 28 Taxable 24 4
  1490. 29 Non-taxable 24 5
  1491. 30 Vendors 21 4
  1492. 31 Add Vendor 30 1
  1493. 32 Reports 30 2
  1494. 33 Search 32 1
  1495. 34 History 32 2
  1496. 35 Cash 0 4
  1497. 36 Receipt 35 1
  1498. 38 Payment 35 3
  1499. 37 Receipts 35 2
  1500. 39 Payments 35 4
  1501. 40 Transfer 35 5
  1502. 42 Receipts 41 1
  1503. 43 Payments 41 2
  1504. 44 Reconciliation 41 3
  1505. 41 Reports 35 7
  1506. 45 Reconciliation 35 6
  1507. 46 HR 0 5
  1508. 47 Employees 46 1
  1509. 48 Add Employee 47 1
  1510. 49 Search 47 2
  1511. 50 Order Entry 0 6
  1512. 51 Sales Order 50 1
  1513. 52 Purchase Order 50 2
  1514. 53 Reports 50 3
  1515. 54 Sales Orders 53 1
  1516. 55 Purchase Orders 53 2
  1517. 57 Sales Orders 56 1
  1518. 58 Purchase Orders 56 2
  1519. 56 Generate 50 4
  1520. 60 Consolidate 50 5
  1521. 61 Sales Orders 60 1
  1522. 62 Purchase Orders 60 2
  1523. 63 Shipping 0 7
  1524. 64 Ship 63 1
  1525. 65 Receive 63 2
  1526. 66 Transfer 63 3
  1527. 67 Quotations 0 8
  1528. 68 Quotation 67 1
  1529. 69 RFQ 67 2
  1530. 70 Reports 67 3
  1531. 71 Quotations 70 1
  1532. 72 RFQs 70 2
  1533. 73 General Journal 0 9
  1534. 74 Journal Entry 73 1
  1535. 75 Adjust Till 73 2
  1536. 76 Reports 73 3
  1537. 77 Goods and Services 0 10
  1538. 78 Add Part 77 1
  1539. 79 Add Service 77 2
  1540. 80 Add Assembly 77 3
  1541. 81 Add Overhead 77 4
  1542. 82 Add Group 77 5
  1543. 83 Add Pricegroup 77 6
  1544. 84 Stock Assembly 77 7
  1545. 85 Reports 77 8
  1546. 86 All Items 85 1
  1547. 87 Parts 85 2
  1548. 88 Requirements 85 3
  1549. 89 Services 85 4
  1550. 90 Labor 85 5
  1551. 91 Groups 85 6
  1552. 92 Pricegroups 85 7
  1553. 93 Assembly 85 8
  1554. 94 Components 85 9
  1555. 95 Translations 77 9
  1556. 96 Description 95 1
  1557. 97 Partsgroup 95 2
  1558. 98 Projects 0 11
  1559. 99 Add Project 98 1
  1560. 100 Add Timecard 98 2
  1561. 101 Generate 98 3
  1562. 102 Sales Orders 101 1
  1563. 103 Reports 98 4
  1564. 104 Search 103 1
  1565. 105 Transactions 103 2
  1566. 106 Time Cards 103 3
  1567. 107 Translations 98 5
  1568. 108 Description 107 1
  1569. 109 Reports 0 12
  1570. 110 Chart of Accounts 109 1
  1571. 111 Trial Balance 109 2
  1572. 112 Income Statement 109 3
  1573. 113 Balance Sheet 109 4
  1574. 114 Inventory Activity 109 5
  1575. 115 Recurring Transactions 0 13
  1576. 116 Batch Printing 0 14
  1577. 117 Sales Invoices 116 1
  1578. 118 Sales Orders 116 2
  1579. 119 Checks 116 3
  1580. 120 Work Orders 116 4
  1581. 121 Quotations 116 5
  1582. 122 Packing Lists 116 6
  1583. 123 Pick Lists 116 7
  1584. 124 Purchase Orders 116 8
  1585. 125 Bin Lists 116 9
  1586. 126 RFQs 116 10
  1587. 127 Time Cards 116 11
  1588. 128 System 0 15
  1589. 129 Audit Control 128 1
  1590. 130 Taxes 128 2
  1591. 131 Defaults 128 3
  1592. 132 Yearend 128 4
  1593. 133 Backup 128 5
  1594. 134 Send to File 133 1
  1595. 135 Send to Email 133 2
  1596. 136 Chart of Accounts 128 6
  1597. 137 Add Accounts 136 1
  1598. 138 List Accounts 136 2
  1599. 139 Add GIFI 136 3
  1600. 140 List GIFI 136 4
  1601. 141 Warehouses 128 7
  1602. 142 Add Warehouse 141 1
  1603. 143 List Warehouse 141 2
  1604. 144 Departments 128 8
  1605. 145 Add Department 144 1
  1606. 146 List Departments 144 2
  1607. 147 Type of Business 128 9
  1608. 148 Add Business 147 1
  1609. 149 List Businesses 147 2
  1610. 150 Language 128 10
  1611. 151 Add Language 150 1
  1612. 152 List Languages 150 2
  1613. 153 SIC 128 11
  1614. 154 Add SIC 153 1
  1615. 155 List SIC 153 2
  1616. 156 HTML Templates 128 12
  1617. 157 Income Statement 156 1
  1618. 158 Balance Sheet 156 2
  1619. 159 Invoice 156 3
  1620. 160 AR Transaction 156 4
  1621. 161 AP Transaction 156 5
  1622. 162 Packing List 156 6
  1623. 163 Pick List 156 7
  1624. 164 Sales Order 156 8
  1625. 165 Work Order 156 9
  1626. 166 Purchase Order 156 10
  1627. 167 Bin List 156 11
  1628. 168 Statement 156 12
  1629. 169 Quotation 156 13
  1630. 170 RFQ 156 14
  1631. 171 Timecard 156 15
  1632. 172 LaTeX Templates 128 13
  1633. 173 Invoice 172 1
  1634. 174 AR Transaction 172 2
  1635. 175 AP Transaction 172 3
  1636. 176 Packing List 172 4
  1637. 177 Pick List 172 5
  1638. 178 Sales Order 172 6
  1639. 179 Work Order 172 7
  1640. 180 Purchase Order 172 8
  1641. 181 Bin List 172 9
  1642. 182 Statement 172 10
  1643. 183 Check 172 11
  1644. 184 Receipt 172 12
  1645. 185 Quotation 172 13
  1646. 186 RFQ 172 14
  1647. 187 Timecard 172 15
  1648. 188 Text Templates 128 14
  1649. 189 POS Invoice 188 1
  1650. 190 Stylesheet 0 16
  1651. 191 Preferences 0 17
  1652. 192 New Window 0 18
  1653. 193 Logout 0 19
  1654. \.
  1655. --
  1656. -- Name: menu_node_parent_key; Type: CONSTRAINT; Schema: public; Owner: ledgersmb; Tablespace:
  1657. --
  1658. ALTER TABLE ONLY menu_node
  1659. ADD CONSTRAINT menu_node_parent_key UNIQUE (parent, "position");
  1660. --
  1661. -- Name: menu_node_pkey; Type: CONSTRAINT; Schema: public; Owner: ledgersmb; Tablespace:
  1662. --
  1663. ALTER TABLE ONLY menu_node
  1664. ADD CONSTRAINT menu_node_pkey PRIMARY KEY (id);
  1665. --
  1666. -- Name: menu_node_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: ledgersmb
  1667. --
  1668. ALTER TABLE ONLY menu_node
  1669. ADD CONSTRAINT menu_node_parent_fkey FOREIGN KEY (parent) REFERENCES menu_node(id);
  1670. CREATE TABLE menu_attribute (
  1671. node_id integer NOT NULL,
  1672. attribute character varying NOT NULL,
  1673. value character varying NOT NULL,
  1674. id serial NOT NULL
  1675. );
  1676. --
  1677. -- Name: menu_attribute_id_seq; Type: SEQUENCE SET; Schema: public; Owner: ledgersmb
  1678. --
  1679. SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('menu_attribute', 'id'), 536, true);
  1680. --
  1681. -- Data for Name: menu_attribute; Type: TABLE DATA; Schema: public; Owner: ledgersmb
  1682. --
  1683. COPY menu_attribute (node_id, attribute, value, id) FROM stdin;
  1684. 1 menu 1 1
  1685. 2 module ar.pl 2
  1686. 2 action add 3
  1687. 3 action add 4
  1688. 3 module is.pl 5
  1689. 3 type invoice 6
  1690. 4 menu 1 7
  1691. 5 module ar.pl 8
  1692. 5 action search 9
  1693. 5 nextsub transactions 10
  1694. 6 module ar.pl 12
  1695. 6 action search 13
  1696. 6 nextsub transactions 14
  1697. 7 module rp.pl 15
  1698. 7 action report 16
  1699. 7 report ar_aging 17
  1700. 9 module rp.pl 21
  1701. 9 action report 22
  1702. 9 report tax_collected 23
  1703. 10 module rp.pl 24
  1704. 10 action report 25
  1705. 10 report nontaxable_sales 26
  1706. 11 menu 1 27
  1707. 12 module ct.pl 28
  1708. 12 action add 29
  1709. 12 db customer 30
  1710. 13 menu 1 31
  1711. 14 module ct.pl 32
  1712. 14 db customer 34
  1713. 15 module ct.pl 35
  1714. 15 action add 36
  1715. 15 db customer 37
  1716. 14 action history 33
  1717. 16 menu 1 38
  1718. 17 module ps.pl 39
  1719. 17 action add 40
  1720. 17 nextsub openinvoices 41
  1721. 18 action openinvoices 42
  1722. 18 module ps.pl 43
  1723. 19 module ps.pl 44
  1724. 19 action receipts 46
  1725. 20 module rc.pl 47
  1726. 20 action till_closing 48
  1727. 20 pos true 49
  1728. 21 menu 1 50
  1729. 22 action add 52
  1730. 22 module ap.pl 51
  1731. 23 action add 53
  1732. 23 type invoice 55
  1733. 23 module ir.pl 54
  1734. 24 menu 1 56
  1735. 25 action search 58
  1736. 25 nextsub transactions 59
  1737. 25 module ap.pl 57
  1738. 26 action search 61
  1739. 26 nextsub transactions 62
  1740. 26 module ap.pl 60
  1741. 27 module rp.pl 63
  1742. 27 action report 64
  1743. 28 module rp.pl 66
  1744. 28 action report 67
  1745. 28 report tax_collected 68
  1746. 27 report tax_paid 65
  1747. 29 module rp.pl 69
  1748. 29 action report 70
  1749. 29 report report 71
  1750. 30 menu 1 72
  1751. 31 module ct.pl 73
  1752. 31 action add 74
  1753. 31 db vendor 75
  1754. 32 menu 1 76
  1755. 33 module ct.pl 77
  1756. 33 action history 79
  1757. 33 db vendor 78
  1758. 34 module ct.pl 80
  1759. 34 action add 81
  1760. 34 db vendor 82
  1761. 35 menu 1 83
  1762. 36 module cp.pl 84
  1763. 36 action payment 85
  1764. 36 type receipt 86
  1765. 37 module cp.pl 87
  1766. 38 module cp.pl 90
  1767. 38 action payment 91
  1768. 37 type receipt 89
  1769. 37 action payments 88
  1770. 38 type check 92
  1771. 39 module cp.pl 93
  1772. 39 type check 95
  1773. 39 action payments 94
  1774. 40 module gl.pl 96
  1775. 40 action add 97
  1776. 40 transfer 1 98
  1777. 41 menu 1 99
  1778. 42 module rp.pl 100
  1779. 42 action report 101
  1780. 42 report receipts 102
  1781. 43 module rp.pl 103
  1782. 43 action report 104
  1783. 43 report payments 105
  1784. 45 module rc.pl 106
  1785. 45 action reconciliation 107
  1786. 44 module rc.pl 108
  1787. 44 action reconciliation 109
  1788. 44 report 1 110
  1789. 46 menu 1 111
  1790. 47 menu 1 112
  1791. 48 module hr.pl 113
  1792. 48 action add 114
  1793. 48 db employee 115
  1794. 49 module hr.pl 116
  1795. 49 db employee 118
  1796. 49 action search 117
  1797. 50 menu 1 119
  1798. 51 module oe.pl 120
  1799. 51 action add 121
  1800. 51 type sales_order 122
  1801. 52 module oe.pl 123
  1802. 52 action add 124
  1803. 52 type purchase_order 125
  1804. 53 menu 1 126
  1805. 54 module oe.pl 127
  1806. 54 type sales_order 129
  1807. 54 action search 128
  1808. 55 module oe.pl 130
  1809. 55 type purchase_order 132
  1810. 55 action search 131
  1811. 56 menu 1 133
  1812. 57 module oe.pl 134
  1813. 57 action search 136
  1814. 58 module oe.pl 137
  1815. 58 action search 139
  1816. 57 type generate_sales_order 135
  1817. 58 type generate_purchase_order 138
  1818. 61 module oe.pl 140
  1819. 61 action search 141
  1820. 62 module oe.pl 143
  1821. 62 action search 144
  1822. 62 type consolidate_purchase_order 145
  1823. 61 type consolidate_sales_order 142
  1824. 63 menu 1 146
  1825. 64 module oe.pl 147
  1826. 64 action search 148
  1827. 65 module oe.pl 150
  1828. 65 action search 151
  1829. 65 type consolidate_sales_order 152
  1830. 64 type receive_order 149
  1831. 66 module oe.pl 153
  1832. 66 action search_transfer 154
  1833. 67 menu 1 155
  1834. 68 module oe.pl 156
  1835. 68 action add 157
  1836. 69 module oe.pl 159
  1837. 69 action add 160
  1838. 68 type sales_quotation 158
  1839. 69 type request_quotation 161
  1840. 70 menu 1 162
  1841. 71 module oe.pl 163
  1842. 71 type sales_quotation 165
  1843. 71 action search 164
  1844. 72 module oe.pl 166
  1845. 72 action search 168
  1846. 72 type request_quotation 167
  1847. 73 menu 1 169
  1848. 74 module gl.pl 170
  1849. 74 action add 171
  1850. 75 module gl.pl 172
  1851. 75 action add_pos_adjust 174
  1852. 75 rowcount 3 175
  1853. 75 pos_adjust 1 176
  1854. 75 reference Adjusting Till: (Till) Source: (Source) 177
  1855. 75 descripton Adjusting till due to data entry error 178
  1856. 76 module gl.pl 180
  1857. 76 action search 181
  1858. 77 menu 1 182
  1859. 78 module ic.pl 183
  1860. 78 action add 184
  1861. 78 item part 185
  1862. 79 module ic.pl 186
  1863. 79 action add 187
  1864. 79 item service 188
  1865. 80 module ic.pl 189
  1866. 80 action add 190
  1867. 81 module ic.pl 192
  1868. 81 action add 193
  1869. 81 item part 194
  1870. 80 item labor 191
  1871. 82 action add 195
  1872. 82 module pe.pl 196
  1873. 83 action add 198
  1874. 83 module pe.pl 199
  1875. 83 type partsgroup 200
  1876. 82 type pricegroup 197
  1877. 84 module ic.pl 202
  1878. 84 action stock_assembly 203
  1879. 85 menu 1 204
  1880. 86 module ic.pl 205
  1881. 87 action search 206
  1882. 86 action search 207
  1883. 87 module ic.pl 208
  1884. 86 searchitems all 209
  1885. 88 module ic.pl 211
  1886. 88 action requirements 212
  1887. 89 action search 213
  1888. 89 module ic.pl 214
  1889. 89 searchitems service 215
  1890. 87 searchitems part 210
  1891. 90 action search 216
  1892. 90 module ic.pl 217
  1893. 90 searchitems labor 218
  1894. 91 module pe.pl 221
  1895. 91 type pricegroup 222
  1896. 91 action search 220
  1897. 92 module pe.pl 224
  1898. 92 type partsgroup 225
  1899. 92 action search 223
  1900. 93 action search 226
  1901. 93 module ic.pl 227
  1902. 93 searchitems assembly 228
  1903. 94 action search 229
  1904. 94 module ic.pl 230
  1905. 94 searchitems component 231
  1906. 95 menu 1 232
  1907. 96 module pe.pl 233
  1908. 96 action translation 234
  1909. 96 translation description 235
  1910. 97 module pe.pl 236
  1911. 97 action translation 237
  1912. 97 translation partsgroup 238
  1913. 98 menu 1 239
  1914. 99 module pe.pl 240
  1915. 99 action add 241
  1916. 99 type project 242
  1917. 100 module jc.pl 243
  1918. 100 action add 244
  1919. 99 project project 245
  1920. 100 project project 246
  1921. 100 type timecard 247
  1922. 101 menu 1 248
  1923. 102 module pe.pl 249
  1924. 102 action project_sales_order 250
  1925. 102 menu 1 255
  1926. 104 module pe.pl 256
  1927. 104 type project 258
  1928. 104 action search 257
  1929. 105 action report 260
  1930. 105 report projects 261
  1931. 105 module rp.pl 262
  1932. 106 module jc.pl 263
  1933. 106 action search 264
  1934. 106 type timecard 265
  1935. 106 project project 266
  1936. 107 menu 1 268
  1937. 108 module pe.pl 269
  1938. 108 action translation 270
  1939. 108 translation project 271
  1940. 109 menu 1 272
  1941. 110 module ca.pl 273
  1942. 110 action chart_of_accounts 274
  1943. 111 action report 275
  1944. 111 module rp.pl 276
  1945. 111 report trial_balance 277
  1946. 112 action report 278
  1947. 112 module rp.pl 279
  1948. 112 report income_statement 280
  1949. 113 action report 281
  1950. 113 module rp.pl 282
  1951. 113 report balance_sheet 283
  1952. 114 action report 284
  1953. 114 module rp.pl 285
  1954. 114 report inv_activity 286
  1955. 115 action recurring_transactions 287
  1956. 115 module am.pl 288
  1957. 116 menu 1 289
  1958. 119 module bp.pl 290
  1959. 119 action search 291
  1960. 119 type check 292
  1961. 119 vc vendor 293
  1962. 117 module bp.pl 294
  1963. 117 action search 295
  1964. 117 vc customer 297
  1965. 118 module bp.pl 298
  1966. 118 action search 299
  1967. 118 vc customer 300
  1968. 118 type invoice 301
  1969. 117 type sales_order 296
  1970. 120 module bp.pl 302
  1971. 120 action search 303
  1972. 120 vc customer 304
  1973. 121 module bp.pl 306
  1974. 121 action search 307
  1975. 121 vc customer 308
  1976. 122 module bp.pl 310
  1977. 122 action search 311
  1978. 122 vc customer 312
  1979. 120 type work_order 305
  1980. 121 type sales_quotation 309
  1981. 122 type packing_list 313
  1982. 123 module bp.pl 314
  1983. 123 action search 315
  1984. 123 vc customer 316
  1985. 123 type pick_list 317
  1986. 124 module bp.pl 318
  1987. 124 action search 319
  1988. 124 vc vendor 321
  1989. 124 type purchase_order 320
  1990. 125 module bp.pl 322
  1991. 125 action search 323
  1992. 125 vc vendor 325
  1993. 126 module bp.pl 326
  1994. 126 action search 327
  1995. 126 vc vendor 329
  1996. 127 module bp.pl 330
  1997. 127 action search 331
  1998. 127 type timecard 332
  1999. 125 type bin_list 324
  2000. 126 type request_quotation 328
  2001. 127 vc employee 333
  2002. 128 menu 1 334
  2003. 129 module am.pl 337
  2004. 130 module am.pl 338
  2005. 131 module am.pl 339
  2006. 129 action audit_control 340
  2007. 130 taxes audit_control 341
  2008. 131 action defaults 342
  2009. 130 action taxes 343
  2010. 132 module am.pl 346
  2011. 132 action yearend 347
  2012. 133 menu 1 348
  2013. 134 module am.pl 349
  2014. 135 module am.pl 350
  2015. 134 action backup 351
  2016. 135 action backup 352
  2017. 134 media file 353
  2018. 135 media email 354
  2019. 136 menu 1 532
  2020. 137 module am.pl 355
  2021. 138 module am.pl 356
  2022. 139 module am.pl 357
  2023. 140 module am.pl 358
  2024. 137 action add_account 359
  2025. 138 action list_account 360
  2026. 139 action add_gifi 361
  2027. 140 action list_gifi 362
  2028. 141 menu 1 363
  2029. 142 module am.pl 364
  2030. 143 module am.pl 365
  2031. 142 action add_warehouse 366
  2032. 143 action list_warehouse 367
  2033. 144 menu 1 533
  2034. 145 module am.pl 368
  2035. 146 module am.pl 369
  2036. 145 action add_department 370
  2037. 146 action list_department 371
  2038. 147 menu 1 372
  2039. 148 module am.pl 373
  2040. 149 module am.pl 374
  2041. 148 action add_business 375
  2042. 149 action list_business 376
  2043. 150 menu 1 377
  2044. 151 module am.pl 378
  2045. 152 module am.pl 379
  2046. 151 action add_language 380
  2047. 152 action list_language 381
  2048. 153 menu 1 382
  2049. 154 module am.pl 383
  2050. 155 module am.pl 384
  2051. 154 action add_sic 385
  2052. 155 action list_sic 386
  2053. 156 menu 1 387
  2054. 157 module am.pl 388
  2055. 158 module am.pl 389
  2056. 159 module am.pl 390
  2057. 160 module am.pl 391
  2058. 161 module am.pl 392
  2059. 162 module am.pl 393
  2060. 163 module am.pl 394
  2061. 164 module am.pl 395
  2062. 165 module am.pl 396
  2063. 166 module am.pl 397
  2064. 167 module am.pl 398
  2065. 168 module am.pl 399
  2066. 169 module am.pl 400
  2067. 170 module am.pl 401
  2068. 171 module am.pl 402
  2069. 157 action list_templates 403
  2070. 158 action list_templates 404
  2071. 159 action list_templates 405
  2072. 160 action list_templates 406
  2073. 161 action list_templates 407
  2074. 162 action list_templates 408
  2075. 163 action list_templates 409
  2076. 164 action list_templates 410
  2077. 165 action list_templates 411
  2078. 166 action list_templates 412
  2079. 167 action list_templates 413
  2080. 168 action list_templates 414
  2081. 169 action list_templates 415
  2082. 170 action list_templates 416
  2083. 171 action list_templates 417
  2084. 157 template income_statement 418
  2085. 158 template balance_sheet 419
  2086. 159 template invoice 420
  2087. 160 template ar_transaction 421
  2088. 161 template ap_transaction 422
  2089. 162 template packing_list 423
  2090. 163 template pick_list 424
  2091. 164 template sales_order 425
  2092. 165 template work_order 426
  2093. 166 template purchase_order 427
  2094. 167 template bin_list 428
  2095. 168 template statement 429
  2096. 169 template quotation 430
  2097. 170 template rfq 431
  2098. 171 template timecard 432
  2099. 157 format HTML 433
  2100. 158 format HTML 434
  2101. 159 format HTML 435
  2102. 160 format HTML 436
  2103. 161 format HTML 437
  2104. 162 format HTML 438
  2105. 163 format HTML 439
  2106. 164 format HTML 440
  2107. 165 format HTML 441
  2108. 166 format HTML 442
  2109. 167 format HTML 443
  2110. 168 format HTML 444
  2111. 169 format HTML 445
  2112. 170 format HTML 446
  2113. 171 format HTML 447
  2114. 172 menu 1 448
  2115. 173 action list_templates 449
  2116. 174 action list_templates 450
  2117. 175 action list_templates 451
  2118. 176 action list_templates 452
  2119. 177 action list_templates 453
  2120. 178 action list_templates 454
  2121. 179 action list_templates 455
  2122. 180 action list_templates 456
  2123. 181 action list_templates 457
  2124. 182 action list_templates 458
  2125. 183 action list_templates 459
  2126. 184 action list_templates 460
  2127. 185 action list_templates 461
  2128. 186 action list_templates 462
  2129. 187 action list_templates 463
  2130. 173 module am.pl 464
  2131. 174 module am.pl 465
  2132. 175 module am.pl 466
  2133. 176 module am.pl 467
  2134. 177 module am.pl 468
  2135. 178 module am.pl 469
  2136. 179 module am.pl 470
  2137. 180 module am.pl 471
  2138. 181 module am.pl 472
  2139. 182 module am.pl 473
  2140. 183 module am.pl 474
  2141. 184 module am.pl 475
  2142. 185 module am.pl 476
  2143. 186 module am.pl 477
  2144. 187 module am.pl 478
  2145. 173 format LATEX 479
  2146. 174 format LATEX 480
  2147. 175 format LATEX 481
  2148. 176 format LATEX 482
  2149. 177 format LATEX 483
  2150. 178 format LATEX 484
  2151. 179 format LATEX 485
  2152. 180 format LATEX 486
  2153. 181 format LATEX 487
  2154. 182 format LATEX 488
  2155. 183 format LATEX 489
  2156. 184 format LATEX 490
  2157. 185 format LATEX 491
  2158. 186 format LATEX 492
  2159. 187 format LATEX 493
  2160. 173 template invoice 506
  2161. 174 template ar_transaction 507
  2162. 175 template ap_transaction 508
  2163. 176 template packing_list 509
  2164. 177 template pick_list 510
  2165. 178 template sales_order 511
  2166. 179 template work_order 512
  2167. 180 template purchase_order 513
  2168. 181 template bin_list 514
  2169. 182 template statement 515
  2170. 185 template quotation 518
  2171. 186 template rfq 519
  2172. 187 template timecard 520
  2173. 183 template check 516
  2174. 184 template receipt 517
  2175. 188 menu 1 521
  2176. 189 module am.pl 522
  2177. 189 action list_templates 523
  2178. 189 template pos_invoice 524
  2179. 189 format TEXT 525
  2180. 190 action display_stylesheet 526
  2181. 190 module am.pl 527
  2182. 191 module am.pl 528
  2183. 191 action config 529
  2184. 193 module login.pl 532
  2185. 193 action logout 533
  2186. 193 target _top 534
  2187. 192 menu 1 530
  2188. 192 new 1 531
  2189. \.
  2190. --
  2191. -- Name: menu_attribute_id_key; Type: CONSTRAINT; Schema: public; Owner: ledgersmb; Tablespace:
  2192. --
  2193. ALTER TABLE ONLY menu_attribute
  2194. ADD CONSTRAINT menu_attribute_id_key UNIQUE (id);
  2195. --
  2196. -- Name: menu_attribute_pkey; Type: CONSTRAINT; Schema: public; Owner: ledgersmb; Tablespace:
  2197. --
  2198. ALTER TABLE ONLY menu_attribute
  2199. ADD CONSTRAINT menu_attribute_pkey PRIMARY KEY (node_id, attribute);
  2200. --
  2201. -- Name: menu_attribute_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: ledgersmb
  2202. --
  2203. ALTER TABLE ONLY menu_attribute
  2204. ADD CONSTRAINT menu_attribute_node_id_fkey FOREIGN KEY (node_id) REFERENCES menu_node(id);
  2205. --
  2206. -- PostgreSQL database dump complete
  2207. --
  2208. --
  2209. CREATE TABLE menu_acl (
  2210. id serial NOT NULL,
  2211. role_name character varying,
  2212. acl_type character varying,
  2213. node_id integer,
  2214. CONSTRAINT menu_acl_acl_type_check CHECK ((((acl_type)::text = 'allow'::text) OR ((acl_type)::text = 'deny'::text)))
  2215. );
  2216. ALTER TABLE ONLY menu_acl
  2217. ADD CONSTRAINT menu_acl_pkey PRIMARY KEY (id);
  2218. ALTER TABLE ONLY menu_acl
  2219. ADD CONSTRAINT menu_acl_node_id_fkey FOREIGN KEY (node_id) REFERENCES menu_node(id);
  2220. --
  2221. -- PostgreSQL database dump complete
  2222. --
  2223. CREATE TYPE menu_item AS (
  2224. position int,
  2225. id int,
  2226. level int,
  2227. label varchar,
  2228. path varchar,
  2229. args varchar[]
  2230. );
  2231. CREATE OR REPLACE FUNCTION menu_generate() RETURNS SETOF menu_item AS
  2232. $$
  2233. DECLARE
  2234. item menu_item;
  2235. arg menu_attribute%ROWTYPE;
  2236. BEGIN
  2237. FOR item IN
  2238. SELECT n.position, n.id, c.level, n.label, c.path, '{}'
  2239. FROM connectby('menu_node', 'id', 'parent', 'position', '0',
  2240. 0, ',')
  2241. c(id integer, parent integer, "level" integer,
  2242. path text, list_order integer)
  2243. JOIN menu_node n USING(id)
  2244. LOOP
  2245. FOR arg IN
  2246. SELECT *
  2247. FROM menu_attribute
  2248. WHERE node_id = item.id
  2249. LOOP
  2250. item.args := item.args ||
  2251. (arg.attribute || '=' || arg.value)::varchar;
  2252. END LOOP;
  2253. RETURN NEXT item;
  2254. END LOOP;
  2255. END;
  2256. $$ language plpgsql;
  2257. --
  2258. -- PostgreSQL database dump
  2259. --
  2260. CREATE VIEW menu_friendly AS
  2261. SELECT t."level", t.path, t.list_order, (repeat(' '::text, (2 * t."level")) || (n.label)::text) AS label, n.id, n."position" FROM (connectby('menu_node'::text, 'id'::text, 'parent'::text, 'position'::text, '0'::text, 0, ','::text) t(id integer, parent integer, "level" integer, path text, list_order integer) JOIN menu_node n USING (id));
  2262. ALTER TABLE public.menu_friendly OWNER TO ledgersmb;
  2263. --
  2264. -- PostgreSQL database dump complete
  2265. --