Initial commit: event-driven UK payslip ingest service
Extracted from /home/wizard/code monorepo into its own repo so Woodpecker CI can watch it. Identical content to /home/wizard/code commit e426028. See README.md for overview, env vars, and Paperless workflow config. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
57484619c1
27 changed files with 2878 additions and 0 deletions
72
alembic/versions/0001_initial.py
Normal file
72
alembic/versions/0001_initial.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
"""initial schema
|
||||
|
||||
Revision ID: 0001
|
||||
Revises:
|
||||
Create Date: 2026-04-18 00:00:00.000000
|
||||
|
||||
"""
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0001"
|
||||
down_revision: str | None = None
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
SCHEMA = "payslip_ingest"
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(f"CREATE SCHEMA IF NOT EXISTS {SCHEMA}")
|
||||
|
||||
op.create_table(
|
||||
"payslip",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("paperless_doc_id", sa.Integer(), nullable=False, unique=True),
|
||||
sa.Column("pay_date", sa.Date(), nullable=False),
|
||||
sa.Column("pay_period_start", sa.Date(), nullable=True),
|
||||
sa.Column("pay_period_end", sa.Date(), nullable=True),
|
||||
sa.Column("employer", sa.Text(), nullable=True),
|
||||
sa.Column("currency", sa.CHAR(3), nullable=False, server_default="GBP"),
|
||||
sa.Column("gross_pay", sa.Numeric(12, 2), nullable=False),
|
||||
sa.Column("income_tax", sa.Numeric(12, 2), nullable=False, server_default=sa.text("0")),
|
||||
sa.Column(
|
||||
"national_insurance", sa.Numeric(12, 2), nullable=False, server_default=sa.text("0")
|
||||
),
|
||||
sa.Column(
|
||||
"pension_employee", sa.Numeric(12, 2), nullable=False, server_default=sa.text("0")
|
||||
),
|
||||
sa.Column(
|
||||
"pension_employer", sa.Numeric(12, 2), nullable=False, server_default=sa.text("0")
|
||||
),
|
||||
sa.Column("student_loan", sa.Numeric(12, 2), nullable=False, server_default=sa.text("0")),
|
||||
sa.Column("other_deductions", postgresql.JSONB(), nullable=True),
|
||||
sa.Column("net_pay", sa.Numeric(12, 2), nullable=False),
|
||||
sa.Column("tax_year", sa.Text(), nullable=False),
|
||||
sa.Column("raw_extraction", postgresql.JSONB(), nullable=False),
|
||||
sa.Column("validated", sa.Boolean(), nullable=False, server_default=sa.text("true")),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.TIMESTAMP(timezone=True),
|
||||
nullable=False,
|
||||
server_default=sa.text("now()"),
|
||||
),
|
||||
schema=SCHEMA,
|
||||
)
|
||||
op.create_index(
|
||||
"idx_payslip_pay_date", "payslip", ["pay_date"], schema=SCHEMA
|
||||
)
|
||||
op.create_index(
|
||||
"idx_payslip_tax_year", "payslip", ["tax_year"], schema=SCHEMA
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("idx_payslip_tax_year", table_name="payslip", schema=SCHEMA)
|
||||
op.drop_index("idx_payslip_pay_date", table_name="payslip", schema=SCHEMA)
|
||||
op.drop_table("payslip", schema=SCHEMA)
|
||||
op.execute(f"DROP SCHEMA IF EXISTS {SCHEMA}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue