feat: tags for expenses, filters by tags in statistics
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
from fastapi import APIRouter, Depends
 | 
			
		||||
 | 
			
		||||
from backend.dependecies import SessionDependency, CurrentUserDependency, PaginationDependency
 | 
			
		||||
from schemas.expense import GetAllExpensesResponse, UpdateExpenseResponse, UpdateExpenseRequest, DeleteExpenseResponse
 | 
			
		||||
from schemas.expense import *
 | 
			
		||||
from services.auth import authorized_user
 | 
			
		||||
from services.expenses import ExpensesService
 | 
			
		||||
 | 
			
		||||
@@ -12,6 +12,8 @@ expense_router = APIRouter(
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# region Expenses
 | 
			
		||||
 | 
			
		||||
@expense_router.get(
 | 
			
		||||
    '/get-all',
 | 
			
		||||
    operation_id='get_all_expenses',
 | 
			
		||||
@@ -47,3 +49,55 @@ async def delete_expense(
 | 
			
		||||
        expense_id: int,
 | 
			
		||||
):
 | 
			
		||||
    return await ExpensesService(session).delete_expense(expense_id)
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Expense tags
 | 
			
		||||
 | 
			
		||||
@expense_router.get(
 | 
			
		||||
    '/get-all-tags',
 | 
			
		||||
    operation_id='get_all_expense_tags',
 | 
			
		||||
    response_model=GetAllExpenseTagsResponse,
 | 
			
		||||
)
 | 
			
		||||
async def get_all(
 | 
			
		||||
        session: SessionDependency,
 | 
			
		||||
):
 | 
			
		||||
    return await ExpensesService(session).get_all_tags()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@expense_router.post(
 | 
			
		||||
    '/create-tag',
 | 
			
		||||
    operation_id='create_expense_tag',
 | 
			
		||||
    response_model=UpdateExpenseTagResponse,
 | 
			
		||||
)
 | 
			
		||||
async def update_expense(
 | 
			
		||||
        session: SessionDependency,
 | 
			
		||||
        request: CreateExpenseTagRequest,
 | 
			
		||||
):
 | 
			
		||||
    return await ExpensesService(session).create_tag(request)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@expense_router.post(
 | 
			
		||||
    '/update-tag',
 | 
			
		||||
    operation_id='update_expense_tag',
 | 
			
		||||
    response_model=UpdateExpenseTagResponse,
 | 
			
		||||
)
 | 
			
		||||
async def update_expense(
 | 
			
		||||
        session: SessionDependency,
 | 
			
		||||
        request: UpdateExpenseTagRequest,
 | 
			
		||||
):
 | 
			
		||||
    return await ExpensesService(session).update_tag(request)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@expense_router.delete(
 | 
			
		||||
    '/delete-tag/{tag_id}',
 | 
			
		||||
    operation_id='delete_expense_tag',
 | 
			
		||||
    response_model=DeleteExpenseTagResponse,
 | 
			
		||||
)
 | 
			
		||||
async def update_expense(
 | 
			
		||||
        session: SessionDependency,
 | 
			
		||||
        tag_id: int,
 | 
			
		||||
):
 | 
			
		||||
    return await ExpensesService(session).delete_tag(tag_id)
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
		Reference in New Issue
	
	Block a user