--
-- PostgreSQL database dump
--

-- Dumped from database version 13.13 (Debian 13.13-0+deb11u1)
-- Dumped by pg_dump version 13.13 (Debian 13.13-0+deb11u1)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: ts_trigger(); Type: FUNCTION; Schema: public; Owner: dalyw
--

CREATE FUNCTION public.ts_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	IF (tg_op = 'INSERT') THEN
	   NEW.created = current_timestamp;
	   NEW.last_update = current_timestamp;
	END IF;

	IF (tg_op = 'UPDATE') THEN
	   NEW.last_update = current_timestamp;
	END IF;

	RETURN NEW;

END;
$$;


ALTER FUNCTION public.ts_trigger() OWNER TO dalyw;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: accounts; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.accounts (
    acct_no character(20) NOT NULL,
    title character varying(255) DEFAULT NULL::character varying,
    acct_type character(1) DEFAULT NULL::bpchar,
    sign_type character(1) DEFAULT NULL::bpchar,
    created date,
    last_update date
);


ALTER TABLE public.accounts OWNER TO dalyw;

--
-- Name: doc_lines; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.doc_lines (
    doc_id integer NOT NULL,
    line_no integer,
    acct_no character(20) DEFAULT NULL::bpchar,
    debit numeric(14,2) DEFAULT NULL::numeric,
    credit numeric(14,2) DEFAULT NULL::numeric,
    company character(20) NOT NULL,
    created date,
    last_update date
);


ALTER TABLE public.doc_lines OWNER TO dalyw;

--
-- Name: document; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.document (
    doc_id integer NOT NULL,
    company character(20) NOT NULL,
    journal character(20) NOT NULL,
    name character(50) NOT NULL,
    doc_date date NOT NULL,
    description character varying(4096) DEFAULT NULL::character varying,
    period character(10),
    created date,
    last_update date
);


ALTER TABLE public.document OWNER TO dalyw;

--
-- Name: docs; Type: VIEW; Schema: public; Owner: dalyw
--

CREATE VIEW public.docs AS
 SELECT btrim((document.journal)::text) AS jrnl,
    btrim((document.name)::text) AS doc,
    document.doc_date,
    document.period,
    btrim((doc_lines.acct_no)::text) AS acct,
    document.description,
    doc_lines.debit,
    doc_lines.credit
   FROM (public.document
     JOIN public.doc_lines ON ((document.doc_id = doc_lines.doc_id)));


ALTER TABLE public.docs OWNER TO dalyw;

--
-- Name: acct_detail; Type: VIEW; Schema: public; Owner: dalyw
--

CREATE VIEW public.acct_detail AS
 SELECT accounts.acct_no,
    accounts.title,
    docs.doc,
    docs.doc_date,
    docs.period,
    docs.description,
    docs.debit,
    docs.credit
   FROM (public.accounts
     LEFT JOIN public.docs ON (((accounts.acct_no)::text = docs.acct)));


ALTER TABLE public.acct_detail OWNER TO dalyw;

--
-- Name: acct_type; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.acct_type (
    line integer,
    code character(1),
    short character(10),
    long character(255),
    created date,
    last_update date
);


ALTER TABLE public.acct_type OWNER TO dalyw;

--
-- Name: accts; Type: VIEW; Schema: public; Owner: dalyw
--

CREATE VIEW public.accts AS
 SELECT btrim((accounts.acct_no)::text) AS acct,
    accounts.title,
    accounts.acct_type,
    accounts.sign_type
   FROM public.accounts
  ORDER BY accounts.acct_no;


ALTER TABLE public.accts OWNER TO dalyw;

--
-- Name: balance_type; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.balance_type (
    line integer,
    code character(1),
    short character(10),
    long character(255)
);


ALTER TABLE public.balance_type OWNER TO dalyw;

--
-- Name: config; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.config (
    name character(50) NOT NULL,
    value character varying(255) DEFAULT NULL::character varying,
    created date,
    last_update date
);


ALTER TABLE public.config OWNER TO dalyw;

--
-- Name: document_doc_id_seq; Type: SEQUENCE; Schema: public; Owner: dalyw
--

CREATE SEQUENCE public.document_doc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.document_doc_id_seq OWNER TO dalyw;

--
-- Name: journal; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.journal (
    jrnl character(10) NOT NULL,
    title character varying(255) DEFAULT NULL::character varying,
    account character(20)
);


ALTER TABLE public.journal OWNER TO dalyw;

--
-- Name: periods; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.periods (
    period character(10) NOT NULL,
    begin_date date NOT NULL,
    end_date date NOT NULL,
    year_end boolean,
    created date,
    last_update date
);


ALTER TABLE public.periods OWNER TO dalyw;

--
-- Name: sign_type; Type: TABLE; Schema: public; Owner: dalyw
--

CREATE TABLE public.sign_type (
    line integer,
    code character(1),
    short character varying(10),
    long character varying(255)
);


ALTER TABLE public.sign_type OWNER TO dalyw;

