ALTER TABLE TBPDV
    ADD IMPRIMIR_ROMANEIO INTEGER DEFAULT 0 NOT NULL;

COMMENT ON COLUMN TBPDV.IMPRIMIR_ROMANEIO IS
'IMPRIMIR ROMANEIO AO FINALIZAR VENDA
0 - NAO; 1 - SIM;';





CREATE INDEX ITBTRANSACAO_PIX_10
ON TBTRANSACAO_PIX (ENDTOEND_ID);


SET TERM ^ ;

CREATE OR ALTER trigger ttbpdv_cfe_forma_pagamento_b06i for tbpdv_cfe_forma_pagamento
active before insert position 6
AS
BEGIN
    IF(COALESCE(NEW.PARCELAS, 0) = 0) THEN
    BEGIN
        NEW.PARCELAS = 1;
    END

    IF(COALESCE(NEW.TRANSACAO_PIX_ID, 0) = 0 AND CHAR_LENGTH(COALESCE(NEW.TRANSACAO_PIX_BB, '')) > 0 AND COALESCE(NEW.TRANSACAO_PIX_BB, '') <> '0') THEN
    BEGIN
        NEW.TRANSACAO_PIX_ID = COALESCE((SELECT FIRST 1 T.ID FROM TBTRANSACAO_PIX T WHERE T.ENDTOEND_ID = NEW.TRANSACAO_PIX_BB), 0);

    END
END
^

SET TERM ; ^

