diff --git a/brewman/alembic/versions/002f51d87565_precision.py b/brewman/alembic/versions/002f51d87565_precision.py deleted file mode 100644 index 04ba5d3e..00000000 --- a/brewman/alembic/versions/002f51d87565_precision.py +++ /dev/null @@ -1,291 +0,0 @@ -"""precision - -Revision ID: 002f51d87565 -Revises: eed0b382c287 -Create Date: 2020-11-03 20:54:33.718750 - -""" -import sqlalchemy as sa - -from alembic import op - - -# revision identifiers, used by Alembic. -revision = "002f51d87565" -down_revision = "eed0b382c287" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column( - "products", - "fraction", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=5), - existing_nullable=False, - ) - op.alter_column( - "products", - "product_yield", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=5), - existing_nullable=False, - ) - op.alter_column( - "products", - "cost_price", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - existing_nullable=False, - ) - op.alter_column( - "products", - "sale_price", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - existing_nullable=False, - ) - op.alter_column( - "recipes", - "quantity", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - existing_nullable=False, - ) - op.alter_column( - "recipes", - "cost_price", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - existing_nullable=False, - ) - op.alter_column( - "recipes", - "sale_price", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - existing_nullable=False, - ) - op.alter_column( - "journals", - "debit", - existing_type=sa.Integer(), - nullable=False, - ) - op.alter_column( - "journals", - "amount", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - nullable=False, - ) - op.alter_column( - "inventories", - "quantity", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - nullable=False, - ) - op.alter_column( - "inventories", - "rate", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - nullable=False, - ) - op.alter_column( - "inventories", - "tax", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=5), - nullable=False, - ) - op.alter_column( - "inventories", - "discount", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=5), - nullable=False, - ) - op.alter_column( - "batches", - "quantity_remaining", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - nullable=False, - ) - op.alter_column( - "batches", - "rate", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=2), - nullable=False, - ) - op.alter_column( - "batches", - "tax", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=5), - nullable=False, - ) - op.alter_column( - "batches", - "discount", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=15, scale=5), - nullable=False, - ) - op.alter_column( - "attendances", - "amount", - existing_type=sa.Numeric(), - type_=sa.Numeric(precision=5, scale=2), - existing_nullable=False, - ) - op.alter_column( - "incentives", - "days_worked", - existing_type=sa.INTEGER(), - type_=sa.Numeric(precision=5, scale=1), - existing_nullable=False, - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column( - "products", - "fraction", - existing_type=sa.Numeric(precision=15, scale=5), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "products", - "product_yield", - existing_type=sa.Numeric(precision=15, scale=5), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "products", - "cost_price", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "products", - "sale_price", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "recipes", - "quantity", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "recipes", - "cost_price", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "recipes", - "sale_price", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "journals", - "debit", - existing_type=sa.Integer(), - nullable=True, - ) - op.alter_column( - "journals", - "amount", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "inventories", - "quantity", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "inventories", - "rate", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "inventories", - "tax", - existing_type=sa.Numeric(precision=15, scale=5), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "inventories", - "discount", - existing_type=sa.Numeric(precision=15, scale=5), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "batches", - "quantity_remaining", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "batches", - "rate", - existing_type=sa.Numeric(precision=15, scale=2), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "batches", - "tax", - existing_type=sa.Numeric(precision=15, scale=5), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "batches", - "discount", - existing_type=sa.Numeric(precision=15, scale=5), - type_=sa.Numeric(), - nullable=True, - ) - op.alter_column( - "attendances", - "amount", - existing_type=sa.Numeric(precision=5, scale=2), - type_=sa.Numeric(), - existing_nullable=False, - ) - op.alter_column( - "incentives", - "days_worked", - existing_type=sa.Numeric(precision=5, scale=1), - type_=sa.INTEGER(), - existing_nullable=False, - ) - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/0363f582ab28_rename_auth.py b/brewman/alembic/versions/0363f582ab28_rename_auth.py deleted file mode 100644 index 13e0fa8e..00000000 --- a/brewman/alembic/versions/0363f582ab28_rename_auth.py +++ /dev/null @@ -1,69 +0,0 @@ -"""rename auth - -Revision ID: 0363f582ab28 -Revises: ad8b2d208492 -Create Date: 2021-09-11 05:32:56.683107 - -""" - -from alembic import op - - -# revision identifiers, used by Alembic. -revision = "0363f582ab28" -down_revision = "ad8b2d208492" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.rename_table("auth_clients", "clients") - op.drop_constraint("uq_auth_clients_code", "clients", type_="unique") - op.drop_constraint("uq_auth_clients_name", "clients", type_="unique") - op.create_unique_constraint(op.f("uq_clients_code"), "clients", ["code"]) - op.create_unique_constraint(op.f("uq_clients_name"), "clients", ["name"]) - - op.rename_table("auth_login_history", "login_history") - op.drop_constraint("uq_auth_login_history_user_id", "login_history", type_="unique") - op.create_unique_constraint(op.f("uq_login_history_user_id"), "login_history", ["user_id", "client_id", "date"]) - - op.rename_table("auth_permissions", "permissions") - op.drop_constraint("uq_auth_permissions_name", "permissions", type_="unique") - op.create_unique_constraint(op.f("uq_permissions_name"), "permissions", ["name"]) - - op.rename_table("auth_roles", "roles") - op.drop_constraint("uq_auth_roles_name", "roles", type_="unique") - op.create_unique_constraint(op.f("uq_roles_name"), "roles", ["name"]) - - op.rename_table("auth_users", "users") - op.drop_constraint("uq_auth_users_username", "users", type_="unique") - op.create_unique_constraint(op.f("uq_users_username"), "users", ["username"]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - op.rename_table("users", "auth_users") - op.drop_constraint(op.f("uq_users_username"), "users", type_="unique") - op.create_unique_constraint("uq_auth_users_username", "users", ["username"]) - - op.rename_table("roles", "auth_roles") - op.drop_constraint(op.f("uq_roles_name"), "roles", type_="unique") - op.create_unique_constraint("uq_auth_roles_name", "roles", ["name"]) - - op.rename_table("permissions", "auth_permissions") - op.drop_constraint(op.f("uq_permissions_name"), "permissions", type_="unique") - op.create_unique_constraint("uq_auth_permissions_name", "permissions", ["name"]) - - op.rename_table("login_history", "auth_login_history") - op.drop_constraint(op.f("uq_login_history_user_id"), "login_history", type_="unique") - op.create_unique_constraint("uq_auth_login_history_user_id", "login_history", ["user_id", "client_id", "date"]) - - op.rename_table("clients", "auth_clients") - op.drop_constraint(op.f("uq_clients_name"), "clients", type_="unique") - op.drop_constraint(op.f("uq_clients_code"), "clients", type_="unique") - op.create_unique_constraint("uq_auth_clients_name", "clients", ["name"]) - op.create_unique_constraint("uq_auth_clients_code", "clients", ["code"]) - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/0670868fe171_stock_keeping_units.py b/brewman/alembic/versions/0670868fe171_stock_keeping_units.py deleted file mode 100644 index 4bedf596..00000000 --- a/brewman/alembic/versions/0670868fe171_stock_keeping_units.py +++ /dev/null @@ -1,160 +0,0 @@ -"""stock_keeping_units - -Revision ID: 0670868fe171 -Revises: 6fb6c96fd408 -Create Date: 2021-09-25 12:17:58.540829 - -""" -import sqlalchemy as sa - -from alembic import op -from sqlalchemy import Boolean, Numeric, Unicode, column, select, table -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -from sqlalchemy.dialects.postgresql import UUID - - -revision = "0670868fe171" -down_revision = "6fb6c96fd408" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table( - "stock_keeping_units", - sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("product_id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("is_default", sa.Boolean(), nullable=False), - sa.Column("units", sa.Unicode(length=255), nullable=False), - sa.Column("fraction", sa.Numeric(precision=15, scale=5), nullable=False), - sa.Column("fraction_units", sa.Unicode(length=255), nullable=False), - sa.Column("product_yield", sa.Numeric(precision=15, scale=5), nullable=False), - sa.Column("cost_price", sa.Numeric(precision=15, scale=2), nullable=False), - sa.Column("sale_price", sa.Numeric(precision=15, scale=2), nullable=False), - sa.ForeignKeyConstraint( - ["product_id"], ["products.id"], name=op.f("fk_stock_keeping_units_product_id_products") - ), - sa.PrimaryKeyConstraint("id", name=op.f("pk_stock_keeping_units")), - sa.UniqueConstraint("product_id", "units", name=op.f("uq_stock_keeping_units_product_id")), - ) - op.create_index( - "unique_true_is_default", - "stock_keeping_units", - ["product_id"], - unique=True, - postgresql_where=sa.text("is_default = true"), - ) - op.drop_constraint("uq_products_name", "products", type_="unique") - op.create_unique_constraint(op.f("uq_products_name"), "products", ["name"]) - - sku = table( - "stock_keeping_units", - column("id", UUID(as_uuid=True)), - column("product_id", UUID(as_uuid=True)), - column("is_default", Boolean), - column("units", Unicode(255)), - column("fraction", Numeric(precision=15, scale=5)), - column("fraction_units", Unicode(255)), - column("product_yield", Numeric(precision=15, scale=5)), - column("cost_price", Numeric(precision=15, scale=2)), - column("sale_price", Numeric(precision=15, scale=2)), - ) - product = table( - "products", - column("id", UUID(as_uuid=True)), - column("units", Unicode(255)), - column("fraction", Numeric(precision=15, scale=5)), - column("fraction_units", Unicode(255)), - column("product_yield", Numeric(precision=15, scale=5)), - column("cost_price", Numeric(precision=15, scale=2)), - column("sale_price", Numeric(precision=15, scale=2)), - ) - - op.execute( - sku.insert().from_select( - [ - sku.c.id, - sku.c.product_id, - sku.c.is_default, - sku.c.units, - sku.c.fraction, - sku.c.fraction_units, - sku.c.product_yield, - sku.c.cost_price, - sku.c.sale_price, - ], - select( - [ - product.c.id, - product.c.id, - True, - product.c.units, - product.c.fraction, - product.c.fraction_units, - product.c.product_yield, - product.c.cost_price, - product.c.sale_price, - ] - ), - ) - ) - - op.drop_column("products", "cost_price") - op.drop_column("products", "units") - op.drop_column("products", "sale_price") - op.drop_column("products", "product_yield") - op.drop_column("products", "fraction_units") - op.drop_column("products", "fraction") - - op.drop_constraint("uq_rate_contract_items_rate_contract_id", "rate_contract_items", type_="unique") - op.drop_constraint("fk_rate_contract_items_product_id_products", "rate_contract_items", type_="foreignkey") - op.alter_column("rate_contract_items", "product_id", new_column_name="sku_id") - op.create_unique_constraint( - op.f("uq_rate_contract_items_rate_contract_id"), "rate_contract_items", ["rate_contract_id", "sku_id"] - ) - op.create_foreign_key( - op.f("fk_rate_contract_items_sku_id_stock_keeping_units"), - "rate_contract_items", - "stock_keeping_units", - ["sku_id"], - ["id"], - ) - - op.drop_constraint("batches_ProductID_fkey", "batches", type_="foreignkey") - op.alter_column("batches", "product_id", new_column_name="sku_id") - op.create_foreign_key( - op.f("fk_batches_sku_id_stock_keeping_units"), "batches", "stock_keeping_units", ["sku_id"], ["id"] - ) - - op.drop_constraint("inventories_ProductID_fkey", "inventories", type_="foreignkey") - op.drop_column("inventories", "product_id") - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column( - "products", sa.Column("fraction", sa.NUMERIC(precision=15, scale=5), autoincrement=False, nullable=False) - ) - op.add_column("products", sa.Column("fraction_units", sa.VARCHAR(length=255), autoincrement=False, nullable=False)) - op.add_column( - "products", sa.Column("product_yield", sa.NUMERIC(precision=15, scale=5), autoincrement=False, nullable=False) - ) - op.add_column( - "products", sa.Column("sale_price", sa.NUMERIC(precision=15, scale=2), autoincrement=False, nullable=False) - ) - op.add_column("products", sa.Column("units", sa.VARCHAR(length=255), autoincrement=False, nullable=False)) - op.add_column( - "products", sa.Column("cost_price", sa.NUMERIC(precision=15, scale=2), autoincrement=False, nullable=False) - ) - op.drop_constraint(op.f("uq_products_name"), "products", type_="unique") - op.create_unique_constraint("uq_products_name", "products", ["name", "units"]) - op.drop_index( - "unique_true_is_default", table_name="stock_keeping_units", postgresql_where=sa.text("is_default = true") - ) - op.drop_table("stock_keeping_units") - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/071e8f29d257_rate_contracts.py b/brewman/alembic/versions/071e8f29d257_rate_contracts.py deleted file mode 100644 index 9534fccf..00000000 --- a/brewman/alembic/versions/071e8f29d257_rate_contracts.py +++ /dev/null @@ -1,71 +0,0 @@ -"""rate contracts - -Revision ID: 071e8f29d257 -Revises: 0363f582ab28 -Create Date: 2021-09-11 05:57:49.062468 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -from brewman.models.permission import Permission -from sqlalchemy.dialects import postgresql - - -revision = "071e8f29d257" -down_revision = "0363f582ab28" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute(Permission.__table__.insert().values(id="f97589c6-df9f-45d3-874d-4245a4d99ade", name="Rate Contracts")) - op.create_table( - "rate_contracts", - sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("date", sa.Date(), nullable=False), - sa.Column("vendor_id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("valid_from", sa.Date(), nullable=True), - sa.Column("valid_till", sa.Date(), nullable=True), - sa.Column("narration", sa.Unicode(length=1000), nullable=False), - sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("creation_date", sa.DateTime(), nullable=False), - sa.Column("last_edit_date", sa.DateTime(), nullable=False), - sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_rate_contracts_user_id_users")), - sa.ForeignKeyConstraint(["vendor_id"], ["accounts.id"], name=op.f("fk_rate_contracts_vendor_id_accounts")), - sa.PrimaryKeyConstraint("id", name=op.f("pk_rate_contracts")), - ) - op.create_index(op.f("ix_rate_contracts_date"), "rate_contracts", ["date"], unique=False) - op.create_table( - "rate_contract_items", - sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("rate_contract_id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("product_id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("cost_price", sa.Numeric(precision=15, scale=2), nullable=False), - sa.ForeignKeyConstraint( - ["product_id"], ["products.id"], name=op.f("fk_rate_contract_items_product_id_products") - ), - sa.ForeignKeyConstraint( - ["rate_contract_id"], - ["rate_contracts.id"], - name=op.f("fk_rate_contract_items_rate_contract_id_rate_contracts"), - ), - sa.PrimaryKeyConstraint("id", name=op.f("pk_rate_contract_items")), - sa.UniqueConstraint("rate_contract_id", "product_id", name=op.f("uq_rate_contract_items_rate_contract_id")), - ) - op.create_index( - op.f("ix_rate_contract_items_rate_contract_id"), "rate_contract_items", ["rate_contract_id"], unique=False - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f("ix_rate_contract_items_rate_contract_id"), table_name="rate_contract_items") - op.drop_table("rate_contract_items") - op.drop_index(op.f("ix_rate_contracts_date"), table_name="rate_contracts") - op.drop_table("rate_contracts") - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/0bf3d70ee7de_initial_commit.py b/brewman/alembic/versions/0bf3d70ee7de_initial_commit.py index d68aec72..43922c9e 100644 --- a/brewman/alembic/versions/0bf3d70ee7de_initial_commit.py +++ b/brewman/alembic/versions/0bf3d70ee7de_initial_commit.py @@ -5,9 +5,11 @@ Revises: Create Date: 2020-05-10 19:02:57.301086 """ + import sqlalchemy as sa from alembic import op +from sqlalchemy import column, func, table, text from sqlalchemy.dialects import postgresql @@ -21,47 +23,47 @@ depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( - "auth_clients", - sa.Column("client_id", postgresql.UUID(), nullable=False), + "clients", + sa.Column("id", postgresql.UUID(), nullable=False), sa.Column("code", sa.Integer(), nullable=False), sa.Column("name", sa.Unicode(length=255), nullable=False), sa.Column("enabled", sa.Boolean(), nullable=False), sa.Column("otp", sa.Integer(), nullable=True), - sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False), - sa.PrimaryKeyConstraint("client_id", name=op.f("pk_auth_clients")), - sa.UniqueConstraint("code", name=op.f("uq_auth_clients_code")), - sa.UniqueConstraint("name", name=op.f("uq_auth_clients_name")), + sa.Column("creation_date", sa.DateTime(), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_clients")), + sa.UniqueConstraint("code", name=op.f("uq_clients_code")), + sa.UniqueConstraint("name", name=op.f("uq_clients_name")), ) op.create_table( - "auth_groups", - sa.Column("GroupID", postgresql.UUID(), nullable=False), - sa.Column("Name", sa.Unicode(length=255), nullable=True), - sa.PrimaryKeyConstraint("GroupID", name=op.f("pk_auth_groups")), - sa.UniqueConstraint("Name", name=op.f("uq_auth_groups_Name")), + "roles", + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("name", sa.Unicode(length=255), nullable=True), + sa.PrimaryKeyConstraint("id", name=op.f("pk_roles")), + sa.UniqueConstraint("name", name=op.f("uq_roles_name")), ) op.create_table( - "auth_roles", - sa.Column("RoleID", postgresql.UUID(), nullable=False), - sa.Column("Name", sa.Unicode(length=255), nullable=True), - sa.PrimaryKeyConstraint("RoleID", name=op.f("pk_auth_roles")), - sa.UniqueConstraint("Name", name=op.f("uq_auth_roles_Name")), + "permissions", + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("name", sa.Unicode(length=255), nullable=True), + sa.PrimaryKeyConstraint("id", name=op.f("pk_permissions")), + sa.UniqueConstraint("name", name=op.f("uq_permissions_name")), ) op.create_table( - "auth_users", - sa.Column("UserID", postgresql.UUID(), nullable=False), - sa.Column("Name", sa.Unicode(length=255), nullable=True), - sa.Column("Password", sa.Unicode(length=60), nullable=True), - sa.Column("LockedOut", sa.Boolean(), nullable=True), - sa.PrimaryKeyConstraint("UserID", name=op.f("pk_auth_users")), - sa.UniqueConstraint("Name", name=op.f("uq_auth_users_Name")), + "users", + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("username", sa.Unicode(length=255), nullable=True), + sa.Column("password", sa.Unicode(length=60), nullable=True), + sa.Column("disabled", sa.Boolean(), nullable=True), + sa.PrimaryKeyConstraint("id", name=op.f("pk_users")), + sa.UniqueConstraint("username", name=op.f("uq_users_username")), ) op.create_table( "cost_centres", - sa.Column("CostCentreID", postgresql.UUID(), nullable=False), - sa.Column("Name", sa.Unicode(length=255), nullable=True), - sa.Column("IsFixture", sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint("CostCentreID", name=op.f("pk_cost_centres")), - sa.UniqueConstraint("Name", name=op.f("uq_cost_centres_Name")), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("name", sa.Unicode(length=255), nullable=True), + sa.Column("is_fixture", sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_cost_centres")), + sa.UniqueConstraint("name", name=op.f("uq_cost_centres_name")), ) op.create_table( "images", @@ -70,24 +72,41 @@ def upgrade(): sa.Column("resource_type", sa.Unicode(length=255), nullable=False), sa.Column("image", postgresql.BYTEA(), nullable=False), sa.Column("thumbnail", postgresql.BYTEA(), nullable=False), - sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False), + sa.Column("creation_date", sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_images")), ) op.create_table( "product_groups", - sa.Column("ProductGroupID", postgresql.UUID(), nullable=False), - sa.Column("Name", sa.Unicode(length=255), nullable=True), - sa.Column("IsFixture", sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint("ProductGroupID", name=op.f("pk_product_groups")), - sa.UniqueConstraint("Name", name=op.f("uq_product_groups_Name")), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("name", sa.Unicode(length=255), nullable=True), + sa.Column("is_fixture", sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_product_groups")), + sa.UniqueConstraint("name", name=op.f("uq_product_groups_name")), ) + setting_type = sa.Enum("VOUCHER_LOCK", name="setting_type") + # setting_type.create(op.get_bind()) op.create_table( "settings", - sa.Column("SettingID", postgresql.UUID(), nullable=False), - sa.Column("Name", sa.Unicode(length=255), nullable=False), - sa.Column("Data", sa.PickleType(), nullable=True), - sa.PrimaryKeyConstraint("SettingID", name=op.f("pk_settings")), - sa.UniqueConstraint("Name", name=op.f("uq_settings_Name")), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("name", sa.Unicode(length=255), nullable=False), + sa.Column("data", sa.PickleType(), nullable=True), + sa.Column("setting_type", setting_type, nullable=False), + sa.Column("valid_from", sa.Date(), nullable=True), + sa.Column("valid_till", sa.Date(), nullable=True), + sa.PrimaryKeyConstraint("id", name=op.f("pk_settings")), + sa.UniqueConstraint("name", name=op.f("uq_settings_name")), + ) + op.create_table( + "account_types", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("name", sa.Unicode(length=255), nullable=False), + sa.Column("balance_sheet", sa.Boolean(), nullable=False), + sa.Column("debit", sa.Boolean(), nullable=False), + sa.Column("cash_flow_classification", sa.Unicode(length=255), nullable=False), + sa.Column("order", sa.Integer(), nullable=False), + sa.Column("show_in_list", sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_account_types")), + sa.UniqueConstraint("name", name=op.f("uq_account_types_name")), ) op.create_table( "accounts", @@ -103,350 +122,430 @@ def upgrade(): sa.Column("is_fixture", sa.Boolean(), nullable=False), sa.ForeignKeyConstraint( ["cost_centre_id"], - ["cost_centres.CostCentreID"], + ["cost_centres.id"], name=op.f("fk_accounts_cost_centre_id_cost_centres"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_accounts")), sa.UniqueConstraint("name", name=op.f("uq_accounts_name")), + sa.ForeignKeyConstraint( + ["type"], + ["account_types.id"], + name=op.f("fk_accounts_type_account_types"), + ), ) op.create_table( - "auth_login_history", - sa.Column("login_history_id", postgresql.UUID(), nullable=False), + "login_history", + sa.Column("id", postgresql.UUID(), nullable=False), sa.Column("user_id", postgresql.UUID(), nullable=False), sa.Column("client_id", postgresql.UUID(), nullable=False), - sa.Column("date", sa.DateTime(timezone=True), nullable=False), + sa.Column("date", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint( ["client_id"], - ["auth_clients.client_id"], - name=op.f("fk_auth_login_history_client_id_auth_clients"), + ["clients.id"], + name=op.f("fk_login_history_client_id_clients"), ), sa.ForeignKeyConstraint( ["user_id"], - ["auth_users.UserID"], - name=op.f("fk_auth_login_history_user_id_auth_users"), + ["users.id"], + name=op.f("fk_login_history_user_id_users"), ), - sa.PrimaryKeyConstraint("login_history_id", name=op.f("pk_auth_login_history")), - sa.UniqueConstraint("user_id", "client_id", "date", name=op.f("uq_auth_login_history_user_id")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_login_history")), + sa.UniqueConstraint("user_id", "client_id", "date", name=op.f("uq_login_history_user_id")), ) op.create_table( - "auth_rolegroups", - sa.Column("RoleGroupID", postgresql.UUID(), nullable=False), - sa.Column("RoleID", postgresql.UUID(), nullable=True), - sa.Column("GroupID", postgresql.UUID(), nullable=True), + "role_permissions", + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("permission_id", postgresql.UUID(), nullable=True), + sa.Column("role_id", postgresql.UUID(), nullable=True), sa.ForeignKeyConstraint( - ["GroupID"], - ["auth_groups.GroupID"], - name=op.f("fk_auth_rolegroups_GroupID_auth_groups"), + ["role_id"], + ["roles.id"], + name=op.f("fk_role_permissions_role_id_roles"), ), sa.ForeignKeyConstraint( - ["RoleID"], - ["auth_roles.RoleID"], - name=op.f("fk_auth_rolegroups_RoleID_auth_roles"), + ["permission_id"], + ["permissions.id"], + name=op.f("fk_auth_rolegroups_permission_id_permissions"), ), - sa.PrimaryKeyConstraint("RoleGroupID", name=op.f("pk_auth_rolegroups")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_role_permissions")), ) op.create_table( - "auth_usergroups", - sa.Column("UserGroupID", postgresql.UUID(), nullable=False), - sa.Column("UserID", postgresql.UUID(), nullable=True), - sa.Column("GroupID", postgresql.UUID(), nullable=True), + "user_roles", + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("user_id", postgresql.UUID(), nullable=True), + sa.Column("role_id", postgresql.UUID(), nullable=True), sa.ForeignKeyConstraint( - ["GroupID"], - ["auth_groups.GroupID"], - name=op.f("fk_auth_usergroups_GroupID_auth_groups"), + ["role_id"], + ["roles.id"], + name=op.f("fk_user_roles_role_id_roles"), ), sa.ForeignKeyConstraint( - ["UserID"], - ["auth_users.UserID"], - name=op.f("fk_auth_usergroups_UserID_auth_users"), + ["user_id"], + ["users.id"], + name=op.f("fk_user_roles_user_id_users"), ), - sa.PrimaryKeyConstraint("UserGroupID", name=op.f("pk_auth_usergroups")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_user_roles")), ) + voucher_type = sa.Enum( + "JOURNAL", + "PURCHASE", + "ISSUE", + "PAYMENT", + "RECEIPT", + "PURCHASE_RETURN", + "OPENING_ACCOUNTS", + "OPENING_BATCHES", + "CLOSING_STOCK", + "OPENING_BALANCE", + "CLOSING_BALANCE", + "EMPLOYEE_BENEFIT", + "INCENTIVE", + name="voucher_type", + ) + # voucher_type.create(op.get_bind()) op.create_table( "vouchers", - sa.Column("VoucherID", postgresql.UUID(), nullable=False), + sa.Column("id", postgresql.UUID(), nullable=False), sa.Column("date", sa.DateTime(), nullable=False), sa.Column("narration", sa.Unicode(length=1000), nullable=False), sa.Column("is_reconciled", sa.Boolean(), nullable=False), sa.Column("reconcile_date", sa.DateTime(), nullable=False), sa.Column("is_starred", sa.Boolean(), nullable=False), - sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False), - sa.Column("last_edit_date", sa.DateTime(timezone=True), nullable=False), - sa.Column("voucher_type", sa.Integer(), nullable=False), + sa.Column("creation_date", sa.DateTime(), nullable=False), + sa.Column("last_edit_date", sa.DateTime(), nullable=False), + sa.Column("voucher_type", voucher_type, nullable=False), sa.Column("user_id", postgresql.UUID(), nullable=False), sa.Column("is_posted", sa.Boolean(), nullable=False), sa.Column("poster_id", postgresql.UUID(), nullable=True), sa.ForeignKeyConstraint( ["poster_id"], - ["auth_users.UserID"], - name=op.f("fk_vouchers_poster_id_auth_users"), + ["users.id"], + name=op.f("fk_vouchers_poster_id_users"), ), sa.ForeignKeyConstraint( ["user_id"], - ["auth_users.UserID"], - name=op.f("fk_vouchers_user_id_auth_users"), + ["users.id"], + name=op.f("fk_vouchers_user_id_users"), ), - sa.PrimaryKeyConstraint("VoucherID", name=op.f("pk_vouchers")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_vouchers")), ) op.create_index(op.f("ix_vouchers_date"), "vouchers", ["date"], unique=False) op.create_table( "employees", sa.Column("id", postgresql.UUID(), nullable=False), - sa.Column("Designation", sa.Unicode(length=255), nullable=True), - sa.Column("Salary", sa.Integer(), nullable=True), - sa.Column("ServicePoints", sa.Numeric(precision=5, scale=2), nullable=True), - sa.Column("JoiningDate", sa.DateTime(), nullable=True), - sa.Column("LeavingDate", sa.DateTime(), nullable=True), + sa.Column("designation", sa.Unicode(length=255), nullable=True), + sa.Column("salary", sa.Integer(), nullable=True), + sa.Column("points", sa.Numeric(precision=5, scale=2), nullable=True), + sa.Column("joining_date", sa.DateTime(), nullable=False), + sa.Column("leaving_date", sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(["id"], ["accounts.id"], name=op.f("fk_employees_id_accounts")), sa.PrimaryKeyConstraint("id", name=op.f("pk_employees")), ) op.create_table( "journals", - sa.Column("JournalID", postgresql.UUID(), nullable=False), - sa.Column("Debit", sa.Integer(), nullable=True), - sa.Column("Amount", sa.Numeric(), nullable=True), - sa.Column("VoucherID", postgresql.UUID(), nullable=False), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("debit", sa.Integer(), nullable=False), + sa.Column("amount", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("voucher_id", postgresql.UUID(), nullable=False), sa.Column("account_id", postgresql.UUID(), nullable=False), - sa.Column("CostCentreID", postgresql.UUID(), nullable=False), + sa.Column("cost_centre_id", postgresql.UUID(), nullable=False), sa.ForeignKeyConstraint( - ["CostCentreID"], - ["cost_centres.CostCentreID"], - name=op.f("fk_journals_CostCentreID_cost_centres"), + ["cost_centre_id"], + ["cost_centres.id"], + name=op.f("fk_journals_cost_centre_id_cost_centres"), ), sa.ForeignKeyConstraint( - ["VoucherID"], - ["vouchers.VoucherID"], - name=op.f("fk_journals_VoucherID_vouchers"), + ["voucher_id"], + ["vouchers.id"], + name=op.f("fk_journals_voucher_id_vouchers"), ), sa.ForeignKeyConstraint( ["account_id"], ["accounts.id"], name=op.f("fk_journals_account_id_accounts"), ), - sa.PrimaryKeyConstraint("JournalID", name=op.f("pk_journals")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_journals")), ) - op.create_index(op.f("ix_journals_VoucherID"), "journals", ["VoucherID"], unique=False) + op.create_index(op.f("ix_journals_voucher_id"), "journals", ["voucher_id"], unique=False) op.create_table( "products", - sa.Column("ProductID", postgresql.UUID(), nullable=False), - sa.Column("Code", sa.Integer(), nullable=True), - sa.Column("Name", sa.Unicode(length=255), nullable=False), - sa.Column("Units", sa.Unicode(length=255), nullable=False), - sa.Column("Fraction", sa.Numeric(), nullable=False), - sa.Column("FractionUnits", sa.Unicode(length=255), nullable=False), - sa.Column("ProductYield", sa.Numeric(), nullable=False), - sa.Column("ProductGroupID", postgresql.UUID(), nullable=False), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("code", sa.Integer(), nullable=True), + sa.Column("name", sa.Unicode(length=255), nullable=False), + sa.Column("fraction_units", sa.Unicode(length=255), nullable=False), + sa.Column("product_group_id", postgresql.UUID(), nullable=False), sa.Column("account_id", postgresql.UUID(), nullable=False), - sa.Column("cost_price", sa.Numeric(), nullable=False), - sa.Column("sale_price", sa.Numeric(), nullable=False), - sa.Column("IsActive", sa.Boolean(), nullable=False), - sa.Column("IsFixture", sa.Boolean(), nullable=False), + sa.Column("is_active", sa.Boolean(), nullable=False), + sa.Column("is_fixture", sa.Boolean(), nullable=False), sa.Column("is_purchased", sa.Boolean(), nullable=False), sa.Column("is_sold", sa.Boolean(), nullable=False), sa.ForeignKeyConstraint( - ["ProductGroupID"], - ["product_groups.ProductGroupID"], - name=op.f("fk_products_ProductGroupID_product_groups"), + ["product_group_id"], + ["product_groups.id"], + name=op.f("fk_products_product_group_id_product_groups"), ), sa.ForeignKeyConstraint( ["account_id"], ["accounts.id"], name=op.f("fk_products_account_id_accounts"), ), - sa.PrimaryKeyConstraint("ProductID", name=op.f("pk_products")), - sa.UniqueConstraint("Code", name=op.f("uq_products_Code")), - sa.UniqueConstraint("Name", "Units", name=op.f("uq_products_Name")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_products")), + sa.UniqueConstraint("code", name=op.f("uq_products_code")), + sa.UniqueConstraint("name", name=op.f("uq_products_name")), + ) + op.create_table( + "stock_keeping_units", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("product_id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("units", sa.Unicode(length=255), nullable=False), + sa.Column("fraction", sa.Numeric(precision=15, scale=5), nullable=False), + sa.Column("product_yield", sa.Numeric(precision=15, scale=5), nullable=False), + sa.Column("cost_price", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("sale_price", sa.Numeric(precision=15, scale=2), nullable=False), + sa.ForeignKeyConstraint( + ["product_id"], ["products.id"], name=op.f("fk_stock_keeping_units_product_id_products") + ), + sa.PrimaryKeyConstraint("id", name=op.f("pk_stock_keeping_units")), + sa.UniqueConstraint("product_id", "units", name=op.f("uq_stock_keeping_units_product_id")), ) op.create_table( "attendances", - sa.Column("AttendanceID", postgresql.UUID(), nullable=False), - sa.Column("EmployeeID", postgresql.UUID(), nullable=True), - sa.Column("Date", sa.DateTime(), nullable=True), - sa.Column("AttendanceType", sa.Integer(), nullable=True), - sa.Column("Amount", sa.Numeric(), nullable=True), - sa.Column("CreationDate", sa.DateTime(timezone=True), nullable=True), - sa.Column("UserID", postgresql.UUID(), nullable=True), - sa.Column("IsValid", sa.Boolean(), nullable=True), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("employee_id", postgresql.UUID(), nullable=True), + sa.Column("date", sa.DateTime(), nullable=True), + sa.Column("attendance_type", sa.Integer(), nullable=True), + sa.Column("amount", sa.Numeric(precision=15, scale=5), nullable=False), + sa.Column("creation_date", sa.DateTime(), nullable=False), + sa.Column("user_id", postgresql.UUID(), nullable=True), + sa.Column("is_valid", sa.Boolean(), nullable=True), sa.ForeignKeyConstraint( - ["EmployeeID"], + ["employee_id"], ["employees.id"], - name=op.f("fk_attendances_EmployeeID_employees"), + name=op.f("fk_attendances_employee_id_employees"), ), sa.ForeignKeyConstraint( - ["UserID"], - ["auth_users.UserID"], - name=op.f("fk_attendances_UserID_auth_users"), + ["user_id"], + ["users.id"], + name=op.f("fk_attendances_user_id_users"), ), - sa.PrimaryKeyConstraint("AttendanceID", name=op.f("pk_attendances")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_attendances")), + ) + op.create_index( + "only_one_valid_attendance", + "attendances", + ["employee_id", "date"], + unique=True, + postgresql_where=sa.text("is_valid = true"), ) op.create_table( "batches", - sa.Column("BatchID", postgresql.UUID(), nullable=False), - sa.Column("Name", sa.DateTime(), nullable=True), - sa.Column("ProductID", postgresql.UUID(), nullable=False), - sa.Column("QuantityRemaining", sa.Numeric(), nullable=True), - sa.Column("Rate", sa.Numeric(), nullable=True), - sa.Column("Tax", sa.Numeric(), nullable=True), - sa.Column("Discount", sa.Numeric(), nullable=True), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("name", sa.DateTime(), nullable=False), + sa.Column("sku_id", postgresql.UUID(), nullable=False), + sa.Column("quantity_remaining", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("rate", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("tax", sa.Numeric(precision=15, scale=5), nullable=False), + sa.Column("discount", sa.Numeric(precision=15, scale=5), nullable=False), sa.ForeignKeyConstraint( - ["ProductID"], - ["products.ProductID"], - name=op.f("fk_batches_ProductID_products"), + ["sku_id"], + ["stock_keeping_units.id"], + name=op.f("fk_batches_sku_id_stock_keeping_units"), ), - sa.PrimaryKeyConstraint("BatchID", name=op.f("pk_batches")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_batches")), ) op.create_table( "fingerprints", - sa.Column("FingerprintID", postgresql.UUID(), nullable=False), - sa.Column("EmployeeID", postgresql.UUID(), nullable=True), - sa.Column("Date", sa.DateTime(), nullable=True), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("employee_id", postgresql.UUID(), nullable=True), + sa.Column("date", sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( - ["EmployeeID"], + ["employee_id"], ["employees.id"], - name=op.f("fk_fingerprints_EmployeeID_employees"), + name=op.f("fk_fingerprints_employee_id_employees"), ), - sa.PrimaryKeyConstraint("FingerprintID", name=op.f("pk_fingerprints")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_fingerprints")), + sa.UniqueConstraint("employee_id", "date", name=op.f("uq_fingerprints_employee_id")), + ) + op.create_table( + "periods", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("valid_from", sa.Date(), nullable=False), + sa.Column("valid_till", sa.Date(), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_periods")), + ) + p = table( + "periods", + column("id", postgresql.UUID()), + column("valid_from", sa.Date()), + column("valid_till", sa.Date()), + ) + op.create_exclude_constraint( + "uq_periods_valid_from", + "periods", + (func.daterange(p.c.valid_from, p.c.valid_till, text("'[]'")), "&&"), ) op.create_table( "recipes", - sa.Column("recipe_id", postgresql.UUID(), nullable=False), - sa.Column("product_id", postgresql.UUID(), nullable=False), - sa.Column("quantity", sa.Numeric(), nullable=False), - sa.Column("cost_price", sa.Numeric(), nullable=False), - sa.Column("sale_price", sa.Numeric(), nullable=False), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("sku_id", postgresql.UUID(), nullable=False), + sa.Column("recipe_yield", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("cost_price", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("sale_price", sa.Numeric(precision=15, scale=2), nullable=False), sa.Column("notes", sa.Unicode(length=255), nullable=True), - sa.Column("valid_from", sa.Date(), nullable=False), - sa.Column("valid_to", sa.Date(), nullable=False), - sa.Column("effective_from", sa.Date(), nullable=False), - sa.Column("effective_to", sa.Date(), nullable=True), + sa.Column("period_id", postgresql.UUID(as_uuid=True), nullable=False), sa.ForeignKeyConstraint( - ["product_id"], - ["products.ProductID"], - name=op.f("fk_recipes_product_id_products"), + ["sku_id"], + ["stock_keeping_units.id"], + name=op.f("fk_recipes_sku_id_stock_keeping_units"), ), - sa.PrimaryKeyConstraint("recipe_id", name=op.f("pk_recipes")), + sa.ForeignKeyConstraint( + ["period_id"], + ["periods.id"], + name=op.f("fk_recipes_period_id_periods"), + ), + sa.PrimaryKeyConstraint("id", name=op.f("pk_recipes")), + sa.UniqueConstraint("sku_id", "period_id", name=op.f("uq_recipes_sku_id")), ) op.create_table( - "salary_deductions", - sa.Column("SalaryDeductionID", postgresql.UUID(), nullable=False), - sa.Column("VoucherID", postgresql.UUID(), nullable=False), - sa.Column("JournalID", postgresql.UUID(), nullable=False), - sa.Column("GrossSalary", sa.Integer(), nullable=True), - sa.Column("DaysWorked", sa.Integer(), nullable=True), - sa.Column("EsiEmployee", sa.Integer(), nullable=True), - sa.Column("PfEmployee", sa.Integer(), nullable=True), - sa.Column("EsiEmployer", sa.Integer(), nullable=True), - sa.Column("PfEmployer", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint( - ["JournalID"], - ["journals.JournalID"], - name=op.f("fk_salary_deductions_JournalID_journals"), - ), - sa.ForeignKeyConstraint( - ["VoucherID"], - ["vouchers.VoucherID"], - name=op.f("fk_salary_deductions_VoucherID_vouchers"), - ), - sa.PrimaryKeyConstraint("SalaryDeductionID", name=op.f("pk_salary_deductions")), - ) - op.create_table( - "service_charges", + "employee_benefit", sa.Column("id", postgresql.UUID(), nullable=False), sa.Column("voucher_id", postgresql.UUID(), nullable=False), sa.Column("journal_id", postgresql.UUID(), nullable=False), - sa.Column("days_worked", sa.Integer(), nullable=False), - sa.Column("points", sa.Numeric(precision=5, scale=2), nullable=False), + sa.Column("gross_salary", sa.Integer(), nullable=True), + sa.Column("days_worked", sa.Integer(), nullable=True), + sa.Column("esi_employee", sa.Integer(), nullable=True), + sa.Column("pf_employee", sa.Integer(), nullable=True), + sa.Column("esi_employer", sa.Integer(), nullable=True), + sa.Column("pf_employer", sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ["journal_id"], - ["journals.JournalID"], - name=op.f("fk_service_charges_journal_id_journals"), + ["journals.id"], + name=op.f("fk_employee_benefit_journal_id_journals"), ), sa.ForeignKeyConstraint( ["voucher_id"], - ["vouchers.VoucherID"], - name=op.f("fk_service_charges_voucher_id_vouchers"), + ["vouchers.id"], + name=op.f("fk_employee_benefit_voucher_id_vouchers"), ), - sa.PrimaryKeyConstraint("id", name=op.f("pk_service_charges")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_employee_benefit")), + ) + op.create_table( + "incentives", + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("voucher_id", postgresql.UUID(), nullable=False), + sa.Column("journal_id", postgresql.UUID(), nullable=False), + sa.Column("days_worked", sa.Numeric(precision=5, scale=1), nullable=False), + sa.Column("points", sa.Numeric(precision=5, scale=2), nullable=False), + sa.ForeignKeyConstraint( + ["journal_id"], + ["journals.id"], + name=op.f("fk_incentives_journal_id_journals"), + ), + sa.ForeignKeyConstraint( + ["voucher_id"], + ["vouchers.id"], + name=op.f("fk_incentives_voucher_id_vouchers"), + ), + sa.PrimaryKeyConstraint("id", name=op.f("pk_incentives")), ) op.create_table( "inventories", - sa.Column("InventoryID", postgresql.UUID(), nullable=False), - sa.Column("VoucherID", postgresql.UUID(), nullable=False), - sa.Column("ProductID", postgresql.UUID(), nullable=False), - sa.Column("BatchID", postgresql.UUID(), nullable=False), - sa.Column("Quantity", sa.Numeric(), nullable=True), - sa.Column("Rate", sa.Numeric(), nullable=True), - sa.Column("Tax", sa.Numeric(), nullable=True), - sa.Column("Discount", sa.Numeric(), nullable=True), + sa.Column("id", postgresql.UUID(), nullable=False), + sa.Column("voucher_id", postgresql.UUID(), nullable=False), + sa.Column("batch_id", postgresql.UUID(), nullable=False), + sa.Column("quantity", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("rate", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("tax", sa.Numeric(precision=15, scale=5), nullable=False), + sa.Column("discount", sa.Numeric(precision=15, scale=5), nullable=False), sa.ForeignKeyConstraint( - ["BatchID"], - ["batches.BatchID"], - name=op.f("fk_inventories_BatchID_batches"), + ["batch_id"], + ["batches.id"], + name=op.f("fk_inventories_batch_id_batches"), ), sa.ForeignKeyConstraint( - ["ProductID"], - ["products.ProductID"], - name=op.f("fk_inventories_ProductID_products"), + ["voucher_id"], + ["vouchers.id"], + name=op.f("fk_inventories_voucher_id_vouchers"), ), - sa.ForeignKeyConstraint( - ["VoucherID"], - ["vouchers.VoucherID"], - name=op.f("fk_inventories_VoucherID_vouchers"), - ), - sa.PrimaryKeyConstraint("InventoryID", name=op.f("pk_inventories")), - sa.UniqueConstraint("VoucherID", "BatchID", name=op.f("uq_inventories_VoucherID")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_inventories")), + sa.UniqueConstraint("voucher_id", "batch_id", name=op.f("uq_inventories_voucher_id")), ) - op.create_index(op.f("ix_inventories_VoucherID"), "inventories", ["VoucherID"], unique=False) + op.create_index(op.f("ix_inventories_voucher_id"), "inventories", ["voucher_id"], unique=False) op.create_table( "recipe_items", - sa.Column("recipe_item_id", postgresql.UUID(), nullable=False), + sa.Column("id", postgresql.UUID(), nullable=False), sa.Column("recipe_id", postgresql.UUID(), nullable=False), sa.Column("product_id", postgresql.UUID(), nullable=False), - sa.Column("quantity", sa.Integer(), nullable=False), - sa.Column("price", sa.Integer(), nullable=False), + sa.Column("quantity", sa.Numeric(precision=15, scale=2), nullable=False), + sa.Column("price", sa.Numeric(precision=15, scale=2), nullable=False), sa.ForeignKeyConstraint( ["product_id"], - ["products.ProductID"], + ["products.id"], name=op.f("fk_recipe_items_product_id_products"), ), sa.ForeignKeyConstraint( ["recipe_id"], - ["recipes.recipe_id"], + ["recipes.id"], name=op.f("fk_recipe_items_recipe_id_recipes"), ), - sa.PrimaryKeyConstraint("recipe_item_id", name=op.f("pk_recipe_items")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_recipe_items")), sa.UniqueConstraint("recipe_id", "product_id", name=op.f("uq_recipe_items_recipe_id")), ) - # ### end Alembic commands ### + op.create_table( + "rate_contracts", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("date", sa.Date(), nullable=False), + sa.Column("vendor_id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("valid_from", sa.Date(), nullable=True), + sa.Column("valid_till", sa.Date(), nullable=True), + sa.Column("narration", sa.Unicode(length=1000), nullable=False), + sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("creation_date", sa.DateTime(), nullable=False), + sa.Column("last_edit_date", sa.DateTime(), nullable=False), + sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_rate_contracts_user_id_users")), + sa.ForeignKeyConstraint(["vendor_id"], ["accounts.id"], name=op.f("fk_rate_contracts_vendor_id_accounts")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_rate_contracts")), + ) + op.create_index(op.f("ix_rate_contracts_date"), "rate_contracts", ["date"], unique=False) + op.create_table( + "rate_contract_items", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("rate_contract_id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("sku_id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("cost_price", sa.Numeric(precision=15, scale=2), nullable=False), + sa.ForeignKeyConstraint( + ["sku_id"], ["stock_keeping_units.id"], name=op.f("fk_rate_contract_items_sku_id_stock_keeping_units") + ), + sa.ForeignKeyConstraint( + ["rate_contract_id"], + ["rate_contracts.id"], + name=op.f("fk_rate_contract_items_rate_contract_id_rate_contracts"), + ), + sa.PrimaryKeyConstraint("id", name=op.f("pk_rate_contract_items")), + sa.UniqueConstraint("rate_contract_id", "sku_id", name=op.f("uq_rate_contract_items_rate_contract_id")), + ) + op.create_index( + op.f("ix_rate_contract_items_rate_contract_id"), "rate_contract_items", ["rate_contract_id"], unique=False + ) + op.create_table( + "closing_stocks", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("date", sa.Date(), nullable=False), + sa.Column("cost_centre_id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("sku_id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("quantity", sa.Numeric(precision=15, scale=2), nullable=False), + sa.ForeignKeyConstraint( + ["cost_centre_id"], ["cost_centres.id"], name=op.f("fk_closing_stocks_cost_centre_id_cost_centres") + ), + sa.ForeignKeyConstraint( + ["sku_id"], ["stock_keeping_units.id"], name=op.f("fk_closing_stocks_sku_id_stock_keeping_units") + ), + sa.PrimaryKeyConstraint("id", name=op.f("pk_closing_stocks")), + sa.UniqueConstraint("date", "cost_centre_id", "sku_id", name=op.f("uq_closing_stocks_date")), + ) def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.drop_table("recipe_items") - op.drop_index(op.f("ix_inventories_VoucherID"), table_name="inventories") - op.drop_table("inventories") - op.drop_table("service_charges") - op.drop_table("salary_deductions") - op.drop_table("recipes") - op.drop_table("fingerprints") - op.drop_table("batches") - op.drop_table("attendances") - op.drop_table("products") - op.drop_index(op.f("ix_journals_VoucherID"), table_name="journals") - op.drop_table("journals") - op.drop_table("employees") - op.drop_index(op.f("ix_vouchers_date"), table_name="vouchers") - op.drop_table("vouchers") - op.drop_table("auth_usergroups") - op.drop_table("auth_rolegroups") - op.drop_table("auth_login_history") - op.drop_table("accounts") - op.drop_table("settings") - op.drop_table("product_groups") - op.drop_table("images") - op.drop_table("cost_centres") - op.drop_table("auth_users") - op.drop_table("auth_roles") - op.drop_table("auth_groups") - op.drop_table("auth_clients") + pass # ### end Alembic commands ### diff --git a/brewman/alembic/versions/0bfb24f16ef2_recipe_validity_not_null.py b/brewman/alembic/versions/0bfb24f16ef2_recipe_validity_not_null.py deleted file mode 100644 index 18772157..00000000 --- a/brewman/alembic/versions/0bfb24f16ef2_recipe_validity_not_null.py +++ /dev/null @@ -1,26 +0,0 @@ -"""recipe validity not null - -Revision ID: 0bfb24f16ef2 -Revises: b13dbf97bd21 -Create Date: 2021-11-10 07:39:05.369603 - -""" -import sqlalchemy as sa - -from alembic import op - - -# revision identifiers, used by Alembic. -revision = "0bfb24f16ef2" -down_revision = "b13dbf97bd21" -branch_labels = None -depends_on = None - - -def upgrade(): - op.alter_column("recipes", "valid_from", existing_type=sa.DATE(), nullable=False) - op.alter_column("recipes", "valid_till", existing_type=sa.DATE(), nullable=False) - - -def downgrade(): - pass diff --git a/brewman/alembic/versions/0e6c5953a63f_recipe.py b/brewman/alembic/versions/0e6c5953a63f_recipe.py deleted file mode 100644 index 7052d8d1..00000000 --- a/brewman/alembic/versions/0e6c5953a63f_recipe.py +++ /dev/null @@ -1,55 +0,0 @@ -"""recipe - -Revision ID: 0e6c5953a63f -Revises: c39eb451a683 -Create Date: 2021-11-01 12:11:16.813756 - -""" -import sqlalchemy as sa - -from alembic import op -from sqlalchemy import column, func, table, text -from sqlalchemy.dialects import postgresql - - -# revision identifiers, used by Alembic. -revision = "0e6c5953a63f" -down_revision = "c39eb451a683" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column("recipes", "product_id", new_column_name="sku_id") - op.alter_column("recipes", "valid_to", new_column_name="valid_till", existing_type=sa.DATE(), nullable=True) - op.alter_column("recipes", "valid_from", existing_type=sa.DATE(), nullable=True) - op.drop_constraint("recipes_product_id_fkey", "recipes", type_="foreignkey") - op.create_foreign_key( - op.f("fk_recipes_sku_id_stock_keeping_units"), "recipes", "stock_keeping_units", ["sku_id"], ["id"] - ) - op.drop_column("recipes", "effective_to") - op.drop_column("recipes", "effective_from") - - recipe = table( - "recipes", - column("sku_id", postgresql.UUID(as_uuid=True)), - column("valid_from", sa.Date()), - column("valid_till", sa.Date()), - ) - - op.create_exclude_constraint( - "uq_recipes_sku_id", - "recipes", - (recipe.c.sku_id, "="), - (func.daterange(recipe.c.valid_from, recipe.c.valid_till, text("'[]'")), "&&"), - ) - # ### end Alembic commands ### - - -# delete from recipe_items where recipe_id in (select id from recipes where product_id in (select product_id from recipes group by product_id having count(*) > 1) and effective_to is not null); -# delete from recipes where id in (select id from recipes where product_id in (select product_id from recipes group by product_id having count(*) > 1) and effective_to is not null); - - -def downgrade(): - pass diff --git a/brewman/alembic/versions/185c674cc392_load_data.py b/brewman/alembic/versions/185c674cc392_load_data.py new file mode 100644 index 00000000..01ca8eac --- /dev/null +++ b/brewman/alembic/versions/185c674cc392_load_data.py @@ -0,0 +1,731 @@ +"""Load data + +Revision ID: 185c674cc392 +Revises: 0bf3d70ee7de +Create Date: 2022-10-31 06:23:13.091598 + +""" +from hashlib import md5 + +import sqlalchemy as sa + +from alembic import op +from sqlalchemy import column, func, insert, select, table +from sqlalchemy.dialects import postgresql + + +# revision identifiers, used by Alembic. +revision = "185c674cc392" +down_revision = "0bf3d70ee7de" +branch_labels = None +depends_on = None + + +def upgrade(): + users() + roles() + permissions() + add_all_permissions_to_owner() + add_all_roles_to_admin() + account_types() + cost_centres() + accounts() + products() + # ### end Alembic commands ### + + +def users(): + users = table( + "users", + column("id", postgresql.UUID()), + column("username", sa.String), + column("password", sa.String), + column("disabled", sa.Boolean), + ) + op.execute( + users.insert().values( + id="8de98592-76d9-c74d-bb3f-d6184d388b5a", + username="Admin", + password=md5("123456".encode("utf-8") + "Salt".encode("utf-8")).hexdigest(), + disabled=False, + ) + ) + + +def roles(): + roles = table("roles", column("id", postgresql.UUID()), column("name", sa.String)) + op.execute( + roles.insert().values( + id="52e08c0c-048a-784f-be10-6e129ad4b5d4", + name="Owner", + ) + ) + op.execute( + roles.insert().values( + id="bc4c2d23-437a-984d-abd4-7d5fce677547", + name="Accountant", + ) + ) + op.execute( + roles.insert().values( + id="cfc44fa7-3392-5b45-b311-5959333f568f", + name="Accounts Manager", + ) + ) + + +def permissions(): + permissions = table("permissions", column("id", postgresql.UUID()), column("name", sa.String)) + op.execute( + permissions.insert().values( + id="09d05434-a09a-fa45-963b-769a2e3fc667", + name="Attendance", + ) + ) + op.execute( + permissions.insert().values( + id="3b099fec-ddc5-4243-b30e-afb78d9ca14a", + name="Trial Balance", + ) + ) + op.execute( + permissions.insert().values( + id="c4d3ae29-420b-ea4c-ae90-00a356263fd9", + name="Cash Flow", + ) + ) + op.execute( + permissions.insert().values( + id="6fcc1a20-6aec-e840-b334-1632b34aeab8", + name="Cost Centres", + ) + ) + op.execute( + permissions.insert().values( + id="c5b7d9d7-f178-0e45-8ea4-bf4e08ec901b", + name="Users", + ) + ) + op.execute( + permissions.insert().values( + id="c3edb554-a057-8942-8030-37b8e926d583", + name="Daybook", + ) + ) + op.execute( + permissions.insert().values( + id="d6675817-ddf5-bf40-9de6-fa223eb4aaa6", + name="Edit Posted Vouchers", + ) + ) + op.execute( + permissions.insert().values( + id="e4edd0ac-7f5d-e64d-8611-73fdc4cd8ba2", + name="Employees", + ) + ) + op.execute( + permissions.insert().values( + id="d9c45323-f997-ba46-9407-8a7145f0828b", + name="Fingerprints", + ) + ) + op.execute( + permissions.insert().values( + id="03b602eb-f58a-b94f-af58-8cb47d7849d0", + name="Issue", + ) + ) + op.execute( + permissions.insert().values( + id="7661388f-62ce-1c41-8e0d-0326ee5d4018", + name="Journal", + ) + ) + op.execute( + permissions.insert().values( + id="f438262f-72dd-2f4e-9186-5abc3af44fba", + name="Accounts", + ) + ) + op.execute( + permissions.insert().values( + id="018a2408-e804-1446-90c5-b015829da6ba", + name="Product Ledger", + ) + ) + op.execute( + permissions.insert().values( + id="b67b2062-5ca7-134f-8258-5d284dd92426", + name="Backdated Vouchers", + ) + ) + op.execute( + permissions.insert().values( + id="36e741da-1a57-b047-a59e-dcd58fcf4338", + name="Post Vouchers", + ) + ) + op.execute( + permissions.insert().values( + id="74fa6d21-eebb-e14c-8153-bebc57190ab4", + name="Products", + ) + ) + op.execute( + permissions.insert().values( + id="08413a22-cf88-fd43-b2b7-365d2951d99f", + name="Product Groups", + ) + ) + op.execute( + permissions.insert().values( + id="0492ebb3-76f3-204e-ab94-bbfe880f0691", + name="Profit & Loss", + ) + ) + op.execute( + permissions.insert().values( + id="12335acb-8630-2d41-a191-1517c8d172de", + name="Purchase", + ) + ) + op.execute( + permissions.insert().values( + id="78a6422b-aa11-174c-9dfa-412a99e87e02", + name="Purchase Entries", + ) + ) + op.execute( + permissions.insert().values( + id="ab33196e-d9e4-114c-ac8c-997954363756", + name="Purchase Return", + ) + ) + op.execute( + permissions.insert().values( + id="ffb7fb65-d42c-424d-9ff1-45069e3b4a29", + name="Recipes", + ) + ) + op.execute( + permissions.insert().values( + id="97515732-24e4-c94d-9585-d4bd7f6c7891", + name="Closing Stock", + ) + ) + op.execute( + permissions.insert().values( + id="a2120944-243f-3f49-be57-0ad633ce4801", + name="Ledger", + ) + ) + op.execute( + permissions.insert().values( + id="d462842b-baf1-2343-95e5-ffdba9bbc163", + name="Raw Material Cost", + ) + ) + op.execute( + permissions.insert().values( + id="a8328891-7ce2-a943-8c29-2eabc1ffeea3", + name="Edit Other User's Vouchers", + ) + ) + op.execute( + permissions.insert().values( + id="cfad44f0-f2a9-7045-89d7-9019cf0f371a", + name="Clients", + ) + ) + op.execute( + permissions.insert().values( + id="92d70e80-1c32-384d-959e-abf84b804696", + name="Employee Benefit", + ) + ) + op.execute( + permissions.insert().values( + id="f586d128-b6d9-4090-a913-78fcbdb68e59", + name="Messages", + ) + ) + op.execute( + permissions.insert().values( + id="d52de0be-9388-4b0b-a359-7e122ab6e53a", + name="Lock Date", + ) + ) + op.execute( + permissions.insert().values( + id="2c40f7cf-67fc-4efa-a670-8d16a2e7884d", + name="Net Transactions", + ) + ) + op.execute( + permissions.insert().values( + id="40deb018-b8f2-460a-88be-8972c9fcdf04", + name="Balance Sheet", + ) + ) + op.execute( + permissions.insert().values( + id="197ebcd2-bc4a-4b65-a138-ce942ece32ea", + name="Advanced Delete", + ) + ) + op.execute( + permissions.insert().values( + id="de204a88-5f9d-4579-a2d6-aa2f25efde42", + name="Rebase", + ) + ) + op.execute( + permissions.insert().values( + id="aecaf82f-aa41-4634-b754-0c1308b621b1", + name="Reset Stock", + ) + ) + op.execute( + permissions.insert().values( + id="a5cb51cb-e38e-4705-84a7-cc1e9a8b866b", + name="Reconcile", + ) + ) + op.execute( + permissions.insert().values( + id="20b707ee-2b59-41ad-be87-76d5fe1efca8", + name="Stock Movement", + ) + ) + op.execute( + permissions.insert().values( + id="cf7019c8-3fd3-45b0-9a42-601029ce5b71", + name="Purchases", + ) + ) + op.execute( + permissions.insert().values( + id="53eecc09-bd06-4890-b6f5-6885dda762d4", + name="Dashboard", + ) + ) + op.execute( + permissions.insert().values( + id="99b56390-96c2-4f3d-8b0f-5ae3c868594f", + name="Incentive", + ) + ) + op.execute( + permissions.insert().values( + id="770532e4-21de-4712-8a6b-4ff9fd63a503", + name="Maintenance", + ) + ) + op.execute(permissions.insert().values(id="f97589c6-df9f-45d3-874d-4245a4d99ade", name="Rate Contracts")) + + +def add_all_permissions_to_owner(): + r = table("roles", column("id", postgresql.UUID()), column("name", sa.String)) + p = table( + "permissions", + column("id", postgresql.UUID(as_uuid=True)), + column("name", sa.Unicode(length=255)), + ) + rp = table( + "role_permissions", + column("id", postgresql.UUID(as_uuid=True)), + column("permission_id", postgresql.UUID(as_uuid=True)), + column("role_id", postgresql.UUID(as_uuid=True)), + ) + op.execute( + insert(rp).from_select( + [rp.c.id, rp.c.role_id, rp.c.permission_id], + select( + [ + sa.text("gen_random_uuid()"), + select([func.distinct(r.c.id)]).where(r.c.name.ilike("Owner")).as_scalar(), + p.c.id, + ] + ), + ) + ) + + +def add_all_roles_to_admin(): + u = table("users", column("id", postgresql.UUID()), column("username", sa.String)) + r = table("roles", column("id", postgresql.UUID()), column("name", sa.String)) + ur = table( + "user_roles", + column("id", postgresql.UUID(as_uuid=True)), + column("user_id", postgresql.UUID(as_uuid=True)), + column("role_id", postgresql.UUID(as_uuid=True)), + ) + op.execute( + insert(ur).from_select( + [ur.c.id, ur.c.user_id, ur.c.role_id], + select( + [ + sa.text("gen_random_uuid()"), + select([func.distinct(u.c.id)]).where(u.c.username.ilike("Admin")).as_scalar(), + r.c.id, + ] + ), + ) + ) + + +def account_types(): + at = table( + "account_types", + column("id", sa.Integer()), + column("name", sa.Unicode(length=255)), + column("balance_sheet", sa.Boolean()), + column("debit", sa.Boolean()), + column("cash_flow_classification", sa.Unicode(length=255)), + column("order", sa.Integer()), + column("show_in_list", sa.Boolean()), + ) + op.execute( + at.insert().values( + id=1, + name="Cash", + balance_sheet=True, + debit=True, + cash_flow_classification="Cash", + order=10000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=2, + name="Purchase", + balance_sheet=False, + debit=True, + cash_flow_classification="Operating", + order=20000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=3, + name="Sale", + balance_sheet=False, + debit=False, + cash_flow_classification="Operating", + order=10000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=4, + name="Assets", + balance_sheet=True, + debit=True, + cash_flow_classification="Investing", + order=20000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=5, + name="Capital", + balance_sheet=True, + debit=False, + cash_flow_classification="Financing", + order=70000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=6, + name="Debtors", + balance_sheet=True, + debit=True, + cash_flow_classification="Operating", + order=30000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=7, + name="Expenses", + balance_sheet=False, + debit=True, + cash_flow_classification="Operating", + order=40000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=9, + name="Creditors", + balance_sheet=True, + debit=False, + cash_flow_classification="Operating", + order=60000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=10, + name="Salary", + balance_sheet=True, + debit=True, + cash_flow_classification="Operating", + order=40000, + show_in_list=False, + ) + ) + op.execute( + at.insert().values( + id=11, + name="Liabilities", + balance_sheet=True, + debit=False, + cash_flow_classification="Operating", + order=50000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=12, + name="Revenue", + balance_sheet=False, + debit=False, + cash_flow_classification="Operating", + order=30000, + show_in_list=True, + ) + ) + op.execute( + at.insert().values( + id=13, + name="Tax", + balance_sheet=True, + debit=False, + cash_flow_classification="Operating", + order=80000, + show_in_list=True, + ) + ) + + +def cost_centres(): + cc = table( + "cost_centres", + column("id", postgresql.UUID()), + column("name", sa.String), + sa.Column("is_fixture", sa.Boolean()), + ) + op.execute(cc.insert().values(id="36f59436-522a-0746-ae94-e0f746bf6c0d", name="Overall", is_fixture=True)) + op.execute(cc.insert().values(id="7b845f95-dfef-fa4a-897c-f0baf15284a3", name="Purchase", is_fixture=True)) + op.execute(cc.insert().values(id="b2d398ce-e3cc-c542-9feb-5d7783e899df", name="Kitchen", is_fixture=True)) + + +def accounts(): + acc = table( + "accounts", + sa.Column("id", postgresql.UUID()), + sa.Column("code", sa.Integer()), + sa.Column("name", sa.Unicode(length=255)), + sa.Column("type", sa.Integer()), + sa.Column("account_type", sa.Unicode(length=50)), + sa.Column("is_starred", sa.Boolean()), + sa.Column("is_active", sa.Boolean()), + sa.Column("is_reconcilable", sa.Boolean()), + sa.Column("cost_centre_id", postgresql.UUID()), + sa.Column("is_fixture", sa.Boolean()), + ) + op.execute( + acc.insert().values( + code=1, + name="All Purchases", + type=2, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="7b845f95-dfef-fa4a-897c-f0baf15284a3", + id="240dd899-c413-854c-a7eb-67a29d154490", + is_fixture=True, + ) + ) + op.execute( + acc.insert().values( + code=1, + name="Local Purchase", + type=9, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="36f59436-522a-0746-ae94-e0f746bf6c0d", + id="d2b75912-505f-2548-9093-466dfff6a0f9", + is_fixture=True, + ) + ) + op.execute( + acc.insert().values( + code=1, + name="ESI/PF - Payable", + type=11, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="36f59436-522a-0746-ae94-e0f746bf6c0d", + id="42277912-cc18-854b-b134-9f4b00dba419", + is_fixture=True, + ) + ) + op.execute( + acc.insert().values( + code=2, + name="ESI/PF - Expense", + type=7, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="36f59436-522a-0746-ae94-e0f746bf6c0d", + id="d2a1a286-e900-764b-a1a5-9f4b00dbb940", + is_fixture=True, + ) + ) + op.execute( + acc.insert().values( + code=1, + name="Cash in Hand", + type=1, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="36f59436-522a-0746-ae94-e0f746bf6c0d", + id="ed2341bb-80b8-9649-90db-f9aaca183bb3", + is_fixture=True, + ) + ) + op.execute( + acc.insert().values( + code=1, + name="Staff Salary", + type=7, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="36f59436-522a-0746-ae94-e0f746bf6c0d", + id="5c2b54d0-c174-004d-a0d5-92cdaadcefa7", + is_fixture=True, + ) + ) + op.execute( + acc.insert().values( + code=2, + name="Incentives", + type=11, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="36f59436-522a-0746-ae94-e0f746bf6c0d", + id="b7eff754-e8ba-e047-ab06-9132c15c7640", + is_fixture=True, + ) + ) + op.execute( + acc.insert().values( + code=1, + name="Suspense", + type=4, + account_type="", + is_starred=False, + is_active=True, + is_reconcilable=False, + cost_centre_id="36f59436-522a-0746-ae94-e0f746bf6c0d", + id="3854e317-6f3b-5142-ab26-9c44d4cddd08", + is_fixture=True, + ) + ) + + +def products(): + pg = table( + "product_groups", + sa.Column("id", postgresql.UUID()), + sa.Column("name", sa.Unicode(length=255)), + sa.Column("is_fixture", sa.Boolean()), + ) + op.execute(pg.insert().values(id="ae59a20c-87bb-444a-8abb-915ad5e58b83", name="Suspense", is_fixture=True)) + op.execute(pg.insert().values(id="e6bf81b9-1e9b-499f-81d5-ab5662e9d9b1", name="Semi", is_fixture=True)) + op.execute(pg.insert().values(id="dad46805-f577-4e5b-8073-9b788e0173fc", name="Menu Items", is_fixture=True)) + + p = table( + "products", + sa.Column("id", postgresql.UUID()), + sa.Column("code", sa.Integer()), + sa.Column("name", sa.Unicode(length=255)), + sa.Column("fraction_units", sa.Unicode(length=255)), + sa.Column("product_group_id", postgresql.UUID()), + sa.Column("account_id", postgresql.UUID()), + sa.Column("is_fixture", sa.Boolean()), + sa.Column("is_active", sa.Boolean()), + sa.Column("is_fixture", sa.Boolean()), + sa.Column("is_purchased", sa.Boolean()), + sa.Column("is_sold", sa.Boolean()), + ) + + op.execute( + p.insert().values( + id="aa79a643-9ddc-4790-ac7f-a41f9efb4c15", + code=1, + name="Suspense", + fraction_units="X", + product_group_id="ae59a20c-87bb-444a-8abb-915ad5e58b83", + account_id="240dd899-c413-854c-a7eb-67a29d154490", + is_active=False, + is_fixture=True, + is_purchased=False, + is_sold=False, + ) + ) + + sku = table( + "stock_keeping_units", + sa.Column("id", postgresql.UUID()), + sa.Column("product_id", postgresql.UUID()), + sa.Column("units", sa.Unicode(length=255)), + sa.Column("fraction", sa.Numeric(precision=15, scale=5)), + sa.Column("product_yield", sa.Numeric(precision=15, scale=5)), + sa.Column("cost_price", sa.Numeric(precision=15, scale=5)), + sa.Column("sale_price", sa.Numeric(precision=15, scale=5)), + ) + + op.execute( + sku.insert().values( + id="aa79a643-9ddc-4790-ac7f-a41f9efb4c15", + product_id="aa79a643-9ddc-4790-ac7f-a41f9efb4c15", + units="X", + fraction=1, + product_yield=1, + cost_price=0, + sale_price=0, + ) + ) + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/brewman/alembic/versions/226cadcec9ac_timezone.py b/brewman/alembic/versions/226cadcec9ac_timezone.py deleted file mode 100644 index 401c1b95..00000000 --- a/brewman/alembic/versions/226cadcec9ac_timezone.py +++ /dev/null @@ -1,112 +0,0 @@ -"""timezone - -Revision ID: 226cadcec9ac -Revises: 002f51d87565 -Create Date: 2021-04-19 09:58:54.556818 - -""" -import sqlalchemy as sa - -from alembic import op -from sqlalchemy.dialects import postgresql - - -# revision identifiers, used by Alembic. -revision = "226cadcec9ac" -down_revision = "002f51d87565" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column( - "attendances", - "creation_date", - existing_type=postgresql.TIMESTAMP(timezone=True), - type_=sa.DateTime(), - existing_nullable=True, - ) - op.alter_column( - "auth_clients", - "creation_date", - existing_type=postgresql.TIMESTAMP(timezone=True), - type_=sa.DateTime(), - existing_nullable=False, - ) - op.alter_column( - "auth_login_history", - "date", - existing_type=postgresql.TIMESTAMP(timezone=True), - type_=sa.DateTime(), - existing_nullable=False, - ) - op.alter_column( - "images", - "creation_date", - existing_type=postgresql.TIMESTAMP(timezone=True), - type_=sa.DateTime(), - existing_nullable=False, - ) - op.alter_column( - "vouchers", - "creation_date", - existing_type=postgresql.TIMESTAMP(timezone=True), - type_=sa.DateTime(), - existing_nullable=False, - ) - op.alter_column( - "vouchers", - "last_edit_date", - existing_type=postgresql.TIMESTAMP(timezone=True), - type_=sa.DateTime(), - existing_nullable=False, - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column( - "vouchers", - "last_edit_date", - existing_type=sa.DateTime(), - type_=postgresql.TIMESTAMP(timezone=True), - existing_nullable=False, - ) - op.alter_column( - "vouchers", - "creation_date", - existing_type=sa.DateTime(), - type_=postgresql.TIMESTAMP(timezone=True), - existing_nullable=False, - ) - op.alter_column( - "images", - "creation_date", - existing_type=sa.DateTime(), - type_=postgresql.TIMESTAMP(timezone=True), - existing_nullable=False, - ) - op.alter_column( - "auth_login_history", - "date", - existing_type=sa.DateTime(), - type_=postgresql.TIMESTAMP(timezone=True), - existing_nullable=False, - ) - op.alter_column( - "auth_clients", - "creation_date", - existing_type=sa.DateTime(), - type_=postgresql.TIMESTAMP(timezone=True), - existing_nullable=False, - ) - op.alter_column( - "attendances", - "creation_date", - existing_type=sa.DateTime(), - type_=postgresql.TIMESTAMP(timezone=True), - existing_nullable=True, - ) - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/6fb6c96fd408_prevent_duplicate_attendance.py b/brewman/alembic/versions/6fb6c96fd408_prevent_duplicate_attendance.py deleted file mode 100644 index 9250acf6..00000000 --- a/brewman/alembic/versions/6fb6c96fd408_prevent_duplicate_attendance.py +++ /dev/null @@ -1,35 +0,0 @@ -"""att - -Revision ID: 6fb6c96fd408 -Revises: 071e8f29d257 -Create Date: 2021-09-11 17:03:39.649878 - -""" -import sqlalchemy as sa - -from alembic import op - - -# revision identifiers, used by Alembic. -revision = "6fb6c96fd408" -down_revision = "071e8f29d257" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_index( - "only_one_valid_attendance", - "attendances", - ["employee_id", "date"], - unique=True, - postgresql_where=sa.text("is_valid = true"), - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index("only_one_valid_attendance", table_name="attendances", postgresql_where=sa.text("is_valid = true")) - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/7ba0aff64237_enums.py b/brewman/alembic/versions/7ba0aff64237_enums.py deleted file mode 100644 index 0d5a2c51..00000000 --- a/brewman/alembic/versions/7ba0aff64237_enums.py +++ /dev/null @@ -1,224 +0,0 @@ -"""enums - -Revision ID: 7ba0aff64237 -Revises: d6f96b7b16c6 -Create Date: 2021-10-29 18:26:58.200044 - -""" -import sqlalchemy as sa - -from alembic import op -from sqlalchemy import column, table - - -# revision identifiers, used by Alembic. -revision = "7ba0aff64237" -down_revision = "d6f96b7b16c6" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - voucher_type = sa.Enum( - "JOURNAL", - "PURCHASE", - "ISSUE", - "PAYMENT", - "RECEIPT", - "PURCHASE_RETURN", - "OPENING_ACCOUNTS", - "OPENING_BATCHES", - "CLOSING_STOCK", - "OPENING_BALANCE", - "CLOSING_BALANCE", - "EMPLOYEE_BENEFIT", - "INCENTIVE", - name="voucher_type", - ) - voucher_type.create(op.get_bind()) - op.add_column( - "vouchers", - sa.Column( - "vt", - voucher_type, - nullable=True, - ), - ) - v = table("vouchers", column("voucher_type", sa.INTEGER()), column("vt", voucher_type)) - op.execute(v.update().where(v.c.voucher_type == 1).values(vt="JOURNAL")) - op.execute(v.update().where(v.c.voucher_type == 2).values(vt="PURCHASE")) - op.execute(v.update().where(v.c.voucher_type == 3).values(vt="ISSUE")) - op.execute(v.update().where(v.c.voucher_type == 4).values(vt="PAYMENT")) - op.execute(v.update().where(v.c.voucher_type == 5).values(vt="RECEIPT")) - op.execute(v.update().where(v.c.voucher_type == 6).values(vt="PURCHASE_RETURN")) - op.execute(v.update().where(v.c.voucher_type == 7).values(vt="OPENING_ACCOUNTS")) - op.execute(v.update().where(v.c.voucher_type == 8).values(vt="OPENING_BATCHES")) - op.execute(v.update().where(v.c.voucher_type == 9).values(vt="CLOSING_STOCK")) - op.execute(v.update().where(v.c.voucher_type == 13).values(vt="INCENTIVE")) - op.drop_column("vouchers", "voucher_type") - - op.alter_column("vouchers", "vt", new_column_name="voucher_type", existing_nullable=True, nullable=False) - - op.create_table( - "account_types", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.Unicode(length=255), nullable=False), - sa.Column("balance_sheet", sa.Boolean(), nullable=False), - sa.Column("debit", sa.Boolean(), nullable=False), - sa.Column("cash_flow_classification", sa.Unicode(length=255), nullable=False), - sa.Column("order", sa.Integer(), nullable=False), - sa.Column("show_in_list", sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint("id", name=op.f("pk_account_types")), - sa.UniqueConstraint("name", name=op.f("uq_account_types_name")), - ) - at = table( - "account_types", - column("id", sa.Integer()), - column("name", sa.Unicode(length=255)), - column("balance_sheet", sa.Boolean()), - column("debit", sa.Boolean()), - column("cash_flow_classification", sa.Unicode(length=255)), - column("order", sa.Integer()), - column("show_in_list", sa.Boolean()), - ) - op.execute( - at.insert().values( - id=1, - name="Cash", - balance_sheet=True, - debit=True, - cash_flow_classification="Cash", - order=10000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=2, - name="Purchase", - balance_sheet=False, - debit=True, - cash_flow_classification="Operating", - order=20000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=3, - name="Sale", - balance_sheet=False, - debit=False, - cash_flow_classification="Operating", - order=10000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=4, - name="Assets", - balance_sheet=True, - debit=True, - cash_flow_classification="Investing", - order=20000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=5, - name="Capital", - balance_sheet=True, - debit=False, - cash_flow_classification="Financing", - order=70000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=6, - name="Debtors", - balance_sheet=True, - debit=True, - cash_flow_classification="Operating", - order=30000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=7, - name="Expenses", - balance_sheet=False, - debit=True, - cash_flow_classification="Operating", - order=40000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=9, - name="Creditors", - balance_sheet=True, - debit=False, - cash_flow_classification="Operating", - order=60000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=10, - name="Salary", - balance_sheet=True, - debit=True, - cash_flow_classification="Operating", - order=40000, - show_in_list=False, - ) - ) - op.execute( - at.insert().values( - id=11, - name="Liabilities", - balance_sheet=True, - debit=False, - cash_flow_classification="Operating", - order=50000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=12, - name="Revenue", - balance_sheet=False, - debit=False, - cash_flow_classification="Operating", - order=30000, - show_in_list=True, - ) - ) - op.execute( - at.insert().values( - id=13, - name="Tax", - balance_sheet=True, - debit=False, - cash_flow_classification="Operating", - order=80000, - show_in_list=True, - ) - ) - op.create_foreign_key(op.f("fk_accounts_type_account_types"), "accounts", "account_types", ["type"], ["id"]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - pass - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/ad8b2d208492_settings_validity.py b/brewman/alembic/versions/ad8b2d208492_settings_validity.py deleted file mode 100644 index b7950b24..00000000 --- a/brewman/alembic/versions/ad8b2d208492_settings_validity.py +++ /dev/null @@ -1,42 +0,0 @@ -"""settings validity - -Revision ID: ad8b2d208492 -Revises: 226cadcec9ac -Create Date: 2021-09-08 11:53:14.164305 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -from sqlalchemy import table - - -revision = "ad8b2d208492" -down_revision = "226cadcec9ac" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - set = table("settings") - op.execute(set.delete()) - - setting_type = sa.Enum("VOUCHER_LOCK", name="setting_type") - setting_type.create(op.get_bind()) - op.add_column("settings", sa.Column("setting_type", setting_type, nullable=False)) - op.add_column("settings", sa.Column("valid_from", sa.Date(), nullable=True)) - op.add_column("settings", sa.Column("valid_till", sa.Date(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column("settings", "valid_till") - op.drop_column("settings", "valid_from") - op.drop_column("settings", "setting_type") - setting_type = sa.Enum("VOUCHER_LOCK", name="setting_type") - setting_type.drop(op.get_bind()) - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/b13dbf97bd21_recipe_yield.py b/brewman/alembic/versions/b13dbf97bd21_recipe_yield.py deleted file mode 100644 index c923281b..00000000 --- a/brewman/alembic/versions/b13dbf97bd21_recipe_yield.py +++ /dev/null @@ -1,41 +0,0 @@ -"""recipe yield - -Revision ID: b13dbf97bd21 -Revises: 0e6c5953a63f -Create Date: 2021-11-08 11:51:07.061978 - -""" -import sqlalchemy as sa - -from alembic import op - - -# revision identifiers, used by Alembic. -revision = "b13dbf97bd21" -down_revision = "0e6c5953a63f" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column("recipes", "quantity", new_column_name="recipe_yield") - op.alter_column( - "recipe_items", - "quantity", - existing_type=sa.INTEGER(), - type_=sa.Numeric(precision=15, scale=2), - existing_nullable=False, - ) - op.alter_column( - "recipe_items", - "price", - existing_type=sa.INTEGER(), - type_=sa.Numeric(precision=15, scale=5), - existing_nullable=False, - ) - # ### end Alembic commands ### - - -def downgrade(): - pass diff --git a/brewman/alembic/versions/c39eb451a683_fraction_units.py b/brewman/alembic/versions/c39eb451a683_fraction_units.py deleted file mode 100644 index 7da3e192..00000000 --- a/brewman/alembic/versions/c39eb451a683_fraction_units.py +++ /dev/null @@ -1,52 +0,0 @@ -"""fraction units - -Revision ID: c39eb451a683 -Revises: 7ba0aff64237 -Create Date: 2021-11-01 10:05:46.057929 - -""" -import sqlalchemy as sa - -from alembic import op -from sqlalchemy import Unicode, column, select, table - -# revision identifiers, used by Alembic. -from sqlalchemy.dialects.postgresql import UUID - - -revision = "c39eb451a683" -down_revision = "7ba0aff64237" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column( - "products", - sa.Column("fraction_units", sa.Unicode(length=255), nullable=False, server_default=""), - ) - product = table( - "products", - column("id", UUID(as_uuid=True)), - column("fraction_units", Unicode(255)), - ) - sku = table( - "stock_keeping_units", - column("product_id", UUID(as_uuid=True)), - column("fraction_units", Unicode(255)), - ) - op.execute( - product.update().values( - fraction_units=select(sku.c.fraction_units).where(sku.c.product_id == product.c.id).limit(1) - ) - ) - - op.drop_index("unique_true_is_default", table_name="stock_keeping_units") - op.drop_column("stock_keeping_units", "is_default") - op.drop_column("stock_keeping_units", "fraction_units") - # ### end Alembic commands ### - - -def downgrade(): - pass diff --git a/brewman/alembic/versions/d6f96b7b16c6_closing_stock.py b/brewman/alembic/versions/d6f96b7b16c6_closing_stock.py deleted file mode 100644 index 71164523..00000000 --- a/brewman/alembic/versions/d6f96b7b16c6_closing_stock.py +++ /dev/null @@ -1,45 +0,0 @@ -"""closing stock - -Revision ID: d6f96b7b16c6 -Revises: c09ff00ec84a -Create Date: 2021-10-12 21:59:28.473737 - -""" -import sqlalchemy as sa - -from alembic import op -from sqlalchemy.dialects import postgresql - - -# revision identifiers, used by Alembic. -revision = "d6f96b7b16c6" -down_revision = "0670868fe171" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table( - "closing_stocks", - sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("date", sa.Date(), nullable=False), - sa.Column("cost_centre_id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("sku_id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("quantity", sa.Numeric(precision=15, scale=2), nullable=False), - sa.ForeignKeyConstraint( - ["cost_centre_id"], ["cost_centres.id"], name=op.f("fk_closing_stocks_cost_centre_id_cost_centres") - ), - sa.ForeignKeyConstraint( - ["sku_id"], ["stock_keeping_units.id"], name=op.f("fk_closing_stocks_sku_id_stock_keeping_units") - ), - sa.PrimaryKeyConstraint("id", name=op.f("pk_closing_stocks")), - sa.UniqueConstraint("date", "cost_centre_id", "sku_id", name=op.f("uq_closing_stocks_date")), - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table("closing_stocks") - # ### end Alembic commands ### diff --git a/brewman/alembic/versions/eed0b382c287_lowercase_fastapi.py b/brewman/alembic/versions/eed0b382c287_lowercase_fastapi.py deleted file mode 100644 index f3fefff1..00000000 --- a/brewman/alembic/versions/eed0b382c287_lowercase_fastapi.py +++ /dev/null @@ -1,280 +0,0 @@ -"""lowercase and fastapi - -Revision ID: eed0b382c287 -Revises: 0bf3d70ee7de -Create Date: 2020-05-10 19:52:58.163810 - -""" -import sqlalchemy as sa - -from alembic import op -from sqlalchemy import column, select, table -from sqlalchemy.dialects import postgresql - - -# revision identifiers, used by Alembic. -revision = "eed0b382c287" -down_revision = "0bf3d70ee7de" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table("msg_subscribers") - op.drop_table("msg_posts") - op.drop_table("msg_threadtags") - op.drop_table("msg_threads") - op.drop_table("msg_tags") - - op.rename_table("auth_roles", "auth_permissions") - with op.batch_alter_table("auth_permissions") as batch_op: - batch_op.alter_column("RoleID", new_column_name="id") - batch_op.alter_column("Name", new_column_name="name") - - op.rename_table("auth_groups", "auth_roles") - with op.batch_alter_table("auth_roles") as batch_op: - batch_op.alter_column("GroupID", new_column_name="id") - batch_op.alter_column("Name", new_column_name="name") - - op.rename_table("auth_rolegroups", "role_permissions") - with op.batch_alter_table("role_permissions") as batch_op: - batch_op.alter_column("RoleGroupID", new_column_name="id") - batch_op.alter_column("RoleID", new_column_name="permission_id") - batch_op.alter_column("GroupID", new_column_name="role_id") - - op.rename_table("auth_usergroups", "user_roles") - with op.batch_alter_table("user_roles") as batch_op: - batch_op.alter_column("UserGroupID", new_column_name="id") - batch_op.alter_column("UserID", new_column_name="user_id") - batch_op.alter_column("GroupID", new_column_name="role_id") - - with op.batch_alter_table("attendances") as batch_op: - batch_op.alter_column("Amount", new_column_name="amount") - batch_op.alter_column("UserID", new_column_name="user_id") - batch_op.alter_column("AttendanceType", new_column_name="attendance_type") - batch_op.alter_column("CreationDate", new_column_name="creation_date") - batch_op.alter_column("Date", new_column_name="date", type_=sa.Date(), nullable=False) - batch_op.alter_column("EmployeeID", new_column_name="employee_id") - batch_op.alter_column("AttendanceID", new_column_name="id") - batch_op.alter_column("IsValid", new_column_name="is_valid") - - with op.batch_alter_table("auth_users") as batch_op: - batch_op.alter_column("UserID", new_column_name="id") - batch_op.alter_column("Name", new_column_name="username") - batch_op.alter_column("Password", new_column_name="password") - batch_op.alter_column("LockedOut", new_column_name="disabled") - - with op.batch_alter_table("batches") as batch_op: - batch_op.alter_column("BatchID", new_column_name="id") - batch_op.alter_column("Discount", new_column_name="discount") - batch_op.alter_column("Name", new_column_name="name", type_=sa.Date(), nullable=False) - batch_op.alter_column("ProductID", new_column_name="product_id") - batch_op.alter_column("QuantityRemaining", new_column_name="quantity_remaining") - batch_op.alter_column("Rate", new_column_name="rate") - batch_op.alter_column("Tax", new_column_name="tax") - - with op.batch_alter_table("cost_centres") as batch_op: - batch_op.alter_column("CostCentreID", new_column_name="id") - batch_op.alter_column("Name", new_column_name="name") - batch_op.alter_column("IsFixture", new_column_name="is_fixture") - - with op.batch_alter_table("product_groups") as batch_op: - batch_op.alter_column("ProductGroupID", new_column_name="id") - batch_op.alter_column("Name", new_column_name="name") - batch_op.alter_column("IsFixture", new_column_name="is_fixture") - - with op.batch_alter_table("inventories") as batch_op: - batch_op.alter_column("InventoryID", new_column_name="id") - batch_op.alter_column("BatchID", new_column_name="batch_id") - batch_op.alter_column("Discount", new_column_name="discount") - batch_op.alter_column("ProductID", new_column_name="product_id") - batch_op.alter_column("Quantity", new_column_name="quantity") - batch_op.alter_column("Rate", new_column_name="rate") - batch_op.alter_column("Tax", new_column_name="tax") - batch_op.alter_column("VoucherID", new_column_name="voucher_id") - - with op.batch_alter_table("journals") as batch_op: - batch_op.alter_column("Amount", new_column_name="amount") - batch_op.alter_column("CostCentreID", new_column_name="cost_centre_id") - batch_op.alter_column("Debit", new_column_name="debit") - batch_op.alter_column("JournalID", new_column_name="id") - batch_op.alter_column("VoucherID", new_column_name="voucher_id") - - with op.batch_alter_table("fingerprints") as batch_op: - batch_op.alter_column("FingerprintID", new_column_name="id") - batch_op.alter_column("Date", new_column_name="date") - batch_op.alter_column("EmployeeID", new_column_name="employee_id") - - with op.batch_alter_table("products") as batch_op: - batch_op.alter_column("ProductID", new_column_name="id") - batch_op.alter_column("Code", new_column_name="code") - batch_op.alter_column("Fraction", new_column_name="fraction") - batch_op.alter_column("FractionUnits", new_column_name="fraction_units") - batch_op.alter_column("IsActive", new_column_name="is_active") - batch_op.alter_column("IsFixture", new_column_name="is_fixture") - batch_op.alter_column("Name", new_column_name="name") - batch_op.alter_column("ProductGroupID", new_column_name="product_group_id") - batch_op.alter_column("ProductYield", new_column_name="product_yield") - batch_op.alter_column("Units", new_column_name="units") - - with op.batch_alter_table("recipes") as batch_op: - batch_op.alter_column("recipe_id", new_column_name="id") - - op.rename_table("salary_deductions", "employee_benefit") - with op.batch_alter_table("employee_benefit") as batch_op: - batch_op.alter_column("SalaryDeductionID", new_column_name="id") - batch_op.alter_column("DaysWorked", new_column_name="days_worked") - batch_op.alter_column("EsiEmployee", new_column_name="esi_employee") - batch_op.alter_column("EsiEmployer", new_column_name="esi_employer") - batch_op.alter_column("GrossSalary", new_column_name="gross_salary") - batch_op.alter_column("JournalID", new_column_name="journal_id") - batch_op.alter_column("PfEmployee", new_column_name="pf_employee") - batch_op.alter_column("PfEmployer", new_column_name="pf_employer") - batch_op.alter_column("VoucherID", new_column_name="voucher_id") - - with op.batch_alter_table("vouchers") as batch_op: - batch_op.alter_column("VoucherID", new_column_name="id") - batch_op.alter_column("date", type_=sa.Date(), nullable=False) - batch_op.alter_column("reconcile_date", type_=sa.Date(), nullable=False) - - op.rename_table("service_charges", "incentives") - - with op.batch_alter_table("employees") as batch_op: - batch_op.alter_column("Designation", new_column_name="designation", nullable=False) - batch_op.alter_column("Salary", new_column_name="salary", nullable=False) - batch_op.alter_column("ServicePoints", new_column_name="points", nullable=False) - batch_op.alter_column( - "JoiningDate", - new_column_name="joining_date", - type_=sa.Date(), - nullable=False, - ) - batch_op.alter_column( - "LeavingDate", - new_column_name="leaving_date", - type_=sa.Date(), - nullable=True, - ) - - with op.batch_alter_table("settings") as batch_op: - batch_op.alter_column("SettingID", new_column_name="id") - batch_op.alter_column("Name", new_column_name="name") - batch_op.alter_column("Data", new_column_name="data") - - op.create_unique_constraint(op.f("uq_accounts_name"), "accounts", ["name"]) - op.drop_constraint("accounts_name_key", "accounts", type_="unique") - op.create_unique_constraint(op.f("uq_auth_clients_code"), "auth_clients", ["code"]) - op.create_unique_constraint(op.f("uq_auth_clients_name"), "auth_clients", ["name"]) - op.drop_constraint("auth_clients_Code_key", "auth_clients", type_="unique") - op.drop_constraint("auth_clients_Name_key", "auth_clients", type_="unique") - op.create_unique_constraint( - op.f("uq_auth_login_history_user_id"), - "auth_login_history", - ["user_id", "client_id", "date"], - ) - op.drop_constraint( - "auth_login_history_user_id_client_id_date_key", - "auth_login_history", - type_="unique", - ) - op.create_unique_constraint(op.f("uq_auth_permissions_name"), "auth_permissions", ["name"]) - op.drop_constraint("auth_roles_Name_key", "auth_permissions", type_="unique") - op.create_unique_constraint(op.f("uq_auth_roles_name"), "auth_roles", ["name"]) - op.drop_constraint("auth_groups_Name_key", "auth_roles", type_="unique") - op.create_unique_constraint(op.f("uq_auth_users_username"), "auth_users", ["username"]) - op.drop_constraint("auth_users_Name_key", "auth_users", type_="unique") - op.create_unique_constraint(op.f("uq_cost_centres_name"), "cost_centres", ["name"]) - op.drop_constraint("entities_costcenters_Name_key", "cost_centres", type_="unique") - op.drop_constraint("uq_employee_id_date", "fingerprints", type_="unique") - op.create_index(op.f("ix_inventories_voucher_id"), "inventories", ["voucher_id"], unique=False) - op.create_unique_constraint(op.f("uq_inventories_voucher_id"), "inventories", ["voucher_id", "batch_id"]) - op.drop_index("ix_inventories_VoucherID", table_name="inventories") - op.create_index(op.f("ix_journals_voucher_id"), "journals", ["voucher_id"], unique=False) - op.drop_index("ix_journals_VoucherID", table_name="journals") - op.create_unique_constraint(op.f("uq_product_groups_name"), "product_groups", ["name"]) - op.drop_constraint("entities_productgroups_Name_key", "product_groups", type_="unique") - op.create_unique_constraint(op.f("uq_products_code"), "products", ["code"]) - op.create_unique_constraint(op.f("uq_products_name"), "products", ["name", "units"]) - op.drop_constraint("products_Code_key", "products", type_="unique") - op.drop_constraint("products_Name_Units_key", "products", type_="unique") - op.create_unique_constraint(op.f("uq_recipe_items_recipe_id"), "recipe_items", ["recipe_id", "product_id"]) - op.drop_constraint("recipe_items_recipe_id_product_id_key", "recipe_items", type_="unique") - op.create_unique_constraint(op.f("uq_settings_name"), "settings", ["name"]) - op.drop_constraint("settings_Name_key", "settings", type_="unique") - op.create_index(op.f("ix_vouchers_date"), "vouchers", ["date"], unique=False) - op.create_foreign_key( - "fk_incentives_journal_id_journals", - "incentives", - "journals", - ["journal_id"], - ["id"], - ) - op.create_foreign_key( - "fk_incentives_voucher_id_vouchers", - "incentives", - "vouchers", - ["voucher_id"], - ["id"], - ) - op.drop_constraint("service_charges_journal_id_fkey", "incentives", type_="foreignkey") - op.drop_constraint("service_charges_voucher_id_fkey", "incentives", type_="foreignkey") - op.create_foreign_key( - "fk_employee_benefit_journal_id_journals", - "employee_benefit", - "journals", - ["journal_id"], - ["id"], - ) - op.create_foreign_key( - "fk_employee_benefit_voucher_id_vouchers", - "employee_benefit", - "vouchers", - ["voucher_id"], - ["id"], - ) - op.drop_constraint( - "entities_salarydeductions_JournalID_fkey", - "employee_benefit", - type_="foreignkey", - ) - op.drop_constraint("salary_deductions_VoucherID_fkey", "employee_benefit", type_="foreignkey") - - permission = table("auth_permissions", column("id", postgresql.UUID()), column("name", sa.String)) - op.execute( - permission.update() - .where(permission.c.name == op.inline_literal("Service Charge")) - .values({"name": op.inline_literal("Incentive")}) - ) - op.execute( - permission.update() - .where(permission.c.name == op.inline_literal("Salary Deduction")) - .values({"name": op.inline_literal("Employee Benefit")}) - ) - account = table("accounts", column("name", sa.String)) - op.execute( - account.update() - .where(account.c.name == op.inline_literal("Service Charges")) - .values({"name": op.inline_literal("Incentives")}) - ) - # Remove unneeded Payment and Receipt permissions - permission = table("auth_permissions", column("id", postgresql.UUID()), column("name", sa.String)) - role_permission = table( - "role_permissions", - column("permission_id", postgresql.UUID()), - column("role_id", postgresql.UUID()), - ) - op.execute( - role_permission.delete().where( - role_permission.c.permission_id.in_( - select([permission.c.id], permission.c.name.in_(["Payment", "Receipt"])) - ) - ) - ) - op.execute(permission.delete().where(permission.c.name.in_(["Payment", "Receipt"]))) - - # ### end Alembic commands ### - - -def downgrade(): - raise Exception("Irreversible migration") diff --git a/brewman/alembic/versions/ef630341157b_recipe_period.py b/brewman/alembic/versions/ef630341157b_recipe_period.py deleted file mode 100644 index 33a7b276..00000000 --- a/brewman/alembic/versions/ef630341157b_recipe_period.py +++ /dev/null @@ -1,70 +0,0 @@ -"""Recipe period - -Revision ID: ef630341157b -Revises: 0bfb24f16ef2 -Create Date: 2022-07-27 16:02:25.375687 - -""" -import uuid -from alembic import op -import sqlalchemy as sa -from sqlalchemy import column, func, table, text -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'ef630341157b' -down_revision = '0bfb24f16ef2' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('periods', - sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.Column('valid_from', sa.Date(), nullable=False), - sa.Column('valid_till', sa.Date(), nullable=False), - sa.PrimaryKeyConstraint('id', name=op.f('pk_periods')) - ) - p = table( - "periods", - column("id", postgresql.UUID()), - column("valid_from", sa.Date()), - column("valid_till", sa.Date()), - ) - op.create_exclude_constraint( - "uq_periods_valid_from", - "periods", - (func.daterange(p.c.valid_from, p.c.valid_till, text("'[]'")), "&&"), - ) - op.execute( - p.insert().values( - id='76662d3f-d5ef-4d51-bbca-909d0b0242d9', - valid_from="01-Oct-2021", - valid_till="31-Oct-2021", - ) - ) - r = table( - "recipes", - column("period_id", postgresql.UUID()), - ) - op.add_column('recipes', sa.Column('period_id', postgresql.UUID(as_uuid=True), nullable=True)) - op.execute(r.update().values(period_id='76662d3f-d5ef-4d51-bbca-909d0b0242d9')) - op.alter_column("recipes", "period_id", existing_type=postgresql.UUID(), nullable=False) - op.drop_constraint("uq_recipes_sku_id", "recipes", type_="unique") - op.create_unique_constraint(op.f('uq_recipes_sku_id'), 'recipes', ['sku_id', 'period_id']) - op.create_foreign_key(op.f('fk_recipes_period_id_periods'), 'recipes', 'periods', ['period_id'], ['id']) - op.drop_column('recipes', 'valid_till') - op.drop_column('recipes', 'valid_from') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('recipes', sa.Column('valid_from', sa.DATE(), autoincrement=False, nullable=False)) - op.add_column('recipes', sa.Column('valid_till', sa.DATE(), autoincrement=False, nullable=False)) - op.drop_constraint(op.f('fk_recipes_period_id_periods'), 'recipes', type_='foreignkey') - op.drop_constraint(op.f('uq_recipes_sku_id'), 'recipes', type_='unique') - op.drop_column('recipes', 'period_id') - op.drop_table('periods') - # ### end Alembic commands ### diff --git a/brewman/brewman/main.py b/brewman/brewman/main.py index 78a7d2a6..d206ce19 100644 --- a/brewman/brewman/main.py +++ b/brewman/brewman/main.py @@ -5,7 +5,6 @@ from starlette.middleware.sessions import SessionMiddleware from .core.config import settings from .db.base import Base # noqa: F401 - from .routers import ( account, account_types, diff --git a/brewman/brewman/models/client.py b/brewman/brewman/models/client.py index 956d260e..39a224b1 100644 --- a/brewman/brewman/models/client.py +++ b/brewman/brewman/models/client.py @@ -18,7 +18,7 @@ from .login_history import LoginHistory class Client(Base): __tablename__ = "clients" - id: uuid.UUID = Column("client_id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) + id: uuid.UUID = Column("id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) code: int = Column("code", Integer, unique=True, nullable=False) name: str = Column("name", Unicode(255), unique=True, nullable=False) enabled: bool = Column("enabled", Boolean, nullable=False) diff --git a/brewman/brewman/models/login_history.py b/brewman/brewman/models/login_history.py index 9896c721..b5a98e49 100644 --- a/brewman/brewman/models/login_history.py +++ b/brewman/brewman/models/login_history.py @@ -23,12 +23,12 @@ if TYPE_CHECKING: class LoginHistory(Base): __tablename__ = "login_history" __table_args__ = (UniqueConstraint("user_id", "client_id", "date"),) - id: uuid.UUID = Column("login_history_id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) + id: uuid.UUID = Column("id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) user_id: uuid.UUID = Column("user_id", UUID(as_uuid=True), ForeignKey("users.id"), nullable=False) client_id: uuid.UUID = Column( "client_id", UUID(as_uuid=True), - ForeignKey("clients.client_id"), + ForeignKey("clients.id"), nullable=False, ) date: datetime.datetime = Column("date", DateTime(), nullable=False) diff --git a/brewman/brewman/models/recipe_item.py b/brewman/brewman/models/recipe_item.py index cc388915..14c32c07 100644 --- a/brewman/brewman/models/recipe_item.py +++ b/brewman/brewman/models/recipe_item.py @@ -21,7 +21,7 @@ class RecipeItem(Base): __tablename__ = "recipe_items" __table_args__ = (UniqueConstraint("recipe_id", "product_id"),) - id: uuid.UUID = Column("recipe_item_id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) + id: uuid.UUID = Column("id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) recipe_id: uuid.UUID = Column("recipe_id", UUID(as_uuid=True), ForeignKey("recipes.id"), nullable=False) product_id: uuid.UUID = Column("product_id", UUID(as_uuid=True), ForeignKey("products.id"), nullable=False) quantity: Decimal = Column("quantity", Numeric(precision=15, scale=2), nullable=False) diff --git a/brewman/brewman/scripts/initializedb.py b/brewman/brewman/scripts/initializedb.py deleted file mode 100644 index 721bc0f9..00000000 --- a/brewman/brewman/scripts/initializedb.py +++ /dev/null @@ -1,196 +0,0 @@ -# user = User("Admin", "123456", False, uuid.UUID("8de98592-76d9-c74d-bb3f-d6184d388b5a")) -# dbsession.add(user) -# -# groups = [ -# Group("Owner", uuid.UUID("52e08c0c-048a-784f-be10-6e129ad4b5d4")), -# Group("Accountant", uuid.UUID("bc4c2d23-437a-984d-abd4-7d5fce677547")), -# Group("Accounts Manager", uuid.UUID("cfc44fa7-3392-5b45-b311-5959333f568f")), -# ] -# -# for group in groups: -# dbsession.add(group) -# user.groups.append(group) -# -# roles = [ -# Role("Attendance", uuid.UUID("09d05434-a09a-fa45-963b-769a2e3fc667")), -# Role("Trial Balance", uuid.UUID("3b099fec-ddc5-4243-b30e-afb78d9ca14a")), -# Role("Cash Flow", uuid.UUID("c4d3ae29-420b-ea4c-ae90-00a356263fd9")), -# Role("Cost Centres", uuid.UUID("6fcc1a20-6aec-e840-b334-1632b34aeab8")), -# Role("Users", uuid.UUID("c5b7d9d7-f178-0e45-8ea4-bf4e08ec901b")), -# Role("Daybook", uuid.UUID("c3edb554-a057-8942-8030-37b8e926d583")), -# Role( -# "Edit Posted Vouchers", -# uuid.UUID("d6675817-ddf5-bf40-9de6-fa223eb4aaa6"), -# ), -# Role("Employees", uuid.UUID("e4edd0ac-7f5d-e64d-8611-73fdc4cd8ba2")), -# Role("Fingerprints", uuid.UUID("d9c45323-f997-ba46-9407-8a7145f0828b")), -# Role("Issue", uuid.UUID("03b602eb-f58a-b94f-af58-8cb47d7849d0")), -# Role("Journal", uuid.UUID("7661388f-62ce-1c41-8e0d-0326ee5d4018")), -# Role("Accounts", uuid.UUID("f438262f-72dd-2f4e-9186-5abc3af44fba")), -# Role("Product Ledger", uuid.UUID("018a2408-e804-1446-90c5-b015829da6ba")), -# Role("Backdated Vouchers", uuid.UUID("b67b2062-5ca7-134f-8258-5d284dd92426")), -# Role("Payment", uuid.UUID("f85c0b52-c3fd-7141-8957-7a56cdc014a4")), -# Role("Post Vouchers", uuid.UUID("36e741da-1a57-b047-a59e-dcd58fcf4338")), -# Role("Products", uuid.UUID("74fa6d21-eebb-e14c-8153-bebc57190ab4")), -# Role("Product Groups", uuid.UUID("08413a22-cf88-fd43-b2b7-365d2951d99f")), -# Role("Profit & Loss", uuid.UUID("0492ebb3-76f3-204e-ab94-bbfe880f0691")), -# Role("Purchase", uuid.UUID("12335acb-8630-2d41-a191-1517c8d172de")), -# Role("Purchase Entries", uuid.UUID("78a6422b-aa11-174c-9dfa-412a99e87e02")), -# Role("Purchase Return", uuid.UUID("ab33196e-d9e4-114c-ac8c-997954363756")), -# Role("Receipt", uuid.UUID("1f1ce53e-76ff-a346-974a-65db6f606e5f")), -# Role("Recipes", uuid.UUID("ffb7fb65-d42c-424d-9ff1-45069e3b4a29")), -# Role("Closing Stock", uuid.UUID("97515732-24e4-c94d-9585-d4bd7f6c7891")), -# Role("Ledger", uuid.UUID("a2120944-243f-3f49-be57-0ad633ce4801")), -# Role("Raw Material Cost", uuid.UUID("d462842b-baf1-2343-95e5-ffdba9bbc163")), -# Role( -# "Edit Other User's Vouchers", -# uuid.UUID("a8328891-7ce2-a943-8c29-2eabc1ffeea3"), -# ), -# Role("Clients", uuid.UUID("cfad44f0-f2a9-7045-89d7-9019cf0f371a")), -# Role("Employee Benefit", uuid.UUID("92d70e80-1c32-384d-959e-abf84b804696")), -# Role("Messages", uuid.UUID("f586d128-b6d9-4090-a913-78fcbdb68e59")), -# Role("Lock Date", uuid.UUID("d52de0be-9388-4b0b-a359-7e122ab6e53a")), -# Role("Net Transactions", uuid.UUID("2c40f7cf-67fc-4efa-a670-8d16a2e7884d")), -# Role("Balance Sheet", uuid.UUID("40deb018-b8f2-460a-88be-8972c9fcdf04")), -# Role("Advanced Delete", uuid.UUID("197ebcd2-bc4a-4b65-a138-ce942ece32ea")), -# Role("Rebase", uuid.UUID("de204a88-5f9d-4579-a2d6-aa2f25efde42")), -# Role("Reset Stock", uuid.UUID("aecaf82f-aa41-4634-b754-0c1308b621b1")), -# Role("Reconcile", uuid.UUID("a5cb51cb-e38e-4705-84a7-cc1e9a8b866b")), -# Role("Stock Movement", uuid.UUID("20b707ee-2b59-41ad-be87-76d5fe1efca8")), -# Role("Purchases", uuid.UUID("cf7019c8-3fd3-45b0-9a42-601029ce5b71")), -# Role("Dashboard", uuid.UUID("53eecc09-bd06-4890-b6f5-6885dda762d4")), -# Role("Incentive", uuid.UUID("99b56390-96c2-4f3d-8b0f-5ae3c868594f")), -# Role("Maintenance", uuid.UUID("770532e4-21de-4712-8a6b-4ff9fd63a503")), -# ] -# -# for role in roles: -# dbsession.add(role) -# groups[0].roles.append(role) -# -# cost_centres = [ -# CostCentre("Overall", uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), True), -# CostCentre("Purchase", uuid.UUID("7b845f95-dfef-fa4a-897c-f0baf15284a3"), True), -# CostCentre("Kitchen", uuid.UUID("b2d398ce-e3cc-c542-9feb-5d7783e899df"), True), -# ] -# -# for cost_centre in cost_centres: -# dbsession.add(cost_centre) -# -# accounts = [ -# Account( -# 1, -# "All Purchases", -# 2, -# False, -# True, -# False, -# uuid.UUID("7b845f95-dfef-fa4a-897c-f0baf15284a3"), -# uuid.UUID("240dd899-c413-854c-a7eb-67a29d154490"), -# True, -# ), -# Account( -# 1, -# "Local Purchase", -# 9, -# False, -# True, -# False, -# uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), -# uuid.UUID("d2b75912-505f-2548-9093-466dfff6a0f9"), -# True, -# ), -# Account( -# 1, -# "ESI/PF - Payable", -# 11, -# False, -# True, -# False, -# uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), -# uuid.UUID("42277912-cc18-854b-b134-9f4b00dba419"), -# True, -# ), -# Account( -# 2, -# "ESI/PF - Expense", -# 7, -# False, -# True, -# False, -# uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), -# uuid.UUID("d2a1a286-e900-764b-a1a5-9f4b00dbb940"), -# True, -# ), -# Account( -# 1, -# "Cash in Hand", -# 1, -# False, -# True, -# False, -# uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), -# uuid.UUID("ed2341bb-80b8-9649-90db-f9aaca183bb3"), -# True, -# ), -# Account( -# 1, -# "Staff Salary", -# 7, -# False, -# True, -# False, -# uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), -# uuid.UUID("5c2b54d0-c174-004d-a0d5-92cdaadcefa7"), -# True, -# ), -# Account( -# 2, -# "Incentives", -# 11, -# False, -# True, -# False, -# uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), -# uuid.UUID("b7eff754-e8ba-e047-ab06-9132c15c7640"), -# True, -# ), -# Account( -# 1, -# "Suspense", -# 4, -# False, -# True, -# False, -# uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), -# uuid.UUID("3854e317-6f3b-5142-ab26-9c44d4cddd08"), -# True, -# ), -# ] -# -# for account in accounts: -# dbsession.add(account) -# -# product_group = ProductGroup("Suspense", uuid.UUID("ae59a20c-87bb-444a-8abb-915ad5e58b83"), True) -# dbsession.add(product_group) -# -# dbsession.add(ProductGroup("Semi", uuid.UUID("e6bf81b9-1e9b-499f-81d5-ab5662e9d9b1"), True)) -# dbsession.add(ProductGroup("Menu Items", uuid.UUID("dad46805-f577-4e5b-8073-9b788e0173fc"), True)) -# -# product = Product( -# 1, -# "Suspense", -# "", -# 1, -# "", -# 1, -# uuid.UUID("ae59a20c-87bb-444a-8abb-915ad5e58b83"), -# uuid.UUID("240dd899-c413-854c-a7eb-67a29d154490"), -# 0, -# 0, -# False, -# False, -# False, -# uuid.UUID("aa79a643-9ddc-4790-ac7f-a41f9efb4c15"), -# True, -# ) -# dbsession.add(product)