ALTER TABLE _setup_main ADD COLUMN raktarbiz_ertek_a_bizonylaton smallint;
ALTER TABLE _setup_main ALTER COLUMN raktarbiz_ertek_a_bizonylaton SET STORAGE PLAIN;
ALTER TABLE _setup_main ALTER COLUMN raktarbiz_ertek_a_bizonylaton SET DEFAULT 1;

ALTER TABLE _setup_main ADD COLUMN szallito_ertek_a_bizonylaton smallint;
ALTER TABLE _setup_main ALTER COLUMN szallito_ertek_a_bizonylaton SET STORAGE PLAIN;
ALTER TABLE _setup_main ALTER COLUMN szallito_ertek_a_bizonylaton SET DEFAULT 1;

UPDATE _setup_main SET raktarbiz_ertek_a_bizonylaton = 1;
UPDATE _setup_main SET szallito_ertek_a_bizonylaton  = 1;

CREATE TABLE _prev_bizonylatszoveg
(
  kod serial NOT NULL,
  sor_kod integer,
  nev character varying(100),
  sor2 character varying(100),
  sor3 character varying(100),
  sor4 character varying(100),
  tetel_azonosito_kod character varying(20),
  mee character varying(20),
  afa_leiras character varying(100),
  CONSTRAINT _prev_bizonylatszoveg_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;

CREATE TABLE _prev_bizonylatszoveg_fej
(
  kod serial NOT NULL,
  partner_nev character varying(120),
  partner_orszag character varying(50),
  partner_iszam character varying(20),
  partner_telepules character varying(60),
  partner_cim character varying(60),
  partner_adoszam character varying(20),
  mozgasnem_nev character varying(100),
  fizetesmod_nev character varying(50),
  munkatars_nev character varying(60),
  fej_kod integer,
  partner_eng_szam character varying(30),
  partner_ostermeloi_szam character varying(30),
  fizetesmod_zaradek character varying(100),
  partner_postacim_nev character varying(120),
  partner_postacim_orszag character varying(50),
  partner_postacim_iszam character varying(20),
  partner_postacim_telepules character varying(60),
  partner_postacim_cim character varying(60),
  kiallito_sorok text,
  vevo_sorok text,
  partner_adoazonosito character varying(20),
  partner_osterm_regszam character varying(20),
  partner_csalgazd_nyilv_szam character varying(20),
  partner_taj_szam character varying(20),
  partner_szuletesi_datum date,
  partner_szuletesi_hely character varying(60),
  partner_szuletesi_nev character varying(60),
  partner_anyja_neve character varying(60),
  CONSTRAINT _prev_bizonylatszoveg_fej_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;

CREATE TABLE _prev_raktar_mozgas
(
  kod serial NOT NULL,
  tetel_kod integer NOT NULL,
  forras_raktar_kod integer NOT NULL,
  mennyiseg double precision NOT NULL DEFAULT 0,
  cel_raktar_kod integer,
  cel_raktar_ujkeszlet double precision DEFAULT 0,
  raktar_mozgas_bizonylat character(20),
  afakulcs integer,
  netto_osszeg double precision,
  brutto_osszeg double precision,
  netto_osszeg_huf double precision,
  brutto_osszeg_huf double precision,
  netto_arbevetel double precision,
  netto_kedvezmeny double precision,
  netto_kedvezmeny_huf double precision,
  netto_arbevetel_huf double precision,
  brutto_arbevetel_huf double precision,
  brutto_arbevetel double precision,
  tetel_tipus smallint,
  megjegyzes text,
  netto_egysegar double precision,
  brutto_egysegar double precision,
  brutto_egysegar_huf double precision,
  netto_egysegar_huf double precision,
  mennyiseg_szamlazva double precision DEFAULT 0,
  szallito_szama character varying(20) DEFAULT '',
  szallitos_tetel_kod integer,
  csak_fobizonylat_tetel smallint,
  fej_kod integer,
  mee_kod integer,
  forras_raktar_atlagar double precision DEFAULT 0,
  cel_raktar_atlagar double precision DEFAULT 0,
  forras_raktar_ujkeszlet double precision DEFAULT 0,
  akcios integer DEFAULT 0,
  CONSTRAINT _prev_raktar_mozgas_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;

CREATE TABLE _prev_raktar_mozgas_egyedi
(
  kod serial NOT NULL,
  rm_kod integer NOT NULL,
  egyedi_azonosito_kod integer NOT NULL,
  mennyiseg double precision NOT NULL,
  CONSTRAINT _prev_raktar_mozgas_egyedi_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;

CREATE TABLE _prev_raktar_mozgas_fej
(
  partner_kod integer NOT NULL,
  mozgasnem_kod integer NOT NULL,
  datum date NOT NULL DEFAULT '2005-01-01',
  ido time without time zone DEFAULT '00:00:00',
  bizonylatszam character varying(30) DEFAULT '',
  m_userid character varying(20) DEFAULT '',
  m_date date DEFAULT '2005-01-01',
  m_time time without time zone DEFAULT '00:00:00',
  c_userid character varying(20) DEFAULT '',
  c_date date DEFAULT '2005-01-01',
  c_time time without time zone DEFAULT '00:00:00',
  raktar_mozgas_bizonylat character(20),
  deviza_nev character(4),
  deviza_arfolyam real,
  telj_datum date,
  fiz_hatarido date,
  fizetesmod_kod integer,
  atvevo_kod integer,
  bizonylat_fajta integer DEFAULT 1,
  kelte date,
  netto_vegosszeg double precision,
  brutto_vegosszeg double precision,
  netto_vegosszeg_huf double precision,
  brutto_vegosszeg_huf double precision,
  netto_arbevetel_vegosszeg double precision,
  netto_arbevetel_vegosszeg_huf double precision,
  netto_kedvezmeny double precision,
  netto_kedvezmeny_huf double precision,
  brutto_arbevetel_vegosszeg double precision,
  brutto_arbevetel_vegosszeg_huf double precision,
  sztornozott_bizonylat character varying(12),
  sztornozo_bizonylat character varying(12),
  megjegyzes text DEFAULT '',
  kod serial NOT NULL,
  sztornozott_bizonylat_kod integer DEFAULT 0,
  sztornozo_bizonylat_kod integer DEFAULT 0,
  forras_raktar_kod integer,
  cel_raktar_kod integer,
  rendben smallint DEFAULT 0,
  datum1 date,
  datum2 date,
  projekt integer DEFAULT 0,
  penzeszkoz_kod integer,
  forras_bizonylat character varying(12),
  forras_bizonylat_kod integer DEFAULT 0,
  forras_bizonylat_fajta integer DEFAULT 0,
  cel_bizonylat character varying(12),
  cel_bizonylat_kod integer DEFAULT 0,
  cel_bizonylat_fajta integer DEFAULT 0,
  afa_arbevetel_vegosszeg double precision DEFAULT 0,
  afa_arbevetel_vegosszeg_huf double precision DEFAULT 0,
  kerekites_huf double precision DEFAULT 0,
  kerekites double precision DEFAULT 0,
  CONSTRAINT _prev_raktar_mozgas_fej_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;
