Feature: Cancelled bills are now separate from void bills.
Void bills are automatically generated when printed bills are changed. Manually cancelled bills are called cancelled bills.
This commit is contained in:
127
barker/alembic/versions/1d95eb10ea20_cancel_bill.py
Normal file
127
barker/alembic/versions/1d95eb10ea20_cancel_bill.py
Normal file
@ -0,0 +1,127 @@
|
||||
"""Cancel Bill
|
||||
|
||||
Revision ID: 1d95eb10ea20
|
||||
Revises: 5967e6603c3e
|
||||
Create Date: 2023-03-17 01:04:25.809115
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import column, table
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy.dialects.postgresql import ENUM
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "1d95eb10ea20"
|
||||
down_revision = "5967e6603c3e"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
# op.execute("ALTER TYPE voucher_type ADD VALUE 'CANCEL';")
|
||||
reporting_level = sa.Enum("Skip", "Aggregate", "Detailed", name="reportinglevel")
|
||||
reporting_level.create(op.get_bind())
|
||||
voucher_type = sa.Enum("KOT", "REGULAR_BILL", "NO_CHARGE", "STAFF", "VOID", "CANCEL", name="vouchertype")
|
||||
voucher_type.create(op.get_bind())
|
||||
|
||||
op.execute("ALTER TABLE settle_options ALTER COLUMN voucher_type DROP DEFAULT;")
|
||||
op.execute("ALTER TABLE settle_options ALTER COLUMN reporting_level DROP DEFAULT;")
|
||||
op.execute(
|
||||
"ALTER TABLE settle_options ALTER COLUMN voucher_type TYPE vouchertype USING voucher_type::text::vouchertype;"
|
||||
)
|
||||
op.execute(
|
||||
"ALTER TABLE settle_options "
|
||||
+ "ALTER COLUMN reporting_level "
|
||||
+ "TYPE reportinglevel USING reporting_level::text::reportinglevel;"
|
||||
)
|
||||
op.execute("ALTER TABLE vouchers ALTER COLUMN voucher_type DROP DEFAULT;")
|
||||
op.execute("ALTER TABLE vouchers ALTER COLUMN voucher_type TYPE vouchertype USING voucher_type::text::vouchertype;")
|
||||
|
||||
op.execute("DROP TYPE voucher_type;")
|
||||
op.execute("DROP TYPE reporting_level;")
|
||||
op.create_index(op.f("ix_vouchers_date"), "vouchers", ["date"], unique=False)
|
||||
|
||||
settle_options()
|
||||
regimes()
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def settle_options():
|
||||
reporting_level = ENUM("Skip", "Aggregate", "Detailed", name="reporting_level", create_type=False)
|
||||
voucher_type = ENUM(
|
||||
"KOT", "REGULAR_BILL", "NO_CHARGE", "STAFF", "VOID", "CANCEL", name="voucher_type", create_type=False
|
||||
)
|
||||
so = table(
|
||||
"settle_options",
|
||||
column("id", sa.Integer()),
|
||||
column("name", sa.Unicode(length=255)),
|
||||
column("has_reason", sa.Boolean()),
|
||||
column("reporting_level", reporting_level),
|
||||
column("voucher_type", voucher_type),
|
||||
column("is_fixture", sa.Boolean()),
|
||||
)
|
||||
|
||||
op.execute(
|
||||
so.insert().values(
|
||||
id=12,
|
||||
name="Cancelled",
|
||||
has_reason=True,
|
||||
reporting_level="Detailed",
|
||||
voucher_type="CANCEL",
|
||||
is_fixture=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def regimes():
|
||||
re = sa.table(
|
||||
"regimes",
|
||||
sa.column("id", sa.Integer()),
|
||||
sa.column("name", sa.Unicode(length=255)),
|
||||
sa.column("header", sa.Unicode(length=255)),
|
||||
sa.column("prefix", sa.Unicode(length=255)),
|
||||
sa.column("is_fixture", sa.Boolean()),
|
||||
)
|
||||
op.execute(
|
||||
re.insert().values(
|
||||
id=12,
|
||||
name="Cancelled",
|
||||
header="",
|
||||
prefix="C",
|
||||
is_fixture=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_vouchers_date"), table_name="vouchers")
|
||||
op.alter_column(
|
||||
"vouchers",
|
||||
"voucher_type",
|
||||
existing_type=sa.Enum("KOT", "REGULAR_BILL", "NO_CHARGE", "STAFF", "VOID", "CANCEL", name="vouchertype"),
|
||||
type_=postgresql.ENUM("KOT", "REGULAR_BILL", "NO_CHARGE", "STAFF", "VOID", name="voucher_type"),
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text("'KOT'::voucher_type"),
|
||||
)
|
||||
op.alter_column(
|
||||
"settle_options",
|
||||
"reporting_level",
|
||||
existing_type=sa.Enum("Skip", "Aggregate", "Detailed", name="reportinglevel"),
|
||||
type_=postgresql.ENUM("Skip", "Aggregate", "Detailed", name="reporting_level"),
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text("'Skip'::reporting_level"),
|
||||
)
|
||||
op.alter_column(
|
||||
"settle_options",
|
||||
"voucher_type",
|
||||
existing_type=sa.Enum("KOT", "REGULAR_BILL", "NO_CHARGE", "STAFF", "VOID", "CANCEL", name="vouchertype"),
|
||||
type_=postgresql.ENUM("KOT", "REGULAR_BILL", "NO_CHARGE", "STAFF", "VOID", name="voucher_type"),
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text("'KOT'::voucher_type"),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user