-- V68: 부가세 분기신고 테이블

CREATE TABLE vat_report (
    vat_id              BIGSERIAL      PRIMARY KEY,
    settle_quarter      VARCHAR(7)     NOT NULL,
    total_sales         NUMERIC(18,2),
    total_purchase      NUMERIC(18,2),
    total_vat_payable   NUMERIC(18,2),
    tax_invoice_count   INT,
    generated_at        TIMESTAMP,
    filed_at            TIMESTAMP,
    file_status         VARCHAR(20)    NOT NULL DEFAULT 'DRAFT',
    created_at          TIMESTAMP      NOT NULL DEFAULT now(),
    updated_at          TIMESTAMP,
    UNIQUE (settle_quarter),
    CONSTRAINT chk_vat_status CHECK (file_status IN ('DRAFT','FILED','AMENDED'))
);

COMMENT ON TABLE vat_report IS '부가세 분기신고';
COMMENT ON COLUMN vat_report.settle_quarter    IS '정산 분기 (예: 2025-Q1)';
COMMENT ON COLUMN vat_report.total_vat_payable IS '납부 부가세 = total_sales * 0.1 - 매입세액';
COMMENT ON COLUMN vat_report.file_status       IS 'DRAFT=작성중, FILED=신고완료, AMENDED=수정신고';
