32 lines
No EOL
830 B
Python
32 lines
No EOL
830 B
Python
from fastapi import APIRouter, HTTPException, status
|
|
|
|
from app.core.database import Conexao
|
|
from app.v1.modules.escrituracao.models.modelo_notas import NotasHolmesInput
|
|
from app.v1.modules.escrituracao.service import NotasDespesas
|
|
|
|
escrituracao_router = APIRouter(
|
|
prefix='/escrituracao'
|
|
)
|
|
|
|
# Rota que recebe a nota do Holmes e grava na PD_HOLMES_APOLLO
|
|
@escrituracao_router.post(
|
|
path='/notas_despesas'
|
|
)
|
|
def inserir_nota_despesas(
|
|
dados_nota_holmes: NotasHolmesInput,
|
|
conexao: Conexao,
|
|
):
|
|
|
|
repo = NotasDespesas(conexao)
|
|
|
|
try:
|
|
acao = repo.inserir_nota_despesas(dados_nota_holmes)
|
|
except ValueError as erro:
|
|
raise HTTPException(
|
|
status_code= status.HTTP_422_UNPROCESSABLE_ENTITY,
|
|
detail= str(erro)
|
|
)
|
|
|
|
return {
|
|
'mensagem': f'Nota {acao}'
|
|
} |