CREATE TABLE receipts
(
    id              BIGSERIAL PRIMARY KEY,
    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,
    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 NOW()
);

CREATE INDEX idx_receipts_issued_at ON receipts(issued_at);