/*order 502396*/

COMMENT ON COLUMN COSTCENTERHISTINVDATA.ORIGIN IS '0 = Initial invoice
1 = Correction invoice
2 = Correction gap first invoice
3 = Correction gap previous invoice
9 = In-arrear invoice';

insert into invoicecorrectiontype i
  (i.invoicecorrectiontype_id,
   code,
   factorydescription,
   systemuser_id,
   timestamp,
   debitcredit,
   sequencenumber,
   active)
  select seq_invoicelinesubtype.nextval,
         111,
         'Correction for not yet invoiced period',
         getminsystemuser(),
         sysdate,
         'D',
         11,
         'Y'
    from dual;

insert into invoicecorrectiontype_desc
  (invoicecorrectiontype_id,
   language_id,
   description,
   systemuser_id,
   timestamp)
  select i.invoicecorrectiontype_id,
         l.language_id,
         i.factorydescription,
         getminsystemuser(),
         sysdate
    from invoicecorrectiontype i, languages l
   where i.code = 111 and l.translatedescription = 'Y';