CREATE TABLE receipts
(
    id              INTEGER PRIMARY KEY AUTOINCREMENT,

    -- основные поля
    receipt_number  TEXT      NOT NULL UNIQUE,
    ui              TEXT      NOT NULL,

    status          INTEGER   NOT NULL,

    issued_at       TIMESTAMP NOT NULL,

    -- суммы
    total_amount    REAL      NOT NULL,
    payment_amount  REAL      NOT NULL,
    cash_amount     REAL      NOT NULL,
    another_amount  REAL      NOT NULL,
    clearing_amount REAL      NOT NULL,
    margin          REAL      NOT NULL,

    currency        TEXT      NOT NULL,
    payment_type    INTEGER   NOT NULL,

    -- касса / продавец
    cashbox_number  INTEGER   NOT NULL,
    cashier         TEXT,

    -- организация / адрес
    name_spd        TEXT,
    name_to         TEXT,
    name_np         TEXT,
    type_np         TEXT,

    street_to       TEXT,
    house_to        TEXT,

    -- SOATO (nullable)
    kod_soato       TEXT,
    oblast_soato    TEXT,
    rayon_soato     TEXT,
    selsovet_soato  TEXT,

    -- прочее
    doc_num         TEXT,
    skno_number     TEXT,
    unp             TEXT,

    success         TEXT,


    created_at      TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
