CREATE TABLE IF NOT EXISTS public.pag_aux_recibo_baixa ( sequencia integer NOT NULL, usuario integer NOT NULL, data date NOT NULL, hora time without time zone NOT NULL, observacao character varying NOT NULL, filial_for integer NOT NULL, fornecedor integer NOT NULL, selecionado_valor_duplicata_anterior numeric(18,6) NOT NULL, selecionado_valor_juros_anterior numeric(18,6) NOT NULL, selecionado_valor_multa_anterior numeric(18,6) NOT NULL, selecionado_valor_desconto_anterior numeric(18,6) NOT NULL, selecionado_valor_liquido_anterior numeric(18,6) NOT NULL, selecionado_valor_pago_anterior numeric(18,6) NOT NULL, selecionado_valor_restante_anterior numeric(18,6) NOT NULL, total_pagamento numeric(18,6) NOT NULL, total_aberto_anterior numeric(18,6) NOT NULL, total_aberto_final numeric(18,6) NOT NULL, total_credito_anterior numeric(18,6) NOT NULL, total_credito_usado numeric(18,6) NOT NULL, total_credito_final numeric(18,6) NOT NULL, situacao character varying(1) NOT NULL, total_credito_gerado numeric(18,6) NOT NULL, CONSTRAINT pk_pag_aux_recibo_baixa PRIMARY KEY (sequencia) ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.pag_aux_recibo_baixa OWNER to postgres; COMMENT ON TABLE public.pag_aux_recibo_baixa IS 'Tabela Auxiliar do Recibo de baixa da duplicata a pagar'; CREATE TABLE IF NOT EXISTS public.pag_aux_recibo_baixa_item ( recibo integer NOT NULL, sequencia integer NOT NULL, produto integer NOT NULL, quantidade numeric(18,6) NOT NULL, preco numeric(18,6) NOT NULL, preco_total numeric(18,6) NOT NULL, data_entrada date NOT NULL, CONSTRAINT pk_pag_aux_recibo_baixa_item PRIMARY KEY (recibo, sequencia), CONSTRAINT fk_pag_aux_recibo_baixa_item FOREIGN KEY (recibo) REFERENCES public.pag_aux_recibo_baixa (sequencia) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.pag_aux_recibo_baixa_item OWNER to postgres; COMMENT ON TABLE public.pag_recibo_baixa_item IS 'Tabela Auxiliar para o Recibo com os Itens das Duplicatas'; CREATE TABLE IF NOT EXISTS public.pag_aux_recibo_baixa_duplicata ( recibo integer NOT NULL, filial_dup integer NOT NULL, sequencia_duplicata integer NOT NULL, vlr_restante numeric(18,6) NOT NULL, vlr_liquido numeric(18,6) NOT NULL, vlr_pago numeric(18,6) NOT NULL, CONSTRAINT pk_pag_aux_recibo_baixa_duplicata PRIMARY KEY (recibo, filial_dup, sequencia_duplicata), CONSTRAINT fk_pag_aux_recibo_baixa_duplicata_recibo FOREIGN KEY (recibo) REFERENCES public.pag_aux_recibo_baixa (sequencia) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.pag_aux_recibo_baixa_duplicata OWNER to postgres; COMMENT ON TABLE public.pag_aux_recibo_baixa_duplicata IS 'Tabela Auxiliar para o Recibo com Sequencia das duplicatas da baixa da duplicata a pagar'; CREATE TABLE IF NOT EXISTS public.pag_aux_recibo_baixa_duplicata_desconto ( recibo integer NOT NULL, filial_dup integer NOT NULL, sequencia_duplicata integer NOT NULL, sequencia_desconto integer NOT NULL, vlr_desconto numeric(18,6) NOT NULL, observacao character varying COLLATE pg_catalog."default" NOT NULL, CONSTRAINT pk_pag_aux_recibo_baixa_duplicata_desconto PRIMARY KEY (recibo, filial_dup, sequencia_duplicata, sequencia_desconto), CONSTRAINT fk_pag_aux_recibo_baixa_duplicata_desconto FOREIGN KEY (recibo) REFERENCES public.pag_aux_recibo_baixa (sequencia) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.pag_aux_recibo_baixa_duplicata_desconto OWNER to postgres; COMMENT ON TABLE public.pag_aux_recibo_baixa_duplicata_desconto IS 'Tabela Auxiliar para o Recibo com os Descontos das duplicatas da baixa da duplicata a pagar'; CREATE TABLE IF NOT EXISTS public.pag_aux_recibo_baixa_cheque_emitido ( recibo integer NOT NULL, banco integer NOT NULL, agencia character varying(10) COLLATE pg_catalog."default" NOT NULL, conta character varying(12) COLLATE pg_catalog."default" NOT NULL, numero_cheque character varying(14) COLLATE pg_catalog."default" NOT NULL, CONSTRAINT pk_pag_aux_recibo_baixa_cheque_emitido PRIMARY KEY (recibo, banco, agencia, conta, numero_cheque), CONSTRAINT fk_pag_aux_recibo_baixa_cheque_emitido_recibo FOREIGN KEY (recibo) REFERENCES public.pag_aux_recibo_baixa (sequencia) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.pag_aux_recibo_baixa_cheque_emitido OWNER to postgres; COMMENT ON TABLE public.pag_aux_recibo_baixa_cheque_emitido IS 'Tabela Auxiliar para o Recibo com os Cheques Emitidos na baixa da duplicata a pagar'; CREATE TABLE IF NOT EXISTS public.pag_aux_recibo_baixa_cheque_recebido ( recibo integer NOT NULL, sequencia_cheque integer NOT NULL, CONSTRAINT pk_pag_aux_recibo_baixa_cheque_recebidoo PRIMARY KEY (recibo, sequencia_cheque), CONSTRAINT fk_pag_aux_recibo_baixa_cheque_recebidoo_recibo FOREIGN KEY (recibo) REFERENCES public.pag_aux_recibo_baixa (sequencia) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.pag_aux_recibo_baixa_cheque_recebido OWNER to postgres; COMMENT ON TABLE public.pag_aux_recibo_baixa_cheque_recebido IS 'Tabela Auxiliar para o Recibo com Sequencia dos Cheques Recebidos na baixa da duplicata a pagar'; CREATE TABLE IF NOT EXISTS public.pag_aux_recibo_baixa_pagamento ( recibo integer NOT NULL, sequencia integer NOT NULL, tipo_pagamento integer NOT NULL, valor numeric(18,6) NOT NULL, identificacao_pix character varying(100) COLLATE pg_catalog."default" NOT NULL, data_pagamento date NOT NULL, data_credito date NOT NULL, CONSTRAINT pk_pag_aux_recibo_baixa_pagamento PRIMARY KEY (recibo, sequencia), CONSTRAINT fk_pag_aux_recibo_baixa_pagamento_recibo FOREIGN KEY (recibo) REFERENCES public.pag_aux_recibo_baixa (sequencia) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.pag_aux_recibo_baixa_pagamento OWNER to postgres; COMMENT ON TABLE public.pag_aux_recibo_baixa_pagamento IS 'Tabela Auxiliar do Recibo para o Pagamento de baixa da duplicata a pagar';