Fix: ValueErrors should be HTTPException
This commit is contained in:
parent
9ecf0b5cc9
commit
7baf79c3fa
|
@ -1,7 +1,7 @@
|
|||
from datetime import date, datetime, timedelta
|
||||
|
||||
from barker.core.config import settings
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.sql.expression import func
|
||||
|
||||
|
@ -35,7 +35,10 @@ def beer_consumption(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
day = func.date_trunc(
|
||||
"day", Voucher.date - timedelta(minutes=settings.NEW_DAY_OFFSET_MINUTES)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import date, datetime, timedelta
|
||||
|
||||
from barker.core.config import settings
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ...core.security import get_current_active_user as get_user
|
||||
|
@ -34,7 +34,10 @@ def bill_details(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
return {
|
||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||
|
|
|
@ -2,7 +2,7 @@ import uuid
|
|||
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
from sqlalchemy import distinct
|
||||
from sqlalchemy.orm import Session, joinedload
|
||||
|
||||
|
@ -37,7 +37,10 @@ def active_cashiers(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
users = (
|
||||
db.query(User)
|
||||
|
@ -72,7 +75,10 @@ def show_id(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
vouchers = (
|
||||
db.query(Voucher)
|
||||
|
@ -130,7 +136,10 @@ def show_blank(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
return {
|
||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import date, datetime, timedelta
|
||||
|
||||
from barker.core.config import settings
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
@ -45,7 +45,10 @@ def discount_report_view(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
return {
|
||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import date, datetime, timedelta
|
||||
|
||||
from barker.core.config import settings
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
@ -44,7 +44,10 @@ def product_sale_report_view(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
return {
|
||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import date, datetime, timedelta
|
||||
|
||||
from barker.core.config import settings
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
@ -45,7 +45,10 @@ def get_sale_analysis(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
return {
|
||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import date, datetime, timedelta
|
||||
|
||||
from barker.core.config import settings
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
@ -35,7 +35,10 @@ def get_tax_report(
|
|||
if (
|
||||
date.today() - start_date
|
||||
).days > 5 and "accounts-audit" not in user.permissions:
|
||||
raise ValueError("Accounts Audit")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Accounts Audit",
|
||||
)
|
||||
|
||||
return {
|
||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||
|
|
|
@ -11,10 +11,9 @@ from barker.models import (
|
|||
VoucherType,
|
||||
)
|
||||
from barker.schemas.receive_payment import ReceivePaymentItem as SettleSchema
|
||||
from fastapi import HTTPException
|
||||
from fastapi import HTTPException, status
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
from starlette import status
|
||||
|
||||
|
||||
def get_tax(tax, voucher_type):
|
||||
|
|
Loading…
Reference in New Issue