--
-- Data for Name: accounts; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.accounts (acct_no, title, acct_type, sign_type, created, last_update) FROM stdin;
3100                	Common Stock	b	c	2024-01-12	2024-01-12
1010                	Cash	b	d	2024-01-12	2024-01-12
1110                	Accounts Receivable	b	d	2024-01-12	2024-01-12
1310                	Inventory	b	d	2024-01-12	2024-01-12
1320                	Labor in inventory	b	d	2024-01-12	2024-01-12
1390                	Overhead in inventory	b	d	2024-01-12	2024-01-12
1410                	Prepaid expense	b	d	2024-01-12	2024-01-12
1510                	Plant	b	d	2024-01-12	2024-01-12
1520                	Equipment	b	d	2024-01-12	2024-01-12
1590                	Accumulated Depreciation	b	d	2024-01-12	2024-01-12
2010                	Current notes payable	b	c	2024-01-12	2024-01-12
2110                	Accounts payable	b	c	2024-01-12	2024-01-12
2310                	Accrued expense	b	c	2024-01-12	2024-01-12
2710                	Long-term debt	b	c	2024-01-12	2024-01-12
5010                	Sales	i	c	2024-01-12	2024-01-12
6010                	Material cost of sales	i	d	2024-01-12	2024-01-12
6110                	Labor cost of sales	i	d	2024-01-12	2024-01-12
6910                	Overhead cost of sales	i	d	2024-01-12	2024-01-12
7010                	Salaries and wages	i	d	2024-01-12	2024-01-12
7020                	Payroll taxes	i	d	2024-01-12	2024-01-12
7030                	Health insurance	i	d	2024-01-12	2024-01-12
7110                	Janitorial supplies	i	d	2024-01-12	2024-01-12
7120                	Building repairs and maintenance	i	d	2024-01-12	2024-01-12
7150                	Utilities	i	d	2024-01-12	2024-01-12
7210                	Professional fees	i	d	2024-01-12	2024-01-12
7510                	Insurance	i	d	2024-01-12	2024-01-12
7610                	Interest	i	d	2024-01-12	2024-01-12
8910                	Federal income taxes	i	d	2024-01-12	2024-01-12
8920                	State income taxes	i	d	2024-01-12	2024-01-12
3990                	Retained Earnings	r	c	2024-01-12	2024-01-12
\.


--
-- Data for Name: acct_type; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.acct_type (line, code, short, long, created, last_update) FROM stdin;
1	b	B/S       	Balance Sheet                                                                                                                                                                                                                                                  	\N	\N
2	r	R/E       	Retained earnings                                                                                                                                                                                                                                              	\N	\N
3	i	Inc       	Income account                                                                                                                                                                                                                                                 	\N	\N
\.


--
-- Data for Name: balance_type; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.balance_type (line, code, short, long) FROM stdin;
1	d	Dr        	Debit balance                                                                                                                                                                                                                                                  
2	c	Cr        	Credit balance                                                                                                                                                                                                                                                 
\.


--
-- Data for Name: config; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.config (name, value, created, last_update) FROM stdin;
accountFormat                                     	0000	2024-01-12	2024-01-12
balanceFormat                                     	555,555,510.00	2024-01-12	2024-01-12
begin_desc                                        	Begining trial balance.	2024-01-12	2024-01-12
begin_document                                    	BEG_BAL	2024-01-12	2024-01-12
begin_journal                                     	gj	2024-01-12	2024-01-12
\.


--
-- Data for Name: doc_lines; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.doc_lines (doc_id, line_no, acct_no, debit, credit, company, created, last_update) FROM stdin;
\.


--
-- Data for Name: document; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.document (doc_id, company, journal, name, doc_date, description, period, created, last_update) FROM stdin;
\.


--
-- Data for Name: journal; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.journal (jrnl, title, account) FROM stdin;
gj        	General Journal	\N
cd        	Cash Disbursements	\N
cr        	Cash Receipts	\N
pr        	Purchases	\N
\.


--
-- Data for Name: periods; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.periods (period, begin_date, end_date, year_end, created, last_update) FROM stdin;
2023-01   	2023-01-01	2023-03-31	f	2024-01-04	2024-01-04
2023-02   	2023-04-01	2023-06-30	f	2024-01-04	2024-01-04
2023-03   	2023-07-01	2023-09-30	f	2024-01-04	2024-01-04
2023-04   	2023-10-01	2023-12-31	t	2024-01-04	2024-01-04
2024-01   	2024-01-01	2024-03-31	f	2024-01-06	2024-01-06
\.


--
-- Data for Name: sign_type; Type: TABLE DATA; Schema: public; Owner: dalyw
--

COPY public.sign_type (line, code, short, long) FROM stdin;
1	d	Dr	Debit balance account
2	c	Cr	Credit balance account
\.


--
-- Name: document_doc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dalyw
--

SELECT pg_catalog.setval('public.document_doc_id_seq', 1, false);


--
-- Name: accounts accounts_stamp; Type: TRIGGER; Schema: public; Owner: dalyw
--

CREATE TRIGGER accounts_stamp BEFORE INSERT OR UPDATE ON public.accounts FOR EACH ROW EXECUTE FUNCTION public.ts_trigger();


--
-- Name: config config_stamp; Type: TRIGGER; Schema: public; Owner: dalyw
--

CREATE TRIGGER config_stamp BEFORE INSERT OR UPDATE ON public.config FOR EACH ROW EXECUTE FUNCTION public.ts_trigger();


--
-- Name: doc_lines doc_lines_stamp; Type: TRIGGER; Schema: public; Owner: dalyw
--

CREATE TRIGGER doc_lines_stamp BEFORE INSERT OR UPDATE ON public.doc_lines FOR EACH ROW EXECUTE FUNCTION public.ts_trigger();


--
-- Name: document document_stamp; Type: TRIGGER; Schema: public; Owner: dalyw
--

CREATE TRIGGER document_stamp BEFORE INSERT OR UPDATE ON public.document FOR EACH ROW EXECUTE FUNCTION public.ts_trigger();


--
-- Name: periods periods_stamp; Type: TRIGGER; Schema: public; Owner: dalyw
--

CREATE TRIGGER periods_stamp BEFORE INSERT OR UPDATE ON public.periods FOR EACH ROW EXECUTE FUNCTION public.ts_trigger();


--
-- PostgreSQL database dump complete
--

