diff --git a/.gitignore b/.gitignore index 40edb316..1a496fab 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,4 @@ venv */__pycache__/ .idea/ *.egg-info/ -brewman/static/ -brewman/static/node_modules -brewman/static/app/**/*.js -brewman/static/app/**/*.map -brewman/static/package-lock.json +frontend \ No newline at end of file diff --git a/bc2f5ea0c0d7_my_test.py b/bc2f5ea0c0d7_my_test.py deleted file mode 100644 index 7a018ba0..00000000 --- a/bc2f5ea0c0d7_my_test.py +++ /dev/null @@ -1,378 +0,0 @@ -"""my test - -Revision ID: bc2f5ea0c0d7 -Revises: -Create Date: 2020-05-10 18:18:15.377295 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'bc2f5ea0c0d7' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('salary_deductions') - op.drop_table('auth_clients') - op.drop_table('auth_usergroups') - op.drop_index('ix_inventories_VoucherID', table_name='inventories') - op.drop_table('inventories') - op.drop_table('employees') - op.drop_table('msg_threadtags') - op.drop_table('fingerprints') - op.drop_table('products') - op.drop_table('cost_centres') - op.drop_table('attendances') - op.drop_table('product_groups') - op.drop_table('accounts') - op.drop_table('recipe_items') - op.drop_table('auth_users') - op.drop_table('msg_subscribers') - op.drop_table('auth_roles') - op.drop_table('msg_tags') - op.drop_table('images') - op.drop_table('vouchers') - op.drop_table('msg_threads') - op.drop_table('auth_rolegroups') - op.drop_table('batches') - op.drop_index('ix_journals_VoucherID', table_name='journals') - op.drop_table('journals') - op.drop_table('service_charges') - op.drop_table('recipes') - op.drop_table('settings') - op.drop_table('auth_login_history') - op.drop_table('auth_groups') - op.drop_table('msg_posts') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('msg_posts', - sa.Column('PostID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Content', sa.VARCHAR(length=1000), autoincrement=False, nullable=False), - sa.Column('CreationDate', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), - sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['ThreadID'], ['msg_threads.ThreadID'], name='msg_posts_ThreadID_fkey'), - sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='msg_posts_UserID_fkey'), - sa.PrimaryKeyConstraint('PostID', name='msg_posts_pkey') - ) - op.create_table('auth_groups', - sa.Column('GroupID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('GroupID', name='auth_groups_pkey'), - sa.UniqueConstraint('Name', name='auth_groups_Name_key'), - postgresql_ignore_search_path=False - ) - op.create_table('auth_login_history', - sa.Column('login_history_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('client_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['client_id'], ['auth_clients.client_id'], name='auth_login_history_client_id_fkey'), - sa.ForeignKeyConstraint(['user_id'], ['auth_users.UserID'], name='auth_login_history_user_id_fkey'), - sa.PrimaryKeyConstraint('login_history_id', name='auth_login_history_pkey'), - sa.UniqueConstraint('user_id', 'client_id', 'date', name='auth_login_history_user_id_client_id_date_key') - ) - op.create_table('settings', - sa.Column('SettingID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('Data', postgresql.BYTEA(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('SettingID', name='settings_pkey'), - sa.UniqueConstraint('Name', name='settings_Name_key') - ) - op.create_table('recipes', - sa.Column('recipe_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('product_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('quantity', sa.NUMERIC(), autoincrement=False, nullable=False), - sa.Column('cost_price', sa.NUMERIC(), autoincrement=False, nullable=False), - sa.Column('sale_price', sa.NUMERIC(), autoincrement=False, nullable=False), - sa.Column('notes', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('valid_from', sa.DATE(), autoincrement=False, nullable=False), - sa.Column('valid_to', sa.DATE(), autoincrement=False, nullable=False), - sa.Column('effective_from', sa.DATE(), autoincrement=False, nullable=False), - sa.Column('effective_to', sa.DATE(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['product_id'], ['products.ProductID'], name='recipes_product_id_fkey'), - sa.PrimaryKeyConstraint('recipe_id', name='recipes_pkey'), - postgresql_ignore_search_path=False - ) - op.create_table('service_charges', - sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('voucher_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('journal_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('days_worked', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('points', sa.NUMERIC(precision=5, scale=2), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['journal_id'], ['journals.JournalID'], name='service_charges_journal_id_fkey'), - sa.ForeignKeyConstraint(['voucher_id'], ['vouchers.VoucherID'], name='service_charges_voucher_id_fkey'), - sa.PrimaryKeyConstraint('id', name='service_charges_pkey') - ) - op.create_table('journals', - sa.Column('JournalID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Debit', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('Amount', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('account_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('CostCentreID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['CostCentreID'], ['cost_centres.CostCentreID'], name='entities_journals_CostCenterID_fkey'), - sa.ForeignKeyConstraint(['VoucherID'], ['vouchers.VoucherID'], name='journals_VoucherID_fkey'), - sa.ForeignKeyConstraint(['account_id'], ['accounts.id'], name='journals_account_id_fkey'), - sa.PrimaryKeyConstraint('JournalID', name='entities_journals_pkey'), - postgresql_ignore_search_path=False - ) - op.create_index('ix_journals_VoucherID', 'journals', ['VoucherID'], unique=False) - op.create_table('batches', - sa.Column('BatchID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('ProductID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('QuantityRemaining', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('Rate', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('Tax', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('Discount', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['ProductID'], ['products.ProductID'], name='batches_ProductID_fkey'), - sa.PrimaryKeyConstraint('BatchID', name='entities_batches_pkey'), - postgresql_ignore_search_path=False - ) - op.create_table('auth_rolegroups', - sa.Column('RoleGroupID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('RoleID', postgresql.UUID(), autoincrement=False, nullable=True), - sa.Column('GroupID', postgresql.UUID(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['GroupID'], ['auth_groups.GroupID'], name='auth_rolegroups_GroupID_fkey'), - sa.ForeignKeyConstraint(['RoleID'], ['auth_roles.RoleID'], name='auth_rolegroups_RoleID_fkey'), - sa.PrimaryKeyConstraint('RoleGroupID', name='auth_rolegroups_pkey') - ) - op.create_table('msg_threads', - sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Title', sa.VARCHAR(length=1000), autoincrement=False, nullable=False), - sa.Column('CreationDate', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Priority', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('Public', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('Closed', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='msg_threads_UserID_fkey'), - sa.PrimaryKeyConstraint('ThreadID', name='msg_threads_pkey'), - sa.UniqueConstraint('Title', name='msg_threads_Title_key'), - postgresql_ignore_search_path=False - ) - op.create_table('vouchers', - sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), - sa.Column('narration', sa.VARCHAR(length=1000), autoincrement=False, nullable=False), - sa.Column('creation_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.Column('last_edit_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.Column('voucher_type', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('is_posted', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('poster_id', postgresql.UUID(), autoincrement=False, nullable=True), - sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('is_reconciled', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('reconcile_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), - sa.Column('is_starred', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['poster_id'], ['auth_users.UserID'], name='vouchers_poster_id_fkey'), - sa.ForeignKeyConstraint(['user_id'], ['auth_users.UserID'], name='vouchers_user_id_fkey'), - sa.PrimaryKeyConstraint('VoucherID', name='vouchers_pkey'), - postgresql_ignore_search_path=False - ) - op.create_table('images', - sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('resource_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('resource_type', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('image', postgresql.BYTEA(), autoincrement=False, nullable=False), - sa.Column('thumbnail', postgresql.BYTEA(), autoincrement=False, nullable=False), - sa.Column('creation_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('id', name='images_pkey') - ) - op.create_table('msg_tags', - sa.Column('TagID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', sa.VARCHAR(length=100), autoincrement=False, nullable=False), - sa.Column('CssClass', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('TagID', name='msg_tags_pkey'), - sa.UniqueConstraint('Name', name='msg_tags_Name_key'), - postgresql_ignore_search_path=False - ) - op.create_table('auth_roles', - sa.Column('RoleID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('RoleID', name='auth_roles_pkey'), - sa.UniqueConstraint('Name', name='auth_roles_Name_key') - ) - op.create_table('msg_subscribers', - sa.Column('SubscriberID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Read', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['ThreadID'], ['msg_threads.ThreadID'], name='msg_subscribers_ThreadID_fkey'), - sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='msg_subscribers_UserID_fkey'), - sa.PrimaryKeyConstraint('SubscriberID', name='msg_subscribers_pkey'), - sa.UniqueConstraint('ThreadID', 'UserID', name='msg_subscribers_ThreadID_UserID_key') - ) - op.create_table('auth_users', - sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('Password', sa.VARCHAR(length=60), autoincrement=False, nullable=True), - sa.Column('LockedOut', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('UserID', name='auth_users_pkey'), - sa.UniqueConstraint('Name', name='auth_users_Name_key'), - postgresql_ignore_search_path=False - ) - op.create_table('recipe_items', - sa.Column('recipe_item_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('recipe_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('product_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('quantity', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('price', sa.INTEGER(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['product_id'], ['products.ProductID'], name='recipe_items_product_id_fkey'), - sa.ForeignKeyConstraint(['recipe_id'], ['recipes.recipe_id'], name='recipe_items_recipe_id_fkey'), - sa.PrimaryKeyConstraint('recipe_item_id', name='recipe_items_pkey'), - sa.UniqueConstraint('recipe_id', 'product_id', name='recipe_items_recipe_id_product_id_key') - ) - op.create_table('accounts', - sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('type', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('account_type', sa.VARCHAR(length=50), autoincrement=False, nullable=False), - sa.Column('is_starred', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('is_reconcilable', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('cost_centre_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('is_fixture', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['cost_centre_id'], ['cost_centres.CostCentreID'], name='accounts_cost_centre_id_fkey'), - sa.PrimaryKeyConstraint('id', name='accounts_pkey'), - sa.UniqueConstraint('name', name='accounts_name_key'), - postgresql_ignore_search_path=False - ) - op.create_table('product_groups', - sa.Column('ProductGroupID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('IsFixture', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('ProductGroupID', name='entities_productgroups_pkey'), - sa.UniqueConstraint('Name', name='entities_productgroups_Name_key'), - postgresql_ignore_search_path=False - ) - op.create_table('attendances', - sa.Column('AttendanceID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('EmployeeID', postgresql.UUID(), autoincrement=False, nullable=True), - sa.Column('Date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('AttendanceType', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('Amount', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('CreationDate', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=True), - sa.Column('IsValid', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['EmployeeID'], ['employees.id'], name='entities_attendances_EmployeeID_fkey'), - sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='entities_attendances_UserID_fkey'), - sa.PrimaryKeyConstraint('AttendanceID', name='entities_attendances_pkey') - ) - op.create_table('cost_centres', - sa.Column('CostCentreID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('IsFixture', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('CostCentreID', name='entities_costcenters_pkey'), - sa.UniqueConstraint('Name', name='entities_costcenters_Name_key'), - postgresql_ignore_search_path=False - ) - op.create_table('products', - sa.Column('ProductID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('Units', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('Fraction', sa.NUMERIC(), autoincrement=False, nullable=False), - sa.Column('FractionUnits', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('ProductYield', sa.NUMERIC(), autoincrement=False, nullable=False), - sa.Column('ProductGroupID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('account_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('cost_price', sa.NUMERIC(), autoincrement=False, nullable=False), - sa.Column('sale_price', sa.NUMERIC(), autoincrement=False, nullable=False), - sa.Column('IsActive', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('IsFixture', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('is_purchased', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('is_sold', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['ProductGroupID'], ['product_groups.ProductGroupID'], name='products_ProductGroupID_fkey'), - sa.ForeignKeyConstraint(['account_id'], ['accounts.id'], name='products_account_id_fkey'), - sa.PrimaryKeyConstraint('ProductID', name='products_pkey'), - sa.UniqueConstraint('Code', name='products_Code_key'), - sa.UniqueConstraint('Name', 'Units', name='products_Name_Units_key'), - postgresql_ignore_search_path=False - ) - op.create_table('fingerprints', - sa.Column('FingerprintID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('EmployeeID', postgresql.UUID(), autoincrement=False, nullable=True), - sa.Column('Date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['EmployeeID'], ['employees.id'], name='entities_fingerprints_EmployeeID_fkey'), - sa.PrimaryKeyConstraint('FingerprintID', name='entities_fingerprints_pkey'), - sa.UniqueConstraint('EmployeeID', 'Date', name='uq_employee_id_date') - ) - op.create_table('msg_threadtags', - sa.Column('ThreadTagID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('TagID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['TagID'], ['msg_tags.TagID'], name='msg_threadtags_TagID_fkey'), - sa.ForeignKeyConstraint(['ThreadID'], ['msg_threads.ThreadID'], name='msg_threadtags_ThreadID_fkey'), - sa.PrimaryKeyConstraint('ThreadTagID', name='msg_threadtags_pkey'), - sa.UniqueConstraint('ThreadID', 'TagID', name='msg_threadtags_ThreadID_TagID_key') - ) - op.create_table('employees', - sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Designation', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('Salary', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('ServicePoints', sa.NUMERIC(precision=5, scale=2), autoincrement=False, nullable=True), - sa.Column('JoiningDate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('LeavingDate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['id'], ['accounts.id'], name='employees_id_fkey'), - sa.PrimaryKeyConstraint('id', name='entities_employees_pkey') - ) - op.create_table('inventories', - sa.Column('InventoryID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('ProductID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('BatchID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('Quantity', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('Rate', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('Tax', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.Column('Discount', sa.NUMERIC(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['BatchID'], ['batches.BatchID'], name='entities_inventories_BatchID_fkey'), - sa.ForeignKeyConstraint(['ProductID'], ['products.ProductID'], name='inventories_ProductID_fkey'), - sa.ForeignKeyConstraint(['VoucherID'], ['vouchers.VoucherID'], name='inventories_VoucherID_fkey'), - sa.PrimaryKeyConstraint('InventoryID', name='entities_inventories_pkey') - ) - op.create_index('ix_inventories_VoucherID', 'inventories', ['VoucherID'], unique=False) - op.create_table('auth_usergroups', - sa.Column('UserGroupID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=True), - sa.Column('GroupID', postgresql.UUID(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['GroupID'], ['auth_groups.GroupID'], name='auth_usergroups_GroupID_fkey'), - sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='auth_usergroups_UserID_fkey'), - sa.PrimaryKeyConstraint('UserGroupID', name='auth_usergroups_pkey') - ) - op.create_table('auth_clients', - sa.Column('client_id', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('enabled', sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column('otp', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('creation_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('client_id', name='auth_clients_pkey'), - sa.UniqueConstraint('code', name='auth_clients_Code_key'), - sa.UniqueConstraint('name', name='auth_clients_Name_key') - ) - op.create_table('salary_deductions', - sa.Column('SalaryDeductionID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('JournalID', postgresql.UUID(), autoincrement=False, nullable=False), - sa.Column('GrossSalary', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('DaysWorked', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('EsiEmployee', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('PfEmployee', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('EsiEmployer', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('PfEmployer', sa.INTEGER(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['JournalID'], ['journals.JournalID'], name='entities_salarydeductions_JournalID_fkey'), - sa.ForeignKeyConstraint(['VoucherID'], ['vouchers.VoucherID'], name='salary_deductions_VoucherID_fkey'), - sa.PrimaryKeyConstraint('SalaryDeductionID', name='entities_salarydeductions_pkey') - ) - # ### end Alembic commands ### diff --git a/brewman/routers/voucher.py b/brewman/routers/voucher.py index c27d986e..4570c631 100644 --- a/brewman/routers/voucher.py +++ b/brewman/routers/voucher.py @@ -51,9 +51,7 @@ def get_db() -> Session: @router.post("/post-voucher/{id_}", response_model=output.Voucher) def post_voucher( - id_: uuid.UUID, - db: Session = Depends(get_db), - user: UserToken = Security(get_user, scopes=["post-vouchers"]), + id_: uuid.UUID, db: Session = Depends(get_db), user: UserToken = Security(get_user, scopes=["post-vouchers"]), ): try: voucher: Voucher = db.query(Voucher).filter(Voucher.id == id_).first() @@ -70,8 +68,7 @@ def post_voucher( except Exception: db.rollback() raise HTTPException( - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, - detail=traceback.format_exc(), + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=traceback.format_exc(), ) @@ -89,15 +86,14 @@ def check_delete_permissions(voucher: Voucher, user: UserToken): ) elif voucher_type not in user.permissions: raise HTTPException( - status_code=status.HTTP_403_FORBIDDEN, detail=f"You are not allowed ({VoucherType.by_id(voucher.type).name}) vouchers", + status_code=status.HTTP_403_FORBIDDEN, + detail=f"You are not allowed ({VoucherType.by_id(voucher.type).name}) vouchers", ) @router.delete("/delete/{id_}") def delete_voucher( - id_: uuid.UUID, - db: Session = Depends(get_db), - user: UserToken = Security(get_user), + id_: uuid.UUID, db: Session = Depends(get_db), user: UserToken = Security(get_user), ): voucher: Voucher = db.query(Voucher).filter(Voucher.id == id_).first() images = db.query(DbImage).filter(DbImage.resource_id == voucher.id).all() @@ -139,9 +135,7 @@ def delete_voucher( .scalar() ) if uses > 0: - raise ValueError( - f"{item.product.name} has been issued and cannot be deleted" - ) + raise ValueError(f"{item.product.name} has been issued and cannot be deleted") batches_to_delete.append(item.batch) elif voucher.type == VoucherType.by_name("Purchase Return").id: for item in voucher.inventories: @@ -216,9 +210,7 @@ def voucher_info(voucher, db): } ) for item in voucher.incentives: - employee = ( - db.query(Employee).filter(Employee.id == item.journal.account_id).first() - ) + employee = db.query(Employee).filter(Employee.id == item.journal.account_id).first() json_voucher["incentives"].append( { "employeeId": item.journal.account_id, @@ -230,9 +222,7 @@ def voucher_info(voucher, db): } ) if len(json_voucher["incentives"]) > 0: - json_voucher["incentive"] = next( - x.amount for x in voucher.journals if x.account_id == Account.incentive_id() - ) + json_voucher["incentive"] = next(x.amount for x in voucher.journals if x.account_id == Account.incentive_id()) for item in voucher.inventories: text = f"{item.product.name} ({item.product.units}) {item.batch.quantity_remaining:.2f}@{item.batch.rate:.2f} from {item.batch.name.strftime('%d-%b-%Y')}" json_voucher["inventories"].append( @@ -256,16 +246,19 @@ def voucher_info(voucher, db): "tax": item.batch.tax, "discount": item.batch.discount, "rate": item.batch.rate, - "product": { - "id": item.batch.product.id, - "name": item.batch.product.full_name, - }, + "product": {"id": item.batch.product.id, "name": item.batch.product.full_name,}, }, } ) images = db.query(DbImage).filter(DbImage.resource_id == voucher.id).all() for image in images: - json_voucher["files"].append({"id": image.id, "resized": f"/db-image/{image.id}/resized", "thumbnail": f"/db-image/{image.id}/thumbnail"}) + json_voucher["files"].append( + { + "id": image.id, + "resized": f"/db-image/{image.id}/resized", + "thumbnail": f"/db-image/{image.id}/thumbnail", + } + ) return json_voucher @@ -290,11 +283,7 @@ def blank_voucher(info, db): elif type_ == "Payment": account = None if info and "account" in info and info["account"]: - account = ( - db.query(AccountBase) - .filter(AccountBase.id == uuid.UUID(info["account"])) - .first() - ) + account = db.query(AccountBase).filter(AccountBase.id == uuid.UUID(info["account"])).first() if account is not None: account = {"id": account.id, "name": account.name} else: @@ -303,11 +292,7 @@ def blank_voucher(info, db): elif type_ == "Receipt": account = None if info and "account" in info and info["account"]: - account = ( - db.query(AccountBase) - .filter(AccountBase.id == uuid.UUID(info["account"])) - .first() - ) + account = db.query(AccountBase).filter(AccountBase.id == uuid.UUID(info["account"])).first() if account is not None: account = {"id": account.id, "name": account.name} else: @@ -317,9 +302,7 @@ def blank_voucher(info, db): json_voucher["vendor"] = AccountBase.local_purchase() elif type_ == "Purchase Return": - json_voucher["journals"].append( - {"account": AccountBase.local_purchase(), "amount": 0, "debit": 1} - ) + json_voucher["journals"].append({"account": AccountBase.local_purchase(), "amount": 0, "debit": 1}) elif type_ == "Issue": if "source" in info: json_voucher["source"] = {"id": info["source"]} @@ -332,9 +315,7 @@ def blank_voucher(info, db): elif type_ == "Employee Benefit": json_voucher["employeeBenefits"] = [] elif type_ == "Incentive": - json_voucher["incentives"], json_voucher["incentive"] = incentive_employees( - info["date"], db - ) + json_voucher["incentives"], json_voucher["incentive"] = incentive_employees(info["date"], db) else: raise ValueError(f'Voucher of type "{type_}" does not exist.') json_voucher["files"] = [] @@ -390,22 +371,12 @@ def incentive_employees(date_, db: Session): def check_voucher_lock_info(voucher_date: Optional[date], data_date: date, db: Session): start, finish = get_lock_info(db) - if ( - start is not None - and start > data_date - or voucher_date is not None - and start > voucher_date - ): + if start is not None and start > data_date or voucher_date is not None and start > voucher_date: raise HTTPException( status_code=status.HTTP_423_LOCKED, detail=f"Vouchers before {start.strftime('%d-%b-%Y')} have been locked.", ) - elif ( - finish is not None - and finish < data_date - or voucher_date is not None - and finish < voucher_date - ): + elif finish is not None and finish < data_date or voucher_date is not None and finish < voucher_date: raise HTTPException( status_code=status.HTTP_423_LOCKED, detail=f"Vouchers after {finish.strftime('%d-%b-%Y')} have been locked.", @@ -425,14 +396,9 @@ def check_voucher_lock_info(voucher_date: Optional[date], data_date: date, db: S def check_voucher_edit_allowed(voucher: Voucher, user: UserToken): if voucher.posted and "edit-posted-vouchers" not in user.permissions: raise HTTPException( - status_code=status.HTTP_403_FORBIDDEN, - detail="You are not allowed to edit posted vouchers", + status_code=status.HTTP_403_FORBIDDEN, detail="You are not allowed to edit posted vouchers", ) - elif ( - voucher.user_id != user.id_ - and "edit-other-user's-vouchers" not in user.permissions - ): + elif voucher.user_id != user.id_ and "edit-other-user's-vouchers" not in user.permissions: raise HTTPException( - status_code=status.HTTP_403_FORBIDDEN, - detail="You are not allowed to edit other user's vouchers", + status_code=status.HTTP_403_FORBIDDEN, detail="You are not allowed to edit other user's vouchers", )