1. Atualizar sequência de RPS

--select tiideal_gerasequencianotas(character varying, character varying, numeric, character varying);

--'data de 28/01/2016, 'data para 28/01/2016', nr sequencia -1,'id_tipo documento')

select tiideal_gerasequencianotas('14/07/2017', '14/07/2017', 31794, '40EE9B1CD3B345FABEFDA62B407B407F')

41BAE58E4E6B48D5A2FEB03FF33A3211

select * from c_invoice where c_invoice_id = '41BAE58E4E6B48D5A2FEB03FF33A3211'

select * from c_invoice where dateinvoiced = '2016-08-17 00:00:00'

update c_invoice
set dateinvoiced = '2016-08-15 00:00:00'
where dateinvoiced = '2016-08-17 00:00:00' and docstatus = 'DR'


2. Atualizar datas na nota fiscal

begin transaction;

alter database c_invoice disable trigger all;
update c_invoice
set dateinvoiced = to_date('06/11/2018', 'DD/MM/YYYY')
where dateinvoiced >= to_date('01/11/2018', 'DD/MM/YYYY') AND dateinvoiced < to_date('01/12/2018', 'DD/MM/YYYY')
and issotrx = 'Y'
and ad_org_id = '540F865E2D6E401F98B7922AADA93EB3'
and coalesce(trim(documentno),'') <> ''
;
alter database c_invoice enable trigger all;

commit;