"""add_tva_breakdown_to_receipt

Revision ID: 1cfb423c6953
Revises: 001_initial
Create Date: 2025-12-12 14:04:22.464289+00:00

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel


# revision identifiers, used by Alembic.
revision: str = '1cfb423c6953'
down_revision: Union[str, None] = '001_initial'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # Add TVA-related columns to receipts table
    with op.batch_alter_table('receipts', schema=None) as batch_op:
        batch_op.add_column(sa.Column('tva_breakdown', sqlmodel.sql.sqltypes.AutoString(length=1000), nullable=True))
        batch_op.add_column(sa.Column('tva_total', sa.Numeric(precision=15, scale=2), nullable=True))
        batch_op.add_column(sa.Column('items_count', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('vendor_address', sqlmodel.sql.sqltypes.AutoString(length=500), nullable=True))


def downgrade() -> None:
    # Remove TVA-related columns from receipts table
    with op.batch_alter_table('receipts', schema=None) as batch_op:
        batch_op.drop_column('vendor_address')
        batch_op.drop_column('items_count')
        batch_op.drop_column('tva_total')
        batch_op.drop_column('tva_breakdown')
